SAVE attribute
Standard: F77 F90 F95 F2003
  Example Program
<Syntax>
type, SAVE [ , attr ]... :: decl-list

SAVE [ :: ] entity [ , entity ]...

SAVE

entity ::= name
         |  / common-block-name /
<Semantics>
The SAVE attribute specifies that a name is a local static variable, and retains its value after return from its procedure. A SAVE statement with no entity list specifies that all non-automatic entities in the procedure are saved. The SAVE attribute is also implicitly conferred on any variable that is given an initial value, either in its type declaration statement or in a DATA statement.

If a procedure that contains a saved variable is recursive, there is only one instance of that variable and it is shared between all instances of the procedure.

It is permitted to declare a variable to be saved in a main program; this has no effect.

The SAVE attribute can also be given to a common block; it specifies that all variables in the common block retain their value even when no active program unit is referencing the common block. This has no effect in NAGWare f95 (and all current Fortran compilers), because it saves common blocks by default.

Similarly, SAVE is permitted in a module, and specifies that all variables in the module retain their value even when no active program unit is referencing the module. This has no effect in NAGWare f95 (and all current Fortran compilers), because it saves module variables by default.
<Related>
Type Declaration statement