Overview

License Terms

GFT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Introduction

GFT is a Generic Fortran 95 module which goal is to allow users to perform FFTs. It has been developped by Jalel Chergui at CNRS/IDRIS and built over core routines of JMFFT developped by Jean-Marie Teuler. It is also an attempt to define a set of standard Fortran generic FFT routines that combine ease of use and performance. In fact, three generic routines only can perform Forward/backward 1D, 2D, 3D and multiple 1D Complex-Complex and Real-Complex FFTs. Also, user has not to worry anymore about size and memory allocation/freeing of temporary work arrays since this job is done by GFT knowing the size of the FFT at an initialization step. Besides those three routines, an auxiliary subroutine has been defined for performance issues on vector processors.

Installation

  1. You'll need a Fortran 95 compiler
  2. Download GFT sources
  3. gzip -cd gft-(version).tar.gz | tar -xvf -
  4. cd GFT-(version)/MakeDep
    Configure the "Make.inc" file
  5. cd .. ; make
    Compile the GFT modules
  6. make x
    Compile, load and run all examples

Quick start

Once GFT is installed, the user has to include GFT module files at compilation time and to link his own object files with the libgft.a archive. Also, each program unit, that makes calls to the GFT routines, must start with "USE GFT" instruction. The GFT archive contains all module objects. It mainly defines four generic routines:

  1. GFT_set_fft(...) sets the size of the 1D, 2D or 3D FFTs, allocates temporary work arrays and returns a GFT object,
  2. GFT_do_fft(...) performs 1D, 2D or 3D FFTs,
  3. GFT_end_fft(...) resets the GFT object to default and frees all temporaries,
  4. GFT_set_bf(...) sets the Blocking Factor to the size of the vector register length for performance issues of 2D and 3D FFTs only.

and five derived data types to perform any kind of FFTs with a given floating point precision:

  1. GFT_CC to perform 1D, 2D and 3D Complex-Complex FFTs,
  2. GFT_RCR to perform 1D, 2D and 3D Real-Complex or Complex-Real FFTs,
  3. GFT_MCC to perform multiple 1D Complex-Complex FFTs,
  4. GFT_MRCR to perform multiple 1D Real-Complex or Complex-Real FFTs,
  5. GFT_prec defines the floating point precision which default is set to 8 bytes double floating point precision.

Examples

  1. This example shows how to perform a 2D Complex-Complex FFT of size (n,m).
    PROGRAM cc_2D
      USE GFT
      IMPLICIT NONE
    
      INTEGER, PARAMETER                           :: ni=257, nj=128
      INTEGER                                      :: n, m, si
      REAL(kind=GFT_Prec)                          :: sc
      COMPLEX(kind=GFT_Prec), DIMENSION(0:ni-1,nj) :: x, y
      TYPE(GFT_CC)                                 :: cc
    
      !... Initialize Array to be Transformed
      x(0:,:) = ...
    
      !... Set size of FFT and cc object
      n=256 ; m=128
      CALL GFT_set_fft(Nx=n, Ny=m, FFT=cc)
    
      !... Forward FFT
      si  = +1         ! Sign of the FFT
      sc =1.0_GFT_Prec ! Scale factor
      CALL GFT_do_fft(FFT=cc, isign=si, scale=sc, c_in=x, c_out=y)
    
      !... Backward FFT
      si  = -1                                     ! Sign of the FFT
      sc = 1.0_GFT_Prec / REAL(n*m, kind=GFT_Prec) ! Scale factor
      CALL GFT_do_fft(FFT=cc, isign=si, scale=sc, c_in=y, c_out=x)
    
      !... Free FFT object
      CALL GFT_end_fft(FFT=cc)
    END PROGRAM cc_2D
    

  2. In this second example, the 2D complex-complex FFT is partially applied on a section of the array x and the output stored in a section of the array y as shown in the program below:
    PROGRAM cc_2D_bis
      USE GFT
      IMPLICIT NONE
    
      INTEGER, PARAMETER                           :: ni=257, nj=128
      INTEGER                                      :: n, m, si
      REAL(kind=GFT_Prec)                          :: sc
      COMPLEX(kind=GFT_Prec), DIMENSION(0:ni-1,nj) :: x, y
      TYPE(GFT_CC)                                 :: cc
    
      !... Initialize Array to be Transformed
      x(0:,:) = ...
    
      !... Set size of FFT and cc object
      n=45 ; m=36
      CALL GFT_set_fft(Nx=n, Ny=m, FFT=cc)
    
      !... Forward FFT
      si  = +1         ! Sign of the FFT
      sc =1.0_GFT_Prec ! Scale factor
      CALL GFT_do_fft(FFT=cc, isign=si, scale=sc, c_in=x(5:n+5,10:m+10), &
                      c_out=y(0:n-1,1:m))
    
      !... Backward FFT
      si  = -1                                     ! Sign of the FFT
      sc = 1.0_GFT_Prec / REAL(n*m, kind=GFT_Prec) ! Scale factor
      CALL GFT_do_fft(FFT=cc, isign=si, scale=sc, c_in=y(0:n-1,1:m), &
                      c_out=x(5:n+5,10:m+10))
    
      !... Free FFT object
      CALL GFT_end_fft(FFT=cc)
    END PROGRAM cc_2D_bis
       

  3. The example below shows how to perform forward/backward 3D complex-real FFTs of size (n,m,l) on a vector processor which register length is 256:
    PROGRAM rcr_3D
      USE GFT
      IMPLICIT NONE
    
      INTEGER, PARAMETER                              :: ni=259,nj=128,nk=64
      INTEGER                                         :: n, m, l, si
      REAL(kind=GFT_Prec)                             :: sc
      COMPLEX(kind=GFT_Prec), DIMENSION(0:ni/2,nj,nk) :: x
      REAL(kind=GFT_Prec), DIMENSION(0:ni-1,nj,nk)    :: y
      TYPE(GFT_RCR)                                   :: rcr
    
      !... Initialize array to be Transformed
      x(0:,:,:) = ...
    
      !... Set the Blocking Factor
      CALL GFT_set_bf(FFT=rcr, BF=256)
    
      !... Set size of FFT
      n=256 ; m=128 ; l=64
      CALL GFT_set_fft(Nx=n, Ny=m, Nz=l, FFT=rcr)
    
      !... Forward FFT
      si = +1            ! Sign of the FFT
      sc = 1.0_GFT_Prec  ! Scale factor
      CALL GFT_do_fft(FFT=rcr, isign=si, scale=sc, c_in=x, r_out=y)
    
      !... Backward FFT
      si = -1                                         ! Sign of the FFT
      sc = 1.0_GFT_Prec / REAL(n*m*l, kind=GFT_Prec)  ! Scale factor
      CALL GFT_do_fft(FFT=rcr, isign=si, scale=sc, r_in=y, c_out=x)
    
      !... Free rcr object
      CALL GFT_end_fft(FFT=rcr)
    END PROGRAM rcr_3D
       

© CNRS - IDRIS, 13/01/2012