d@0: d@0:
d@0:d@0: d@0: Next: Fortran Examples, d@0: Previous: FFTW Constants in Fortran, d@0: Up: Calling FFTW from Fortran d@0:
In C, in order to use a plan, one normally calls fftw_execute
,
d@0: which executes the plan to perform the transform on the input/output
d@0: arrays passed when the plan was created (see Using Plans). The
d@0: corresponding subroutine call in Fortran is:
d@0:
call dfftw_execute(plan) d@0:d@0:
d@0: However, we have had reports that this causes problems with some
d@0: recent optimizing Fortran compilers. The problem is, because the
d@0: input/output arrays are not passed as explicit arguments to
d@0: dfftw_execute
, the semantics of Fortran (unlike C) allow the
d@0: compiler to assume that the input/output arrays are not changed by
d@0: dfftw_execute
. As a consequence, certain compilers end up
d@0: optimizing out or repositioning the call to dfftw_execute
,
d@0: assuming incorrectly that it does nothing.
d@0:
d@0:
There are various workarounds to this, but the safest and simplest
d@0: thing is to not use dfftw_execute
in Fortran. Instead, use the
d@0: functions described in New-array Execute Functions, which take
d@0: the input/output arrays as explicit arguments. For example, if the
d@0: plan is for a complex-data DFT and was created for the arrays
d@0: in
and out
, you would do:
d@0:
call dfftw_execute_dft(plan, in, out) d@0:d@0:
d@0: There are a few things to be careful of, however: d@0: d@0:
dfftw_execute_dft
, Real-input (r2c) DFT plans should use use
d@0: dfftw_execute_dft_r2c
, and real-output (c2r) DFT plans should
d@0: use dfftw_execute_dft_c2r
. The various r2r plans should use
d@0: dfftw_execute_r2r
.
d@0:
d@0: fftw_malloc
in C). You
d@0: can, of course, use the FFTW_UNALIGNED
flag when creating the
d@0: plan, in which case the plan does not depend on the alignment, but
d@0: this may sacrifice substantial performance on architectures (like x86)
d@0: with SIMD instructions (see SIMD alignment and fftw_malloc).
d@0:
d@0: