Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

G Editing

The G data edit descriptor for generalized editing can be used for input or output with any intrinsic type. It takes the following forms:

Gw

Gw.d

Gw.dEe

where w is the total field width, d is the number of places after the decimal point, and e is the number of digits in the exponent.

If w is 0, the field width is selected by the processor. If w is zero, you can only specify forms G0 or G0.d.

If w is nonzero, d must be specified.

If e is present and zero, the exponent part contains the minimal number of digits needed to represent the exponent. For integer, character, and logical data types d and e are ignored.

When used to specify I/O for integer data, the Gw, Gw.d and Gw.dEe edit descriptors follow the rules for Iw editing.

When used to specifiy I/O for logical data, the Gw.d and Gw.dEe edit descriptors with nonzero w follow the rules for Lw editing. On output, if w is 0, the Gw and Gw.d edit descriptors follow the rules for L1 editing.

When used to specify I/O for character data, the Gw.d and Gw.d.Ee edit descriptors with nonzero w follows the same rules as Aw editing. For output, when w is zero, the Gw and Gw.d edit descriptors follow the rules for A editing when no w is specified.

Rules for Real Input Processing

On input, the G data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. The G descriptor interprets and assigns input data in the same way as the F data edit descriptor. w cannot be zero on input. If e is present, it has no effect on input.

Rules for Real Output Processing

The form in which the value is written depends on the magnitude of the internal value being edited. N is the magnitude of the internal value and r is the rounding mode value defined in the table below. If 0 < N < 0.1 - r x 10-d-1 or N >= 10d - r, or N is identically 0, w is nonzero, and d is 0, Gw.d output editing is the same as k PEw.d output editing and Gw.d Ee output editing is the same as k PEw.d Ee output editing, where k is the scale factor. If 0.1 - r x 10-d-1 <= N < 10d - r or N is identically 0 and d is not zero, the scale factor has no effect, and the value of N determines the editing as follows:

Effect of Data Magnitude on G Format Conversions

Data Magnitude

Effective Conversion

N = 0

F(w - n).(d -1), n('b')

0.1 - r x 10-d-1 <= N < 1 - r x 10-d

F(w - n).d, n('b')

1 - r x 10-d <= N < 10 - r x 10-d+1

F(w - n).(d -1), n('b')

10 - r x 10-d+1 <= N < 100 - r x 10-d+2

F(w - n).(d -2), n('b')

.

.

.

.

.

.

10d-2 - r x 10-2 <= N < 10d-1 - r x 10-1

F(w - n).1, n('b')

10d-1 - r x 10-1 <= N < 10d - r

(w - n).0, n('b')

The 'b' is a blank following the numeric data representation. For Gw.d, n('b') is 4 blanks. For Gw.dEe, n('b' ) is e+2 blanks.

The r is defined for each I/O rounding mode as follows:

Rounding Mode

r

COMPATIBLE

0.5

NEAREST

0.5 if the higher value is even

-0.5 if the lower value is even

UP

1

DOWN

0

ZERO

1 if the internal value is negative

0 if the internal value is positive

Note that the scale factor has no effect on output unless the magnitude of the datum to be edited is outside the range that permits effective use of F editing.

If w is greater than zero, it should be greater than or equal to d+7 to allow for the following:

  • A sign (optional if the value is positive and descriptor SP is not in effect)

  • One digit to the left of the decimal point

  • The decimal point

  • The d digits to the right of the decimal point

  • The 4-digit or e+2-digit exponent

If e is specified and positive, w should be greater than or equal to d + e + 5 if w is positive.

If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field width, the entire field of width w is filled with asterisks. However, the field width is not filled with asterisks if the field width is exceeded when optional characters are omitted.

For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for Fw.d.

The following shows output using the G edit descriptor and compares it to output using equivalent F editing (the symbol ^ represents a nonprinting blank character):

  Value               Format    Output with G     Format    Output with F
         0.01234567   G13.6     ^0.123457E-01     F13.6     ^^^^^0.012346
        -0.12345678   G13.6     -0.123457^^^^     F13.6     ^^^^-0.123457
         1.23456789   G13.6     ^^1.23457^^^^     F13.6     ^^^^^1.234568
        12.34567890   G13.6     ^^12.3457^^^^     F13.6     ^^^^12.345679
       123.45678901   G13.6     ^^123.457^^^^     F13.6     ^^^123.456789
     -1234.56789012   G13.6     ^-1234.57^^^^     F13.6     ^-1234.567890
     12345.67890123   G13.6     ^^12345.7^^^^     F13.6     ^12345.678901
    123456.78901234   G13.6     ^^123457.^^^^     F13.6     123456.789012
  -1234567.89012345   G13.6     -0.123457E+07     F13.6     *************

If w is zero, the Gw and Gw.d edit descriptors follow the rules for the G.w.dEe edit descriptors on output, but with leading and trailing blanks removed.