24 integer,
private :: IMAX, JMAX
25 integer,
private :: IGS, JGS
26 integer,
private :: LMM, MMM
29 real(RP),
private,
allocatable :: table_x(:,:), table_y(:,:)
30 real(RP),
private,
allocatable :: table_l(:), table_m(:)
32 real(RP),
private,
allocatable :: work(:,:,:)
36 subroutine dft_setup(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM)
38 integer,
intent(in) :: ka, ia, ja
39 integer,
intent(in) :: ks, ke, is, ie, js, je
40 integer,
intent(in) :: lm, mm
42 integer :: i, j, k, l, m
53 allocate( table_x(is:ie,0:2*lm), table_y(js:je,0:2*mm) )
54 allocate( table_l(0:2*lm), table_m(0:2*mm) )
55 allocate( work(ka,0:2*lm,ja) )
58 x = 2*pi/imax*(i-is+igs)
64 x = 2*pi/imax*(i-is+igs)
65 table_x(i,2*l-1) = cos(l*x)
66 table_x(i,2*l) = -sin(l*x)
71 y = 2*pi/jmax*(j-js+jgs)
77 y = 2*pi/jmax*(j-js+jgs)
78 table_y(j,2*m-1) = cos(m*y)
79 table_y(j,2*m) = -sin(m*y)
85 table_l(2*l-1) = cos(pi*l/imax)
86 table_l(2*l) = sin(pi*l/imax)
91 table_m(2*m-1) = cos(pi*m/jmax)
92 table_m(2*m) = sin(pi*m/jmax)
106 deallocate( table_x, table_y )
107 deallocate( table_l, table_m )
113 subroutine dft_g2s(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,f,s)
115 integer,
intent(in) :: KA, IA, JA
116 integer,
intent(in) :: KS, KE, IS, IE, JS, JE
117 integer,
intent(in) :: LM, MM
118 real(RP),
intent(in) :: f(KA, IA, JA)
119 real(RP),
intent(out) :: s(KA,0:2*LM,0:2*MM)
120 real(RP) :: work_s(KA,0:2*LM,0:2*MM)
122 integer :: i, j, k, l, m
138 work(k,l,j) = work(k,l,j) + f(k,i,j)*tb
163 work_s(k,l,m) = work_s(k,l,m) + work(k,l,j)*tb
176 subroutine dft_s2g(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,s,f)
178 integer,
intent(in) :: KA, IA, JA
179 integer,
intent(in) :: KS, KE, IS, IE, JS, JE
180 integer,
intent(in) :: LM, MM
181 real(RP),
intent(in) :: s(KA,0:2*LM,0:2*MM)
182 real(RP),
intent(out) :: f(KA, IA, JA)
184 integer :: i, j, k, l, m
220 work(k,l,j) = work(k,l,j) + s(k,l,m)*tb
244 f(k,i,j) = f(k,i,j) + work(k,l,j)*tb
256 subroutine dft_g2g(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,f)
257 integer,
intent(in) :: ka, ia, ja
258 integer,
intent(in) :: ks, ke, is, ie, js, je
259 integer,
intent(in) :: lm, mm
260 real(rp),
intent(inout) :: f(ka, ia, ja)
261 real(rp) :: s(ka,0:2*lm,0:2*mm)
263 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,f,s)
264 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s,f)
269 subroutine dft_g2g_divfree(KA,KS,KE,IA,IS,IE,JA,JS,JE,LM,MM,u,v)
270 integer,
intent(in) :: ka, ia, ja
271 integer,
intent(in) :: ks, ke, is, ie, js, je
272 integer,
intent(in) :: lm, mm
273 real(rp),
intent(inout) :: u(ka, ia, ja)
274 real(rp),
intent(inout) :: v(ka, ia, ja)
276 real(rp) :: s1(ka,0:2*lm,0:2*mm)
277 real(rp) :: s2(ka,0:2*lm,0:2*mm)
278 real(rp) :: s3(ka,0:2*lm,0:2*mm)
279 real(rp) :: a, b, fac
283 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,u,s1)
292 s1(k,2*l-1,m) = a*table_l(2*l-1) + b*table_l(2*l)
293 s1(k,2*l,m) = b*table_l(2*l-1) - a*table_l(2*l)
299 call dft_g2s(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,v,s2)
308 s2(k,l,2*m-1) = a*table_m(2*m-1) + b*table_m(2*m)
309 s2(k,l,2*m) = b*table_m(2*m-1) - a*table_m(2*m)
331 s3(k,2*l-1,m) = -l*s2(k,2*l,m)
332 s3(k,2*l,m) = l*s2(k,2*l-1,m)
343 s3(k,l,2*m-1) = s3(k,l,2*m-1) + m*s1(k,l,2*m)
344 s3(k,l,2*m) = s3(k,l,2*m) - m*s1(k,l,2*m-1)
361 s3(k,2*l-1,0) = s3(k,2*l-1,0)*fac
362 s3(k,2*l,0) = s3(k,2*l,0)*fac
371 s3(k,0,2*m-1) = s3(k,0,2*m-1)*fac
372 s3(k,0,2*m) = s3(k,0,2*m)*fac
380 fac = 1.0_rp/ (l*l+m*m)
382 s3(k,2*l-1,2*m-1) = s3(k,2*l-1,2*m-1)*fac
383 s3(k,2*l-1,2*m) = s3(k,2*l-1,2*m)*fac
384 s3(k,2*l,2*m-1) = s3(k,2*l,2*m-1)*fac
385 s3(k,2*l,2*m) = s3(k,2*l,2*m)*fac
405 s1(k,l,2*m-1) = -m*s3(k,l,2*m)
406 s1(k,l,2*m) = m*s3(k,l,2*m-1)
424 s2(k,2*l-1,m) = l*s3(k,2*l,m)
425 s2(k,2*l,m) = -l*s3(k,2*l-1,m)
438 s1(k,2*l-1,m) = a*table_l(2*l-1) - b*table_l(2*l)
439 s1(k,2*l,m) = b*table_l(2*l-1) + a*table_l(2*l)
445 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s1,u)
454 s2(k,l,2*m-1) = a*table_m(2*m-1) - b*table_m(2*m)
455 s2(k,l,2*m) = b*table_m(2*m-1) + a*table_m(2*m)
461 call dft_s2g(ka,ks,ke,ia,is,ie,ja,js,je,lm,mm,s2,v)