I have been tasked with porting some old (circa 1986) VAX VMS FORTRAN code to c++ and have run into a bit of a stumbling block. The following two lines of code are part of a computed goto.
WRITE(2'N) (Y (I), I = 1, 5)
READ(2'N, ERR = 48) (Y (I), I = 1, 5)
My problem is the unit designator "2'N" , if that is indeed what it is. "N" is an integer variable passed in to the subroutine. I've done quite a bit of googleing for this pattern and reading what VMS documentation I could find, but have been unable to locate any info with respect to this pattern with the apostrophe. I understand the implied do loop that follows the write and read statements, but I don't understand 'where' this is writing to and reading from. Browsing the rest of the FORTRAN code doesn't reveal a unit=2 open statement that could be associated with this call, so it seems likely it's not a disk file, but I'm not certain. I'm hoping someone here can reach back into their memory and help me out.
If I read the VMS VAX FORTRAN manual correctly, 'N
specifies the N
-th record in unit 2
.
From Cl. 7.1.1.6 "Record Specifier":
The record specifier identifies the number of the record you wish to access in a file with relative organization. It takes either one of the following forms:
REC = r 'r
r
Is a numeric expression with a value that represents the position in a direct access file of the record to be accessed. [...]
Please note that this is not Standard-conforming Fortran! Most compilers will not accept this syntax. Instead, use REC=...
:
WRITE(2, REC=N) (Y (I), I = 1, 5)
READ(2, REC=N, ERR = 48) (Y (I), I = 1, 5)
The file at unit 2
needs not be open explicitly. This is specified in the same document, Cl. 7.1.1.2 "Logical Unit Specifier":
A logical unit number is assigned to a file or device in one of the two ways:
- Explicitly trough an OPEN statement [...]
- Implicitly by the system [...]
In the latter case, the file name used is defined in Cl. 4.2.2.1 "FORTRAN Logical Names" of the VAX Fortran user manual:
VAX FORTRAN provides predefined logical names in the following form:
FOR0nn[.DAT]
[...]
For example:
WRITE (17,200)
If you enter the preceding statement without including an explicit file specification, the data is written to a file named FOR017.DAT on your default disk under your default directory.
Most modern compilers will create a file fort.nn
in this case.