The easiest way to export and import wisdom is to do so using
fftw_wisdom_from_filename. The only trick is that these
require you to pass a C string, which is an array of type
CHARACTER(C_CHAR) that is terminated by
You can call them like this:
integer(C_INT) :: ret ret = fftw_export_wisdom_to_filename(C_CHAR_'my_wisdom.dat' // C_NULL_CHAR) if (ret .eq. 0) stop 'error exporting wisdom to file' ret = fftw_import_wisdom_from_filename(C_CHAR_'my_wisdom.dat' // C_NULL_CHAR) if (ret .eq. 0) stop 'error importing wisdom from file'
Note that prepending ‘C_CHAR_’ is needed to specify that the
literal string is of kind
C_CHAR, and we null-terminate the
string by appending ‘// C_NULL_CHAR’. These functions return an
ret) which is
0 if an error
occurred during export/import and nonzero otherwise.
It is also possible to use the lower-level routines
fftw_import_wisdom_from_file, which accept parameters of the C
FILE*, expressed in Fortran as
However, you are then responsible for creating the
yourself. You can do this by using
iso_c_binding to define
Fortran intefaces for the C library functions
fclose, which is a bit strange in Fortran but workable.