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

ID 767251
Date 6/24/2024
Public

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

Document Table of Contents

OPEN: SHARE Specifier

The SHARE specifier indicates whether file locking is implemented while the unit is open. It takes the following form:

SHARE = shr

shr

Is a scalar default character expression.

On Windows* systems, this expression evaluates to one of the following values:

'DENYRW'

Indicates deny-read/write mode. No other process can open the file.

'DENYWR'

Indicates deny-write mode. No process can open the file with write access.

'DENYRD'

Indicates deny-read mode. No process can open the file with read access.

'DENYNONE'

Indicates deny-none mode. Any process can open the file in any mode.

On Linux* systems, this expression evaluates to one of the following values:

'DENYRW'

Indicates exclusive access for cooperating processes.

'DENYNONE'

Indicates shared access for cooperating processes.

On Windows systems, the default is 'DENYWR'. However, if you specify compiler option fpscomp general or the SHARED specifier, the default is 'DENYNONE'.

On Linux systems, no restrictions are applied to file opening if you do not use a locking mechanism.

'COMPAT' is accepted for compatibility with previous versions. It is equivalent to 'DENYNONE'.

Use the ACCESS specifier in an INQUIRE statement to determine the access permission for a file.

Be careful not to permit other users to perform operations that might cause problems. For example, if you open a file intending only to read from it, and want no other user to write to it while you have it open, you could open it with ACTION='READ' and SHARE='DENYRW'. Other users would not be able to open it with ACTION='WRITE' and change the file.

Suppose you want several users to read a file, and you want to make sure no user updates the file while anyone is reading it. First, determine what type of access to the file you want to allow the original user. Because you want the initial user to read the file only, that user should open the file with ACTION='READ'. Next, determine what type of access the initial user should allow other users; in this case, other users should be able only to read the file. The first user should open the file with SHARE='DENYWR'. Other users can also open the same file with ACTION='READ' and SHARE='DENYWR'.