fourier_fftpack

Module

Description

$Id$

This module contains FFT wrapper subroutines.

Quick access

Variables:

ax, ay, az, fft_x_parallel, fft_x_parallel_1d, fft_x_parallel_2d, fft_x_parallel_3d, fft_x_parallel_4d, fft_xy_parallel, fft_xy_parallel_2d, fft_xy_parallel_2d_other, fft_xy_parallel_3d, fft_xy_parallel_4d, fft_xyz_parallel, fft_xyz_parallel_3d, fft_xyz_parallel_3d_body, fft_xyz_parallel_4d, fft_y_parallel, fft_y_parallel_1d, fft_y_parallel_2d, fft_y_parallel_3d, fft_y_parallel_4d, fft_z_parallel, fft_z_parallel_1d, fft_z_parallel_2d, fft_z_parallel_3d, fft_z_parallel_4d, fourier_transform_other, fourier_transform_other_1, fourier_transform_other_2, fourier_transform_xy_xy_body, kx_fft, kx_fft2, ky_fft, ky_fft2, kz_fft, kz_fft2, p_im_2d, p_im_3d, p_im_4d, p_re_2d, p_re_3d, p_re_4d, t_im_2d, t_im_3d, t_im_4d, t_re_2d, t_re_3d, t_re_4d, wsavex, wsavey, wsavez

Routines:

fft_xy_parallel_2d_other(), field_extrapol_z_parallel(), fourier_shift_y(), fourier_shift_yz_y(), fourier_transform(), fourier_transform_real_1(), fourier_transform_shear(), fourier_transform_shear_xy(), fourier_transform_x(), fourier_transform_xy(), fourier_transform_xy_xy(), fourier_transform_xy_xy_other(), fourier_transform_xz(), fourier_transform_y(), fourier_transform_y_y(), initialize_fourier(), setup_extrapol_fact(), vect_pot_extrapol_z_parallel()

Needed modules

Variables

  • fourier/ax (nxgrid) [complex,private]
  • fourier/ay (nygrid) [complex,private]
  • fourier/az (nzgrid) [complex,private]
  • fourier/fft_x_parallel [public]
  • fourier/fft_x_parallel_1d [private]
  • fourier/fft_x_parallel_2d [private]
  • fourier/fft_x_parallel_3d [private]
  • fourier/fft_x_parallel_4d [private]
  • fourier/fft_xy_parallel [public]
  • fourier/fft_xy_parallel_2d [private]
  • fourier/fft_xy_parallel_3d [private]
  • fourier/fft_xy_parallel_4d [private]
  • fourier/fft_xyz_parallel [public]
  • fourier/fft_xyz_parallel_3d [private]
  • fourier/fft_xyz_parallel_3d_body [private]
  • fourier/fft_xyz_parallel_4d [private]
  • fourier/fft_y_parallel [public]
  • fourier/fft_y_parallel_1d [private]
  • fourier/fft_y_parallel_2d [private]
  • fourier/fft_y_parallel_3d [private]
  • fourier/fft_y_parallel_4d [private]
  • fourier/fft_z_parallel [public]
  • fourier/fft_z_parallel_1d [private]
  • fourier/fft_z_parallel_2d [private]
  • fourier/fft_z_parallel_3d [private]
  • fourier/fft_z_parallel_4d [private]
  • fourier/fourier_transform_other [public]
  • fourier/fourier_transform_other_1 [private]
  • fourier/fourier_transform_other_2 [private]
  • fourier/fourier_transform_xy_xy_body [private]
  • fourier/kx_fft (nxgrid) [real,public]
  • fourier/kx_fft2 (nxgrid) [real,public]
  • fourier/ky_fft (nygrid) [real,public]
  • fourier/ky_fft2 (nygrid) [real,public]
  • fourier/kz_fft (nzgrid) [real,public]
  • fourier/kz_fft2 (nzgrid) [real,public]
  • fourier/p_im_2d (*,*) [real,private/allocatable]
  • fourier/p_im_3d (*,*,*) [real,private/allocatable]
  • fourier/p_im_4d (*,*,*,*) [real,private/allocatable]
  • fourier/p_re_2d (*,*) [real,private/allocatable]
  • fourier/p_re_3d (*,*,*) [real,private/allocatable]
  • fourier/p_re_4d (*,*,*,*) [real,private/allocatable]
  • fourier/t_im_2d (*,*) [real,private/allocatable]
  • fourier/t_im_3d (*,*,*) [real,private/allocatable]
  • fourier/t_im_4d (*,*,*,*) [real,private/allocatable]
  • fourier/t_re_2d (*,*) [real,private/allocatable]
  • fourier/t_re_3d (*,*,*) [real,private/allocatable]
  • fourier/t_re_4d (*,*,*,*) [real,private/allocatable]
  • fourier/wsavex (*,*) [real,private/allocatable]
  • fourier/wsavey (*,*) [real,private/allocatable]
  • fourier/wsavez (*,*) [real,private/allocatable]

Subroutines and functions

subroutine  fourier/initialize_fourier()
Use :

general (idiv())

Call to:

cffti(), fatal_error(), information(), cfftf(), transp(), cfftb(), not_implemented(), transp_other(), transp_xy(), transp_xy_other(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform(a_re, a_im[, linv])

Subroutine to do Fourier transform in 3-D. The routine overwrites the input data. This version works currently only when nxgrid=nygrid=nzgrid! The length of the work arrays for ffts is therefore always nx.

27-oct-02/axel: adapted from transform_i, for fftpack

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

Call to:

fatal_error(), information(), cfftf(), transp(), cfftb(), not_implemented(), transp_other(), cffti(), transp_xy(), transp_xy_other(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_xy(a_re, a_im[, linv])

Subroutine to do Fourier transform in x and y. The routine overwrites the input data. This version works currently only when nxgrid=nygrid! The length of the work arrays for ffts is therefore always nx.

19-dec-06/anders: adapted from fourier_transform

Parameters:
  • a_re (,,*) [real]

  • a_im (,,*) [real]

  • linv [logical]

Call to:

fatal_error(), information(), cfftf(), transp(), cfftb(), not_implemented(), transp_other(), cffti(), transp_xy(), transp_xy_other(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_xz(a_re, a_im[, linv])

Subroutine to do Fourier transform in the x- and z-directions. The routine overwrites the input data. This version works currently only when nxgrid=nygrid=nzgrid! The length of the work arrays for ffts is therefore always nx.

27-oct-02/axel: adapted from transform_fftpack

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

Call to:

not_implemented(), fatal_error(), information(), cfftf(), transp(), cfftb(), transp_other(), cffti(), transp_xy(), transp_xy_other(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_x(a_re, a_im[, linv])

Subroutine to do Fourier transform in the x-direction. WARNING: It is not cache efficient to Fourier transform in any other direction, so better transpose the array and only transform in x.

The routine overwrites the input data. This version works currently only when nxgrid=nygrid=nzgrid! The length of the work arrays for ffts is therefore always nx.

06-feb-03/nils: adapted from transform_fftpack

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

Call to:

fatal_error(), information(), cfftf(), cfftb(), transp(), transp_other(), cffti(), transp_xy(), transp_xy_other(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_y(a_re, a_im[, linv[, lnorm]])

Subroutine to do Fourier transform in the y-direction. As it is not cache efficient to Fourier transform in other direction than x, we transpose the array. The original array and the transposed one are shown below in the left and right sides, respectively

————— ^ nygrid —————- ^ nygrid

|x z Q W E R T Y| | |r s m W |i h c Y| | |j k l m n b v c| | |e a l Q |u g v T| | |---------------| | ^ |----------------| | ^ |o p a s d f g h| | | ny |w p k z |y f b R| | | ny |q w e r t y u i| | | |q o j x |t d n E| | |

————— —————- —————> <nygrid><nygrid>

nx —————-> nx

The transposed array has the elements in the correct order, but for obvious book-keeping reasons, the dimension is still (nx,ny), instead of (nygrid,nx). The fourier transform then can be done, but the calculation has to be split into boxes of dimension (nygrid,ny). Therefore, it only works when nx is a multiple of nygrid.

For the case nx<nygrid, interpolate the x-values to the dimension of nygrid prior to transposing. Then transform and interpolate back

07-may-08/wlad: coded

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

  • lnorm [logical]

Use :

general (spline())

Call to:

fatal_error(), information(), transp(), cfftf(), cfftb(), transp_other(), cffti(), transp_xy(), transp_xy_other(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_shear(a_re, a_im[, linv])

Subroutine to do Fourier transform in shearing coordinates. The routine overwrites the input data.

The transform from real space to Fourier space goes as follows:

(x,y,z)

(y,x,z) - (ky,x,z) - (ky’,x,z)

(x,ky’,z) - (kx,ky’,z)

(z,ky’,kx) - (kz,ky’,kx)

Vertical lines refer to a transposition operation, horizontal lines to any other operation. Here ky’ refers to a coordinate frame where y has been transformed so that the x-direction is purely periodic (not shear periodic). The transformation from Fourier space to real space takes place like sketched in the diagram, only in the opposite direction (starting lower right).

For 2-D runs two cases of degeneracy have to be taken into account: (- refers to a missing direction).

(x,y,-)

(y,x,-) - (ky,x,-) - (ky’,x,-)

(x, ky’,-) - (kx,ky’,-)

(x,-,z) - (kx,-,z)

(z,-,kx) - (kz,-,kx)

25-may-06/anders: adapted from transform_fftpack

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

Call to:

fatal_error(), information(), transp(), cfftf(), cfftb(), cffti(), transp_xy(), transp_xy_other(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_shear_xy(a_re, a_im[, linv])

Subroutine to do Fourier transform in shearing coordinates. The routine overwrites the input data.

The transform from real space to Fourier space goes as follows:

(x,y,z)

(y,x,z) - (ky,x,z) - (ky’,x,z)

(x,ky’,z) - (kx,ky’,z)

Vertical lines refer to a transposition operation, horizontal lines to any other operation. Here ky’ refers to a coordinate frame where y has been transformed so that the x-direction is purely periodic (not shear periodic). The transformation from Fourier space to real space takes place like sketched in the diagram, only in the opposite direction (starting lower right).

19-dec-06/anders: adapted from fourier_transform_shear

Parameters:
  • a_re (nx,ny,nz) [real]

  • a_im (nx,ny,nz) [real]

  • linv [logical]

Call to:

fatal_error(), information(), transp(), cfftf(), cfftb(), cffti(), transp_xy(), transp_xy_other(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_xy_xy(a_re, a_im[, linv[, lneed_im]])

Wraps the actual xy-transform for correct multithreading logic

$ use OMP_lib

Parameters:
  • a_re (,) [real,inout]

  • a_im (,) [real,inout]

  • linv [logical,in,]

  • lneed_im [logical,in,]

Call to:

transp_xy(), cfftf(), cfftb(), fatal_error(), transp_xy_other(), cffti(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_xy_xy_other(a_re, a_im[, linv])

Subroutine to do Fourier transform of a 2-D array of arbitrary size under MPI. The routine overwrites the input data.

15-jan-2008/wlad: adapted from fourier_transform_xy_xy

and fourier_transform_other_2

Parameters:
  • a_re (,) [real]

  • a_im (,) [real]

  • linv [logical]

Use :

mpicomm (transp_xy_other())

Call to:

fatal_error(), transp_xy_other(), cffti(), cfftf(), cfftb(), not_implemented(), remap_to_pencil_x(), unmap_from_pencil_x(), remap_to_pencil_xy_2d_other(), unmap_from_pencil_xy_2d_other(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/fft_xy_parallel_2d_other(a_re, a_im[, linv[, lignore_shear]])

For x- and/or y-parallelization the calculation will be done under MPI in parallel on all processors of the corresponding xy-plane. nx is restricted to be an integer multiple of nprocy. ny is restricted to be an integer multiple of nprocx. linv indicates forward (=false, default) or backward (=true) transform. You can set lneed_im=false if the imaginary data can be disregarded. Attention: input data will be overwritten.

09-jul-2013/wlad: adpated from fft_xy_parallel

Parameters:
  • a_re (,) [real]

  • a_im (,) [real]

  • linv [logical]

  • lignore_shear [logical]

Use :

mpicomm (remap_to_pencil_xy_2d_other(), transp_pencil_xy(), unmap_from_pencil_xy_2d_other())

Call to:

fatal_error(), cffti(), remap_to_pencil_xy_2d_other(), cfftf(), unmap_from_pencil_xy_2d_other(), cfftb(), not_implemented(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/setup_extrapol_fact(z, ref_z, factor[, reduce])

Subroutine to setup ‘factor’ for z-extrapolation of a vector potential. ‘factor’ is the multiplication factor for the Fourier coefficients, including the normalization. ‘z’ gives the z-coordinates. ‘ref_z’ gives the reference z-coordinate for the extrapolation. ‘reduce’ is used to reduce the eventual enhancement of contrast in cases where a z is smaller than ref_z (=”intrapolation”). nx is restricted to be an integer multiple of nprocy. ny is restricted to be an integer multiple of nprocx.

25-jan-2011/Bourdin.KIS: coded

Parameters:
  • z (*) [real,in]

  • ref_z [real,in]

  • factor (,,*) [real,out]

  • reduce [real,in,]

Call to:

fatal_error(), not_implemented(), cfftf(), cfftb(), cffti(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/vect_pot_extrapol_z_parallel(in, out, factor)

Subroutine to do a z-extrapolation of a vector potential using ‘factor’ as a multiplication factor to the Fourier coefficients. The normalization needs to be already included in ‘factor’. Backwards and forwards transforms are done efficiently in one go. For x- and/or y-parallelization the calculation will be done under MPI in parallel on all processors of the corresponding xy-plane. nx is restricted to be an integer multiple of nprocy. ny is restricted to be an integer multiple of nprocx.

7-jul-2010/Bourdin.KIS: coded, adapted parts of bc_aa_pot2 and mdi_init

Parameters:
  • in (,,*) [real,in]

  • out (,,*,*) [real,out]

  • factor (,,*) [real,in]

Use :

mpicomm (remap_to_pencil_xy(), transp_pencil_xy(), unmap_from_pencil_xy())

Call to:

fatal_error(), not_implemented(), cfftf(), cfftb(), cffti(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/field_extrapol_z_parallel(in, out, factor)

Subroutine to do a z-extrapolation of a fields z-component using ‘factor’ as a multiplication factor to the Fourier coefficients. The normalization needs to be already included in ‘factor’. ‘in’ and ‘factor’ are assumed to be already in pencil shape. Backwards and forwards transforms are done efficiently in one go. For x- and/or y-parallelization the calculation will be done under MPI in parallel on all processors of the corresponding xy-plane. nx is restricted to be an integer multiple of nprocy. ny is restricted to be an integer multiple of nprocx.

7-jul-2010/Bourdin.KIS: coded, adapted parts of bc_aa_pot2 and mdi_init

Parameters:
  • in (,) [real,in]

  • out (,,*,*) [real,out]

  • factor (,,*) [real,in]

Use :

mpicomm (remap_to_pencil_xy(), transp_pencil_xy(), unmap_from_pencil_xy())

Call to:

fatal_error(), not_implemented(), cfftf(), cfftb(), cffti(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_y_y(a_re, a_im[, linv])

Subroutine to do Fourier transform of a 1-D array under MPI. Not very efficient since the ipy=0 processors do all the work.

3-sep-2008/anders: adapted from fourier_transform_xy_xy

Parameters:
  • a_re (ny) [real]

  • a_im (ny) [real]

  • linv [logical]

Use :

mpicomm (mpirecv_real(), mpisend_real()), general (find_proc())

Call to:

cfftf(), cfftb(), fatal_error(), cffti(), information(), transp(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_shift_yz_y(a_re, shift_y)

Performs a periodic shift in the y-direction of an entire y-z plane by the amount shift_y. The shift is done in Fourier space for maximum interpolation accuracy. Data is re-distributed in elongated shape, so that the FFT will be performed in parallel on all processors.

19-jul-06/anders: coded

Parameters:
  • a_re (ny,nz) [real]

  • shift_y [real]

Use :

mpicomm (mpisend_real(), mpirecv_real()), general (find_proc())

Call to:

fatal_error(), cffti(), information(), transp(), cfftf(), cfftb(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_shift_y(a_re, shift_y)

Performs a periodic shift in the y-direction by the amount shift_y(x). The shift is done in Fourier space for maximum interpolation accuracy. MR: NOT USED; POTENTIALLY INCORRECT

04-oct-07/anders: adapted from fourier_transform_shear

Parameters:
  • a_re (nx,ny,nz) [real]

  • shift_y (nx) [real]

Call to:

fatal_error(), cffti(), information(), transp(), cfftf(), cfftb(), rffti(), rfftf(), rfftb()

subroutine  fourier/fourier_transform_real_1(a, na, ifirst_fft, wsavex_temp[, linv])

Subroutine to do Fourier transform on a 1-D real array of arbitrary size. This routine does not operate in parallel, but should be used to Fourier transform an array present in its entirety on the local processor. The routine overwrites the input data.

1-jul-2006/dhruba: Adapted from fourier_transform_other_1

Parameters:
  • a (na) [real]

  • na [integer,in,]

  • ifirst_fft [integer,in]

  • wsavex_temp (15 + 2 * na) [real]

  • linv [logical]

Call to:

rffti(), information(), rfftf(), rfftb()

subroutine  fourier/pushpars2c(p_par)
Parameters:

p_par (3) [integer]

Use :

syscalls (copy_addr()), general (string_to_enum())