FORTRAN 77 Language Reference


The EQUIVALENCE statement specifies that two or more variables or arrays in a program unit share the same memory.

EQUIVALENCE (nlist) [, (nlist)] ...




List of variable names, array element names, array names, and character substring names separated by commas  


An EQUIVALENCE statement stipulates that the storage sequence of the entities whose names appear in the list nlist must have the same first memory location.

An EQUIVALENCE statement can cause association of entities other than specified in the nlist.

An array name, if present, refers to the first element of the array.

If an array element name appears in an EQUIVALENCE statement, the number of subscripts can be less than or equal to the number of dimensions specified in the array declarator for the array name.


In nlist, dummy arguments and functions are not permitted.

Subscripts of array elements must be integer constants greater than the lower bound and less than or equal to the upper bound.

EQUIVALENCE can associate automatic variables only with other automatic variables or undefined storage classes. These classes must be ones which are not in any of the COMMON, STATIC, SAVE, DATA, or dummy arguments.

An EQUIVALENCE statement can associate an element of type character with a noncharacter element. @

An EQUIVALENCE statement cannot specify that the same storage unit is to occur more than once in a storage sequence. For example, the following statement is not allowed:

       DIMENSION A (2) 
       EQUIVALENCE (A(1),B), (A(2),B) 

An EQUIVALENCE statement cannot specify that consecutive storage units are to be nonconsecutive. For example, the following statement is not allowed:

       REAL A (2) 
       EQUIVALENCE (A(1), D(1)), (A(2), D(2)) 

When COMMON statements and EQUIVALENCE statements are used together, several additional rules can apply. For such rules, refer to the notes on the COMMON statement.


       CHARACTER A*4, B*4, C(2)*3 
       EQUIVALENCE (A,C(1)),(B,C(2))

The association of A, B, and C can be graphically illustrated as follows. The first seven character positions are arranged in memory as follows: