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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Program Structure Control Statements<br />

This feature is helpful in avoiding duplication of code for a function (such as I/O) required in a number of<br />

places throughout a program. It can also be an aid to writing a well-structured program.<br />

Each REMOTE-block within the same program unit must have a different name and it must not be a<br />

subprogram or variable name. Note that a REMOTE-block is local to the program unit in which it is<br />

defined and may not be referenced (executed) from another program unit.<br />

REMOTE-blocks may be defined anywhere in the program unit except as follows.<br />

1. They must follow all specification statements.<br />

2. They must not be defined within a control structure.<br />

If a REMOTE BLOCK statement is encountered during execution, control is transferred to the statement<br />

following the corresponding END BLOCK statement.<br />

Note that the nested definition of REMOTE-blocks is not permitted.<br />

Example:<br />

EXECUTE A<br />

PRINT *, ’FIRST’<br />

.<br />

.<br />

.<br />

EXECUTE A<br />

PRINT *, ’SECOND’<br />

.<br />

.<br />

.<br />

REMOTE BLOCK A<br />

I = I + 1<br />

PRINT *, ’I=’, I<br />

END BLOCK<br />

Both EXECUTE statements will cause REMOTE-block A to be executed. That is, variable I will be<br />

incremented and its value will be printed. When the block has been executed by the first EXECUTE<br />

statement, control returns to the PRINT statement following it and the word FIRST is printed. Similarly,<br />

when the block is executed by the second EXECUTE statement, control returns to the PRINT statement<br />

following it and the word SECOND is printed.<br />

REMOTE-blocks may be executed from other REMOTE-blocks. For example, REMOTE-block A might<br />

contain the statement EXECUTE B, where B is a REMOTE-block defined elsewhere in the program unit.<br />

The execution of REMOTE-blocks from other REMOTE-blocks may take place to any level; however, the<br />

recursive execution of REMOTE-blocks is not permitted, either directly or through a chain of EXECUTE<br />

statements. Attempts to execute REMOTE-blocks recursively are detected as errors at execution time.<br />

EXECUTE and REMOTE BLOCK 205

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

Saved successfully!

Ooh no, something went wrong!