Next: , Previous: , Up: Calling FFTW from Legacy Fortran   [Contents][Index]

8.3 FFTW Execution in Fortran

In C, in order to use a plan, one normally calls fftw_execute, which executes the plan to perform the transform on the input/output arrays passed when the plan was created (see Using Plans). The corresponding subroutine call in legacy Fortran is:

        call dfftw_execute(plan)

However, we have had reports that this causes problems with some recent optimizing Fortran compilers. The problem is, because the input/output arrays are not passed as explicit arguments to dfftw_execute, the semantics of Fortran (unlike C) allow the compiler to assume that the input/output arrays are not changed by dfftw_execute. As a consequence, certain compilers end up optimizing out or repositioning the call to dfftw_execute, assuming incorrectly that it does nothing.

There are various workarounds to this, but the safest and simplest thing is to not use dfftw_execute in Fortran. Instead, use the functions described in New-array Execute Functions, which take the input/output arrays as explicit arguments. For example, if the plan is for a complex-data DFT and was created for the arrays in and out, you would do:

        call dfftw_execute_dft(plan, in, out)

There are a few things to be careful of, however:

Next: , Previous: , Up: Calling FFTW from Legacy Fortran   [Contents][Index]