Alignment Options

-align recnbyte or -Zp[n]

Use the -align recnbyte (or -Zp[n]) option to specify the alignment constraint for structures on n-byte boundaries (where n = 1, 2, 4, 8, or 16 with -Zp[n]).

When you specify this option, each structure member after the first is stored on either the size of the member type or n-byte boundaries (where n = 1, 2, 4, 8, or 16), whichever is smaller.

For example, to specify 2 bytes as the packing boundary (or alignment constraint) for all structures and unions in the file prog1.f, use the following command:

ifort -Zp2 prog1.f

The default for IA-32 and Itanium-based systems is -align rec8byte or -Zp8. The -Zp16 option enables you to align Fortran structures such as common blocks. For information on Fortran record structures, see STRUCTURE statement in the Intel® Fortran Language Reference.

If you specify -Zp (omit n), structures are packed at 8-byte boundary.

-align  and -pad

The -align option is a front-end option that changes alignment of variables in a common block.


common /block1/ch,doub,ch1,int
integer int
character(len=1) ch, ch1
double precision doub

The -align option enables padding inserted to ensure alignment of doub and int on natural alignment boundaries. The -noalign option disables padding.

The -align option applies mainly to structures. It analyzes and reorders memory layout for variables and arrays and basically functions as -Zp{n}. You can disable either option with -noalign.

For -align keyword options, see your User's Guide, Volume I.

The -pad option is effectively not different from -align  when applied to structures and derived types. However, the scope of -pad is greater because it applies also to common blocks, derived types, sequence types, and VAX* structures.

Recommendations on Controlling Alignment with Options

The following options control whether the Intel Fortran compiler adds padding (when needed) to naturally align multiple data items in common blocks, derived-type structures, and Intel Fortran record structures:

The -align nocommons arbitrarily aligns the bytes of common block data. In this case, unaligned data can occur unless the order of data items specified in the COMMON statement places the largest numeric data item first, followed by the next largest numeric data (and so on), followed by any character data.

Specify the -align dcommons option for applications that use common blocks, unless your application has no unaligned data or, if the application might have unaligned data, all data items are four bytes or smaller. For applications that use common blocks where all data items are four bytes or smaller, you can specify -align commons instead of -align dcommons.

The -align nosequence option means that sequenced components are packed regardless of any other alignment rules. Note that -align none  implies -align nosequence.

The -align sequence option means that sequenced components obey whatever alignment rules are currently in use. Consequently, since -align record is a default value, then -align sequence alone on the command line will cause the components of these derived types to be naturally aligned.

The default behavior is that multiple data items in derived-type structures and record structures will be naturally aligned; data items in common blocks will not (-align records with -align nocommons ). In derived-type structures, using the SEQUENCE statement prevents -align records from adding needed padding bytes to naturally align data items.