I work with Fourier transforms and PSD calculations. It is very convenient to use an algorithm for the FT calculation that works with a complex array. But to populate this array, and use the FT result to compute the PSD, it is more convenient to address the elements using a Real array. I used to do this using the EQUIVALENCE statement:
INTEGER, PARAMETER :: npts INTEGER, PARAMETER :: nhalf = npts / 2 REAL :: a(npts) COMPLEX :: z(nhalf) EQUIVALENCE (a, z)
Two problems are developing. First, EQUIVALENCE is becoming obsolete (maybe it already is except for an extension) so I am leary of continuing this practice; second, I would really like to dynamically allocate the storage area (i.e. npts should be read as an input), and I see that dynamically allocated arrays cannot be used in EQUIVALENCE.
As a different but related problem, I used (F77) to be able to obtain effective equivalence by doing the REAL-referenced work in a main program and the COMPLEX-referenced work in a subroutine, thus
CALL fftcalc (a, nhalf, dum1, dum2, ...) ... SUBROUTINE fftcalc (z, nhalf, dum1, dum2, ...) COMPLEX :: z(nhalf) ...
But this technique no longer works in F90 because corresponding arguments are required to be of the same type.
Can anybody advise me on these issues? Perhaps using pointers (ugh!)?