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.75 SAVE Statement<br />

<br />

SAVE [a [,a] ...]<br />

where:<br />

a<br />

is a named common block preceded and followed by a slash (/), a variable name or an array name.<br />

The SAVE statement is used to retain the value of an entity after the execution of a RETURN or END<br />

statement in a subprogram. Upon re-entry to the subprogram, the entity will have the same value it had<br />

when exit was made from the subprogram. However, an entity belonging to a common block that has<br />

appeared in a SAVE statement may become redefined in another program unit.<br />

Notes:<br />

1. A name cannot appear in a SAVE statement more than once in the same program unit.<br />

2. Dummy arguments, procedure names and names belonging to a common block are not permitted<br />

in a SAVE statement.<br />

3. A SAVE statement with no list is identical to a SAVE statement containing all allowable names in<br />

a program unit.<br />

4. A common block name appearing in a SAVE statement has the same effect of specifying all<br />

names belonging to that common block in the SAVE statement.<br />

5. If a named common block is specified in a SAVE statement in a subprogram, it must be specified<br />

in a SAVE statement in every subprogram in which that common block appears. Furthermore,<br />

upon executing a RETURN or END statement, the current values of the entities in that common<br />

block are made available to the next program unit executed in which that common block appears.<br />

6. If a named common block is specified in a SAVE statement in the main program unit, the current<br />

values of the entities in that common block are made available to every subprogram that<br />

specifies that common block. In this case, a SAVE statement has no effect in the subprogram.<br />

In the following example, the subroutine BLKINIT initializes the entities of the common block BLK and<br />

uses a SAVE statement to ensure that their values are made available to subroutine BLKPRT.<br />

Example:<br />

SAVE Statement 135

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

Saved successfully!

Ooh no, something went wrong!