FORTRAN 77 Language Reference

Description

For automatic variables, there is one copy for each invocation of the procedure. To avoid local variables becoming undefined between invocations, f77 classifies every variable as either static or automatic with all local variables being static by default. For other than the default, you can declare variables as static or automatic in a STATIC @, AUTOMATIC @, or IMPLICIT statement. See also the discussion of the -stackvar option in the Fortran User's Guide.

One usage of AUTOMATIC is to declare all automatic at the start of a function.

Example: Recursive function with implicit automatic:


       INTEGER FUNCTION NFCTRL( I )
       IMPLICIT AUTOMATIC (A-Z)
       ...
       RETURN
       END

Local variables and arrays are static by default, so in general, there is no need to use SAVE. You should use SAVE to ensure portability. Also, SAVE is safer if you leave a subprogram by some way other than a RETURN.