32 #if defined DEBUG || defined QUICKDEBUG
61 real(RP),
private,
parameter :: OneOverThree = 1.0_rp / 3.0_rp
62 real(RP),
private,
parameter :: twoOverThree = 2.0_rp / 3.0_rp
63 real(RP),
private,
parameter :: FourOverThree = 4.0_rp / 3.0_rp
65 real(RP),
private :: Cs = 0.13_rp
66 real(RP),
private,
parameter :: PrN = 0.7_rp
67 real(RP),
private,
parameter :: RiC = 0.25_rp
68 real(RP),
private,
parameter :: FmC = 16.0_rp
69 real(RP),
private,
parameter :: FhB = 40.0_rp
70 real(RP),
private :: RPrN
71 real(RP),
private :: RRiC
72 real(RP),
private :: PrNovRiC
75 real(RP),
private,
parameter :: CB = 1.4_rp
76 real(RP),
private,
parameter :: CBt = 0.45_rp
77 real(RP),
private,
parameter :: aN = 0.47958315233127197_rp
78 real(RP),
private,
parameter :: atN4 = 0.09_rp
79 real(RP),
private,
parameter :: C1o = an**3
80 real(RP),
private,
parameter :: D1o = prn * atn4 / an
82 real(RP),
private,
allocatable :: lambda0(:,:,:)
83 real(RP),
private,
allocatable :: lambda (:,:,:)
85 real(RP),
private :: ATMOS_PHY_TB_SMG_NU_MAX = 10000.0_rp
86 logical,
private :: ATMOS_PHY_TB_SMG_backscatter = .false.
87 logical,
private :: ATMOS_PHY_TB_SMG_bottom = .true.
88 logical,
private :: ATMOS_PHY_TB_SMG_implicit = .false.
89 logical,
private :: ATMOS_PHY_TB_SMG_horizontal = .false.
91 real(RP),
private :: tke_fact
98 FZ, CZ, CDX, CDY, MAPF, &
106 real(rp),
intent(in) :: fz (0:
ka,
ia,
ja)
107 real(rp),
intent(in) :: cz (
ka,
ia,
ja)
108 real(rp),
intent(in) :: cdx (
ia)
109 real(rp),
intent(in) :: cdy (
ja)
110 real(rp),
intent(in) :: mapf(
ia,
ja,2)
112 logical,
intent(in),
optional :: horizontal
114 real(rp) :: atmos_phy_tb_smg_cs
115 real(rp) :: atmos_phy_tb_smg_filter_fact = 2.0_rp
116 logical :: atmos_phy_tb_smg_consistent_tke = .true.
118 namelist / param_atmos_phy_tb_smg / &
119 atmos_phy_tb_smg_cs, &
120 atmos_phy_tb_smg_nu_max, &
121 atmos_phy_tb_smg_filter_fact, &
122 atmos_phy_tb_smg_bottom, &
123 atmos_phy_tb_smg_backscatter, &
124 atmos_phy_tb_smg_implicit, &
125 atmos_phy_tb_smg_consistent_tke, &
126 atmos_phy_tb_smg_horizontal
133 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Setup'
134 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Smagorinsky-type Eddy Viscocity Model'
136 atmos_phy_tb_smg_cs = cs
138 if (
present(horizontal) ) atmos_phy_tb_smg_horizontal = horizontal
142 read(
io_fid_conf,nml=param_atmos_phy_tb_smg,iostat=ierr)
144 log_info(
"ATMOS_PHY_TB_smg_setup",*)
'Not found namelist. Default used.'
145 elseif( ierr > 0 )
then
146 log_error(
"ATMOS_PHY_TB_smg_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_TB_SMG. Check!'
149 log_nml(param_atmos_phy_tb_smg)
151 cs = atmos_phy_tb_smg_cs
155 prnovric = ( 1.0_rp - prn ) * rric
157 allocate( lambda0(
ka,
ia,
ja) )
158 allocate( lambda(
ka,
ia,
ja) )
161 lambda0(:,:,:) = undef
162 lambda(:,:,:) = undef
164 if ( atmos_phy_tb_smg_horizontal )
then
169 lambda0(
k,i,j) = cs * sqrt( cdx(i) * cdy(j) / ( mapf(i,j,1) * mapf(i,j,2) ) )
170 lambda(
k,i,j) = lambda0(
k,i,j)
175 i = iundef; j = iundef;
k = iundef
177 atmos_phy_tb_smg_consistent_tke = .false.
178 atmos_phy_tb_smg_implicit = .false.
179 atmos_phy_tb_smg_backscatter = .false.
185 lambda0(
k,i,j) = cs *
mixlen( fz(
k,i,j) - fz(
k-1,i,j), &
186 cdx(i) / mapf(i,j,1), &
187 cdy(j) / mapf(i,j,2), &
188 atmos_phy_tb_smg_filter_fact )
193 i = iundef; j = iundef;
k = iundef
196 if ( atmos_phy_tb_smg_bottom )
then
201 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 ) )
206 i = iundef; j = iundef;
k = iundef
213 lambda(
k,i,j) = lambda0(
k,i,j)
218 i = iundef; j = iundef;
k = iundef
224 if ( atmos_phy_tb_smg_consistent_tke )
then
235 qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, &
236 qflx_sgs_rhot, qflx_sgs_rhoq, &
237 MOMZ_t, MOMX_t, MOMY_t, RHOT_t, RHOQ_t, &
239 MOMZ, MOMX, MOMY, POTT, DENS, QTRC, N2, &
240 FZ, FDZ, RCDZ, RFDZ, CDX, FDX, CDY, FDY, &
241 GSQRT, J13G, J23G, J33G, MAPF, dt )
264 real(rp),
intent(out) :: qflx_sgs_momz(
ka,
ia,
ja,3)
265 real(rp),
intent(out) :: qflx_sgs_momx(
ka,
ia,
ja,3)
266 real(rp),
intent(out) :: qflx_sgs_momy(
ka,
ia,
ja,3)
267 real(rp),
intent(out) :: qflx_sgs_rhot(
ka,
ia,
ja,3)
268 real(rp),
intent(out) :: qflx_sgs_rhoq(
ka,
ia,
ja,3,
qa)
270 real(rp),
intent(out) :: momz_t (
ka,
ia,
ja)
271 real(rp),
intent(out) :: momx_t (
ka,
ia,
ja)
272 real(rp),
intent(out) :: momy_t (
ka,
ia,
ja)
273 real(rp),
intent(out) :: rhot_t (
ka,
ia,
ja)
274 real(rp),
intent(out) :: rhoq_t (
ka,
ia,
ja,
qa)
276 real(rp),
intent(out) :: nu (
ka,
ia,
ja)
277 real(rp),
intent(out) :: ri (
ka,
ia,
ja)
278 real(rp),
intent(out) :: pr (
ka,
ia,
ja)
280 real(rp),
intent(in) :: momz (
ka,
ia,
ja)
281 real(rp),
intent(in) :: momx (
ka,
ia,
ja)
282 real(rp),
intent(in) :: momy (
ka,
ia,
ja)
283 real(rp),
intent(in) :: pott (
ka,
ia,
ja)
284 real(rp),
intent(in) :: dens (
ka,
ia,
ja)
285 real(rp),
intent(in) :: qtrc (
ka,
ia,
ja,
qa)
286 real(rp),
intent(in) :: n2 (
ka,
ia,
ja)
288 real(rp),
intent(in) :: fz (0:
ka,
ia,
ja)
289 real(rp),
intent(in) :: fdz (
ka-1)
290 real(rp),
intent(in) :: rcdz (
ka)
291 real(rp),
intent(in) :: rfdz (
ka-1)
292 real(rp),
intent(in) :: cdx (
ia)
293 real(rp),
intent(in) :: fdx (
ia-1)
294 real(rp),
intent(in) :: cdy (
ja)
295 real(rp),
intent(in) :: fdy (
ja-1)
297 real(rp),
intent(in) :: gsqrt (
ka,
ia,
ja,7)
298 real(rp),
intent(in) :: j13g (
ka,
ia,
ja,7)
299 real(rp),
intent(in) :: j23g (
ka,
ia,
ja,7)
300 real(rp),
intent(in) :: j33g
301 real(rp),
intent(in) :: mapf(
ia,
ja,2,4)
302 real(
dp),
intent(in) :: dt
308 real(rp) :: s33_c(
ka,
ia,
ja)
309 real(rp) :: s11_c(
ka,
ia,
ja)
310 real(rp) :: s22_c(
ka,
ia,
ja)
311 real(rp) :: s31_c(
ka,
ia,
ja)
312 real(rp) :: s12_c(
ka,
ia,
ja)
313 real(rp) :: s23_c(
ka,
ia,
ja)
314 real(rp) :: s12_z(
ka,
ia,
ja)
315 real(rp) :: s23_x(
ka,
ia,
ja)
316 real(rp) :: s31_y(
ka,
ia,
ja)
323 real(rp) :: lambda_r(
ka)
330 real(rp) :: tend(
ka,
ia,
ja)
338 real(rp) :: random (
ka,
ia,
ja)
339 real(rp) :: random_mz(
ka,
ia,
ja)
340 real(rp) :: random_mx(
ka,
ia,
ja)
341 real(rp) :: random_my(
ka,
ia,
ja)
342 real(rp) :: random_qz(
ka,
ia,
ja)
343 real(rp) :: random_qx(
ka,
ia,
ja)
344 real(rp) :: random_qy(
ka,
ia,
ja)
347 real(rp) :: dz, dx, dy
354 integer ::
k, i, j, iq
357 log_progress(*)
'atmosphere / physics / turbulence / Smagorinsky'
360 qflx_sgs_momz(:,:,:,:) = undef
361 qflx_sgs_momx(:,:,:,:) = undef
362 qflx_sgs_momy(:,:,:,:) = undef
363 qflx_sgs_rhot(:,:,:,:) = undef
364 qflx_sgs_rhoq(:,:,:,:,:) = undef
374 qflx_sgs_momz(
ks:
ke, 1:
is-1, : ,:) = undef
375 qflx_sgs_momz(
ks:
ke,
ie+1:
ia , : ,:) = undef
376 qflx_sgs_momz(
ks:
ke, : , 1:
js-1,:) = undef
377 qflx_sgs_momz(
ks:
ke, : ,
je+1:
ja ,:) = undef
378 qflx_sgs_momx(
ks:
ke, 1:
is-1, : ,:) = undef
379 qflx_sgs_momx(
ks:
ke,
ie+1:
ia , : ,:) = undef
380 qflx_sgs_momx(
ks:
ke, : , 1:
js-1,:) = undef
381 qflx_sgs_momx(
ks:
ke, : ,
je+1:
ja ,:) = undef
382 qflx_sgs_momy(
ks:
ke, 1:
is-1, : ,:) = undef
383 qflx_sgs_momy(
ks:
ke,
ie+1:
ia , : ,:) = undef
384 qflx_sgs_momy(
ks:
ke, : , 1:
js-1,:) = undef
385 qflx_sgs_momy(
ks:
ke, : ,
je+1:
ja ,:) = undef
391 call calc_strain_tensor( &
392 s33_c, s11_c, s22_c, &
393 s31_c, s12_c, s23_c, &
394 s12_z, s23_x, s31_y, &
396 dens, momz, momx, momy, &
397 gsqrt, j13g, j23g, j33g, mapf )
399 if ( atmos_phy_tb_smg_backscatter )
then
401 call random_normal( random(:,:,:) )
407 random_mz(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
408 + random(
k+1,i,j) + random(
k-1,i,j) &
409 + random(
k,i+1,j) + random(
k,i-1,j) &
410 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
412 random_mz(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
414 + random(
ks,i+1,j) + random(
ks,i-1,j) &
415 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
416 random_mz(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
418 + random(
ke,i+1,j) + random(
ke,i-1,j) &
419 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
423 call random_normal( random(:,:,:) )
429 random_mx(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
430 + random(
k+1,i,j) + random(
k-1,i,j) &
431 + random(
k,i+1,j) + random(
k,i-1,j) &
432 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
434 random_mx(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
436 + random(
ks,i+1,j) + random(
ks,i-1,j) &
437 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
438 random_mx(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
440 + random(
ke,i+1,j) + random(
ke,i-1,j) &
441 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
445 call random_normal( random(:,:,:) )
451 random_my(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
452 + random(
k+1,i,j) + random(
k-1,i,j) &
453 + random(
k,i+1,j) + random(
k,i-1,j) &
454 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
456 random_my(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
458 + random(
ks,i+1,j) + random(
ks,i-1,j) &
459 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
460 random_my(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
462 + random(
ke,i+1,j) + random(
ke,i-1,j) &
463 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
467 call random_normal( random(:,:,:) )
473 random_qz(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
474 + random(
k+1,i,j) + random(
k-1,i,j) &
475 + random(
k,i+1,j) + random(
k,i-1,j) &
476 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
478 random_qz(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
480 + random(
ks,i+1,j) + random(
ks,i-1,j) &
481 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
482 random_qz(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
484 + random(
ke,i+1,j) + random(
ke,i-1,j) &
485 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
489 call random_normal( random(:,:,:) )
495 random_qx(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
496 + random(
k+1,i,j) + random(
k-1,i,j) &
497 + random(
k,i+1,j) + random(
k,i-1,j) &
498 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
500 random_qx(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
502 + random(
ks,i+1,j) + random(
ks,i-1,j) &
503 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
504 random_qx(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
506 + random(
ke,i+1,j) + random(
ke,i-1,j) &
507 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
511 call random_normal( random(:,:,:) )
517 random_qy(
k,i,j) = ( random(
k,i,j) * 2.0_rp &
518 + random(
k+1,i,j) + random(
k-1,i,j) &
519 + random(
k,i+1,j) + random(
k,i-1,j) &
520 + random(
k,i,j+1) + random(
k,i,j-1) ) / 8.0_rp
522 random_qy(
ks,i,j) = ( random(
ks,i,j) * 2.0_rp &
524 + random(
ks,i+1,j) + random(
ks,i-1,j) &
525 + random(
ks,i,j+1) + random(
ks,i,j-1) ) / 7.0_rp
526 random_qy(
ke,i,j) = ( random(
ke,i,j) * 2.0_rp &
528 + random(
ke,i+1,j) + random(
ke,i-1,j) &
529 + random(
ke,i,j+1) + random(
ke,i,j-1) ) / 7.0_rp
544 ri(
k,i,j) = n2(
k,i,j) / max(s2(
k,i,j), eps)
550 if ( ri(
k,i,j) < 0.0_rp )
then
551 fm(
k) = sqrt( 1.0_rp - fmc * ri(
k,i,j) )
552 nu(
k,i,j) = lambda(
k,i,j)**2 * sqrt( s2(
k,i,j) ) * fm(
k)
553 pr(
k,i,j) = fm(
k) / sqrt( 1.0_rp - fhb*ri(
k,i,j) ) * prn
554 else if ( ri(
k,i,j) < ric )
then
555 fm(
k) = ( 1.0_rp - ri(
k,i,j)*rric )**4
556 nu(
k,i,j) = lambda(
k,i,j)**2 * sqrt( s2(
k,i,j) ) * fm(
k)
557 pr(
k,i,j) = prn / ( 1.0_rp - prnovric * ri(
k,i,j) )
565 if ( ri(
k,i,j) < ric )
then
566 kh(
k,i,j) = max( min( nu(
k,i,j) / pr(
k,i,j), atmos_phy_tb_smg_nu_max ), eps )
567 nu(
k,i,j) = max( min( nu(
k,i,j), atmos_phy_tb_smg_nu_max ), eps )
568 pr(
k,i,j) = nu(
k,i,j) / kh(
k,i,j)
569 rf = ri(
k,i,j) / pr(
k,i,j)
570 lambda_r(
k) = lambda(
k,i,j) * sqrt( fm(
k) / sqrt( 1.0_rp - rf ) )
577 if ( atmos_phy_tb_smg_backscatter )
then
580 lambda_r(
k) = min( 1.8_rp * lambda0(
k,i,j), lambda_r(
k) )
581 leovleo5 = ( lambda_r(
k) / lambda0(
k,i,j) )**5
582 c2 = cb * leovleo5 / ( 1.0_rp + cb * leovleo5 )
583 d2 = cbt * leovleo5 / ( 1.0_rp + cbt * leovleo5 )
584 c1(
k) = c1o / sqrt( 1.0_rp - c2 )
586 e(
k) = nu(
k,i,j)**3 * ( 1.0_rp - c2 ) / ( lambda_r(
k)**4 + eps )
587 et = kh(
k,i,j) * ( 1.0_rp - d2 )
589 dz = fz(
k,i,j) - fz(
k-1,i,j)
590 dx = cdx(i) / mapf(i,j,1,
i_xy)
591 dy = cdy(j) / mapf(i,j,2,
i_xy)
593 fact = sqrt( cb * leovleo5 * e(
k) / ( 3.0_rp * dt ) ) * dens(
k,i,j)
594 random_mz(
k,i,j) = random_mz(
k,i,j) * fact * dx * dy / sqrt( dx**2 + dy**2 )
595 random_mx(
k,i,j) = random_mx(
k,i,j) * fact * dy * dz / sqrt( dy**2 + dz**2 )
596 random_my(
k,i,j) = random_my(
k,i,j) * fact * dz * dx / sqrt( dz**2 + dx**2 )
598 fact = sqrt( cbt * leovleo5 * et / ( 3.0_rp * dt ) ) * dens(
k,i,j)
599 random_qz(
k,i,j) = random_qz(
k,i,j) * fact * dz
600 random_qx(
k,i,j) = random_qx(
k,i,j) * fact * dx
601 random_qy(
k,i,j) = random_qy(
k,i,j) * fact * dy
607 e(
k) = nu(
k,i,j)**3 / ( lambda_r(
k)**4 + eps )
615 tke(
k,i,j) = ( e(
k) * lambda_r(
k) / c1(
k) )**twooverthree
621 i = iundef; j = iundef;
k = iundef
633 if ( atmos_phy_tb_smg_horizontal )
then
634 qflx_sgs_momz(:,:,:,
zdir) = 0.0_rp
641 call check( __line__, dens(
k,i,j) )
642 call check( __line__, nu(
k,i,j) )
643 call check( __line__, s33_c(
k,i,j) )
644 call check( __line__, s11_c(
k,i,j) )
645 call check( __line__, s22_c(
k,i,j) )
646 call check( __line__, tke(
k,i,j) )
648 qflx_sgs_momz(
k,i,j,
zdir) = dens(
k,i,j) * ( &
649 - 2.0_rp * nu(
k,i,j) &
650 * ( s33_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
651 + twooverthree * tke(
k,i,j) * tke_fact )
656 i = iundef; j = iundef;
k = iundef
662 qflx_sgs_momz(
ks,i,j,
zdir) = dens(
ks,i,j) * twooverthree * tke(
ks,i,j) * tke_fact
663 qflx_sgs_momz(
ke,i,j,
zdir) = dens(
ke,i,j) * twooverthree * tke(
ke,i,j) * tke_fact
668 i = iundef; j = iundef;
k = iundef
677 call check( __line__, dens(
k,i,j) )
678 call check( __line__, dens(
k,i+1,j) )
679 call check( __line__, dens(
k+1,i,j) )
680 call check( __line__, dens(
k+1,i+1,j) )
681 call check( __line__, nu(
k,i,j) )
682 call check( __line__, nu(
k,i+1,j) )
683 call check( __line__, nu(
k+1,i,j) )
684 call check( __line__, nu(
k+1,i+1,j) )
685 call check( __line__, s31_y(
k,i,j) )
687 qflx_sgs_momz(
k,i,j,
xdir) = - 0.125_rp &
688 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i+1,j)+dens(
k+1,i+1,j) ) &
689 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i+1,j)+nu(
k+1,i+1,j)) &
695 i = iundef; j = iundef;
k = iundef
705 call check( __line__, dens(
k,i,j) )
706 call check( __line__, dens(
k,i,j+1) )
707 call check( __line__, dens(
k+1,i,j) )
708 call check( __line__, dens(
k+1,i,j+1) )
709 call check( __line__, nu(
k,i,j) )
710 call check( __line__, nu(
k,i,j+1) )
711 call check( __line__, nu(
k+1,i,j) )
712 call check( __line__, nu(
k+1,i,j+1) )
713 call check( __line__, s23_x(
k,i,j) )
715 qflx_sgs_momz(
k,i,j,
ydir) = - 0.125_rp &
716 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i,j+1)+dens(
k+1,i,j+1) ) &
717 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i,j+1)+nu(
k+1,i,j+1) ) &
723 i = iundef; j = iundef;
k = iundef
726 if ( atmos_phy_tb_smg_implicit )
then
728 call calc_tend_momz( tend, &
730 gsqrt, j13g, j23g, j33g, mapf, &
738 ap = - fouroverthree * dt &
739 * dens(
ks+1,i,j)*nu(
ks+1,i,j) &
743 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks+1,i,j) )
745 c(
k,i,j) = ap * rfdz(
k+1) / gsqrt(
k+1,i,j,
i_xyw)
746 ap = - fouroverthree * dt &
747 * dens(
k+1,i,j)*nu(
k+1,i,j) &
748 * rcdz(
k+1) / gsqrt(
k+1,i,j,
i_xyz)
749 a(
k,i,j) = ap * rfdz(
k) / gsqrt(
k,i,j,
i_xyw)
750 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k+1,i,j) )
754 b(
ke-1,i,j) = - c(
ke-1,i,j) + 0.5_rp * ( dens(
ke-1,i,j)+dens(
ke,i,j) )
760 call diffusion_solver( &
762 a(:,i,j), b(:,i,j), c(:,i,j), d, &
766 qflx_sgs_momz(
k,i,j,
zdir) = qflx_sgs_momz(
k,i,j,
zdir) &
767 - fouroverthree * dens(
k,i,j) * nu(
k,i,j) * dt &
768 * ( tend(
k,i,j) - tend(
k-1,i,j) ) * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
778 if ( atmos_phy_tb_smg_horizontal )
then
779 qflx_sgs_momx(:,:,:,
zdir) = 0.0_rp
786 call check( __line__, dens(
k,i,j) )
787 call check( __line__, dens(
k,i+1,j) )
788 call check( __line__, dens(
k+1,i,j) )
789 call check( __line__, dens(
k+1,i+1,j) )
790 call check( __line__, nu(
k,i,j) )
791 call check( __line__, nu(
k,i+1,j) )
792 call check( __line__, nu(
k+1,i,j) )
793 call check( __line__, nu(
k+1,i+1,j) )
794 call check( __line__, s31_y(
k,i,j) )
796 qflx_sgs_momx(
k,i,j,
zdir) = - 0.125_rp &
797 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i+1,j)+dens(
k+1,i+1,j) ) &
798 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i+1,j)+nu(
k+1,i+1,j) ) &
804 i = iundef; j = iundef;
k = iundef
809 qflx_sgs_momx(
ks-1,i,j,
zdir) = 0.0_rp
810 qflx_sgs_momx(
ke ,i,j,
zdir) = 0.0_rp
814 i = iundef; j = iundef;
k = iundef
825 call check( __line__, dens(
k,i,j) )
826 call check( __line__, nu(
k,i,j) )
827 call check( __line__, s11_c(
k,i,j) )
828 call check( __line__, s22_c(
k,i,j) )
829 call check( __line__, s33_c(
k,i,j) )
830 call check( __line__, tke(
k,i,j) )
832 qflx_sgs_momx(
k,i,j,
xdir) = dens(
k,i,j) * ( &
833 - 2.0_rp * nu(
k,i,j) &
834 * ( s11_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
835 + twooverthree * tke(
k,i,j) * tke_fact )
840 i = iundef; j = iundef;
k = iundef
850 call check( __line__, dens(
k,i,j) )
851 call check( __line__, dens(
k,i+1,j) )
852 call check( __line__, dens(
k,i,j+1) )
853 call check( __line__, dens(
k,i+1,j+1) )
854 call check( __line__, nu(
k,i,j) )
855 call check( __line__, nu(
k,i+1,j) )
856 call check( __line__, nu(
k,i,j+1) )
857 call check( __line__, nu(
k,i+1,j+1) )
858 call check( __line__, s12_z(
k,i,j) )
860 qflx_sgs_momx(
k,i,j,
ydir) = - 0.125_rp &
861 * ( dens(
k,i,j)+dens(
k,i+1,j)+dens(
k,i,j+1)+dens(
k,i+1,j+1) ) &
862 * ( nu(
k,i,j)+nu(
k,i+1,j)+nu(
k,i,j+1)+nu(
k,i+1,j+1) ) &
868 i = iundef; j = iundef;
k = iundef
871 if ( atmos_phy_tb_smg_implicit )
then
872 call calc_tend_momx( tend, &
874 gsqrt, j13g, j23g, j33g, mapf, &
882 ap = - dt * 0.25_rp * ( dens(
ks ,i ,j)*nu(
ks ,i ,j) &
883 + dens(
ks+1,i ,j)*nu(
ks+1,i ,j) &
884 + dens(
ks ,i+1,j)*nu(
ks ,i+1,j) &
885 + dens(
ks+1,i+1,j)*nu(
ks+1,i+1,j) ) &
889 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks,i+1,j) )
891 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_uyz)
892 ap = - dt * 0.25_rp * ( dens(
k ,i ,j)*nu(
k ,i ,j) &
893 + dens(
k+1,i ,j)*nu(
k+1,i ,j) &
894 + dens(
k ,i+1,j)*nu(
k ,i+1,j) &
895 + dens(
k+1,i+1,j)*nu(
k+1,i+1,j) ) &
897 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_uyz)
898 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k,i+1,j) )
902 b(
ke,i,j) = - c(
ke,i,j) + 0.5_rp * ( dens(
ke,i,j)+dens(
ke,i+1,j) )
908 call diffusion_solver( &
910 a(:,i,j), b(:,i,j), c(:,i,j), d, &
914 qflx_sgs_momx(
k,i,j,
zdir) = qflx_sgs_momx(
k,i,j,
zdir) &
915 - 0.25_rp * ( dens(
k ,i ,j)*nu(
k ,i ,j) &
916 + dens(
k+1,i ,j)*nu(
k+1,i ,j) &
917 + dens(
k ,i+1,j)*nu(
k ,i+1,j) &
918 + dens(
k+1,i+1,j)*nu(
k+1,i+1,j) ) &
919 * dt * ( tend(
k+1,i,j) - tend(
k,i,j) ) * rfdz(
k) / gsqrt(
k,i,j,
i_uyw)
929 if ( atmos_phy_tb_smg_horizontal )
then
930 qflx_sgs_momy(:,:,:,
zdir) = 0.0_rp
937 call check( __line__, dens(
k,i,j) )
938 call check( __line__, dens(
k,i,j+1) )
939 call check( __line__, dens(
k+1,i,j) )
940 call check( __line__, dens(
k+1,i,j+1) )
941 call check( __line__, nu(
k,i,j) )
942 call check( __line__, nu(
k,i,j+1) )
943 call check( __line__, nu(
k+1,i,j) )
944 call check( __line__, nu(
k+1,i,j+1) )
945 call check( __line__, s23_x(
k,i,j) )
947 qflx_sgs_momy(
k,i,j,
zdir) = - 0.125_rp &
948 * ( dens(
k,i,j)+dens(
k+1,i,j)+dens(
k,i,j+1)+dens(
k+1,i,j+1) ) &
949 * ( nu(
k,i,j)+nu(
k+1,i,j)+nu(
k,i,j+1)+nu(
k+1,i,j+1) ) &
955 i = iundef; j = iundef;
k = iundef
960 qflx_sgs_momy(
ks-1,i,j,
zdir) = 0.0_rp
961 qflx_sgs_momy(
ke ,i,j,
zdir) = 0.0_rp
965 i = iundef; j = iundef;
k = iundef
977 call check( __line__, dens(
k,i,j) )
978 call check( __line__, dens(
k,i+1,j) )
979 call check( __line__, dens(
k,i,j+1) )
980 call check( __line__, dens(
k,i+1,j+1) )
981 call check( __line__, nu(
k,i,j) )
982 call check( __line__, nu(
k,i+1,j) )
983 call check( __line__, nu(
k,i,j+1) )
984 call check( __line__, nu(
k,i+1,j+1) )
985 call check( __line__, s12_z(
k,i,j) )
987 qflx_sgs_momy(
k,i,j,
xdir) = - 0.125_rp &
988 * ( dens(
k,i,j)+dens(
k,i+1,j)+dens(
k,i,j+1)+dens(
k,i+1,j+1) ) &
989 * ( nu(
k,i,j)+nu(
k,i+1,j)+nu(
k,i,j+1)+nu(
k,i+1,j+1) ) &
995 i = iundef; j = iundef;
k = iundef
1006 call check( __line__, dens(
k,i,j) )
1007 call check( __line__, nu(
k,i,j) )
1008 call check( __line__, s11_c(
k,i,j) )
1009 call check( __line__, s22_c(
k,i,j) )
1010 call check( __line__, s33_c(
k,i,j) )
1011 call check( __line__, tke(
k,i,j) )
1013 qflx_sgs_momy(
k,i,j,
ydir) = dens(
k,i,j) * ( &
1014 - 2.0_rp * nu(
k,i,j) &
1015 * ( s22_c(
k,i,j) - ( s11_c(
k,i,j) + s22_c(
k,i,j) + s33_c(
k,i,j) ) * oneoverthree ) &
1016 + twooverthree * tke(
k,i,j) * tke_fact)
1021 i = iundef; j = iundef;
k = iundef
1024 if ( atmos_phy_tb_smg_implicit )
then
1025 call calc_tend_momy( tend, &
1027 gsqrt, j13g, j23g, j33g, mapf, &
1028 iis, iie, jjs, jje )
1035 ap = - dt * 0.25_rp * ( dens(
ks ,i,j )*nu(
ks ,i,j ) &
1036 + dens(
ks+1,i,j )*nu(
ks+1,i,j ) &
1037 + dens(
ks ,i,j+1)*nu(
ks ,i,j+1) &
1038 + dens(
ks+1,i,j+1)*nu(
ks+1,i,j+1) ) &
1042 b(
ks,i,j) = - a(
ks,i,j) + 0.5_rp * ( dens(
ks,i,j)+dens(
ks,i,j+1) )
1044 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xvz)
1045 ap = - dt * 0.25_rp * ( dens(
k ,i,j )*nu(
k ,i,j ) &
1046 + dens(
k+1,i,j )*nu(
k+1,i,j ) &
1047 + dens(
k ,i,j+1)*nu(
k ,i,j+1) &
1048 + dens(
k+1,i,j+1)*nu(
k+1,i,j+1) ) &
1049 * rfdz(
k) / gsqrt(
k,i,j,
i_xvw)
1050 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xvz)
1051 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + 0.5_rp * ( dens(
k,i,j)+dens(
k,i,j+1) )
1055 b(
ke,i,j) = - c(
ke,i,j) + 0.5_rp * ( dens(
ke,i,j)+dens(
ke,i,j+1) )
1061 call diffusion_solver( &
1063 a(:,i,j), b(:,i,j), c(:,i,j), d, &
1067 qflx_sgs_momy(
k,i,j,
zdir) = qflx_sgs_momy(
k,i,j,
zdir) &
1068 - 0.25_rp * ( dens(
k ,i,j )*nu(
k ,i,j ) &
1069 + dens(
k+1,i,j )*nu(
k+1,i,j ) &
1070 + dens(
k ,i,j+1)*nu(
k ,i,j+1) &
1071 + dens(
k+1,i,j+1)*nu(
k+1,i,j+1) ) &
1072 * dt * ( tend(
k+1,i,j) - tend(
k,i,j) ) * rfdz(
k) / gsqrt(
k,i,j,
i_xvw)
1080 if ( atmos_phy_tb_smg_backscatter )
then
1082 #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) ) )
1089 flxz(
k) = j13g(
k,i,j,
i_xyz) * random_my(
k,i,j) &
1090 - j23g(
k,i,j,
i_xyz) * random_mx(
k,i,j)
1095 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) &
1096 + f2h(
k,i+1,j,2) * random_my(
k,i+1,j) ) &
1097 - gsqrt(
k,i-1,j,
i_xyw) * ( f2h(
k,i-1,j,1) * random_my(
k+1,i-1,j) &
1098 + f2h(
k,i-1,j,2) * random_my(
k,i-1,j) ) &
1099 ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1100 - ( gsqrt(
k,i,j+1,
i_xyw) * ( f2h(
k,i,j+1,1) * random_mx(
k+1,i,j+1) &
1101 + f2h(
k,i,j+1,2) * random_mx(
k,i,j+1) ) &
1102 - gsqrt(
k,i,j-1,
i_xyw) * ( f2h(
k,i,j-1,1) * random_mx(
k+1,i,j-1) &
1103 + f2h(
k,i,j+1,2) * random_mx(
k,i,j-1) ) &
1104 ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1105 + ( flxz(
k+1) - flxz(
k) ) * rfdz(
k) &
1108 momz_t(
ke,i,j) = 0.0_rp
1118 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) &
1119 + f2h(
k,i ,j,1) * random_mz(
k+1,i ,j) + f2h(
k,i ,j,2) * random_mz(
k,i ,j) ) * 0.5_rp &
1120 - 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) &
1121 + f2h(
k,i ,j,1) * random_my(
k+1,i ,j) + f2h(
k,i ,j,2) * random_my(
k,i ,j) ) * 0.5_rp
1126 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 &
1127 - 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) &
1128 + ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1140 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) &
1141 + f2h(
k,i,j ,1) * random_mx(
k+1,i,j ) + f2h(
k,i,j ,2) * random_mx(
k,i,j ) ) * 0.5_rp &
1142 - 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) &
1143 + f2h(
k,i,j ,1) * random_mz(
k+1,i,j ) + f2h(
k,i,j ,2) * random_mz(
k,i,j ) ) * 0.5_rp
1148 momy_t(
k,i,j) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1149 - ( gsqrt(
k,i+1,j,
i_xvz) * ( random_mz(
k,i+1,j+1) + random_mz(
k,i+1,j) ) * 0.5_rp &
1150 - 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) &
1163 momz_t(
k,i,j) = 0.0_rp
1172 momx_t(
k,i,j) = 0.0_rp
1181 momy_t(
k,i,j) = 0.0_rp
1190 if ( atmos_phy_tb_smg_implicit )
then
1197 ap = - dt * 0.25_rp * ( dens(
ks,i,j)+dens(
ks+1,i,j) ) &
1198 * ( kh(
ks,i,j)+kh(
ks+1,i,j) ) &
1202 b(
ks,i,j) = - a(
ks,i,j) + dens(
ks,i,j)
1204 c(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
1205 ap = - dt * 0.25_rp * ( dens(
k,i,j)+dens(
k+1,i,j) ) &
1206 * ( kh(
k,i,j)+kh(
k+1,i,j) ) &
1207 * rfdz(
k) / gsqrt(
k,i,j,
i_xyw)
1208 a(
k,i,j) = ap * rcdz(
k) / gsqrt(
k,i,j,
i_xyz)
1209 b(
k,i,j) = - a(
k,i,j) - c(
k,i,j) + dens(
k,i,j)
1213 b(
ke,i,j) = - c(
ke,i,j) + dens(
ke,i,j)
1220 call calc_flux_phi( &
1222 dens, pott, kh, 1.0_rp, &
1223 gsqrt, j13g, j23g, j33g, mapf, &
1224 atmos_phy_tb_smg_horizontal, &
1225 atmos_phy_tb_smg_implicit, &
1227 iis, iie, jjs, jje )
1229 if ( atmos_phy_tb_smg_backscatter )
then
1236 dd(
k,i,j) = sqrt( ( ( pott(
k+1,i,j) - pott(
k-1,i,j) ) * j33g / ( fdz(
k) + fdz(
k-1) ) )**2 &
1237 + ( ( ( 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) ) &
1238 + ( 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 &
1239 + ( ( ( 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) ) &
1240 + ( 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 &
1243 dd(
ks,i,j) = sqrt( ( ( pott(
ks+1,i,j) - pott(
ks,i,j) ) * j33g * rfdz(
ks) )**2 &
1244 + ( ( ( 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) ) &
1245 + ( 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 &
1246 + ( ( ( 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) ) &
1247 + ( 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 &
1249 dd(
ke,i,j) = sqrt( ( ( pott(
ke,i,j) - pott(
ke-1,i,j) ) * j33g * rfdz(
ke-1) )**2 &
1250 + ( ( ( 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) ) &
1251 + ( 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 &
1252 + ( ( ( 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) ) &
1253 + ( 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 &
1264 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) ) &
1265 + 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) ) &
1266 + 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) )
1271 rhot_t(
k,i,j) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1272 + ( 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) &
1273 + ( 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) &
1286 rhot_t(
k,i,j) = 0.0_rp
1306 call calc_flux_phi( &
1307 qflx_sgs_rhoq(:,:,:,:,iq), &
1308 dens, qtrc(:,:,:,iq), kh, 1.0_rp, &
1309 gsqrt, j13g, j23g, j33g, mapf, &
1310 atmos_phy_tb_smg_horizontal, &
1311 atmos_phy_tb_smg_implicit, &
1313 iis, iie, jjs, jje )
1316 if ( atmos_phy_tb_smg_backscatter .and. iq ==
i_qv )
then
1323 dd(
k,i,j) = sqrt( ( ( qtrc(
k+1,i,j,iq) - qtrc(
k-1,i,j,iq) ) * j33g / ( fdz(
k) + fdz(
k-1) ) )**2 &
1324 + ( ( ( 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) ) &
1325 + ( 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 &
1326 + ( ( ( 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) ) &
1327 + ( 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 &
1330 dd(
ks,i,j) = sqrt( ( ( qtrc(
ks+1,i,j,iq) - qtrc(
ks,i,j,iq) ) * j33g * rfdz(
ks) )**2 &
1331 + ( ( ( 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) ) &
1332 + ( 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 &
1333 + ( ( ( 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) ) &
1334 + ( 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 &
1336 dd(
ke,i,j) = sqrt( ( ( qtrc(
ke,i,j,iq) - qtrc(
ke-1,i,j,iq) ) * j33g * rfdz(
ke-1) )**2 &
1337 + ( ( ( 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) ) &
1338 + ( 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 &
1339 + ( ( ( 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) ) &
1340 + ( 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 &
1351 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) ) &
1352 + 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) ) &
1353 + 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) )
1358 rhoq_t(
k,i,j,iq) = ( ( flxz(
k) - flxz(
k-1) ) * rcdz(
k) &
1359 + ( 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) &
1360 + ( 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) &
1373 rhoq_t(
k,i,j,iq) = 0.0_rp
1388 call file_history_in( tke(:,:,:),
'TKE_SMG',
'turbulent kinetic energy (Smagorinsky)',
'm2/s2', fill_halo=.true. )
1395 function mixlen(dz, dx, dy, filter_fact)
1397 real(rp),
intent(in) :: dz
1398 real(rp),
intent(in) :: dx
1399 real(rp),
intent(in) :: dy
1400 real(rp),
intent(in) :: filter_fact
1403 mixlen = fact(dz, dx, dy) * filter_fact * ( dz * dx * dy )**oneoverthree
1408 function fact(dz, dx, dy)
1409 real(rp),
intent(in) :: dz
1410 real(rp),
intent(in) :: dx
1411 real(rp),
intent(in) :: dy
1414 real(rp),
parameter :: oot = -1.0_rp/3.0_rp
1415 real(rp),
parameter :: fot = 5.0_rp/3.0_rp
1416 real(rp),
parameter :: eot = 11.0_rp/3.0_rp
1417 real(rp),
parameter :: tof = -3.0_rp/4.0_rp
1418 real(rp) :: a1, a2, b1, b2, dmax
1421 dmax = max(dz, dx, dy)
1422 if ( dz == dmax )
then
1425 else if ( dx == dmax )
then
1435 fact = 1.736_rp * (a1*a2)**oot &
1436 * ( 4.0_rp*p1(b1)*a1**oot + 0.222_rp*p2(b1)*a1**fot + 0.077*p3(b1)*a1**eot - 3.0_rp*b1 &
1437 + 4.0_rp*p1(b2)*a2**oot + 0.222_rp*p2(b2)*a2**fot + 0.077*p3(b2)*a2**eot - 3.0_rp*b2 &
1442 real(rp),
intent(in) :: z
1445 p1 = 2.5_rp * p2(z) - 1.5_rp * sin(z) * cos(z)**twooverthree
1449 real(rp),
intent(in) :: z
1452 p2 = 0.986_rp * z + 0.073_rp * z**2 - 0.418_rp * z**3 + 0.120_rp * z**4
1456 real(rp),
intent(in) :: z
1459 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