PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

bug in fortran 90 namelist, and/or bad standard

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Emilia Solano



Joined: 06 Apr 2006
Posts: 3

PostPosted: Mon Jan 12, 2009 8:07 am    Post subject: bug in fortran 90 namelist, and/or bad standard Reply with quote

In fortran 90 namelists allocatable arrays are not permited (alas), but type-derived structures are.

Given a structured variable such as, for instance

example%index=1
example%name="filename"
example%array=0., 0.

pgf90 can read the namelist correctly, but writes it out in an expected way:

&NAMELIST_INPUT
EXAMPLE = 1,
"filename ",
0.000000 ,
0.000000
/

The output of the namelist is no longer human-friendly, as the variable names are not fully spelled out.

Admitedly, the f90 standard specifies that the output should be
variable_name= values
without specifying that the variable name should include the component name when the variable has a structure.

Both Intel and gfortran deal with namelist output in the form fortran programmers would consider natural, and write the output namelist as
example%index=1
example%name="filename"
example%array=0., 0.

Is there an option or switch in the pgf90 compilor that would produce the desired behaviour?

Or do we report this as a pgf90 bug?

Below is a simple test code displaying this behaviour.
Code:
program namelist_test
     implicit none
      type ExampleTyp
       integer             :: index
       character(len=20)  :: name
       real, dimension(2) :: array
      end type ExampleTyp
     type (ExampleTyp)   :: example
     namelist/namelist_input/example
     example%index=1
     example%name="wrong"
     example%array=1.
     open(unit=22,status='new',file='fort.22')
     write (22,namelist_input)
     close(22)
     open(unit=10,status='old',file='fort.10')
     read (10,namelist_input)
     close(10)
     open(unit=21,status='new',file='fort.21',DELIM="quote")
     write (21,namelist_input)
     close(21)
end program namelist_test


The input file is fort.10:
Code:
 &namelist_input
  example%index=1,
  example%name="filename"
  example%array=2*0.0
 / !end namelist_input
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Mon Jan 12, 2009 5:17 pm    Post subject: Reply with quote

Hi Emilia,

As far as I can tell, the Fortran standard allows either method. So long as the compiler can read in the same format as it outputs, it's fine. However, since I'm not an expert on the intricacies of the standard, I sent the question to our compiler engineers. I also added a feature request (TPR#15480) for a flag that will output derived types in the same format as Intel and Gfortran.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group