60 real(RP),
parameter :: oneoverthree = 1.0_rp / 3.0_rp
61 real(RP),
parameter :: tke_min = 1.0e-10_rp
62 real(RP),
parameter :: lt_min = 1.0e-6_rp
63 real(RP),
parameter :: us_min = 1.0e-6_rp
67 real(RP),
parameter :: b1 = 24.0_rp
68 real(RP),
parameter :: b2 = 15.0_rp
70 real(RP),
parameter :: c2 = 0.75_rp
71 real(RP),
parameter :: c3 = 0.352_rp
72 real(RP),
parameter :: c5 = 0.2_rp
73 real(RP),
parameter :: g1 = 0.235_rp
81 real(RP),
parameter :: prn = 0.74_rp
88 logical :: atmos_phy_tb_mynn_tke_init = .false.
89 real(RP) :: atmos_phy_tb_mynn_n2_max = 1.e3_rp
90 real(RP) :: atmos_phy_tb_mynn_nu_min = 1.e-6_rp
91 real(RP) :: atmos_phy_tb_mynn_nu_max = 10000._rp
92 real(RP) :: atmos_phy_tb_mynn_kh_min = 1.e-6_rp
93 real(RP) :: atmos_phy_tb_mynn_kh_max = 10000._rp
94 real(RP) :: atmos_phy_tb_mynn_lt_max = 700._rp
109 character(len=*),
intent(in) :: TYPE_TB
111 real(RP),
intent(in) :: CDZ(
ka)
112 real(RP),
intent(in) :: CDX(
ia)
113 real(RP),
intent(in) :: CDY(
ja)
114 real(RP),
intent(in) :: CZ (
ka,
ia,
ja)
116 real(RP) :: ATMOS_PHY_TB_MYNN_PBL_MAX = 1e10_rp
118 namelist / param_atmos_phy_tb_mynn / &
119 atmos_phy_tb_mynn_tke_init, &
120 atmos_phy_tb_mynn_pbl_max, &
121 atmos_phy_tb_mynn_n2_max, &
122 atmos_phy_tb_mynn_nu_min, &
123 atmos_phy_tb_mynn_nu_max, &
124 atmos_phy_tb_mynn_kh_min, &
125 atmos_phy_tb_mynn_kh_max, &
126 atmos_phy_tb_mynn_lt_max
133 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[TURBULENCE] / Categ[ATMOS PHYSICS] / Origin[SCALElib]' 134 if(
io_l )
write(
io_fid_log,*)
'+++ Mellor-Yamada Nakanishi-Niino Model' 136 if ( type_tb /=
'MYNN' )
then 137 write(*,*)
'xxx ATMOS_PHY_TB_TYPE is not MYNN. Check!' 144 read(
io_fid_conf,nml=param_atmos_phy_tb_mynn,iostat=ierr)
146 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 147 elseif( ierr > 0 )
then 148 write(*,*)
'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_TB_MYNN. Check!' 156 if ( atmos_phy_tb_mynn_pbl_max >= cz(k,i,j) )
then 163 a1 = b1 * (1.0_rp - 3.0_rp * g1) / 6.0_rp
164 a2 = 1.0_rp / (3.0_rp * g1 * b1**(1.0_rp/3.0_rp) * prn )
165 c1 = g1 - 1.0_rp / ( 3.0_rp * a1 * b1**(1.0_rp/3.0_rp) )
166 g2 = ( 2.0_rp * a1 * (3.0_rp - 2.0_rp * c2) + b2 * (1.0_rp - c3) ) / b1
167 f1 = b1 * (g1 - c1) + 2.0_rp * a1 * (3.0_rp - 2.0_rp * c2) + 3.0_rp * a2 * (1.0_rp - c2) * (1.0_rp - c5)
168 f2 = b1 * (g1 + g2) - 3.0_rp * a1 * (1.0_rp - c2)
170 rf1 = b1 * (g1 - c1) / f1
174 af12 = a1 * f1 / ( a2 * f2 )
176 sqrt_2pi = sqrt( 2.0_rp * pi )
177 rsqrt_2pi = 1.0_rp / sqrt_2pi
178 rsqrt_2 = 1.0_rp / sqrt( 2.0_rp )
185 qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, & ! (out)
186 qflx_sgs_rhot, qflx_sgs_rhoq, &
188 tke_t, nu, ri, pr, n2, &
189 momz, momx, momy, rhot, dens, qtrc, &
190 sflx_mw, sflx_mu, sflx_mv, sflx_sh, sflx_qv, &
191 gsqrt, j13g, j23g, j33g, mapf, dt )
225 atmos_thermodyn_temp_pres, &
226 atmos_thermodyn_templhv, &
227 atmos_thermodyn_templhs
229 atmos_saturation_alpha, &
230 atmos_saturation_pres2qsat => atmos_saturation_pres2qsat_all
237 real(RP),
intent(out) :: qflx_sgs_momz(
ka,
ia,
ja,3)
238 real(RP),
intent(out) :: qflx_sgs_momx(
ka,
ia,
ja,3)
239 real(RP),
intent(out) :: qflx_sgs_momy(
ka,
ia,
ja,3)
240 real(RP),
intent(out) :: qflx_sgs_rhot(
ka,
ia,
ja,3)
241 real(RP),
intent(out) :: qflx_sgs_rhoq(
ka,
ia,
ja,3,
qa)
243 real(RP),
intent(inout) :: tke (
ka,
ia,
ja)
244 real(RP),
intent(out) :: tke_t(
ka,
ia,
ja)
245 real(RP),
intent(out) :: Nu(
ka,
ia,
ja)
246 real(RP),
intent(out) :: Ri(
ka,
ia,
ja)
247 real(RP),
intent(out) :: Pr(
ka,
ia,
ja)
248 real(RP),
intent(out) :: N2(
ka,
ia,
ja)
250 real(RP),
intent(in) :: MOMZ(
ka,
ia,
ja)
251 real(RP),
intent(in) :: MOMX(
ka,
ia,
ja)
252 real(RP),
intent(in) :: MOMY(
ka,
ia,
ja)
253 real(RP),
intent(in) :: RHOT(
ka,
ia,
ja)
254 real(RP),
intent(in) :: DENS(
ka,
ia,
ja)
255 real(RP),
intent(in) :: QTRC(
ka,
ia,
ja,
qa)
257 real(RP),
intent(in) :: SFLX_MW(
ia,
ja)
258 real(RP),
intent(in) :: SFLX_MU(
ia,
ja)
259 real(RP),
intent(in) :: SFLX_MV(
ia,
ja)
260 real(RP),
intent(in) :: SFLX_SH(
ia,
ja)
261 real(RP),
intent(in) :: SFLX_QV(
ia,
ja)
263 real(RP),
intent(in) :: GSQRT (
ka,
ia,
ja,7)
264 real(RP),
intent(in) :: J13G (
ka,
ia,
ja,7)
265 real(RP),
intent(in) :: J23G (
ka,
ia,
ja,7)
266 real(RP),
intent(in) :: J33G
267 real(RP),
intent(in) :: MAPF (
ia,
ja,2,4)
268 real(DP),
intent(in) :: dt
272 real(RP) :: phiN(
ka,
ia,
ja)
279 real(RP) :: dudz2(
ka,
ia,
ja)
280 real(RP) :: q2_2(
ka,
ia,
ja)
282 real(RP) :: RHOKh (
ka,
ia,
ja)
284 real(RP) :: SFLX_PT(
ia,
ja)
291 real(RP) :: tke_N(
ka,
ia,
ja)
293 real(RP) :: POTT(
ka,
ia,
ja)
294 real(RP) :: POTV(
ka,
ia,
ja)
295 real(RP) :: POTL(
ka,
ia,
ja)
296 real(RP) :: TEML(
ka,
ia,
ja)
303 real(RP) :: temp(
ka,
ia,
ja)
304 real(RP) :: pres(
ka,
ia,
ja)
309 real(RP) :: alpha(
ka,
ia,
ja)
325 real(RP) :: flux_z(
ka,
ia,
ja)
326 real(RP) :: flux_x(
ka,
ia,
ja)
327 real(RP) :: flux_y(
ka,
ia,
ja)
336 integer :: k, i, j, iq
337 integer :: IIS, IIE, JJS, JJE
339 if (
io_l )
write(
io_fid_log, *)
"*** Physics step: Turbulence (MYNN)" 351 qflx_sgs_momz(k,i,j,
xdir) = 0.0_rp
359 qflx_sgs_momx(k,i,j,
xdir) = 0.0_rp
368 qflx_sgs_momy(k,i,j,
xdir) = 0.0_rp
376 qflx_sgs_rhot(k,i,j,
xdir) = 0.0_rp
385 qflx_sgs_rhoq(k,i,j,
xdir,iq) = 0.0_rp
395 qflx_sgs_momz(k,i,j,
ydir) = 0.0_rp
403 qflx_sgs_momx(k,i,j,
ydir) = 0.0_rp
411 qflx_sgs_momy(k,i,j,
ydir) = 0.0_rp
419 qflx_sgs_rhot(k,i,j,
ydir) = 0.0_rp
428 qflx_sgs_rhoq(k,i,j,
ydir,iq) = 0.0_rp
437 qflx_sgs_momz(k,i,j,
zdir) = 0.0_rp
446 qflx_sgs_rhoq(k,i,j,
zdir,iq) = 0.0_rp
463 u(k,i,j) = 0.5_rp * ( momx(k,i,j) + momx(k,i-1,j) ) / dens(k,i,j)
472 v(k,i,j) = 0.5_rp * ( momy(k,i,j) + momy(k,i,j-1) ) / dens(k,i,j)
480 call atmos_thermodyn_temp_pres( temp, pres, &
484 call atmos_thermodyn_templhv( lhv, temp )
485 call atmos_thermodyn_templhs( lhs, temp )
486 call atmos_saturation_alpha( alpha, temp )
493 if (
i_qc > 0 ) ql = qtrc(k,i,j,
i_qc)
498 if (
i_qi > 0 ) qs = qtrc(k,i,j,
i_qi)
504 qdry = qdry - qtrc(k,i,j,iq)
507 qw(k,i,j) = qtrc(k,i,j,
i_qv) + ql + qs
509 lh(k,i,j) = lhv(k,i,j) * alpha(k,i,j) + lhs(k,i,j) * ( 1.0_rp-alpha(k,i,j) )
511 pott(k,i,j) = rhot(k,i,j) / dens(k,i,j)
513 potl(k,i,j) = pott(k,i,j) * (1.0_rp - 1.0_rp * (lhv(k,i,j) * ql + lhs(k,i,j) * qs) / ( temp(k,i,j) * cp ) )
514 teml(k,i,j) = potl(k,i,j) * temp(k,i,j) / pott(k,i,j)
518 potv(k,i,j) = ( qdry + (epstvap+1.0_rp) * qtrc(k,i,j,
i_qv) ) * potl(k,i,j)
522 sflx_pt(i,j) = sflx_sh(i,j) / ( cp * dens(
ks,i,j) ) &
523 * pott(
ks,i,j) / temp(
ks,i,j)
525 n2(
ks,i,j) = min(atmos_phy_tb_mynn_n2_max, &
526 grav * ( potv(
ks+1,i,j) - potv(
ks,i,j) ) &
527 / ( ( cz(
ks+1,i,j)-cz(
ks,i,j) ) * potv(
ks,i,j) ) )
529 n2(k,i,j) = min(atmos_phy_tb_mynn_n2_max, &
530 grav * ( potv(k+1,i,j) - potv(k-1,i,j) ) &
531 / ( ( cz(k+1,i,j)-cz(k-1,i,j) ) * potv(k,i,j) ) )
534 dudz2(
ks,i,j) = ( ( u(
ks+1,i,j) - u(
ks,i,j) )**2 + ( v(
ks+1,i,j) - v(
ks,i,j) )**2 ) &
535 / ( cz(
ks+1,i,j) - cz(
ks,i,j) )**2
537 dudz2(k,i,j) = ( ( u(k+1,i,j) - u(k-1,i,j) )**2 + ( v(k+1,i,j) - v(k-1,i,j) )**2 ) &
538 / ( cz(k+1,i,j) - cz(k-1,i,j) )**2
542 ri(k,i,j) = n2(k,i,j) / max(dudz2(k,i,j), 1e-10_rp)
548 if ( atmos_phy_tb_mynn_tke_init )
then 553 q(k,i,j) = sqrt( tke_min*2.0_rp )
562 q(k,i,j) = sqrt( max(tke(k,i,j), tke_min)*2.0_rp )
573 sflx_mu, sflx_mv, sflx_pt, &
580 if ( atmos_phy_tb_mynn_tke_init )
then 585 tke(k,i,j) = max(q2_2(k,i,j) * 0.5_rp, tke_min)
586 q(k,i,j) = sqrt( tke(k,i,j) * 2.0_rp )
598 call comm_vars8(tke, 1)
599 call comm_wait (tke, 1)
601 atmos_phy_tb_mynn_tke_init = .false.
604 call get_smsh( sm, sh, &
608 call atmos_saturation_pres2qsat( qsl(
ks:ke_pbl,:,:), &
609 teml(
ks:ke_pbl,:,:), pres(
ks:ke_pbl,:,:), &
617 dqsl = qsl(k,i,j) * lh(k,i,j) / ( rvap * potl(k,i,j)**2 )
618 aa = 1.0_rp / ( 1.0_rp + lh(k,i,j)/cp * dqsl )
619 bb = temp(k,i,j) / pott(k,i,j) * dqsl
620 ac = min( q(k,i,j)/sqrt(q2_2(k,i,j)), 1.0_rp )
621 sigma_s = max( sqrt( 0.25_rp * aa**2 * l(k,i,j)**2 * ac * b2 * sh(k,i,j) ) &
622 * abs( qw(k+1,i,j) - qw(k-1,i,j) - bb * ( potl(k+1,i,j)-potl(k-1,i,j) ) ) &
623 / ( cz(k+1,i,j) - cz(k-1,i,j) ), &
625 q1 = aa * ( qw(k,i,j) - qsl(k,i,j) ) * 0.5_rp / sigma_s
626 rr = min( max( 0.5_rp * ( 1.0_rp + erf(q1*rsqrt_2) ), 0.0_rp ), 1.0_rp )
627 ql = min( max( 2.0_rp * sigma_s * ( rr * q1 + rsqrt_2pi * exp(-0.5_rp*q1**2) ), &
630 cc = ( 1.0_rp + epstvap * qw(k,i,j) - (1.0_rp+epstvap) * ql ) * pott(k,i,j)/temp(k,i,j) * lh(k,i,j) / cp &
631 - (1.0_rp+epstvap) * pott(k,i,j)
632 rt = min( max( rr - ql / (2.0_rp*sigma_s*sqrt_2pi) * exp(-q1**2 * 0.5_rp), 0.0_rp ), 1.0_rp )
633 betat = 1.0_rp + epstvap * qw(k,i,j) - (1.0_rp+epstvap) * ql - rt * aa * bb * cc
634 betaq = epstvap * pott(k,i,j) + rt * aa * cc
635 n2(k,i,j) = min(atmos_phy_tb_mynn_n2_max, &
636 grav * ( ( potl(k+1,i,j) - potl(k-1,i,j) ) * betat &
637 + ( qw(k+1,i,j) - qw(k-1,i,j) ) * betaq ) &
638 / ( cz(k+1,i,j) - cz(k-1,i,j) ) / potv(k,i,j) )
640 n2(
ks,i,j) = n2(
ks+1,i,j)
643 ri(k,i,j) = n2(k,i,j) / max(dudz2(k,i,j), 1e-10_rp)
658 sflx_mu, sflx_mv, sflx_pt, &
677 nu(k,i,j) = max( min( l(k,i,j) * q(k,i,j) * sm(k,i,j), &
678 atmos_phy_tb_mynn_nu_max ), &
679 atmos_phy_tb_mynn_nu_min )
686 kh = max( min( l(k,i,j) * q(k,i,j) * sh(k,i,j), &
687 atmos_phy_tb_mynn_kh_max ), &
688 atmos_phy_tb_mynn_kh_min )
689 rhokh(k,i,j) = dens(k,i,j) * kh
690 pr(k,i,j) = nu(k,i,j) / kh
698 call comm_vars( nu, 1 )
707 ap = - dt * 0.5_rp * ( dens(
ks ,i,j)*nu(
ks ,i,j) &
708 + dens(
ks+1,i,j)*nu(
ks+1,i,j) ) &
710 a(
ks,i,j) = ap * rcdz(
ks) / ( dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
712 b(
ks,i,j) = - a(
ks,i,j) + 1.0_rp
713 do k =
ks+1, ke_pbl-1
714 c(k,i,j) = ap * rcdz(k) / ( dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
715 ap = - dt * 0.5_rp * ( dens(k ,i,j)*nu(k ,i,j) &
716 + dens(k+1,i,j)*nu(k+1,i,j) ) &
717 * rfdz(k) / gsqrt(k,i,j,
i_xyw)
718 a(k,i,j) = ap * rcdz(k) / ( dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
719 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 1.0_rp
721 a(ke_pbl,i,j) = 0.0_rp
722 c(ke_pbl,i,j) = ap * rcdz(ke_pbl) / ( dens(ke_pbl,i,j) * gsqrt(ke_pbl,i,j,
i_xyz) )
723 b(ke_pbl,i,j) = - c(ke_pbl,i,j) + 1.0_rp
725 d(
ks,i,j) = u(
ks,i,j) + dt * sflx_mu(i,j) * rcdz(
ks) / ( dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
729 call diffusion_solver( &
731 a(:,i,j), b(:,i,j), c(:,i,j), d(:,i,j), &
736 call comm_vars( phin, 2 )
737 call comm_wait( nu, 1 )
738 call comm_wait( phin, 2 )
749 qflx_sgs_momx(k,i,j,
zdir) = - 0.03125_rp &
750 * ( dens(k,i,j) + dens(k+1,i,j) + dens(k,i+1,j) + dens(k+1,i+1,j) ) &
751 * ( nu(k,i,j) + nu(k+1,i,j) + nu(k,i+1,j) + nu(k+1,i+1,j) ) &
752 * ( (phin(k+1,i,j)+phin(k+1,i+1,j)) - (phin(k,i,j)+phin(k,i+1,j)) ) &
753 * j33g * rfdz(k) / gsqrt(k,i,j,
i_uyw)
759 qflx_sgs_momx(
ks-1,i,j,
zdir) = 0.0_rp
765 qflx_sgs_momx(k,i,j,
zdir) = 0.0_rp
775 d(
ks,i,j) = v(
ks,i,j) + dt * sflx_mv(i,j) * rcdz(
ks) / ( dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
779 call diffusion_solver( &
781 a(:,i,j), b(:,i,j), c(:,i,j), d(:,i,j), &
789 call comm_vars( phin, 1 )
790 call comm_wait( phin, 1 )
799 qflx_sgs_momy(
ks-1,i,j,
zdir) = 0.0_rp
801 qflx_sgs_momy(k,i,j,
zdir) = - 0.03125_rp &
802 * ( dens(k,i,j) + dens(k+1,i,j) + dens(k,i,j+1) + dens(k+1,i,j+1) ) &
803 * ( nu(k,i,j) + nu(k+1,i,j) + nu(k,i,j+1) + nu(k+1,i,j+1) ) &
804 * ( (phin(k+1,i,j)+phin(k+1,i,j+1)) - (phin(k,i,j)+phin(k,i,j+1)) ) &
805 * j33g * rfdz(k) / gsqrt(k,i,j,
i_xvw)
808 qflx_sgs_momy(k,i,j,
zdir) = 0.0_rp
819 ap = - dt * 0.5_rp * ( rhokh(
ks,i,j) + rhokh(
ks+1,i,j) ) &
821 a(
ks,i,j) = ap * rcdz(
ks) / (dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
823 b(
ks,i,j) = - a(
ks,i,j) + 1.0_rp
824 do k =
ks+1, ke_pbl-1
825 c(k,i,j) = ap * rcdz(k) / (dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
826 ap = - dt * 0.5_rp * ( rhokh(k,i,j) + rhokh(k+1,i,j) ) &
827 * rfdz(k) / gsqrt(k,i,j,
i_xyw)
828 a(k,i,j) = ap * rcdz(k) / ( dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
829 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 1.0_rp
831 a(ke_pbl,i,j) = 0.0_rp
832 c(ke_pbl,i,j) = ap * rcdz(ke_pbl) / (dens(ke_pbl,i,j) * gsqrt(ke_pbl,i,j,
i_xyz) )
833 b(ke_pbl,i,j) = - c(ke_pbl,i,j) + 1.0_rp
834 d(
ks,i,j) = potl(
ks,i,j) + dt * sflx_pt(i,j) * rcdz(
ks) / gsqrt(
ks,i,j,
i_xyz)
836 d(k,i,j) = potl(k,i,j)
838 call diffusion_solver( &
840 a(:,i,j), b(:,i,j), c(:,i,j), d(:,i,j), &
847 qflx_sgs_rhot(
ks-1,i,j,
zdir) = 0.0_rp
849 qflx_sgs_rhot(k,i,j,
zdir) = - 0.5_rp &
850 * ( rhokh(k,i,j) + rhokh(k+1,i,j) ) &
851 * j33g * ( phin(k+1,i,j) - phin(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_xyw)
854 qflx_sgs_rhot(k,i,j,
zdir) = 0.0_rp
865 d(
ks,i,j) = qw(
ks,i,j) + dt * sflx_qv(i,j) * rcdz(
ks) / ( dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
869 call diffusion_solver( &
871 a(:,i,j), b(:,i,j), c(:,i,j), d(:,i,j), &
878 qflx_sgs_rhoq(
ks-1,i,j,
zdir,iq) = 0.0_rp
880 qflx_sgs_rhoq(k,i,j,
zdir,iq) = - 0.5_rp &
881 * ( rhokh(k,i,j) + rhokh(k+1,i,j) ) &
882 * j33g * ( phin(k+1,i,j) - phin(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_xyw)
885 qflx_sgs_rhoq(k,i,j,
zdir,iq) = 0.0_rp
896 mflx = j33g * momz(k,i,j) / ( mapf(i,j,1,
i_xy)*mapf(i,j,2,
i_xy) ) &
897 + j13g(k,i,j,
i_xyw) * 0.25_rp * ( momx(k,i-1,j)+momx(k,i,j)+momx(k+1,i-1,j)+momx(k+1,i,j) ) / mapf(i,j,2,
i_xy) &
898 + j23g(k,i,j,
i_xyw) * 0.25_rp * ( momy(k,i,j-1)+momy(k,i,j)+momy(k+1,i,j-1)+momy(k+1,i,j) ) / mapf(i,j,1,
i_xy)
899 flux_z(k,i,j) = 0.5_rp * ( mflx * ( tke(k+1,i,j)+tke(k,i,j) ) &
900 -abs(mflx) * ( tke(k+1,i,j)-tke(k,i,j) ) )
907 mflx = momx(k,i,j) * gsqrt(k,i,j,
i_uyz) / mapf(i,j,2,
i_uy)
908 flux_x(k,i,j) = 0.5_rp * ( mflx * ( tke(k,i+1,j)+tke(k,i,j) ) &
909 -abs(mflx) * ( tke(k,i+1,j)-tke(k,i,j) ) )
916 mflx = momy(k,i,j) * gsqrt(k,i,j,
i_xvz) / mapf(i,j,1,
i_xv)
917 flux_y(k,i,j) = 0.5_rp * ( mflx * ( tke(k,i,j+1)+tke(k,i,j) ) &
918 -abs(mflx) * ( tke(k,i,j+1)-tke(k,i,j) ) )
925 advc = ( ( flux_z(
ks,i,j) ) * rcdz(
ks) &
926 + ( flux_x(
ks,i,j) - flux_x(
ks,i-1,j) ) * rcdx(i) &
927 + ( flux_y(
ks,i,j) - flux_y(
ks,i,j-1) ) * rcdy(j) ) &
928 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy) / ( gsqrt(
ks,i,j,
i_xyz) * dens(
ks,i,j) )
929 d(
ks,i,j) = tke(
ks,i,j) + dt * ( nu(
ks,i,j) * (dudz2(
ks,i,j) - n2(
ks,i,j)/pr(
ks,i,j)) &
933 gen(
ks,i,j) = nu(
ks,i,j) * (dudz2(
ks,i,j) - n2(
ks,i,j)/pr(
ks,i,j))
935 do k =
ks+1, ke_pbl-1
936 advc = ( ( flux_z(k,i,j) - flux_z(k-1,i,j) ) * rcdz(k) &
937 + ( flux_x(k,i,j) - flux_x(k,i-1,j) ) * rcdx(i) &
938 + ( flux_y(k,i,j) - flux_y(k,i,j-1) ) * rcdy(j) ) &
939 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy) / ( gsqrt(k,i,j,
i_xyz) * dens(k,i,j) )
940 d(k,i,j) = tke(k,i,j) &
941 + dt * ( nu(k,i,j) * (dudz2(k,i,j) - n2(k,i,j)/pr(k,i,j)) &
945 gen(k,i,j) = nu(k,i,j) * (dudz2(k,i,j) - n2(k,i,j)/pr(k,i,j))
948 advc = ( ( - flux_z(ke_pbl-1,i,j) ) * rcdz(ke_pbl) &
949 + ( flux_x(ke_pbl,i,j) - flux_x(ke_pbl,i-1,j) ) * rcdx(i) &
950 + ( flux_y(ke_pbl,i,j) - flux_y(ke_pbl,i,j-1) ) * rcdy(j) ) &
951 * mapf(i,j,1,
i_xy) * mapf(i,j,2,
i_xy) / ( gsqrt(ke_pbl,i,j,
i_xyz) * dens(ke_pbl,i,j) )
952 d(ke_pbl,i,j) = tke(ke_pbl,i,j) + dt * ( nu(ke_pbl,i,j) * (dudz2(ke_pbl,i,j) - n2(ke_pbl,i,j)/pr(ke_pbl,i,j)) &
955 adv(ke_pbl,i,j) = advc
956 gen(ke_pbl,i,j) = nu(ke_pbl,i,j) * (dudz2(ke_pbl,i,j) - n2(ke_pbl,i,j)/pr(ke_pbl,i,j))
964 ap = - dt * 1.5_rp * ( dens(
ks ,i,j)*nu(
ks ,i,j) &
965 + dens(
ks+1,i,j)*nu(
ks+1,i,j) ) &
967 a(
ks,i,j) = ap * rcdz(
ks) / ( dens(
ks,i,j) * gsqrt(
ks,i,j,
i_xyz) )
969 b(
ks,i,j) = - a(
ks,i,j) + 1.0_rp + 2.0_rp * dt * q(
ks,i,j) / ( b1 * l(
ks,i,j) )
970 do k =
ks+1, ke_pbl-1
971 c(k,i,j) = ap * rcdz(k) / ( dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
972 ap = - dt * 1.5_rp * ( dens(k ,i,j)*nu(k ,i,j) &
973 + dens(k+1,i,j)*nu(k+1,i,j)) &
974 * rfdz(k) / gsqrt(k,i,j,
i_xyw)
975 a(k,i,j) = ap * rcdz(k) / ( dens(k,i,j) * gsqrt(k,i,j,
i_xyz) )
976 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 1.0_rp + 2.0_rp * dt * q(k,i,j) / ( b1 * l(k,i,j) )
979 a(ke_pbl,i,j) = 0.0_rp
980 c(ke_pbl,i,j) = ap * rcdz(ke_pbl) / ( dens(ke_pbl,i,j) * gsqrt(ke_pbl,i,j,
i_xyz) )
981 b(ke_pbl,i,j) = - c(ke_pbl,i,j) + 1.0_rp + 2.0_rp * dt * q(ke_pbl,i,j) / ( b1 * l(ke_pbl,i,j) )
982 call diffusion_solver( &
984 a(:,i,j), b(:,i,j), c(:,i,j), d(:,i,j), &
987 do k =
ks+1, ke_pbl-1
988 tke(1,i,j) = d(k,i,j) &
989 + ( ( (tke_n(k+1,i,j)-tke_n(k,i,j)) * rfdz(k) / gsqrt(k,i,j,
i_xyw) &
990 * (nu(k+1,i,j)*dens(k+1,i,j)+nu(k,i,j)*dens(k,i,j))*1.5_rp &
991 - (tke_n(k,i,j)-tke_n(k-1,i,j)) * rfdz(k-1) / gsqrt(k-1,i,j,
i_xyw) &
992 * (nu(k,i,j)*dens(k,i,j)+nu(k-1,i,j)*dens(k-1,i,j))*1.5_rp ) &
993 * rcdz(k) / gsqrt(k,i,j,
i_xyz) / dens(k,i,j) &
994 - 2.0_rp*tke_n(k,i,j) * q(k,i,j) / (b1 * l(k,i,j)) ) &
996 if ( tke_n(k,i,j) > 0.1_rp .AND. abs(tke(1,i,j) - tke_n(k,i,j))/tke_n(k,i,j) > 1e-10_rp )
then 997 advc = ( tke(k,i,j) - d(k,i,j) ) / dt + nu(k,i,j) * (dudz2(k,i,j) - n2(k,i,j)/pr(k,i,j))
998 write(*,*)k,i,j,tke(1,i,j),tke_n(k,i,j), tke(k,i,j),nu(k,i,j),dudz2(k,i,j),n2(k,i,j),pr(k,i,j),advc
999 open(90, file=
"mynn.dat")
1000 write(90,*)ke_pbl-
ks+1
1002 write(90,*)tke(
ks:ke_pbl,i,j)
1003 write(90,*)q(
ks:ke_pbl,i,j)
1004 write(90,*)l(
ks:ke_pbl,i,j)
1005 write(90,*)rcdz(
ks:ke_pbl)
1006 write(90,*)rfdz(
ks:ke_pbl)
1007 write(90,*)nu(
ks:ke_pbl,i,j)
1008 write(90,*)dens(
ks:ke_pbl,i,j)
1009 write(90,*)dudz2(
ks:ke_pbl,i,j)
1010 write(90,*)n2(
ks:ke_pbl,i,j)
1011 write(90,*)pr(
ks:ke_pbl,i,j)
1018 tke_t(k,i,j) = ( max(tke_n(k,i,j), tke_min) - tke(k,i,j) ) / dt
1021 tke_t(k,i,j) = 0.0_rp
1030 adv(ke_pbl+1:
ke,:,:) = 0.0_rp
1031 gen(ke_pbl+1:
ke,:,:) = 0.0_rp
1032 dudz2(ke_pbl+1:
ke,:,:) = 0.0_rp
1033 l(ke_pbl+1:
ke,:,:) = 0.0_rp
1034 potv(ke_pbl+1:
ke,:,:) = 0.0_rp
1035 potl(ke_pbl+1:
ke,:,:) = 0.0_rp
1036 call hist_in(adv,
'TKE_advc',
'advection of TKE',
'm2/s3', nohalo=.true.)
1037 call hist_in(gen,
'TKE_gen',
'generation of TKE',
'm2/s3', nohalo=.true.)
1038 call hist_in(dudz2,
'dUdZ2',
'dudz2',
'm2/s2', nohalo=.true.)
1039 call hist_in(l,
'L_mix',
'minxing length',
'm', nohalo=.true.)
1040 call hist_in(potv,
'POTV',
'virtual potential temperature',
'K', nohalo=.true.)
1041 call hist_in(potl,
'POTL',
'liquid potential temperature',
'K', nohalo=.true.)
1051 SFLX_MU, SFLX_MV, SFLX_PT, &
1062 real(RP),
intent(out) :: l(
ka,
ia,
ja)
1063 real(RP),
intent(in) :: DENS(
ka,
ia,
ja)
1064 real(RP),
intent(in) :: q(
ka,
ia,
ja)
1065 real(RP),
intent(in) :: n2(
ka,
ia,
ja)
1066 real(RP),
intent(in) :: SFLX_MU(
ia,
ja)
1067 real(RP),
intent(in) :: SFLX_MV(
ia,
ja)
1068 real(RP),
intent(in) :: SFLX_PT(
ia,
ja)
1069 real(RP),
intent(in) :: PT0(
ka,
ia,
ja)
1096 qdz = q(k,i,j) * ( fz(k,i,j) - fz(k-1,i,j) )
1097 int_qz = int_qz + ((fz(k,i,j)+fz(k-1,i,j))*0.5_rp-fz(
ks-1,i,j)) * qdz
1101 lt = min( max(0.23_rp * int_qz / (int_q + eps), &
1103 atmos_phy_tb_mynn_lt_max )
1106 us = ( sflx_mu(i,j)**2 + sflx_mv(i,j)**2 )**0.25_rp / dens(
ks,i,j)
1107 us = max(us, us_min)
1108 rlm = - karman * grav * sflx_pt(i,j) / (pt0(
ks,i,j) * us**3 )
1110 qc = (grav/pt0(
ks,i,j)*max(sflx_pt(i,j),0.0_rp)*lt)**oneoverthree
1113 z = ( fz(k,i,j)+fz(k-1,i,j) )*0.5_rp - fz(
ks-1,i,j)
1117 sw = sign(0.5_rp, zeta) + 0.5_rp
1119 * ( sw / (1.0_rp + 2.7_rp*min(zeta,1.0_rp)*sw ) &
1120 + ( (1.0_rp - 100.0_rp*zeta)*(1.0_rp-sw) )**0.2_rp )
1123 sw = sign(0.5_rp, n2(k,i,j)) + 0.5_rp
1124 rn2sr = 1.0_rp / ( sqrt(n2(k,i,j)*sw) + 1.0_rp-sw)
1125 lb = (1.0_rp + 5.0_rp * sqrt(qc*rn2sr/lt)) * q(k,i,j) * rn2sr * sw &
1126 + 999.e10_rp * (1.0_rp-sw)
1129 l(k,i,j) = 1.0_rp / ( 1.0_rp/ls + rlt + 1.0_rp/lb )
1142 real(RP),
intent(out) :: q2_2(
ka,
ia,
ja)
1143 real(RP),
intent(in) :: dudz2(
ka,
ia,
ja)
1144 real(RP),
intent(in) :: Ri(
ka,
ia,
ja)
1145 real(RP),
intent(in) :: l(
ka,
ia,
ja)
1158 rf = min(0.5_rp / af12 * ( ri(k,i,j) &
1160 - sqrt(ri(k,i,j)**2 + 2.0_rp*af12*(rf1-2.0_rp*rf2)*ri(k,i,j) + (af12*rf1)**2) ), &
1162 sh_2 = 3.0_rp * a2 * (g1+g2) * (rfc-rf) / (1.0_rp-rf)
1163 sm_2 = sh_2 * af12 * (rf1-rf) / (rf2-rf)
1164 q2 = b1 * l(k,i,j)**2 * sm_2 * (1.0_rp-rf) * dudz2(k,i,j)
1165 q2_2(k,i,j) = max( q2, 1.e-10_rp )
1173 subroutine get_smsh( &
1178 real(RP),
intent(out) :: sm(
ka,
ia,
ja)
1179 real(RP),
intent(out) :: sh(
ka,
ia,
ja)
1180 real(RP),
intent(in) :: q(
ka,
ia,
ja)
1181 real(RP),
intent(in) :: q2_2(
ka,
ia,
ja)
1182 real(RP),
intent(in) :: l(
ka,
ia,
ja)
1183 real(RP),
intent(in) :: n2(
ka,
ia,
ja)
1184 real(RP),
intent(in) :: dudz2(
ka,
ia,
ja)
1205 ac = min(q(k,i,j)/sqrt(q2_2(k,i,j)), 1.0_rp)
1207 l2q2 = ( l(k,i,j) / q(k,i,j) )**2
1208 gh = - n2(k,i,j) * l2q2
1210 p1 = 1.0_rp - 3.0_rp * ac2 * a2 * b2 * (1.0_rp-c3) * gh
1211 p2 = 1.0_rp - 9.0_rp * ac2 * a1 * a2 * (1.0_rp-c2) * gh
1212 p3 = p1 + 9.0_rp * ac2 * a2**2 * (1.0_rp-c2) * (1.0_rp-c5) * gh
1213 p4 = p1 - 12.0_rp * ac2 * a1 * a2 * (1.0_rp-c2) * gh
1214 p5 = 6.0_rp * ac2 * a1**2 * dudz2(k,i,j) * l2q2
1216 rd25 = 1.0_rp / max(p2 * p4 + p5 * p3, 1.e-20_rp)
1217 sm(k,i,j) = max( ac * a1 * (p3 - 3.0_rp * c1 * p4) * rd25, 0.0_rp )
1218 sh(k,i,j) = max( ac * a2 * (p2 + 3.0_rp * c1 * p5) * rd25, 0.0_rp )
1225 end subroutine get_smsh
1228 real(RP),
parameter :: a = 0.1400122886866665_rp
1229 real(RP),
parameter :: fourpi = 1.2732395447351628_rp
1231 real(RP),
intent(in) :: x
1237 erf = sign( sqrt( 1.0_rp - exp(-x2 * (fourpi+a*x2)/(1.0_rp+a*x2) ) ), x )
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
real(rp), dimension(:), allocatable, public grid_rcdy
reciprocal of center-dy
real(rp), public const_cpdry
specific heat (dry air,constant pressure) [J/kg/K]
module ATMOSPHERE / Saturation adjustment
subroutine, public prc_mpistop
Abort MPI.
subroutine, public atmos_phy_tb_diffusion_solver(phi, a, b, c, d, KE_TB)
integer, public iblock
block size for cache blocking: x
logical, public io_l
output log or not? (this process)
real(rp), dimension(:), allocatable, public grid_rcdx
reciprocal of center-dx
integer, parameter, public zdir
subroutine, public atmos_phy_tb_mynn(qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, qflx_sgs_rhot, qflx_sgs_rhoq, tke, tke_t, Nu, Ri, Pr, N2, MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_QV, GSQRT, J13G, J23G, J33G, MAPF, dt)
subroutine get_length(l, DENS, q, n2, SFLX_MU, SFLX_MV, SFLX_PT, PT0)
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
real(rp), dimension(:,:,:), allocatable, public real_fz
geopotential height [m] (cell face )
subroutine get_q2_level2(q2_2, dudz2, Ri, l)
real(rp), dimension(:,:,:), allocatable, public real_cz
geopotential height [m] (cell center)
subroutine, public check(current_line, v)
Undefined value checker.
real(rp), dimension(:), allocatable, public grid_rcdz
reciprocal of center-dz
real(rp), parameter, public const_karman
von Karman constant
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
real(rp), public const_undef
subroutine, public atmos_phy_tb_mynn_setup(TYPE_TB, CDZ, CDX, CDY, CZ)
integer, public ia
of x whole cells (local, with HALO)
integer, public ka
of z whole cells (local, with HALO)
integer, public jblock
block size for cache blocking: 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)
real(rp), public const_epstvap
1 / epsilon - 1
real(rp), parameter, public const_rvap
specific gas constant (water vapor) [J/kg/K]
integer, public ks
start point of inner domain: z, local
module ATMOSPHERE / Physics Turbulence
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
module ATMOSPHERE / Thermodynamics
logical, public io_lnml
output log or not? (for namelist, this process)
real(rp), public const_pi
pi
real(rp), dimension(:), allocatable, public grid_rfdz
reciprocal of face-dz
integer, public io_fid_conf
Config file ID.
integer, public io_fid_log
Log file ID.
module ATMOSPHERE / Physics Turbulence
integer, public ja
of y whole cells (local, with HALO)