LF Fortran 95

Data Edit Descriptors

Data Edit Descriptors

Data edit descriptors control conversion of data to or from its internal representation.

Numeric Editing

The I, B, O, Z, Q, F, E, EN, ES, D, and G edit descriptors can be used to specify the input/output of INTEGER, REAL, and COMPLEX data. The following general rules apply:

INTEGER Editing (I, B, O, and Z)

The Iw, Iw.m, Bw, Bw.m, Ow, Ow.m, Zw, and Zw.m edit descriptors indicate the manner of editing for INTEGER data. The w indicates the width of the field on input, including a sign (if present). The m indicates the minimum number of digits on output; m must not exceed w unless w is zero. The output width is padded with blanks if the number is smaller than the field, unless w is zero. If w is zero then a suitable width will be used to show all digits without any padding blanks. Note that an input width must always be specified.

REAL Editing (Q, F, D, and E)

The Qw.d, Fw.d, Ew.d, Dw.d, Ew.dEe, EN, and ES edit descriptors indicate the manner of editing of REAL and COMPLEX data.

Q, F, D, E, EN, and ES editing are identical on input. The w indicates the width of the field; the d indicates the number of digits in the fractional part. The field consists of an optional sign, followed by one or more digits that can contain a decimal point. If the decimal point is omitted, the rightmost d digits are interpreted as the fractional part. An exponent can be included in one of the following forms:

F editing, the output field consists of zero or more blanks followed by a minus sign or an optional plus sign (see S, SP, and SS Editing), followed by one or more digits that contain a decimal point and represent the magnitude. The field is modified by the established scale factor (see P Editing) and is rounded to d decimal digits. If w is zero then a suitable width will be used to show all digits and sign without any padding blanks.

For Q, E, and D editing, the output field consists of the following, in order:

For Q, E, and D editing, the scale factor k controls the position of the decimal point. If d < k ≤ 0, the output field contains exactly |k| leading zeros and |-k| significant digits after the decimal point. If 0 < k < d+2, the output field contains exactly k significant digits to the left of the decimal point and -k+1 significant digits to the right of the decimal point. Other values of k are not permitted.

EN Editing

The EN edit descriptor produces an output field in engineering notation such that the decimal exponent is divisible by three and the absolute value of the significand is greater than or equal to 1 and less than 1000, except when the output value is zero. The scale factor has no effect on output.

The forms of the edit descriptor are ENw.d and ENw.dEe indicating that the external field occupies w positions, the fractional part of which consists of d digits and the exponent part e digits.

On input, EN editing is the same as F editing.

ES Editing

The ES edit descriptor produces an output field in the form of a real number in scientific notation such that the absolute value of the significand is greater than or equal to 1 and less than 10, except when the output value is zero. The scale factor has no effect on output.

The forms of the edit descriptor are ESw.d and ESw.dEe indicating that the external field occupies w positions, the fractional part of which consists of d digits and the exponent part e digits.

On input, ES editing is the same as F editing.

COMPLEX Editing

COMPLEX editing is accomplished by using two REAL edit descriptors. The first of the edit descriptors specifies the real part; the second specifies the imaginary part. The two edit descriptors can be different. Control edit descriptors can be processed between the edit descriptor for the real part and the edit descriptor for the imaginary part. Character string edit descriptors can be processed between the two edit descriptors on output only.

LOGICAL Editing (L)

The Lw edit descriptor indicates that the field occupies w positions. The specified input/output list item must be of type LOGICAL.

The input field consists of optional blanks, optionally followed by a decimal point, followed by a T for true or F for false. The T or F can be followed by additional characters in the field. Note that the logical constants .TRUE. and .FALSE. are acceptable input forms. If a processor is capable of representing letters in both upper and lower case, a lower-case letter is equivalent to the corresponding uppercase letter in a LOGICAL input field.

The output field consists of w - 1 blanks followed by a T or F, depending on whether the value of the internal data object is true or false, respectively.

CHARACTER Editing (A)

The A[w] edit descriptor is used with an input/output list item of type CHARACTER.

If a field width w is specified with the A edit descriptor, the field consists of w characters. If a field width w is not specified with the A edit descriptor, the number of characters in the field is the length of the corresponding list item.

Let len be the length of the list item. On input, if w is greater than or equal to len, the rightmost len characters will be taken from the field; if w is less than len, the w characters are left-justified and padded with len-w trailing blanks.

On output, the list item is padded with leading blanks if w is greater than len. If w is less than or equal to len, the output field consists of the leftmost w characters of the list item.

Generalized Editing (G)

The Gw.d and Gw.dEe edit descriptors can be used with an input/output list item of any intrinsic type.

These edit descriptors indicate that the external field occupies w positions, the fractional part of which consists of a maximum of d digits and the exponent part e digits. d and e have no effect when used with INTEGER, LOGICAL, or CHARACTER data.

Generalized Integer Editing

With INTEGER data, the Gw.d and Gw.dEe edit descriptors follow the rules for the Iw edit descriptor.

Generalized Real and Complex Editing

The form and interpretation of the input field is the same as for F editing.

The method of representation in the output field depends on the magnitude of the data object being edited. If the decimal point falls just before, within, or just after the d significant digits to be printed, then the output is as for the F edit descriptor; otherwise, editing is as for the E edit descriptor.

Note that the scale factor k (see See P Editing) has no effect unless the magnitude of the data object to be edited is outside the range that permits effective use of F editing.

Generalized Logical Editing

With LOGICAL data, the Gw.d and Gw.dEe edit descriptors follow the Lw edit descriptor rules.

Generalized Character Editing

With CHARACTER data, the Gw.d and Gw.dEe edit descriptors follow the Aw edit descriptor rules.