HP Fortran Programmer's Reference (September 2007)

I/O and file handling
Nonadvancing I/O
Chapter 8216
Nonadvancing I/O
By default, a data transfer leaves the file positioned after the last record read or written. This
type of I/O is called advancing. Fortran 90 also allows nonadvancing I/O, which positions the
file just after the last character read or written, without advancing to the next record. It is
character-oriented and can be used only with external files opened for sequential access. It
cannot be used with list-directed or namelist-directed I/O.
To use nonadvancing I/O, you must specify ADVANCE='NO' in the READ or WRITE statement.
The example program in “File access” on page 231 uses nonadvancing I/O in the first WRITE
statement, which is reproduced here:
WRITE (6, FMT='(A)', ADVANCE='NO') &
' Enter number to insert in list: '
The effect of nonadvancing I/O on the WRITE statement is to suppress the newline character
that is normally output at the end of a record. This is the desired effect in the example
program: by using a nonadvancing WRITE statement, the user input to the READ statement
stays on the same line as the prompt.
You can get the same effect with the newline ($) edit descriptor, an HP Fortran extension that
also suppresses the carriage-return/linefeed sequence at the end of a record; see “Newline ($)
edit descriptor” on page 242.
For an example program that illustrates nonadvancing I/O in a READ statement, see
“Nonadvancing I/O” on page 229. For more information about nonadvancing I/O and the
ADVANCE= specifier, see the READ and WRITE statements in Chapter 10.