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