FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-109
WRITE Statement
Execution of a WRITE statement causes values to be transferred from the output 
list to the specified file.
The first character of each record has the effect defined by the SPACECONTROL 
specifier in the OPEN statement.
Execution of a WRITE statement for a file that does not exist causes that file to be 
created. This does not apply to structured files.
•
Use of WRITE with EDIT format files
Use the INQUIRE statement’s NEXTREC specifier to obtain the line number of the 
last line written.
If the WRITE statement writes more than one line, the system forms each 
successive record number by adding 1000 to the last record number.
If the file was not opened with ACCESS = 'DIRECT' and the WRITE statement 
does not specify upd = .TRUE., the WRITE statement deletes all lines (if any) from 
the current position to the end of the file before writing the new line or lines.
You cannot WRITE to an EDIT format file in a FORTRAN program that has been 
compiled to run as a NonStop process. A program compiled with ENV OLD in 
effect is compiled to run as a NonStop process if it includes either a CHECKPOINT 
or START BACKUP statement. A program compiled with ENV COMMON in effect 
is compiled to run as a NonStop process if it includes a NONSTOP directive.
•
REC specifier
The system interprets negative record numbers according to the file type, as 
follows:
•
UNLOCK specifier
Use the UNLOCK specifier to coordinate file access when a file is shared among 
two or more processes.
If the value of unlock is .TRUE., FORTRAN uses the WRITEUPDATEUNLOCK 
procedure to restore access to the current record for the other processes that 
share the file. For additional information about file and record locking, see the 
ENSCRIBE Programmer’s Guide.
•
UPDATE specifier
The UPDATE specifier enables you to update, add, or delete records in structured 
files.
File Type REC = -1 REC = -2
EDIT format Beginning of file End of file
Other unstructured End of file End of file
Relative End of file First unused record position










