equivalence is one of Fortran's two features for storage-association of entities. (The other is common blocks on which topic I will remain silent here). The equivalence statement declares that the entities named in its argument list share the same storage locations. In this case data1 and data2 share the same memory locations.
If you have a tool for inspecting memory locations and point it at data1 you'll see something like this:
+----------+----------+----------+----------+----------+----------+
| | | | | |
| data1(0) | data1(1) | data1(2) | data1(3) | data1(4) | data1(...
| | | | | |
+----------+----------+----------+----------+----------+----------+
Point the same tool at data2 and you'll see something like this
+----------+----------+----------+----------+----------+----------+
| | |
| data2(0) | data2(1) | data2(....
| re im | re im | re im
+----------+----------+----------+----------+----------+----------+
but the 'truth' is rather more like
+----------+----------+----------+----------+----------+----------+
| | |
| data1(0) data1(1) | data1(2) data1(3) | data1(4) data1(...
| | |
| data2(0) | data2(1) | data2(....
| re im | re im | re im
+----------+----------+----------+----------+----------+----------+
data1(0) is at the same location as the real component of data2(0). data1(1) is the imaginary component of data2(0), and so forth.
This is one of the applications of equivalence which one still occasionally comes across -- being able to switch between viewing data as complex or as pairs of reals. However, it's not confined to this kind of type conversion, there's nothing to say you can't equivalence integers and reals, or any other types.
Another use one occasionally still sees is the use of equivalence for remapping arrays from one rank to another. For example, given
integer, dimension(3,2) :: array2
integer, dimension(6) :: array1
and
equivalence(array1(1),array2(1,1))
the same elements can be treated as belonging to a rank-2 array or to a rank-1 array to suit the program's needs.
equivalence is generally frowned upon these days, most of what it has been used for can be done more safely with modern Fortran. For more, you might care to look at my answer to Is the storage of COMPLEX in fortran guaranteed to be two REALs?
data1(0)anddata1(1)are the real and imaginary parts ofdata2(0). - agentp