LF Fortran 95

REWIND Statement

Description

The REWIND statement repositions a file to its initial point.

Syntax

REWIND (position-spec-list)
Where:

position-spec-list is [[UNIT=]unit-number][, ERR=label][, IOSTAT=stat] where UNIT=, ERR=, and IOSTAT= can be in any order but if UNIT= is omitted, then unit-number must be first.

unit-number is a scalar INTEGER expression corresponding to the input/output unit number of an external file.

label is a statement label that is branched to if an error condition occurs during execution of the statement.

stat is a variable of type INTEGER that is assigned a positive value if an error condition occurs, a negative value if an end-of-file or end-of-record condition occurs, and zero otherwise.

Remarks

Rewinding a file that is connected but has zero size has no effect.

Note that REWIND may only be used on sequential access files.

Example

integer :: ios rewind 10 ! file on unit 10 rewound rewind (10,iostat=ios) ! rewind with status