The REWIND statement positions the file associated with the specified unit to its initial point.
Use the TOPEN() routines to rewind tape devices. See the Fortran Library Reference Manual for details.
REWIND u
REWIND ([UNIT=] u [, IOSTAT=ios] [, ERR= s])
Parameter |
Description |
u |
Unit identifier of an external unit connected to the file u must be connected for sequential access, or append access. |
ios |
I/O specifier, an integer variable or an integer array element |
s |
Error specifier: s must be the label of an executable statement in the same program in which this REWIND statement occurs. The program control is transferred to this label in case of an error during the execution of the REWIND statement. |
The options can be specified in any order.
Rewinding a unit not associated with any file has no effect. Likewise, REWIND in a terminal file has no effect either.
Using a REWIND statement on a direct-access file is not defined in the FORTRAN 77 Standard, and is unpredictable.
Example 1: Simple form of unit specifier:
ENDFILE 3 REWIND 3 READ (3,'(I2)') I REWIND 3 READ (3,'(I2)')I
Example 2: REWIND with the UNIT=u form of unit specifier and error trap:
INTEGER CODE ... REWIND (UNIT = 3) REWIND (UNIT = 3, IOSTAT = CODE, ERR = 100) ... 100 WRITE (*,*) 'error in rewinding' STOP