60 in_fv, lcmesh3D, elem3D_, IS, IE, IA, IHALO, JS, JE, JA, JHALO, KS, KE, KA, KHALO, &
61 interp_ord, out_dg_flush_flag )
62 use scale_comm_cartesc,
only: &
68 integer,
intent(in) :: IS, IE, IA, IHALO
69 integer,
intent(in) :: JS, JE, JA, JHALO
70 integer,
intent(in) :: KS, KE, KA, KHALO
71 real(RP),
intent(inout) :: out_dg(elem3D_%Np,lcmesh3D%NeA)
72 real(RP),
intent(in) :: in_fv(KA,IA,JA)
73 integer,
intent(in) :: interp_ord
74 logical,
intent(in),
optional :: out_dg_flush_flag
76 integer :: ke_x, ke_y, ke_z
80 real(RP) :: tend_fv_cp(KA,IA,JA)
81 real(RP) :: dqdx(KA,IA,JA), dqdy(KA,IA,JA), dqdz(KA,IA,JA)
82 real(RP) :: dqdxx(KA,IA,JA), dqdyy(KA,IA,JA), dqdzz(KA,IA,JA)
83 real(RP) :: dqdxy(KA,IA,JA), dqdxz(KA,IA,JA), dqdyz(KA,IA,JA)
85 logical :: out_dg_flush_flag_
88 if (
present(out_dg_flush_flag) )
then
89 out_dg_flush_flag_ = out_dg_flush_flag
91 out_dg_flush_flag_ = .true.
94 tend_fv_cp(:,:,:) = in_fv(:,:,:)
95 if ( interp_ord > 0 )
then
96 call comm_vars8( tend_fv_cp(:,:,:), 1 )
97 call comm_wait( tend_fv_cp(:,:,:), 1, .true. )
102 if ( out_dg_flush_flag_ )
then
108 if ( interp_ord > 0 )
then
113 dqdx(k,i,j) = 0.25_rp * ( tend_fv_cp(k,i+1,j) - tend_fv_cp(k,i-1,j) )
121 dqdy(k,i,j) = 0.25_rp * ( tend_fv_cp(k,i,j+1) - tend_fv_cp(k,i,j-1) )
129 dqdz(k,i,j) = 0.25_rp * ( tend_fv_cp(k+1,i,j) - tend_fv_cp(k-1,i,j) )
131 dqdz(ks,i,j) = 0.25_rp * ( - tend_fv_cp(ks+2,i,j) + 4.0_rp * tend_fv_cp(ks+1,i,j) - 3.0_rp * tend_fv_cp(ks,i,j) )
132 dqdz(ke,i,j) = 0.25_rp * ( 3.0_rp * tend_fv_cp(ke,i,j) - 4.0_rp * tend_fv_cp(ke-1,i,j) + tend_fv_cp(ke-2,i,j) )
136 if ( interp_ord > 1 )
then
141 dqdxx(k,i,j) = 0.25_rp * ( tend_fv_cp(k,i+1,j) - 2.0_rp * tend_fv_cp(k,i,j) + tend_fv_cp(k,i-1,j) )
149 dqdyy(k,i,j) = 0.25_rp * ( tend_fv_cp(k,i,j+1) - 2.0_rp * tend_fv_cp(k,i,j) + tend_fv_cp(k,i,j-1) )
157 dqdxy(k,i,j) = 0.25_rp * ( dqdx(k,i,j+1) - dqdx(k,i,j-1) )
165 dqdzz(k,i,j) = 0.25_rp * ( tend_fv_cp(k+1,i,j) - 2.0_rp * tend_fv_cp(k,i,j) + tend_fv_cp(k-1,i,j) )
166 dqdxz(k,i,j) = 0.25_rp * ( dqdx(k+1,i,j) - dqdx(k-1,i,j) )
167 dqdyz(k,i,j) = 0.25_rp * ( dqdy(k+1,i,j) - dqdy(k-1,i,j) )
169 dqdzz(ks,i,j) = dqdzz(ks+1,i,j); dqdzz(ke,i,j) = dqdzz(ke-1,i,j);
170 dqdxz(ks,i,j) = 0.5_rp * ( dqdx(ks+1,i,j) - dqdx(ks,i,j) ); dqdxz(ke,i,j) = 0.5_rp * ( dqdx(ke,i,j) - dqdx(ke-1,i,j) );
171 dqdyz(ks,i,j) = 0.5_rp * ( dqdy(ks+1,i,j) - dqdy(ks,i,j) ); dqdyz(ke,i,j) = 0.5_rp * ( dqdy(ke,i,j) - dqdy(ke-1,i,j) );
176 select case(interp_ord)
179 do ke_z=1, lcmesh3d%NeZ
180 do ke_y=1, lcmesh3d%NeY
181 do ke_x=1, lcmesh3d%NeX
182 kelem = ke_x + (ke_y-1)*lcmesh3d%NeX + (ke_z-1)*lcmesh3d%NeX*lcmesh3d%NeY
183 i = ihalo + ke_x; j = jhalo + ke_y; k = khalo + ke_z
184 out_dg(:,kelem) = out_dg(:,kelem) &
191 do ke_z=1, lcmesh3d%NeZ
192 do ke_y=1, lcmesh3d%NeY
193 do ke_x=1, lcmesh3d%NeX
194 kelem = ke_x + (ke_y-1)*lcmesh3d%NeX + (ke_z-1)*lcmesh3d%NeX*lcmesh3d%NeY
195 i = ihalo + ke_x; j = jhalo + ke_y; k = khalo + ke_z
196 out_dg(:,kelem) = out_dg(:,kelem) &
198 + dqdx(k,i,j) * elem3d_%x1(:) &
199 + dqdy(k,i,j) * elem3d_%x2(:) &
200 + dqdz(k,i,j) * elem3d_%x3(:)
206 do ke_z=1, lcmesh3d%NeZ
207 do ke_y=1, lcmesh3d%NeY
208 do ke_x=1, lcmesh3d%NeX
209 kelem = ke_x + (ke_y-1)*lcmesh3d%NeX + (ke_z-1)*lcmesh3d%NeX*lcmesh3d%NeY
210 i = ihalo + ke_x; j = jhalo + ke_y; k = khalo + ke_z
211 out_dg(:,kelem) = out_dg(:,kelem) &
213 + dqdx(k,i,j) * elem3d_%x1(:) &
214 + dqdy(k,i,j) * elem3d_%x2(:) &
215 + dqdz(k,i,j) * elem3d_%x3(:) &
216 + dqdxy(k,i,j) * elem3d_%x1(:) * elem3d_%x2(:) &
217 + dqdxz(k,i,j) * elem3d_%x1(:) * elem3d_%x3(:) &
218 + dqdyz(k,i,j) * elem3d_%x2(:) * elem3d_%x3(:) &
219 + 0.5_rp * dqdxx(k,i,j) * ( elem3d_%x1(:)**2 - 1.0_rp / 3.0_rp ) &
220 + 0.5_rp * dqdyy(k,i,j) * ( elem3d_%x2(:)**2 - 1.0_rp / 3.0_rp ) &
221 + 0.5_rp * dqdzz(k,i,j) * ( elem3d_%x3(:)**2 - 1.0_rp / 3.0_rp )
235 in_fv, lcmesh2D, elem2D_, IS, IE, IA, IHALO, JS, JE, JA, JHALO, &
236 interp_ord, out_dg_flush_flag )
237 use scale_comm_cartesc,
only: &
243 integer,
intent(in) :: IS, IE, IA, IHALO
244 integer,
intent(in) :: JS, JE, JA, JHALO
245 real(RP),
intent(inout) :: out_dg(elem2D_%Np,lcmesh2D%NeA)
246 real(RP),
intent(in) :: in_fv(IA,JA)
247 integer,
intent(in) :: interp_ord
248 logical,
intent(in),
optional :: out_dg_flush_flag
250 integer :: ke_x, ke_y
254 real(RP) :: tend_fv_cp(IA,JA)
255 real(RP) :: dqdx(IA,JA), dqdy(IA,JA)
256 real(RP) :: dqdxx(IA,JA), dqdyy(IA,JA)
257 real(RP) :: dqdxy(IA,JA)
259 logical :: out_dg_flush_flag_
262 if (
present(out_dg_flush_flag) )
then
263 out_dg_flush_flag_ = out_dg_flush_flag
265 out_dg_flush_flag_ = .true.
268 tend_fv_cp(:,:) = in_fv(:,:)
269 if ( interp_ord > 0 )
then
270 call comm_vars8( tend_fv_cp(:,:), 1 )
271 call comm_wait( tend_fv_cp(:,:), 1, .false. )
276 if ( out_dg_flush_flag_ )
then
282 if ( interp_ord > 0 )
then
286 dqdx(i,j) = 0.25_rp * ( tend_fv_cp(i+1,j) - tend_fv_cp(i-1,j) )
292 dqdy(i,j) = 0.25_rp * ( tend_fv_cp(i,j+1) - tend_fv_cp(i,j-1) )
296 if ( interp_ord > 1 )
then
300 dqdxx(i,j) = 0.25_rp * ( tend_fv_cp(i+1,j) - 2.0_rp * tend_fv_cp(i,j) + tend_fv_cp(i-1,j) )
306 dqdyy(i,j) = 0.25_rp * ( tend_fv_cp(i,j+1) - 2.0_rp * tend_fv_cp(i,j) + tend_fv_cp(i,j-1) )
312 dqdxy(i,j) = 0.25_rp * ( dqdx(i,j+1) - dqdx(i,j-1) )
317 select case(interp_ord)
320 do ke_y=1, lcmesh2d%NeY
321 do ke_x=1, lcmesh2d%NeX
322 kelem = ke_x + (ke_y-1)*lcmesh2d%NeX
323 i = ihalo + ke_x; j = jhalo + ke_y;
324 out_dg(:,kelem) = out_dg(:,kelem) &
330 do ke_y=1, lcmesh2d%NeY
331 do ke_x=1, lcmesh2d%NeX
332 kelem = ke_x + (ke_y-1)*lcmesh2d%NeX
333 i = ihalo + ke_x; j = jhalo + ke_y
334 out_dg(:,kelem) = out_dg(:,kelem) &
336 + dqdx(i,j) * elem2d_%x1(:) &
337 + dqdy(i,j) * elem2d_%x2(:)
342 do ke_y=1, lcmesh2d%NeY
343 do ke_x=1, lcmesh2d%NeX
344 kelem = ke_x + (ke_y-1)*lcmesh2d%NeX
345 i = ihalo + ke_x; j = jhalo + ke_y
346 out_dg(:,kelem) = out_dg(:,kelem) &
348 + dqdx(i,j) * elem2d_%x1(:) &
349 + dqdy(i,j) * elem2d_%x2(:) &
350 + dqdxy(i,j) * elem2d_%x1(:) * elem2d_%x2(:) &
351 + 0.5_rp * dqdxx(i,j) * ( elem2d_%x1(:)**2 - 1.0_rp / 3.0_rp ) &
352 + 0.5_rp * dqdyy(i,j) * ( elem2d_%x2(:)**2 - 1.0_rp / 3.0_rp )