Ada : The FFTW library

Description

FFTW is an FFT 1D, 2D and 3D scalable and parallel library.

Versions installed

  • FFTW 2.1.5
  • FFTW 3.2.2
  • FFTW 3.3.2
  • FFTW 3.3.3 (default version)
  • FFTW 3.3.5

Characteristics

  • Version 2.1.5 is parallelized with MPI, multi-threaded and also mono-processor. Attention: This version is more than 10 years old and is NOT compatible with the other newer installed versions.

The 3.3 versions are parallelized with MPI and multi-threaded. Moreover, these libraries include a new Fortran 2003 interface.

Utilisation

The available versions are accessed with the module command. To use the default version:

$ module load fftw
$ mpiifort appel_fftw.f90

To compile with a specific version:

$ module load fftw/3.3.2
$ mpiifort appel_fftw.f90

Example

fftw_1d_f2003.f90
module FFTW3
  use, intrinsic :: iso_c_binding
  include 'fftw3.f03'
end module FFTW3
 
program fftw_1d
 
  use FFTW3
  implicit none
  integer(kind=C_INT), parameter  :: n = 16
  complex(kind=C_DOUBLE_COMPLEX), dimension(n)  :: in, out
  type(C_PTR) :: p, p2
  integer i,j
  real fact
 
  do i=1,N
     j=i-1
     in(i)=cmplx(j*j,1)
  enddo
 
  write(*,*)"create plans"
 
  p  = fftw_plan_dft_1d(N,in,out,FFTW_FORWARD,FFTW_ESTIMATE)
  p2 = fftw_plan_dft_1d(N,in,out,FFTW_BACKWARD,FFTW_ESTIMATE)
 
  write(*,*)"do it"
 
  call fftw_execute_dft(p, in, out)
  do i=1,N
     write(*,"(f12.4,1x,f12.4)")out(i)
  enddo
 
  write(*,*)
  write(*,*)"undo it"
 
  call fftw_execute_dft(p2, out,in)
  fact=1.0/N
  do i=1,N
     write(*,)in(i)*fact
  enddo
 
  write(*,*)"clean up"
  call fftw_destroy_plan(p)
  call fftw_destroy_plan(p2)
 
end program fftw_1d
$ module load fftw
$ ifort fftw_1d_f2003.f90
$ ./a.out

Comments

  • The fftw_plan type, appearing in the argument calls of the routines, corresponds to a C address. This type must be explicitly coded in Fortran INTEGER(kind=8), or more rigorously type(C_PTR), by using the Fortran 2003 interface as in the example above.
  • The FFTW versions are also accessible in the Intel MKL library without changing the source code. However, some functionalities are lacking. For more information, we advise you to consult the INTEL documentation Appendix E: FFTW Interface to Intel® Math Kernel Library.
  • If the MKL and FFTW libraries are loaded at the same time, the order in which they are loaded is important. It is first necessary to ensure (during a porting, for example) that the calls to FFTW have been completely resolved by the FFTW library. If the loading is done through the module command, it must be ensured that FFTW was loaded after the MKL. This is the case below (LAPACK is part of the MKL):
 $ module list
 Currently Loaded Modulefiles:
   1) lapack/intel   2) fftw/3.3.2
   

Note: The performance can be evaluated by calling MKL functions in place of FFTW.

Documentation