Chris@10: Chris@10: Chris@10: Wisdom File Export/Import from Fortran - FFTW 3.3.3 Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10:
Chris@10: Chris@10: Chris@10:

Chris@10: Next: , Chris@10: Previous: Accessing the wisdom API from Fortran, Chris@10: Up: Accessing the wisdom API from Fortran Chris@10:


Chris@10:
Chris@10: Chris@10:

7.6.1 Wisdom File Export/Import from Fortran

Chris@10: Chris@10:

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

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

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

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