23 integer,
private :: IMAX, JMAX
24 integer,
private :: IGS, JGS
25 integer,
private :: LMM, MMM
28 real(RP),
private,
allocatable :: table_x(:,:), table_y(:,:)
29 real(RP),
private,
allocatable :: table_l(:), table_m(:)
31 real(RP),
private,
allocatable :: work(:,:,:)
35 subroutine dft_setup(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM)
37 integer,
intent(in) :: ka, ia, ja
38 integer,
intent(in) :: ks, ke, is, ie, js, je
39 integer,
intent(in) :: lm, mm
41 integer :: i, j, k, l, m
52 allocate( table_x(is:ie,0:2*lm), table_y(js:je,0:2*mm) )
53 allocate( table_l(0:2*lm), table_m(0:2*mm) )
54 allocate( work(ka,0:2*lm,ja) )
57 x = 2*pi/imax*(i-is+igs)
63 x = 2*pi/imax*(i-is+igs)
64 table_x(i,2*l-1) = cos(l*x)
65 table_x(i,2*l) = -sin(l*x)
70 y = 2*pi/jmax*(j-js+jgs)
76 y = 2*pi/jmax*(j-js+jgs)
77 table_y(j,2*m-1) = cos(m*y)
78 table_y(j,2*m) = -sin(m*y)
84 table_l(2*l-1) = cos(pi*l/imax)
85 table_l(2*l) = sin(pi*l/imax)
90 table_m(2*m-1) = cos(pi*m/jmax)
91 table_m(2*m) = sin(pi*m/jmax)
96 subroutine dft_g2s(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,f,s)
98 integer,
intent(in) :: KA, IA, JA
99 integer,
intent(in) :: KS, KE, IS, IE, JS, JE
100 integer,
intent(in) :: LM, MM
101 real(RP),
intent(in) :: f(KA, IA, JA)
102 real(RP),
intent(out) :: s(KA,0:2*LM,0:2*MM)
103 real(RP) :: work_s(KA,0:2*LM,0:2*MM)
105 integer :: i, j, k, l, m
117 work(k,l,j) = work(k,l,j) + f(k,i,j)*tb
137 work_s(k,l,m) = work_s(k,l,m) + work(k,l,j)*tb
147 subroutine dft_s2g(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,s,f)
149 integer,
intent(in) :: KA, IA, JA
150 integer,
intent(in) :: KS, KE, IS, IE, JS, JE
151 integer,
intent(in) :: LM, MM
152 real(RP),
intent(in) :: s(KA,0:2*LM,0:2*MM)
153 real(RP),
intent(out) :: f(KA, IA, JA)
155 integer :: i, j, k, l, m
183 work(k,l,j) = work(k,l,j) + s(k,l,m)*tb
204 f(k,i,j) = f(k,i,j) + work(k,l,j)*tb
213 subroutine dft_g2g(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,f)
214 integer,
intent(in) :: ka, ia, ja
215 integer,
intent(in) :: ks, ke, is, ie, js, je
216 integer,
intent(in) :: lm, mm
217 real(rp),
intent(inout) :: f(ka, ia, ja)
218 real(rp) :: s(ka,0:2*lm,0:2*mm)
220 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,f,s)
221 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s,f)
226 subroutine dft_g2g_divfree(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,u,v)
227 integer,
intent(in) :: ka, ia, ja
228 integer,
intent(in) :: ks, ke, is, ie, js, je
229 integer,
intent(in) :: lm, mm
230 real(rp),
intent(inout) :: u(ka, ia, ja)
231 real(rp),
intent(inout) :: v(ka, ia, ja)
233 real(rp) :: s1(ka,0:2*lm,0:2*mm)
234 real(rp) :: s2(ka,0:2*lm,0:2*mm)
235 real(rp) :: s3(ka,0:2*lm,0:2*mm)
236 real(rp) :: a, b, fac
238 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,u,s1)
246 s1(k,2*l-1,m) = a*table_l(2*l-1) + b*table_l(2*l)
247 s1(k,2*l,m) = b*table_l(2*l-1) - a*table_l(2*l)
252 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,v,s2)
260 s2(k,l,2*m-1) = a*table_m(2*m-1) + b*table_m(2*m)
261 s2(k,l,2*m) = b*table_m(2*m-1) - a*table_m(2*m)
279 s3(k,2*l-1,m) = -l*s2(k,2*l,m)
280 s3(k,2*l,m) = l*s2(k,2*l-1,m)
289 s3(k,l,2*m-1) = s3(k,l,2*m-1) + m*s1(k,l,2*m)
290 s3(k,l,2*m) = s3(k,l,2*m) - m*s1(k,l,2*m-1)
303 s3(k,2*l-1,0) = s3(k,2*l-1,0)*fac
304 s3(k,2*l,0) = s3(k,2*l,0)*fac
311 s3(k,0,2*m-1) = s3(k,0,2*m-1)*fac
312 s3(k,0,2*m) = s3(k,0,2*m)*fac
318 fac = 1.0_rp/ (l*l+m*m)
320 s3(k,2*l-1,2*m-1) = s3(k,2*l-1,2*m-1)*fac
321 s3(k,2*l-1,2*m) = s3(k,2*l-1,2*m)*fac
322 s3(k,2*l,2*m-1) = s3(k,2*l,2*m-1)*fac
323 s3(k,2*l,2*m) = s3(k,2*l,2*m)*fac
339 s1(k,l,2*m-1) = -m*s3(k,l,2*m)
340 s1(k,l,2*m) = m*s3(k,l,2*m-1)
354 s2(k,2*l-1,m) = l*s3(k,2*l,m)
355 s2(k,2*l,m) = -l*s3(k,2*l-1,m)
366 s1(k,2*l-1,m) = a*table_l(2*l-1) - b*table_l(2*l)
367 s1(k,2*l,m) = b*table_l(2*l-1) + a*table_l(2*l)
372 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s1,u)
380 s2(k,l,2*m-1) = a*table_m(2*m-1) - b*table_m(2*m)
381 s2(k,l,2*m) = b*table_m(2*m-1) + a*table_m(2*m)
386 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s2,v)