FORTRAN 77 Language Reference

COMMON

The COMMON statement defines a block of main memory storage so that different program units can share the same data without using arguments.

COMMON [/[cb]/] nlist [[,]/[cb]/ nlist]

Parameter 

Description 

cb

Common block name 

nlist

List of variable names, array names, and array declarators 

Description

If the common block name is omitted, then blank common block is assumed.

Any common block name including blank common can appear more than once in COMMON statements in the same program unit. The list nlist following each successive appearance of the same common block name is treated as a continuation of the list for that common block name.

The size of a common block is the sum of the sizes of all the entities in the common block, plus space for alignment.

Within a program, all common blocks in different program units that have the same name must be of the same size. However, blank common blocks within a program are not required to be of the same size.

Restrictions

Formal argument names and function names cannot appear in a COMMON statement.

An EQUIVALENCE statement must not cause the storage sequences of two different common blocks in the same program unit to be associated. See Example 2.

An EQUIVALENCE statement must not cause a common block to be extended on the left-hand side. See Example 4.

Examples

Example 1:


       DIMENSION V(100) 
       COMMON V, M 
       COMMON /LIMITS/I, J 
       ... 

Unlabeled common and labeled common:

In the above example, V and M are in the unlabeled common block; I and J are defined in the named common block, LIMITS.

Example 2: You cannot associate storage of two different common blocks in the same program unit:


       COMMON /X/ A 
       COMMON /Y/ B 
       EQUIVALENCE ( A, B)			        Not allowed

Example 3: An EQUIVALENCE statement can extend a common block on the right-hand side:


       DIMENSION A(5) 
       COMMON /X/ B 
       EQUIVALENCE ( B, A) 

Example 4: An EQUIVALENCE statement must not cause a common block to be extended on the left-hand side:


       COMMON /X/ A 
       REAL B(2) 
       EQUIVALENCE ( A, B(2))			   Not allowed