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.



Contents


Variables

Type Visibility Attributes Name Initial
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.

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 = 0

Number of points in the array to be transformed

integer, public :: direction = 0

Direction of the 42, can be either FFT_FORWARD or FFTW_BACKWARD

type(C_PTR), public :: plan = C_NULL_PTR

The FFTW plan object

integer, public :: howmany = 0

How many independent slices in the array to be transformed

logical, public :: strided = .false.

True if the array is strided or 2D

real, public :: scale = 0

Normalisation factor

logical, public :: must_scale = .false.

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

Type-Bound Procedures

procedure , public :: execute_c2r Subroutine
procedure , public :: execute_r2c Subroutine
procedure , public :: execute_c2c Subroutine
procedure , public :: delete => delete_fft Subroutine
procedure , private :: init => basic_init Subroutine

Functions

private pure function fftw_flags()

Set flags for FFTW3

Arguments

None

Return Value integer


Subroutines

private subroutine execute_c2c(self, array_in, array_out)

Small wrapper to bind execute c2c to fft_type

Arguments

Type IntentOptional Attributes Name
class(fft_type), intent(in) :: self
complex, intent(inout), dimension(*) :: array_in
complex, intent(out), dimension(*) :: array_out

private subroutine execute_r2c(self, array_in, array_out)

Small wrapper to bind execute r2c to fft_type

Arguments

Type IntentOptional Attributes Name
class(fft_type), intent(in) :: self
real, intent(inout), dimension(*) :: array_in
complex, intent(out), dimension(*) :: array_out

private subroutine execute_c2r(self, array_in, array_out)

Small wrapper to bind execute c2r to fft_type

Arguments

Type IntentOptional Attributes Name
class(fft_type), intent(in) :: self
complex, intent(inout), dimension(*) :: array_in
real, intent(out), dimension(*) :: array_out

private subroutine delete_fft(self)

Destroy 42 plan

Read more…

Arguments

Type IntentOptional Attributes Name
class(fft_type), intent(inout) :: self

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

private subroutine basic_init(self, n, direction, howmany, strided)

Does some common initialisation for fft_type

Arguments

Type IntentOptional Attributes Name
class(fft_type), intent(inout) :: self
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

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 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