PRINT

The PRINT statement is a data transfer output statement.

Read syntax diagramSkip visual syntax diagramPRINT nameformat,output_item_list
is a namelist group name
output_item
is an output list item. An output list specifies the data to be transferred. An output list item can be:
  • A variable. An array is treated as if all of its elements were specified in the order they are arranged in storage.

    A pointer must be associated with a target, and an allocatable object must be allocated. A derived-type object cannot have any ultimate component that is inaccessible to this statement. The evaluation of output_item cannot result in a derived-type object that contains a pointer. The structure components of a structure in a formatted statement are treated as if they appear in the order of the derived-type definition; in an unformatted statement, the structure components are treated as a single value in their internal representation (including padding).

  • An expression.
  • An implied-DO list, as described under Implied-DO List.

An expression that is an output_item cannot have a value that is a procedure pointer.

format
is a format specifier that specifies the format to be used in the output operation. format is a format identifier that can be:
  • The statement label of a FORMAT statement. The FORMAT statement must be in the same scoping unit.
  • The name of a scalar INTEGER(4) or INTEGER(8) variable that was assigned the statement label of a FORMAT statement. The FORMAT statement must be in the same scoping unit.

    Fortran 95 does not permit assigning of a statement label.

  • A character constant. It cannot be a Hollerith constant. It must begin with a left parenthesis and end with a right parenthesis. Only the format codes described in the FORMAT statement can be used between the parentheses. Blank characters can precede the left parenthesis, or follow the right parenthesis.
  • A character variable that contains character data whose leftmost character positions constitute a valid format. A valid format begins with a left parenthesis and ends with a right parenthesis. Only the format codes listed under FORMAT can be used between the parentheses. Blank characters can precede the left parenthesis, or follow the right parenthesis.
  • An array of noncharacter intrinsic type.
  • Any character expression, except one involving concatenation of an operand that specifies inherited length, unless the operand is the name of a constant.
  • An asterisk, specifying list-directed formatting.
  • A namelist specifier that specifies a previously defined namelist.

Specifying the –qport=typestmt compiler option enables the TYPE statement which has identical functionality to the PRINT statement.

   PRINT 10, A,B,C
10 FORMAT (E4.2,G3.2E1,B3)