| United States-English |
|
|
|
![]() |
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP
Fortran statementsSAVE (statement and attribute) |
|
Stores variables in static memory. SyntaxA type declaration statement with the SAVE attribute is:
The syntax of the SAVE statement is:
DescriptionThe SAVE statement and attribute cause objects in a subroutine or function to be stored in static memory, instead of being dynamically allocated whenever the procedure is invoked (the default case). A saved object retains its value and definition, association, and allocation status between invocations of the program unit in which the saved object is declared. If save-list is omitted, everything in the scoping unit that can be saved is saved. No other explicit occurrences of the SAVE attribute or the SAVE statement are allowed. The names of the following may appear in save-list:
If the name of a common block appears in save-list, it must be delimited by slashes (for example, /my_block/); all variables in the named common block are saved. If a common block is saved in one program unit, it must be saved in all program units (except main) where it appears. HP Fortran always saves all common blocks. The following must not appear in save-list:
Initializing a variable in a DATA statement or in a type declaration statement implies that the variable has the SAVE attribute, unless the variable is in a named common block in a block data subprogram. A SAVE statement in a main program unit has no effect. ExamplesThe SAVE statement in the following example saves the variables a, b, and c, as well as the variables in the common block dot:
The SAVE statement in the next example saves the values of all of the variables in the subroutine fixit:
Related statementsAUTOMATIC and STATIC Related conceptsFor related information, see the following:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||