For external files, you can specify that I/O should be asynchronous. By doing this, you allow other statements to execute while an I/O statement is executing.
In order to execute a program that uses asynchronous I/O on Linux* or Mac OS* X systems, you must explicitly include one of the following compiler command line options when you compile and link your program:
-threads
-reentrancy threaded
-openmp
On Windows* systems, no extra options are needed to execute a program that uses asynchronous I/O.
Asynchronous I/O is supported for all READ and WRITE operations to external files. However, if you specify asynchronous I/O, you cannot use variable format expressions in formatted I/O operations.
To allow asynchronous I/O for a file, first specify ASYNCHRONOUS='YES' in its OPEN statement, then do the same for each READ or WRITE statement that you want to execute in this manner.
Execution of an asynchronous I/O statement initiates a "pending" I/O operation, which can be terminated in the following ways:
by an explicit WAIT (initno) statement, which performs a wait operation for the specified pending asynchronous data transfer operation
by a CLOSE statement for the file
by a file-positioning statement such as REWIND or BACKSPACE
by an INQUIRE statement for the file
You can use the INQUIRE statement with the keyword of ASYNCHRONOUS (ASYNCHRONOUS=specifier) to determine whether asynchronous I/O is allowed. If it is allowed, a value of YES is returned.
Additionally, you can use the INQUIRE statement with the keyword of PENDING (PENDING= specifier) to determine whether previously pending asynchronous data transfers are complete.
If an ID= specifier appears and the specified data transfer operation is complete, the variable specified by PENDING is assigned the value False and the INQUIRE statement performs a wait operation for the specified data transfer.
If the ID= specifier is omitted and all previously pending data transfer operations for the specified unit are complete, the variable specified by PENDING is assigned the value False and the INQUIRE statement performs wait operations for all previously pending data transfers for the specified unit.
Otherwise, the variable specified by PENDING is assigned the value True and no wait operations are performed. Previously pending data transfers remain pending.
A data attribute called ASYNCHRONOUS specifies that a variable may be subject to asynchronous input/output. Assigning this attribute to a variable allows certain optimizations to occur.
For more information, see the following topics in the Language Reference:
Asynchronous Specifier
Open: ASYNCHRONOUS Specifier
INQUIRE: ASYNCHRONOUS Specifier
ASYNCHRONOUS Statement and Attributes