Chris@10: Chris@10:
Chris@10:Chris@10: Next: FFTW Constants in Fortran, Chris@10: Previous: Calling FFTW from Legacy Fortran, Chris@10: Up: Calling FFTW from Legacy Fortran Chris@10:
Nearly all of the FFTW functions have Fortran-callable equivalents.
Chris@10: The name of the legacy Fortran routine is the same as that of the
Chris@10: corresponding C routine, but with the ‘fftw_’ prefix replaced by
Chris@10: ‘dfftw_’.1 The single and long-double precision
Chris@10: versions use ‘sfftw_’ and ‘lfftw_’, respectively, instead of
Chris@10: ‘fftwf_’ and ‘fftwl_’; quadruple precision (real*16
)
Chris@10: is available on some systems as ‘fftwq_’ (see Precision).
Chris@10: (Note that long double
on x86 hardware is usually at most
Chris@10: 80-bit extended precision, not quadruple precision.)
Chris@10:
Chris@10:
For the most part, all of the arguments to the functions are the same, Chris@10: with the following exceptions: Chris@10: Chris@10:
plan
variables (what would be of type fftw_plan
in C),
Chris@10: must be declared as a type that is at least as big as a pointer
Chris@10: (address) on your machine. We recommend using integer*8
everywhere,
Chris@10: since this should always be big enough.
Chris@10:
Chris@10: fftw_plan_dft
) is
Chris@10: converted into a subroutine. The return value is converted into
Chris@10: an additional first parameter of this subroutine.2
Chris@10:
Chris@10: fftw_malloc
dynamic-allocation routine.
Chris@10: If you want to exploit the SIMD FFTW (see SIMD alignment and fftw_malloc), you'll
Chris@10: need to figure out some other way to ensure that your arrays are at
Chris@10: least 16-byte aligned.
Chris@10:
Chris@10: fftw_iodim
Chris@10: structure from the guru interface (see Guru vector and transform sizes) must be split into separate arguments. In particular, any
Chris@10: fftw_iodim
array arguments in the C guru interface become three
Chris@10: integer array arguments (n
, is
, and os
) in the
Chris@10: Fortran guru interface, all of whose lengths should be equal to the
Chris@10: corresponding rank
argument.
Chris@10:
Chris@10: kind
array parameter, so the kind
array
Chris@10: of that routine should be in the reverse of the order of the iodim
Chris@10: arrays (see above).
Chris@10:
Chris@10: In general, you should take care to use Fortran data types that
Chris@10: correspond to (i.e. are the same size as) the C types used by FFTW.
Chris@10: In practice, this correspondence is usually straightforward
Chris@10: (i.e. integer
corresponds to int
, real
Chris@10: corresponds to float
, etcetera). The native Fortran
Chris@10: double/single-precision complex type should be compatible with
Chris@10: fftw_complex
/fftwf_complex
. Such simple correspondences
Chris@10: are assumed in the examples below.
Chris@10:
Chris@10:
Chris@10:
Chris@10:
[1] Technically, Fortran 77 identifiers are not Chris@10: allowed to have more than 6 characters, nor may they contain Chris@10: underscores. Any compiler that enforces this limitation doesn't Chris@10: deserve to link to FFTW.
Chris@10: Chris@10:[2] The Chris@10: reason for this is that some Fortran implementations seem to have Chris@10: trouble with C function return values, and vice versa.
Chris@10: Chris@10: