cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: FFTW 3.3.5: Wisdom File Export/Import from Fortran cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127:
cannam@127:

cannam@127: Next: , Previous: , Up: Accessing the wisdom API from Fortran   [Contents][Index]

cannam@127:
cannam@127:
cannam@127: cannam@127:

7.6.1 Wisdom File Export/Import from Fortran

cannam@127: cannam@127: cannam@127: cannam@127:

The easiest way to export and import wisdom is to do so using cannam@127: fftw_export_wisdom_to_filename and cannam@127: fftw_wisdom_from_filename. The only trick is that these cannam@127: require you to pass a C string, which is an array of type cannam@127: CHARACTER(C_CHAR) that is terminated by C_NULL_CHAR. cannam@127: You can call them like this: cannam@127:

cannam@127:
cannam@127:
  integer(C_INT) :: ret
cannam@127:   ret = fftw_export_wisdom_to_filename(C_CHAR_'my_wisdom.dat' // C_NULL_CHAR)
cannam@127:   if (ret .eq. 0) stop 'error exporting wisdom to file'
cannam@127:   ret = fftw_import_wisdom_from_filename(C_CHAR_'my_wisdom.dat' // C_NULL_CHAR)
cannam@127:   if (ret .eq. 0) stop 'error importing wisdom from file'
cannam@127: 
cannam@127: cannam@127:

Note that prepending ‘C_CHAR_’ is needed to specify that the cannam@127: literal string is of kind C_CHAR, and we null-terminate the cannam@127: string by appending ‘// C_NULL_CHAR’. These functions return an cannam@127: integer(C_INT) (ret) which is 0 if an error cannam@127: occurred during export/import and nonzero otherwise. cannam@127:

cannam@127:

It is also possible to use the lower-level routines cannam@127: fftw_export_wisdom_to_file and cannam@127: fftw_import_wisdom_from_file, which accept parameters of the C cannam@127: type FILE*, expressed in Fortran as type(C_PTR). cannam@127: However, you are then responsible for creating the FILE* cannam@127: yourself. You can do this by using iso_c_binding to define cannam@127: Fortran intefaces for the C library functions fopen and cannam@127: fclose, which is a bit strange in Fortran but workable. cannam@127:

cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: