EQUIVALENCE Statement or Redefined Common Blocks [ HP FORTRAN 77/iX Migration Guide ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Migration Guide
EQUIVALENCE Statement or Redefined Common Blocks
HP FORTRAN 77/iX has different alignment requirements from HP FORTRAN
77/V. In most programs, the compiler automatically allocates the
alignment. However, your HP FORTRAN 77/V program might force a specific
alignment by the use of EQUIVALENCE or implicitly expect a particular
alignment by using different definitions of the same common block among
program units. Typically, such explicit or implicit equivalences are
used for three reasons: to change the data type of a variable, to pack
variables into a logical record to be passed to system routines or
routines coded in another language, or to save space.
An equivalence that changes the data type of a variable is safe and
presents no problem in migration from HP FORTRAN 77/V to HP FORTRAN
77/iX, provided that the equivalenced variables or arrays are the same
size in memory (for example, when equivalencing a REAL*4 and an
INTEGER*4). Multiple equivalences to an array, however, are likely to
produce a dependency on the alignment convention of the compiler and
generate error messages.
The type of equivalence that creates a packed record is commonly used to
call database intrinsics and other system intrinsics. The compiler flags
this as an error if an alignment is specified that conflicts with the
requirements of HP FORTRAN 77/iX.
These are some solutions to alignment problems:
* If your program has alignment problems, specify HP3000_16
ALIGNMENT; this causes the compiler to use HP FORTRAN 77/V's
alignment rules and to generate code to handle the resulting
variables correctly. Specify the ALIGNMENT option before the
first statement in your compilation file. This will cause the
options to take effect in every program unit (mixing alignments
generally produces undesirable results).
* If you call FORTRAN subprograms from other languages (for example,
to receive elements of Pascal packed records and any COBOL
compatible type) that may align variables other than on their
regular boundaries, specify HP3000_16 ALIGNMENT.
NOTE Specifying HP3000_16 ALIGNMENT causes a slight reduction in
performance, so do not use it unnecessarily.
* If your program uses equivalence to overlay one logical set of
data items with another (planning for them to be used separately,
for data space savings), consider modifying it not to do this.
The practice is unnecessary in MPE/iX (with its large data space)
and could introduce defects during software maintenance on such a
fragile construct.
MPE/iX 5.0 Documentation