Node:Fortran-interface routines, Next:FFTW Constants in Fortran, Previous:Calling FFTW from Fortran, Up:Calling FFTW from Fortran
Nearly all of the FFTW functions have Fortran-callable equivalents. The
name of the Fortran routine is the same as that of the corresponding C
routine, but with the
fftw_ prefix replaced by
(The single and long-double precision versions use
lfftw_, respectively, instead of
For the most part, all of the arguments to the functions are the same, with the following exceptions:
planvariables (what would be of type
fftw_planin C), must be declared as a type that is at least as big as a pointer (address) on your machine. We recommend using
fftw_plan_dft) is converted into a subroutine. The return value is converted into an additional first parameter of this subroutine.2
fftw_mallocdynamic-allocation routine. If you want to exploit the SIMD FFTW (see Data Alignment), you'll need to figure out some other way to ensure that your arrays are at least 16-byte aligned.
fftw_iodimstructure from the guru interface (see Guru vector and transform sizes) must be split into separate arguments. In particular, any
fftw_iodimarray arguments in the C guru interface become three integer array arguments (
os) in the Fortran guru interface, all of whose length should be equal to the corresponding
In general, you should take care to use Fortran data types that
correspond to (i.e. are the same size as) the C types used by FFTW. If
your C and Fortran compilers are made by the same vendor, the
correspondence is usually straightforward (i.e.
real corresponds to
etcetera). The native Fortran double/single-precision complex type
should be compatible with
Such simple correspondences are assumed in the examples below.
Technically, Fortran 77 identifiers are not allowed to have more than 6 characters, nor may they contain underscores. Any compiler that enforces this limitation doesn't deserve to link to FFTW.
The reason for this is that some Fortran implementations seem to have trouble with C function return values, and vice versa.