The EQUIVALENCE statement specifies two or more aliases that share the same storage.
equivalence-sets is a comma-separated list of (equivalence-objects)
equivalence-objects is a comma-separated list ofvariables, array elements, or substrings
An equivalence-object must not be:
made available by use association;
a dummy argument;
an allocatable array;
a subobject of a non-sequence derived type;
a subobject of a sequence derived type containing a pointer at any level of component selection;
an automatic object;
a function name;
an entry name;
a result name;
a named constant;
a structure component;
or a subobject of any of these objects
If the equivalenced objects have different types or kinds, the EQUIVALENCE statement does not perform any 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 scalar properties.
If an equivalence-object is a derived type that is not a numeric sequence or CHARACTER sequence type, all of the objects in the equivalence set must be of that type.
If an equivalence-object is of an intrinsic type other than default INTEGER, default REAL, double precision REAL, default COMPLEX, default LOGICAL, or default CHARACTER, all of the objects in equivalence-set must be of the same type with the same kind value.
A data object of type default CHARACTER can be equivalenced only with other objects of type default CHARACTER. The lengths of the equivalenced objects are not required to be the same.
An EQUIVALENCE statement can not specify that the same storage unit is to occur more than once in a storage sequence.
When one of the equivalence objects is initialized, all associated objects are considered to be initialized. Each equivalence set may have only one initialization value.
If an equivalence-object has the VOLATILE attribute, all equivalence-objects in the equivalence-set are volatile.
Examplereal :: a=1. real(kind(1.d0)) :: d integer :: i logical :: l equivalence (a,d,i,l) write(*,*) a ! writes 1.0000000 write(*,*) d ! writes 5.263544247120890E-315 write(*,*) i ! writes 1065353216 write(*,*) l ! writes T