Formatted read question

From: Steven G. Kargl (kargl_at_troutmask.apl.washington.edu)
Date: 12/28/04


Date: Tue, 28 Dec 2004 20:27:50 +0000 (UTC)

Gang,

What is the "correct" behavior for a conforming compiler
with following code

      program a
      character*15 b
      real x
      b = 'E+00'
      read(b,'(E15.8)') x
      print *, x
      end

My interpretation of the standard and what a compiler should
do is at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19155

g77 gives
troutmask:kargl[218] f77 -o a a.f
troutmask:kargl[219] ./a
  0.

gfortran gives
troutmask:kargl[220] gfc -o a a.f
troutmask:kargl[221] ./a
At line 5 of file a.f
Fortran runtime error: Bad value during floating point read

NAG's FreeBSD compiler agrees with gfortran.

-- 
Steve
http://troutmask.apl.washington.edu/~kargl/

Quantcast