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 Fortran structures, see STRUCTURE statement in Intel® Fortran Language Reference Manual.

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.

Example:

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

The -align option enables padding inserted to assure 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 Command-line Options.

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 data, 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 derived types with the SEQUENCE attribute are packed regardless of any other alignment rules. Note that -align none implies
-align
nosequence .

The -align sequence option means that derived types with the SEQUENCE attribute 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 fields in these derived types to be naturally aligned.

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