List-directed formatting allows you to control the editing process using the lengths and types of data that is read or written. You can only use list-directed formatting with sequential or stream access.
Use the asterisk format identifier to specify list-directed formatting. For example:
REAL TOTAL1, TOTAL2 PRINT *, TOTAL1, TOTAL2
If you specify list-directed formatting for a formatted record, that record consists of a sequence of values and value separators.
where:
A null value has no effect on the definition status of the corresponding input list item.
Input list items in a list-directed READ
statement are defined by corresponding values in a formatted record. The syntax of each value
must agree with the type of the corresponding input list item.
Syntax | Type |
c | A literal constant of intrinsic type, or a non-delimited character constant. |
r * | r is an unsigned, nonzero, integer literal constant. r * indicates r successive appearances of the null value. |
r * c | Indicates r successive appearances of the constant. |
You must not specify a kind type parameter for c or r.
List-directed formatting interprets two or more consecutive blanks as a single blank, unless the blanks are within a character value.
The constant c will have the same kind type parameter as the corresponding list item.
+-------------------------------IBM Extension--------------------------------+
Use the -qintlog compiler option to specify integer or logical values for input items of either integer or logical type.
+----------------------------End of IBM Extension----------------------------+
List-directed formatting interprets an object of derived type that occurs
in an input list as if all structure components occur in the same order as in
the derived type definition. The ultimate components of the derived type must not have the pointer
or allocatable
attribute.
A slash indicates the end of the input list and terminates list-directed formatting. Additional input list items after the slash evaluate as null values.
A character value that meets the following conditions can continue in as many records as necessary:
Delimiting apostrophes or quotation marks are not necessary to continue a character value across multiple records. If you omit delimiting characters, the first blank, comma, slash, or end-of-record terminates the character constant.
If you do not specify delimiting apostrophes or quotation marks, apostrophes and double quotation marks in the character value are not doubled.
In list-directed input an end-of-record has the same effect as a blank separator, unless the blank is within a character literal constant or complex literal constant. An end-of record does not insert a blank or any other character in a character value. An end-of-record must not occur between a doubled apostrophe in an apostrophe-delimited character sequence, or between a doubled quote in a quote-delimited character sequence
List-directed PRINT and WRITE statements output values in an order identical to the output list. Values are written in a form valid for the data type of each output list item.
Table 21. List-Directed Output
Data Type | Form of Output |
Arrays | Column-major order |
Character | Depends on DELIM= specifier and file type, see Character Output. |
Complex | Enclosed in parentheses with a comma separating the real and imaginary parts. Uses E or F editing. |
Integer | Uses I editing. |
Logical |
T for a true value F for a false value |
Real | Uses E or F editing. |
The output of character constants can change depending on the DELIM= specifier on the OPEN statement.
Character constants output to an internal file, a file opened without a DELIM= specifier, or a file opened with a DELIM= specifier with a value of NONE, output as follows:
Double quotation marks delimit character constants in a file opened with a DELIM= specifier with a value of QUOTE. A value separator follows the delimiter. Each internal quote outputs as two contiguous double quotation marks.
Apostrophes delimit character constants in a file opened with a DELIM= specifier with a value of APOSTROPHE A value separator follows the delimiter. Each internal apostrophe outputs as two contiguous apostrophes.
Each output record begins with a blank character that provides carriage control when that record outputs.
The end-of-record must not occur within a constant that is not character or complex.
In a complex constant, the end of a record can occur between the comma and the imaginary part of the constant only if the constant is as long or longer than a record. The only embedded blanks that can occur within a complex constant are one blank between the comma and the end of a record, and one blank at the beginning of the next record.
Blanks must not occur within a constant that is not character or complex.
List-directed formatting interprets a structure that occurs in an
output list as if all structure components occur in the output list in the
same order as in the definition of that derived type. The ultimate
components of the derived type must not have the pointer
or allocatable
attribute.
Null values are not output.
Slashes you specify as value separators are not output.
+-------------------------------IBM Extension--------------------------------+
The Width of a Written Field table contains the width of the
written field for any data type and length. The size of the record is
the sum of the field widths plus one byte to separate each non-character
field.
Table 22. Width of a Written Field
Data Type | Length (bytes) | Maximum Field Width (characters) | Fraction (decimal digits) | Precision/IEEE (decimal digits) |
---|---|---|---|---|
integer |
1 2 4 8 |
4 6 11 20 |
n/a n/a n/a n/a |
n/a n/a n/a n/a |
real |
4 8 16 |
17 26 43 |
10 18 35 |
7 15 31 |
complex |
8 16 32 |
37 55 89 |
10 18 35 |
7 15 31 |
logical |
1 2 4 8 |
1 1 1 1 |
n/a n/a n/a n/a |
n/a n/a n/a n/a |
character | n | n | n/a | n/a |
+----------------------------End of IBM Extension----------------------------+