HP-UX Floating-Point Guide
190 Chapter 7
Performance Tuning
Static Variables
Static Variables
A static variable retains its value between invocations of the routine in
which it is declared. From a performance standpoint, static variables are
costly because they prohibit the compiler from making certain types of
optimizations. For example, a subroutine that contains a static variable
is ineligible for certain optimizations.
There are several ways to give a variable static storage class. In C, you
can declare the variable globally, or you can use the static storage class
specifier. In Fortran, you can use the +save, -K or +e option (see
“Creating and Zeroing Static Data (Fortran only)” on page 178); place
variables in a common block; specify them in a SAVE statement; use a
DATA statement to initialize variables; or give the initial value in a
declaration. The preferred method is always to specify static duration
only for those variables that absolutely must be static. For example, you
should be particularly cautious about using the +save, -K and +e
options because they place all of a program’s local variables in static
storage.