fft_work Module

Provides some wrappers for managing FFTW plans.

The initialisation routines (init_crfftw, init_rcfftw, init_ccfftw) create FFTW plans, storing them in an instance of fft_type, along with some useful metadata, notably scale.

The preprocessor macro FFTW_PREFIX is provided to enable calling the single or double precision FFTW routines.


Uses


Contents


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: FFT_TO_SPECTRAL_SPACE = -1

Constant for forward transforms, from real space to spectral space

integer, public, parameter :: FFT_TO_REAL_SPACE = 1

Constant for inverse transforms, from spectral space to real space

logical, public :: measure_plan = .true.

If true, then use FFTW_PATIENT to pick the optimal 42 algorithm, otherwise use FFTW_ESTIMATE (potentially slower but more reproducible results). FFTW_PATIENT takes longer to set up the plan initially, but may be faster overall.

integer, private, parameter :: FFTW_R2HC = 0
integer, private, parameter :: FFTW_HC2R = 1
integer, private, parameter :: FFTW_DHT = 2
integer, private, parameter :: FFTW_REDFT00 = 3
integer, private, parameter :: FFTW_REDFT01 = 4
integer, private, parameter :: FFTW_REDFT10 = 5
integer, private, parameter :: FFTW_REDFT11 = 6
integer, private, parameter :: FFTW_RODFT00 = 7
integer, private, parameter :: FFTW_RODFT01 = 8
integer, private, parameter :: FFTW_RODFT10 = 9
integer, private, parameter :: FFTW_RODFT11 = 10
integer, private, parameter :: FFTW_FORWARD = -1
integer, private, parameter :: FFTW_BACKWARD = +1
integer, private, parameter :: FFTW_MEASURE = 0
integer, private, parameter :: FFTW_DESTROY_INPUT = 1
integer, private, parameter :: FFTW_UNALIGNED = 2
integer, private, parameter :: FFTW_CONSERVE_MEMORY = 4
integer, private, parameter :: FFTW_EXHAUSTIVE = 8
integer, private, parameter :: FFTW_PRESERVE_INPUT = 16
integer, private, parameter :: FFTW_PATIENT = 32
integer, private, parameter :: FFTW_ESTIMATE = 64
integer, private, parameter :: FFTW_WISDOM_ONLY = 2097152
integer, private, parameter :: FFTW_ESTIMATE_PATIENT = 128
integer, private, parameter :: FFTW_BELIEVE_PCOST = 256
integer, private, parameter :: FFTW_NO_DFT_R2HC = 512
integer, private, parameter :: FFTW_NO_NONTHREADED = 1024
integer, private, parameter :: FFTW_NO_BUFFERING = 2048
integer, private, parameter :: FFTW_NO_INDIRECT_OP = 4096
integer, private, parameter :: FFTW_ALLOW_LARGE_GENERIC = 8192
integer, private, parameter :: FFTW_NO_RANK_SPLITS = 16384
integer, private, parameter :: FFTW_NO_VRANK_SPLITS = 32768
integer, private, parameter :: FFTW_NO_VRECURSE = 65536
integer, private, parameter :: FFTW_NO_SIMD = 131072
integer, private, parameter :: FFTW_NO_SLOW = 262144
integer, private, parameter :: FFTW_NO_FIXED_RADIX_LARGE_N = 524288
integer, private, parameter :: FFTW_ALLOW_PRUNING = 1048576
real, public :: time_fft(2) = 0.

Total time taken setting up and performing FFTs

logical, private :: initialised = .false.

True if this module has been initialised


Interfaces

public interface init_crfftw

  • private subroutine init_crfftw_1d(fft, direction, n, howmany, transposed)

    Create FFTW plan suitable for 1D complex to real transformation

    Arguments

    Type IntentOptional Attributes Name
    type(fft_type), intent(out) :: fft

    The created plan

    integer, intent(in) :: direction

    Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

    integer, intent(in) :: n

    Number of points in array to transform

    integer, intent(in) :: howmany

    Number of independent FFTs in array

    logical, intent(in), optional :: transposed

    If true, then take 42 of transpose of array

  • private subroutine init_crfftw_2d(fft, direction, m, n, howmany, stride_)

    Create FFTW plan suitable for 2D complex to real transformation

    Arguments

    Type IntentOptional Attributes Name
    type(fft_type), intent(out) :: fft

    The created plan

    integer, intent(in) :: direction

    Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

    integer, intent(in) :: m

    Number of points in first dimension of array to transform

    integer, intent(in) :: n

    Number of points in second dimension of array to transform

    integer, intent(in) :: howmany

    Number of independent FFTs in array

    integer, intent(in), optional :: stride_

    Stride of array if different from howmany

public interface init_rcfftw

  • private subroutine init_rcfftw_1d(fft, direction, n, howmany, transposed)

    Create FFTW plan suitable for 1D real to complex transformation

    Arguments

    Type IntentOptional Attributes Name
    type(fft_type), intent(out) :: fft

    The created plan

    integer, intent(in) :: direction

    Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

    integer, intent(in) :: n

    Number of points in array to transform

    integer, intent(in) :: howmany

    Number of independent FFTs in array

    logical, intent(in), optional :: transposed

    If true, then take 42 of transpose of array

  • private subroutine init_rcfftw_2d(fft, direction, m, n, howmany, stride_)

    Create FFTW plan suitable for 2D real to complex transformation

    Arguments

    Type IntentOptional Attributes Name
    type(fft_type), intent(out) :: fft

    The created plan

    integer, intent(in) :: direction

    Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

    integer, intent(in) :: m

    Number of points in first dimension of array to transform

    integer, intent(in) :: n

    Number of points in second dimension of array to transform

    integer, intent(in) :: howmany

    Number of independent FFTs in array

    integer, intent(in), optional :: stride_

    Stride of array if different from howmany


Derived Types

type, public ::  fft_type

Information about a planned 42 transform

Components

Type Visibility Attributes Name Initial
logical, public :: created = .false.

True if the plan has been created

integer, public :: n

Number of points in the array to be transformed

integer, public :: direction

Direction of the 42, can be either FFT_FORWARD or FFTW_BACKWARD

integer(kind=kind_id), public :: plan

The FFTW plan object

integer, public :: howmany

How many independent slices in the array to be transformed

logical, public :: strided

True if the array is strided or 2D

real, public :: scale

Normalisation factor

logical, public :: must_scale

If true, then the result of the 42 needs to be multiplied by scale. If false, then the scaling can be skipped, saving some work


Functions

private function basic_init(n, direction, howmany, strided)

Does some common initialisation for fft_type

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Number of points

integer, intent(in) :: direction

Direction of 42, must be either FFT_TO_REAL_SPACE or FFT_TO_SPECTRAL_SPACE

integer, intent(in) :: howmany

Number of independent FFTs

logical, intent(in) :: strided

Is array strided/2D

Return Value type(fft_type)

private function fftw_flags()

Set flags for FFTW3

Arguments

None

Return Value integer


Subroutines

private subroutine init_fft_work()

Perform any one off setup of the fft library. This is currently mostly only needed for builds with OpenMP for threaded transforms.

Arguments

None

public subroutine init_z(fft, direction, n, howmany)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft
integer, intent(in) :: direction
integer, intent(in) :: n
integer, intent(in) :: howmany

public subroutine init_ccfftw(fft, direction, n, howmany, data_array, transpose, m)

Create an FFTW plan for complex-to-complex transforms

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft

The created plan

integer, intent(in) :: direction

Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

integer, intent(in) :: n

Number of points in array to transform

integer, intent(in) :: howmany

Number of independent FFTs in array

complex, intent(inout), dimension(:,:) :: data_array

Example array to transform

logical, intent(in), optional :: transpose

If true, then take 42 of transpose of array

integer, intent(in), optional :: m

Size of transpose direction. Required if transpose is true

private subroutine init_rcfftw_1d(fft, direction, n, howmany, transposed)

Create FFTW plan suitable for 1D real to complex transformation

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft

The created plan

integer, intent(in) :: direction

Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

integer, intent(in) :: n

Number of points in array to transform

integer, intent(in) :: howmany

Number of independent FFTs in array

logical, intent(in), optional :: transposed

If true, then take 42 of transpose of array

private subroutine init_crfftw_1d(fft, direction, n, howmany, transposed)

Create FFTW plan suitable for 1D complex to real transformation

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft

The created plan

integer, intent(in) :: direction

Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

integer, intent(in) :: n

Number of points in array to transform

integer, intent(in) :: howmany

Number of independent FFTs in array

logical, intent(in), optional :: transposed

If true, then take 42 of transpose of array

private subroutine init_rcfftw_2d(fft, direction, m, n, howmany, stride_)

Create FFTW plan suitable for 2D real to complex transformation

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft

The created plan

integer, intent(in) :: direction

Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

integer, intent(in) :: m

Number of points in first dimension of array to transform

integer, intent(in) :: n

Number of points in second dimension of array to transform

integer, intent(in) :: howmany

Number of independent FFTs in array

integer, intent(in), optional :: stride_

Stride of array if different from howmany

private subroutine init_crfftw_2d(fft, direction, m, n, howmany, stride_)

Create FFTW plan suitable for 2D complex to real transformation

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(out) :: fft

The created plan

integer, intent(in) :: direction

Direction of the transformation, either FFT_TO_SPECTRAL_SPACE or FFT_TO_REAL_SPACE

integer, intent(in) :: m

Number of points in first dimension of array to transform

integer, intent(in) :: n

Number of points in second dimension of array to transform

integer, intent(in) :: howmany

Number of independent FFTs in array

integer, intent(in), optional :: stride_

Stride of array if different from howmany

public subroutine delete_fft(fft)

Destroy 42 plan

Read more…

Arguments

Type IntentOptional Attributes Name
type(fft_type), intent(inout) :: fft

public subroutine finish_fft_work()

Restore FFTW to pristine state

Arguments

None

public subroutine save_wisdom(filename)

Save FFTW wisdom to file

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename

public subroutine load_wisdom(filename)

Load FFTW wisdom from file

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename