Next: FORMAT Statement / FMT=
Up: Input / Output
Previous: READ Statement
READ and WRITE can be interchanged in the following,
(not all the specifiers can be used at the same time,)
WRITE([UNIT=]< unit >, [FMT=]< format >, IOSTAT=< int-variable >, ERR=< label >, &
ADVANCE=< advance-mode >, REC=< int-expr >) < output-list >
where
- UNIT=< unit > is a valid logical unit number or
* for the default (standard) output. If it is the first field then
the specifier is optional.
- FMT=< format > is a string of formatting
characters, a valid FORMAT statement label or a *
for free format. If this is the second field then the specifier is
optional.
- IOSTAT=< int-variable > specifies an integer variable to
hold a return code,
as usual, zero means no error.
- < label > in ERR=
is a valid label to where
control jumps if there is an WRITE error.
- ADVANCE=< advance-mode > specifies
whether each WRITE should
start a new record or not. setting the specifier, (< advance-mode >,)
to 'NO' initiates non-advancing I/O. The default is 'YES'.
If non-advancing I/O is used then the file must be connected for
sequential access and the format must be explicitly stated.
- REC=< int-expr > is the record number for direct access.
Consider,
WRITE(17,FMT='(I4)',IOSTAT=istat,ERR=10, END=11,EOR=12) ival
here, '(I4)' means INTEGER with 4 digits.
the labels 10, 11 and 12 are statements where
control can jump on an I /
O exception. ival is an INTEGER variable whose value is written
out.
WRITE(*,'(A)',ADVANCE='NO') 'Input : '
Since non-advancing output has been specified, the cursor will remain
on the same line as the string 'Input : '
, under normal
circumstances (default advancing output) the cursor would be positioned
at the start of the next line. Note the explicit format descriptor.
See later for a more detailed explanation of the format edit
descriptors.
Return to corresponding overview page
Next: FORMAT Statement / FMT=
Up: Input / Output
Previous: READ Statement
©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997Not for commercial use.