HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
COMMON
Chapter 10 303
HP Fortran also allows blank—or unnamed—common to be initialized.
Common block size
The size of a common block is determined by the number and type of the variables it contains.
In the following example, the common block my_block takes 20 bytes of storage: b uses 8 (2
bytes per element) and arr uses 12 (4 bytes per element):
INTEGER(2) b(4)
INTEGER(4) arr(3)
COMMON /cb/b, arr
Data space within the common area for arrays b and arr shown in this example is allocated
as follows:
Allocation common block storage
Common block storage is allocated at link time. It is not local to any one program unit.
Each program unit that uses the common block must include a COMMON statement that
contains the block name, if a name was specified. Variables assigned to the common block by
the program unit need not correspond by name, type, or number of elements with those of any
other program unit. The only consideration is the size of the common blocks referenced by the
different program units. Correspondence between objects in different instances of the same
common block is established by storage association.
Note the following for HP Fortran: when types with different alignment restrictions are mixed
in a common block, the compiler may insert padding bytes as necessary.
Examples
The following example illustrates how the same common block can be declared in different
program units with different variables but the same size:
Table 10-5
Bytes Common block variables
0, 1, 2, 3 b(1), b(2)
4, 5, 6, 7 b(3), b(4)
8, 9, 10, 11 arr(1)
12, 13, 14, 15 arr(2)
16, 17, 18, 19 arr(3)