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.

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

2.72 REMOTE BLOCK Statement<br />

REMOTE BLOCK name<br />

where:<br />

name<br />

is a valid <strong>FORTRAN</strong> symbolic name.<br />

The REMOTE BLOCK statement is used to define a block of statements which may be executed by an<br />

EXECUTE statement. A REMOTE-block must be defined in the program unit in which it is used and is<br />

terminated by an END BLOCK statement. A REMOTE-block is similar in concept to a subroutine, with the<br />

advantage that shared variables do not need to be placed in a common block or passed in an argument list.<br />

When execution of the REMOTE-block is complete, control returns to the statement following the<br />

EXECUTE statement which invoked it.<br />

This feature is helpful in avoiding duplication of code for a common sequence of statements required in a<br />

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

feature can be mimicked using the ASSIGN and assigned GO TO statements. However, statement numbers<br />

must be introduced which could lead to errors.<br />

Each REMOTE-block must have a different name and it must not be a subprogram or variable name. Note<br />

that a REMOTE-block is local to the program unit in which it is defined and may not be referenced<br />

(executed) from another program unit.<br />

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

Example:<br />

EXECUTE INCR<br />

PRINT *, ’FIRST’<br />

EXECUTE INCR<br />

PRINT *, ’SECOND’<br />

.<br />

.<br />

.<br />

REMOTE BLOCK INCR<br />

I=I+1<br />

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

END BLOCK<br />

Both EXECUTE statements will cause REMOTE-block INCR 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 />

For more information, see the chapter entitled "Program Structure Control Statements" on page 193.<br />

REMOTE BLOCK Statement 131

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

Saved successfully!

Ooh no, something went wrong!