FORTRAN 77 Language Reference

PRINT

The PRINT statement writes from a list to stdout.

PRINT f [, iolist]

PRINT grname

Parameter 

Description 

f

Format identifier 

iolist

List of variables, substrings, arrays, and records 

grname

Name of the namelist group 

Description

The PRINT statement accepts the following arguments.

Format Identifier

f is a format identifier and can be:

Output List

iolist can be empty or can contain output items or implied DO lists. The output items must be one of the following:

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

Namelist-Directed PRINT

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:

  1. The format, if specified, is established.

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

  3. In the second form of the PRINT statement, data is transferred from the items of the specified namelist group to standard output.

Restrictions

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

Examples

Example 1: Formatted scalars:


       CHARACTER TEXT*16 
       PRINT 1, NODE, TEXT 
1     FORMAT (I2, A16) 

Example 2: List-directed array:


       PRINT *, I, J, (VECTOR(I), I = 1, 5) 

Example 3: Formatted array:


       INTEGER VECTOR(10) 
       PRINT '(12 I2)', I, J, VECTOR 

Example 4: Namelist:


       CHARACTER LABEL*16 
       REAL QUANTITY 
       INTEGER NODE 
       NAMELIST /SUMMARY/ LABEL, QUANTITY, NODE 
       PRINT SUMMARY