I find an output problem while I write some data to a file and
need your help.
I am using Intel Visual Fortran (IVF) with the Version IA-32
11.0.061. When I write a formatted small data smaller than 1.0d-100 to
a text file, I find that the sign "d" or "e" disappear, for example,
data 0.256415163d-199 will result in 0.25641516-199, while it is ok
for the data bigger than . I find the same problem in IVF with some
version IA-32 10.*.*. I do not know how to explain and solve it. Is
this a bug of this compiler or my mistake?
A small example for my question is shown as follows,
---------------------------------------------
program main
implicit none
real*8 aa,bb
aa=0.256415163d-199
bb=0.256415163d-99
open(101,file='test.dat')
write(101,*) 'aa='
write(101,'(1d18.8)'),aa
write(101,*)'bb='
write(101,'(1d18.8)') bb
pause
end program main
--------------------------------------------
And the result is given in the file "test.dat":
aa=
0.25641516-199
bb=
0.25641516D-99
Thank you very much for your help.
> I am using Intel Visual Fortran (IVF) with the Version IA-32
> 11.0.061. When I write a formatted small data smaller than 1.0d-100 to
> a text file, I find that the sign "d" or "e" disappear, for example,
> data 0.256415163d-199 will result in 0.25641516-199, while it is ok
> for the data bigger than . I find the same problem in IVF with some
> version IA-32 10.*.*. I do not know how to explain and solve it. Is
> this a bug of this compiler or my mistake?
It is neither a bug in the compiler nor a mistake on your part.
This is the standard way that floating point numbers with
three-digit exponents are written. The default format has two-digit
exponents, so obviously that would not work for numbers with more
digits in the exponents. You can control this with a format like
e18.7es3 or something similar (unless you really want that leading
zero to be printed, then you would use e18.8e3). If you want only a
single exponent digit, then you could use e18.7es1.
Or you could just keep using the default format. It works correctly
for both input and output, so there is nothing wrong with it.
$.02 -Ron Shepard
The output is exactly as it is suppose to be. The width of the output
field for the exponent (including the letter "E" or "D" ) when using E
and D edit descriptors is 4 columns wide. If the exponent itself needs
4 columns (such as a negative sign and a 3-digit exponent), the letter
"E" or "D" gets dropped.
ES and E the wrong way round: use es18.7e3 not e18.7es3 for example
John Harper
Cheers!
Thank Ron, baf and John very much, !
> ES and E the wrong way round: use es18.7e3 not e18.7es3 for example
Yep, that's right, I typed faster than I thought.
$.02 -Ron Shepard