27 #if defined DEBUG || defined QUICKDEBUG
44 public :: atmos_phy_bl_mynn_tendency_tracer
63 integer,
private,
parameter :: i_tke = 1
64 integer,
private,
parameter :: i_tsq = 2
65 integer,
private,
parameter :: i_qsq = 3
66 integer,
private,
parameter :: i_cov = 4
68 real(
rp),
private,
parameter :: oneoverthree = 1.0_rp / 3.0_rp
69 real(
rp),
private,
parameter :: lt_min = 1.e-6_rp
70 real(
rp),
private,
parameter :: flx_lim_fact = 0.5_rp
72 real(
rp),
private :: a1
73 real(
rp),
private :: a2
74 real(
rp),
private,
parameter :: b1 = 24.0_rp
75 real(
rp),
private,
parameter :: b2 = 15.0_rp
76 real(
rp),
private :: c1
77 real(
rp),
private,
parameter :: c2 = 0.75_rp
78 real(
rp),
private,
parameter :: c3 = 0.352_rp
79 real(
rp),
private,
parameter :: c5 = 0.2_rp
80 real(
rp),
private,
parameter :: g1 = 0.235_rp
81 real(
rp),
private :: g2
82 real(
rp),
private :: f1
83 real(
rp),
private :: f2
84 real(
rp),
private :: rf1
85 real(
rp),
private :: rf2
86 real(
rp),
private :: rfc
87 real(
rp),
private :: af12
88 real(
rp),
private,
parameter :: prn = 0.74_rp
90 real(
rp),
private,
parameter :: zeta_min = -3.0_rp
91 real(
rp),
private,
parameter :: zeta_max = 1.0_rp
93 real(
rp),
private :: sqrt_2pi
94 real(
rp),
private :: rsqrt_2pi
95 real(
rp),
private :: rsqrt_2
97 logical,
private :: initialize
99 real(
rp),
private :: atmos_phy_bl_mynn_pbl_max = 4.e+3_rp
100 real(
rp),
private :: atmos_phy_bl_mynn_tke_min = 1.e-20_rp
101 real(
rp),
private :: atmos_phy_bl_mynn_n2_max = 1.e1_rp
102 real(
rp),
private :: atmos_phy_bl_mynn_nu_min = -1.e1_rp
103 real(
rp),
private :: atmos_phy_bl_mynn_nu_max = 1.e4_rp
104 real(
rp),
private :: atmos_phy_bl_mynn_kh_min = -1.e1_rp
105 real(
rp),
private :: atmos_phy_bl_mynn_kh_max = 1.e4_rp
106 real(
rp),
private :: atmos_phy_bl_mynn_lt_max = 700.0_rp
107 real(
rp),
private :: atmos_phy_bl_mynn_sq_fact = 3.0_rp
108 logical,
private :: atmos_phy_bl_mynn_init_tke = .false.
109 logical,
private :: atmos_phy_bl_mynn_similarity = .true.
111 character(len=H_SHORT),
private :: atmos_phy_bl_mynn_level =
"2.5"
113 namelist / param_atmos_phy_bl_mynn / &
114 atmos_phy_bl_mynn_pbl_max, &
115 atmos_phy_bl_mynn_n2_max, &
116 atmos_phy_bl_mynn_nu_min, &
117 atmos_phy_bl_mynn_nu_max, &
118 atmos_phy_bl_mynn_kh_min, &
119 atmos_phy_bl_mynn_kh_max, &
120 atmos_phy_bl_mynn_lt_max, &
121 atmos_phy_bl_mynn_level, &
122 atmos_phy_bl_mynn_sq_fact, &
123 atmos_phy_bl_mynn_init_tke, &
124 atmos_phy_bl_mynn_similarity
141 log_info(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Tracer Setup'
142 log_info(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Mellor-Yamada Nakanishi-Niino scheme'
146 read(
io_fid_conf,nml=param_atmos_phy_bl_mynn,iostat=ierr)
148 log_error(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_BL_MYNN. Check!'
152 select case ( atmos_phy_bl_mynn_level )
167 'sub-grid variance of liquid water potential temperature (MYNN) ', &
168 'sub-grid variance of total water content (MYNN) ', &
169 'sub-grid covariance of liquid water potential temperature and total water content (MYNN)' /)
175 log_error(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'only level 2.5 and 3 are supported at this moment'
187 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
196 integer,
intent(in) ::
ka,
ks,
ke
197 integer,
intent(in) ::
ia,
is,
ie
198 integer,
intent(in) ::
ja,
js,
je
200 character(len=*),
intent(in) :: bulkflux_type
202 real(
rp),
intent(in),
optional :: tke_min
203 real(
rp),
intent(in),
optional :: pbl_max
210 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Setup'
211 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Mellor-Yamada Nakanishi-Niino scheme'
213 if (
present(tke_min) ) atmos_phy_bl_mynn_tke_min = tke_min
214 if (
present(pbl_max) ) atmos_phy_bl_mynn_pbl_max = pbl_max
218 read(
io_fid_conf,nml=param_atmos_phy_bl_mynn,iostat=ierr)
220 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Not found namelist. Default used.'
221 elseif( ierr > 0 )
then
222 log_error(
"ATMOS_PHY_BL_MYNN_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_BL_MYNN. Check!'
225 log_nml(param_atmos_phy_bl_mynn)
227 a1 = b1 * (1.0_rp - 3.0_rp * g1) / 6.0_rp
228 a2 = 1.0_rp / (3.0_rp * g1 * b1**(1.0_rp/3.0_rp) * prn )
229 c1 = g1 - 1.0_rp / ( 3.0_rp * a1 * b1**(1.0_rp/3.0_rp) )
230 g2 = ( 2.0_rp * a1 * (3.0_rp - 2.0_rp * c2) + b2 * (1.0_rp - c3) ) / b1
231 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)
232 f2 = b1 * (g1 + g2) - 3.0_rp * a1 * (1.0_rp - c2)
234 rf1 = b1 * (g1 - c1) / f1
238 af12 = a1 * f1 / ( a2 * f2 )
240 sqrt_2pi = sqrt( 2.0_rp * pi )
241 rsqrt_2pi = 1.0_rp / sqrt_2pi
242 rsqrt_2 = 1.0_rp / sqrt( 2.0_rp )
244 if ( atmos_phy_bl_mynn_level ==
"3" )
then
245 log_warn(
"ATMOS_PHY_BL_MYNN_setup", *)
"At this moment, level 3 is still experimental"
248 initialize = atmos_phy_bl_mynn_init_tke
250 select case ( bulkflux_type )
251 case (
"B91",
"B91W01" )
254 atmos_phy_bl_mynn_similarity = .false.
265 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
266 DENS, U, V, POTT, PROG, &
268 QDRY, QV, Qw, POTL, POTV, SFC_DENS, &
269 SFLX_MU, SFLX_MV, SFLX_SH, SFLX_QV, &
273 RHOU_t, RHOV_t, RHOT_t, RHOQV_t, &
275 Nu, Kh, Qlp, cldfrac, Zi )
285 hydrometeor_lhv => atmos_hydrometeor_lhv
287 matrix_solver_tridiagonal
292 integer,
intent(in) ::
ka,
ks,
ke
293 integer,
intent(in) ::
ia,
is,
ie
294 integer,
intent(in) ::
ja,
js,
je
296 real(
rp),
intent(in) :: dens (
ka,
ia,
ja)
297 real(
rp),
intent(in) :: u (
ka,
ia,
ja)
298 real(
rp),
intent(in) :: v (
ka,
ia,
ja)
299 real(
rp),
intent(in) :: pott (
ka,
ia,
ja)
301 real(
rp),
intent(in) :: pres (
ka,
ia,
ja)
302 real(
rp),
intent(in) :: exner (
ka,
ia,
ja)
303 real(
rp),
intent(in) :: n2 (
ka,
ia,
ja)
304 real(
rp),
intent(in) :: qdry (
ka,
ia,
ja)
305 real(
rp),
intent(in) :: qv (
ka,
ia,
ja)
306 real(
rp),
intent(in) :: qw (
ka,
ia,
ja)
307 real(
rp),
intent(in) :: potl (
ka,
ia,
ja)
308 real(
rp),
intent(in) :: potv (
ka,
ia,
ja)
309 real(
rp),
intent(in) :: sfc_dens(
ia,
ja)
310 real(
rp),
intent(in) :: sflx_mu (
ia,
ja)
311 real(
rp),
intent(in) :: sflx_mv (
ia,
ja)
312 real(
rp),
intent(in) :: sflx_sh (
ia,
ja)
313 real(
rp),
intent(in) :: sflx_qv (
ia,
ja)
314 real(
rp),
intent(in) :: us (
ia,
ja)
315 real(
rp),
intent(in) :: ts (
ia,
ja)
316 real(
rp),
intent(in) :: qs (
ia,
ja)
317 real(
rp),
intent(in) :: rlmo (
ia,
ja)
319 real(
rp),
intent(in) :: cz(
ka,
ia,
ja)
320 real(
rp),
intent(in) :: fz(0:
ka,
ia,
ja)
321 real(
dp),
intent(in) :: dt_dp
323 character(len=*),
intent(in) :: bulkflux_type
325 real(
rp),
intent(out) :: rhou_t (
ka,
ia,
ja)
326 real(
rp),
intent(out) :: rhov_t (
ka,
ia,
ja)
327 real(
rp),
intent(out) :: rhot_t (
ka,
ia,
ja)
328 real(
rp),
intent(out) :: rhoqv_t(
ka,
ia,
ja)
330 real(
rp),
intent(out) :: nu (
ka,
ia,
ja)
331 real(
rp),
intent(out) :: kh (
ka,
ia,
ja)
332 real(
rp),
intent(out) :: qlp (
ka,
ia,
ja)
333 real(
rp),
intent(out) :: cldfrac(
ka,
ia,
ja)
334 real(
rp),
intent(out) :: zi (
ia,
ja)
342 real(
rp) :: rho_h(
ka)
350 real(
rp) :: rhonu (
ka)
351 real(
rp) :: rhokh (
ka)
352 real(
rp) :: n2_new(
ka)
355 real(
rp) :: sm25 (
ka)
357 real(
rp) :: sh25 (
ka)
358 real(
rp) :: shpgh (
ka)
359 real(
rp) :: nu_f (
ka)
360 real(
rp) :: kh_f (
ka)
362 real(
rp) :: q2_2 (
ka)
372 real(
rp) :: prod_t(
ka)
373 real(
rp) :: prod_q(
ka)
374 real(
rp) :: prod_c(
ka)
375 real(
rp) :: diss_p(
ka)
377 real(
rp) :: dtldz(
ka)
378 real(
rp) :: dqwdz(
ka)
379 real(
rp) :: betat(
ka)
380 real(
rp) :: betaq(
ka)
382 real(
rp) :: gammat (
ka)
383 real(
rp) :: gammaq (
ka)
384 real(
rp) :: f_gamma(
ka)
386 real(
rp) :: rlqsm_h(
ka)
394 real(
rp) :: phi_n(
ka)
395 real(
rp) :: tke_p(
ka)
396 real(
rp) :: dummy(
ka)
401 real(
rp) :: phi_m, phi_h
405 real(
rp) :: f2h(
ka,2)
408 logical :: mynn_level3
424 log_progress(*)
"atmosphere / physics / pbl / MYNN"
426 mynn_level3 = ( atmos_phy_bl_mynn_level ==
"3" )
461 if ( atmos_phy_bl_mynn_pbl_max >= cz(
k,i,j) - fz(
ks-1,i,j) )
then
468 if ( initialize )
then
475 z1 = cz(
ks,i,j) - fz(
ks-1,i,j)
478 fdz(
k) = cz(
k+1,i,j) - cz(
k ,i,j)
481 cdz(
k) = fz(
k ,i,j) - fz(
k-1,i,j)
491 u(:,i,j), v(:,i,j), potl(:,i,j), qw(:,i,j), &
492 cdz(:), fdz(:), f2h(:,:), &
493 dudz2(:,i,j), dtldz(:), dqwdz(:) )
496 n2_new(
k) = min( max( n2(
k,i,j), - atmos_phy_bl_mynn_n2_max ), atmos_phy_bl_mynn_n2_max )
498 ri(
k,i,j) = n2_new(
k) / dudz2(
k,i,j)
502 q(
k) = sqrt( max( prog(
k,i,j,i_tke), atmos_phy_bl_mynn_tke_min ) * 2.0_rp )
505 if ( mynn_level3 )
then
507 tsq(
k) = max( prog(
k,i,j,i_tsq), 0.0_rp )
508 qsq(
k) = max( prog(
k,i,j,i_qsq), 0.0_rp )
509 cov(
k) = prog(
k,i,j,i_cov)
510 cov(
k) = sign( min( abs(cov(
k)), sqrt(tsq(
k) * qsq(
k))), cov(
k) )
520 if ( initialize .and. it==1 )
then
528 sflx_ptv = - us3 * rlmo(i,j) / karman
533 sflx_ptv, rlmo(i,j), &
538 call get_q2_level2( &
540 dudz2(:,i,j), ri(:,i,j), l(:,i,j), &
543 if ( initialize .and. it==1 )
then
545 q(
k) = sqrt( q2_2(
k) )
550 ac(
k) = min( q(
k) / sqrt( q2_2(
k) + 1e-20_rp ), 1.0_rp )
557 l(:,i,j), n2_new(:), &
558 potv(:,i,j), dudz2(:,i,j), &
559 dtldz(:), dqwdz(:), &
560 betat(:), betaq(:), &
562 tsq(:), qsq(:), cov(:), &
565 gammat(:), gammaq(:), &
570 pres(:,i,j), pott(:,i,j), &
571 potl(:,i,j), qw(:,i,j), &
572 qdry(:,i,j), exner(:,i,j), &
573 dtldz(:), dqwdz(:), &
574 l(:,i,j), sh25(:), ac(:), &
575 tsq(:), qsq(:), cov(:), &
577 betat(:), betaq(:), &
578 qlp(:,i,j), cldfrac(:,i,j) )
580 if ( atmos_phy_bl_mynn_similarity )
then
582 zeta = min( max( z1 * rlmo(i,j), zeta_min ), zeta_max )
584 select case ( bulkflux_type )
594 case (
'B91',
'B91W01' )
596 if ( zeta >= 0 )
then
597 tmp = - 2.0_rp / 3.0_rp * ( 0.35_rp * zeta - 6.0_rp ) * exp(-0.35_rp*zeta)
598 phi_m = tmp * zeta + zeta + 1.0_rp
599 phi_h = tmp + zeta * sqrt( 1.0_rp + 2.0_rp * zeta / 3.0_rp ) + 1.0_rp
601 if ( bulkflux_type ==
'B91W01' )
then
604 tmp = abs(zeta)**(2.0_rp/3.0_rp)
605 phi_m = 1.0_rp / sqrt( 1.0_rp + 3.6_rp * tmp )
606 phi_h = 0.95_rp / sqrt( 1.0_rp + 7.9_rp * tmp )
609 tmp = sqrt( 1.0_rp + 16.0_rp * abs(zeta) )
610 phi_m = 1.0_rp / sqrt(tmp)
620 n2_new(
k) = min(atmos_phy_bl_mynn_n2_max, &
621 grav * ( dtldz(
k) * betat(
k) + dqwdz(
k) * betaq(
k) ) / potv(
k,i,j) )
625 ri(
k,i,j) = n2_new(
k) / dudz2(
k,i,j)
629 sflx_pt = sflx_sh(i,j) / ( cpdry * exner(
ks,i,j) )
630 sflx_ptv = grav / potv(
ks,i,j) * ( betat(
ks) * sflx_pt + betaq(
ks) * sflx_qv(i,j) ) / sfc_dens(i,j)
635 sflx_ptv, rlmo(i,j), &
640 call get_q2_level2( &
642 dudz2(:,i,j), ri(:,i,j), l(:,i,j), &
646 ac(
k) = min( q(
k) / sqrt( q2_2(
k) + 1e-20_rp ), 1.0_rp )
653 l(:,i,j), n2_new(:), &
654 potv(:,i,j), dudz2(:,i,j), &
655 dtldz(:), dqwdz(:), &
656 betat(:), betaq(:), &
658 initialize .and. it==1, &
659 tsq(:), qsq(:), cov(:), &
662 gammat(:), gammaq(:), &
666 lq(
k) = l(
k,i,j) * q(
k)
667 nu_f(
k) = lq(
k) * sm25(
k)
668 kh_f(
k) = lq(
k) * sh25(
k)
670 if ( atmos_phy_bl_mynn_similarity )
then
676 nu(
k,i,j) = min( f2h(
k,1) * nu_f(
k+1) + f2h(
k,2) * nu_f(
k), &
677 atmos_phy_bl_mynn_nu_max )
678 kh(
k,i,j) = min( f2h(
k,1) * kh_f(
k+1) + f2h(
k,2) * kh_f(
k), &
679 atmos_phy_bl_mynn_kh_max )
683 sw = 0.5_rp - sign(0.5_rp, abs(kh(
k,i,j)) - eps)
684 pr(
k,i,j) = nu(
k,i,j) / ( kh(
k,i,j) + sw ) * ( 1.0_rp - sw ) &
688 rho(
ks) = dens(
ks,i,j) + dt * sflx_qv(i,j) / cdz(
ks)
694 rho_h(
k) = f2h(
k,1) * rho(
k+1) + f2h(
k,2) * rho(
k)
695 rhonu(
k) = rho_h(
k) * nu(
k,i,j)
696 rhokh(
k) = rho_h(
k) * kh(
k,i,j)
700 if ( mynn_level3 )
then
704 wtl = - lq(
k) * ( sh25(
k) * dtldz(
k) + gammat(
k) )
705 wqw = - lq(
k) * ( sh25(
k) * dqwdz(
k) + gammaq(
k) )
706 prod_t(
k) = - 2.0_rp * wtl * dtldz(
k)
707 prod_q(
k) = - 2.0_rp * wqw * dqwdz(
k)
708 prod_c(
k) = - wtl * dqwdz(
k) - wqw * dtldz(
k)
714 tsq(:), qsq(:), cov(:), &
715 dtldz(:), dqwdz(:), potv(:,i,j), &
716 prod_t(:), prod_q(:), prod_c(:), &
717 betat(:), betaq(:), &
718 f_gamma(:), l(:,i,j), q(:), &
720 gammat(:), gammaq(:) )
724 wtl = - lq(
k) * ( sh25(
k) * dtldz(
k) + gammat(
k) )
725 wqw = - lq(
k) * ( sh25(
k) * dqwdz(
k) + gammaq(
k) )
726 prod_t(
k) = - 2.0_rp * wtl * dtldz(
k)
727 prod_q(
k) = - 2.0_rp * wqw * dqwdz(
k)
728 prod_c(
k) = - wtl * dqwdz(
k) - wqw * dtldz(
k)
737 if ( it == nit )
then
740 rlqsm_h(
k) = rho_h(
k) * ( f2h(
k,1) * lq(
k+1) * smp(
k+1) + f2h(
k,2) * lq(
k) * smp(
k) )
747 flx(
k) = - rlqsm_h(
k) * ( u(
k+1,i,j) - u(
k,i,j) ) / fdz(
k)
750 sf_t = sflx_mu(i,j) / cdz(
ks)
751 d(
ks) = ( u(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
753 d(
k) = u(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
757 ap = - dt * rhonu(
k) / fdz(
k)
758 a(
k) = ap / ( rho(
k) * cdz(
k) )
759 b(
k) = - a(
k) - c(
k) + 1.0_rp
760 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
763 b(ke_pbl) = - c(ke_pbl) + 1.0_rp
765 call matrix_solver_tridiagonal( &
767 a(:), b(:), c(:), d(:), &
771 phi_n(
ks:ke_pbl) = dummy(
ks:ke_pbl)
772 rhou_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - u(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
774 rhou_t(
k,i,j) = ( phi_n(
k) - u(
k,i,j) ) * rho(
k) / dt
777 rhou_t(
k,i,j) = 0.0_rp
779 flxu(
ks-1,i,j) = 0.0_rp
781 flxu(
k,i,j) = flx(
k) &
782 - rhonu(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
793 flx(
k) = - rlqsm_h(
k) * ( v(
k+1,i,j) - v(
k,i,j) ) / fdz(
k)
796 sf_t = sflx_mv(i,j) / cdz(
ks)
797 d(
ks) = ( v(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
799 d(
k) = v(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
803 call matrix_solver_tridiagonal( &
805 a(:), b(:), c(:), d(:), &
808 rhov_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - v(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
810 rhov_t(
k,i,j) = ( phi_n(
k) - v(
k,i,j) ) * rho(
k) / dt
813 rhov_t(
k,i,j) = 0.0_rp
815 flxv(
ks-1,i,j) = 0.0_rp
817 flxv(
k,i,j) = flx(
k) &
818 - rhonu(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
829 flx(
k) = - ( f2h(
k,1) * lq(
k+1) * gammat(
k+1) + f2h(
k,2) * lq(
k) * gammat(
k) ) &
833 sf_t = sflx_pt / cdz(
ks)
835 d(
ks) = pott(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) / rho(
ks)
837 d(
k) = pott(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
842 ap = - dt * rhokh(
k) / fdz(
k)
843 a(
k) = ap / ( rho(
k) * cdz(
k) )
844 b(
k) = - a(
k) - c(
k) + 1.0_rp
845 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
848 b(ke_pbl) = - c(ke_pbl) + 1.0_rp
850 call matrix_solver_tridiagonal( &
852 a(:), b(:), c(:), d(:), &
855 rhot_t(
ks,i,j) = ( phi_n(
ks) - pott(
ks,i,j) ) * rho(
ks) / dt - sf_t
857 rhot_t(
k,i,j) = ( phi_n(
k) - pott(
k,i,j) ) * rho(
k) / dt
860 rhot_t(
k,i,j) = 0.0_rp
862 flxt(
ks-1,i,j) = 0.0_rp
864 flxt(
k,i,j) = flx(
k) &
865 - rhokh(
k) * ( phi_n(
k+1) - phi_n(
k) ) / cdz(
k)
872 if ( flxt(
ks,i,j) > 1e-4_rp )
then
873 fmin = flxt(
ks,i,j) / rho_h(
ks)
874 do k =
ks+1, ke_pbl-2
875 tmp = ( flxt(
k-1,i,j) + flxt(
k,i,j) + flxt(
k+1,i,j) ) &
876 / ( rho_h(
k-1) + rho_h(
k) + rho_h(
k+1) )
877 if ( fmin < 0.0_rp .and. tmp > fmin )
exit
878 if ( tmp < fmin )
then
884 zi(i,j) = fz(kmin,i,j) - fz(
ks-1,i,j)
890 flx(
k) = - ( f2h(
k,1) * lq(
k+1) * gammaq(
k+1) + f2h(
k,2) * lq(
k) * gammaq(
k) ) &
894 sf_t = sflx_qv(i,j) / cdz(
ks)
895 d(
ks) = ( qv(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
897 d(
k) = qv(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
900 call matrix_solver_tridiagonal( &
902 a(:), b(:), c(:), d(:), &
905 rhoqv_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - qv(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
907 rhoqv_t(
k,i,j) = ( phi_n(
k) - qv(
k,i,j) ) * rho(
k) / dt
910 rhoqv_t(
k,i,j) = 0.0_rp
912 flxq(
ks-1,i,j) = 0.0_rp
914 flxq(
k,i,j) = flx(
k) &
915 - rhokh(
k) * ( phi_n(
k+1) - phi_n(
k) ) / cdz(
k)
927 nu(
ks-1,i,j) = 0.0_rp
928 kh(
ks-1,i,j) = 0.0_rp
930 prod(
k,i,j) = lq(
k) * ( ( sm25(
k) + smp(
k) ) * dudz2(
k,i,j) &
931 - ( sh25(
k) * n2_new(
k) - shpgh(
k) ) )
933 if ( atmos_phy_bl_mynn_similarity )
then
934 prod(
ks,i,j) = us3 / ( karman * z1 ) * ( phi_m - zeta )
938 tke_p(
k) = q(
k)**2 * 0.5_rp
939 diss(
k,i,j) = - 2.0_rp * q(
k) / ( b1 * l(
k,i,j) )
948 d(
k) = ( tke_p(
k) * dens(
k,i,j) + dt * prod(
k,i,j) * rho(
k) ) / rho(
k)
954 ap = - dt * atmos_phy_bl_mynn_sq_fact * rhonu(
k) / fdz(
k)
955 a(
k) = ap / ( rho(
k) * cdz(
k) )
956 b(
k) = - a(
k) - c(
k) + 1.0_rp - diss(
k,i,j) * dt
957 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
960 b(ke_pbl) = - c(ke_pbl) + 1.0_rp - diss(ke_pbl,i,j) * dt
962 call matrix_solver_tridiagonal( &
964 a(:), b(:), c(:), d(:), &
968 phi_n(
k) = max( phi_n(
k), atmos_phy_bl_mynn_tke_min )
970 phi_n(ke_pbl) = 0.0_rp
973 if ( it == nit )
then
975 diss(
k,i,j) = diss(
k,i,j) * phi_n(
k)
976 rprog_t(
k,i,j,i_tke) = ( phi_n(
k) * rho(
k) - prog(
k,i,j,i_tke) * dens(
k,i,j) ) / dt
979 rprog_t(
k,i,j,i_tke) = 0.0_rp
983 q(
k) = sqrt( phi_n(
k) * 2.0_rp )
988 if ( .not. mynn_level3 ) cycle
1004 diss_p(
k) = dt * 2.0_rp * q(
k) / ( b2 * l(
k,i,j) )
1007 d(
k) = ( tsq(
k) * dens(
k,i,j) + dt * prod_t(
k) * rho(
k) ) / rho(
k)
1012 ap = - dt * rhonu(
k) / fdz(
k)
1013 a(
k) = ap / ( rho(
k) * cdz(
k) )
1014 b(
k) = - a(
k) - c(
k) + 1.0_rp + diss_p(
k)
1015 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1018 b(ke_pbl) = - c(ke_pbl) + 1.0_rp + diss_p(ke_pbl)
1020 call matrix_solver_tridiagonal( &
1022 a(:), b(:), c(:), d(:), &
1026 tsq(
k) = max( tsq(
k), 0.0_rp )
1028 tsq(ke_pbl) = 0.0_rp
1030 if ( it == nit )
then
1032 rprog_t(
k,i,j,i_tsq) = ( tsq(
k) * rho(
k) - prog(
k,i,j,i_tsq) * dens(
k,i,j) ) / dt
1035 rprog_t(
k,i,j,i_tsq) = 0.0_rp
1043 d(
k) = ( qsq(
k) * dens(
k,i,j) + dt * prod_q(
k) * rho(
k) ) / rho(
k)
1048 call matrix_solver_tridiagonal( &
1050 a(:), b(:), c(:), d(:), &
1054 qsq(
k) = max( qsq(
k), 0.0_rp )
1056 qsq(ke_pbl) = 0.0_rp
1058 if ( it == nit )
then
1060 rprog_t(
k,i,j,i_qsq) = ( qsq(
k) * rho(
k) - prog(
k,i,j,i_qsq) * dens(
k,i,j) ) / dt
1063 rprog_t(
k,i,j,i_qsq) = 0.0_rp
1071 d(
k) = ( cov(
k) * dens(
k,i,j) + dt * prod_c(
k) * rho(
k) ) / rho(
k)
1076 call matrix_solver_tridiagonal( &
1078 a(:), b(:), c(:), d(:), &
1082 cov(
k) = sign( min( abs(cov(
k)), sqrt(tsq(
k)*qsq(
k)) ), cov(
k) )
1084 cov(ke_pbl) = 0.0_rp
1086 if ( it == nit )
then
1088 rprog_t(
k,i,j,i_cov) = ( cov(
k) * rho(
k) - prog(
k,i,j,i_cov) * dens(
k,i,j) ) / dt
1091 rprog_t(
k,i,j,i_cov) = 0.0_rp
1106 dudz2(
k,i,j) = undef
1109 cldfrac(
k,i,j) = undef
1116 call file_history_in(ri(:,:,:),
'Ri_MYNN',
'Richardson number',
'1', fill_halo=.true. )
1117 call file_history_in(pr(:,:,:),
'Pr_MYNN',
'Prandtl number',
'1', fill_halo=.true., dim_type=
"ZHXY" )
1118 call file_history_in(prod(:,:,:),
'TKE_prod_MYNN',
'TKE production',
'm2/s3', fill_halo=.true.)
1119 call file_history_in(diss(:,:,:),
'TKE_diss_MYNN',
'TKE dissipation',
'm2/s3', fill_halo=.true.)
1120 call file_history_in(dudz2(:,:,:),
'dUdZ2_MYNN',
'dudz2',
'm2/s2', fill_halo=.true.)
1121 call file_history_in(l(:,:,:),
'L_mix_MYNN',
'minxing length',
'm', fill_halo=.true.)
1123 call file_history_in(flxu(:,:,:),
'ZFLX_RHOU_MYNN',
'Z FLUX of RHOU (MYNN)',
'kg/m/s2', fill_halo=.true., dim_type=
"ZHXY" )
1124 call file_history_in(flxv(:,:,:),
'ZFLX_RHOV_MYNN',
'Z FLUX of RHOV (MYNN)',
'kg/m/s2', fill_halo=.true., dim_type=
"ZHXY" )
1125 call file_history_in(flxt(:,:,:),
'ZFLX_RHOT_MYNN',
'Z FLUX of RHOT (MYNN)',
'K kg/m2/s', fill_halo=.true., dim_type=
"ZHXY" )
1126 call file_history_in(flxq(:,:,:),
'ZFLX_QV_MYNN',
'Z FLUX of RHOQV (MYNN)',
'kg/m2/s', fill_halo=.true., dim_type=
"ZHXY" )
1129 initialize = .false.
1138 subroutine atmos_phy_bl_mynn_tendency_tracer( &
1139 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
1140 DENS, QTRC, SFLX_Q, &
1146 matrix_solver_tridiagonal
1149 integer,
intent(in) ::
ka,
ks,
ke
1150 integer,
intent(in) ::
ia,
is,
ie
1151 integer,
intent(in) ::
ja,
js,
je
1153 real(
rp),
intent(in) :: dens (
ka,
ia,
ja)
1154 real(
rp),
intent(in) :: qtrc (
ka,
ia,
ja)
1155 real(
rp),
intent(in) :: sflx_q(
ia,
ja)
1156 real(
rp),
intent(in) :: kh (
ka,
ia,
ja)
1157 real(
rp),
intent(in) ::
mass
1158 real(
rp),
intent(in) :: cz (
ka,
ia,
ja)
1159 real(
rp),
intent(in) :: fz (0:
ka,
ia,
ja)
1160 real(
dp),
intent(in) :: ddt
1163 real(
rp),
intent(out) :: rhoq_t(
ka,
ia,
ja)
1165 real(
rp) :: qtrc_n(
ka)
1166 real(
rp) :: rho (
ka)
1167 real(
rp) :: rhokh (
ka)
1180 real(
rp) :: f2h(
ka,2)
1187 dt = real( ddt, kind=
rp )
1201 if ( atmos_phy_bl_mynn_pbl_max >= cz(
k,i,j) - fz(
ks-1,i,j) )
then
1209 cdz(
k) = fz(
k ,i,j) - fz(
k-1,i,j)
1210 fdz(
k) = cz(
k+1,i,j) - cz(
k ,i,j)
1218 sf_t = sflx_q(i,j) / cdz(
ks)
1220 rho(
ks) = dens(
ks,i,j) + dt * sf_t *
mass
1222 rho(
k) = dens(
k,i,j)
1227 rho_h = f2h(
k,1) * dens(
k+1,i,j) + f2h(
k,2) * dens(
k,i,j)
1228 rhokh(
k) = rho_h * kh(
k,i,j)
1231 d(
ks) = ( qtrc(
ks,i,j) * dens(
ks,i,j) + dt * sf_t ) / rho(
ks)
1238 ap = - dt * rhokh(
k) / fdz(
k)
1239 a(
k) = ap / ( rho(
k) * cdz(
k) )
1240 b(
k) = - a(
k) - c(
k) + 1.0_rp
1241 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1244 b(ke_pbl) = - c(ke_pbl) + 1.0_rp
1246 call matrix_solver_tridiagonal( &
1248 a(:), b(:), c(:), d(:), &
1251 rhoq_t(
ks,i,j) = ( qtrc_n(
ks) * rho(
ks) - qtrc(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
1253 rhoq_t(
k,i,j) = ( qtrc_n(
k) - qtrc(
k,i,j) ) * rho(
k) / dt
1256 rhoq_t(
k,i,j) = 0.0_rp
1260 flx(
k,i,j) = - rhokh(
k) * ( qtrc_n(
k+1) - qtrc_n(
k) ) / fdz(
k)
1266 call file_history_in(flx(:,:,:),
'ZFLX_'//trim(
tracer_name)//
'_MYNN',
'Z FLUX of DENS * '//trim(
tracer_name)//
' (MYNN)',
'kg/m2/s', fill_halo=.true.)
1269 end subroutine atmos_phy_bl_mynn_tendency_tracer
1276 subroutine get_length( &
1289 integer,
intent(in) ::
ka,
ks, ke_pbl
1290 integer,
intent(in) :: i, j
1292 real(
rp),
intent(in) :: q(
ka)
1293 real(
rp),
intent(in) :: n2(
ka)
1294 real(
rp),
intent(in) :: sflx_ptv
1295 real(
rp),
intent(in) :: rlmo
1296 real(
rp),
intent(in) :: cz(
ka)
1297 real(
rp),
intent(in) :: fz(0:
ka)
1299 real(
rp),
intent(out) :: l(
ka)
1301 real(
rp),
parameter :: ls_fact_max = 2.0_rp
1323 qdz = q(
k) * ( fz(
k) - fz(
k-1) )
1324 z = cz(
k) - fz(
ks-1)
1325 int_qz = int_qz + z * qdz
1329 lt = min( max(0.23_rp * int_qz / (int_q + 1e-20_rp), &
1331 atmos_phy_bl_mynn_lt_max )
1334 qc = ( lt * max(sflx_ptv,0.0_rp) )**oneoverthree
1337 z = cz(
k) - fz(
ks-1)
1338 zeta = min( max( z * rlmo, zeta_min ), zeta_max )
1341 sw = sign(0.5_rp, zeta) + 0.5_rp
1343 * ( sw / (1.0_rp + 2.7_rp*zeta*sw ) &
1344 + min( ( (1.0_rp - 100.0_rp*zeta)*(1.0_rp-sw) )**0.2_rp, ls_fact_max) )
1347 sw = sign(0.5_rp, n2(
k)-eps) + 0.5_rp
1348 rn2sr = 1.0_rp / ( sqrt(n2(
k)*sw) + 1.0_rp-sw)
1349 lb = (1.0_rp + 5.0_rp * sqrt(qc*rn2sr*rlt)) * q(
k) * rn2sr * sw &
1350 + 1.e10_rp * (1.0_rp-sw)
1353 l(
k) = 1.0_rp / ( 1.0_rp/ls + rlt + 1.0_rp/(lb+1e-20_rp) )
1357 end subroutine get_length
1360 subroutine get_q2_level2( &
1365 integer,
intent(in) ::
ka,
ks, ke_pbl
1367 real(
rp),
intent(in) :: dudz2(
ka)
1368 real(
rp),
intent(in) :: ri(
ka)
1369 real(
rp),
intent(in) :: l(
ka)
1371 real(
rp),
intent(out) :: q2_2(
ka)
1380 rf = min(0.5_rp / af12 * ( ri(
k) &
1382 - sqrt(ri(
k)**2 + 2.0_rp*af12*(rf1-2.0_rp*rf2)*ri(
k) + (af12*rf1)**2) ), &
1384 sh_2 = 3.0_rp * a2 * (g1+g2) * (rfc-rf) / (1.0_rp-rf)
1385 sm_2 = sh_2 * af12 * (rf1-rf) / (rf2-rf)
1386 q2_2(
k) = b1 * l(
k)**2 * sm_2 * (1.0_rp-rf) * dudz2(
k)
1390 end subroutine get_q2_level2
1393 subroutine get_smsh( &
1412 integer,
intent(in) ::
ka,
ks, ke_pbl
1413 integer,
intent(in) :: i, j
1415 real(
rp),
intent(in) :: q(
ka)
1416 real(
rp),
intent(in) :: ac(
ka)
1417 real(
rp),
intent(in) :: l(
ka)
1418 real(
rp),
intent(in) :: n2(
ka)
1419 real(
rp),
intent(in) :: potv(
ka)
1420 real(
rp),
intent(in) :: dudz2(
ka)
1421 real(
rp),
intent(in) :: dtldz(
ka)
1422 real(
rp),
intent(in) :: dqwdz(
ka)
1423 real(
rp),
intent(in) :: betat(
ka)
1424 real(
rp),
intent(in) :: betaq(
ka)
1425 logical,
intent(in) :: mynn_level3
1426 logical,
intent(in) :: initialize
1428 real(
rp),
intent(inout) :: tsq(
ka)
1429 real(
rp),
intent(inout) :: qsq(
ka)
1430 real(
rp),
intent(inout) :: cov(
ka)
1432 real(
rp),
intent(out) :: sm25 (
ka)
1433 real(
rp),
intent(out) :: smp (
ka)
1434 real(
rp),
intent(out) :: sh25 (
ka)
1435 real(
rp),
intent(out) :: shpgh (
ka)
1436 real(
rp),
intent(out) :: gammat (
ka)
1437 real(
rp),
intent(out) :: gammaq (
ka)
1438 real(
rp),
intent(out) :: f_gamma(
ka)
1451 real(
rp) :: f1, f2, f3, f4
1479 f1 = - 3.0_rp * ac2 * a2 * b2 * ( 1.0_rp - c3 )
1480 f2 = - 9.0_rp * ac2 * a1 * a2 * ( 1.0_rp - c2 )
1481 f3 = 9.0_rp * ac2 * a2**2 * ( 1.0_rp - c2 ) * ( 1.0_rp - c5 )
1482 f4 = - 12.0_rp * ac2 * a1 * a2 * ( 1.0_rp - c2 )
1484 ghq2 = max( - n2(
k) * l2, -q2 )
1486 gmq2 = dudz2(
k) * l2
1488 p1q2 = q2 + f1 * ghq2
1489 p2q2 = q2 + f2 * ghq2
1490 p3q2 = q2 + ( f1 + f3 ) * ghq2
1491 p4q2 = q2 + ( f1 + f4 ) * ghq2
1492 p5q2 = 6.0_rp * ac2 * a1**2 * gmq2
1493 rd25 = q2 / max( p2q2 * p4q2 + p5q2 * p3q2, 1e-20_rp )
1495 sm25(
k) = ac(
k) * a1 * ( p3q2 - 3.0_rp * c1 * p4q2 ) * rd25
1496 sh25(
k) = ac(
k) * a2 * ( p2q2 + 3.0_rp * c1 * p5q2 ) * rd25
1499 if ( mynn_level3 )
then
1501 fact = ac(
k) * b2 * l2 * sh25(
k)
1502 tsq25 = fact * dtldz(
k)**2
1503 qsq25 = fact * dqwdz(
k)**2
1504 cov25 = fact * dtldz(
k) * dqwdz(
k)
1507 if ( initialize )
then
1513 if ( q2 <= 1e-10_rp )
then
1520 tltv25 = betat(
k) * tsq25 + betaq(
k) * cov25
1521 qwtv25 = betat(
k) * cov25 + betaq(
k) * qsq25
1522 tvsq25 = betat(
k) * tltv25 + betaq(
k) * qwtv25
1524 tltv = betat(
k) * tsq(
k) + betaq(
k) * cov(
k)
1525 qwtv = betat(
k) * cov(
k) + betaq(
k) * qsq(
k)
1526 tvsq = betat(
k) * tltv + betaq(
k) * qwtv
1528 rdp = q2 / max( p2q2 * ( f4 * ghq2 + q2 ) + p5q2 * ( f3 * ghq2 + q2 ), 1e-20_rp )
1530 fact = l2 / q2 * ( grav / potv(
k) )**2 * ( tvsq - tvsq25 )
1532 ew = ( 1.0_rp - c3 ) * ( - p2q2 * f4 - p5q2 * f3 ) * rdp
1533 if ( abs(ew) > 1e-20_rp )
then
1534 cw25q2 = p1q2 * ( p2q2 + 3.0_rp * c1 * p5q2 ) * rd25 / 3.0_rp
1536 fact = min( max( fact, 0.12_rp * q2 - cw25q2 ), 0.76_rp * q2 - cw25q2 )
1540 emq2 = 3.0_rp * ac(
k) * a1 * ( 1.0_rp - c3 ) * ( f3 - f4 ) * rdp
1541 eh = 3.0_rp * ac(
k) * a2 * ( 1.0_rp - c3 ) * ( p2q2 + p5q2 ) * rdp
1543 smp(
k) = emq2 * fact
1544 shpgh(
k) = eh * fact / l2
1545 f_gamma(
k) = - eh * grav / ( q2 * potv(
k) )
1546 gammat(
k) = ( tltv - tltv25 ) * f_gamma(
k)
1547 gammaq(
k) = ( qwtv - qwtv25 ) * f_gamma(
k)
1560 end subroutine get_smsh
1567 dtldz, dqwdz, POTV, &
1568 prod_t, prod_q, prod_c, &
1576 integer,
intent(in) :: KA, KS, KE
1577 integer,
intent(in) :: i, j
1579 real(RP),
intent(in) :: tsq (KA)
1580 real(RP),
intent(in) :: qsq (KA)
1581 real(RP),
intent(in) :: cov (KA)
1582 real(RP),
intent(in) :: dtldz (KA)
1583 real(RP),
intent(in) :: dqwdz (KA)
1584 real(RP),
intent(in) :: POTV (KA)
1585 real(RP),
intent(in) :: prod_t (KA)
1586 real(RP),
intent(in) :: prod_q (KA)
1587 real(RP),
intent(in) :: prod_c (KA)
1588 real(RP),
intent(in) :: betat (KA)
1589 real(RP),
intent(in) :: betaq (KA)
1590 real(RP),
intent(in) :: f_gamma(KA)
1591 real(RP),
intent(in) :: l (KA)
1592 real(RP),
intent(in) :: q (KA)
1593 real(RP),
intent(in) :: dt
1595 real(RP),
intent(inout) :: gammat(KA)
1596 real(RP),
intent(inout) :: gammaq(KA)
1601 real(RP) :: a11, a12, a21, a22, a23, a32, a33
1602 real(RP) :: v1, v2, v3
1604 real(RP) :: a13, a31, det
1613 f1 = f_gamma(k) * l(k) * q(k)
1614 f2 = - 2.0_rp * q(k) / ( b2 * l(k) )
1616 v1 = prod_t(k) + f2 * tsq(k)
1617 v2 = prod_c(k) + f2 * cov(k)
1618 v3 = prod_q(k) + f2 * qsq(k)
1620 a11 = - f1 * dtldz(k) * betat(k) * 2.0_rp + 1.0_rp / dt - f2
1621 a12 = - f1 * dtldz(k) * betaq(k) * 2.0_rp
1622 a21 = - f1 * dqwdz(k) * betat(k)
1623 a22 = - f1 * ( dtldz(k) * betat(k) + dqwdz(k) * betaq(k) ) + 1.0_rp / dt - f2
1624 a23 = - f1 * dtldz(k) * betaq(k)
1625 a32 = - f1 * dqwdz(k) * betat(k) * 2.0_rp
1626 a33 = - f1 * dqwdz(k) * betaq(k) * 2.0_rp + 1.0_rp / dt - f2
1628 if ( q(k) < 1e-20_rp .or. abs(f_gamma(k)) * dt >= q(k) )
then
1632 dcov = ( v2 - f1 * v1 - f2 * v3 ) / ( a22 - f1 * a12 - f2 * a32 )
1633 dtsq = ( v1 - a12 * dcov ) / a11
1634 dqsq = ( v3 - a32 * dcov ) / a33
1638 f1 = - l(k) * grav / potv(k) * f_gamma(k) / q(k)
1639 f2 = f1 * betat(k)**2
1643 f2 = f1 * betat(k) * betaq(k) * 2.0_rp
1647 f2 = f1 * betaq(k)**2
1652 det = a11 * ( a22 * a33 - a23 * a32 ) + a12 * ( a23 * a31 - a21 * a33 ) + a13 * ( a21 * a32 - a22 * a31 )
1653 dtsq = ( v1 * ( a22 * a33 - a23 * a32 ) + a12 * ( a23 * v3 - v2 * a33 ) + a13 * ( v2 * a32 - a22 * v3 ) ) / det
1654 dcov = ( a11 * ( v2 * a33 - a23 * v3 ) + v1 * ( a23 * a31 - a21 * a33 ) + a13 * ( a21 * v3 - v2 * a31 ) ) / det
1655 dqsq = ( a11 * ( a22 * v3 - v2 * a32 ) + a12 * ( v2 * a31 - a21 * v3 ) + v3 * ( a21 * a32 - a22 * a31 ) ) / det
1659 gammat(k) = gammat(k) + f_gamma(k) * ( betat(k) * dtsq + betaq(k) * dcov )
1660 gammaq(k) = gammaq(k) + f_gamma(k) * ( betat(k) * dcov + betaq(k) * dqsq )
1672 dudz2, dtldz, dqwdz )
1675 integer,
intent(in) :: KA, KS, KE
1676 integer,
intent(in) :: i, j
1678 real(RP),
intent(in) :: U (KA)
1679 real(RP),
intent(in) :: V (KA)
1680 real(RP),
intent(in) :: POTL(KA)
1681 real(RP),
intent(in) :: Qw (KA)
1682 real(RP),
intent(in) :: CDZ (KA)
1683 real(RP),
intent(in) :: FDZ (KA)
1684 real(RP),
intent(in) :: F2H (KA,2)
1686 real(RP),
intent(out) :: dudz2(KA)
1687 real(RP),
intent(out) :: dtldz(KA)
1688 real(RP),
intent(out) :: dqwdz(KA)
1690 real(RP) :: Uh(KA), Vh(KA)
1696 uh(k) = f2h(k,1) * u(k+1) + f2h(k,2) * u(k)
1697 vh(k) = f2h(k,1) * v(k+1) + f2h(k,2) * v(k)
1700 dudz2(ks) = ( ( uh(ks) - u(ks) )**2 + ( vh(ks) - v(ks) )**2 ) / ( cdz(ks) * 0.5_rp )**2
1702 dudz2(ks) = max( dudz2(ks), 1e-20_rp )
1704 dudz2(k) = ( ( uh(k) - uh(k-1) )**2 + ( vh(k) - vh(k-1) )**2 ) / cdz(k)**2
1705 dudz2(k) = max( dudz2(k), 1e-20_rp )
1710 qh(k) = f2h(k,1) * potl(k+1) + f2h(k,2) * potl(k)
1712 dtldz(ks) = ( qh(ks) - potl(ks) ) / ( cdz(ks) * 0.5_rp )
1715 dtldz(k) = ( qh(k) - qh(k-1) ) / cdz(k)
1719 qh(k) = f2h(k,1) * qw(k+1) + f2h(k,2) * qw(k)
1721 dqwdz(ks) = ( qh(ks) - qw(ks) ) / ( cdz(ks) * 0.5_rp )
1724 dqwdz(k) = ( qh(k) - qh(k-1) ) / cdz(k)
1733 PRES, POTT, POTL, Qw, Qdry, EXNER, &
1734 dtldz, dqwdz, l, sh25, ac, &
1737 betat, betaq, Qlp, cldfrac )
1745 atmos_saturation_pres2qsat => atmos_saturation_pres2qsat_liq
1747 hydrometeor_lhv => atmos_hydrometeor_lhv
1748 integer,
intent(in) :: KA, KS, KE
1749 real(RP),
intent(in) :: PRES (KA)
1750 real(RP),
intent(in) :: POTT (KA)
1751 real(RP),
intent(in) :: POTL (KA)
1752 real(RP),
intent(in) :: Qw (KA)
1753 real(RP),
intent(in) :: Qdry (KA)
1754 real(RP),
intent(in) :: EXNER(KA)
1755 real(RP),
intent(in) :: dtldz(KA)
1756 real(RP),
intent(in) :: dqwdz(KA)
1757 real(RP),
intent(in) :: l (KA)
1758 real(RP),
intent(in) :: sh25 (KA)
1759 real(RP),
intent(in) :: ac (KA)
1760 real(RP),
intent(in) :: tsq (KA)
1761 real(RP),
intent(in) :: qsq (KA)
1762 real(RP),
intent(in) :: cov (KA)
1763 logical,
intent(in) :: mynn_level3
1765 real(RP),
intent(out) :: betat (KA)
1766 real(RP),
intent(out) :: betaq (KA)
1767 real(RP),
intent(out) :: Qlp (KA)
1768 real(RP),
intent(out) :: cldfrac(KA)
1770 real(RP) :: TEML(KA)
1771 real(RP) :: Qsl (KA)
1772 real(RP) :: LHVL(KA)
1775 real(RP) :: aa, bb, cc
1783 teml(k) = potl(k) * exner(k)
1786 call atmos_saturation_pres2qsat( &
1788 teml(:), pres(:), qdry(:), &
1791 call hydrometeor_lhv( &
1798 dqsl = ( 1.0_rp + qsl(k) / ( qdry(k) * epsvap ) ) * qsl(k) * lhvl(k) / ( rvap * teml(k)**2 )
1799 cptot = qdry(k) * cpdry + qsl(k) * cpvap
1800 aa = 1.0_rp / ( 1.0_rp + lhvl(k)/cptot * dqsl )
1801 bb = exner(k) * dqsl
1803 if ( mynn_level3 )
then
1804 sigma_s = 0.5_rp * aa * sqrt( max( qsq(k) - 2.0_rp * bb * cov(k) + bb**2 * tsq(k), 1.0e-20_rp ) )
1807 sigma_s = max( 0.5_rp * aa * l(k) * sqrt( ac(k) * b2 * sh25(k) ) * abs( dqwdz(k) - bb * dtldz(k) ), &
1811 q1 = aa * ( qw(k) - qsl(k) ) * 0.5_rp / sigma_s
1812 cldfrac(k) = min( max( 0.5_rp * ( 1.0_rp + erf(q1*rsqrt_2) ), 0.0_rp ), 1.0_rp )
1813 qlp(k) = min( max( 2.0_rp * sigma_s * ( cldfrac(k) * q1 + rsqrt_2pi &
1814 #if defined(PGI) || defined(SX)
1815 * exp( -min( 0.5_rp*q1**2, 1.e+3_rp ) ) &
1817 * exp(-0.5_rp*q1**2) &
1819 ), 0.0_rp ), qw(k) * 0.5_rp )
1820 cc = ( 1.0_rp + epstvap * qw(k) - qlp(k) / epsvap ) / exner(k) * lhvl(k) / cptot &
1822 rt = cldfrac(k) - qlp(k) / (2.0_rp*sigma_s*sqrt_2pi) &
1823 #if defined(PGI) || defined(SX)
1824 * exp( -min( q1**2 * 0.5_rp, 1.e+3_rp ) )
1826 * exp(-q1**2 * 0.5_rp)
1828 betat(k) = 1.0_rp + epstvap * qw(k) - qlp(k) / epsvap - rt * aa * bb * cc
1829 betaq(k) = epstvap * pott(k) + rt * aa * cc
1841 integer,
intent(in) :: KA, KS, KE
1842 real(RP),
intent(in) :: CDZ(KA)
1843 real(RP),
intent(out) :: f2h(KA,2)
1845 real(RP) :: dz1, dz2
1851 f2h(k,1) = dz2 / ( dz1 + dz2 )
1852 f2h(k,2) = dz1 / ( dz1 + dz2 )