RE: Strange output format

From: Alberto Fasso' (fasso@SLAC.Stanford.EDU)
Date: Thu Jul 19 2007 - 13:59:11 CEST

  • Next message: Markus Brugger: "RE: crash with no error"

    Dear Helmut,

    Maybe I missed your point, but you had spoken about a "post processing
    program", not about a human being. For a post processing program,
    provided that, as Fluka, it is written in Fortran, that expression
    is straightforward.
    May I add that it is straightforward also to any human being like
    me, who has spent a life reading Fortran output?
    Concerning "6.4308-100", which is -93.57, that is true IN A PROGRAM
    (and indeed the "E" or "D" must be present in a program statement),
    but it is not true in output! Have you ever seen an output containing
    arithmetic expressions needing to be evaluated?

    Now, I don't remember if you were talking about the main Fluka output
    or about an output from a tool such as usbsuw, ustsuw etc. In the latter case,
    you could make the modification yourself, but it does not need to be
    as complicated as you suggest. Just replace in the FORMAT expression
    E11.4 by E11.4E3 (see my "Fortran format lecture"...).
    If you were referring instead to the main output, I am afraid that
    the number of places where the modification must be made is so large
    that it would require a considerable effort. Is it really necessary?
    I can assure you that you can get used to it very quickly, just as
    many thousands of Fortran programmers have done in the past 50 years.
    Even the notation "E" is not at all a "mathematical standard" as you seem to
    think, but just a Fortran convention that later has been adopted by other
    programming languages.


    On Thu, 19 Jul 2007, Helmut Vincke wrote:

    > 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' []
    > Sent: Thursday, July 19, 2007 11:27 AM
    > To: Helmut Vincke
    > Cc:
    > 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
    > :
    > 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

    Alberto FassÚ
    SLAC-RP, MS 48, 2575 Sand Hill Road, Menlo Park CA 94025
    Phone: (1 650) 926 4762   Fax: (1 650) 926 3569

  • Next message: Markus Brugger: "RE: crash with no error"

    This archive was generated by hypermail 2.1.6 : Thu Jul 19 2007 - 14:23:26 CEST