output format dependent on standard?
Tobias Burnus
burnus@net-b.de
Sun Aug 5 20:36:00 GMT 2007
Daniel Franke wrote:
> Is there any specific reason for this switch in formatting if -std=f95?
> $> gfortran-svn -std=f95 print.f90 && ./a.out
> 0.0000000E+00 0.1000000
> $> gfortran-svn -std=f2003 print.f90 && ./a.out
> 0.000000 0.1000000
>
I think the only reason is that "0.0" looks nicer than "0.0e+00"; maybe
Toon or Richard Maine remembers.
The Fortran 95 standard has in "10.8.2 List-directed output"
"Real constants are produced with the effect of either an F edit
descriptor or an E edit descriptor, depending on the magnitude x of the
value and a range 10^d1 <= x < 10^d2, where d1 and d2 are
processor-dependent integers. If the magnitude x is within this range,
the constant is produced using 0PFw.d; otherwise, 1PEw.dEe is used."
And Fortran 2003 has in "10.9.2 List-directed output":
"Real constants are produced with the effect of either an F edit
descriptor or an E edit descriptor, depending on the magnitude x of the
value and a range 10^d1 <= x < 10^d2 , where d1 and d2 are processor
dependent integers. If the magnitude x is within this range or is zero,
the constant is produced using 0PFw.d; otherwise, 1PEw.d Ee is used."
Do you see the extra "or is zero" in the second standard? Thus Fortran
2003 compilers need to produce "0.0" (with a "reasonable
processor-dependent values for w, d, and e"). I don't see why Fortran
95 compilers used E format, but seemingly all compilers did.
> Is there any specific reason for this switch in formatting if -std=f95?
For gfortran: Well, good question. The other compilers I know simply changed from E to F format without any backward option.
Tobias
More information about the Fortran
mailing list