Intel® Fortran Compiler 18.0 Developer Guide and Reference

G Editing

The G data edit descriptor generally transfers values of real type, but it can be used to transfer values of any intrinsic type. It takes the following form:

Gw.d[Ee]

The value of d (the number of places after the decimal point) plus e (the number of digits in the exponent) must not exceed the value of w (the field width), unless w is zero. If w is zero, you can only specify forms G0 or G0.d.

When w is zero, the processor selects the field width. On input, w must not be zero.

The specified I/O list item can be of any intrinsic type.

When used to specify I/O for integer, logical, or character data, the edit descriptor follows the same rules as Iw, Lw, and Aw, respectively, and d and e have no effect.

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.

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

The w should be greater than or equal to d+7 to allow for the following:

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

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

See Also