XL Fortran for AIX 8.1

Language Reference



The CLOSE statement disconnects an external file from a unit.



is a list that must contain one unit specifier (UNIT=u) and can also contain one of each of the other valid specifiers. The valid specifiers are:

[UNIT=] u
is a unit specifier in which u must be an external unit identifier whose value is not an asterisk. An external unit identifier refers to an external file that is represented by a scalar integer expression, whose value is in the range 1 through 2147483647. If the optional characters UNIT= are omitted, u must be the first item in close_list.

is an input/output status specifier that specifies the status of the input/output operation. ios is a scalar variable of type INTEGER(4) or default integer. When the input/output statement containing this specifier finishes executing, ios is defined with:

ERR= stmt_label
is an error specifier that specifies the statement label of an executable statement in the same scoping unit to which control is to transfer in the case of an error. Coding the ERR= specifier suppresses error messages.

STATUS= char_expr
specifies the status of the file after it is closed. char_expr is a scalar character expression whose value, when any trailing blanks are removed, is either KEEP or DELETE.

The default is DELETE if the file status is SCRATCH; otherwise, the default is KEEP.


A CLOSE statement that refers to a unit can occur in any program unit of an executable program and need not occur in the same scoping unit as the OPEN statement referring to that unit. You can specify a unit that does not exist or has no file connected; the CLOSE statement has no effect in this case.

IBM Extension BeginsUnit 0 cannot be closed. IBM Extension Ends

When an executable program stops for reasons other than an error condition, all units that are connected are closed. Each unit is closed with the status KEEP unless the file status prior to completion was SCRATCH, in which case the unit is closed with the status DELETE. The effect is as though a CLOSE statement without a STATUS= specifier were executed on each connected unit.

If a preconnected unit is disconnected by a CLOSE statement, the rules of implicit opening apply if the unit is later specified in a WRITE statement (without having been explicitly opened).



Related Information

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]