15.1.13 OPTIONS Directive

The OPTIONS directive controls alignment of fields in record structures and data items in common blocks. The fields and data items can be naturally aligned (for performance reasons) or they can be packed together on arbitrary byte boundaries.

The OPTIONS directive takes the following form:

 cDEC$ OPTIONS /[NO]ALIGN[=p]
    ...
 cDEC$ END OPTIONS
c
Is one of the following: C (or c), !, or * (see Section 15.1.1).
p
Is a specifier with one of the following forms:
{ [class =] rule     }
{ (class = rule,...) }
{ ALL                }
{ NONE               }
class
Is one of the following keywords:

  • COMMONS: For common blocks

  • RECORDS: For records

  • STRUCTURES: A synonym for RECORDS
rule
Is one of the following keywords:

  • PACKED

    Packs fields in records or data items in common blocks on arbitrary byte boundaries.

  • NATURAL

    Naturally aligns fields in records and data items in common blocks on up to 64-bit boundaries (inconsistent with the Fortran 90 standard).

    This keyword causes the compiler to naturally align all data in a common block, including INTEGER(8), REAL(8), and all COMPLEX data.

  • STANDARD

    Naturally aligns data items in common blocks on up to 32-bit boundaries (consistent with the Fortran 90 standard).

    This keyword only applies to common blocks; so, you can specify /ALIGN=COMMONS=STANDARD, but you cannot specify /ALIGN=STANDARD.

ALL
Is the same as specifying /ALIGN, /ALIGN=NATURAL, and /ALIGN=(RECORDS=NATURAL,COMMONS=NATURAL).
NONE
Is the same as specifying /NOALIGN, /ALIGN=PACKED, and /ALIGN=(RECORDS=PACKED,COMMONS=PACKED).

Rules and Behavior

The OPTIONS (and accompanying END OPTIONS) directives must come after OPTIONS, SUBROUTINE, FUNCTION, and BLOCK DATA statements (if any) in the program unit, and before the executable part of the program unit.

The OPTIONS directive supersedes the compiler option that sets alignment.

For performance reasons, Compaq Fortran aligns local data items on natural boundaries. However, EQUIVALENCE, COMMON, RECORD, and STRUCTURE data declaration statements can force misaligned data. By default, you receive compiler messages when misaligned data is encountered.


Note
Misaligned data significantly increases the time it takes to execute a program. As the number of misaligned fields encountered increases, so does the time needed to complete program execution. Specifying cDEC$ OPTIONS/ALIGN (or the compiler option that sets alignment) minimizes misaligned data.

If you want aligned data in common blocks, do one of the following:

If you want packed unaligned data in a record structure, do one of the following:

An OPTIONS directive must be accompanied by an END OPTIONS directive; the directives can be nested up to 100 levels. For example:

 CDEC$ OPTIONS   /ALIGN=PACKED         ! Start of Group A
    declarations
 CDEC$ OPTIONS   /ALIGN=RECO=NATU         ! Start of nested Group B
    more declarations
 CDEC$ END   OPTIONS                      ! End of Group B
    still more declarations
 CDEC$ END   OPTIONS                   ! End of Group A

The CDEC$ OPTIONS specification for Group B only applies to RECORDS; common blocks within Group B will be PACKED. This is because COMMONS retains the previous setting (in this case, from the Group A specification).

For More Information:


Previous Page Next Page Table of Contents