Wrapper Routines
================
All of the uniprocessor and multi-threaded transform routines have
Fortran-callable wrappers, except for the wisdom import/export functions
(since it is not possible to exchange string and file arguments portably
with Fortran) and the specific planner routines (Note:Discussion on
Specific Plans.). The name of the wrapper routine is the same as that
of the corresponding C routine, but with `fftw/fftwnd/rfftw/rfftwnd'
replaced by `fftw_f77/fftwnd_f77/rfftw_f77/rfftwnd_f77'. For example,
in Fortran, instead of calling `fftw_one' you would call
`fftw_f77_one'.(1) For the most part, all of the arguments to the
functions are the same, with the following exceptions:
* `plan' variables (what would be of type `fftw_plan',
`rfftwnd_plan', etcetera, in C), must be declared as a type that is
the same size as a pointer (address) on your machine. (Fortran
has no generic pointer type.) The Fortran `integer' type is
usually the same size as a pointer, but you need to be wary
(especially on 64-bit machines). (You could also use `integer*4'
on a 32-bit machine and `integer*8' on a 64-bit machine.) Ugh.
(`g77' has a special type, `integer(kind=7)', that is defined to
be the same size as a pointer.)
* Any function that returns a value (e.g. `fftw_create_plan') is
converted into a subroutine. The return value is converted into an
additional (first) parameter of the wrapper subroutine. (The
reason for this is that some Fortran implementations seem to have
trouble with C function return values.)
* When performing one-dimensional `FFTW_IN_PLACE' transforms, you
don't have the option of passing `NULL' for the `out' argument
(since there is no way to pass `NULL' from Fortran). Therefore,
when performing such transforms, you *must* allocate and pass a
contiguous scratch array of the same size as the transform. Note
that for in-place multi-dimensional (`(r)fftwnd') transforms, the
`out' argument is ignored, so you can pass anything for that
parameter.
* The wrapper routines expect multi-dimensional arrays to be in
column-major order, which is the ordinary format of Fortran arrays.
They do this transparently and costlessly simply by reversing the
order of the dimensions passed to FFTW, but this has one important
consequence for multi-dimensional real-complex transforms,
discussed below.
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. `integer' corresponds
to `int', `real' corresponds to `float', etcetera). Such simple
correspondences are assumed in the examples below. The examples also
assume that FFTW was compiled in double precision (the default).
---------- Footnotes ----------
(1) 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.