When you make one character substring equivalent to another character substring, the EQUIVALENCE statement also sets associations between the other corresponding characters in the character entities; for example:
CHARACTER NAME*16, ID*9
EQUIVALENCE(NAME(10:13), ID(2:5))
These statements cause character variables NAME and ID to share space (see Figure 5-1). The arrays can also be aligned by the following statement:
EQUIVALENCE(NAME(9:9), ID(1:1))
Figure 5-1 Equivalence of Substrings
If the character substring references are array elements, the EQUIVALENCE statement sets associations between the other corresponding characters in the complete arrays.
Character elements of arrays can overlap at any character position. For example, the following statements cause character arrays FIELDS and STAR to share storage (see Figure 5-2).
CHARACTER FIELDS(100)*4, STAR(5)*5
EQUIVALENCE(FIELDS(1)(2:4), STAR(2)(3:5))
Figure 5-2 Equivalence of Character Arrays
The EQUIVALENCE statement cannot assign the same storage location to two or more substrings that start at different character positions in the same character variable or character array. The EQUIVALENCE statement also cannot assign memory locations in a way that is inconsistent with the normal linear storage of character variables and arrays.