| Application Programmer's I/O Guide - S-3695-35 | ||
|---|---|---|
| Prev Section | Chapter 2. Standard Fortran I/O | Next Section |
The auxiliary I/O statements consist of the OPEN, CLOSE, INQUIRE, BACKSPACE, REWIND, and ENDFILE statements. These types of statements specify file connections, describe files, or position files. See the Fortran Language Reference manual for your compiler system for more details about auxiliary I/O statements.
The OPEN and CLOSE statements specify an external file and how to access the file.
An OPEN statement connects an existing file to a unit, creates a file that is preconnected, creates a file and connects it to a unit, or changes certain specifiers of a connection between a file and a unit. The following are examples of the OPEN statement:
OPEN (11,ACCESS='DIRECT',FORM='FORMATTED',RECL=24) OPEN (10,ACCESS='SEQUENTIAL', FORM='UNFORMATTED') OPEN (9,BLANK='NULL') |
The CLOSE statement terminates the connection of a particular file to a unit. A unit that does not exist or has no file connected to it may appear within a CLOSE statement; this would not affect any files.
The INQUIRE statement describes the connection to an external file. This statement can be executed before, during, or after a file is connected to a unit. All values that the INQUIRE statement assigns are current at the time that the statement is executed.
You can use the INQUIRE statement to check the properties of a specific file or check the connection to a particular unit. The two forms of the INQUIRE statement are INQUIRE by file and INQUIRE by unit.
The INQUIRE by file statement retrieves information about the properties of a particular file.
The INQUIRE by unit statement retrieves the name of a file connected to a specified unit if the file is a named file. The standard input, standard output, and standard error files are unnamed files. An INQUIRE on a unit connected to any of these files indicates that the file is unnamed.
An INQUIRE by unit on any unit connected by using an explicit named OPEN statement indicates that the file is named, and returns the name that was present in the FILE= specifier in the OPEN statement.
An INQUIRE by unit on any unit connected by using an explicit unnamed OPEN statement, or an implicit open may indicate that the file is named. A name is returned only if the I/O library can ensure that a subsequent OPEN statement with a FILE= name will connect to the same file.
The BACKSPACE and REWIND statements change the position of the external file. The ENDFILE statement writes the last record of the external file.
You cannot use file positioning statements on a file that is connected as a direct access file. The REC= record specifier is used for positioning in a READ or WRITE statement on a direct access file.
The BACKSPACE statement causes the file connected to the specified unit to be positioned to the preceding record. The following are examples of the BACKSPACE statement:
BACKSPACE 10 BACKSPACE (11, IOSTAT=ios, ERR=100) BACKSPACE (12, ERR=100) BACKSPACE (13, IOSTAT=ios) |
The ENDFILE statement writes an endfile record as the next record of the file. The following are examples of the ENDFILE statement:
ENDFILE 10 ENDFILE (11, IOSTAT=ios, ERR=100) ENDFILE (12, ERR=100) ENDFILE (13, IOSTAT=ios) |
The REWIND statement positions the file at its initial point. The following are examples of the REWIND statement:
REWIND 10 REWIND (11, IOSTAT=ios, ERR=100) REWIND (12, ERR=100) REWIND (13, IOSTAT=ios) REWIND (14) |
| Prev Section | Table of Contents | Title Page | Next Section |
| Data transfer statements | Up one level | Private I/O on Cray T3E systems |