In this section, we discuss how one can import/export FFTW wisdom (saved plans) to/from a Fortran program; we assume that the reader is already familiar with wisdom, as described in Words of Wisdom-Saving Plans.
The basic problem is that is difficult to (portably) pass files and
strings between Fortran and C, so we cannot provide a direct Fortran
equivalent to the fftw_export_wisdom_to_file
, etcetera,
functions. Fortran interfaces are provided for the functions
that do not take file/string arguments, however:
dfftw_import_system_wisdom
, dfftw_import_wisdom
,
dfftw_export_wisdom
, and dfftw_forget_wisdom
.
So, for example, to import the system-wide wisdom, you would do:
integer isuccess call dfftw_import_system_wisdom(isuccess)
As usual, the C return value is turned into a first parameter;
isuccess
is non-zero on success and zero on failure (e.g. if
there is no system wisdom installed).
If you want to import/export wisdom from/to an arbitrary file or
elsewhere, you can employ the generic dfftw_import_wisdom
and
dfftw_export_wisdom
functions, for which you must supply a
subroutine to read/write one character at a time. The FFTW package
contains an example file doc/f77_wisdom.f
demonstrating how to
implement import_wisdom_from_file
and
export_wisdom_to_file
subroutines in this way. (These routines
cannot be compiled into the FFTW library itself, lest all FFTW-using
programs be required to link with the Fortran I/O library.)