15 #include "inc_openmp.h" 18 #define PROFILE_START(name) call fapp_start(name, 1, 1) 19 #define PROFILE_STOP(name) call fapp_stop (name, 1, 1) 20 #elif defined(PROFILE_FINEPA) 21 #define PROFILE_START(name) call start_collection(name) 22 #define PROFILE_STOP(name) call stop_collection (name) 24 #define PROFILE_START(name) 25 #define PROFILE_STOP(name) 39 #if defined DEBUG || defined QUICKDEBUG 66 #define F2H(k,p,idx) (CDZ(k+p-1)*GSQRT(k+p-1,i,j,idx)/(CDZ(k)*GSQRT(k,i,j,idx)+CDZ(k+1)*GSQRT(k+1,i,j,idx))) 68 # define F2H(k,p,idx) 0.5_RP 75 integer,
private,
parameter :: NB = 1
76 integer,
private,
parameter :: VA_FVM_HEVI = 0
94 character(len=*),
intent(in) :: atmos_dyn_type
95 integer,
intent(out) :: va_out
96 character(len=H_SHORT),
intent(out) :: var_name(:)
97 character(len=H_MID),
intent(out) :: var_desc(:)
98 character(len=H_SHORT),
intent(out) :: var_unit(:)
101 if ( atmos_dyn_type /=
'FVM-HEVI' .AND. atmos_dyn_type /=
'HEVI' )
then 102 write(*,*)
'xxx ATMOS_DYN_TYPE is not FVM-HEVI. Check!' 112 if(
io_l )
write(
io_fid_log,*)
'*** Register additional prognostic variables (HEVI)' 113 if ( va_out < 1 )
then 133 DENS_RK, MOMZ_RK, MOMX_RK, MOMY_RK, RHOT_RK, &
136 DENS0, MOMZ0, MOMX0, MOMY0, RHOT0, &
137 DENS, MOMZ, MOMX, MOMY, RHOT, &
138 DENS_t, MOMZ_t, MOMX_t, MOMY_t, RHOT_t, &
140 DPRES0, RT2P, CORIOLI, &
141 num_diff, wdamp_coef, divdmp_coef, DDIV, &
142 FLAG_FCT_MOMENTUM, FLAG_FCT_T, &
143 FLAG_FCT_ALONG_STREAM, &
144 CDZ, FDZ, FDX, FDY, &
145 RCDZ, RCDX, RCDY, RFDZ, RFDX, RFDY, &
146 PHI, GSQRT, J13G, J23G, J33G, MAPF, &
147 REF_dens, REF_rhot, &
148 BND_W, BND_E, BND_S, BND_N, &
153 rdry => const_rdry, &
154 cvdry => const_cvdry, &
155 cpdry => const_cpdry, &
158 grav => const_grav, &
200 real(RP),
intent(out) :: dens_rk(
ka,
ia,
ja)
201 real(RP),
intent(out) :: momz_rk(
ka,
ia,
ja)
202 real(RP),
intent(out) :: momx_rk(
ka,
ia,
ja)
203 real(RP),
intent(out) :: momy_rk(
ka,
ia,
ja)
204 real(RP),
intent(out) :: rhot_rk(
ka,
ia,
ja)
206 real(RP),
intent(out) :: prog_rk(
ka,
ia,
ja,
va)
208 real(RP),
intent(inout) :: mflx_hi(
ka,
ia,
ja,3)
209 real(RP),
intent(out) :: tflx_hi(
ka,
ia,
ja,3)
211 real(RP),
intent(in),
target :: dens0(
ka,
ia,
ja)
212 real(RP),
intent(in),
target :: momz0(
ka,
ia,
ja)
213 real(RP),
intent(in),
target :: momx0(
ka,
ia,
ja)
214 real(RP),
intent(in),
target :: momy0(
ka,
ia,
ja)
215 real(RP),
intent(in),
target :: rhot0(
ka,
ia,
ja)
217 real(RP),
intent(in) :: dens(
ka,
ia,
ja)
218 real(RP),
intent(in) :: momz(
ka,
ia,
ja)
219 real(RP),
intent(in) :: momx(
ka,
ia,
ja)
220 real(RP),
intent(in) :: momy(
ka,
ia,
ja)
221 real(RP),
intent(in) :: rhot(
ka,
ia,
ja)
223 real(RP),
intent(in) :: dens_t(
ka,
ia,
ja)
224 real(RP),
intent(in) :: momz_t(
ka,
ia,
ja)
225 real(RP),
intent(in) :: momx_t(
ka,
ia,
ja)
226 real(RP),
intent(in) :: momy_t(
ka,
ia,
ja)
227 real(RP),
intent(in) :: rhot_t(
ka,
ia,
ja)
229 real(RP),
intent(in) :: prog0(
ka,
ia,
ja,
va)
230 real(RP),
intent(in) :: prog (
ka,
ia,
ja,
va)
232 real(RP),
intent(in) :: dpres0(
ka,
ia,
ja)
233 real(RP),
intent(in) :: rt2p(
ka,
ia,
ja)
234 real(RP),
intent(in) :: corioli(1,
ia,
ja)
235 real(RP),
intent(in) :: num_diff(
ka,
ia,
ja,5,3)
236 real(RP),
intent(in) :: wdamp_coef(
ka)
237 real(RP),
intent(in) :: divdmp_coef
238 real(RP),
intent(in) :: ddiv(
ka,
ia,
ja)
240 logical,
intent(in) :: flag_fct_momentum
241 logical,
intent(in) :: flag_fct_t
242 logical,
intent(in) :: flag_fct_along_stream
244 real(RP),
intent(in) :: cdz(
ka)
245 real(RP),
intent(in) :: fdz(
ka-1)
246 real(RP),
intent(in) :: fdx(
ia-1)
247 real(RP),
intent(in) :: fdy(
ja-1)
248 real(RP),
intent(in) :: rcdz(
ka)
249 real(RP),
intent(in) :: rcdx(
ia)
250 real(RP),
intent(in) :: rcdy(
ja)
251 real(RP),
intent(in) :: rfdz(
ka-1)
252 real(RP),
intent(in) :: rfdx(
ia-1)
253 real(RP),
intent(in) :: rfdy(
ja-1)
255 real(RP),
intent(in) :: phi (
ka,
ia,
ja)
256 real(RP),
intent(in) :: gsqrt (
ka,
ia,
ja,7)
257 real(RP),
intent(in) :: j13g (
ka,
ia,
ja,7)
258 real(RP),
intent(in) :: j23g (
ka,
ia,
ja,7)
259 real(RP),
intent(in) :: j33g
260 real(RP),
intent(in) :: mapf (
ia,
ja,2,4)
261 real(RP),
intent(in) :: ref_dens(
ka,
ia,
ja)
262 real(RP),
intent(in) :: ref_rhot(
ka,
ia,
ja)
264 logical,
intent(in) :: bnd_w
265 logical,
intent(in) :: bnd_e
266 logical,
intent(in) :: bnd_s
267 logical,
intent(in) :: bnd_n
269 real(RP),
intent(in) :: dtrk
270 logical,
intent(in) :: last
274 real(RP) :: pott(
ka,
ia,
ja)
275 real(RP) :: dpres(
ka,
ia,
ja)
277 real(RP) :: qflx_hi (
ka,
ia,
ja,3)
278 real(RP) :: qflx_j13(
ka,
ia,
ja)
279 real(RP) :: qflx_j23(
ka,
ia,
ja)
288 real(RP) :: advch_t(
ka,
ia,
ja,5)
289 real(RP) :: advcv_t(
ka,
ia,
ja,5)
290 real(RP) :: wdmp_t(
ka,
ia,
ja)
291 real(RP) :: ddiv_t(
ka,
ia,
ja,3)
292 real(RP) :: pg_t(
ka,
ia,
ja,3)
293 real(RP) :: cf_t(
ka,
ia,
ja,2)
310 integer :: iis, iie, jjs, jje
320 qflx_hi(:,:,:,:) = undef
321 qflx_j13(:,:,:) = undef
322 qflx_j23(:,:,:) = undef
325 #if defined DEBUG || defined QUICKDEBUG 326 dens_rk( 1:
ks-1,:,:) = undef
327 dens_rk(
ke+1:
ka ,:,:) = undef
328 momz_rk( 1:
ks-1,:,:) = undef
329 momz_rk(
ke+1:
ka ,:,:) = undef
330 momx_rk( 1:
ks-1,:,:) = undef
331 momx_rk(
ke+1:
ka ,:,:) = undef
332 momy_rk( 1:
ks-1,:,:) = undef
333 momy_rk(
ke+1:
ka ,:,:) = undef
334 rhot_rk( 1:
ks-1,:,:) = undef
335 rhot_rk(
ke+1:
ka ,:,:) = undef
336 prog_rk( 1:
ks-1,:,:,:) = undef
337 prog_rk(
ke+1:
ka ,:,:,:) = undef
350 if ( bnd_w ) ifs_off = 0
351 if ( bnd_s ) jfs_off = 0
359 profile_start(
"hevi_pres")
366 call check( __line__, dpres0(k,i,j) )
367 call check( __line__, rt2p(k,i,j) )
368 call check( __line__, rhot(k,i,j) )
369 call check( __line__, ref_rhot(k,i,j) )
371 dpres(k,i,j) = dpres0(k,i,j) + rt2p(k,i,j) * ( rhot(k,i,j) - ref_rhot(k,i,j) )
373 dpres(
ks-1,i,j) = dpres0(
ks-1,i,j) - dens(
ks,i,j) * ( phi(
ks-1,i,j) - phi(
ks+1,i,j) )
374 dpres(
ke+1,i,j) = dpres0(
ke+1,i,j) - dens(
ke,i,j) * ( phi(
ke+1,i,j) - phi(
ke-1,i,j) )
377 profile_stop(
"hevi_pres")
381 profile_start(
"hevi_mflx_z")
387 mflx_hi(
ks-1,i,j,
zdir) = 0.0_rp
390 call check( __line__, momx(k+1,i ,j) )
391 call check( __line__, momx(k+1,i-1,j) )
392 call check( __line__, momx(k ,i ,j) )
393 call check( __line__, momx(k ,i+1,j) )
394 call check( __line__, momy(k+1,i,j) )
395 call check( __line__, momy(k+1,i,j-1) )
396 call check( __line__, momy(k ,i,j) )
397 call check( __line__, momy(k ,i,j-1) )
399 mflx_hi(k,i,j,
zdir) = j13g(k,i,j,
i_xyw) * 0.25_rp / mapf(i,j,2,
i_xy) &
400 * ( momx(k+1,i,j)+momx(k+1,i-1,j) &
401 + momx(k ,i,j)+momx(k ,i-1,j) ) &
402 + j23g(k,i,j,
i_xyw) * 0.25_rp / mapf(i,j,1,
i_xy) &
403 * ( momy(k+1,i,j)+momy(k+1,i,j-1) &
404 + momy(k ,i,j)+momy(k ,i,j-1) ) &
405 + gsqrt(k,i,j,
i_xyw) / ( mapf(i,j,1,
i_xy)*mapf(i,j,2,
i_xy) ) * num_diff(k,i,j,
i_dens,
zdir)
407 mflx_hi(
ke ,i,j,
zdir) = 0.0_rp
411 k = iundef; i = iundef; j = iundef
413 profile_stop(
"hevi_mflx_z")
415 profile_start(
"hevi_mflx_x")
416 iss = max(iis-1,
is-ifs_off)
426 call check( __line__, momx(k,i,j) )
429 mflx_hi(k,i,j,
xdir) = gsqrt(k,i,j,
i_uyz) / mapf(i,j,2,
i_uy) &
430 * ( momx(k,i,j) + num_diff(k,i,j,
i_dens,
xdir) )
435 k = iundef; i = iundef; j = iundef
437 profile_stop(
"hevi_mflx_x")
442 do j = max(jjs-1,
js-jfs_off), min(jje,
jeh)
447 call check( __line__, momy(k,i,j) )
450 mflx_hi(k,i,j,
ydir) = gsqrt(k,i,j,
i_xvz) / mapf(i,j,1,
i_xv) &
451 * ( momy(k,i,j) + num_diff(k,i,j,
i_dens,
ydir) )
456 k = iundef; i = iundef; j = iundef
460 profile_start(
"hevi_sr")
473 call check( __line__, dens0(k,i,j) )
474 call check( __line__, mflx_hi(k ,i ,j ,
xdir) )
475 call check( __line__, mflx_hi(k ,i-1,j ,
xdir) )
476 call check( __line__, mflx_hi(k ,i ,j ,
ydir) )
477 call check( __line__, mflx_hi(k ,i ,j-1,
ydir) )
478 call check( __line__, dens_t(k,i,j) )
480 advcv = - ( mflx_hi(k,i,j,
zdir)-mflx_hi(k-1,i ,j,
zdir) ) * rcdz(k)
481 advch = - ( ( mflx_hi(k,i,j,
xdir)-mflx_hi(k ,i-1,j,
xdir) ) * rcdx(i) &
482 + ( mflx_hi(k,i,j,
ydir)-mflx_hi(k ,i, j-1,
ydir) ) * rcdy(j) ) &
483 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy)
484 sr(k,i,j) = ( advcv + advch ) / gsqrt(k,i,j,
i_xyz) + dens_t(k,i,j)
495 k = iundef; i = iundef; j = iundef
497 profile_stop(
"hevi_sr")
503 profile_start(
"hevi_momz_qflxhi_z")
506 gsqrt(:,:,:,
i_xyz), j33g, &
510 profile_stop(
"hevi_momz_qflxhi_z")
512 profile_start(
"hevi_momz_qflxj")
515 gsqrt(:,:,:,
i_xyz), j13g(:,:,:,
i_xyz), mapf(:,:,:,
i_xy), &
520 gsqrt(:,:,:,
i_xyz), j23g(:,:,:,
i_xyz), mapf(:,:,:,
i_xy), &
523 profile_stop(
"hevi_momz_qflxj")
526 profile_start(
"hevi_momz_qflxhi_x")
533 profile_stop(
"hevi_momz_qflxhi_x")
536 profile_start(
"hevi_momz_qflxhi_y")
543 profile_stop(
"hevi_momz_qflxhi_y")
546 profile_start(
"hevi_sw")
560 call check( __line__, qflx_hi(k ,i ,j ,
zdir) )
561 call check( __line__, qflx_hi(k-1,i ,j ,
zdir) )
562 call check( __line__, qflx_j13(k ,i ,j) )
563 call check( __line__, qflx_j13(k-1,i ,j) )
564 call check( __line__, qflx_j23(k ,i ,j) )
565 call check( __line__, qflx_j23(k-1,i ,j) )
566 call check( __line__, qflx_hi(k ,i ,j ,
xdir) )
567 call check( __line__, qflx_hi(k ,i-1,j ,
xdir) )
568 call check( __line__, qflx_hi(k ,i ,j ,
ydir) )
569 call check( __line__, qflx_hi(k ,i ,j-1,
ydir) )
570 call check( __line__, ddiv(k ,i,j) )
571 call check( __line__, ddiv(k+1,i,j) )
572 call check( __line__, momz0(k,i,j) )
573 call check( __line__, momz_t(k,i,j) )
575 advcv = - ( qflx_hi(k,i,j,
zdir) - qflx_hi(k-1,i ,j ,
zdir) &
576 + qflx_j13(k,i,j) - qflx_j13(k-1,i ,j ) &
577 + qflx_j23(k,i,j) - qflx_j23(k-1,i ,j ) ) * rfdz(k)
578 advch = - ( ( qflx_hi(k,i,j,
xdir) - qflx_hi(k,i-1,j ,
xdir) ) * rcdx(i) &
579 + ( qflx_hi(k,i,j,
ydir) - qflx_hi(k,i ,j-1,
ydir) ) * rcdy(j) ) &
580 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy)
581 wdmp = - wdamp_coef(k) * momz0(k,i,j)
582 div = divdmp_coef / dtrk * ( ddiv(k+1,i,j)-ddiv(k,i,j) ) * fdz(k)
583 sw(k,i,j) = ( advcv + advch ) / gsqrt(k,i,j,
i_xyw) &
584 + wdmp + div + momz_t(k,i,j)
590 ddiv_t(k,i,j,1) = div
596 profile_stop(
"hevi_sw")
598 k = iundef; i = iundef; j = iundef
610 call check( __line__, rhot(k,i,j) )
611 call check( __line__, dens(k,i,j) )
613 pott(k,i,j) = rhot(k,i,j) / dens(k,i,j)
618 k = iundef; i = iundef; j = iundef
623 mflx_hi(:,:,:,
zdir), pott, gsqrt(:,:,:,
i_xyw), &
630 mflx_hi(:,:,:,
xdir), pott, gsqrt(:,:,:,
i_uyz), &
637 mflx_hi(:,:,:,
ydir), pott, gsqrt(:,:,:,
i_xvz), &
643 profile_start(
"hevi_st")
656 call check( __line__, tflx_hi(k ,i ,j ,
zdir) )
657 call check( __line__, tflx_hi(k-1,i ,j ,
zdir) )
658 call check( __line__, tflx_hi(k ,i ,j ,
xdir) )
659 call check( __line__, tflx_hi(k ,i-1,j ,
xdir) )
660 call check( __line__, tflx_hi(k ,i ,j ,
ydir) )
661 call check( __line__, tflx_hi(k ,i ,j-1,
ydir) )
662 call check( __line__, rhot_t(k,i,j) )
664 advcv = - ( tflx_hi(k,i,j,
zdir) - tflx_hi(k-1,i ,j ,
zdir) ) * rcdz(k)
665 advch = - ( ( tflx_hi(k,i,j,
xdir) - tflx_hi(k ,i-1,j ,
xdir) ) * rcdx(i) &
666 + ( tflx_hi(k,i,j,
ydir) - tflx_hi(k ,i ,j-1,
ydir) ) * rcdy(j) ) &
667 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy)
668 st(k,i,j) = ( advcv + advch ) / gsqrt(k,i,j,
i_xyz) + rhot_t(k,i,j)
679 k = iundef; i = iundef; j = iundef
681 profile_stop(
"hevi_st")
685 profile_start(
"hevi_solver")
712 momz(:,i,j), pott(:,i,j), gsqrt(:,i,j,
i_xyz), &
716 a(k,i,j) = dtrk**2 * j33g * rcdz(k) * rt2p(k,i,j) * j33g / gsqrt(k,i,j,
i_xyz)
718 b = grav * dtrk**2 * j33g / ( cdz(
ks+1) + cdz(
ks) )
719 f1(
ks,i,j) = - ( pt(
ks+1,i,j) * rfdz(
ks) * a(
ks+1,i,j) + b ) / gsqrt(
ks,i,j,
i_xyw)
720 f2(
ks,i,j) = 1.0_rp + ( pt(
ks ,i,j) * rfdz(
ks) * ( a(
ks+1,i,j)+a(
ks,i,j) ) ) / gsqrt(
ks,i,j,
i_xyw)
722 b = grav * dtrk**2 * j33g / ( cdz(k+1) + cdz(k) )
723 f1(k,i,j) = - ( pt(k+1,i,j) * rfdz(k) * a(k+1,i,j) + b ) / gsqrt(k,i,j,
i_xyw)
724 f2(k,i,j) = 1.0_rp + ( pt(k ,i,j) * rfdz(k) * ( a(k+1,i,j)+a(k,i,j) ) ) / gsqrt(k,i,j,
i_xyw)
725 f3(k,i,j) = - ( pt(k-1,i,j) * rfdz(k) * a(k,i,j) - b ) / gsqrt(k,i,j,
i_xyw)
727 b = grav * dtrk**2 * j33g / ( cdz(
ke) + cdz(
ke-1) )
728 f2(
ke-1,i,j) = 1.0_rp + ( pt(
ke-1,i,j) * rfdz(
ke-1) * ( a(
ke,i,j)+a(
ke-1,i,j) ) ) / gsqrt(
ke-1,i,j,
i_xyw)
729 f3(
ke-1,i,j) = - ( pt(
ke-2,i,j) * rfdz(
ke-1) * a(
ke-1,i,j) - b ) / gsqrt(
ke-1,i,j,
i_xyw)
731 pg = - ( dpres(k+1,i,j) + rt2p(k+1,i,j)*dtrk*st(k+1,i,j) &
732 - dpres(k ,i,j) - rt2p(k ,i,j)*dtrk*st(k ,i,j) ) &
733 * rfdz(k) * j33g / gsqrt(k,i,j,
i_xyw) &
735 * ( f2h(k,1,
i_xyz) * ( dens(k+1,i,j) - ref_dens(k+1,i,j) + sr(k+1,i,j) * dtrk ) &
736 + f2h(k,2,
i_xyz) * ( dens(k ,i,j) - ref_dens(k ,i,j) + sr(k ,i,j) * dtrk ) )
737 c(k-
ks+1,i,j) = momz(k,i,j) + dtrk * ( pg + sw(k,i,j) )
739 if ( lhist ) pg_t(k,i,j,1) = pg
745 f1(:,i,j), f2(:,i,j), f3(:,i,j) )
748 #ifdef DEBUG_HEVI2HEVE 750 c(k-
ks+1,i,j) = momz(k,i,j)
751 mflx_hi(k,i,j,
zdir) = mflx_hi(k,i,j,
zdir) &
752 + j33g * momz(k,i,j) / ( mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy) )
753 momz_rk(k,i,j) = momz0(k,i,j) &
755 - j33g * ( dpres(k+1,i,j)-dpres(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_xyw) &
756 - grav * ( f2h(k,2,
i_xyz)*(dens(k,i,j)-ref_dens(k,i,j))+f2h(k,1,
i_xyz)*(dens(k+1,i,j)-ref_dens(k+1,i,j)) ) &
760 mflx_hi(k,i,j,
zdir) = mflx_hi(k,i,j,
zdir) &
761 + j33g * c(k-
ks+1,i,j) / ( mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy) )
763 momz_rk(k,i,j) = momz0(k,i,j) &
764 + ( c(k-
ks+1,i,j) - momz(k,i,j) )
767 momz_rk(
ks-1,i,j) = 0.0_rp
768 momz_rk(
ke ,i,j) = 0.0_rp
771 advcv = - c(1,i,j) * j33g * rcdz(
ks) / gsqrt(
ks,i,j,
i_xyz)
772 dens_rk(
ks,i,j) = dens0(
ks,i,j) + dtrk * ( advcv + sr(
ks,i,j) )
774 if ( lhist ) advcv_t(
ks,i,j,
i_dens) = advcv
776 advcv = - c(1,i,j)*pt(
ks,i,j) * j33g * rcdz(
ks) / gsqrt(
ks,i,j,
i_xyz)
777 rhot_rk(
ks,i,j) = rhot0(
ks,i,j) + dtrk * ( advcv + st(
ks,i,j) )
779 if ( lhist ) advcv_t(
ks,i,j,
i_rhot) = advcv
782 advcv = - ( c(k-
ks+1,i,j) - c(k-
ks,i,j) ) &
783 * j33g * rcdz(k) / gsqrt(k,i,j,
i_xyz)
784 dens_rk(k,i,j) = dens0(k,i,j) + dtrk * ( advcv + sr(k,i,j) )
786 if ( lhist ) advcv_t(k,i,j,
i_dens) = advcv
788 advcv = - ( c(k-
ks+1,i,j)*pt(k,i,j) - c(k-
ks,i,j)*pt(k-1,i,j) ) &
789 * j33g * rcdz(k) / gsqrt(k,i,j,
i_xyz)
790 rhot_rk(k,i,j) = rhot0(k,i,j) + dtrk * ( advcv + st(k,i,j) )
792 if ( lhist ) advcv_t(k,i,j,
i_rhot) = advcv
796 dens_rk(
ke,i,j) = dens0(
ke,i,j) + dtrk * ( advcv + sr(
ke,i,j) )
798 if ( lhist ) advcv_t(
ke,i,j,
i_dens) = advcv
800 advcv = c(
ke-
ks,i,j) * pt(
ke-1,i,j) * j33g * rcdz(
ke) / gsqrt(
ke,i,j,
i_xyz)
801 rhot_rk(
ke,i,j) = rhot0(
ke,i,j) + dtrk * ( advcv + st(
ke,i,j) )
803 if ( lhist ) advcv_t(
ke,i,j,
i_rhot) = advcv
807 call check_equation( &
809 dens(:,i,j), momz(:,i,j), rhot(:,i,j), dpres(:,i,j), &
811 sr(:,i,j), sw(:,i,j), st(:,i,j), &
812 j33g, gsqrt(:,i,j,:), &
820 k = iundef; i = iundef; j = iundef
823 profile_stop(
"hevi_solver")
828 profile_start(
"hevi_momx")
832 gsqrt(:,:,:,
i_uyw), j33g, &
838 gsqrt(:,:,:,
i_uyz), j13g(:,:,:,
i_uyw), mapf(:,:,:,
i_uy), &
843 gsqrt(:,:,:,
i_uyz), j23g(:,:,:,
i_uyw), mapf(:,:,:,
i_uy), &
881 call check( __line__, qflx_hi(k ,i ,j ,
zdir) )
882 call check( __line__, qflx_hi(k-1,i ,j ,
zdir) )
883 call check( __line__, qflx_hi(k ,i ,j ,
xdir) )
884 call check( __line__, qflx_hi(k ,i-1,j ,
xdir) )
885 call check( __line__, qflx_hi(k ,i ,j ,
ydir) )
886 call check( __line__, qflx_hi(k ,i ,j-1,
ydir) )
887 call check( __line__, dpres(k,i+1,j) )
888 call check( __line__, dpres(k,i ,j) )
889 call check( __line__, corioli(1,i ,j) )
890 call check( __line__, corioli(1,i+1,j) )
891 call check( __line__, momy(k,i ,j ) )
892 call check( __line__, momy(k,i+1,j ) )
893 call check( __line__, momy(k,i ,j-1) )
894 call check( __line__, momy(k,i+1,j-1) )
895 call check( __line__, ddiv(k,i+1,j) )
896 call check( __line__, ddiv(k,i ,j) )
897 call check( __line__, momx0(k,i,j) )
899 advcv = - ( qflx_hi(k,i,j,
zdir) - qflx_hi(k-1,i ,j ,
zdir) &
900 + qflx_j13(k,i,j) - qflx_j13(k-1,i ,j ) &
901 + qflx_j23(k,i,j) - qflx_j23(k-1,i ,j ) ) * rcdz(k)
902 advch = - ( ( qflx_hi(k,i,j,
xdir) - qflx_hi(k ,i-1,j ,
xdir) ) * rfdx(i) &
903 + ( qflx_hi(k,i,j,
ydir) - qflx_hi(k ,i ,j-1,
ydir) ) * rcdy(j) ) &
904 * mapf(i,j,1,
i_uy) * mapf(i,j,2,
i_uy)
905 pg = ( ( gsqrt(k,i+1,j,
i_xyz) * dpres(k,i+1,j) &
906 - gsqrt(k,i ,j,
i_xyz) * dpres(k,i ,j) &
908 + ( j13g(k ,i,j,
i_uyw) &
909 * 0.5_rp * ( f2h(k,1,
i_uyz) * ( dpres(k+1,i+1,j)+dpres(k+1,i,j) ) &
910 + f2h(k,2,
i_uyz) * ( dpres(k ,i+1,j)+dpres(k ,i,j) ) ) &
911 - j13g(k-1,i,j,
i_uyw) &
912 * 0.5_rp * ( f2h(k,1,
i_uyz) * ( dpres(k ,i+1,j)+dpres(k ,i,j) ) &
913 + f2h(k,2,
i_uyz) * ( dpres(k-1,i+1,j)+dpres(k-1,i,j) ) ) &
916 cf = 0.125_rp * ( corioli(1,i+1,j )+corioli(1,i,j ) ) &
917 * ( momy(k,i+1,j )+momy(k,i,j ) &
918 + momy(k,i+1,j-1)+momy(k,i,j-1) ) &
919 + 0.25_rp * mapf(i,j,1,
i_uy) * mapf(i,j,2,
i_uy) &
920 * ( momy(k,i,j) + momy(k,i,j-1) + momy(k,i+1,j) + momy(k,i+1,j-1) ) &
921 * ( ( momy(k,i,j) + momy(k,i,j-1) + momy(k,i+1,j) + momy(k,i+1,j-1) ) * 0.25_rp &
922 * ( 1.0_rp/mapf(i+1,j,2,
i_xy) - 1.0_rp/mapf(i,j,2,
i_xy) ) * rfdx(i) &
924 * ( 1.0_rp/mapf(i,j,1,
i_uv) - 1.0_rp/mapf(i,j-1,1,
i_uv) ) * rcdy(j) ) &
925 * 2.0_rp / ( dens(k,i+1,j) + dens(k,i,j) )
926 div = divdmp_coef / dtrk * ( ddiv(k,i+1,j)/mapf(i+1,j,2,
i_xy) - ddiv(k,i,j)/mapf(i,j,1,
i_xy) ) &
927 * mapf(i,j,1,
i_uy) * mapf(i,j,2,
i_uy) * fdx(i)
928 momx_rk(k,i,j) = momx0(k,i,j) &
929 + dtrk * ( ( advcv + advch - pg ) / gsqrt(k,i,j,
i_uyz) + cf + div + momx_t(k,i,j) )
934 pg_t(k,i,j,2) = - pg / gsqrt(k,i,j,
i_uyz)
936 ddiv_t(k,i,j,2) = div
942 profile_stop(
"hevi_momx")
944 k = iundef; i = iundef; j = iundef
948 profile_start(
"hevi_momy")
952 gsqrt(:,:,:,
i_xvw), j33g, &
958 gsqrt(:,:,:,
i_xvz), j13g(:,:,:,
i_xvw), mapf(:,:,:,
i_xv), &
963 gsqrt(:,:,:,
i_xvz), j23g(:,:,:,
i_xvw), mapf(:,:,:,
i_xv), &
996 do j = jjs, min(jje,
jeh)
1000 call check( __line__, qflx_hi(k ,i ,j ,
zdir) )
1001 call check( __line__, qflx_hi(k-1,i ,j ,
zdir) )
1002 call check( __line__, qflx_hi(k ,i ,j ,
xdir) )
1003 call check( __line__, qflx_hi(k ,i-1,j ,
xdir) )
1004 call check( __line__, qflx_hi(k ,i ,j ,
ydir) )
1005 call check( __line__, qflx_hi(k ,i ,j-1,
ydir) )
1006 call check( __line__, dpres(k,i,j ) )
1007 call check( __line__, dpres(k,i,j+1) )
1008 call check( __line__, corioli(1,i,j ) )
1009 call check( __line__, corioli(1,i,j+1) )
1010 call check( __line__, momx(k,i ,j ) )
1011 call check( __line__, momx(k,i ,j+1) )
1012 call check( __line__, momx(k,i-1,j ) )
1013 call check( __line__, momx(k,i-1,j+1) )
1014 call check( __line__, ddiv(k,i,j+1) )
1015 call check( __line__, ddiv(k,i,j ) )
1016 call check( __line__, momy_t(k,i,j) )
1017 call check( __line__, momy0(k,i,j) )
1019 advcv = - ( qflx_hi(k,i,j,
zdir) - qflx_hi(k-1,i ,j ,
zdir) &
1020 + qflx_j13(k,i,j) - qflx_j13(k-1,i ,j ) &
1021 + qflx_j23(k,i,j) - qflx_j23(k-1,i ,j ) ) * rcdz(k)
1022 advch = - ( ( qflx_hi(k,i,j,
xdir) - qflx_hi(k ,i-1,j ,
xdir) ) * rcdx(i) &
1023 + ( qflx_hi(k,i,j,
ydir) - qflx_hi(k ,i ,j-1,
ydir) ) * rfdy(j) ) &
1024 * mapf(i,j,1,
i_xv) * mapf(i,j,2,
i_xv)
1025 pg = ( ( gsqrt(k,i,j+1,
i_xyz) * dpres(k,i,j+1) &
1026 - gsqrt(k,i,j ,
i_xyz) * dpres(k,i,j ) &
1028 + ( j23g(k ,i,j,
i_xvw) &
1029 * 0.5_rp * ( f2h(k ,1,
i_xvz) * ( dpres(k+1,i,j+1)+dpres(k+1,i,j) ) &
1030 + f2h(k ,2,
i_xvz) * ( dpres(k ,i,j+1)+dpres(k ,i,j) ) ) &
1031 - j23g(k-1,i,j,
i_xvw) &
1032 * 0.5_rp * ( f2h(k-1,1,
i_xvz) * ( dpres(k ,i,j+1)+dpres(k ,i,j) ) &
1033 + f2h(k-1,2,
i_xvz) * ( dpres(k-1,i,j+1)+dpres(k-1,i,j) ) ) &
1036 cf = - 0.125_rp * ( corioli(1,i ,j+1)+corioli(1,i ,j) ) &
1037 * ( momx(k,i ,j+1)+momx(k,i ,j) &
1038 + momx(k,i-1,j+1)+momx(k,i-1,j) ) &
1039 - 0.25_rp * mapf(i,j,1,
i_xv) * mapf(i,j,2,
i_xv) &
1040 * ( momx(k,i,j) + momx(k,i-1,j) + momx(k,i,j+1) + momx(k,i-1,j+1) ) &
1042 * ( 1.0_rp/mapf(i,j,2,
i_uv) - 1.0_rp/mapf(i-1,j,2,
i_uv) ) * rcdx(i) &
1043 - 0.25_rp * ( momx(k,i,j)+momx(k,i-1,j)+momx(k,i,j+1)+momx(k,i-1,j+1) ) &
1044 * ( 1.0_rp/mapf(i,j+1,1,
i_xy) - 1.0_rp/mapf(i,j,1,
i_xy) ) * rfdy(j) ) &
1045 * 2.0_rp / ( dens(k,i,j+1) + dens(k,i,j) )
1046 div = divdmp_coef / dtrk * ( ddiv(k,i,j+1)/mapf(i,j+1,1,
i_xy) - ddiv(k,i,j)/mapf(i,j,1,
i_xy) ) &
1047 * mapf(i,j,1,
i_xv) * mapf(i,j,2,
i_xv) * fdy(j)
1048 momy_rk(k,i,j) = momy0(k,i,j) &
1049 + dtrk * ( ( advcv + advch - pg ) / gsqrt(k,i,j,
i_xvz) + cf + div + momy_t(k,i,j) )
1052 advcv_t(k,i,j,
i_momy) = advcv / gsqrt(k,i,j,
i_xvz)
1053 advch_t(k,i,j,
i_momy) = advch / gsqrt(k,i,j,
i_xvz)
1054 pg_t(k,i,j,3) = - pg / gsqrt(k,i,j,
i_xvz)
1056 ddiv_t(k,i,j,3) = div
1062 profile_stop(
"hevi_momy")
1064 k = iundef; i = iundef; j = iundef
1076 call hist_in(advcv_t(:,:,:,
i_dens),
'DENS_t_advcv',
'tendency of density (vert. advection)',
'kg/m3/s' )
1077 call hist_in(advcv_t(:,:,:,
i_momz),
'MOMZ_t_advcv',
'tendency of momentum z (vert. advection)',
'kg/m2/s2', zdim=
'half')
1078 call hist_in(advcv_t(:,:,:,
i_momx),
'MOMX_t_advcv',
'tendency of momentum x (vert. advection)',
'kg/m2/s2', xdim=
'half')
1079 call hist_in(advcv_t(:,:,:,
i_momy),
'MOMY_t_advcv',
'tendency of momentum y (vert. advection)',
'kg/m2/s2', ydim=
'half')
1080 call hist_in(advcv_t(:,:,:,
i_rhot),
'RHOT_t_advcv',
'tendency of rho*theta (vert. advection)',
'K kg/m3/s' )
1082 call hist_in(advch_t(:,:,:,
i_dens),
'DENS_t_advch',
'tendency of density (horiz. advection)',
'kg/m3/s' )
1083 call hist_in(advch_t(:,:,:,
i_momz),
'MOMZ_t_advch',
'tendency of momentum z (horiz. advection)',
'kg/m2/s2', zdim=
'half')
1084 call hist_in(advch_t(:,:,:,
i_momx),
'MOMX_t_advch',
'tendency of momentum x (horiz. advection)',
'kg/m2/s2', xdim=
'half')
1085 call hist_in(advch_t(:,:,:,
i_momy),
'MOMY_t_advch',
'tendency of momentum y (horiz. advection)',
'kg/m2/s2', ydim=
'half')
1086 call hist_in(advch_t(:,:,:,
i_rhot),
'RHOT_t_advch',
'tendency of rho*theta (horiz. advection)',
'K kg/m3/s' )
1088 call hist_in(pg_t(:,:,:,1),
'MOMZ_t_pg',
'tendency of momentum z (pressure gradient)',
'kg/m2/s2', zdim=
'half')
1089 call hist_in(pg_t(:,:,:,2),
'MOMX_t_pg',
'tendency of momentum x (pressure gradient)',
'kg/m2/s2', xdim=
'half')
1090 call hist_in(pg_t(:,:,:,3),
'MOMY_t_pg',
'tendency of momentum y (pressure gradient)',
'kg/m2/s2', ydim=
'half')
1092 call hist_in(wdmp_t(:,:,:),
'MOMZ_t_wdamp',
'tendency of momentum z (Rayleigh damping)',
'kg/m2/s2', zdim=
'half')
1094 call hist_in(ddiv_t(:,:,:,1),
'MOMZ_t_ddiv',
'tendency of momentum z (divergence damping)',
'kg/m2/s2', zdim=
'half')
1095 call hist_in(ddiv_t(:,:,:,2),
'MOMX_t_ddiv',
'tendency of momentum x (divergence damping)',
'kg/m2/s2', xdim=
'half')
1096 call hist_in(ddiv_t(:,:,:,3),
'MOMY_t_ddiv',
'tendency of momentum y (divergence damping)',
'kg/m2/s2', ydim=
'half')
1098 call hist_in(cf_t(:,:,:,1),
'MOMX_t_cf',
'tendency of momentum x (coliolis force)',
'kg/m2/s2', xdim=
'half')
1099 call hist_in(cf_t(:,:,:,2),
'MOMY_t_cf',
'tendency of momentum y (coliolis force)',
'kg/m2/s2', ydim=
'half')
1113 real(RP),
intent(inout) :: C(KMAX-1)
1114 real(RP),
intent(in) :: F1(KA)
1115 real(RP),
intent(in) :: F2(KA)
1116 real(RP),
intent(in) :: F3(KA)
1118 real(RP) :: e(KMAX-2)
1119 real(RP) :: f(KMAX-2)
1125 rdenom = 1.0_rp / f2(
ks)
1126 e(1) = - f1(
ks) * rdenom
1127 f(1) = c(1) * rdenom
1129 rdenom = 1.0_rp / ( f2(k+
ks-1) + f3(k+
ks-1) * e(k-1) )
1130 e(k) = - f1(k+
ks-1) * rdenom
1131 f(k) = ( c(k) - f3(k+
ks-1) * f(k-1) ) * rdenom
1135 c(kmax-1) = ( c(kmax-1) - f3(
ke-1) * f(kmax-2) ) &
1136 / ( f2(
ke-1) + f3(
ke-1) * e(kmax-2) )
1137 do k = kmax-2, 1, -1
1138 c(k) = e(k) * c(k+1) + f(k)
1145 subroutine check_equation( &
1147 DENS, MOMZ, RHOT, DPRES, &
1165 real(RP),
intent(in) :: VECT(KMAX-1)
1166 real(RP),
intent(in) :: DENS(KA)
1167 real(RP),
intent(in) :: MOMZ(KA)
1168 real(RP),
intent(in) :: RHOT(KA)
1169 real(RP),
intent(in) :: DPRES(KA)
1170 real(RP),
intent(in) :: REF_dens(KA)
1171 real(RP),
intent(in) :: Sr(KA)
1172 real(RP),
intent(in) :: Sw(KA)
1173 real(RP),
intent(in) :: St(KA)
1174 real(RP),
intent(in) :: J33G
1175 real(RP),
intent(in) :: G(KA,8)
1176 real(RP),
intent(in) :: RT2P(KA)
1177 real(RP),
intent(in) :: dt
1178 integer ,
intent(in) :: i
1179 integer ,
intent(in) :: j
1181 real(RP),
parameter :: small = 1e-6_rp
1183 real(RP) :: MOMZ_N(KA)
1184 real(RP) :: DENS_N(KA)
1185 real(RP) :: RHOT_N(KA)
1186 real(RP) :: DPRES_N(KA)
1188 real(RP) :: POTT(KA)
1191 real(RP) :: error, lhs, rhs
1196 momz_n(k) = vect(k-
ks+1)
1198 momz_n(:
ks-1) = 0.0_rp
1199 momz_n(
ke:) = 0.0_rp
1203 dens_n(k) = dens(k) &
1204 + dt * ( - j33g * ( momz_n(k) - momz_n(k-1) ) * rcdz(k) / g(k,
i_xyz) + sr(k) )
1206 dens_n(
ks) = dens(
ks) &
1207 + dt * ( - j33g * momz_n(
ks) * rcdz(
ks) / g(
ks,
i_xyz) + sr(
ks) )
1208 dens_n(
ke) = dens(
ke) &
1209 + dt * ( j33g * momz_n(
ke-1) * rcdz(
ke) / g(
ke,
i_xyz) + sr(
ke) )
1213 pott(k) = rhot(k) / dens(k)
1216 pt(k) = ( 7.0_rp * ( pott(k+1) + pott(k ) ) &
1217 - ( pott(k+2) + pott(k-1) ) ) / 12.0_rp
1220 pt(
ks ) = ( pott(
ks+1) + pott(
ks ) ) * 0.5_rp
1221 pt(
ke-1) = ( pott(
ke ) + pott(
ke-1) ) * 0.5_rp
1224 rhot_n(k) = rhot(k) &
1225 + dt * ( - j33g * ( momz_n(k)*pt(k) - momz_n(k-1)*pt(k-1) ) * rcdz(k) / g(k,
i_xyz) &
1228 rhot_n(
ks) = rhot(
ks) &
1229 + dt * ( - j33g * momz_n(
ks)*pt(
ks) * rcdz(
ks) / g(
ks,
i_xyz) + st(
ks) )
1230 rhot_n(
ke) = rhot(
ke) &
1231 + dt * ( j33g * momz_n(
ke-1)*pt(
ke-1) * rcdz(
ke) / g(
ke-1,
i_xyz) + st(
ke) )
1235 dpres_n(k) = dpres(k) + rt2p(k) * ( rhot_n(k) - rhot(k) )
1239 lhs = ( dens_n(k) - dens(k) ) / dt
1240 rhs = - j33g * ( momz_n(k) - momz_n(k-1) ) * rcdz(k) / g(k,
i_xyz) + sr(k)
1241 if ( abs(lhs) < small )
then 1244 error = ( lhs - rhs ) / lhs
1246 if ( abs(error) > small )
then 1247 write(*,*)
"HEVI: DENS error", k, i, j, error, lhs, rhs
1254 lhs = ( momz_n(k) - momz(k) ) / dt
1255 rhs = - j33g * ( dpres_n(k+1) - dpres_n(k) ) * rfdz(k) / g(k,
i_xyw) &
1256 - grav * ( dens_n(k+1) - ref_dens(k+1) + dens_n(k) - ref_dens(k) ) * 0.5_rp &
1258 if ( abs(lhs) < small )
then 1261 error = ( lhs - rhs ) / lhs
1263 if ( abs(error) > small )
then 1264 write(*,*)
"HEVI: MOMZ error", k, i, j, error, lhs, rhs
1265 write(*,*) momz_n(k), momz(k), dt
1266 write(*,*) - j33g * ( dpres(k+1) - dpres(k) ) * rfdz(k) / g(k,
i_xyw) &
1267 - grav * ( dens(k+1) -ref_dens(k+1) + dens(k) -ref_dens(k) ) * 0.5_rp &
1274 lhs = ( rhot_n(k) - rhot(k) ) / dt
1275 rhs = - j33g * ( momz_n(k)*pt(k) - momz_n(k-1)*pt(k-1) ) * rcdz(k) / g(k,
i_xyz) + st(k)
1276 if ( abs(lhs) < small )
then 1279 error = ( lhs - rhs ) / lhs
1281 if ( abs(error) > small )
then 1282 write(*,*)
"HEVI: RHOT error", k, i, j, error, lhs, rhs
1288 end subroutine check_equation
integer, parameter, public i_rhot
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
subroutine, public prc_mpistop
Abort MPI.
subroutine, public atmos_dyn_tstep_short_fvm_hevi_regist(ATMOS_DYN_TYPE, VA_out, VAR_NAME, VAR_DESC, VAR_UNIT)
Register.
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxx_xvz
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj23_uyz
integer, public iblock
block size for cache blocking: x
integer, parameter, public i_momx
logical, public io_l
output log or not? (this process)
integer, parameter, public zdir
integer, parameter, public i_momz
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj23_xyw
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxx_xyz
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj13_xyw
integer, parameter, public xdir
subroutine, public check(current_line, v)
Undefined value checker.
real(rp), dimension(:), allocatable, public grid_rcdz
reciprocal of center-dz
module Atmosphere / Dynamics RK
integer, parameter, public i_dens
integer, parameter, public i_momy
real(rp), public const_undef
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxx_xyw
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxy_xyw
integer, public ia
of whole cells: x, local, with HALO
procedure(flux_z), pointer, public atmos_dyn_fvm_fluxz_xvz
integer, public ka
of whole cells: z, local, with HALO
integer, public jblock
block size for cache blocking: y
integer, public kmax
of computational cells: z, local
subroutine, public atmos_dyn_tstep_short_fvm_hevi_setup
Setup.
integer, public jhalo
of halo cells: y
real(rp), public const_grav
standard acceleration of gravity [m/s2]
integer, public js
start point of inner domain: y, local
integer, parameter, public const_undef2
undefined value (INT2)
module Atmosphere / Dynamics common
procedure(valuew), pointer, public atmos_dyn_fvm_flux_valuew_z
integer, public ks
start point of inner domain: z, local
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj13_xvz
integer, public jeh
end point of inner domain: y, local (half level)
integer, public ieh
end point of inner domain: x, local (half level)
subroutine solve_direct(C, F1, F2, F3)
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
procedure(flux_z), pointer, public atmos_dyn_fvm_fluxz_uyz
subroutine, public atmos_dyn_tstep_short_fvm_hevi(DENS_RK, MOMZ_RK, MOMX_RK, MOMY_RK, RHOT_RK, PROG_RK, mflx_hi, tflx_hi, DENS0, MOMZ0, MOMX0, MOMY0, RHOT0, DENS, MOMZ, MOMX, MOMY, RHOT, DENS_t, MOMZ_t, MOMX_t, MOMY_t, RHOT_t, PROG0, PROG, DPRES0, RT2P, CORIOLI, num_diff, wdamp_coef, divdmp_coef, DDIV, FLAG_FCT_MOMENTUM, FLAG_FCT_T, FLAG_FCT_ALONG_STREAM, CDZ, FDZ, FDX, FDY, RCDZ, RCDX, RCDY, RFDZ, RFDX, RFDY, PHI, GSQRT, J13G, J23G, J33G, MAPF, REF_dens, REF_rhot, BND_W, BND_E, BND_S, BND_N, dtrk, last)
module scale_atmos_dyn_fvm_flux
subroutine, public atmos_dyn_fct(qflx_anti, phi_in, DENS0, DENS, qflx_hi, qflx_lo, mflx_hi, rdz, rdx, rdy, GSQRT, MAPF, dt, flag_vect)
Flux Correction Transport Limiter.
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj13_uyz
procedure(flux_j), pointer, public atmos_dyn_fvm_fluxj23_xvz
real(rp), dimension(:), allocatable, public grid_rfdz
reciprocal of face-dz
integer, public io_fid_log
Log file ID.
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxz_xyz
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxx_uyz
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxy_xyz
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxy_uyz
procedure(flux_wz), pointer, public atmos_dyn_fvm_fluxz_xyw
integer, public ihalo
of halo cells: x
procedure(flux_mom), pointer, public atmos_dyn_fvm_fluxy_xvz
integer, public ja
of whole cells: y, local, with HALO