File Sharing on Linux

Depending on the value specified by the ACTION (or READONLY) specifier in the OPEN statement, the file will be opened by your program for reading, writing, or both reading and writing records. This simply checks that the program itself executes the type of statements intended.

File locking mechanisms allow users to enable or restrict access to a particular file when that file is being accessed by another process.

Intel® Fortran file locking features provide three file access modes:

The file locking mechanism looks for explicit setting of the corresponding specifier in the OPEN statement. Otherwise, the Fortran runtime does not perform any setting or checking for file locking. The process can access the file regardless of the fact that other processes have already opened or locked the file.

Examples

In the following examples, Process 1 and Process 2 are separate programs running at the same time, and opening the same file. Process 1 opens the file first. Process 2 opens the file later, before Process 1 closes it. The processes may or may not be cooperating.

Implicit Shared Mode (No Locking)

Process 1 opens the file without a specifier, resulting in no locking.

Process 2 now tries to open the file:

Explicit Shared Mode

Process 1 opens the file with Explicit Shared mode.

Process 2 now tries to open the file:

Exclusive Mode

Process 1 opens the file with Exclusive mode.

Process 2 now tries to open the file:

The Fortran runtime does not coordinate file entry updates during cooperative access. The user needs to coordinate access times among cooperating processes to handle the possibility of simultaneous WRITE and REWRITE statements on the same record positions.