[UP]


Manual Reference Pages  - common (7)

NAME

common(7f) - [FORTRAN:INTRINSICS] specifies blocks of variables that can be accessed by any scoping unit in the program (LICENSE:PD)

SYNOPSIS

common /common-block-name/ variables, /common-block-name/ variables, ...

DESCRIPTION

The COMMON statement specifies blocks of physical storage, called common blocks, that can be accessed by any of the scoping units in a program. Thus, the COMMON statement provides a global data facility based on storage association (16.5.3).

A common block that does not have a name is called blank common.
R568 common-stmt is COMMON [ / [ common-block-name ] / ] common-block-object-list [ [ , ] / [ common-block-name ] / common-block-object-list ] ...
R569 common-block-object is variable-name [ ( array-spec ) ] or proc-pointer-name
C595 (R569) An array-spec in a common-block-object shall be an explicit-shape-spec-list.
C596 (R569) Only one appearance of a given variable-name or proc-pointer-name is permitted in all common-block-object-lists within a scoping unit.
C597 (R569) A common-block-object shall not be a dummy argument, an allocatable variable, a derived-type object with an ultimate component that is allocatable, an automatic object, a function name, an entry name, a variable with the BIND attribute, a coarray, or a result name.
C598 (R569) If a common-block-object is of a derived type, the type shall have the BIND attribute or the SEQUENCE attribute and it shall have no default initialization.
C599 (R569) A variable-name or proc-pointer-name shall not be a name made accessible by use association.
In each COMMON statement, the data objects whose names appear in a common block object list following a common block name are declared to be in that common block. If the first common block name is omitted, all data objects whose names appear in the first common block object list are specified to be in blank common. Alternatively, the appearance of two slashes with no common block name between them declares the data objects whose names appear in the common block object list that follows to be in blank common.
Any common block name or an omitted common block name for blank common may occur more than once in one or more COMMON statements in a scoping unit. The common block list following each successive appearance of the same common block name in a scoping unit is treated as a continuation of the list for that common block name. Similarly, each blank common block object list in a scoping unit is treated as a continuation of blank common.
The form variable-name (array-spec) specifies the DIMENSION attribute for that variable.
If derived-type objects of numeric sequence type (4.5.2) or character sequence type (4.5.2) appear in common, it is as if the individual components were enumerated directly in the common list.
       NOTE 5.44
       Examples of COMMON statements are:

COMMON /BLOCKA/ A, B, D (10, 30) COMMON I, J, K

5.7.2.2 Common block storage sequence
For each common block in a scoping unit, a common block storage sequence is formed as follows:
         (1)     A storage sequence is formed consisting of the sequence of storage units in the storage sequences
                 (16.5.3.2) of all data objects in the common block object lists for the common block. The order of
                 the storage sequences is the same as the order of the appearance of the common block object lists in
                 the scoping unit.
         (2)     The storage sequence formed in (1) is extended to include all storage units of any storage sequence
                 associated with it by equivalence association. The sequence shall be extended only by adding storage
                 units beyond the last storage unit. Data objects associated with an entity in a common block are
                 considered to be in that common block.

Only COMMON statements and EQUIVALENCE statements appearing in the scoping unit contribute to common block storage sequences formed in that scoping unit.
5.7.2.3 Size of a common block
The size of a common block is the size of its common block storage sequence, including any extensions of the sequence resulting from equivalence association.
5.7.2.4 Common association
Within a program, the common block storage sequences of all nonzero-sized common blocks with the same name have the same first storage unit, and the common block storage sequences of all zero-sized common blocks with the same name are storage associated with one another. Within a program, the common block storage sequences of all nonzero-sized blank common blocks have the same first storage unit and the storage sequences of all zero-sized blank common blocks are associated with one another and with the first storage unit of any nonzero-sized blank common blocks. This results in the association of objects in different scoping units. Use or host association may cause these associated objects to be accessible in the same scoping unit.
A nonpointer object that is default integer, default real, double precision real, default complex, default logical, or of numeric sequence type shall be associated only with nonpointer objects of these types and kinds.
A nonpointer object that is default character or of character sequence type shall be associated only with nonpointer objects of these types and kinds.
A nonpointer object of a derived type that is not a numeric sequence or character sequence type shall be associated only with nonpointer objects of the same type with the same type parameter values.
A nonpointer object of intrinsic type but which is not default integer, default real, double precision real, default complex, default logical, or default character shall be associated only with nonpointer objects of the same type and type parameters.
A data pointer shall be storage associated only with data pointers of the same type and rank. Data pointers that are storage associated shall have deferred the same type parameters; corresponding nondeferred type parameters shall have the same value. A procedure pointer shall be storage associated only with another procedure pointer; either both interfaces shall be explicit or both interfaces shall be implicit. If the interfaces are explicit, the characteristics shall be the same. If the interfaces are implicit, either both shall be subroutines or both shall be functions with the same type and type parameters.
An object with the TARGET attribute shall be storage associated only with another object that has the TARGET attribute and the same type and type parameters.
        NOTE 5.45
        A common block is permitted to contain sequences of different storage units, provided each scoping unit
        that accesses the common block specifies an identical sequence of storage units for the common block. For
        example, this allows a single common block to contain both numeric and character storage units.

Association in different scoping units between objects of default type, objects of double precision real type, and sequence structures is permitted according to the rules for equivalence objects (5.7.1).

5.7.2.5 Differences between named common and blank common
A blank common block has the same properties as a named common block, except for the following.
        undefined unless the common block has the SAVE attribute, but never causes data objects in blank common
        to become undefined (16.6.6).
        they appear, but blank common blocks may be of different sizes.
        declaration statement in a block data program unit (11.3), but objects in blank common shall not be initially
        defined.

5.7.3 Restrictions on common and equivalence
An EQUIVALENCE statement shall not cause the storage sequences of two different common blocks to be associated.

Equivalence association shall not cause a derived-type object with default initialization to be associated with an object in a common block.

Equivalence association shall not cause a common block storage sequence to be extended by adding storage units preceding the first storage unit of the first object specified in a COMMON statement for the common block.

        NOTE 5.46
        For example, the following is not permitted:

COMMON /X/ A REAL B (2) EQUIVALENCE (A, B(2)) ! Not standard-conforming


common (7) March 11, 2021
Generated by manServer 1.08 from c58cb048-d09c-4cab-afec-7b14725e7de2 using man macros.

Binary file (standard input) matches