Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

About the default precision of exponential part when read/write

FortCpp
Beginner
626 Views

The intel fortran compiler works a bit different on Linux and Windows. When read/write a double precision number in its scientific notation without specifying the format, I got different result.

If I just use write(file_out, '(E20.12)')mynumber,

on Linux, the result is 0.000000000000e+00

on Windows the result is 0.000000000000e+000

 

Is there a way for change the default exponential digits? I mean still use write(file_out, '(E20.12)')mynumber, not change my code to write(file_out, '(E20.12E3)')mynumber.

I am compiling some of my old code on windows, this will save me a lot of trouble. I cannot find a answer. Please tell me how to do it. Thanks.

0 Kudos
2 Replies
Steven_L_Intel1
Employee
626 Views

No, it doesn't work differently on Windows and Linux - at least it isn't supposed to. You won't get E+000 unless you use a Ew.dE3 format.

E20.2 will give you E+nn or +nnn if the exponent is three digits - this is specified by the Fortran standard. You may want to look at the G0 or G0.d formats that will use the minimum field width necessary to represent the value.

0 Kudos
FortCpp
Beginner
626 Views

Thanks Steve.

I could not reproduce my previous result within a new project. Yes you are right about the fortran output format. I'll try to find where the problem is located.

0 Kudos
Reply