Oracle® Solaris Studio 12.4: Fortran User's Guide

Exit Print View

Updated: March 2015
 
 

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
1
1
n
1
1
1
1
1
1
COMPLEX X
COMPLEX*8 X
DOUBLE COMPLEX X
COMPLEX*16 X
COMPLEX*32 X
8
8
16
16
32
4
4
8
8
8/16
4
4
4
4
4
DOUBLE PRECISION X
REAL X
REAL*4 X
REAL*8 X
REAL*16 X
8
4
4
8
16
8
4
4
8
8/16
4
4
4
4
4
INTEGER X
INTEGER*2 X
INTEGER*4 X
INTEGER*8 X
4
2
4
8
4
2
4
8
4
2
4
4
LOGICAL X
LOGICAL*1 X
LOGICAL*2 X
LOGICAL*4 X
LOGICAL*8 X
4
1
2
4
8
4
1
2
4
8
4
1
2
4
4

Note the following:

  • REAL*16 and COMPLEX*32: in 64-bit environments (compiling with -m64) the default alignment is on 16-byte (rather than 8-byte) boundaries, as indicated by 8/16 in the table. This data type is often referred to as quad precision.

  • Arrays and structures align according to their elements or fields. An array aligns the same as the array element. A structure aligns the same as the field with the widest alignment.

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.