Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

File Operation I/O Statements

The following are file connection, inquiry, and positioning I/O statements:

  • BACKSPACE

    Positions a sequential file at the beginning of the preceding record, making it available for subsequent I/O processing.

  • CLOSE

    Terminates the connection between a logical unit and a file or device.

  • DELETE

    Deletes a record from a relative file.

  • ENDFILE

    Writes an end-of-file record to a sequential file and positions the file after this record (the terminal point). For direct access files, truncates the file after the current record.

  • FLUSH

    Causes data written to a file to become available to other processes or causes data written to a file outside of Fortran to be accessible to a READ statement.

  • INQUIRE

    Requests information on the status of specified properties of a file or logical unit. For more information on specifiers you can use in INQUIRE statements, see INQUIRE Statement Specifiers.

  • OPEN

    Connects a Fortran logical unit to a file or device; declares attributes for read and write operations. For more information on specifiers you can use in OPEN statements, see OPEN Statement Specifiers.

  • REWIND

    Positions a sequential or direct access file at the beginning of the file (the initial point).

  • WAIT

    Performs a wait operation for a specified pending asynchronous data transfer operation.

The following table summarizes I/O statement specifiers:

I/O Specifiers

Specifier

Values

Description

Used with:

ACCESS=access

'SEQUENTIAL', 'DIRECT', 'STREAM', or 'APPEND'

Specifies the method of file access.

INQUIRE, OPEN

ACTION=permission

'READ', 'WRITE' or 'READWRITE' (default is 'READWRITE')

Specifies file I/O mode.

INQUIRE, OPEN

ADVANCE=c-expr

'NO' or 'YES' (default is 'YES')

Specifies formatted sequential data input as advancing, or non-advancing.

READ

ASSOCIATEVARIABLE=var

Integer variable

Specifies a variable to be updated to reflect the record number of the next sequential record in the file.

OPEN

ASYNCHRONOUS=asynch

'YES' or 'NO' (default is 'NO')

Specifies whether or not the I/O is done asynchronously

INQUIRE, OPEN

BINARY=bin

'NO' or 'YES'

Returns whether file format is binary.

INQUIRE

BLANK=blank_control

'NULL' or 'ZERO' (default is 'NULL')

Specifies whether blanks are ignored in numeric fields or interpreted as zeros.

INQUIRE, OPEN

BLOCKSIZE=blocksize

Positive integer variable or expression

Specifies or returns the internal buffer size used in I/O.

INQUIRE, OPEN

BUFFERCOUNT=bc

Numeric expression

Specifies the number of buffers to be associated with the unit for multibuffered I/O.

OPEN

BUFFERED=bf

'YES' or 'NO' (default is 'NO')

Specifies runtime library behavior following WRITE operations.

INQUIRE, OPEN

CARRIAGECONTROL= control

'FORTRAN', 'LIST', or 'NONE'

Specifies carriage control processing.

INQUIRE, OPEN

CONVERT=form

'LITTLE_ENDIAN', 'BIG_ENDIAN', 'CRAY', 'FDX', 'FGX', 'IBM', 'VAXD', 'VAXG', or 'NATIVE' (default is 'NATIVE')

Specifies a numeric format for unformatted data.

INQUIRE, OPEN

DEFAULTFILE=var

Character expression

Specifies a default file pathname string.

INQUIRE, OPEN

DELIM=delimiter

'APOSTROPHE', 'QUOTE' or 'NONE' (default is 'NONE')

Specifies the delimiting character for list-directed or namelist data.

INQUIRE, OPEN

DIRECT=dir

'NO' or 'YES'

Returns whether file is connected for direct access.

INQUIRE

DISPOSE=dis (or DISP=dis)

'KEEP', 'SAVE', 'DELETE', 'PRINT', 'PRINT/DELETE', 'SUBMIT', or 'SUBMIT/DELETE' (default is 'DELETE' for scratch files; 'KEEP' for all other files)

Specifies the status of a file after the unit is closed.

OPEN, CLOSE

formatlist

Character variable or expression

Lists edit descriptors. Used in FORMAT statements and format specifiers (the FMT=formatspec option) to describe the format of data.

FORMAT, PRINT, READ, WRITE

END=endlabel

Integer between 1 and 99999

When an end of file is encountered, transfers control to the statement whose label is specified.

READ

EOR=eorlabel

Integer between 1 and 99999

When an end of record is encountered, transfers to the statement whose label is specified.

READ

ERR=errlabel

Integer between 1 and 99999

Specifies the label of an executable statement where execution is transferred after an I/O error.

All except PRINT

EXIST=ex

.TRUE. or .FALSE.

Returns whether a file exists and can be opened.

INQUIRE

FILE=file(or NAME=name)

Character variable or expression. Length and format of the name are determined by the operating system

Specifies the name of a file

INQUIRE, OPEN

[FMT=]formatspec

Character variable or expression

Specifies an editlist to use to format data.

PRINT, READ, WRITE

FORM=form

'FORMATTED', 'UNFORMATTED', or 'BINARY'

Specifies a file's format.

INQUIRE, OPEN

FORMATTED=fmt

'NO' or 'YES'

Returns whether a file is connected for formatted data transfer.

INQUIRE

IOFOCUS=iof

.TRUE. or .FALSE. (default is .TRUE. unless unit '*' is specified)

Specifies whether a unit is the active window in a QuickWin application.

INQUIRE, OPEN

iolist

List of variables of any type, character expression, or NAMELIST

Specifies items to be input or output.

PRINT, READ, WRITE

IOSTAT=iostat

Integer variable

Specifies a variable whose value indicates whether an I/O error has occurred.

All except PRINT

MAXREC=var

Numeric expression

Specifies the maximum number of records that can be transferred to or from a direct access file.

OPEN

MODE=permission

'READ', 'WRITE' or 'READWRITE' (default is 'READWRITE')

Same as ACTION.

INQUIRE, OPEN

NAMED=var

.TRUE. or .FALSE.

Returns whether a file is named.

INQUIRE

NEWUNIT=u-var

Scalar integer variable

Is assigned an unused unit number that is automatically chosen. It is always a negative integer.

OPEN

NEXTREC=nr

Integer variable

Returns where the next record can be read or written in a file.

INQUIRE

[NML=]nmlspec

Namelist name

Specifies a namelist group to be input or output.

PRINT, READ, WRITE

NUMBER=num

Integer variable

Returns the number of the unit connected to a file.

INQUIRE

OPENED=od

.TRUE. or .FALSE.

Returns whether a file is connected.

INQUIRE

ORGANIZATION=org

'SEQUENTIAL' or 'RELATIVE' (default is 'SEQUENTIAL')

Specifies the internal organization of a file.

INQUIRE, OPEN

PAD=pad_switch

'YES' or 'NO' (default is 'YES')

Specifies whether an input record is padded with blanks when the input list or format requires more data than the record holds, or whether the input record is required to contain the data indicated.

INQUIRE, OPEN

POS=pos

Positive integer

Specifies the file storage unit position in a stream file.

INQUIRE, READ, WRITE

POSITION=file_pos

'ASIS', 'REWIND' or 'APPEND' (default is 'ASIS')

Specifies position in a file.

INQUIRE, OPEN

READ=rd

'NO' or 'YES'

Returns whether a file can be read.

INQUIRE

READONLY

Specifies that only READ statements can refer to this connection.

OPEN

READWRITE=rdwr

'NO' or 'YES'

Returns whether a file can be both read and written to.

INQUIRE

REC=rec

Positive integer variable or expression

Specifies the first (or only) record of a file to be read from, or written to.

READ, WRITE

RECL=length(or RECORDSIZE=length)

Positive integer variable or expression

Specifies the record length in direct access files, or the maximum record length in sequential files.

INQUIRE, OPEN

RECORDTYPE=typ

'FIXED', 'VARIABLE', 'SEGMENTED', 'STREAM', 'STREAM_LF', or 'STREAM_CR'

Specifies the type of records in a file.

INQUIRE, OPEN

SEQUENTIAL=seq

'NO' or 'YES'

Returns whether file is connected for sequential access.

INQUIRE

SHARE=share

'COMPAT', 'DENYNONE', 'DENYWR', 'DENYRD', or 'DENYRW' (default is 'DENYNONE')

Controls how other processes can simultaneously access a file on networked systems.

INQUIRE, OPEN

SHARED

Specifies that a file is connected for shared access by more than one program executing simultaneously.

OPEN

SIZE=size

Integer variable

Returns the number of characters read in a nonadvancing READ before an end-of-record condition occurred.

READ

STATUS=status(or TYPE=status)

'OLD', 'NEW', 'UNKNOWN' or 'SCRATCH' (default is 'UNKNOWN')

Specifies the status of a file on opening and/or closing.

CLOSE, OPEN

TITLE=name

Character expression

Specifies the name of a child window in a QuickWin application.

OPEN

UNFORMATTED=unf

'NO' or 'YES'

Returns whether a file is connected for unformatted data transfer.

INQUIRE

[UNIT=]unitspec

Integer variable or expression

Specifies the unit to which a file is connected.

All except PRINT

USEROPEN=fname

Name of a user-written function

Specifies an external function that controls the opening of a file.

OPEN

WRITE=rd

'NO' or 'YES'

Returns whether a file can be written to.

INQUIRE