Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 3 Data types and data objects

Storage association and alignment

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

In general, no assumptions about the relative storage locations of any entities can be made. The use of COMMON and EQUIVALENCE statements enable storage association to be established. The detailed syntax and description of these statements is given in Chapter 10.

The COMMON statement enables common blocks of storage to be established. The use of a COMMON statement referring to the same common block in more than one program unit ensures that the same storage locations are referenced in each of the program units.

The EQUIVALENCE statement enables more than one name to be given to the same storage location within a program unit. Where common block elements or array elements are referenced, restrictions apply because of the imposed sequencing of these elements within storage.

The SEQUENCE statement appears only in a derived-type definition (see “Derived-type definition”). It enables derived-type variables to be located in common blocks and to be named in EQUIVALENCE statements.

Storage association alignment rule

The COMMON and SEQUENCE storage statements enforce an ordering of variables within storage. Association may be established between variables with different type and kind parameters. The general rules for the alignment of variables in storage are as follows:

  • A variable will be stored at an address that is a multiple of the alignment required for storage of a scalar variable with the same type and kind parameters (see Table 3-1 “ Types and kind parameters ”). This is an extension to the Fortran 90 Standard.

  • A derived type will have the same alignment as the component that has the most restrictive alignment requirement.

The following example illustrates how a sequence of variables would be stored within a derived type.

TYPE t
   SEQUENCE
   CHARACTER(LEN=7) :: c
   INTEGER(2) :: i2
   REAL(8) :: r8
   REAL(4) :: r4
END TYPE t
TYPE (t), DIMENSION(5) :: ta

Each element of t is allocated as in Table 3-5 “Example of structure storage”. The first component of t starts at an address that is a multiple of 8

Table 3-5 Example of structure storage

Component

Byte offset

Length

c

0

7

i2

8

2

r8

16

8

r4

24

4

padding

28

4

 

The four trailing padding bytes are necessary to preserve the alignment of r8 in each element of the array.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.