[Bug fortran/42901] New: reading array of structures from namelist fails
arnold dot moene at wur dot nl
gcc-bugzilla@gcc.gnu.org
Fri Jan 29 21:41:00 GMT 2010
Reading a namelist that contains a variable that is an array of structures
fails. Whatever the index of the array element, the values that are read are
assigned to the first array element.
Below a more or less minimal example:
------------
PROGRAM test_nml
! Start declarations
! Struct with one member
TYPE FIELD_DESCR
INTEGER NUMBER ! number
END TYPE
! Array of structs
TYPE FSETUP
TYPE (FIELD_DESCR), DIMENSION(3) :: VEL ! 3 velocity components
END TYPE
!Actual variable
TYPE (FSETUP) FIELD_SETUP
!Namelist
NAMELIST /NL_SETUP/ FIELD_SETUP
! End of declarations
! Reading succeeds, but only fills struct of first array element
READ(*,NML=NL_SETUP)
! Show failure
WRITE(*,NML=NL_SETUP)
END PROGRAM test_nml
------------
If fed with the following namelist:
------------
&NL_SETUP
FIELD_SETUP%VEL(1)%NUMBER= 3,
FIELD_SETUP%VEL(2)%NUMBER= 9,
FIELD_SETUP%VEL(3)%NUMBER= 27,
/
------------
The resulting output is:
------------
&NL_SETUP
FIELD_SETUP%VEL(1)%NUMBER= 27,
FIELD_SETUP%VEL(2)%NUMBER= 0,
FIELD_SETUP%VEL(3)%NUMBER=-1209668170, /
------------
At least ifort knows how to deal with this correctly.
--
Summary: reading array of structures from namelist fails
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: arnold dot moene at wur dot nl
GCC host triplet: Linux localhost 2.6.27.19-desktop586-1mnb
GCC target triplet: i586-manbo-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42901
More information about the Gcc-bugs
mailing list