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