24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>FORTRAN</strong> Statements<br />

2.74 REWIND Statement<br />

<br />

REWIND u<br />

REWIND (alist)<br />

where:<br />

u<br />

alist<br />

is an external unit identifier.<br />

is a list of rewind specifiers separated by commas:<br />

[UNIT =] u<br />

IOSTAT = ios<br />

ERR = s<br />

Execution of a REWIND statement causes the file connected to the specified unit to be positioned at the<br />

beginning (or before the first record) of the file.<br />

Rewind Specifiers<br />

[UNIT =] u<br />

IOSTAT = ios<br />

ERR = s<br />

u is an external unit identifier. An external unit identifier is a non-negative integer<br />

expression. If the optional UNIT= specifier is omitted then the specifier must be the first<br />

item in the list of specifiers.<br />

is an input/output status specifier. The integer variable or integer array element ios is<br />

defined with zero if no error condition exists or a positive integer value if an error condition<br />

exists.<br />

is an error specifier and s is a statement label. When an error occurs, execution is<br />

transferred to the statement labelled by s.<br />

Example:<br />

LOOP<br />

READ( UNIT=7, END=100, FMT=200 )RECORD<br />

PRINT *, RECORD<br />

ENDLOOP<br />

100 REWIND( UNIT=7 )<br />

LOOP<br />

READ( UNIT=7, END=101, FMT=200 )RECORD<br />

WRITE( UNIT=8, FMT=200 )RECORD<br />

ENDLOOP<br />

101 CONTINUE<br />

In the previous example, we illustrate how one might process the records in a file twice. After reaching the<br />

endfile record, a REWIND statement is executed and the file is read a second time.<br />

REWIND Statement 133

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!