The PRINT statement writes from a list to stdout.
PRINT f [, iolist]
Parameter |
Description |
f |
Format identifier |
iolist |
List of variables, substrings, arrays, and records |
grname |
Name of the namelist group |
The PRINT statement accepts the following arguments.
f is a format identifier and can be:
An asterisk (*), which indicates list-directed I/O. See "List-Directed I/O " on for more information.
The label of a FORMAT statement that appears in the same program unit.
An integer variable name that has been assigned the label of a FORMAT statement that appears in the same program unit.
A character expression or integer array that specifies the format string. The integer array is nonstandard. @
iolist can be empty or can contain output items or implied DO lists. The output items must be one of the following:
Variables
Substrings
Arrays
Array elements
Record fields
Any other expression
A simple unsubscripted array name specifies all of the elements of the array in memory storage order, with the leftmost subscript increasing more rapidly.
Implied DO lists are described on "Implied DO Lists".
The second form of the PRINT statement is used to print the items of the specified namelist group. Here, grname is the name of a group previously defined by a NAMELIST statement.
Execution proceeds as follows:
The format, if specified, is established.
If the output list is not empty, data is transferred from the list to standard output.
If a format is specified, data is edited accordingly.
In the second form of the PRINT statement, data is transferred from the items of the specified namelist group to standard output.
Output from an exception handler is unpredictable. If you make your own exception handler, do not do any FORTRAN output from it. If you must do some, then call abort right after the output. Doing so reduces the relative risk of a program freeze. FORTRAN I/O from an exception handler amounts to recursive I/O. See the next point.
Recursive I/O does not work reliably. If you list a function in an I/O list, and if that function does I/O, then during runtime, the execution may freeze, or some other unpredictable problem may occur. This risk exists independent of parallelization.
Example: Recursive I/O fails intermittently:
PRINT *, x, f(x) Not allowed because f() does I/O. END FUNCTION F(X) PRINT *, X RETURN END
CHARACTER TEXT*16 PRINT 1, NODE, TEXT 1 FORMAT (I2, A16)
Example 2: List-directed array:
PRINT *, I, J, (VECTOR(I), I = 1, 5)
INTEGER VECTOR(10) PRINT '(12 I2)', I, J, VECTOR
CHARACTER LABEL*16 REAL QUANTITY INTEGER NODE NAMELIST /SUMMARY/ LABEL, QUANTITY, NODE PRINT SUMMARY