Clicky

Fortran Wiki
Better support for EQUIVALENCE

Proposal: Support EQUIVALENCE wherever possible, including dummy arguments and derived types.

It should be obvious to most people that EQUIVALENCE can be useful for in-place complex<->real Fourier transforms, and for interoperation with C unions.

EQUIVALENCE seems to be nearly deprecated because excessive use can lead to obfuscated and non-portable code. But, just like GOTOs and global variables, limited use is often important.

Theoretically, TRANSFER alleviates the need for EQUIVALENCE. Efficient compiler optimization could recognize the useless copy step, and use the data in-place. However, this is not a solution for creating a data union, where the largest object in the union may depend on the compiler. Even if you claim that unions are bad, they are at least needed for C-interoperability.