38 USE gft,
only: gft_prec, gft_rcr, gft_set_fft, gft_do_fft, gft_end_fft
40 INTEGER,
INTENT(IN):: isp
41 INTEGER,
INTENT(IN):: ny,mx,niy,mjx
42 COMPLEX(kind=GFT_Prec),
DIMENSION(0:niy/2,mjx),
INTENT(IN) :: kernelTransf
43 REAL(kind=gft_prec),
DIMENSION(0:ny-1,mx),
INTENT(IN) :: spatdatain
44 REAL(kind=gft_prec),
DIMENSION(0:ny-1,mx),
INTENT(OUT):: spatdataout
47 REAL(kind=gft_prec),
DIMENSION(0:niy-1,mjx) :: spatdatainhelp
48 REAL(kind=gft_prec),
DIMENSION(0:niy-1,mjx) :: spatdataouthelpwithkernel
49 REAL(kind=gft_prec) :: sc , ratio
50 COMPLEX(kind=GFT_Prec),
DIMENSION(0:niy/2,mjx) :: spatDataTransf,spatDataTransfWithKernel
54 INTEGER :: ilat, ilon, nstart_y, nend_y, mstart_x, mend_x, dimx,dimy
66 nstart_y = 0; nend_y = ny-1
67 mstart_x = 1; mend_x = mx
72 spatdatainhelp(0:,:) =0
73 spatdatainhelp(nstart_y : nend_y, mstart_x : mend_x )=spatdatain
79 CALL gft_set_fft(nx=dimy, ny=dimx, fft=rcr)
85 sc = 1.0_gft_prec/real(dimx*dimy , kind=gft_prec)
86 CALL gft_do_fft(fft=rcr, isign= -1, scale=sc, r_in=spatdatainhelp, c_out=spatdatatransf)
94 spatdatatransfwithkernel = spatdatatransf * kerneltransf
105 CALL gft_do_fft(fft=rcr, isign=1, scale=sc, c_in=spatdatatransfwithkernel, r_out=spatdataouthelpwithkernel)
112 if (spatdataouthelpwithkernel(ilat, ilon) < 0 ) spatdataouthelpwithkernel(ilat, ilon)=0
113 if (spatdataouthelpwithkernel(ilat, ilon) < 1.0e-10 ) spatdataouthelpwithkernel(ilat, ilon)=0
118 spatdataout=spatdataouthelpwithkernel(nstart_y : nend_y, mstart_x : mend_x )
121 ratio=sum(spatdatain)/sum(spatdataout)
123 spatdataout=spatdataout*ratio
127 CALL gft_end_fft(fft=rcr)
167 USE gft,
only: gft_rcr, gft_prec, gft_set_fft, gft_do_fft, gft_end_fft
170 INTEGER,
INTENT(IN):: ny, mx, niy, mjx, y_dim_kernel, x_dim_kernel
172 REAL (kind=gft_prec),
DIMENSION(0:(y_dim_kernel-1),x_dim_kernel ),
INTENT(IN):: kernelin
174 COMPLEX(kind=GFT_Prec),
DIMENSION(0:(niy/2),mjx),
INTENT(OUT) :: kernelTransf
176 REAL (kind=gft_prec),
DIMENSION(0:(niy-1),mjx) :: kernel,kernel1
177 REAL (kind=gft_prec),
DIMENSION(0:(ny-1),mx) :: mediumsizekernel
178 REAL (kind=gft_prec),
DIMENSION(0:(ny-1),mx) :: reorderedkernel
179 REAL (kind=gft_prec) :: sc
180 INTEGER :: edge_y, edge_x,edge_y_sm, edge_x_sm, code, dimy,dimx
189 kernel(0:,:)=0; kernel1(0:,:)=0;
193 mediumsizekernel(:,:)=0.
194 edge_y_sm = (dimy - y_dim_kernel)/2
195 edge_x_sm = (dimx - x_dim_kernel)/2
196 mediumsizekernel( (edge_y_sm +1 ):(edge_y_sm + y_dim_kernel) , (edge_x_sm + 1):(edge_x_sm + x_dim_kernel)) = kernelin
202 kernel((edge_y+1):(edge_y+dimy),(edge_x+1):(edge_x+dimx))= reorderedkernel
206 CALL gft_set_fft(nx=dimy, ny=dimx, fft=rcr, code=code)
209 sc = 1.0_gft_prec/real(dimx*dimy , kind=gft_prec)
212 CALL gft_do_fft(fft=rcr, isign=-1 , scale=sc, r_in=kernel, c_out=kerneltransf)
214 CALL gft_end_fft(fft=rcr)
239 INTEGER,
INTENT(IN):: ispec
240 INTEGER :: safety_margin, &
241 maxlatEven, maxlonEven, maxlatExt, maxlonExt, maxlatEvenExt, maxlonEvenExt
243 safety_margin =
spec(ispec)%rad
245 maxlateven= ((
maxlat + safety_margin - 1) / 2) * 2 + 2
246 maxloneven= ((
maxlon + safety_margin - 1) / 2) * 2 + 2
248 maxlonevenext=2**ceiling(log(1.*maxloneven)/log(2.))
249 maxlatevenext=2**ceiling(log(1.*maxlateven)/log(2.))
251 maxlatext=2**(1+ceiling(log(maxlatevenext*1.)/log(2.)))
252 maxlonext=2**(1+ceiling(log(maxlonevenext*1.)/log(2.)))
256 print *,
"ispec, maxlat, maxlatEvenext(ny),maxlatExt(niy), ", ispec,
maxlat,maxlatevenext, maxlatext
257 print *,
"ispec, maxlon, maxlonEvenext(mx),maxlonExt(mjx)", ispec,
maxlon,maxlonevenext, maxlonext
259 spec(ispec)%maxlatExt = maxlatext
260 spec(ispec)%maxlonExt = maxlonext
261 spec(ispec)%maxlatEvenExt = maxlatevenext
262 spec(ispec)%maxlonEvenExt = maxlonevenext
283 SUBROUTINE lowpassfilter(dimy_start, dimy_end, dimx_start, dimx_end , filterexpo, filter)
284 USE gft,
only: gft_prec
287 INTEGER,
INTENT(IN):: dimy_start, dimy_end, dimx_start, dimx_end
288 REAL,
INTENT(IN) :: filterexpo
289 COMPLEX(kind=GFT_Prec),
DIMENSION(dimy_start:dimy_end,dimx_start:dimx_end),
INTENT(OUT):: filter
294 DO iy = dimy_start, dimy_end
295 DO jx = dimx_start, dimx_end
296 distance= ( iy**2 + (jx-1)**2 )**0.5 + 1.
297 filter(iy,jx) =
COMPLEX((1./distance**filterexpo), 0.)
300 filter(:,:) = filter(:,:) /sum(filter(:,:))
subroutine gft2dconvolution(isp, ny, mx, niy, mjx, spatdatain, kerneltransf, spatdataout)
subroutine gft2dtransformkernel(ny, mx, niy, mjx, y_dim_kernel, x_dim_kernel, kernelin, kerneltransf)
GFT2DTransformKernel