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