J3/01-339 Subject: Writing zero in list directed and namelist I/O From: Richard Bleikamp To: J3 Date: 23rd August 2001 History: Robert Corbett asked in F95 interpretation 000067 how zero is formatted when writing via list directed and namelist I/O. He noted that F90 "fixed" a problem when the G edit descriptor was changed (compared to F77) to use an F edit descriptor (instead of E) when a zero value was written with the G edit descriptor. He asked if the lack of a similar change for list directed and namelist I/O was intentional or an oversight. My recollection is that the control and I/O subgroup intended to make the similar fix for namelist and list directed I/O, but forgot to do so. The reasons why F90 chose to change the behavior of the G edit descriptor apply equally well to namelist and list directed I/O, namely, the typical user would prefer to see 0.0 instead of 0.0000E+00. I observe that some implementations have a flag to control how zero is printed by the G edit descriptor, so that users can obtain the F77 behavior. I suspect the same flag will be used to control list directed and namelist formatting of zero in the same way, so that users who want the F77 style of output can get it (mostly so they can "diff" output of test suites against expected results). The following edits, against 01-007r2, change the behavior of list directed and namelist output of real and complex datatype values of zero to use an F edit descriptor style of formatting, rather than an E/D edit descriptor style of formatting. EDITS: [3:23+] Add the following as the last paragraph of section 1.5.1 "List directed and namelist output statements produce a real literal constant zero for a real value that is zero, and for the real or imaginary part of a complex value that is zero. In this standard, these real literal constants are produced with the effect of an F edit descriptor. Previous standards produced such constants with the effect of an E edit descriptor." [223:34] in section 10.9.2 (List-directed output), fifth paragraph, change "If the magnitude x is within this range" to "If the magnitude x is within this range or is zero" [228:33] in section 10.10.2.1 (Namelist output editing), third paragraph, change "If the magnitude x is within this range" to "If the magnitude x is within this range or is zero" End of Edits