[UP]


Manual Reference Pages  - equivalence (7)

NAME

equivalence(7f) - [FORTRAN:INTRINSICS] used to specify the sharing of storage units by two or more objects in a storage unit (LICENSE:PD)

SYNOPSIS

equivalence(object1,object2)

DESCRIPTION

An EQUIVALENCE statement is used to specify the sharing of storage units by two or more objects in a scoping unit. This causes storage association (16.5.3) of the objects that share the storage units.

If the equivalenced objects have differing type or type parameters, the EQUIVALENCE statement does not cause type conversion or imply mathematical equivalence. If a scalar and an array are equivalenced, the scalar does not have array properties and the array does not have the properties of a scalar.

     R565      equivalence-stmt             is   EQUIVALENCE equivalence-set-list

R566 equivalence-set is ( equivalence-object , equivalence-object-list )

R567 equivalence-object is variable-name or array-element or substring

C583 (R567) An equivalence-object shall not be a designator with a base object that is a dummy argument, a pointer, an allocatable variable, a derived-type object that has an allocatable ultimate component, an object of a nonsequence derived type, an object of a derived type that has a pointer at any level of component selection, an automatic object, a function name, an entry name, a result name, a variable with the BIND attribute, a variable in a common block that has the BIND attribute, or a named constant.

C584 (R567) An equivalence-object shall not be a designator that has more than one part-ref .

C585 (R567) An equivalence-object shall not be a coarray or a subobject thereof.

C586 (R567) An equivalence-object shall not have the TARGET attribute.

C587 (R567) Each subscript or substring range expression in an equivalence-object shall be an integer initialization expression (7.1.12).

C588 (R566) If an equivalence-object is default integer, default real, double precision real, default complex, default logical, or of numeric sequence type, all of the objects in the equivalence set shall be of these types.

C589 (R566) If an equivalence-object is default character or of character sequence type, all of the objects in the equivalence set shall be of these types and kinds.

C590 (R566) If an equivalence-object is of a sequence type that is not a numeric sequence or character sequence type, all of the objects in the equivalence set shall be of the same type with the same type parameter values.

C591 (R566) If an equivalence-object is of an intrinsic type but is not default integer, default real, double precision real, default complex, default logical, or default character, all of the objects in the equivalence set shall be of the same type with the same kind type parameter value.

C592 (R567) If an equivalence-object has the PROTECTED attribute, all of the objects in the equivalence set shall have the PROTECTED attribute.

C593 (R567) The name of an equivalence-object shall not be a name made accessible by use association.

C594 (R567) A substring shall not have length zero.

NOTE 5.40

The EQUIVALENCE statement allows the equivalencing of sequence structures and the equivalencing of objects of intrinsic type with nondefault type parameters, but there are strict rules regarding the appearance of these objects in an EQUIVALENCE statement.

A structure that appears in an EQUIVALENCE statement shall be a sequence structure. If a sequence structure is not of numeric sequence type or of character sequence type, it shall be equivalenced only to objects of the same type with the same type parameter values.

A structure of a numeric sequence type shall be equivalenced only to another structure of a numeric sequence type, an object that is default integer, default real, double precision real, default complex, or default logical type such that components of the structure ultimately become associated only with objects of these types and kinds.

A structure of a character sequence type shall be equivalenced only to an object of default character type or another structure of a character sequence type.

An object of intrinsic type with nondefault kind type parameters shall not be equivalenced to objects of different type or kind type parameters.

Further rules on the interaction of EQUIVALENCE statements and default initialization are given in 16.5.3.4.

5.7.1.2 Equivalence association
An EQUIVALENCE statement specifies that the storage sequences (16.5.3.2) of the data objects specified in an equivalence-set are storage associated. All of the nonzero-sized sequences in the equivalence-set, if any, have the same first storage unit, and all of the zero-sized sequences in the equivalence-set, if any, are storage associated with one another and with the first storage unit of any nonzero-sized sequences. This causes the storage association of the data objects in the equivalence-set and may cause storage association of other data objects.
5.7.1.3 Equivalence of default character objects
A default character data object shall not be equivalenced to an object that is not default character and not of a character sequence type. The lengths of equivalenced default character objects need not be the same.
An EQUIVALENCE statement specifies that the storage sequences of all the default character data objects specified in an equivalence-set are storage associated. All of the nonzero-sized sequences in the equivalence-set, if any, have the same first character storage unit, and all of the zero-sized sequences in the equivalence-set, if any, are storage associated with one another and with the first character storage unit of any nonzero-sized sequences. This causes the storage association of the data objects in the equivalence-set and may cause storage association of other data objects.
       NOTE 5.41
       For example, using the declarations:

CHARACTER (LEN = 4) :: A, B CHARACTER (LEN = 3) :: C (2) EQUIVALENCE (A, C (1)), (B, C (2))

the association of A, B, and C can be illustrated graphically as:

1 2 3 4 5 6 7 |--- --- A --- ---| |--- --- B --- ---| |--- C(1) ---| |--- C(2) ---|

5.7.1.4 Array names and array element designators
For a nonzero-sized array, the use of the array name unqualified by a subscript list as an equivalence-object has the same effect as using an array element designator that identifies the first element of the array.
5.7.1.5 Restrictions on EQUIVALENCE statements
An EQUIVALENCE statement shall not specify that the same storage unit is to occur more than once in a storage sequence.
       NOTE 5.42
       For example:

REAL, DIMENSION (2) :: A REAL :: B EQUIVALENCE (A(1), B), (A(2), B) ! Not standard-conforming

is prohibited, because it would specify the same storage unit for A (1) and A (2).

An EQUIVALENCE statement shall not specify that consecutive storage units are to be nonconsecutive.
        NOTE 5.43
        For example, the following is prohibited:

REAL A (2) DOUBLE PRECISION D (2) EQUIVALENCE (A(1), D(1)), (A(2), D(2)) ! Not standard-conforming

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


equivalence (7) March 11, 2021
Generated by manServer 1.08 from 4fabd27c-7752-45ae-a878-3e3595477184 using man macros.