IOSTAT= specifier

Standard: F77 F90 F95 F2003 F2008 Example program


IOSTAT = variable

The IOSTAT= specifier is permitted in all input/output statements. The variable must be a scalar integer and should be able to represent values in the range −9999 to +9999.


The IOSTAT= specifier causes the specified variable to be assigned the value zero if the input/output operation was successful, with a positive value if an error condition occurred, with the negative value IOSTAT_END (from the intrinsic module ISO_FORTRAN_ENV) if an end-of-file condition occurred, or with the negative value IOSTAT_EOR (from the intrinsic module ISO_FORTRAN_ENV) if an end-of-record condition occurred.

If the statement also contains an END=, EOR= or ERR= specifier control will also be transferred if the corresponding condition occurred; if no appropriate END=, EOR= or ERR= appears execution continues normally.

The IOMSG= specifier can be used to retrieve the actual error message at the same time as the error code.

The F90_IOSTAT module contains named constants for each possible error code; the source code for this module can be found in the compiler library directory.


END= specifier, EOR= specifier, ERR= specifier, IOMSG= specifier, IS_IOSTAT_END intrinsic function, IS_IOSTAT_EOR intrinsic function