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

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.



Mon, 05 Sep 2011 21:19:46 GMT  
 Is this a compiler bug or my mistake while writing a small data to a file?
In article

Quote:

>     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



Mon, 05 Sep 2011 23:06:00 GMT  
 Is this a compiler bug or my mistake while writing a small data to a file?

Quote:

> 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.

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.


Mon, 05 Sep 2011 23:06:46 GMT  
 Is this a compiler bug or my mistake while writing a small data to a file?


Quote:
> In article


> >     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

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

John Harper



Tue, 06 Sep 2011 04:50:46 GMT  
 Is this a compiler bug or my mistake while writing a small data to a file?

I have understood the rule.

Cheers!

Thank Ron, baf and John very much, !



Tue, 06 Sep 2011 12:13:01 GMT  
 Is this a compiler bug or my mistake while writing a small data to a file?
In article

Quote:

> 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



Tue, 06 Sep 2011 12:42:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Problem when writing unformatted data to file using Intel Fortran Compiler

2. i would like to write several small files to one file

3. Weird behaviour of file.write() (no data written)?

4. Reading a binary file / writing binary data to a file

5. purging file buffers - to make new data be written to file

6. Reading and then Writing to a file - small newbie question - please

7. I am wishing to read quickbooks data files with C5.5

8. chop-up large data files into smaller ones with heading

9. indexed file format and data files- for cobol compilers

10. Small File Selector bug on 95

11. small announcement: File/Directory Handling for supported Eiffel-Compilers

12. Inserting data and writing files

 

 
Powered by phpBB® Forum Software