Edits - Named Scratch Files

by Craig T. Dedo

May 22, 1997

1.	Edits to the Standard

These edits are with respect to the Fortran 95 Committee Draft, X3J3 / 96 -007r1 .

[140:35-36] Delete the sentence:

"If the STATUS= specifier has the value SCRATCH, the FILE= specifier shall be absent."

[140:38+] Add the following note:

[140:2-3+] Delete the sentence which starts with "If the STATUS= specifier is included..." and replace it with:

"If the STATUS= specifier is included in such an OPEN statement, it shall be specified with the value OLD or SCRATCH; the value SCRATCH shall be permitted only if the file to which the unit is already connected has a STATUS of SCRATCH."

[140:13+] Add the following text:

"If an existing file is not connected, execution of an OPEN statement that connects that file with a STATUS of SCRATCH is prohibited."

[141:18-19] Delete Note 9.14.

[End of Edits]

The following background information is provided for the convenience of readers.

2.	Rationale

Currently, the Fortran standard does not allow the user to name scratch files. Not allowing the user to name scratch files is an unnecessary irregularity. A named scratch file would be the only kind of named file which would be automatically deleted when the file is closed or execution terminates.

Allowing Fortran programmers to give names to scratch files would have several advantages. These advantages include:

•	This feature would allow the programmer to protect against accidentally overwriting existing files. This could happen if the processor generates a file name which is the same as the name of an existing file.

•	This feature would allow the programmer to specify a location for the scratch file which has enough space for the scratch file's contents.

•	The programmer could look at a scratch file's contents during execution.

If the processor does not delete scratch files if the program crashes, this feature would allow the programmer to do some post-mortem analysis.

3.	Technical Specification

This proposal would require a Fortran processor to allow the user to name files opened with the keyword STATUS="SCRATCH". Since previous practice did not allow the use of file names with scratch files, the programmer would still be allowed to open a scratch file without specifying a file name.

It is illegal to open a file with STATUS="SCRATCH" which has the same name as a non-scratch file which is already open, whether on the same or a different unit. If a file is attached to the same unit and the programmer opens it again with the same name, the open operation is legal only if the file has STATUS="SCRATCH".

It is illegal to open a scratch file with the same name as an existing file that is not open.

If the program crashes during execution, the existence of the scratch file after the crash is processor-dependent.

4.	References

ISO/IEC 1539-1:1991(E) International Standard Programming Language Fortran 90, 9.3.4

X3J3 / 96-004, X3J3 Journal of Requirements (JOR), Item 120

[End of J3 / 97-193]