Data Space Efficiency [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Programmer's Guide
Data Space Efficiency
The suggestions below help to decrease the amount of space needed to
store data.
Eliminate Redundant or Unused Variables
Eliminate redundant or unused variables. Redundant variables are defined
and used only one time. For example, in the statements:
temp1 = a * 25.0
temp2 = b**3
answer = temp1 + temp2
the variables temp1 and temp2 are redundant. The three lines can be
rewritten as:
answer = a * 25.0 + b**3
The cross reference facility can be used to locate the redundant and
unused variables. Refer to the CROSSREF or XREF compiler directive in
the HP FORTRAN 77/iX Reference.
Avoid Common Variables
Common variables remain in your data space throughout the run of your
program, but local variables typically are only in the data space when
the subroutine in which they are declared is active. Do not place
variables that are accessed by only one routine into common blocks.
When using COMMON and EQUIVALENCE statements, group variables of the same
type. This prevents wasted space due to differences in data type
alignment.
Use INTEGER*2 and LOGICAL*2 Data
To save data space, use the SHORT compiler option so that integer and
logical data use 16 bits instead of 32 bits. However, be aware that some
constructs require 4-byte types. Among these are all integer and logical
I/O specifiers whose values are set by the I/O library (such as most
INQUIRE statement specifiers) and integer variables in ASSIGN statements.
NOTE You can decrease performance by using 16-bit data.
MPE/iX 5.0 Documentation