32 #if defined DEBUG || defined QUICKDEBUG
62 real(RP),
private,
parameter :: OneOverThree = 1.0_rp / 3.0_rp
63 real(RP),
private,
parameter :: twoOverThree = 2.0_rp / 3.0_rp
64 real(RP),
private,
parameter :: FourOverThree = 4.0_rp / 3.0_rp
66 real(RP),
private :: Cs = 0.13_rp
67 real(RP),
private,
parameter :: PrN = 0.7_rp
68 real(RP),
private,
parameter :: RiC = 0.25_rp
69 real(RP),
private,
parameter :: FmC = 16.0_rp
70 real(RP),
private,
parameter :: FhB = 40.0_rp
71 real(RP),
private :: RPrN
72 real(RP),
private :: RRiC
73 real(RP),
private :: PrNovRiC
76 real(RP),
private,
parameter :: CB = 1.4_rp
77 real(RP),
private,
parameter :: CBt = 0.45_rp
78 real(RP),
private,
parameter :: aN = 0.47958315233127197_rp
79 real(RP),
private,
parameter :: atN4 = 0.09_rp
80 real(RP),
private,
parameter :: C1o = an**3
81 real(RP),
private,
parameter :: D1o = prn * atn4 / an
83 real(RP),
private,
allocatable :: lambda0(:,:,:)
84 real(RP),
private,
allocatable :: lambda (:,:,:)
86 real(RP),
private :: ATMOS_PHY_TB_SMG_NU_MAX = 10000.0_rp
87 logical,
private :: ATMOS_PHY_TB_SMG_backscatter = .false.
88 logical,
private :: ATMOS_PHY_TB_SMG_bottom = .true.
89 logical,
private :: ATMOS_PHY_TB_SMG_implicit = .false.
90 logical,
private :: ATMOS_PHY_TB_SMG_horizontal = .false.
92 real(RP),
private :: tke_fact
100 FZ, CZ, CDX, CDY, MAPF, &
108 real(rp),
intent(in) :: fz (0:
ka,
ia,
ja)
109 real(rp),
intent(in) :: cz (
ka,
ia,
ja)
110 real(rp),
intent(in) :: cdx (
ia)
111 real(rp),
intent(in) :: cdy (
ja)
112 real(rp),
intent(in) :: mapf(
ia,
ja,2)
114 logical,
intent(in),
optional :: horizontal
116 real(rp) :: atmos_phy_tb_smg_cs
117 real(rp) :: atmos_phy_tb_smg_filter_fact
118 logical :: atmos_phy_tb_smg_consistent_tke
120 namelist / param_atmos_phy_tb_smg / &
121 atmos_phy_tb_smg_cs, &
122 atmos_phy_tb_smg_nu_max, &
123 atmos_phy_tb_smg_filter_fact, &
124 atmos_phy_tb_smg_bottom, &
125 atmos_phy_tb_smg_backscatter, &
126 atmos_phy_tb_smg_implicit, &
127 atmos_phy_tb_smg_consistent_tke, &
128 atmos_phy_tb_smg_horizontal
137 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Setup'
138 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Smagorinsky-type Eddy Viscocity Model'
140 atmos_phy_tb_smg_cs = cs
141 atmos_phy_tb_smg_filter_fact = 2.0_rp
142 atmos_phy_tb_smg_consistent_tke = .true.
144 if (
present(horizontal) ) atmos_phy_tb_smg_horizontal = horizontal
147 read(
io_fid_conf,nml=param_atmos_phy_tb_smg,iostat=ierr)
149 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Not found namelist. Default used.'
150 elseif( ierr > 0 )
then
151 log_error(
"ATMOS_PHY_TB_smg_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_TB_SMG. Check!'
154 log_nml(param_atmos_phy_tb_smg)
156 cs = atmos_phy_tb_smg_cs
160 prnovric = ( 1.0_rp - prn ) * rric
162 allocate( lambda0(
ka,
ia,
ja) )
163 allocate( lambda(
ka,
ia,
ja) )
167 lambda0(:,:,:) = undef
168 lambda(:,:,:) = undef
170 if ( atmos_phy_tb_smg_horizontal )
then
176 lambda0(
k,i,j) = cs * sqrt( cdx(i) * cdy(j) / ( mapf(i,j,1) * mapf(i,j,2) ) )
177 lambda(
k,i,j) = lambda0(
k,i,j)
184 i = iundef; j = iundef;
k = iundef
186 atmos_phy_tb_smg_consistent_tke = .false.
187 atmos_phy_tb_smg_implicit = .false.
188 atmos_phy_tb_smg_backscatter = .false.
195 lambda0(
k,i,j) = cs *
mixlen( fz(
k,i,j) - fz(
k-1,i,j), &
196 cdx(i) / mapf(i,j,1), &
197 cdy(j) / mapf(i,j,2), &
198 atmos_phy_tb_smg_filter_fact )
204 i = iundef; j = iundef;
k = iundef
206 if ( atmos_phy_tb_smg_bottom )
then
212 lambda(
k,i,j) = sqrt( 1.0_rp / ( 1.0_rp / lambda0(
k,i,j)**2 + 1.0_rp / ( karman*(cz(
k,i,j)-fz(
ks-1,i,j)) )**2 ) )
218 i = iundef; j = iundef;
k = iundef
226 lambda(
k,i,j) = lambda0(
k,i,j)
232 i = iundef; j = iundef;
k = iundef
238 if ( atmos_phy_tb_smg_consistent_tke )
then
254 deallocate( lambda0 )
262 qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, &
263 qflx_sgs_rhot, qflx_sgs_rhoq, &
264 MOMZ_t, MOMX_t, MOMY_t, RHOT_t, RHOQ_t, &
266 MOMZ, MOMX, MOMY, POTT, DENS, QTRC, N2, &
267 FZ, FDZ, RCDZ, RFDZ, CDX, FDX, CDY, FDY, &
268 GSQRT, J13G, J23G, J33G, MAPF, dt )
288 matrix_solver_tridiagonal
292 real(rp),
intent(out) :: qflx_sgs_momz(
ka,
ia,
ja,3)
293 real(rp),
intent(out) :: qflx_sgs_momx(
ka,
ia,
ja,3)
294 real(rp),
intent(out) :: qflx_sgs_momy(
ka,
ia,
ja,3)
295 real(rp),
intent(out) :: qflx_sgs_rhot(
ka,
ia,
ja,3)
296 real(rp),
intent(out) :: qflx_sgs_rhoq(
ka,
ia,
ja,3,
qa)
298 real(rp),
intent(out) :: momz_t (
ka,
ia,
ja)
299 real(rp),
intent(out) :: momx_t (
ka,
ia,
ja)
300 real(rp),
intent(out) :: momy_t (
ka,
ia,
ja)
301 real(rp),
intent(out) :: rhot_t (
ka,
ia,
ja)
302 real(rp),
intent(out) :: rhoq_t (
ka,
ia,
ja,
qa)
304 real(rp),
intent(out) :: nu (
ka,
ia,
ja)
305 real(rp),
intent(out) :: ri (
ka,
ia,
ja)
306 real(rp),
intent(out) :: pr (
ka,
ia,
ja)
308 real(rp),
intent(in) :: momz (
ka,
ia,
ja)
309 real(rp),
intent(in) :: momx (
ka,
ia,
ja)
310 real(rp),
intent(in) :: momy (
ka,
ia,
ja)
311 real(rp),
intent(in) :: pott (
ka,
ia,
ja)
312 real(rp),
intent(in) :: dens (
ka,
ia,
ja)
313 real(rp),
intent(in) :: qtrc (
ka,
ia,
ja,
qa)
314 real(rp),
intent(in) :: n2 (
ka,
ia,
ja)
316 real(rp),
intent(in) :: fz (0:
ka,
ia,
ja)
317 real(rp),
intent(in) :: fdz (
ka-1)
318 real(rp),
intent(in) :: rcdz (
ka)
319 real(rp),
intent(in) :: rfdz (
ka-1)
320 real(rp),
intent(in) :: cdx (
ia)
321 real(rp),
intent(in) :: fdx (
ia-1)
322 real(rp),
intent(in) :: cdy (
ja)
323 real(rp),
intent(in) :: fdy (
ja-1)
325 real(rp),
intent(in) :: gsqrt (
ka,
ia,
ja,7)
326 real(rp),
intent(in) :: j13g (
ka,
ia,
ja,7)
327 real(rp),
intent(in) :: j23g (
ka,
ia,
ja,7)
328 real(rp),
intent(in) :: j33g
329 real(rp),
intent(in) :: mapf(
ia,
ja,2,4)
330 real(
dp),
intent(in) :: dt
336 real(rp) :: s33_c(
ka,
ia,
ja)
337 real(rp) :: s11_c(
ka,
ia,
ja)
338 real(rp) :: s22_c(
ka,
ia,
ja)
339 real(rp) :: s31_c(
ka,
ia,
ja)
340 real(rp) :: s12_c(
ka,
ia,
ja)
341 real(rp) :: s23_c(
ka,
ia,
ja)
342 real(rp) :: s12_z(
ka,
ia,
ja)
343 real(rp) :: s23_x(
ka,
ia,
ja)
344 real(rp) :: s31_y(
ka,
ia,
ja)
351 real(rp) :: lambda_r(
ka)
358 real(rp) :: tend(
ka,
ia,
ja)
359 real(rp) :: tend2(
ka,
ia,
ja)
366 real(rp) :: random (
ka,
ia,
ja)
367 real(rp) :: random_mz(
ka,
ia,
ja)
368 real(rp) :: random_mx(
ka,
ia,
ja)
369 real(rp) :: random_my(
ka,
ia,
ja)
370 real(rp) :: random_qz(
ka,
ia,
ja)
371 real(rp) :: random_qx(
ka,
ia,
ja)
372 real(rp) :: random_qy(
ka,
ia,
ja)
375 real(rp) :: dz, dx, dy
382 integer ::
k, i, j, iq
396 log_progress(*)
'atmosphere / physics / turbulence / Smagorinsky'
400 qflx_sgs_momz(:,:,:,:) = undef
401 qflx_sgs_momx(:,:,:,:) = undef
402 qflx_sgs_momy(:,:,:,:) = undef
403 qflx_sgs_rhot(:,:,:,:) = undef
404 qflx_sgs_rhoq(:,:,:,:,:) = undef
416 qflx_sgs_momz(
ks:
ke, 1:
is-1, : ,:) = undef
417 qflx_sgs_momz(
ks:
ke,
ie+1:
ia , : ,:) = undef
418 qflx_sgs_momz(
ks:
ke, : , 1:
js-1,:) = undef
419 qflx_sgs_momz(
ks:
ke, : ,
je+1:
ja ,:) = undef
420 qflx_sgs_momx(
ks:
ke, 1:
is-1, : ,:) = undef
421 qflx_sgs_momx(
ks:
ke,
ie+1:
ia , : ,:) = undef
422 qflx_sgs_momx(
ks:
ke, : , 1:
js-1,:) = undef
423 qflx_sgs_momx(
ks:
ke, : ,
je+1:
ja ,:) = undef
424 qflx_sgs_momy(
ks:
ke, 1:
is-1, : ,:) = undef
425 qflx_sgs_momy(
ks:
ke,
ie+1:
ia , : ,:) = undef
426 qflx_sgs_momy(
ks:
ke, : , 1:
js-1,:) = undef
427 qflx_sgs_momy(
ks:
ke, : ,
je+1:
ja ,:) = undef
434 call calc_strain_tensor( &
435 s33_c, s11_c, s22_c, &
436 s31_c, s12_c, s23_c, &
437 s12_z, s23_x, s31_y, &
439 dens, momz, momx, momy, &
440 gsqrt, j13g, j23g, j33g, mapf )
442 if ( atmos_phy_tb_smg_backscatter )
then
443 call random_normal( random(:,:,:) )
450 random_mz(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
451 + random(
k+1,i,j) + random(
k-1,i,j) &
452 + random(
k,i+1,j) + random(
k,i-1,j) &
453 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
455 random_mz(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
457 + random(
ks,i+1,j) + random(
ks,i-1,j) &
458 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
459 random_mz(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
461 + random(
ke,i+1,j) + random(
ke,i-1,j) &
462 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
467 call random_normal( random(:,:,:) )
474 random_mx(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
475 + random(
k+1,i,j) + random(
k-1,i,j) &
476 + random(
k,i+1,j) + random(
k,i-1,j) &
477 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
479 random_mx(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
481 + random(
ks,i+1,j) + random(
ks,i-1,j) &
482 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
483 random_mx(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
485 + random(
ke,i+1,j) + random(
ke,i-1,j) &
486 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
491 call random_normal( random(:,:,:) )
498 random_my(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
499 + random(
k+1,i,j) + random(
k-1,i,j) &
500 + random(
k,i+1,j) + random(
k,i-1,j) &
501 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
503 random_my(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
505 + random(
ks,i+1,j) + random(
ks,i-1,j) &
506 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
507 random_my(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
509 + random(
ke,i+1,j) + random(
ke,i-1,j) &
510 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
515 call random_normal( random(:,:,:) )
522 random_qz(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
523 + random(
k+1,i,j) + random(
k-1,i,j) &
524 + random(
k,i+1,j) + random(
k,i-1,j) &
525 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
527 random_qz(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
529 + random(
ks,i+1,j) + random(
ks,i-1,j) &
530 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
531 random_qz(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
533 + random(
ke,i+1,j) + random(
ke,i-1,j) &
534 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
539 call random_normal( random(:,:,:) )
546 random_qx(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
547 + random(
k+1,i,j) + random(
k-1,i,j) &
548 + random(
k,i+1,j) + random(
k,i-1,j) &
549 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
551 random_qx(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
553 + random(
ks,i+1,j) + random(
ks,i-1,j) &
554 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
555 random_qx(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
557 + random(
ke,i+1,j) + random(
ke,i-1,j) &
558 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
563 call random_normal( random(:,:,:) )
570 random_qy(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
571 + random(
k+1,i,j) + random(
k-1,i,j) &
572 + random(
k,i+1,j) + random(
k,i-1,j) &
573 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
575 random_qy(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
577 + random(
ks,i+1,j) + random(
ks,i-1,j) &
578 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
579 random_qy(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
581 + random(
ke,i+1,j) + random(
ke,i-1,j) &
582 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
598 ri(
k,i,j) = n2(
k,i,j) / max(s2(
k,i,j), eps)
604 if ( ri(
k,i,j) < 0.0_rp )
then
605 fm(
k) = sqrt( 1.0_rp - fmc * ri(
k,i,j) )
606 nu(
k,i,j) = lambda(
k,i,j)**2 * sqrt( s2(
k,i,j) ) * fm(
k)
607 pr(
k,i,j) = fm(
k) / sqrt( 1.0_rp - fhb*ri(
k,i,j) ) * prn
608 else if ( ri(
k,i,j) < ric )
then
609 fm(
k) = ( 1.0_rp - ri(
k,i,j)*rric )**4
610 nu(
k,i,j) = lambda(
k,i,j)**2 * sqrt( s2(
k,i,j) ) * fm(
k)
611 pr(
k,i,j) = prn / ( 1.0_rp - prnovric * ri(
k,i,j) )
619 if ( ri(
k,i,j) < ric )
then
620 kh(
k,i,j) = max( min( nu(
k,i,j) / pr(
k,i,j), atmos_phy_tb_smg_nu_max ), eps )
621 nu(
k,i,j) = max( min( nu(
k,i,j), atmos_phy_tb_smg_nu_max ), eps )
622 pr(
k,i,j) = nu(
k,i,j) / kh(
k,i,j)
623 rf = ri(
k,i,j) / pr(
k,i,j)
624 lambda_r(
k) = lambda(
k,i,j) * sqrt( fm(
k) / sqrt( 1.0_rp - rf ) )
632 if ( atmos_phy_tb_smg_backscatter )
then
634 lambda_r(
k) = min( 1.8_rp * lambda0(
k,i,j), lambda_r(
k) )
635 leovleo5 = ( lambda_r(
k) / lambda0(
k,i,j) )**5
636 c2 = cb * leovleo5 / ( 1.0_rp + cb * leovleo5 )
637 d2 = cbt * leovleo5 / ( 1.0_rp + cbt * leovleo5 )
638 c1(
k) = c1o / sqrt( 1.0_rp - c2 )
640 e(
k) = nu(
k,i,j)**3 * ( 1.0_rp - c2 ) / ( lambda_r(
k)**4 + eps )
641 et = kh(
k,i,j) * ( 1.0_rp - d2 )
643 dz = fz(
k,i,j) - fz(
k-1,i,j)
644 dx = cdx(i) / mapf(i,j,1,
i_xy)
645 dy = cdy(j) / mapf(i,j,2,
i_xy)
647 fact = sqrt( cb * leovleo5 * e(
k) / ( 3.0_rp * dt ) ) * dens(
k,i,j)
648 random_mz(
k,i,j) = random_mz(
k,i,j) * fact * dx * dy / sqrt( dx**2 + dy**2 )
649 random_mx(
k,i,j) = random_mx(
k,i,j) * fact * dy * dz / sqrt( dy**2 + dz**2 )
650 random_my(
k,i,j) = random_my(
k,i,j) * fact * dz * dx / sqrt( dz**2 + dx**2 )
652 fact = sqrt( cbt * leovleo5 * et / ( 3.0_rp * dt ) ) * dens(
k,i,j)
653 random_qz(
k,i,j) = random_qz(
k,i,j) * fact * dz
654 random_qx(
k,i,j) = random_qx(
k,i,j) * fact * dx
655 random_qy(
k,i,j) = random_qy(
k,i,j) * fact * dy
661 e(
k) = nu(
k,i,j)**3 / ( lambda_r(
k)**4 + eps )
669 tke(
k,i,j) = ( e(
k) * lambda_r(
k) / c1(
k) )**twooverthree
676 i = iundef; j = iundef;
k = iundef
688 if ( atmos_phy_tb_smg_horizontal )
then
691 qflx_sgs_momz(:,:,:,
zdir) = 0.0_rp
701 call check( __line__, dens(
k,i,j) )
702 call check( __line__, nu(
k,i,j) )
703 call check( __line__, s33_c(
k,i,j) )
704 call check( __line__, s11_c(
k,i,j) )
705 call check( __line__, s22_c(
k,i,j) )
706 call check( __line__, tke(
k,i,j) )
708 qflx_sgs_momz(
k,i,j,
zdir) = dens(
k,i,j) * ( &
709 - 2.0_rp * nu(
k,i,j) &
710 * ( s33_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
711 + twooverthree * tke(
k,i,j) * tke_fact )
717 i = iundef; j = iundef;
k = iundef
724 qflx_sgs_momz(
ks,i,j,
zdir) = dens(
ks,i,j) * twooverthree * tke(
ks,i,j) * tke_fact
725 qflx_sgs_momz(
ke,i,j,
zdir) = dens(
ke,i,j) * twooverthree * tke(
ke,i,j) * tke_fact
732 i = iundef; j = iundef;
k = iundef
742 call check( __line__, dens(
k,i,j) )
743 call check( __line__, dens(
k,i+1,j) )
744 call check( __line__, dens(
k+1,i,j) )
745 call check( __line__, dens(
k+1,i+1,j) )
746 call check( __line__, nu(
k,i,j) )
747 call check( __line__, nu(
k,i+1,j) )
748 call check( __line__, nu(
k+1,i,j) )
749 call check( __line__, nu(
k+1,i+1,j) )
750 call check( __line__, s31_y(
k,i,j) )
752 qflx_sgs_momz(
k,i,j,
xdir) = - 0.125_rp &
753 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i+1,j)+dens(
k+1,i+1,j) ) &
754 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i+1,j)+nu(
k+1,i+1,j)) &
762 i = iundef; j = iundef;
k = iundef
771 call check( __line__, dens(
k,i,j) )
772 call check( __line__, dens(
k,i,j+1) )
773 call check( __line__, dens(
k+1,i,j) )
774 call check( __line__, dens(
k+1,i,j+1) )
775 call check( __line__, nu(
k,i,j) )
776 call check( __line__, nu(
k,i,j+1) )
777 call check( __line__, nu(
k+1,i,j) )
778 call check( __line__, nu(
k+1,i,j+1) )
779 call check( __line__, s23_x(
k,i,j) )
781 qflx_sgs_momz(
k,i,j,
ydir) = - 0.125_rp &
782 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i,j+1)+dens(
k+1,i,j+1) ) &
783 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i,j+1)+nu(
k+1,i,j+1) ) &
791 i = iundef; j = iundef;
k = iundef
796 if ( atmos_phy_tb_smg_implicit )
then
798 call calc_tend_momz( tend, &
800 gsqrt, j13g, j23g, j33g, mapf, &
808 ap = - fouroverthree * dt &
809 * dens(
ks+1,i,j)*nu(
ks+1,i,j) &
813 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks+1,i,j) )
816 ap = - fouroverthree * dt &
817 * dens(
k,i,j)*nu(
k,i,j) &
820 c(
k,i,j) = ap * rfdz(
k+1) / gsqrt(
k+1,i,j,
i_xyw)
821 ap = - fouroverthree * dt &
822 * dens(
k+1,i,j)*nu(
k+1,i,j) &
823 * rcdz(
k+1) / gsqrt(
k+1,i,j,
i_xyz)
824 a(
k,i,j) = ap * rfdz(
k) / gsqrt(
k,i,j,
i_xyw)
825 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k+1,i,j) )
828 ap = - fouroverthree * dt &
829 * dens(
ke-1,i,j)*nu(
ke-1,i,j) &
834 b(
ke-1,i,j) = - c(
ke-1,i,j) + 0.5_rp * ( dens(
ke-1,i,j)+dens(
ke,i,j) )
839 call matrix_solver_tridiagonal(
ka,
ks,
ke-1,
ia, iis, iie,
ja, jjs, jje, &
840 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
848 qflx_sgs_momz(
k,i,j,
zdir) = qflx_sgs_momz(
k,i,j,
zdir) &
849 - fouroverthree * dens(
k,i,j) * nu(
k,i,j) * dt &
850 * ( tend2(
k,i,j) - tend2(
k-1,i,j) ) * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
863 if ( atmos_phy_tb_smg_horizontal )
then
866 qflx_sgs_momx(:,:,:,
zdir) = 0.0_rp
876 call check( __line__, dens(
k,i,j) )
877 call check( __line__, dens(
k,i+1,j) )
878 call check( __line__, dens(
k+1,i,j) )
879 call check( __line__, dens(
k+1,i+1,j) )
880 call check( __line__, nu(
k,i,j) )
881 call check( __line__, nu(
k,i+1,j) )
882 call check( __line__, nu(
k+1,i,j) )
883 call check( __line__, nu(
k+1,i+1,j) )
884 call check( __line__, s31_y(
k,i,j) )
886 qflx_sgs_momx(
k,i,j,
zdir) = - 0.125_rp &
887 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i+1,j)+dens(
k+1,i+1,j) ) &
888 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i+1,j)+nu(
k+1,i+1,j) ) &
896 i = iundef; j = iundef;
k = iundef
902 qflx_sgs_momx(
ks-1,i,j,
zdir) = 0.0_rp
903 qflx_sgs_momx(
ke ,i,j,
zdir) = 0.0_rp
909 i = iundef; j = iundef;
k = iundef
920 call check( __line__, dens(
k,i,j) )
921 call check( __line__, nu(
k,i,j) )
922 call check( __line__, s11_c(
k,i,j) )
923 call check( __line__, s22_c(
k,i,j) )
924 call check( __line__, s33_c(
k,i,j) )
925 call check( __line__, tke(
k,i,j) )
927 qflx_sgs_momx(
k,i,j,
xdir) = dens(
k,i,j) * ( &
928 - 2.0_rp * nu(
k,i,j) &
929 * ( s11_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
930 + twooverthree * tke(
k,i,j) * tke_fact )
937 i = iundef; j = iundef;
k = iundef
947 call check( __line__, dens(
k,i,j) )
948 call check( __line__, dens(
k,i+1,j) )
949 call check( __line__, dens(
k,i,j+1) )
950 call check( __line__, dens(
k,i+1,j+1) )
951 call check( __line__, nu(
k,i,j) )
952 call check( __line__, nu(
k,i+1,j) )
953 call check( __line__, nu(
k,i,j+1) )
954 call check( __line__, nu(
k,i+1,j+1) )
955 call check( __line__, s12_z(
k,i,j) )
957 qflx_sgs_momx(
k,i,j,
ydir) = - 0.125_rp &
958 * ( dens(
k,i,j)+dens(
k,i+1,j)+dens(
k,i,j+1)+dens(
k,i+1,j+1) ) &
959 * ( nu(
k,i,j)+nu(
k,i+1,j)+nu(
k,i,j+1)+nu(
k,i+1,j+1) ) &
967 i = iundef; j = iundef;
k = iundef
972 if ( atmos_phy_tb_smg_implicit )
then
973 call calc_tend_momx( tend, &
975 gsqrt, j13g, j23g, j33g, mapf, &
984 ap = - dt * 0.25_rp * ( dens(
ks ,i ,j)*nu(
ks ,i ,j) &
985 + dens(
ks+1,i ,j)*nu(
ks+1,i ,j) &
986 + dens(
ks ,i+1,j)*nu(
ks ,i+1,j) &
987 + dens(
ks+1,i+1,j)*nu(
ks+1,i+1,j) ) &
991 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks,i+1,j) )
994 ap = - dt * 0.25_rp * ( dens(
k-1,i ,j)*nu(
k-1,i ,j) &
995 + dens(
k ,i ,j)*nu(
k ,i ,j) &
996 + dens(
k-1,i+1,j)*nu(
k-1,i+1,j) &
997 + dens(
k ,i+1,j)*nu(
k ,i+1,j) ) &
998 * rfdz(
k-1) / gsqrt(
k-1,i,j,
i_uyw)
1000 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_uyz)
1001 ap = - dt * 0.25_rp * ( dens(
k ,i ,j)*nu(
k ,i ,j) &
1002 + dens(
k+1,i ,j)*nu(
k+1,i ,j) &
1003 + dens(
k ,i+1,j)*nu(
k ,i+1,j) &
1004 + dens(
k+1,i+1,j)*nu(
k+1,i+1,j) ) &
1005 * rfdz(
k) / gsqrt(
k,i,j,
i_uyw)
1006 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_uyz)
1007 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k,i+1,j) )
1010 ap = - dt * 0.25_rp * ( dens(
ke-1,i ,j)*nu(
ke-1,i ,j) &
1011 + dens(
ke ,i ,j)*nu(
ke ,i ,j) &
1012 + dens(
ke-1,i+1,j)*nu(
ke-1,i+1,j) &
1013 + dens(
ke ,i+1,j)*nu(
ke ,i+1,j) ) &
1018 b(
ke,i,j) = - c(
ke,i,j) + 0.5_rp * ( dens(
ke,i,j)+dens(
ke,i+1,j) )
1023 call matrix_solver_tridiagonal(
ka,
ks,
ke,
ia, iis, iie,
ja, jjs, jje, &
1024 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
1032 qflx_sgs_momx(
k,i,j,
zdir) = qflx_sgs_momx(
k,i,j,
zdir) &
1033 - 0.25_rp * ( dens(
k ,i ,j)*nu(
k ,i ,j) &
1034 + dens(
k+1,i ,j)*nu(
k+1,i ,j) &
1035 + dens(
k ,i+1,j)*nu(
k ,i+1,j) &
1036 + dens(
k+1,i+1,j)*nu(
k+1,i+1,j) ) &
1037 * dt * ( tend2(
k+1,i,j) - tend2(
k,i,j) ) * rfdz(
k) / gsqrt(
k,i,j,
i_uyw)
1050 if ( atmos_phy_tb_smg_horizontal )
then
1053 qflx_sgs_momy(:,:,:,
zdir) = 0.0_rp
1063 call check( __line__, dens(
k,i,j) )
1064 call check( __line__, dens(
k,i,j+1) )
1065 call check( __line__, dens(
k+1,i,j) )
1066 call check( __line__, dens(
k+1,i,j+1) )
1067 call check( __line__, nu(
k,i,j) )
1068 call check( __line__, nu(
k,i,j+1) )
1069 call check( __line__, nu(
k+1,i,j) )
1070 call check( __line__, nu(
k+1,i,j+1) )
1071 call check( __line__, s23_x(
k,i,j) )
1073 qflx_sgs_momy(
k,i,j,
zdir) = - 0.125_rp &
1074 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i,j+1)+dens(
k+1,i,j+1) ) &
1075 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i,j+1)+nu(
k+1,i,j+1) ) &
1083 i = iundef; j = iundef;
k = iundef
1089 qflx_sgs_momy(
ks-1,i,j,
zdir) = 0.0_rp
1090 qflx_sgs_momy(
ke ,i,j,
zdir) = 0.0_rp
1096 i = iundef; j = iundef;
k = iundef
1107 call check( __line__, dens(
k,i,j) )
1108 call check( __line__, dens(
k,i+1,j) )
1109 call check( __line__, dens(
k,i,j+1) )
1110 call check( __line__, dens(
k,i+1,j+1) )
1111 call check( __line__, nu(
k,i,j) )
1112 call check( __line__, nu(
k,i+1,j) )
1113 call check( __line__, nu(
k,i,j+1) )
1114 call check( __line__, nu(
k,i+1,j+1) )
1115 call check( __line__, s12_z(
k,i,j) )
1117 qflx_sgs_momy(
k,i,j,
xdir) = - 0.125_rp &
1118 * ( dens(
k,i,j)+dens(
k,i+1,j)+dens(
k,i,j+1)+dens(
k,i+1,j+1) ) &
1119 * ( nu(
k,i,j)+nu(
k,i+1,j)+nu(
k,i,j+1)+nu(
k,i+1,j+1) ) &
1127 i = iundef; j = iundef;
k = iundef
1137 call check( __line__, dens(
k,i,j) )
1138 call check( __line__, nu(
k,i,j) )
1139 call check( __line__, s11_c(
k,i,j) )
1140 call check( __line__, s22_c(
k,i,j) )
1141 call check( __line__, s33_c(
k,i,j) )
1142 call check( __line__, tke(
k,i,j) )
1144 qflx_sgs_momy(
k,i,j,
ydir) = dens(
k,i,j) * ( &
1145 - 2.0_rp * nu(
k,i,j) &
1146 * ( s22_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
1147 + twooverthree * tke(
k,i,j) * tke_fact)
1154 i = iundef; j = iundef;
k = iundef
1159 if ( atmos_phy_tb_smg_implicit )
then
1160 call calc_tend_momy( tend, &
1162 gsqrt, j13g, j23g, j33g, mapf, &
1163 iis, iie, jjs, jje )
1171 ap = - dt * 0.25_rp * ( dens(
ks ,i,j )*nu(
ks ,i,j ) &
1172 + dens(
ks+1,i,j )*nu(
ks+1,i,j ) &
1173 + dens(
ks ,i,j+1)*nu(
ks ,i,j+1) &
1174 + dens(
ks+1,i,j+1)*nu(
ks+1,i,j+1) ) &
1178 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks,i,j+1) )
1181 ap = - dt * 0.25_rp * ( dens(
k-1,i,j )*nu(
k-1,i,j ) &
1182 + dens(
k ,i,j )*nu(
k ,i,j ) &
1183 + dens(
k-1,i,j+1)*nu(
k-1,i,j+1) &
1184 + dens(
k ,i,j+1)*nu(
k ,i,j+1) ) &
1185 * rfdz(
k-1) / gsqrt(
k-1,i,j,
i_xvw)
1187 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xvz)
1188 ap = - dt * 0.25_rp * ( dens(
k ,i,j )*nu(
k ,i,j ) &
1189 + dens(
k+1,i,j )*nu(
k+1,i,j ) &
1190 + dens(
k ,i,j+1)*nu(
k ,i,j+1) &
1191 + dens(
k+1,i,j+1)*nu(
k+1,i,j+1) ) &
1192 * rfdz(
k) / gsqrt(
k,i,j,
i_xvw)
1193 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xvz)
1194 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k,i,j+1) )
1197 ap = - dt * 0.25_rp * ( dens(
ke-1,i,j )*nu(
ke-1,i,j ) &
1198 + dens(
ke ,i,j )*nu(
ke ,i,j ) &
1199 + dens(
ke-1,i,j+1)*nu(
ke-1,i,j+1) &
1200 + dens(
ke ,i,j+1)*nu(
ke ,i,j+1) ) &
1205 b(
ke,i,j) = - c(
ke,i,j) + 0.5_rp * ( dens(
ke,i,j)+dens(
ke,i,j+1) )
1210 call matrix_solver_tridiagonal(
ka,
ks,
ke,
ia, iis, iie,
ja, jjs, jje, &
1211 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
1219 qflx_sgs_momy(
k,i,j,
zdir) = qflx_sgs_momy(
k,i,j,
zdir) &
1220 - 0.25_rp * ( dens(
k ,i,j )*nu(
k ,i,j ) &
1221 + dens(
k+1,i,j )*nu(
k+1,i,j ) &
1222 + dens(
k ,i,j+1)*nu(
k ,i,j+1) &
1223 + dens(
k+1,i,j+1)*nu(
k+1,i,j+1) ) &
1224 * dt * ( tend2(
k+1,i,j) - tend2(
k,i,j) ) * rfdz(
k) / gsqrt(
k,i,j,
i_xvw)
1233 if ( atmos_phy_tb_smg_backscatter )
then
1235 #define f2h(k,i,j,p) ( ( FZ(k+p-1,i,j) - FZ(k+p-2,i,j) ) / ( FZ(k+1,i,j) - FZ(k-1,i,j) ) )
1246 flxz(
k) = j13g(
k,i,j,
i_xyz) * random_my(
k,i,j) &
1247 - j23g(
k,i,j,
i_xyz) * random_mx(
k,i,j)
1252 momz_t(
k,i,j) = ( ( gsqrt(
k,i+1,j,
i_xyw) * ( f2h(
k,i+1,j,1) * random_my(
k+1,i+1,j) &
1253 + f2h(
k,i+1,j,2) * random_my(
k,i+1,j) ) &
1254 - gsqrt(
k,i-1,j,
i_xyw) * ( f2h(
k,i-1,j,1) * random_my(
k+1,i-1,j) &
1255 + f2h(
k,i-1,j,2) * random_my(
k,i-1,j) ) &
1256 ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1257 - ( gsqrt(
k,i,j+1,
i_xyw) * ( f2h(
k,i,j+1,1) * random_mx(
k+1,i,j+1) &
1258 + f2h(
k,i,j+1,2) * random_mx(
k,i,j+1) ) &
1259 - gsqrt(
k,i,j-1,
i_xyw) * ( f2h(
k,i,j-1,1) * random_mx(
k+1,i,j-1) &
1260 + f2h(
k,i,j+1,2) * random_mx(
k,i,j-1) ) &
1261 ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1262 + ( flxz(
k+1) - flxz(
k) ) * rfdz(
k) &
1265 momz_t(
ke,i,j) = 0.0_rp
1278 flxz(
k) = j23g(
k,i,j,
i_uyw) * ( f2h(
k,i+1,j,1) * random_mz(
k+1,i+1,j) + f2h(
k,i,j+1,2) * random_mz(
k,i+1,j) &
1279 + f2h(
k,i ,j,1) * random_mz(
k+1,i ,j) + f2h(
k,i ,j,2) * random_mz(
k,i ,j) ) * 0.5_rp &
1280 - j33g * ( f2h(
k,i+1,j,1) * random_my(
k+1,i+1,j) + f2h(
k,i+1,j,2) * random_my(
k,i+1,j) &
1281 + f2h(
k,i ,j,1) * random_my(
k+1,i ,j) + f2h(
k,i ,j,2) * random_my(
k,i ,j) ) * 0.5_rp
1286 momx_t(
k,i,j) = ( ( gsqrt(
k,i,j+1,
i_uyz) * ( random_mz(
k,i+1,j+1) + random_mz(
k,i,j+1) ) * 0.5_rp &
1287 - gsqrt(
k,i,j-1,
i_uyz) * ( random_mz(
k,i+1,j-1) + random_mz(
k,i,j-1) ) * 0.5_rp ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_uy) &
1288 + ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1303 flxz(
k) = j33g * ( f2h(
k,i,j+1,1) * random_mx(
k+1,i,j+1) + f2h(
k,i,j+1,2) * random_mx(
k,i,j+1) &
1304 + f2h(
k,i,j ,1) * random_mx(
k+1,i,j ) + f2h(
k,i,j ,2) * random_mx(
k,i,j ) ) * 0.5_rp &
1305 - j13g(
k,i,j,
i_xvw) * ( f2h(
k,i,j+1,1) * random_mz(
k+1,i,j+1) + f2h(
k,i,j+1,2) * random_mz(
k,i,j+1) &
1306 + f2h(
k,i,j ,1) * random_mz(
k+1,i,j ) + f2h(
k,i,j ,2) * random_mz(
k,i,j ) ) * 0.5_rp
1311 momy_t(
k,i,j) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1312 - ( gsqrt(
k,i+1,j,
i_xvz) * ( random_mz(
k,i+1,j+1) + random_mz(
k,i+1,j) ) * 0.5_rp &
1313 - gsqrt(
k,i-1,j,
i_xyz) * ( random_mz(
k,i-1,j+1) + random_mz(
k,i-1,j) ) * 0.5_rp ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xv) &
1333 momz_t(
k,i,j) = 0.0_rp
1346 momx_t(
k,i,j) = 0.0_rp
1359 momy_t(
k,i,j) = 0.0_rp
1372 if ( atmos_phy_tb_smg_implicit )
then
1379 ap = - dt * 0.25_rp * ( dens(
ks,i,j)+dens(
ks+1,i,j) ) &
1380 * ( kh(
ks,i,j)+kh(
ks+1,i,j) ) &
1384 b(
ks,i,j) = - a(
ks,i,j) + dens(
ks,i,j)
1387 ap = - dt * 0.25_rp * ( dens(
k-1,i,j)+dens(
k,i,j) ) &
1388 * ( kh(
k-1,i,j)+kh(
k,i,j) ) &
1389 * rfdz(
k-1) / gsqrt(
k-1,i,j,
i_xyw)
1391 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
1392 ap = - dt * 0.25_rp * ( dens(
k,i,j)+dens(
k+1,i,j) ) &
1393 * ( kh(
k,i,j)+kh(
k+1,i,j) ) &
1394 * rfdz(
k) / gsqrt(
k,i,j,
i_xyw)
1395 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
1396 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + dens(
k,i,j)
1399 ap = - dt * 0.25_rp * ( dens(
ke-1,i,j)+dens(
ke,i,j) ) &
1400 * ( kh(
ke-1,i,j)+kh(
ke,i,j) ) &
1405 b(
ke,i,j) = - c(
ke,i,j) + dens(
ke,i,j)
1413 call calc_flux_phi( &
1415 dens, pott, kh, 1.0_rp, &
1416 gsqrt, j13g, j23g, j33g, mapf, &
1417 atmos_phy_tb_smg_horizontal, &
1418 atmos_phy_tb_smg_implicit, &
1420 iis, iie, jjs, jje )
1422 if ( atmos_phy_tb_smg_backscatter )
then
1429 dd(
k,i,j) = sqrt( ( ( pott(
k+1,i,j) - pott(
k-1,i,j) ) * j33g / ( fdz(
k) + fdz(
k-1) ) )**2 &
1430 + ( ( ( gsqrt(
k,i+1,j,
i_xyz)*pott(
k,i+1,j) - gsqrt(
k,i-1,j,
i_xyz)*pott(
k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1431 + ( j13g(
k+1,i,j,
i_xyz)*pott(
k+1,i,j) - j13g(
k-1,i,j,
i_xyz)*pott(
k-1,i,j) ) / ( fdz(
k) + fdz(
k-1) ) ) * mapf(i,j,1,
i_xy) )**2 &
1432 + ( ( ( gsqrt(
k,i,j+1,
i_xyz)*pott(
k,i,j+1) - gsqrt(
k,i,j-1,
i_xyz)*pott(
k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1433 + ( j23g(
k+1,i,j,
i_xyz)*pott(
k+1,i,j) - j23g(
k-1,i,j,
i_xyz)*pott(
k-1,i,j) ) / ( fdz(
k) + fdz(
k-1) ) ) * mapf(i,j,2,
i_xy) )**2 &
1436 dd(
ks,i,j) = sqrt( ( ( pott(
ks+1,i,j) - pott(
ks,i,j) ) * j33g * rfdz(
ks) )**2 &
1437 + ( ( ( gsqrt(
ks,i+1,j,
i_xyz)*pott(
ks,i+1,j) - gsqrt(
ks,i-1,j,
i_xyz)*pott(
ks,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1438 + ( j13g(
ks+1,i,j,
i_xyz)*pott(
ks+1,i,j) - j13g(
ks,i,j,
i_xyz)*pott(
ks,i,j) ) * rfdz(
ks) ) * mapf(i,j,1,
i_xy) )**2 &
1439 + ( ( ( gsqrt(
ks,i,j+1,
i_xyz)*pott(
ks,i,j+1) - gsqrt(
ks,i,j-1,
i_xyz)*pott(
ks,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1440 + ( j23g(
ks+1,i,j,
i_xyz)*pott(
ks+1,i,j) - j23g(
ks,i,j,
i_xyz)*pott(
ks,i,j) ) * rfdz(
ks) ) * mapf(i,j,2,
i_xy) )**2 &
1442 dd(
ke,i,j) = sqrt( ( ( pott(
ke,i,j) - pott(
ke-1,i,j) ) * j33g * rfdz(
ke-1) )**2 &
1443 + ( ( ( gsqrt(
ke,i+1,j,
i_xyz)*pott(
ke,i+1,j) - gsqrt(
ke,i-1,j,
i_xyz)*pott(
ke,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1444 + ( j13g(
ke,i,j,
i_xyz)*pott(
ke,i,j) - j13g(
ke-1,i,j,
i_xyz)*pott(
ke-1,i,j) ) * rfdz(
ke-1) ) * mapf(i,j,1,
i_xy) )**2 &
1445 + ( ( ( gsqrt(
ke,i,j+1,
i_xyz)*pott(
ke,i,j+1) - gsqrt(
ke,i,j-1,
i_xyz)*pott(
ke,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1446 + ( j23g(
ke,i,j,
i_xyz)*pott(
ke,i,j) - j23g(
ke-1,i,j,
i_xyz)*pott(
ke-1,i,j) ) * rfdz(
ke-1) ) * mapf(i,j,2,
i_xy) )**2 &
1460 flxz(
k) = j33g * ( f2h(
k,i,j,1) * random_qz(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qz(
k,i,j) * dd(
k,i,j) ) &
1461 + j13g(
k,i,j,
i_xyw) * ( f2h(
k,i,j,1) * random_qx(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qx(
k,i,j) * dd(
k,i,j) ) &
1462 + j23g(
k,i,j,
i_xyw) * ( f2h(
k,i,j,1) * random_qy(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qy(
k,i,j) * dd(
k,i,j) )
1467 rhot_t(
k,i,j) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1468 + ( gsqrt(
k,i+1,j,
i_xyz) * random_qx(
k,i+1,j) * dd(
k,i+1,j) - gsqrt(
k,i-1,j,
i_xyz) * random_qx(
k,i-1,j) * dd(
k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1469 + ( gsqrt(
k,i,j+1,
i_xyz) * random_qy(
k,i,j+1) * dd(
k,i,j+1) - gsqrt(
k,i,j-1,
i_xyz) * random_qy(
k,i,j-1) * dd(
k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1484 rhot_t(
k,i,j) = 0.0_rp
1506 call calc_flux_phi( &
1507 qflx_sgs_rhoq(:,:,:,:,iq), &
1508 dens, qtrc(:,:,:,iq), kh, 1.0_rp, &
1509 gsqrt, j13g, j23g, j33g, mapf, &
1510 atmos_phy_tb_smg_horizontal, &
1511 atmos_phy_tb_smg_implicit, &
1513 iis, iie, jjs, jje )
1516 if ( atmos_phy_tb_smg_backscatter .and. iq ==
i_qv )
then
1523 dd(
k,i,j) = sqrt( ( ( qtrc(
k+1,i,j,iq) - qtrc(
k-1,i,j,iq) ) * j33g / ( fdz(
k) + fdz(
k-1) ) )**2 &
1524 + ( ( ( gsqrt(
k,i+1,j,
i_xyz)*qtrc(
k,i+1,j,iq) - gsqrt(
k,i-1,j,
i_xyz)*qtrc(
k,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1525 + ( j13g(
k+1,i,j,
i_xyz)*qtrc(
k+1,i,j,iq) - j13g(
k-1,i,j,
i_xyz)*qtrc(
k-1,i,j,iq) ) / ( fdz(
k) + fdz(
k-1) ) ) * mapf(i,j,1,
i_xy) )**2 &
1526 + ( ( ( gsqrt(
k,i,j+1,
i_xyz)*qtrc(
k,i,j+1,iq) - gsqrt(
k,i,j-1,
i_xyz)*qtrc(
k,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1527 + ( j23g(
k+1,i,j,
i_xyz)*qtrc(
k+1,i,j,iq) - j23g(
k-1,i,j,
i_xyz)*qtrc(
k-1,i,j,iq) ) / ( fdz(
k) + fdz(
k-1) ) ) * mapf(i,j,2,
i_xy) )**2 &
1530 dd(
ks,i,j) = sqrt( ( ( qtrc(
ks+1,i,j,iq) - qtrc(
ks,i,j,iq) ) * j33g * rfdz(
ks) )**2 &
1531 + ( ( ( gsqrt(
ks,i+1,j,
i_xyz)*qtrc(
ks,i+1,j,iq) - gsqrt(
ks,i-1,j,
i_xyz)*qtrc(
ks,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1532 + ( j13g(
ks+1,i,j,
i_xyz)*qtrc(
ks+1,i,j,iq) - j13g(
ks,i,j,
i_xyz)*qtrc(
ks,i,j,iq) ) * rfdz(
ks) ) * mapf(i,j,1,
i_xy) )**2 &
1533 + ( ( ( gsqrt(
ks,i,j+1,
i_xyz)*qtrc(
ks,i,j+1,iq) - gsqrt(
ks,i,j-1,
i_xyz)*qtrc(
ks,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1534 + ( j23g(
ks+1,i,j,
i_xyz)*qtrc(
ks+1,i,j,iq) - j23g(
ks,i,j,
i_xyz)*qtrc(
ks,i,j,iq) ) * rfdz(
ks) ) * mapf(i,j,2,
i_xy) )**2 &
1536 dd(
ke,i,j) = sqrt( ( ( qtrc(
ke,i,j,iq) - qtrc(
ke-1,i,j,iq) ) * j33g * rfdz(
ke-1) )**2 &
1537 + ( ( ( gsqrt(
ke,i+1,j,
i_xyz)*qtrc(
ke,i+1,j,iq) - gsqrt(
ke,i-1,j,
i_xyz)*qtrc(
ke,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1538 + ( j13g(
ke,i,j,
i_xyz)*qtrc(
ke,i,j,iq) - j13g(
ke-1,i,j,
i_xyz)*qtrc(
ke-1,i,j,iq) ) * rfdz(
ke-1) ) * mapf(i,j,1,
i_xy) )**2 &
1539 + ( ( ( gsqrt(
ke,i,j+1,
i_xyz)*qtrc(
ke,i,j+1,iq) - gsqrt(
ke,i,j-1,
i_xyz)*qtrc(
ke,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1540 + ( j23g(
ke,i,j,
i_xyz)*qtrc(
ke,i,j,iq) - j23g(
ke-1,i,j,
i_xyz)*qtrc(
ke-1,i,j,iq) ) * rfdz(
ke-1) ) * mapf(i,j,2,
i_xy) )**2 &
1554 flxz(
k) = j33g * ( f2h(
k,i,j,1) * random_qz(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qz(
k,i,j) * dd(
k,i,j) ) &
1555 + j13g(
k,i,j,
i_xyw) * ( f2h(
k,i,j,1) * random_qx(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qx(
k,i,j) * dd(
k,i,j) ) &
1556 + j23g(
k,i,j,
i_xyw) * ( f2h(
k,i,j,1) * random_qy(
k+1,i,j) * dd(
k+1,i,j) + f2h(
k,i,j,2) * random_qy(
k,i,j) * dd(
k,i,j) )
1561 rhoq_t(
k,i,j,iq) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1562 + ( gsqrt(
k,i+1,j,
i_xyz) * random_qx(
k,i+1,j) * dd(
k,i+1,j) - gsqrt(
k,i-1,j,
i_xyz) * random_qx(
k,i-1,j) * dd(
k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1563 + ( gsqrt(
k,i,j+1,
i_xyz) * random_qy(
k,i,j+1) * dd(
k,i,j+1) - gsqrt(
k,i,j-1,
i_xyz) * random_qy(
k,i,j-1) * dd(
k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1578 rhoq_t(
k,i,j,iq) = 0.0_rp
1594 call file_history_in( tke(:,:,:),
'TKE_SMG',
'turbulent kinetic energy (Smagorinsky)',
'm2/s2', fill_halo=.true. )
1603 function mixlen(dz, dx, dy, filter_fact)
1606 real(rp),
intent(in),
value :: dz
1607 real(rp),
intent(in),
value :: dx
1608 real(rp),
intent(in),
value :: dy
1609 real(rp),
intent(in),
value :: filter_fact
1612 mixlen = fact(dz, dx, dy) * filter_fact * ( dz * dx * dy )**oneoverthree
1617 function fact(dz, dx, dy)
1619 real(rp),
intent(in) :: dz
1620 real(rp),
intent(in) :: dx
1621 real(rp),
intent(in) :: dy
1624 real(rp),
parameter :: oot = -1.0_rp/3.0_rp
1625 real(rp),
parameter :: fot = 5.0_rp/3.0_rp
1626 real(rp),
parameter :: eot = 11.0_rp/3.0_rp
1627 real(rp),
parameter :: tof = -3.0_rp/4.0_rp
1628 real(rp) :: a1, a2, b1, b2, dmax
1630 dmax = max(dz, dx, dy)
1631 if ( dz == dmax )
then
1634 else if ( dx == dmax )
then
1644 fact = 1.736_rp * (a1*a2)**oot &
1645 * ( 4.0_rp*p1(b1)*a1**oot + 0.222_rp*p2(b1)*a1**fot + 0.077*p3(b1)*a1**eot - 3.0_rp*b1 &
1646 + 4.0_rp*p1(b2)*a2**oot + 0.222_rp*p2(b2)*a2**fot + 0.077*p3(b2)*a2**eot - 3.0_rp*b2 &
1652 real(rp),
intent(in) :: z
1655 p1 = 2.5_rp * p2(z) - 1.5_rp * sin(z) * cos(z)**twooverthree
1660 real(rp),
intent(in) :: z
1663 p2 = 0.986_rp * z + 0.073_rp * z**2 - 0.418_rp * z**3 + 0.120_rp * z**4
1668 real(rp),
intent(in) :: z
1671 p3 = 0.976_rp * z + 0.188_rp * z**2 - 1.169_rp * z**3 + 0.755_rp * z**4 - 0.151_rp * z**5