Chris@19: Chris@19: Chris@19: Overview of Fortran interface - FFTW 3.3.4 Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: Chris@19:
Chris@19: Chris@19:

Chris@19: Next: , Chris@19: Previous: Calling FFTW from Modern Fortran, Chris@19: Up: Calling FFTW from Modern Fortran Chris@19:


Chris@19:
Chris@19: Chris@19:

7.1 Overview of Fortran interface

Chris@19: Chris@19:

FFTW provides a file fftw3.f03 that defines Fortran 2003 Chris@19: interfaces for all of its C routines, except for the MPI routines Chris@19: described elsewhere, which can be found in the same directory as Chris@19: fftw3.h (the C header file). In any Fortran subroutine where Chris@19: you want to use FFTW functions, you should begin with: Chris@19: Chris@19:

Chris@19:

       use, intrinsic :: iso_c_binding
Chris@19:        include 'fftw3.f03'
Chris@19: 
Chris@19:

This includes the interface definitions and the standard Chris@19: iso_c_binding module (which defines the equivalents of C Chris@19: types). You can also put the FFTW functions into a module if you Chris@19: prefer (see Defining an FFTW module). Chris@19: Chris@19:

At this point, you can now call anything in the FFTW C interface Chris@19: directly, almost exactly as in C other than minor changes in syntax. Chris@19: For example: Chris@19: Chris@19:

Chris@19:

       type(C_PTR) :: plan
Chris@19:        complex(C_DOUBLE_COMPLEX), dimension(1024,1000) :: in, out
Chris@19:        plan = fftw_plan_dft_2d(1000,1024, in,out, FFTW_FORWARD,FFTW_ESTIMATE)
Chris@19:        ...
Chris@19:        call fftw_execute_dft(plan, in, out)
Chris@19:        ...
Chris@19:        call fftw_destroy_plan(plan)
Chris@19: 
Chris@19:

A few important things to keep in mind are: Chris@19: Chris@19:

Chris@19: Chris@19: Chris@19: Chris@19: Chris@19: