VMS Help FORTRAN, Statements, AUTOMATIC and STATIC *Conan The Librarian (sorry for the slow response - running on an old VAX) |
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 /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 /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 following call or return to the subprogram.
|