Output of very small numbers with e, en format is goofed up


The following code (compiled with either pgf90 or pgf77)
shows the problem I’ve encountered:

      real*8 wow
      wow = 1d-120
      write(*,*) wow
      write(*,900) wow
  900 format(1x,e15.7)

The output is


Note that the format using ‘e15.7’ (the second number output) is missing the ‘E’. This creates problems for me, and I don’t think it’s the correct behaviour. Am I out to lunch?

Hi Tuna,

The E edit descriptor by default is limited to 3 digits plus a sign (4 characters in total). This limit causes the truncation of exponent field and the removal of the ‘E’ when the exponent reaches 100. To have the ‘E’ printed, you need to use the second form of the E descriptor, ‘Ew.dEe’ where you specify the number of exponent digits to print. Changing your format to ‘e15.7e3’ will allow enough room for the ‘E’ to print.

  • Mat

Thanks much, that did the trick. I have not come upon the this form of the e format descriptor, but this seems to work with g, e, and en. My fortran 90 book has only listing of the 2nd e as a possiblility, but no description as to what it actually does.

This fixes the code for me. Thanks again