This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]