Data Alignment Considerations

For optimal performance with most cases, make sure your data is aligned naturally. If you must use 1- or 2-byte integer or logical data, in some cases specifying 4- or 8-byte alignment provides better performance (see Ordering Data Declarations to Avoid Unaligned Data).

A natural boundary is a memory address that is a multiple of the data item's size (data type sizes are described in Data Representation ). For example, a REAL (KIND=8) data item aligned on natural boundaries has an address that is a multiple of 8. An array is aligned on natural boundaries if all of its elements are so aligned.

All data items whose starting address is on a natural boundary are naturally aligned. Data not aligned on a natural boundary is called unaligned data.

Although the Visual Fortran compiler naturally aligns individual data items when it can, certain Compaq Fortran statements (such as EQUIVALENCE) can cause data items to become unaligned (see Causes of Unaligned Data and Ensuring Natural Alignment).

Although you can use the DF command /align: keyword options to ensure naturally aligned data, you should check and consider reordering data declarations of data items within common blocks and structures. Within each common block, derived type, or record structure, carefully specify the order and sizes of data declarations to ensure naturally aligned data. Start with the largest size numeric items first, followed by smaller size numeric items, and then nonnumeric (character) data.

The following sections discuss data alignment considerations in more detail: