This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
on unformatted read
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 31 May 2011 17:38:53 +0200
- Subject: on unformatted read
Dear all.
I came across an inconsistency between compilers in the handling of
unformatted reads and I wonder if this is intended.
Please consider:
$ cat listread.for
INTEGER, PARAMETER :: nPhases = 4
INTEGER :: I, jConn(nPhases)
jConn = -1
read (*,*) (jConn(I), I=1, nPhases)
write (*,*) jConn
end
$ ifort -warn all -g listread.for && ./a.out
1 2 3.0 4
1 2 3 4
$ gfortran -Wall -W -g listread.for && ./a.out
1 2 3.0 4
At line 7 of file listread.for (unit = 5, file = 'stdin')
Fortran runtime error: Bad integer for item 3 in list input
Above error is given by various versions of gfortran, from 4.3 to
latest svn. Anecdote has it that g77 treated floating point values
like ifort does in above output, but I don't have g77 available for
testing. Can gfortran be coaxed into convert real values to integer on
such a read? I'd appreciate if someone could comment which behaviour
would be "the right one" and why?
Thanks
Daniel