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

Badly Formatted Output

mattsdad
Beginner
925 Views

I have a small routine that I am using to generate parameters for a table that is going into another piece of code. Some of the numbers are more than 10**100 (or less than 10**-100) which creates an odd output. I am using D25.16 and getting something like0.21501611+101 which does not have the D in it.

Is there a way to specify the D format so that it will put the D in, even when the order of magnitude has more than two digits?

0 Kudos
4 Replies
TimP
Honored Contributor III
925 Views
Use E format, with exponent width specified, e.g. E26.16e5, standard since 30 years ago. G, EN, and ES formats also accept exponent width specification. Sorry, you have to accept the E instead of D if you want to do this by a standard format. It's in the E and D editing section of ifort .chm help file.
0 Kudos
jimdempseyatthecove
Honored Contributor III
925 Views

I have had problems where if the text in the file contains E format that the input parser reads into an E temp (real(4)) eventhough you may be reading into a double (real(8)) float. When this happens precision is lost.

The poster wanted the output text file to contain D for use later when file is re-read.

I suppose as a hack one could write to an internal file (character string) and then replace E with D.

Jim

0 Kudos
Jugoslav_Dujic
Valued Contributor II
925 Views
Jim, I think you have a misconception (if I read your post correctly). For the purpose of READing, it doesn't matter at all whether the input string is in E or D format. Actually, D format is totally superfluous, and (as far as I can tell) it doesn't carry any additional semantics compared with E, and is effectively obsolescent (though not declared as such in the Fortran standard).

The behavior mattsdad described (D or E omitted when exponent is greater than 99) is in the VF reference manual and prescribed as such in the Fortran Standard (10.6.1.2.2, "E and D editing"). Thus, nothing to worry about.


0 Kudos
mattsdad
Beginner
925 Views
The E format works fine. Thanks
0 Kudos
Reply