Input/Output Editing

Detailed information about input/output editing.

Data Edit Descriptors

The Cray Fortran compiler allows w to be zero for the G edit descriptor, and it permits w to be omitted for the I, B, O, Z, or G edit descriptors.

The Cray Fortran compiler allows signed binary, octal, or hexadecimal values as input.

If the minimum digits (m) field is specified, the default field width is increased, if necessary, to allow for that minimum width.

The Cray Fortran compiler allows the use of B, O, and Z edit descriptors of REAL data items. The Cray Fortran compiler accepts the Dw.dEe edit descriptor.

The Cray Fortran compiler accepts the ZERO_WIDTH_PRECISION environment variable, which can be used to modify the default size of the width w field. This environment variable is examined only upon program startup. Changing the value of the environment variable during program execution has no effect. For more information about the ZERO_WIDTH_PRECISION environment, see ZERO_WIDTH_PRECISION.

The Cray Fortran compiler allows w to be zero or omitted for the D, E, EN, ES, or G edit descriptors.

The Cray Fortran compiler does not restrict the use of Ew.d and Dw.d to an exponent less than or equal to 999. The Ew.dEe form must be used.

Table 1. Default Fractional and Exponent Digits
Data Size and Representationwde
4-byte (32-bit) IEEE1792
8-byte (64-bit) IEEE26173

The Cray Fortran compiler allows w to be zero or omitted on the L or G edit descriptors.

The Cray Fortran compiler allows w to be zero or omitted on the G edit descriptor.

Control Edit Descriptors

The Cray Fortran supports the Q edit descriptor. The Q edit descriptor is used to determine the number of characters remaining in the input record. It has the following format:Q

When a Q edit descriptor is encountered during execution of an input statement, the corresponding input list item must be of type integer. Interpretation of the Q edit descriptor causes the input list item to be defined with a value that represents the number of characters remaining to be read in the formatted record.

For example, if c is the character position within the current record of the next character to be read, and the record consists of n characters, then the item is defined with the following value MAX(n-c+1,0).

If no characters have yet been read, then the item is defined as n (the length of the record). If all the characters of the record have been read (c>n), then the item is defined as zero.

The Q edit descriptor must not be encountered during the execution of an output statement.

The following example code uses Q on input:
INTEGER N
CHARACTER LINE * 80
READ (*, FMT='(Q,A)') N, LINE(1:N)

List-directed Formatting

Input values are generally accepted as list-directed input if they are the same as those required for explicit formatting with an edit descriptor. The exceptions are as follows:
  • When the data list item is of type integer, the constant must be of a form suitable for the I edit descriptor. The Cray Fortran compiler permits binary, octal, and hexadecimal based values in a list-directed input record to correspond to I edit descriptors.

Namelist Formatting

The Cray Fortran compiler has extended the namelist feature. The following additional rules govern namelist processing:
  • An ampersand (&) or dollar sign ($) can precede the namelist group name or terminate namelist group input. If an ampersand precedes the namelist group name, either the slash (/) or the ampersand must terminate the namelist group input. If the dollar sign precedes the namelist group name, either the slash or the dollar sign must terminate the namelist group input.
  • Octal and hexadecimal constants are allowed as input to integer and single-precision real namelist group items. An error is generated if octal and hexadecimal constants are specified as input to character, complex, or double-precision real namelist group items.
  • Octal constants must be of the following form:
    • O"123"
    • O'123'
    • o"123"
    • o'123'
  • Hexadecimal constants must be of the following form:
    • Z"1a3"
    • Z'1a3'
    • z"1a3"
    • z'1a3'

I/O Editing

Usually, data is stored in memory as the values of variables in some binary form. On the other hand, formatted data records in a file consist of characters. Thus, when data is read from a formatted record, it must be converted from characters to the internal representation. When data is written to a formatted record, it must be converted from the internal representation into a string of characters.

The tables below list the control and data edit descriptor extensions supported by the Cray Fortran compiler and provide a brief description of each.

Table 2. Summary of Control Edit Descriptors
DescriptorDescription
$ or \Suppress carriage control
Table 3. Summary of Data Edit Descriptors
DescriptorDescription
QReturn number of characters left in record
The following tables show the use of the Cray Fortran compiler's edit descriptors with all intrinsic data types. In these tables:
  • NA indicates invalid usage that is not allowed.
  • I,O indicates that usage is allowed for both input and output.
  • I indicates legal usage for input only.
  • NA indicates invalid usage that is not allowed.
  • I,O indicates that usage is allowed for both input and output.
  • I indicates legal usage for input only.
    Table 4. Default Compatibility Between I/O List Data Types and Data Edit Descriptors
    Data typesQZROLIGFESENEDBA
    IntegerII,OI,OI,ONAI,OI,ONANANANANAI,OI,O
    RealNAI,OI,OI,ONANAI,OI,OI,OI,OI,OI,OI,OI,O
    ComplexNAI,OI,OI,ONANAI,OI,OI,OI,OI,OI,OI,OI,O
    LogicalNAI,OI,OI,OI,ONAI,ONANANANANAI,OI,O
    CharacterNANANANANANAI,ONANANANANANAI,O

    The table below, RELAXED Compatibility Between Data Types and Data Edit Descriptors shows the restrictions for the various data types that are allowed when the FORMAT_TYPE_CHECKING environment variable is set to RELAXED. Not all data edit descriptors support all data sizes; for example, a 16-byte real variable with an I edit descriptor cannot be read/write.

    Table 5. RELAXED Compatibility Between Data Types and Data Edit Descriptors
    Data typesQZROLIGFESENEDBA
    IntegerII,OI,OI,OI,OI,OI,OI,OI,OI,OI,ONAI,OI,O
    RealNAI,OI,OI,OI,OI,OI,OI,OI,OI,OI,OI,OI,OI,O
    ComplexNAI,OI,OI,ONANAI,OI,OI,OI,OI,OI,OI,OI,O
    LogicalNAI,OI,OI,OI,OI,OI,OI,OI,OI,OI,ONAI,OI,O
    CharacterNANANANANANAI,ONANANANANANAI,O

    STRICT77 Compatibility Between Data Types and Data Edit Descriptors shows the restrictions for the various data types that are allowed when the FORMAT_TYPE_CHECKING environment variable is set to STRICT77.

    Table 6. STRICT77 Compatibility Between Data Types and Data Edit Descriptors
    Data typesQZROLIGFESENEDBA
    IntegerNAI,ONAI,ONAI,ONANANANANANAI,ONA
    RealNANANANANANAI,OI,ONANAI,OI,ONANA
    ComplexNANANANANANAI,OI,ONANAI,OI,ONANA
    LogicalNANANANAI,ONANANANANANANANANA
    CharacterNANANANANANANANANANANANANAI,O

    STRICT90 and STRICT95 Compatibility Between Data Types and Data Edit Descriptors shows the restrictions for the various data types that are allowed when the FORMAT_TYPE_CHECKING environment variable is set to STRICT90 or STRICT95.

    Table 7. STRICT90 or STRICT95 Compatibility Between Data Types and Data Edit Descriptors
    Data typesQZROLIGFESENEDBA
    IntegerNAI,ONAI,ONAI,OI,ONANANANANAI,ONA
    RealNANANANANANAI,OI,OI,OI,OI,OI,ONANA
    ComplexNANANANANANAI,OI,OI,OI,OI,OI,ONANA
    LogicalNANANANAI,ONAI,ONANANANANANANA
    CharacterNANANANANANAI,ONANANANANANAI,O