FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-77
OPEN Statement
PROTECT specifier
When a process opens a Guardian file, the PROTECT option specifies to what
degree the process is willing to share access to the file with other openers or
potential openers of the file. The other openers might be in other processes or in
the same process as the current opener.
For example, if a process specifies PROTECT = 'EXCLUSIVE', the file must be
closed when the process opens the file. Furthermore, any subsequent attempt to
open the same file, including by the process that already has the file open, will fail
until the original process closes the file.
On the other hand, two processes can open the same file if both specify
PROTECT = 'SHARED'.
The default value is 'SHARED'.
°
'SHARED' specifies that multiple openers can access the file for both input and
output.
°
'PROTECTED' specifies that the file can be opened for output by only one
opener. Other openers can only read from the file.
°
'EXCLUSIVE' specifies that the file can be opened by only one opener.
Attempts to establish more than one open fail. Attempts to open a file with
exclusive access when the file is already open also fail.
Table 7-8 shows whether your attempt to open a file succeeds or fails, based on
the attribute value:
°
You specify for the:
°
MODE option ('INPUT', 'OUTPUT', or 'I-O')
°
PROTECT option ('SHARED', 'PROTECTED', or 'EXCLUSIVE')
°
Specified by other current openers of the same file for the:
°
MODE option ('INPUT', 'OUTPUT', or 'I-O')
°
PROTECT option ('SHARED', 'PROTECTED', or 'EXCLUSIVE')
Table 7-8. File Protection and Mode Interaction Between Opening
Processes (page 1 of 2)
File Already Open With
Open Operation Attempted With SHARED PROTECTED EXCLUSIVE
Protection
Specifier Mode Specifier I O I-O I O I-O I O I-O
SHARED INPUT S S S S S S F F F
OUTPUT SSSSSS F F F
I-O SSSFFF F F F