XL Fortran for AIX 8.1
Language Reference
Purpose
The CLOSE statement disconnects an external file from a
unit.
Format
>>-CLOSE--(--close_list--)-------------------------------------><
|
- close_list
- 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.
- IOSTAT= ios
- 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:
- A zero value if no error condition occurs
- A positive value if an error occurs.
- 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.
- If KEEP is specified for a file that exists, the file will
continue to exist after the CLOSE statement. If KEEP
is specified for a file that does not exist, the file will not exist after the
CLOSE statement. KEEP must not be specified for a
file whose status prior to executing the CLOSE statement is
SCRATCH.
- If DELETE is specified, the file will not exist after the
CLOSE statement.
The default is DELETE if the file status is SCRATCH;
otherwise, the default is KEEP.
Rules
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.
Unit 0 cannot be closed.
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).
Examples
CLOSE(15)
CLOSE(UNIT=16,STATUS='DELETE')
Related Information
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]