FFT_BOX

   more...

   more...
Computes the Discrete Fourier Transform of several complex or real sequences.
Function Return Value
Complex array containing the Discrete Fourier Transform of the sequences in X . If X is an assumed shape complex array of rank 2, 3 or 4, the result is a complex array of the same shape and rank consisting of the DFT for each of the last rank’s indices.  (Output)
Required Argument
X — Box containing the sequences for which the transform is to be computed. X is an assumed shape complex array of rank 2, 3 or 4. If X is real or double, it is converted to complex internally prior to the computation. (Input)
Optional Arguments, Packaged Options
WORK — A COMPLEX array of the same precision as the data. For rank-1 transforms the size of WORK is n + 15. To define this array for each problem, set WORK(1) = 0. Each additional rank adds the dimension of the transform plus 15. Using the optional argument WORK increases the efficiency of the transform
The option and derived type names are given in the following tables:
Option Names for FFT
Option Value
Options_for_fast_dft
1
Name of Unallocated Option Array to Use for Setting Options
Use
Derived Type
?_fft_box_options(:)
Use when setting options for calls hereafter.
?_options
?_fft_box_options_once(:)
Use when setting options for next call only.
?_options
For a description on how to use these options, see Matrix Optional Data Changes. See FAST_DFT located in Chapter 6, “Transforms” for the specific options for this routine.
FORTRAN 90 Interface
FFT_BOX (X [])
Description
Computes the Discrete Fourier Transform of a box of complex sequences. This function uses FAST_DFT, FAST_2DFT, and FAST_3DFT from Chapter 6.
Examples
Parallel Example
 
use rand_gen_int
use fft_box_int
use ifft_box_int
use linear_operators
use mpi_setup_int
 
implicit none
 
! This is FFT_BOX example.
 
integer i,j
integer, parameter :: n=40, nr=4
real(kind(1e0)) :: err(nr), one=1e0
real(kind(1e0)) :: a(n,1,nr), b(n,nr), c(n,1,nr), yy(n,n,nr)
complex(kind(1e0)), dimension(n,nr) :: f, fa, fb, cc, aa
 
real(kind(1e0)),parameter::zero_par=0.e0
real(kind(1e0))::dummy_par(0)
integer iseed_par
type(s_options)::iopti_par(2)
 
 
! setup for MPI
MP_NPROCS = MP_SETUP()
 
! Set Random Number generator seed
 
iseed_par = 53976279
iopti_par(1)=s_options(s_rand_gen_generator_seed,zero_par)
iopti_par(2)=s_options(iseed_par,zero_par)
 
 
call rand_gen(dummy_par,iopt=iopti_par)
! Generate two random periodic sequences 'a' and 'b'.
a=rand(a); b=rand(b)
! Compute the convolution 'c' of 'a' and 'b'.
do i=1,nr
aa(1:,i) = a(1:,1,i)
yy(1:,1,i)=b(1:,i)
do j=2,n
yy(2:,j,i)=yy(1:n-1,j-1,i)
yy(1,j,i)=yy(n,j-1,i)
end do
end do
 
c=yy .x. a
 
! Compute f=inverse(transform(a)*transform(b)).
fa = fft_box(aa)
fb = fft_box(b)
f=ifft_box(fa*fb)
! Check the Convolution Theorem:
! inverse(transform(a)*transform(b)) = convolution(a,b).
do i=1,nr
cc(1:,i) = c(1:,1,i)
end do
err = norm(cc-f)/norm(cc)
if (ALL(err <= sqrt(epsilon(one))) .AND. MP_RANK == 0) then
write (*,*) 'FFT_BOX is correct.'
end if
 
MP_NPROCS = MP_SETUP('Final')
end