4.16 SAVE Statement

The SAVE statement causes the definition of data entities to be retained after execution of a RETURN or END statement in a subprogram. It takes the following form:

SAVE [nlist]
nlist
Is a list of variables, arrays, array declarators, named common blocks (preceded and followed by a slash), records, record arrays, or record array declarators, separated by commas.

If array names or common block names are used, the entire array or common block is retained.

Rules and Behavior

A SAVE statement cannot include a blank common block, names of entities in a common block, procedure names, and names of dummy arguments.

Within a program unit, an entity listed in a SAVE statement does not become undefined upon execution of a RETURN or END statement within that program unit.

Even though a common block can be included in a SAVE statement, individual entities within the common block could become undefined (or redefined) in another program unit.

When a SAVE statement does not explicitly contain a list, it is treated as though all allowable items in the program unit are specified on the list.


Note
It is not necessary to use SAVE statements in Compaq Fortran 77 programs. The definitions of data entities are retained automatically by default, unless you specify the compiler option RECURSIVE. (Optimizations may also affect this. For more information, see your user manual.) However, the FORTRAN-77 Standard requires using SAVE statements for programs that depend on such retention for their correct operation. If you want your programs to be portable, you should include SAVE statements where your programs require them.

The omission of such SAVE statements in necessary instances is not always flagged, even when you specify the compiler option STANDARD, because the compiler may not be able to determine whether such dependences exist.


For More Information:


Previous Page Next Page Table of Contents