Common blocks (COMMON statement), derived-type data, and Compaq Fortran record structures (RECORD statement) usually contain multiple items within the context of the larger structure.
The following declarations can force data to be unaligned:
The order of variables in the COMMON statement determines their storage order.
Unless you are sure that the data items in the common block will be naturally aligned, specify either the /align:commons or /align:dcommons option, depending on the largest data size used.
For examples and more information, see Arranging Data in Common Blocks.
Derived-type data members are declared after a TYPE statement.
If your data includes derived-type data structures, unless you are sure that the data items in derived-type data structures will be naturally aligned, use the /align:records option (default).
If you omit the SEQUENCE statement, the /align:records option ensures all data items are naturally aligned.
If you specify the SEQUENCE statement, the /align:records option is prevented from adding necessary padding to avoid unaligned data (data items are packed) unless you also specify the /align:sequence option. When you use SEQUENCE, you should specify a data declaration order such that all data items are naturally aligned or specify /align:sequence.
For an example and more information, see Arranging Data Items in Derived-Type Data.
Compaq Fortran record structures usually contain multiple data items. The order of variables in the STRUCTURE statement determines their storage order. The RECORD statement names the record structure.
If your data includes Compaq Fortran record structures, you should use the /align:records option (default), unless you are sure that the data items in derived-type data and Compaq Fortran record structures will be naturally aligned.
For examples and more information, see Arranging Data Items in Compaq Fortran Record Structures.
EQUIVALENCE statements can force unaligned data or cause data to span natural boundaries.
To avoid unaligned data in a common block, derived-type data, or record structures, use one or both of the following:
Other possible causes of unaligned data include unaligned actual arguments and arrays that contain a derived-type structure or Compaq Fortran record structure.
When actual arguments from outside the program unit are not naturally aligned, unaligned data access will occur. Compaq Fortran assumes all passed arguments are naturally aligned and has no information at compile time about data that will be introduced by actual arguments during program execution.
For arrays where each array element contains a derived-type structure or Compaq Fortran record structure, the size of the array elements may cause some elements (but not the first) to start on an unaligned boundary.
Even if the data items are naturally aligned within a derived-type structure without the SEQUENCE statement or a record structures, the size of an array element might require use of /align options to supply needed padding to avoid some array elements being unaligned.
If you specify /align:norecords, no padding bytes are added between array elements. If array elements each contain a derived-type structure with the SEQUENCE statement, array elements are packed without padding bytes regardless of the DF command options specified. In this case, some elements will be unaligned.
When /align:records option is in effect, the number of padding bytes added by the compiler for each array element is dependent on the size of the largest data item within the structure. The compiler determines the size of the array elements as an exact multiple of the largest data item in the derived-type structure without the SEQUENCE statement or a record structure. The compiler then adds the appropriate number of padding bytes.
For instance, if a structure contains an 8-byte floating-point number followed by a 3-byte character variable, each element contains five bytes of padding (16 is an exact multiple of 8). However, if the structure contains one 4-byte floating-point number, one 4-byte integer, followed by a 3-byte character variable, each element would contain one byte of padding (12 is an exact multiple of 4).
For more information:
On the /align options, see Options Controlling Alignment.