FORTRAN 77 Language Reference

SAVE

The SAVE statement preserves items in a subprogram after the RETURN or END statements are executed, preventing them from becoming undefined.

SAVE [ v [, v ] ]

Parameter 

Description 

v

Name of an array, variable, or common block (enclosed in slashes), occurring in a subprogram  

Description

SAVE variables are placed in an internal static area. All common blocks are already preserved because they have been allocated to a static area. Therefore, common block names specified in SAVE statements are allowed but ignored.

A SAVE statement is optional in the main program and has no effect.

A SAVE with no list preserves all local variables and arrays in the routine.

Local variables and arrays are already static by default, predisposing the need for SAVE. However, using SAVE can ensure portability, especially with routines that leave a subprogram by some way other than a RETURN.

Restrictions

The following constructs must not appear in a SAVE statement:

Example

Example: A SAVE statement:


       SUBROUTINE FFA(N) 
       DIMENSION A(1000,1000), V(1000) 
       SAVE A 
       ... 
       RETURN 
       END