[Bug fortran/42901] New: reading array of structures from namelist fails
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 INTEGERNUMBER ! 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
[Bug fortran/19362] ICE in fold_convert, at fold-const.c:1998
--- Additional Comments From arnold dot moene at wur dot nl 2005-04-07 22:44 --- The following (4 files :( ) example from the WRF weather model seems to be related. I can't see if it is really triggered by the same bug: prompt cat ESMF_TimeInterval.f module ESMF_TimeIntervalMod implicit none private type ESMF_TimeInterval sequence ! match C++ storage order integer:: YR ! calendar interval number of days end type public ESMF_TimeInterval end module ESMF_TimeIntervalMod prompt cat ESMF_Time.f module ESMF_TimeMod use ESMF_TimeIntervalMod implicit none private type ESMF_Time sequence integer :: DD end type public ESMF_Time public operator(+) private ESMF_TimeInc interface operator(+) module procedure ESMF_TimeInc end interface contains function ESMF_TimeInc(time, timeinterval) type(ESMF_Time) :: ESMF_TimeInc type(ESMF_Time), intent(in) :: time type(ESMF_TimeInterval), intent(in) :: timeinterval ! Do nothing end function ESMF_TimeInc end module ESMF_TimeMod prompt cat ESMF_Alarm.f module ESMF_AlarmMod use ESMF_TimeIntervalMod, only : ESMF_TimeInterval use ESMF_TimeMod, only : ESMF_Time implicit none type ESMF_Alarm sequence type(ESMF_TimeInterval) :: RingInterval type(ESMF_Time) :: PrevRingTime end type ESMF_Alarm public ESMF_Alarm end module ESMF_AlarmMod prompt cat ESMF_Clock.f module ESMF_ClockMod use ESMF_AlarmMod contains subroutine ESMF_ClockAdvance() use ESMF_TimeMod type(ESMF_Alarm) :: alarm alarm%PrevRingTime = alarm%PrevRingTime + alarm%RingInterval end subroutine ESMF_ClockAdvance end module ESMF_ClockMod Attempt to compile gives: prompt gfortran -c ESMF_TimeInterval.f ESMF_Time.f ESMF_Alarm.f ESMF_Clock.f Warning: ESMF_TimeInterval.f:6: Line is being truncated ESMF_Time.f: In function 'esmf_timeinc': ESMF_Time.f:12: warning: unused variable 'timeinterval' ESMF_Time.f:12: warning: unused variable 'time' ESMF_Time.f:12: warning: Function return value not set ESMF_Time.f:12: warning: control reaches end of non-void function ESMF_Clock.f: In function 'esmf_clockadvance': ESMF_Clock.f:7: internal compiler error: in fold_convert, at fold-const.c:2002 Please submit a full bug report, with preprocessed source if appropriate. See URL:http://gcc.gnu.org/bugs.html for instructions. gfortran is recently downloaded prebuilt version: prompt gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc/configure --enable-languages=c,f95 --prefix=/home/work/gfortran/build/irun Thread model: posix gcc version 4.1.0 20050314 (experimental) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19362