From: Helmut Vincke (Helmut.Vincke@cern.ch)
Date: Thu Jul 19 2007 - 13:20:29 CEST
Dear Alberto
Thanks for the answer and the Fortran format lecture.
With all due respect but you have obviously missed my point. An ASCII
file is seen as an interface between computers and human beings. When it
comes to numbers in the "computer to human communication", the only
standard which can be applied is the mathematical standard. There it
makes a big difference if we have "6.4308-100", which is -93.57 or if we
have 6.4308E-100 which was most likely the number the computer wanted to
communicate to me.
Hence my suggestion would be to sort out such funny numbers by something
like:
IF (number.GT. 0.0001E-99) THEN
WRITE(*,'(E10.4) Number
ELSE
WRITE(*,'(E10.3E3) Number
ENDIF
Then also other non fortran programs and even human beings can read it
the way the computer wanted them to understand it.
Best regards
Helmut
-----Original Message-----
From: Alberto Fasso' [mailto:fasso@slac.stanford.edu]
Sent: Thursday, July 19, 2007 11:27 AM
To: Helmut Vincke
Cc: fluka-discuss@fluka.org
Subject: Re: Strange output format
Hi Helmut,
> During an activation calculation I encountered a result in the ASCII
> output file which was "6.4308-100". I think I am not the first who had
> such a result and therefore I found it worth being discussed in the
> discussion list.
>
> I assume it should be "6.4308E-100"
No, it is correct according to the Fortran standard. See it in
http://www.fortran.com/fortran/F77_std/rjcnf0001-sh-13.html#sh-13.2.1 :
The Ew.d, Dw.d, and Ew.dEe edit descriptors indicate that the external
field occupies w positions, the fractional part of which consists of d
digits, unless a scale factor greater than one is in effect, and the
exponent part consists of e digits. The e has no effect on input. The
form of the output field for a scale factor of zero is:
[+] [0] . x x ...x exp
* where: + signifies a plus or a minus ( 13.5.9)
..........
* exp is a decimal exponent, one of the following forms:
For a descriptor Ew.d: form of the exponent E+z1z2 or +0z1z2 (!!!) (if
|exp|<=99)
+z1z2z3 (if 99<|exp|<=999) (note that this is your
case) For a descriptor Ew.dEe: form of the exponent +z1z2z3 or
E+z1z2...ze For a descriptor Dw.d: form of the exponent D+z1z2 or E+z1z2
or +z1z2 (if
|exp|<=99)
+z1z2z3 (if 99<|exp|<=999) (your case) where z is
a digit. The sign in the exponent is required. A plus sign must be used
if the exponent value is zero.
As you can see, the form "6.4308E-100" that you suggest, cannot be used
if the descriptor is of the type Dw.d or Ew.d. It could be used with
Ew.dE3, but this form is very rare in my experience.
> In post processing programs it could cause troubles. Either it is seen
> as expression and the result is seen as -93.57, or the program
crashes.
> In the first case it might even go unnoticed resulting in bad results.
Only if your post processing program is not in Fortran. For a Fortran
post processing program, there can be no problem.
Alberto
This archive was generated by hypermail 2.1.6 : Thu Jul 19 2007 - 14:22:25 CEST