Top: f77 Up: 13 - Statements
Previous: 13,7,1 - Conversion_Rules Next: 13,9 - BACKSPACE
Section 13,8: AUTOMATIC_and_STATIC
The AUTOMATIC and STATIC statements are used within a called
subprogram to control the allocation of storage to variables and
the initial value of variables. Statement format:
AUTOMATIC v [,v]...
STATIC v [,v]...
v Is the name of a variable, array, or array declarator.
The following table summarizes the difference between automatic and
static variables upon entry to and exit from a subprogram:
+-----------+---------------------------+------------------------+
| Variable | Entry | Exit |
+-----------+---------------------------+------------------------+
| AUTOMATIC | Variables are unassigned, | The storage area allo- |
| | and do not reflect any | cated to the variable |
| | changes caused in the | is deleted. |
| | previous execution of | |
| | the program. | |
+-----------+---------------------------+------------------------+
| STATIC | Values of the subprogram | The current values of |
| | variables are unchanged | the variables are kept |
| | since the last execution | in the static storage |
| | of the subprogram. | area. |
+-----------+---------------------------+------------------------+
By default, all variables are STATIC. To change the default from
STATIC to AUTOMATIC, specify the -assume recursive compiler option.
To override the compiler option in effect for specific variables,
specify the variables in AUTOMATIC or STATIC type statements.
NOTE
Variables in COMMON, DATA, EQUIVALENCE, and SAVE
statements, or in BLOCK DATA subprograms are always
STATIC, regardless of the -assume recursive
compiler option or any previous AUTOMATIC
specification.
AUTOMATIC variables can reduce memory use because only the
variables currently being used are allocated to memory.
AUTOMATIC variables permit recursion. With recursion, a subprogram
can call itself (directly or indirectly), and resulting values are
available upon a subsequent call or return to the subprogram.
Top: f77 Up: 13 - Statements
Previous: 13,7,1 - Conversion_Rules Next: 13,9 - BACKSPACE