The SAVE statement preserves items in a subprogram after the RETURN or END statements are executed, preventing them from becoming undefined.
Parameter |
Description |
v |
Name of an array, variable, or common block (enclosed in slashes), occurring in a subprogram |
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.
The following constructs must not appear in a SAVE statement:
Variables or arrays in a common block
Dummy argument names
Record names
Procedure names
Automatic variables or arrays
SUBROUTINE FFA(N) DIMENSION A(1000,1000), V(1000) SAVE A ... RETURN END