Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this a compiler bug or my mistake while writing a small data to a file?

1 view
Skip to first unread message

hitlu...@gmail.com

unread,
Mar 19, 2009, 9:19:46 AM3/19/09
to
Dear all,

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.

Ron Shepard

unread,
Mar 19, 2009, 11:06:00 AM3/19/09
to
In article
<b7a03706-b527-47d7...@x1g2000prh.googlegroups.com>,
"hitlu...@gmail.com" <hitlu...@gmail.com> wrote:

> 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

baf

unread,
Mar 19, 2009, 11:06:46 AM3/19/09
to

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.

jfh

unread,
Mar 19, 2009, 4:50:46 PM3/19/09
to
On Mar 20, 4:06 am, Ron Shepard <ron-shep...@NOSPAM.comcast.net>
wrote:
> In article
> <b7a03706-b527-47d7-a527-5f510b45f...@x1g2000prh.googlegroups.com>,

ES and E the wrong way round: use es18.7e3 not e18.7es3 for example

John Harper

hitluckyfox

unread,
Mar 20, 2009, 12:13:01 AM3/20/09
to

I have understood the rule.

Cheers!

Thank Ron, baf and John very much, !

Ron Shepard

unread,
Mar 20, 2009, 12:42:28 AM3/20/09
to
In article
<0c758b17-bbd7-49d7...@v35g2000pro.googlegroups.com>,
jfh <john....@vuw.ac.nz> wrote:

> 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

0 new messages