Chris@10: Chris@10:
Chris@10:Chris@10: Previous: Accessing the wisdom API from Fortran, Chris@10: Up: Calling FFTW from Modern Fortran Chris@10:
Rather than using the include
statement to include the
Chris@10: fftw3.f03
interface file in any subroutine where you want to
Chris@10: use FFTW, you might prefer to define an FFTW Fortran module. FFTW
Chris@10: does not install itself as a module, primarily because
Chris@10: fftw3.f03
can be shared between different Fortran compilers while
Chris@10: modules (in general) cannot. However, it is trivial to define your
Chris@10: own FFTW module if you want. Just create a file containing:
Chris@10:
Chris@10:
module FFTW3 Chris@10: use, intrinsic :: iso_c_binding Chris@10: include 'fftw3.f03' Chris@10: end module Chris@10:Chris@10:
Compile this file into a module as usual for your compiler (e.g. with
Chris@10: gfortran -c
you will get a file fftw3.mod
). Now,
Chris@10: instead of include 'fftw3.f03'
, whenever you want to use FFTW
Chris@10: routines you can just do:
Chris@10:
Chris@10:
use FFTW3 Chris@10:Chris@10:
as usual for Fortran modules. (You still need to link to the FFTW Chris@10: library, of course.) Chris@10: Chris@10: Chris@10: