Using Fortran I/O statements

Under Language Environment, Fortran I/O statements formerly written to a Fortran error message unit (either directly or by default) are directed to a Language Environment message file specified by the MSGFILE runtime option. At program initialization, the Fortran error message unit is connected to the file specified by the MSGFILE runtime option.

The following types of output from Fortran programs are directed to the message file:
  • Error messages that result from unhandled conditions
  • Output produced by a sequential WRITE statement with a unit identifier having a value equal to the Fortran error message unit
  • Output produced by a sequential WRITE statement with * as the unit identifier when the Fortran error message and the standard print unit are the same
  • Output produced by a PRINT statement when the Fortran error message and the standard print unit are the same
  • Printed output from the dump services (CDUMP, CPCUMP, DUMP, PDUMP, or SDUMP)
The message file can be either a named or unnamed file. To specify an unnamed file, code the MSGFILE runtime option as follows:
MSGFILE(FTeeF001)

The ee value is a two-character representation of the error message unit number that is specified in the ERRUNIT runtime option; the ee value cannot be any other number.

The default ddname of the Language Environment message file is SYSOUT. The ddname can be changed in a Fortran program by issuing an OPEN statement to connect to the error message unit with a different ddname in the FILE specifier. You can use a CLOSE statement to close the message file currently connected to the Fortran error message unit. In this case, the default message file as specified by the MSGFILE runtime option becomes the current message file. Any subsequent output messages are written to this message file after the CLOSE statement is issued. No subsequent OPEN statement is required.

For example, when the standard print unit is the same as the error message unit (unit 6 in Figure 1), all output from the PRINT statement is directed to the error message unit. When the MSGFILE(ONE) runtime option is in effect, the message file with ddname ONE is connected to the error message unit.

Figure 1. Directing output messages
PRINT *, 'FILE ONE, RECORD 1'
PRINT *, 'FILE ONE, RECORD 2'
OPEN (6, FILE='TWO')
PRINT *, 'FILE TWO, RECORD 1'
PRINT *, 'FILE TWO, RECORD 2'
CLOSE (6)
PRINT *, 'FILE ONE, NEW RECORD 1'
PRINT *, 'FILE ONE, NEW RECORD 2'

Figure 1 shows the first two records being written to the message file with the ddname ONE. The first OPEN statement closes file ONE and connects file TWO to the error message unit; two messages are written to it. The CLOSE statement closes file TWO and makes ONE the current message file. This occurs because the MSGFILE(ONE) runtime option is specified. The next PRINT statement connects file ONE to the error message unit, and two records are written to it. The message file is opened and the error message unit is connected automatically when an output message is issued.

The error message unit is restricted to sequential formatted output operations. Therefore, there are restrictions on the OPEN statement specifiers that can be used for the error message unit. Table 1 shows the valid OPEN statement specifiers and specifier values.

Table 1. Allowable OPEN statement specifiers
SPECIFIER=spv Default spv value Additional allowable spv values
STATUS=sta UNKNOWN None
ACCESS=acc SEQUENTIAL None
CHAR=chr DBCS NODBCS can also be specified, but is ignored.
FORM=frm FORMATTED None
ACTION=act WRITE None
BLANK=blk ZERO NULL. BLANK has no meaning because the error message unit is used only for output.
PAD=pad YES NO. PAD has no meaning because the error message unit is used only for output.
POSITION=ASIS ASIS None
DELIM=dlm Based on Fortran OPEN and CLOSE statements that refer to the error message unit. APOSTROPHE, QUOTE, or NONE can be specified.
RECL=rcl Maximum data length of a message file record. Any positive value which does not exceed the maximum allowable length of the data in a message file record.