Sun Studio 12 Update 1: Fortran User's Guide

4.2.3 Size and Alignment of Data Types

Storage and alignment are always given in bytes. Values that can fit into a single byte are byte-aligned.

The size and alignment of types depends on various compiler options and platforms, and how variables are declared. The default maximum alignment in COMMON blocks is to 4-byte boundaries.

Default data alignment and storage allocation can be changed by compiling with special options, such as -aligncommon, -f, -dalign, -dbl_align_all,- xmemalign,, and- xtypemap. The default descriptions in this manual assume that these options are not in force.

There is additional information in the Fortran Programming Guide regarding special cases of data types and alignment on certain platforms.

The following table summarizes the default size and alignment, ignoring other aspects of types and options.

Table 4–3 Default Data Sizes and Alignments (in Bytes)

Fortran Data Type 

Size 

DefaultAlignment 

Alignment inCOMMON  

BYTE X

CHARACTER X

CHARACTER*n X

COMPLEX X

COMPLEX*8 X

DOUBLE COMPLEX X

COMPLEX*16 X

COMPLEX*32 X

16 

16 

32 

8/16 

DOUBLE PRECISION X

REAL X

REAL*4 X

REAL*8 X

REAL*16 X

16 

8/16 

INTEGER X

INTEGER*2 X

INTEGER*4 X

INTEGER*8 X

LOGICAL X

LOGICAL*1 X

LOGICAL*2 X

LOGICAL*4 X

LOGICAL*8 X

Note the following:

Options -f or -dalign force alignment of all 8, 16, or 32-byte data onto 8-byte boundaries. Option -dbl_align_all causes all data to be aligned on 8-byte boundaries. Programs that depend on the use of these options may not be portable.