[Bug libfortran/37707] New: Namelist read of array of derived type incorrect
toon at moene dot indiv dot nluug dot nl
gcc-bugzilla@gcc.gnu.org
Wed Oct 1 21:01:00 GMT 2008
The following program:
type s
integer m
integer n
end type s
type(s) :: a(3)
character*80 :: l = ' &namlis a%m=1,2, a%n=5,6, /'
namelist /namlis/ a
a%m=[87,88,89]
a%n=[97,98,99]
print*,a%m
print*,a%n
read(l,namlis)
write(*,namlis)
end
prints:
87 88 89
97 98 99
At line 12 of file nl.f90
Fortran runtime error: Cannot match namelist object name 2
The error condition is bogus. According to the Fortran 2003 Standard, subclause
10.10.1.2 (third paragraph):
"When the name in the input record represents an array variable or a variable
of derived type, the effect is as if the variable represented where expanded
into a sequence of scalar list items of intrinsic data types, in the same way
that formatted input/output list items are expanded."
In other words: a%m has to be read in in the same way as it has to be written
out. That means that the original namelist read above should assign 1 to a(1)%m
and 2 to a(2)%m and nothing (i.e., not change the value of a(3)%m) and, mutatis
mutandis, for a(..)%n.
--
Summary: Namelist read of array of derived type incorrect
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: toon at moene dot indiv dot nluug dot nl
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37707
More information about the Gcc-bugs
mailing list