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>Language</strong> <strong>Reference</strong><br />

READ statement to be executed when an end of file condition is encountered during the READ and to be<br />

by-passed immediately following a READ statement. It is not valid to use this control statement with<br />

direct-access or memory-to-memory reads. Clearly, it is not valid to use this statement when END= is<br />

specified in the READ statement.<br />

Example:<br />

READ(7, *) I, X<br />

AT END DO<br />

PRINT *, ’END-OF-FILE ENCOUNTERED’<br />

EOFSW = .TRUE.<br />

END AT END<br />

If the READ statement is executed without encountering end of file, control passes to the statement<br />

following the END AT END statement. If an end of file condition occurs during the read, the string,<br />

END-OF-FILE ENCOUNTERED is printed, logical variable EOFSW is assigned the value .TRUE. and<br />

control passes to the statement following the END AT END statement.<br />

Example:<br />

READ(7, *) X<br />

AT END, EOFSW = .TRUE.<br />

If an end of file is not encountered by the READ statement, control passes to the statement following the AT<br />

END statement. If an end-of-file condition occurs, variable EOFSW is set to .TRUE. and control then<br />

passes to the statement following the AT END statement. Note that the use of the second form of the AT<br />

END statement requires the use of a comma (,) between the AT END word and the executable statement.<br />

This is necessary to distinguish the case where the executable statement is an assignment statement. The<br />

executable statement may be any statement that is also allowed as the operand of a logical IF statement.<br />

9.17 Notes on Structured Programming Statements<br />

In addition to the definitions and examples of these constructs, the following points should be noted:<br />

(i)<br />

Any of the new control statements with their blocks may be used within the block of any<br />

other statement. For example, a WHILE-block may contain another WHILE or an<br />

IF-THEN-ELSE block. Blocks may be nested in this manner to any level within storage<br />

limitations. An important exception to this rule is the REMOTE-block A REMOTE-block<br />

may contain other types of blocks (nested to any level); however, another REMOTE-block<br />

may not be defined within it. Furthermore, REMOTE-blocks may not be defined within<br />

another control structure. The following example is illegal.<br />

Example:<br />

* Illegal definition of a REMOTE-block.<br />

IF( I .EQ. 3 )then<br />

REMOTE BLOCK A<br />

.<br />

.<br />

.<br />

END BLOCK<br />

END IF<br />

(ii)<br />

When nesting blocks, the inner blocks must always be completed with the appropriate<br />

block-terminating END statement before the outer blocks are terminated. Similarly, when<br />

nesting blocks with DO-loops, a DO-loop started within a block must be completed before<br />

212 Notes on Structured Programming Statements

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

Saved successfully!

Ooh no, something went wrong!