-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfft.f90
33 lines (26 loc) · 1.03 KB
/
fft.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
! some routines to compute the
! discrete fourier transform
! using the fftw library
module fft
use, intrinsic :: iso_c_binding ! allow c binding
include 'fftw3.f03'
contains
subroutine fft_forward_3d(Nx,Ny,Nz,in,out)
integer,intent(in) :: Nx,Ny,Nz
complex(C_DOUBLE_COMPLEX),intent(inout) :: in(0:Nx-1,0:Ny-1,0:Nz-1)
complex(C_DOUBLE_COMPLEX),intent(out) :: out(0:Nx-1,0:Ny-1,0:Nz-1)
type(C_PTR) :: plan
plan = fftw_plan_dft_3d(Nz,Ny,Nx,in,out,FFTW_FORWARD, FFTW_ESTIMATE)
call fftw_execute_dft(plan,in,out)
call fftw_destroy_plan(plan)
end subroutine fft_forward_3d
subroutine fft_backward_3d(Nx,Ny,Nz,in,out)
integer,intent(in) :: Nx,Ny,Nz
complex(C_DOUBLE_COMPLEX),intent(inout) :: in(0:Nx-1,0:Ny-1,0:Nz-1)
complex(C_DOUBLE_COMPLEX),intent(out) :: out(0:Nx-1,0:Ny-1,0:Nz-1)
type(C_PTR) :: plan
plan = fftw_plan_dft_3d(Nz,Ny,Nx,in,out,FFTW_BACKWARD, FFTW_ESTIMATE)
call fftw_execute_dft(plan,in,out)
call fftw_destroy_plan(plan)
end subroutine fft_backward_3d
end module fft