32 #if defined DEBUG || defined QUICKDEBUG
70 integer,
private,
parameter :: i_tke = 1
71 integer,
private,
parameter :: i_tsq = 2
72 integer,
private,
parameter :: i_qsq = 3
73 integer,
private,
parameter :: i_cov = 4
75 integer,
private,
parameter :: i_b71 = 1
76 integer,
private,
parameter :: i_b91 = 2
77 integer,
private,
parameter :: i_b91w01 = 3
79 real(
rp),
private,
parameter :: oneoverthree = 1.0_rp / 3.0_rp
80 real(
rp),
private,
parameter :: lt_min = 1.e-6_rp
81 real(
rp),
private,
parameter :: flx_lim_fact = 0.5_rp
83 real(
rp),
private :: a1
84 real(
rp),
private :: a2
85 real(
rp),
private,
parameter :: b1 = 24.0_rp
86 real(
rp),
private,
parameter :: b2 = 15.0_rp
87 real(
rp),
private :: c1
88 real(
rp),
private :: c2 = -1.0_rp
89 real(
rp),
private :: c3 = -1.0_rp
90 real(
rp),
private,
parameter :: c5 = 0.2_rp
91 real(
rp),
private,
parameter :: g1 = 0.235_rp
92 real(
rp),
private :: g2
93 real(
rp),
private :: f2
94 real(
rp),
private :: rf2
95 real(
rp),
private :: rfc
96 real(
rp),
private,
parameter :: prn = 0.74_rp
99 real(
rp),
private,
parameter :: sqrt_2pi = sqrt( 2.0_rp * pi )
100 real(
rp),
private,
parameter :: rsqrt_2pi = 1.0_rp / sqrt_2pi
101 real(
rp),
private,
parameter :: rsqrt_2 = 1.0_rp / sqrt( 2.0_rp )
104 integer,
parameter :: max_plume = 10
106 real(
rp) :: dplume(max_plume)
107 real(
rp) :: pw(max_plume)
108 logical :: atmos_phy_bl_mynn_mf
112 integer,
private :: hist_ri
113 integer,
private :: hist_pr
114 integer,
private :: hist_tke_pr
115 integer,
private :: hist_tke_di
116 integer,
private :: hist_dudz2
117 integer,
private :: hist_lmix
118 integer,
private :: hist_flxu
119 integer,
private :: hist_flxv
120 integer,
private :: hist_flxt
121 integer,
private :: hist_flxq
122 integer,
private :: hist_flxu2
123 integer,
private :: hist_flxv2
124 integer,
private :: hist_flxt2
125 integer,
private :: hist_flxq2
128 logical,
private :: atmos_phy_bl_mynn_k2010 = .false.
129 logical,
private :: atmos_phy_bl_mynn_o2019 = .false.
130 real(
rp),
private :: atmos_phy_bl_mynn_pbl_max = 3000.0_rp
131 real(
rp),
private :: atmos_phy_bl_mynn_tke_min = 1.e-20_rp
132 real(
rp),
private :: atmos_phy_bl_mynn_n2_max = 1.e1_rp
133 real(
rp),
private :: atmos_phy_bl_mynn_nu_max = 1.e4_rp
134 real(
rp),
private :: atmos_phy_bl_mynn_kh_max = 1.e4_rp
135 real(
rp),
private :: atmos_phy_bl_mynn_lt_max = 2000.0_rp
136 logical,
private :: atmos_phy_bl_mynn_use_zi = .true.
137 real(
rp),
private :: atmos_phy_bl_mynn_zeta_lim = 10.0_rp
138 real(
rp),
private :: atmos_phy_bl_mynn_sq_fact = 3.0_rp
139 real(
rp),
private :: atmos_phy_bl_mynn_cns = -1.0_rp
140 real(
rp),
private :: atmos_phy_bl_mynn_alpha2 = -1.0_rp
141 real(
rp),
private :: atmos_phy_bl_mynn_alpha4 = -1.0_rp
142 real(
rp),
private :: atmos_phy_bl_mynn_dump_coef = 0.5_rp
143 logical,
private :: atmos_phy_bl_mynn_dz_sim = .true.
144 logical,
private :: atmos_phy_bl_mynn_similarity = .true.
147 character(len=H_SHORT),
private :: atmos_phy_bl_mynn_level =
"2.5"
149 namelist / param_atmos_phy_bl_mynn / &
150 atmos_phy_bl_mynn_k2010, &
151 atmos_phy_bl_mynn_o2019, &
152 atmos_phy_bl_mynn_pbl_max, &
153 atmos_phy_bl_mynn_n2_max, &
154 atmos_phy_bl_mynn_nu_max, &
155 atmos_phy_bl_mynn_kh_max, &
156 atmos_phy_bl_mynn_lt_max, &
157 atmos_phy_bl_mynn_use_zi, &
158 atmos_phy_bl_mynn_zeta_lim, &
159 atmos_phy_bl_mynn_level, &
160 atmos_phy_bl_mynn_sq_fact, &
161 atmos_phy_bl_mynn_cns, &
162 atmos_phy_bl_mynn_alpha2, &
163 atmos_phy_bl_mynn_alpha4, &
164 atmos_phy_bl_mynn_dump_coef,&
165 atmos_phy_bl_mynn_dz_sim, &
166 atmos_phy_bl_mynn_similarity
182 log_info(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Tracer Setup'
183 log_info(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Mellor-Yamada Nakanishi-Niino scheme'
187 read(
io_fid_conf,nml=param_atmos_phy_bl_mynn,iostat=ierr)
189 log_error(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_BL_MYNN. Check!'
193 select case ( atmos_phy_bl_mynn_level )
208 'sub-grid variance of liquid water potential temperature (MYNN) ', &
209 'sub-grid variance of total water content (MYNN) ', &
210 'sub-grid covariance of liquid water potential temperature and total water content (MYNN)' /)
216 log_error(
"ATMOS_PHY_BL_MYNN_tracer_setup",*)
'only level 2.5 and 3 are supported at this moment'
236 character(len=*),
intent(in) :: bulkflux_type
238 real(
rp),
intent(in),
optional :: dx
239 real(
rp),
intent(in),
optional :: tke_min
240 real(
rp),
intent(in),
optional :: pbl_max
247 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Setup'
248 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Mellor-Yamada Nakanishi-Niino scheme'
250 if (
present(tke_min) ) atmos_phy_bl_mynn_tke_min = tke_min
251 if (
present(pbl_max) ) atmos_phy_bl_mynn_pbl_max = pbl_max
255 read(
io_fid_conf,nml=param_atmos_phy_bl_mynn,iostat=ierr)
257 log_info(
"ATMOS_PHY_BL_MYNN_setup",*)
'Not found namelist. Default used.'
258 elseif( ierr > 0 )
then
259 log_error(
"ATMOS_PHY_BL_MYNN_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_BL_MYNN. Check!'
262 log_nml(param_atmos_phy_bl_mynn)
264 atmos_phy_bl_mynn_mf = .false.
265 if ( atmos_phy_bl_mynn_o2019 )
then
266 if ( atmos_phy_bl_mynn_cns < 0.0_rp ) atmos_phy_bl_mynn_cns = 3.5_rp
267 if ( atmos_phy_bl_mynn_alpha2 < 0.0_rp ) atmos_phy_bl_mynn_alpha2 = 0.3_rp
268 if ( atmos_phy_bl_mynn_alpha4 < 0.0_rp ) atmos_phy_bl_mynn_alpha4 = 10.0_rp
269 if ( c2 < 0.0_rp ) c2 = 0.729_rp
270 if ( c3 < 0.0_rp ) c3 = 0.34_rp
271 atmos_phy_bl_mynn_k2010 = .true.
272 atmos_phy_bl_mynn_use_zi = .true.
273 if ( atmos_phy_bl_mynn_level .ne.
"3" )
then
274 atmos_phy_bl_mynn_mf = .true.
276 if ( .not.
present(dx) )
then
277 log_error(
"ATMOS_PHY_BL_MYNN_setup",*)
'dx must be set with O2019'
280 if ( atmos_phy_bl_mynn_mf )
then
283 dplume(n) = 100.0_rp * n
284 pw(n) = 0.1_rp + ( 0.5_rp - 0.1_rp ) * ( n - 1 ) / ( max_plume - 1 )
285 if ( dplume(n) > dx )
then
293 if ( atmos_phy_bl_mynn_cns < 0.0_rp ) atmos_phy_bl_mynn_cns = 2.7_rp
294 if ( atmos_phy_bl_mynn_alpha2 < 0.0_rp ) atmos_phy_bl_mynn_alpha2 = 1.0_rp
295 if ( atmos_phy_bl_mynn_alpha4 < 0.0_rp ) atmos_phy_bl_mynn_alpha4 = 100.0_rp
296 if ( c2 < 0.0_rp ) c2 = 0.75_rp
297 if ( c3 < 0.0_rp ) c3 = 0.352_rp
303 a1 = b1 * (1.0_rp - 3.0_rp * g1) / 6.0_rp
304 a2 = 1.0_rp / (3.0_rp * g1 * b1**(1.0_rp/3.0_rp) * prn )
305 c1 = g1 - 1.0_rp / ( 3.0_rp * a1 * b1**(1.0_rp/3.0_rp) )
306 g2 = ( 2.0_rp * a1 * (3.0_rp - 2.0_rp * c2) + b2 * (1.0_rp - c3) ) / b1
307 f2 = b1 * (g1 + g2) - 3.0_rp * a1 * (1.0_rp - c2)
314 select case ( bulkflux_type )
315 case (
"B91",
"B91W01" )
318 atmos_phy_bl_mynn_similarity = .false.
325 call file_history_reg(
'Ri_MYNN',
'Richardson number',
'1', hist_ri, fill_halo=.true. )
326 call file_history_reg(
'Pr_MYNN',
'Prandtl number',
'1', hist_pr, fill_halo=.true., dim_type=
"ZHXY" )
327 call file_history_reg(
'TKE_prod_MYNN',
'TKE production',
'm2/s3', hist_tke_pr, fill_halo=.true.)
328 call file_history_reg(
'TKE_diss_MYNN',
'TKE dissipation',
'm2/s3', hist_tke_di, fill_halo=.true.)
329 call file_history_reg(
'dUdZ2_MYNN',
'dudz2',
'm2/s2', hist_dudz2, fill_halo=.true.)
330 call file_history_reg(
'L_mix_MYNN',
'minxing length',
'm', hist_lmix, fill_halo=.true.)
332 call file_history_reg(
'ZFLX_RHOU_BL',
'Z FLUX of RHOU (MYNN)',
'kg/m/s2', hist_flxu, fill_halo=.true., dim_type=
"ZHXY" )
333 call file_history_reg(
'ZFLX_RHOV_BL',
'Z FLUX of RHOV (MYNN)',
'kg/m/s2', hist_flxv, fill_halo=.true., dim_type=
"ZHXY" )
334 call file_history_reg(
'ZFLX_RHOT_BL',
'Z FLUX of RHOT (MYNN)',
'K kg/m2/s', hist_flxt, fill_halo=.true., dim_type=
"ZHXY" )
335 call file_history_reg(
'ZFLX_QV_BL',
'Z FLUX of RHOQV (MYNN)',
'kg/m2/s', hist_flxq, fill_halo=.true., dim_type=
"ZHXY" )
337 call file_history_reg(
'ZFLX_RHOU2_BL',
'Z FLUX of RHOU (MYNN)',
'kg/m/s2', hist_flxu2, fill_halo=.true., dim_type=
"ZHXY" )
338 call file_history_reg(
'ZFLX_RHOV2_BL',
'Z FLUX of RHOV (MYNN)',
'kg/m/s2', hist_flxv2, fill_halo=.true., dim_type=
"ZHXY" )
339 call file_history_reg(
'ZFLX_RHOT2_BL',
'Z FLUX of RHOT (MYNN)',
'K kg/m2/s', hist_flxt2, fill_halo=.true., dim_type=
"ZHXY" )
340 call file_history_reg(
'ZFLX_QV2_BL',
'Z FLUX of RHOQV (MYNN)',
'kg/m2/s', hist_flxq2, fill_halo=.true., dim_type=
"ZHXY" )
361 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
363 DENS, U, V, W, POTT, &
365 QDRY, QV, Qw, POTL, POTV, SFC_DENS, &
366 SFLX_MU, SFLX_MV, SFLX_SH, SFLX_QV, &
376 hydrometeor_lhv => atmos_hydrometeor_lhv, &
379 matrix_solver_tridiagonal
381 file_history_query, &
385 integer,
intent(in) ::
ka,
ks,
ke
386 integer,
intent(in) ::
ia,
is,
ie
387 integer,
intent(in) ::
ja,
js,
je
391 real(
rp),
intent(in) :: dens (
ka,
ia,
ja)
392 real(
rp),
intent(in) :: u (
ka,
ia,
ja)
393 real(
rp),
intent(in) :: v (
ka,
ia,
ja)
394 real(
rp),
intent(in) :: w (
ka,
ia,
ja)
395 real(
rp),
intent(in) :: pott (
ka,
ia,
ja)
396 real(
rp),
intent(in) :: pres (
ka,
ia,
ja)
397 real(
rp),
intent(in) :: exner (
ka,
ia,
ja)
398 real(
rp),
intent(in) :: n2 (
ka,
ia,
ja)
399 real(
rp),
intent(in) :: qdry (
ka,
ia,
ja)
400 real(
rp),
intent(in) :: qv (
ka,
ia,
ja)
401 real(
rp),
intent(in) :: qw (
ka,
ia,
ja)
402 real(
rp),
intent(in) :: potl (
ka,
ia,
ja)
403 real(
rp),
intent(in) :: potv (
ka,
ia,
ja)
404 real(
rp),
intent(in) :: sfc_dens(
ia,
ja)
405 real(
rp),
intent(in) :: sflx_mu (
ia,
ja)
406 real(
rp),
intent(in) :: sflx_mv (
ia,
ja)
407 real(
rp),
intent(in) :: sflx_sh (
ia,
ja)
408 real(
rp),
intent(in) :: sflx_qv (
ia,
ja)
409 real(
rp),
intent(in) :: us (
ia,
ja)
410 real(
rp),
intent(in) :: ts (
ia,
ja)
411 real(
rp),
intent(in) :: qs (
ia,
ja)
412 real(
rp),
intent(in) :: rlmo (
ia,
ja)
414 real(
rp),
intent(in) :: frac_land(
ia,
ja)
416 real(
rp),
intent(in) :: cz(
ka,
ia,
ja)
417 real(
rp),
intent(in) :: fz(0:
ka,
ia,
ja)
418 real(
rp),
intent(in) :: f2h(
ka,2,
ia,
ja)
420 character(len=*),
intent(in) :: bulkflux_type
428 real(
rp) :: cldfrac(
ka)
430 real(
rp) :: sflx_buoy
434 real(
rp) :: prod (
ka)
435 real(
rp) :: diss (
ka)
436 real(
rp) :: dudz2(
ka)
438 real(
rp) :: rho_h(
ka)
441 real(
rp) :: rhonu (
ka)
442 real(
rp) :: rhokh (
ka)
443 real(
rp) :: n2_new(
ka)
445 real(
rp) :: sm25 (
ka)
446 real(
rp) :: sh25 (
ka)
456 real(
rp) :: prod_t(
ka)
457 real(
rp) :: prod_q(
ka)
458 real(
rp) :: prod_c(
ka)
459 real(
rp) :: diss_p(
ka)
460 real(
rp) :: dtldz(
ka)
461 real(
rp) :: dqwdz(
ka)
463 real(
rp) :: shpgh(
ka)
464 real(
rp) :: gammat (
ka)
465 real(
rp) :: gammaq (
ka)
473 logical :: mynn_level3
475 real(
rp),
parameter :: dt = 1.0_rp
478 real(
rp) :: tflux(0:
ka)
479 real(
rp) :: qflux(0:
ka)
480 real(
rp) :: uflux(0:
ka)
481 real(
rp) :: vflux(0:
ka)
482 real(
rp) :: eflux(0:
ka)
485 real(
rp) :: ptlv (
ka)
486 real(
rp) :: nu_f (
ka)
487 real(
rp) :: kh_f (
ka)
488 real(
rp) :: q2_2 (
ka)
490 real(
rp) :: betat(
ka)
491 real(
rp) :: betaq(
ka)
493 real(
rp) :: flx(0:
ka)
499 real(
rp) :: f_smp (
ka)
500 real(
rp) :: f_shpgh(
ka)
501 real(
rp) :: f_gamma(
ka)
502 real(
rp) :: tltv25 (
ka)
503 real(
rp) :: qwtv25 (
ka)
504 real(
rp) :: tvsq25 (
ka)
505 real(
rp) :: tvsq_up(
ka)
506 real(
rp) :: tvsq_lo(
ka)
507 real(
rp) :: dtsq (
ka)
508 real(
rp) :: dqsq (
ka)
509 real(
rp) :: dcov (
ka)
511 real(
rp) :: mflux(0:
ka)
514 real(
rp) :: qw2(
ka), qh(
ka)
515 real(
rp) :: tlh(
ka), tvh(
ka)
516 real(
rp) :: eh(
ka), dh(
ka)
517 real(
rp) :: teml(
ka), lhvl(
ka), psat(
ka)
520 real(
rp) :: work(
ka,4)
528 mynn_level3 = ( atmos_phy_bl_mynn_level ==
"3" )
530 select case ( bulkflux_type )
538 log_error(
"ATMOS_PHY_BL_MYNN_init_TKE",*)
"BULKFLUX_type is invalid: ", trim(bulkflux_type)
606 z(
k) = cz(
k,i,j) - fz(
ks-1,i,j)
612 if ( atmos_phy_bl_mynn_pbl_max >= z(
k) )
then
620 cdz(
k) = fz(
k,i,j) - fz(
k-1,i,j)
623 fdz(
k) = cz(
k+1,i,j) - cz(
k,i,j)
630 cptot = cpdry + sflx_qv(i,j) * (
cp_vapor - cpdry )
631 sflx_pt = sflx_sh(i,j) / ( cptot * exner(
ks,i,j) )
633 call mynn_main(
ka,
ks, ke_pbl, &
635 tke(:), tsq(:), qsq(:), cov(:), &
637 nu(:), rhonu(:), kh(:), rhokh(:), pr(:), &
638 prod(:), prod_t(:), prod_q(:), prod_c(:), &
639 diss(:), diss_p(:), &
640 sm25(:), smp(:), sh25(:), shpgh(:), &
641 gammat(:), gammaq(:), &
642 dudz2(:), n2_new(:), ri(:), &
643 dtldz(:), dqwdz(:), &
645 uflux(:), vflux(:), tflux(:), qflux(:), eflux(:), &
646 qlp(:), cldfrac(:), zi, sflx_buoy, &
647 u(:,i,j), v(:,i,j), w(:,i,j), &
648 dens(:,i,j), pres(:,i,j), &
649 pott(:,i,j), potl(:,i,j), potv(:,i,j), &
650 qw(:,i,j), n2(:,i,j), &
651 exner(:,i,j), qdry(:,i,j), &
652 sflx_pt, sflx_sh(i,j), sflx_qv(i,j), sfc_dens(i,j), &
653 rlmo(i,j), us(i,j), ts(i,j), qs(i,j), &
654 z(:), cdz(:), fdz(:), f2h(:,:,i,j), &
658 mynn_level3, .true., &
662 ptlv(:), nu_f(:), kh_f(:), q2_2(:), ac(:), &
663 betat(:), betaq(:), &
664 flx(:), a(:), b(:), c(:), d(:), &
665 f_smp(:), f_shpgh(:), f_gamma(:), &
666 tltv25(:), qwtv25(:), tvsq25(:), &
667 tvsq_up(:), tvsq_lo(:), dtsq(:), dqsq(:), dcov(:), &
669 uh(:), vh(:), wh(:), qw2(:), qh(:), &
670 tlh(:), tvh(:), eh(:), dh(:), &
671 teml(:), lhvl(:), psat(:) )
674 prog(
k,i,j,i_tke) = tke(
k)
677 prog(
k,i,j,i_tke) = 0.0_rp
680 if ( mynn_level3 )
then
682 prog(
k,i,j,i_tsq) = tsq(
k)
683 prog(
k,i,j,i_qsq) = qsq(
k)
684 prog(
k,i,j,i_cov) = cov(
k)
687 prog(
k,i,j,i_tsq) = 0.0_rp
688 prog(
k,i,j,i_qsq) = 0.0_rp
689 prog(
k,i,j,i_cov) = 0.0_rp
707 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
708 DENS, U, V, W, POTT, PROG, &
710 QDRY, QV, Qw, POTL, POTV, SFC_DENS, &
711 SFLX_MU, SFLX_MV, SFLX_SH, SFLX_QV, &
714 CZ, FZ, F2H, dt_DP, &
716 RHOU_t, RHOV_t, RHOT_t, RHOQV_t, &
718 Nu, Kh, Qlp, cldfrac, &
725 hydrometeor_lhv => atmos_hydrometeor_lhv, &
728 matrix_solver_tridiagonal
730 file_history_query, &
734 integer,
intent(in) ::
ka,
ks,
ke
735 integer,
intent(in) ::
ia,
is,
ie
736 integer,
intent(in) ::
ja,
js,
je
738 real(
rp),
intent(in) :: dens (
ka,
ia,
ja)
739 real(
rp),
intent(in) :: u (
ka,
ia,
ja)
740 real(
rp),
intent(in) :: v (
ka,
ia,
ja)
741 real(
rp),
intent(in) :: w (
ka,
ia,
ja)
742 real(
rp),
intent(in) :: pott (
ka,
ia,
ja)
744 real(
rp),
intent(in) :: pres (
ka,
ia,
ja)
745 real(
rp),
intent(in) :: exner (
ka,
ia,
ja)
746 real(
rp),
intent(in) :: n2 (
ka,
ia,
ja)
747 real(
rp),
intent(in) :: qdry (
ka,
ia,
ja)
748 real(
rp),
intent(in) :: qv (
ka,
ia,
ja)
749 real(
rp),
intent(in) :: qw (
ka,
ia,
ja)
750 real(
rp),
intent(in) :: potl (
ka,
ia,
ja)
751 real(
rp),
intent(in) :: potv (
ka,
ia,
ja)
752 real(
rp),
intent(in) :: sfc_dens(
ia,
ja)
753 real(
rp),
intent(in) :: sflx_mu (
ia,
ja)
754 real(
rp),
intent(in) :: sflx_mv (
ia,
ja)
755 real(
rp),
intent(in) :: sflx_sh (
ia,
ja)
756 real(
rp),
intent(in) :: sflx_qv (
ia,
ja)
757 real(
rp),
intent(in) :: us (
ia,
ja)
758 real(
rp),
intent(in) :: ts (
ia,
ja)
759 real(
rp),
intent(in) :: qs (
ia,
ja)
760 real(
rp),
intent(in) :: rlmo (
ia,
ja)
762 real(
rp),
intent(in) :: frac_land(
ia,
ja)
764 real(
rp),
intent(in) :: cz(
ka,
ia,
ja)
765 real(
rp),
intent(in) :: fz(0:
ka,
ia,
ja)
766 real(
rp),
intent(in) :: f2h(
ka,2,
ia,
ja)
767 real(
dp),
intent(in) :: dt_dp
769 character(len=*),
intent(in) :: bulkflux_type
771 real(
rp),
intent(out) :: rhou_t (
ka,
ia,
ja)
772 real(
rp),
intent(out) :: rhov_t (
ka,
ia,
ja)
773 real(
rp),
intent(out) :: rhot_t (
ka,
ia,
ja)
774 real(
rp),
intent(out) :: rhoqv_t(
ka,
ia,
ja)
776 real(
rp),
intent(out) :: nu (
ka,
ia,
ja)
777 real(
rp),
intent(out) :: kh (
ka,
ia,
ja)
778 real(
rp),
intent(out) :: qlp (
ka,
ia,
ja)
779 real(
rp),
intent(out) :: cldfrac(
ka,
ia,
ja)
780 real(
rp),
intent(out) :: zi (
ia,
ja)
781 real(
rp),
intent(out) :: sflx_buoy (
ia,
ja)
792 real(
rp) :: rho_h(
ka)
805 real(
rp) :: rhonu (
ka)
806 real(
rp) :: rhokh (
ka)
807 real(
rp) :: n2_new(
ka)
809 real(
rp) :: sm25 (
ka)
810 real(
rp) :: sh25 (
ka)
820 real(
rp) :: prod_t(
ka)
821 real(
rp) :: prod_q(
ka)
822 real(
rp) :: prod_c(
ka)
823 real(
rp) :: diss_p(
ka)
824 real(
rp) :: dtldz(
ka)
825 real(
rp) :: dqwdz(
ka)
827 real(
rp) :: shpgh(
ka)
828 real(
rp) :: gammat (
ka)
829 real(
rp) :: gammaq (
ka)
830 real(
rp) :: rlqsm_h(
ka)
832 real(
rp) :: flx(0:
ka)
838 real(
rp) :: phi_n(
ka)
839 real(
rp) :: dummy(
ka)
849 logical :: mynn_level3
857 real(
rp) :: tflux(0:
ka)
858 real(
rp) :: qflux(0:
ka)
859 real(
rp) :: uflux(0:
ka)
860 real(
rp) :: vflux(0:
ka)
861 real(
rp) :: eflux(0:
ka)
872 real(
rp) :: ptlv (
ka)
873 real(
rp) :: nu_f (
ka)
874 real(
rp) :: kh_f (
ka)
875 real(
rp) :: q2_2 (
ka)
877 real(
rp) :: betat(
ka)
878 real(
rp) :: betaq(
ka)
880 real(
rp) :: f_smp (
ka)
881 real(
rp) :: f_shpgh(
ka)
882 real(
rp) :: f_gamma(
ka)
883 real(
rp) :: tltv25 (
ka)
884 real(
rp) :: qwtv25 (
ka)
885 real(
rp) :: tvsq25 (
ka)
886 real(
rp) :: tvsq_up(
ka)
887 real(
rp) :: tvsq_lo(
ka)
888 real(
rp) :: dtsq (
ka)
889 real(
rp) :: dqsq (
ka)
890 real(
rp) :: dcov (
ka)
892 real(
rp) :: mflux(0:
ka)
895 real(
rp) :: qw2(
ka), qh(
ka)
896 real(
rp) :: tlh(
ka), tvh(
ka)
897 real(
rp) :: eh(
ka), dh(
ka)
898 real(
rp) :: teml(
ka), lhvl(
ka), psat(
ka)
901 real(
rp) :: work(
ka,4)
908 log_progress(*)
"atmosphere / physics / pbl / MYNN"
910 mynn_level3 = ( atmos_phy_bl_mynn_level ==
"3" )
912 select case ( bulkflux_type )
920 log_error(
"ATMOS_PHY_BL_MYNN_tendency",*)
"BULKFLUX_type is invalid: ", trim(bulkflux_type)
994 z(
k) = cz(
k,i,j) - fz(
ks-1,i,j)
1000 if ( atmos_phy_bl_mynn_pbl_max >= z(
k) )
then
1008 cdz(
k) = fz(
k,i,j) - fz(
k-1,i,j)
1011 fdz(
k) = cz(
k+1,i,j) - cz(
k,i,j)
1015 tke(
k) = max( prog(
k,i,j,i_tke), atmos_phy_bl_mynn_tke_min )
1018 if ( mynn_level3 )
then
1020 tsq(
k) = max( prog(
k,i,j,i_tsq), 0.0_rp )
1021 qsq(
k) = max( prog(
k,i,j,i_qsq), 0.0_rp )
1022 cov(
k) = prog(
k,i,j,i_cov)
1023 cov(
k) = sign( min( abs(cov(
k)), sqrt(tsq(
k) * qsq(
k))), cov(
k) )
1027 cptot = cpdry + sflx_qv(i,j) * (
cp_vapor - cpdry )
1028 sflx_pt = sflx_sh(i,j) / ( cptot * exner(
ks,i,j) )
1030 call mynn_main(
ka,
ks, ke_pbl, &
1032 tke(:), tsq(:), qsq(:), cov(:), &
1033 q(:), l(:,i,j), lq(:), &
1034 nu(:,i,j), rhonu(:), kh(:,i,j), rhokh(:), pr(:,i,j), &
1035 prod(:,i,j), prod_t(:), prod_q(:), prod_c(:), &
1036 diss(:,i,j), diss_p(:), &
1037 sm25(:), smp(:), sh25(:), shpgh(:), &
1038 gammat(:), gammaq(:), &
1039 dudz2(:,i,j), n2_new(:), ri(:,i,j), &
1040 dtldz(:), dqwdz(:), &
1042 uflux(:), vflux(:), tflux(:), qflux(:), eflux(:), &
1043 qlp(:,i,j), cldfrac(:,i,j), zi(i,j), sflx_buoy(i,j), &
1044 u(:,i,j), v(:,i,j), w(:,i,j), &
1045 dens(:,i,j), pres(:,i,j), &
1046 pott(:,i,j), potl(:,i,j), potv(:,i,j), &
1047 qw(:,i,j), n2(:,i,j), &
1048 exner(:,i,j), qdry(:,i,j), &
1049 sflx_pt, sflx_sh(i,j), sflx_qv(i,j), sfc_dens(i,j), &
1050 rlmo(i,j), us(i,j), ts(i,j), qs(i,j), &
1051 z(:), cdz(:), fdz(:), f2h(:,:,i,j), &
1055 mynn_level3, .false., &
1059 ptlv(:), nu_f(:), kh_f(:), q2_2(:), ac(:), &
1060 betat(:), betaq(:), &
1061 flx(:), a(:), b(:), c(:), d(:), &
1062 f_smp(:), f_shpgh(:), f_gamma(:), &
1063 tltv25(:), qwtv25(:), tvsq25(:), &
1064 tvsq_up(:), tvsq_lo(:), dtsq(:), dqsq(:), dcov(:), &
1066 uh(:), vh(:), wh(:), qw2(:), qh(:), &
1067 tlh(:), tvh(:), eh(:), dh(:), &
1068 teml(:), lhvl(:), psat(:) )
1074 flx(ke_pbl) = 0.0_rp
1077 rlqsm_h(
k) = rho_h(
k) * ( f2h(
k,1,i,j) * lq(
k+1) * smp(
k+1) + f2h(
k,2,i,j) * lq(
k) * smp(
k) )
1082 if ( atmos_phy_bl_mynn_mf )
then
1089 flx(
k) = - rlqsm_h(
k) * ( u(
k+1,i,j) - u(
k,i,j) ) / fdz(
k)
1093 sf_t = sflx_mu(i,j) / cdz(
ks)
1094 d(
ks) = ( u(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
1096 d(
k) = u(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
1100 ap = - dt * rhonu(
k) / fdz(
k)
1101 a(
k) = ap / ( rho(
k) * cdz(
k) )
1104 b(
k) = - a(
k) + 1.0_rp
1106 b(
k) = - a(
k) + dt * rhonu(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) + 1.0_rp
1109 b(
k) = - a(
k) - c(
k) + 1.0_rp
1111 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1114 b(ke_pbl) = - c(ke_pbl) + 1.0_rp
1116 call matrix_solver_tridiagonal( &
1121 a(:), b(:), c(:), d(:), &
1125 phi_n(
ks:ke_pbl) = dummy(
ks:ke_pbl)
1126 rhou_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - u(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
1128 rhou_t(
k,i,j) = ( phi_n(
k) - u(
k,i,j) ) * rho(
k) / dt
1131 rhou_t(
k,i,j) = 0.0_rp
1133 flxu(
ks-1,i,j) = 0.0_rp
1134 flxu2(
ks-1,i,j) = 0.0_rp
1136 flxu(
k,i,j) = flx(
k) &
1137 - rhonu(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
1138 flxu2(
k,i,j) = flx(
k)
1141 flxu(
k,i,j) = 0.0_rp
1142 flxu2(
k,i,j) = 0.0_rp
1148 if ( atmos_phy_bl_mynn_mf )
then
1155 flx(
k) = - rlqsm_h(
k) * ( v(
k+1,i,j) - v(
k,i,j) ) / fdz(
k)
1159 sf_t = sflx_mv(i,j) / cdz(
ks)
1160 d(
ks) = ( v(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
1162 d(
k) = v(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
1166 call matrix_solver_tridiagonal( &
1171 a(:), b(:), c(:), d(:), &
1174 rhov_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - v(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
1176 rhov_t(
k,i,j) = ( phi_n(
k) - v(
k,i,j) ) * rho(
k) / dt
1179 rhov_t(
k,i,j) = 0.0_rp
1181 flxv(
ks-1,i,j) = 0.0_rp
1182 flxv2(
ks-1,i,j) = 0.0_rp
1184 flxv(
k,i,j) = flx(
k) &
1185 - rhonu(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
1186 flxv2(
k,i,j) = flx(
k)
1189 flxv(
k,i,j) = 0.0_rp
1190 flxv2(
k,i,j) = 0.0_rp
1196 if ( atmos_phy_bl_mynn_mf )
then
1203 flx(
k) = - ( f2h(
k,1,i,j) * lq(
k+1) * gammat(
k+1) + f2h(
k,2,i,j) * lq(
k) * gammat(
k) ) &
1208 sf_t = sflx_pt / cdz(
ks)
1210 d(
ks) = pott(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) / rho(
ks)
1212 d(
k) = pott(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
1217 ap = - dt * rhokh(
k) / fdz(
k)
1218 a(
k) = ap / ( rho(
k) * cdz(
k) )
1221 b(
k) = - a(
k) + 1.0_rp
1223 b(
k) = - a(
k) + dt * rhokh(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) + 1.0_rp
1226 b(
k) = - a(
k) - c(
k) + 1.0_rp
1228 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1231 b(ke_pbl) = - c(ke_pbl) + 1.0_rp
1233 call matrix_solver_tridiagonal( &
1238 a(:), b(:), c(:), d(:), &
1241 rhot_t(
ks,i,j) = ( phi_n(
ks) - pott(
ks,i,j) ) * rho(
ks) / dt - sf_t
1243 rhot_t(
k,i,j) = ( phi_n(
k) - pott(
k,i,j) ) * rho(
k) / dt
1246 rhot_t(
k,i,j) = 0.0_rp
1248 flxt(
ks-1,i,j) = 0.0_rp
1249 flxt2(
ks-1,i,j) = 0.0_rp
1251 flxt(
k,i,j) = flx(
k) &
1252 - rhokh(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
1253 flxt2(
k,i,j) = flx(
k)
1256 flxt(
k,i,j) = 0.0_rp
1257 flxt2(
k,i,j) = 0.0_rp
1261 if ( flxt(
ks,i,j) > 1e-4_rp )
then
1262 fmin = flxt(
ks,i,j) / rho_h(
ks)
1264 do k =
ks+1, ke_pbl-2
1265 tmp = ( flxt(
k-1,i,j) + flxt(
k,i,j) + flxt(
k+1,i,j) ) &
1266 / ( rho_h(
k-1) + rho_h(
k) + rho_h(
k+1) )
1267 if ( fmin < 0.0_rp .and. tmp > fmin )
exit
1268 if ( tmp < fmin )
then
1274 zi(i,j) = fz(kmin,i,j) - fz(
ks-1,i,j)
1278 if ( atmos_phy_bl_mynn_mf )
then
1285 flx(
k) = - ( f2h(
k,1,i,j) * lq(
k+1) * gammaq(
k+1) + f2h(
k,2,i,j) * lq(
k) * gammaq(
k) ) &
1290 sf_t = sflx_qv(i,j) / cdz(
ks)
1291 d(
ks) = ( qv(
ks,i,j) * dens(
ks,i,j) + dt * ( sf_t - flx(
ks) / cdz(
ks) ) ) / rho(
ks)
1293 d(
k) = qv(
k,i,j) - dt * ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) )
1296 call matrix_solver_tridiagonal( &
1301 a(:), b(:), c(:), d(:), &
1304 rhoqv_t(
ks,i,j) = ( phi_n(
ks) * rho(
ks) - qv(
ks,i,j) * dens(
ks,i,j) ) / dt - sf_t
1306 rhoqv_t(
k,i,j) = ( phi_n(
k) - qv(
k,i,j) ) * rho(
k) / dt
1309 rhoqv_t(
k,i,j) = 0.0_rp
1311 flxq(
ks-1,i,j) = 0.0_rp
1312 flxq2(
ks-1,i,j) = 0.0_rp
1314 flxq(
k,i,j) = flx(
k) &
1315 - rhokh(
k) * ( phi_n(
k+1) - phi_n(
k) ) / fdz(
k)
1316 flxq2(
k,i,j) = flx(
k)
1319 flxq(
k,i,j) = 0.0_rp
1320 flxq2(
k,i,j) = 0.0_rp
1336 d(
k) = tke(
k) * dens(
k,i,j) / rho(
k) + dt * ( - ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) ) + prod(
k,i,j) )
1342 ap = - dt * atmos_phy_bl_mynn_sq_fact * rhonu(
k) / fdz(
k)
1343 a(
k) = ap / ( rho(
k) * cdz(
k) )
1346 b(
k) = - a(
k) + 1.0_rp - diss(
k,i,j) * dt
1348 b(
k) = - a(
k) + dt * atmos_phy_bl_mynn_sq_fact * rhonu(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) + 1.0_rp - diss(
k,i,j) * dt
1351 b(
k) = - a(
k) - c(
k) + 1.0_rp - diss(
k,i,j) * dt
1353 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1357 call matrix_solver_tridiagonal( &
1362 a(:), b(:), c(:), d(:), &
1366 phi_n(
k) = max( phi_n(
k), atmos_phy_bl_mynn_tke_min )
1370 diss(
k,i,j) = diss(
k,i,j) * phi_n(
k)
1371 rprog_t(
k,i,j,i_tke) = ( phi_n(
k) * rho(
k) - prog(
k,i,j,i_tke) * dens(
k,i,j) ) / dt
1375 rprog_t(
k,i,j,i_tke) = - atmos_phy_bl_mynn_dump_coef * prog(
k,i,j,i_tke) * dens(
k,i,j) / dt
1376 diss(
k,i,j) = 0.0_rp
1377 prod(
k,i,j) = 0.0_rp
1381 if ( mynn_level3 )
then
1386 diss_p(
k) = dt * 2.0_rp * q(
k) / ( b2 * l(
k,i,j) )
1389 d(
k) = tsq(
k) * dens(
k,i,j) / rho(
k) + dt * prod_t(
k)
1394 ap = - dt * rhonu(
k) / fdz(
k)
1395 a(
k) = ap / ( rho(
k) * cdz(
k) )
1398 b(
k) = - a(
k) + diss_p(
k)
1400 b(
k) = - a(
k) + dt * rhonu(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) + diss_p(
k)
1403 b(
k) = - a(
k) - c(
k) + 1.0_rp + diss_p(
k)
1405 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
1408 b(ke_pbl) = - c(ke_pbl) + 1.0_rp + diss_p(ke_pbl)
1410 call matrix_solver_tridiagonal( &
1415 a(:), b(:), c(:), d(:), &
1419 tsq(
k) = max( tsq(
k), 0.0_rp )
1423 rprog_t(
k,i,j,i_tsq) = ( tsq(
k) * rho(
k) - prog(
k,i,j,i_tsq) * dens(
k,i,j) ) / dt
1427 rprog_t(
k,i,j,i_tsq) = - atmos_phy_bl_mynn_dump_coef * prog(
k,i,j,i_tsq) * dens(
k,i,j) / dt
1434 d(
k) = qsq(
k) * dens(
k,i,j) / rho(
k) + dt * prod_q(
k)
1438 call matrix_solver_tridiagonal( &
1443 a(:), b(:), c(:), d(:), &
1447 qsq(
k) = max( qsq(
k), 0.0_rp )
1451 rprog_t(
k,i,j,i_qsq) = ( qsq(
k) * rho(
k) - prog(
k,i,j,i_qsq) * dens(
k,i,j) ) / dt
1455 rprog_t(
k,i,j,i_qsq) = - atmos_phy_bl_mynn_dump_coef * prog(
k,i,j,i_qsq) * dens(
k,i,j) / dt
1462 d(
k) = cov(
k) * dens(
k,i,j) / rho(
k) + dt * prod_c(
k)
1467 call matrix_solver_tridiagonal( &
1472 a(:), b(:), c(:), d(:), &
1476 cov(
k) = sign( min( abs(cov(
k)), sqrt(tsq(
k)*qsq(
k)) ), cov(
k) )
1480 rprog_t(
k,i,j,i_cov) = ( cov(
k) * rho(
k) - prog(
k,i,j,i_cov) * dens(
k,i,j) ) / dt
1484 rprog_t(
k,i,j,i_cov) = - atmos_phy_bl_mynn_dump_coef * prog(
k,i,j,i_cov) * dens(
k,i,j) / dt
1489 nu(
ks-1,i,j) = 0.0_rp
1490 kh(
ks-1,i,j) = 0.0_rp
1495 prod(
k,i,j) = 0.0_rp
1496 diss(
k,i,j) = 0.0_rp
1501 dudz2(
k,i,j) = undef
1504 cldfrac(
k,i,j) = undef
1513 call file_history_query(hist_ri, do_put)
1514 if ( do_put )
call file_history_put(hist_ri, ri(:,:,:))
1515 call file_history_query(hist_pr, do_put)
1516 if ( do_put )
call file_history_put(hist_pr, pr(:,:,:))
1517 call file_history_query(hist_tke_pr, do_put)
1518 if ( do_put )
call file_history_put(hist_tke_pr, prod(:,:,:))
1519 call file_history_query(hist_tke_di, do_put)
1520 if ( do_put )
call file_history_put(hist_tke_di, diss(:,:,:))
1521 call file_history_query(hist_dudz2, do_put)
1522 if ( do_put )
call file_history_put(hist_dudz2, dudz2(:,:,:))
1523 call file_history_query(hist_lmix, do_put)
1524 if ( do_put )
call file_history_put(hist_lmix, l(:,:,:))
1526 call file_history_query(hist_flxu, do_put)
1527 if ( do_put )
call file_history_put(hist_flxu, flxu(1:,:,:))
1528 call file_history_query(hist_flxv, do_put)
1529 if ( do_put )
call file_history_put(hist_flxv, flxv(1:,:,:))
1530 call file_history_query(hist_flxt, do_put)
1531 if ( do_put )
call file_history_put(hist_flxt, flxt(1:,:,:))
1532 call file_history_query(hist_flxq, do_put)
1533 if ( do_put )
call file_history_put(hist_flxq, flxq(1:,:,:))
1535 call file_history_query(hist_flxu2, do_put)
1536 if ( do_put )
call file_history_put(hist_flxu2, flxu2(1:,:,:))
1537 call file_history_query(hist_flxv2, do_put)
1538 if ( do_put )
call file_history_put(hist_flxv2, flxv2(1:,:,:))
1539 call file_history_query(hist_flxt2, do_put)
1540 if ( do_put )
call file_history_put(hist_flxt2, flxt2(1:,:,:))
1541 call file_history_query(hist_flxq2, do_put)
1542 if ( do_put )
call file_history_put(hist_flxq2, flxq2(1:,:,:))
1553 subroutine mynn_main( &
1556 tke, tsq, qsq, cov, &
1558 Nu, RHONu, Kh, RHOKh, Pr, &
1559 prod, prod_t, prod_q, prod_c, &
1561 sm25, smp, sh25, shpgh, &
1563 dudz2, n2_new, Ri, &
1566 uflux, vflux, tflux, qflux, eflux, &
1567 Qlp, cldfrac, Zi, SFLX_BUOY, &
1573 SFLX_PT, SFLX_SH, SFLX_QV, SFC_DENS, &
1579 mynn_level3, initialize, &
1583 PTLV, Nu_f, Kh_f, q2_2, ac, betat, betaq, &
1585 f_smp, f_shpgh, f_gamma, tltv25, qwtv25, tvsq25, &
1586 tvsq_up, tvsq_lo, dtsq, dqsq, dcov, &
1588 Uh, Vh, Wh, qw2, qh, tlh, tvh, eh, dh, &
1597 matrix_solver_tridiagonal
1598 integer,
intent(in) ::
ka,
ks, ke_pbl
1599 integer,
intent(in) :: i, j
1600 real(
rp),
intent(inout) :: tke(
ka)
1601 real(
rp),
intent(inout) :: tsq(
ka)
1602 real(
rp),
intent(inout) :: qsq(
ka)
1603 real(
rp),
intent(inout) :: cov(
ka)
1604 real(
rp),
intent(out) :: q(
ka)
1605 real(
rp),
intent(out) :: l(
ka)
1606 real(
rp),
intent(out) :: lq(
ka)
1607 real(
rp),
intent(out) :: nu(
ka)
1608 real(
rp),
intent(out) :: rhonu(
ka)
1609 real(
rp),
intent(out) :: kh(
ka)
1610 real(
rp),
intent(out) :: rhokh(
ka)
1611 real(
rp),
intent(out) :: pr(
ka)
1612 real(
rp),
intent(out) :: prod(
ka)
1613 real(
rp),
intent(out) :: prod_t(
ka)
1614 real(
rp),
intent(out) :: prod_q(
ka)
1615 real(
rp),
intent(out) :: prod_c(
ka)
1616 real(
rp),
intent(out) :: diss(
ka)
1617 real(
rp),
intent(out) :: diss_p(
ka)
1618 real(
rp),
intent(out) :: sm25(
ka)
1619 real(
rp),
intent(out) :: smp(
ka)
1620 real(
rp),
intent(out) :: sh25(
ka)
1621 real(
rp),
intent(out) :: shpgh(
ka)
1622 real(
rp),
intent(out) :: gammat(
ka)
1623 real(
rp),
intent(out) :: gammaq(
ka)
1624 real(
rp),
intent(out) :: dudz2(
ka)
1625 real(
rp),
intent(out) :: n2_new(
ka)
1626 real(
rp),
intent(out) :: ri(
ka)
1627 real(
rp),
intent(out) :: dtldz(
ka)
1628 real(
rp),
intent(out) :: dqwdz(
ka)
1629 real(
rp),
intent(out) :: rho(
ka)
1630 real(
rp),
intent(out) :: rho_h(
ka)
1631 real(
rp),
intent(out) :: uflux(
ka)
1632 real(
rp),
intent(out) :: vflux(
ka)
1633 real(
rp),
intent(out) :: tflux(
ka)
1634 real(
rp),
intent(out) :: qflux(
ka)
1635 real(
rp),
intent(out) :: eflux(
ka)
1636 real(
rp),
intent(out) :: qlp(
ka)
1637 real(
rp),
intent(out) :: cldfrac(
ka)
1638 real(
rp),
intent(out) :: zi
1639 real(
rp),
intent(out) :: sflx_buoy
1640 real(
rp),
intent(in) :: u(
ka)
1641 real(
rp),
intent(in) :: v(
ka)
1642 real(
rp),
intent(in) :: w(
ka)
1643 real(
rp),
intent(in) :: dens(
ka)
1644 real(
rp),
intent(in) :: pres(
ka)
1645 real(
rp),
intent(in) :: pott(
ka)
1646 real(
rp),
intent(in) :: potl(
ka)
1647 real(
rp),
intent(in) :: potv(
ka)
1648 real(
rp),
intent(in) :: qw(
ka)
1649 real(
rp),
intent(in) :: n2(
ka)
1650 real(
rp),
intent(in) :: exner(
ka)
1651 real(
rp),
intent(in) :: qdry(
ka)
1652 real(
rp),
intent(in) :: sflx_pt
1653 real(
rp),
intent(in) :: sflx_sh
1654 real(
rp),
intent(in) :: sflx_qv
1655 real(
rp),
intent(in) :: sfc_dens
1656 real(
rp),
intent(in) :: rlmo
1657 real(
rp),
intent(in) :: us
1658 real(
rp),
intent(in) :: ts
1659 real(
rp),
intent(in) :: qs
1660 real(
rp),
intent(in) :: z(
ka)
1661 real(
rp),
intent(in) :: cdz(
ka)
1662 real(
rp),
intent(in) :: fdz(
ka)
1663 real(
rp),
intent(in) :: f2h(
ka,2)
1664 real(
rp),
intent(in) :: frac_land
1665 real(
rp),
intent(in) :: dt
1666 integer,
intent(in) :: i_b_type
1667 logical,
intent(in) :: mynn_level3
1668 logical,
intent(in) :: initialize
1671 real(
rp),
intent(out) :: ptlv (
ka)
1672 real(
rp),
intent(out) :: nu_f (
ka)
1673 real(
rp),
intent(out) :: kh_f (
ka)
1674 real(
rp),
intent(out) :: q2_2 (
ka)
1675 real(
rp),
intent(out) :: ac (
ka)
1676 real(
rp),
intent(out) :: betat(
ka)
1677 real(
rp),
intent(out) :: betaq(
ka)
1679 real(
rp),
intent(out) :: flx(0:
ka)
1680 real(
rp),
intent(out) :: a(
ka)
1681 real(
rp),
intent(out) :: b(
ka)
1682 real(
rp),
intent(out) :: c(
ka)
1683 real(
rp),
intent(out) :: d(
ka)
1688 real(
rp) :: phi_m, phi_h
1692 real(
rp),
intent(out) :: f_smp (
ka)
1693 real(
rp),
intent(out) :: f_shpgh(
ka)
1694 real(
rp),
intent(out) :: f_gamma(
ka)
1695 real(
rp),
intent(out) :: tltv25 (
ka)
1696 real(
rp),
intent(out) :: qwtv25 (
ka)
1697 real(
rp),
intent(out) :: tvsq25 (
ka)
1698 real(
rp),
intent(out) :: tvsq_up(
ka)
1699 real(
rp),
intent(out) :: tvsq_lo(
ka)
1700 real(
rp),
intent(out) :: dtsq (
ka)
1701 real(
rp),
intent(out) :: dqsq (
ka)
1702 real(
rp),
intent(out) :: dcov (
ka)
1710 real(
rp),
intent(out) :: mflux(0:
ka)
1713 real(
rp),
intent(out) :: uh(
ka), vh(
ka), wh(
ka)
1714 real(
rp),
intent(out) :: qw2(
ka), qh(
ka)
1715 real(
rp),
intent(out) :: tlh(
ka), tvh(
ka)
1716 real(
rp),
intent(out) :: eh(
ka), dh(
ka)
1717 real(
rp),
intent(out) :: teml(
ka), lhvl(
ka), psat(
ka)
1720 real(
rp),
intent(out) :: work(
ka,4)
1725 integer ::
k, it, nit
1728 if ( atmos_phy_bl_mynn_similarity .or. initialize )
then
1729 call get_phi( zeta, phi_m, phi_h, &
1730 z(
ks), rlmo, i_b_type )
1735 dudz2(:), dtldz(:), dqwdz(:), &
1736 u(:), v(:), potl(:), &
1738 cdz(:), fdz(:), f2h(:,:), &
1740 phi_m, phi_h, z(
ks), &
1741 uh(:), vh(:), qw2(:), qh(:) )
1746 q(
k) = sqrt( max( tke(
k), atmos_phy_bl_mynn_tke_min ) * 2.0_rp )
1749 if ( atmos_phy_bl_mynn_use_zi )
then
1751 ptlv(
k) = potl(
k) * ( 1.0_rp + epstvap * qw(
k) )
1753 call calc_zi_o2019(
ka,
ks, ke_pbl, &
1760 if ( initialize .or. (.not. mynn_level3) )
then
1764 n2_new(
k) = min( max( n2(
k), - atmos_phy_bl_mynn_n2_max ), atmos_phy_bl_mynn_n2_max )
1765 ri(
k) = n2_new(
k) / dudz2(
k)
1767 if ( initialize )
then
1768 dudz2(
ks) = max( dudz2(
ks), 1e-4_rp )
1769 n2_new(
ks) = min( n2_new(
ks), 0.0_rp )
1770 ri(
ks) = n2_new(
ks) / dudz2(
ks)
1773 sflx_buoy = - us3 * rlmo / karman
1775 if ( atmos_phy_bl_mynn_mf )
then
1781 dens(:), potv(:), potl(:), qw(:), &
1782 u(:), v(:), w(:), tke(:), &
1785 sflx_sh, sflx_buoy, &
1788 zi, z(:), cdz(:), f2h(:,:), &
1790 tflux(:), qflux(:), &
1791 uflux(:), vflux(:), eflux(:), &
1792 tlh(:), tvh(:), qh(:), &
1793 uh(:), vh(:), wh(:), eh(:), dh(:) )
1804 z(:), cdz(:), fdz(:), &
1808 call get_q2_level2( &
1810 dudz2(:), ri(:), l(:), &
1813 if ( initialize )
then
1815 q(
k) = sqrt( q2_2(
k) )
1820 ac(
k) = min( q(
k) / sqrt( q2_2(
k) + 1e-20_rp ), 1.0_rp )
1829 potv(:), dudz2(:), &
1830 dtldz(:), dqwdz(:), &
1831 betat(:), betaq(:), &
1833 tsq(:), qsq(:), cov(:), &
1834 sm25(:), f_smp(:), &
1835 sh25(:), f_shpgh(:), &
1837 tltv25(:), qwtv25(:), &
1839 tvsq_up(:), tvsq_lo(:) )
1844 flx(ke_pbl) = 0.0_rp
1846 if ( initialize )
then
1856 betat(:), betaq(:), &
1857 qlp(:), cldfrac(:), &
1861 tsq(:), qsq(:), cov(:), &
1862 teml(:), lhvl(:), psat(:) )
1866 n2_new(
k) = min(atmos_phy_bl_mynn_n2_max, &
1867 grav * ( dtldz(
k) * betat(
k) + dqwdz(
k) * betaq(
k) ) / potv(
k) )
1868 ri(
k) = n2_new(
k) / dudz2(
k)
1871 sflx_buoy = grav / potv(
ks) * ( betat(
ks) * sflx_pt + betaq(
ks) * sflx_qv ) / sfc_dens
1874 if ( atmos_phy_bl_mynn_use_zi )
then
1876 ptlv(
k) = potl(
k) * betat(
k) + qw(
k) * betaq(
k)
1878 call calc_zi_o2019(
ka,
ks, ke_pbl, &
1885 if ( atmos_phy_bl_mynn_mf )
then
1888 dens(:), potv(:), potl(:), qw(:), &
1889 u(:), v(:), w(:), tke(:), &
1892 sflx_sh, sflx_buoy, &
1895 zi, z(:), cdz(:), f2h(:,:), &
1897 tflux(:), qflux(:), &
1898 uflux(:), vflux(:), eflux(:), &
1899 tlh(:), tvh(:), qh(:), &
1900 uh(:), vh(:), wh(:), eh(:), dh(:) )
1912 z(:), cdz(:), fdz(:), &
1916 call get_q2_level2( &
1918 dudz2(:), ri(:), l(:), &
1922 ac(
k) = min( q(
k) / sqrt( q2_2(
k) + 1e-20_rp ), 1.0_rp )
1931 potv(:), dudz2(:), &
1932 dtldz(:), dqwdz(:), &
1933 betat(:), betaq(:), &
1935 initialize .and. it==1, &
1936 tsq(:), qsq(:), cov(:), &
1937 sm25(:), f_smp(:), &
1938 sh25(:), f_shpgh(:), &
1940 tltv25(:), qwtv25(:), &
1942 tvsq_up(:), tvsq_lo(:) )
1946 nu_f(
k) = lq(
k) * sm25(
k)
1947 kh_f(
k) = lq(
k) * sh25(
k)
1949 if ( atmos_phy_bl_mynn_similarity )
then
1950 nu_f(
ks) = karman * z(
ks) * us / phi_m
1951 kh_f(
ks) = karman * z(
ks) * us / phi_h
1955 nu(
k) = min( f2h(
k,1) * nu_f(
k+1) + f2h(
k,2) * nu_f(
k), &
1956 atmos_phy_bl_mynn_nu_max )
1957 kh(
k) = min( f2h(
k,1) * kh_f(
k+1) + f2h(
k,2) * kh_f(
k), &
1958 atmos_phy_bl_mynn_kh_max )
1962 sw = 0.5_rp - sign(0.5_rp, abs(kh(
k)) - eps)
1963 pr(
k) = nu(
k) / ( kh(
k) + sw ) * ( 1.0_rp - sw ) &
1967 rho(
ks) = dens(
ks) + dt * sflx_qv / cdz(
ks)
1973 rho_h(
k) = f2h(
k,1) * rho(
k+1) + f2h(
k,2) * rho(
k)
1974 rhonu(
k) = max( nu(
k) * rho_h(
k), 1e-20_rp )
1975 rhokh(
k) = max( kh(
k) * rho_h(
k), 1e-20_rp )
1981 if ( mynn_level3 )
then
1985 tltv = betat(
k) * tsq(
k) + betaq(
k) * cov(
k)
1986 qwtv = betat(
k) * cov(
k) + betaq(
k) * qsq(
k)
1987 gammat(
k) = f_gamma(
k) * ( tltv - tltv25(
k) )
1988 gammaq(
k) = f_gamma(
k) * ( qwtv - qwtv25(
k) )
1990 wtl = - lq(
k) * ( sh25(
k) * dtldz(
k) + gammat(
k) )
1991 wqw = - lq(
k) * ( sh25(
k) * dqwdz(
k) + gammaq(
k) )
1992 prod_t(
k) = - 2.0_rp * wtl * dtldz(
k)
1993 prod_q(
k) = - 2.0_rp * wqw * dqwdz(
k)
1994 prod_c(
k) = - wtl * dqwdz(
k) - wqw * dtldz(
k)
1997 if ( atmos_phy_bl_mynn_similarity .or. initialize )
then
1998 tmp = 2.0_rp * us * phi_h / ( karman * z(
ks) )
1999 tmp = tmp * ( zeta / ( z(
ks) * rlmo ) )**2
2001 prod_t(
ks) = tmp * ts**2
2003 prod_q(
ks) = tmp * ts * qs
2005 prod_c(
ks) = tmp * qs**2
2010 flx(ke_pbl) = 0.0_rp
2012 flx(
k) = rhonu(
k) * ( tsq(
k+1) - tsq(
k) ) / fdz(
k)
2015 prod_t(
k) = prod_t(
k) + ( flx(
k) - flx(
k-1) ) / cdz(
k)
2018 flx(
k) = rhonu(
k) * ( qsq(
k+1) - qsq(
k) ) / fdz(
k)
2021 prod_q(
k) = prod_q(
k) + ( flx(
k) - flx(
k-1) ) / cdz(
k)
2024 flx(
k) = rhonu(
k) * ( cov(
k+1) - cov(
k) ) / fdz(
k)
2027 prod_c(
k) = prod_c(
k) + ( flx(
k) - flx(
k-1) ) / cdz(
k)
2030 call get_gamma_implicit( &
2033 tsq(:), qsq(:), cov(:), &
2034 dtldz(:), dqwdz(:), potv(:), &
2035 prod_t(:), prod_q(:), prod_c(:), &
2036 betat(:), betaq(:), &
2037 f_gamma(:), l(:), q(:), &
2039 dtsq(:), dqsq(:), dcov(:) )
2043 tltv = betat(
k) * ( tsq(
k) + dtsq(
k) ) + betaq(
k) * ( cov(
k) + dcov(
k) )
2044 qwtv = betat(
k) * ( cov(
k) + dcov(
k) ) + betaq(
k) * ( qsq(
k) + dqsq(
k) )
2045 gammat(
k) = f_gamma(
k) * ( tltv - tltv25(
k) )
2046 gammaq(
k) = f_gamma(
k) * ( qwtv - qwtv25(
k) )
2048 tvsq = max( betat(
k) * tltv + betaq(
k) * qwtv, 0.0_rp )
2049 tvsq = tvsq - tvsq25(
k)
2050 tvsq = min( max( tvsq, tvsq_lo(
k) ), tvsq_up(
k) )
2051 smp(
k) = f_smp(
k) * tvsq
2052 shpgh(
k) = f_shpgh(
k) * tvsq
2054 wtl = - lq(
k) * ( sh25(
k) * dtldz(
k) + gammat(
k) )
2055 wqw = - lq(
k) * ( sh25(
k) * dqwdz(
k) + gammaq(
k) )
2056 prod_t(
k) = - 2.0_rp * wtl * dtldz(
k)
2057 prod_q(
k) = - 2.0_rp * wqw * dqwdz(
k)
2058 prod_c(
k) = - wtl * dqwdz(
k) - wqw * dtldz(
k)
2061 if ( atmos_phy_bl_mynn_similarity .or. initialize )
then
2067 tmp = 2.0_rp * us * phi_h / ( karman * z(
ks) )
2068 tmp = tmp * ( zeta / ( z(
ks) * rlmo ) )**2
2070 prod_t(
ks) = tmp * ts**2
2072 prod_q(
ks) = tmp * ts * qs
2074 prod_c(
ks) = tmp * qs**2
2091 prod(
k) = lq(
k) * ( ( sm25(
k) + smp(
k) ) * dudz2(
k) &
2092 - ( sh25(
k) * n2_new(
k) - shpgh(
k) ) )
2094 if ( atmos_phy_bl_mynn_similarity .or. initialize )
then
2095 prod(
ks) = us3 / ( karman * z(
ks) ) * ( phi_m - zeta )
2099 diss(
k) = - 2.0_rp * q(
k) / ( b1 * l(
k) )
2101 diss_p(
k) = dt * 2.0_rp * q(
k) / ( b2 * l(
k) )
2105 if ( .not. initialize )
exit
2120 d(
k) = dt * ( - ( flx(
k) - flx(
k-1) ) / ( cdz(
k) * rho(
k) ) + prod(
k) )
2126 ap = - dt * atmos_phy_bl_mynn_sq_fact * rhonu(
k) / fdz(
k)
2127 a(
k) = ap / ( rho(
k) * cdz(
k) )
2130 b(
k) = - a(
k) - diss(
k) * dt
2132 b(
k) = - a(
k) + dt * atmos_phy_bl_mynn_sq_fact * rhonu(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) - diss(
k) * dt
2135 b(
k) = - a(
k) - c(
k) - diss(
k) * dt
2137 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
2140 b(ke_pbl) = - c(ke_pbl) - diss(ke_pbl) * dt
2142 call matrix_solver_tridiagonal( &
2147 a(:), b(:), c(:), d(:), &
2151 tke(
k) = min( max( tke(
k), atmos_phy_bl_mynn_tke_min ), 100.0_rp )
2153 tke(ke_pbl) = 0.0_rp
2157 q(
k) = ( q(
k) + sqrt( tke(
k) * 2.0_rp ) ) * 0.5_rp
2161 if ( .not. mynn_level3 ) cycle
2166 d(
k) = dt * prod_t(
k)
2171 ap = - dt * rhonu(
k) / fdz(
k)
2172 a(
k) = ap / ( rho(
k) * cdz(
k) )
2175 b(
k) = - a(
k) + diss_p(
k)
2177 b(
k) = - a(
k) + dt * rhonu(
k-1) / ( fdz(
k-1) * rho(
k) * cdz(
k) ) + diss_p(
k)
2180 b(
k) = - a(
k) - c(
k) + 1.0_rp + diss_p(
k)
2182 c(
k+1) = ap / ( rho(
k+1) * cdz(
k+1) )
2185 b(ke_pbl) = - c(ke_pbl) + diss_p(ke_pbl)
2187 call matrix_solver_tridiagonal( &
2192 a(:), b(:), c(:), d(:), &
2196 tsq(
k) = max( tsq(
k), 0.0_rp )
2198 tsq(ke_pbl) = 0.0_rp
2204 d(
k) = dt * prod_q(
k)
2209 call matrix_solver_tridiagonal( &
2214 a(:), b(:), c(:), d(:), &
2218 qsq(
k) = max( qsq(
k), 0.0_rp )
2220 qsq(ke_pbl) = 0.0_rp
2226 d(
k) = dt * prod_c(
k)
2231 call matrix_solver_tridiagonal( &
2236 a(:), b(:), c(:), d(:), &
2240 cov(
k) = sign( min( abs(cov(
k)), sqrt(tsq(
k)*qsq(
k)) ), cov(
k) )
2242 cov(ke_pbl) = 0.0_rp
2247 end subroutine mynn_main
2250 subroutine get_length( &
2266 integer,
intent(in),
value ::
ka,
ks, ke_pbl
2268 real(
rp),
intent(in) :: q(
ka)
2269 real(
rp),
intent(in) :: n2(
ka)
2270 real(
rp),
intent(in) :: potv(
ka)
2271 real(
rp),
intent(in) :: dens(
ka)
2272 real(
rp),
intent(in) :: mflux_gl(0:
ka)
2273 real(
rp),
intent(in) :: zi
2274 real(
rp),
intent(in) :: sflx_buoy
2275 real(
rp),
intent(in) :: rlmo
2276 real(
rp),
intent(in) :: z(
ka)
2277 real(
rp),
intent(in) :: cdz(
ka)
2278 real(
rp),
intent(in) :: fdz(
ka)
2279 logical,
intent(in) :: initialize
2281 real(
rp),
intent(out) :: l(
ka)
2283 real(
rp),
parameter :: sqrt05 = sqrt( 0.5_rp )
2306 if ( atmos_phy_bl_mynn_use_zi )
then
2310 if ( z(
k) > zi * 1.3_rp )
then
2325 int_qz = int_qz + z(
k) * qdz
2329 lt = min( max(0.23_rp * int_qz / (int_q + 1e-20_rp), &
2331 atmos_phy_bl_mynn_lt_max )
2334 qc = ( lt * max(sflx_buoy,0.0_rp) )**oneoverthree
2335 if ( atmos_phy_bl_mynn_o2019 )
then
2336 tau = 0.5_rp * zi / max(sflx_buoy,1.0e-10_rp)**oneoverthree
2344 sw = sign(0.5_rp, zeta) + 0.5_rp
2345 ls = karman * z(
k) &
2346 * ( sw / (1.0_rp + atmos_phy_bl_mynn_cns*zeta*sw ) &
2347 + ( (1.0_rp - atmos_phy_bl_mynn_alpha4*zeta)*(1.0_rp-sw) )**0.2_rp )
2350 sw = sign(0.5_rp, n2(
k)-eps) + 0.5_rp
2351 rn2sr = 1.0_rp / ( sqrt(n2(
k)*sw) + 1.0_rp-sw)
2352 if ( atmos_phy_bl_mynn_o2019 )
then
2353 if ( z(
k) > zi ) tau = 50.0_rp
2375 lb = atmos_phy_bl_mynn_alpha2 * max( q(
k), ( mflux_gl(
k)+mflux_gl(
k-1))/dens(
k) ) * rn2sr * sw &
2376 + tau * q(
k) * sqrt05 * (1.0_rp-sw)
2378 lb = atmos_phy_bl_mynn_alpha2 * (1.0_rp + 5.0_rp * sqrt(qc*rn2sr*rlt)) * q(
k) * rn2sr * sw &
2379 + 1.e10_rp * (1.0_rp-sw)
2383 if ( initialize )
then
2384 l(
k) = min( ls, lb )
2385 else if ( atmos_phy_bl_mynn_o2019 )
then
2386 l(
k) = min( 1.0_rp / ( 1.0_rp/ls + rlt ), lb )
2388 l(
k) = 1.0_rp / ( 1.0_rp/ls + rlt + 1.0_rp/(lb+1e-20_rp) )
2393 end subroutine get_length
2396 subroutine get_q2_level2( &
2402 integer,
intent(in),
value ::
ka,
ks, ke_pbl
2404 real(
rp),
intent(in) :: dudz2(
ka)
2405 real(
rp),
intent(in) :: ri(
ka)
2406 real(
rp),
intent(in) :: l(
ka)
2408 real(
rp),
intent(out) :: q2_2(
ka)
2415 real(
rp) :: a2k, f1, rf1, af12
2420 if ( atmos_phy_bl_mynn_k2010 .and. ri(
k) > 0.0_rp )
then
2421 a2k = a2 / ( 1.0_rp + ri(
k) )
2425 f1 = b1 * ( g1 - c1 ) + 2.0 * a1 * ( 3.0_rp - 2.0_rp * c2 ) + 3.0 * a2k * ( 1.0_rp - c2 ) * ( 1.0_rp - c5 )
2426 rf1 = b1 * ( g1 - c1 ) / f1
2427 af12 = a1 * f1 / ( a2k * f2 )
2428 rf = min(0.5_rp / af12 * ( ri(
k) &
2430 - sqrt(ri(
k)**2 + 2.0_rp*af12*(rf1-2.0_rp*rf2)*ri(
k) + (af12*rf1)**2) ), &
2432 sh_2 = 3.0_rp * a2k * (g1+g2) * (rfc-rf) / (1.0_rp-rf)
2433 sm_2 = sh_2 * af12 * (rf1-rf) / (rf2-rf)
2434 q2_2(
k) = b1 * l(
k)**2 * sm_2 * (1.0_rp-rf) * dudz2(
k)
2438 end subroutine get_q2_level2
2441 subroutine get_smsh( &
2464 integer,
intent(in),
value ::
ka,
ks, ke_pbl
2465 integer,
intent(in),
value :: i, j
2467 real(
rp),
intent(in) :: q(
ka)
2468 real(
rp),
intent(in) :: ac(
ka)
2469 real(
rp),
intent(in) :: l(
ka)
2470 real(
rp),
intent(in) :: n2(
ka)
2471 real(
rp),
intent(in) :: ri(
ka)
2472 real(
rp),
intent(in) :: potv(
ka)
2473 real(
rp),
intent(in) :: dudz2(
ka)
2474 real(
rp),
intent(in) :: dtldz(
ka)
2475 real(
rp),
intent(in) :: dqwdz(
ka)
2476 real(
rp),
intent(in) :: betat(
ka)
2477 real(
rp),
intent(in) :: betaq(
ka)
2478 logical,
intent(in),
value :: mynn_level3
2479 logical,
intent(in),
value :: initialize
2481 real(
rp),
intent(inout) :: tsq(
ka)
2482 real(
rp),
intent(inout) :: qsq(
ka)
2483 real(
rp),
intent(inout) :: cov(
ka)
2485 real(
rp),
intent(out) :: sm25 (
ka)
2486 real(
rp),
intent(out) :: f_smp (
ka)
2487 real(
rp),
intent(out) :: sh25 (
ka)
2488 real(
rp),
intent(out) :: f_shpgh(
ka)
2489 real(
rp),
intent(out) :: f_gamma(
ka)
2490 real(
rp),
intent(out) :: tltv25 (
ka)
2491 real(
rp),
intent(out) :: qwtv25 (
ka)
2492 real(
rp),
intent(out) :: tvsq25 (
ka)
2493 real(
rp),
intent(out) :: tvsq_up(
ka)
2494 real(
rp),
intent(out) :: tvsq_lo(
ka)
2508 real(
rp) :: f1, f2, f3, f4
2523 real(
rp) :: tmp1, tmp2
2533 if ( atmos_phy_bl_mynn_k2010 .and. ri(
k) > 0.0_rp )
then
2534 a2k = a2 / ( 1.0_rp + ri(
k) )
2543 f1 = - 3.0_rp * ac2 * a2k * b2 * ( 1.0_rp - c3 )
2544 f2 = - 9.0_rp * ac2 * a1 * a2k * ( 1.0_rp - c2 )
2545 f3 = 9.0_rp * ac2 * a2k**2 * ( 1.0_rp - c2 ) * ( 1.0_rp - c5 )
2546 f4 = - 12.0_rp * ac2 * a1 * a2k * ( 1.0_rp - c2 )
2548 if ( mynn_level3 )
then
2549 ghq2 = max( - n2(
k) * l2, -q2 )
2553 gmq2 = dudz2(
k) * l2
2555 p1q2 = q2 + f1 * ghq2
2556 p2q2 = q2 + f2 * ghq2
2557 p3q2 = q2 + ( f1 + f3 ) * ghq2
2558 p4q2 = q2 + ( f1 + f4 ) * ghq2
2559 p5q2 = 6.0_rp * ac2 * a1**2 * gmq2
2560 rd25q2 = q2 / max( p2q2 * p4q2 + p5q2 * p3q2, 1e-20_rp )
2562 sm25(
k) = ac(
k) * a1 * ( p3q2 - 3.0_rp * c1 * p4q2 ) * rd25q2
2563 sh25(
k) = ac(
k) * a2k * ( p2q2 + 3.0_rp * c1 * p5q2 ) * rd25q2
2565 fact = ac(
k) * b2 * l2 * sh25(
k)
2566 tsq25 = fact * dtldz(
k)**2
2567 qsq25 = fact * dqwdz(
k)**2
2568 cov25 = fact * dtldz(
k) * dqwdz(
k)
2570 if ( initialize .or. (.not. mynn_level3 ) )
then
2576 if ( mynn_level3 )
then
2578 if ( q2 <= 1e-10_rp )
then
2588 tltv25(
k) = betat(
k) * tsq25 + betaq(
k) * cov25
2589 qwtv25(
k) = betat(
k) * cov25 + betaq(
k) * qsq25
2590 tvsq25(
k) = max(betat(
k) * tltv25(
k) + betaq(
k) * qwtv25(
k), 0.0_rp)
2591 cw25 = p1q2 * ( p2q2 + 3.0_rp * c1 * p5q2 ) * rd25q2 / ( 3.0_rp * q2 )
2594 l2q2 = min( l2q2, 1.0_rp / max(n2(
k), eps) )
2597 rdpq2 = q2 / max( p2q2 * ( f4 * ghq2 + q2 ) + p5q2 * ( f3 * ghq2 + q2 ), 1e-20_rp )
2599 tltv = betat(
k) * tsq(
k) + betaq(
k) * cov(
k)
2600 qwtv = betat(
k) * cov(
k) + betaq(
k) * qsq(
k)
2601 tvsq = max(betat(
k) * tltv + betaq(
k) * qwtv, 0.0_rp)
2603 ew = ( 1.0_rp - c3 ) * ( - p2q2 * f4 - p5q2 * f3 ) * rdpq2
2604 if ( abs(ew) > eps )
then
2605 fact = q2 * potv(
k)**2 / ( ew * l2q2 * grav**2 )
2606 if ( fact > 0.0_rp )
then
2613 tvsq_up(
k) = ( tmp1 - cw25 ) * fact
2614 tvsq_lo(
k) = ( tmp2 - cw25 ) * fact
2620 emq2 = 3.0_rp * ac(
k) * a1 * ( 1.0_rp - c3 ) * ( f3 - f4 ) * rdpq2
2621 eh = 3.0_rp * ac(
k) * a2k * ( 1.0_rp - c3 ) * ( p2q2 + p5q2 ) * rdpq2
2624 fact = grav / potv(
k)
2625 f_smp(
k) = emq2 * fact**2 * l2q2
2626 f_shpgh(
k) = eh * fact**2 / q2
2627 f_gamma(
k) = - eh * fact / q2
2640 end subroutine get_smsh
2643 subroutine get_gamma_implicit( &
2647 dtldz, dqwdz, POTV, &
2648 prod_t, prod_q, prod_c, &
2657 integer,
intent(in),
value ::
ka,
ks,
ke
2658 integer,
intent(in),
value :: i, j
2660 real(
rp),
intent(in) :: tsq (
ka)
2661 real(
rp),
intent(in) :: qsq (
ka)
2662 real(
rp),
intent(in) :: cov (
ka)
2663 real(
rp),
intent(in) :: dtldz (
ka)
2664 real(
rp),
intent(in) :: dqwdz (
ka)
2665 real(
rp),
intent(in) :: potv (
ka)
2666 real(
rp),
intent(in) :: prod_t (
ka)
2667 real(
rp),
intent(in) :: prod_q (
ka)
2668 real(
rp),
intent(in) :: prod_c (
ka)
2669 real(
rp),
intent(in) :: betat (
ka)
2670 real(
rp),
intent(in) :: betaq (
ka)
2671 real(
rp),
intent(in) :: f_gamma(
ka)
2672 real(
rp),
intent(in) :: l (
ka)
2673 real(
rp),
intent(in) :: q (
ka)
2674 real(
rp),
intent(in),
value :: dt
2676 real(
rp),
intent(out) :: dtsq(
ka)
2677 real(
rp),
intent(out) :: dqsq(
ka)
2678 real(
rp),
intent(out) :: dcov(
ka)
2680 real(
rp) :: a11, a12, a21, a22, a23, a32, a33
2681 real(
rp) :: v1, v2, v3
2683 real(
rp) :: a13, a31, det
2692 f1 = f_gamma(
k) * l(
k) * q(
k)
2693 f2 = - 2.0_rp * q(
k) / ( b2 * l(
k) )
2695 v1 = prod_t(
k) + f2 * tsq(
k)
2696 v2 = prod_c(
k) + f2 * cov(
k)
2697 v3 = prod_q(
k) + f2 * qsq(
k)
2699 a11 = - f1 * dtldz(
k) * betat(
k) * 2.0_rp + 1.0_rp / dt - f2
2700 a12 = - f1 * dtldz(
k) * betaq(
k) * 2.0_rp
2701 a21 = - f1 * dqwdz(
k) * betat(
k)
2702 a22 = - f1 * ( dtldz(
k) * betat(
k) + dqwdz(
k) * betaq(
k) ) + 1.0_rp / dt - f2
2703 a23 = - f1 * dtldz(
k) * betaq(
k)
2704 a32 = - f1 * dqwdz(
k) * betat(
k) * 2.0_rp
2705 a33 = - f1 * dqwdz(
k) * betaq(
k) * 2.0_rp + 1.0_rp / dt - f2
2707 if ( q(
k) < 1e-20_rp .or. abs(f_gamma(
k)) * dt >= q(
k) )
then
2711 dcov(
k) = ( v2 - f1 * v1 - f2 * v3 ) / ( a22 - f1 * a12 - f2 * a32 )
2712 dtsq(
k) = ( v1 - a12 * dcov(
k) ) / a11
2713 dqsq(
k) = ( v3 - a32 * dcov(
k) ) / a33
2717 f1 = - l(
k) * grav / potv(
k) * f_gamma(
k) / q(
k)
2718 f2 = f1 * betat(
k)**2
2722 f2 = f1 * betat(
k) * betaq(
k) * 2.0_rp
2726 f2 = f1 * betaq(
k)**2
2731 det = a11 * ( a22 * a33 - a23 * a32 ) + a12 * ( a23 * a31 - a21 * a33 ) + a13 * ( a21 * a32 - a22 * a31 )
2732 dtsq(
k) = ( v1 * ( a22 * a33 - a23 * a32 ) + a12 * ( a23 * v3 - v2 * a33 ) + a13 * ( v2 * a32 - a22 * v3 ) ) / det
2733 dcov(
k) = ( a11 * ( v2 * a33 - a23 * v3 ) + v1 * ( a23 * a31 - a21 * a33 ) + a13 * ( a21 * v3 - v2 * a31 ) ) / det
2734 dqsq(
k) = ( a11 * ( a22 * v3 - v2 * a32 ) + a12 * ( v2 * a31 - a21 * v3 ) + v3 * ( a21 * a32 - a22 * a31 ) ) / det
2740 end subroutine get_gamma_implicit
2746 dudz2, dtldz, dqwdz, &
2747 U, V, POTL, Qw, QDRY, &
2755 integer,
intent(in),
value :: KA, KS, KE
2756 integer,
intent(in),
value :: i, j
2758 real(RP),
intent(out) :: dudz2(KA)
2759 real(RP),
intent(out) :: dtldz(KA)
2760 real(RP),
intent(out) :: dqwdz(KA)
2762 real(RP),
intent(in) :: U (KA)
2763 real(RP),
intent(in) :: V (KA)
2764 real(RP),
intent(in) :: POTL(KA)
2765 real(RP),
intent(in) :: Qw (KA)
2766 real(RP),
intent(in) :: QDRY(KA)
2767 real(RP),
intent(in) :: CDZ (KA)
2768 real(RP),
intent(in) :: FDZ (KA)
2769 real(RP),
intent(in) :: F2H (KA,2)
2770 real(RP),
intent(in) :: us
2771 real(RP),
intent(in) :: ts
2772 real(RP),
intent(in) :: qs
2773 real(RP),
intent(in) :: phi_m
2774 real(RP),
intent(in) :: phi_h
2775 real(RP),
intent(in) :: z1
2777 real(RP),
intent(out) :: Uh (KA)
2778 real(RP),
intent(out) :: Vh (KA)
2779 real(RP),
intent(out) :: qw2(KA)
2780 real(RP),
intent(out) :: qh (KA)
2785 uh(k) = f2h(k,1) * u(k+1) + f2h(k,2) * u(k)
2786 vh(k) = f2h(k,1) * v(k+1) + f2h(k,2) * v(k)
2789 if ( atmos_phy_bl_mynn_dz_sim )
then
2790 dudz2(ks) = ( us * phi_m / ( karman * z1 ) )**2
2792 dudz2(ks) = ( ( uh(ks) - u(ks) )**2 + ( vh(ks) - v(ks) )**2 ) / ( cdz(ks) * 0.5_rp )**2
2795 dudz2(ks) = max( dudz2(ks), 1e-20_rp )
2797 dudz2(k) = ( ( uh(k) - uh(k-1) )**2 + ( vh(k) - vh(k-1) )**2 ) / cdz(k)**2
2802 dudz2(k) = max( dudz2(k), 1e-20_rp )
2807 qh(k) = f2h(k,1) * potl(k+1) + f2h(k,2) * potl(k)
2809 if ( atmos_phy_bl_mynn_dz_sim )
then
2810 dtldz(ks) = ts * phi_h / ( karman * z1 )
2812 dtldz(ks) = ( qh(ks) - potl(ks) ) / ( cdz(ks) * 0.5_rp )
2816 dtldz(k) = ( qh(k) - qh(k-1) ) / cdz(k)
2822 qw2(k) = qw(k) / ( qdry(k) + qw(k) )
2826 qh(k) = f2h(k,1) * qw2(k+1) + f2h(k,2) * qw2(k)
2828 if ( atmos_phy_bl_mynn_dz_sim )
then
2829 dqwdz(ks) = qs * phi_h / ( karman * z1 )
2831 dqwdz(ks) = ( qh(ks) - qw2(ks) ) / ( cdz(ks) * 0.5_rp )
2836 dqwdz(k) = ( qh(k) - qh(k-1) ) / cdz(k)
2847 betat, betaq, Qlp, cldfrac, &
2848 PRES, POTT, POTL, Qw, EXNER, &
2858 atmos_saturation_psat => atmos_saturation_psat_liq
2861 hydrometeor_lhv => atmos_hydrometeor_lhv, &
2863 integer,
intent(in),
value :: KA, KS, KE
2864 real(RP),
intent(in) :: PRES (KA)
2865 real(RP),
intent(in) :: POTT (KA)
2866 real(RP),
intent(in) :: POTL (KA)
2867 real(RP),
intent(in) :: Qw (KA)
2868 real(RP),
intent(in) :: EXNER(KA)
2869 real(RP),
intent(in) :: tsq (KA)
2870 real(RP),
intent(in) :: qsq (KA)
2871 real(RP),
intent(in) :: cov (KA)
2873 real(RP),
intent(out) :: betat (KA)
2874 real(RP),
intent(out) :: betaq (KA)
2875 real(RP),
intent(out) :: Qlp (KA)
2876 real(RP),
intent(out) :: cldfrac(KA)
2878 real(RP),
intent(out) :: TEML(KA)
2879 real(RP),
intent(out) :: LHVL(KA)
2880 real(RP),
intent(out) :: psat(KA)
2885 real(RP) :: aa, bb, cc
2893 teml(k) = potl(k) * exner(k)
2896 call atmos_saturation_psat( &
2901 call hydrometeor_lhv( &
2908 qsl = epsvap * psat(k) / ( pres(k) - ( 1.0_rp - epsvap ) * psat(k) )
2909 dqsl = pres(k) * qsl**2 * lhvl(k) / ( epsvap * psat(k) * rvap * teml(k)**2 )
2911 cptot = ( 1.0_rp - qsl ) * cpdry + qsl *
cp_vapor
2912 aa = 1.0_rp / ( 1.0_rp + lhvl(k)/cptot * dqsl )
2913 bb = exner(k) * dqsl
2915 sigma_s = min( max( &
2916 0.5_rp * aa * sqrt( max( qsq(k) - 2.0_rp * bb * cov(k) + bb**2 * tsq(k), 1.0e-20_rp ) ), &
2917 aa * qsl * 0.09_rp), aa * qsl )
2918 q1 = aa * ( qw(k) - qsl ) * 0.5_rp / sigma_s
2919 cldfrac(k) = min( max( 0.5_rp * ( 1.0_rp + erf(q1*rsqrt_2) ), 0.0_rp ), 1.0_rp )
2920 qlp(k) = min( max( 2.0_rp * sigma_s * ( cldfrac(k) * q1 + rsqrt_2pi &
2921 #if defined(NVIDIA) || defined(SX)
2922 * exp( -min( 0.5_rp*q1**2, 1.e+3_rp ) ) &
2924 * exp(-0.5_rp*q1**2) &
2926 ), 0.0_rp ), qw(k) * 0.5_rp )
2927 cc = ( 1.0_rp + epstvap * qw(k) - qlp(k) / epsvap ) / exner(k) * lhvl(k) / cptot &
2929 rt = cldfrac(k) - qlp(k) / (2.0_rp*sigma_s*sqrt_2pi) &
2930 #if defined(NVIDIA) || defined(SX)
2931 * exp( -min( q1**2 * 0.5_rp, 1.e+3_rp ) )
2933 * exp(-q1**2 * 0.5_rp)
2935 betat(k) = 1.0_rp + epstvap * qw(k) - qlp(k) / epsvap - rt * aa * bb * cc
2936 betaq(k) = epstvap * pott(k) + rt * aa * cc
2944 zeta, phi_m, phi_h, &
2945 z1, RLmo, I_B_TYPE )
2947 real(RP),
intent(out) :: zeta
2948 real(RP),
intent(out) :: phi_m
2949 real(RP),
intent(out) :: phi_h
2950 real(RP),
intent(in) :: z1
2951 real(RP),
intent(in) :: RLmo
2952 integer,
intent(in) :: I_B_TYPE
2956 zeta = min( max( z1 * rlmo, -atmos_phy_bl_mynn_zeta_lim ), atmos_phy_bl_mynn_zeta_lim )
2958 select case ( i_b_type )
2961 if ( zeta >= 0 )
then
2962 phi_m = 4.7_rp * zeta + 1.0_rp
2963 phi_h = 4.7_rp * zeta + 0.74_rp
2965 phi_m = 1.0_rp / sqrt(sqrt( 1.0_rp - 15.0_rp * zeta ))
2966 phi_h = 0.47_rp / sqrt( 1.0_rp - 9.0_rp * zeta )
2968 case ( i_b91, i_b91w01 )
2970 if ( zeta >= 0 )
then
2971 tmp = - 2.0_rp / 3.0_rp * ( 0.35_rp * zeta - 6.0_rp ) * exp(-0.35_rp*zeta) * zeta
2972 phi_m = tmp + zeta + 1.0_rp
2973 phi_h = tmp + zeta * sqrt( 1.0_rp + 2.0_rp * zeta / 3.0_rp ) + 1.0_rp
2975 if ( i_b_type == i_b91w01 )
then
2978 tmp = abs(zeta)**(2.0_rp/3.0_rp)
2979 phi_m = 1.0_rp / sqrt( 1.0_rp + 3.6_rp * tmp )
2980 phi_h = 0.95_rp / sqrt( 1.0_rp + 7.9_rp * tmp )
2983 tmp = sqrt( 1.0_rp + 16.0_rp * abs(zeta) )
2984 phi_m = 1.0_rp / sqrt(tmp)
2985 phi_h = 1.0_rp / tmp
2994 subroutine calc_zi_o2019( &
3002 integer,
intent(in) :: KA, KS, KE
3003 real(RP),
intent(out) :: Zi
3004 real(RP),
intent(in) :: PTLV(KA)
3005 real(RP),
intent(in) :: tke(KA)
3006 real(RP),
intent(in) :: z(KA)
3007 real(RP),
intent(in) :: frac_land
3008 logical,
intent(in) :: initialize
3010 real(RP) :: zit, zie
3011 real(RP) :: tmin, dtv
3019 tmin = min( tmin, ptlv(k) )
3020 if ( z(k) > 200.0_rp )
then
3025 if ( frac_land >= 0.5_rp )
then
3032 if ( tmin + dtv <= ptlv(k) )
then
3038 if ( .not. initialize )
then
3039 tke_min = max( tke(ks), 0.02_rp )
3041 if ( tke(k) <= tke_min * 0.05_rp )
then
3047 we = 0.5_rp * tanh( ( zit - 200.0_rp ) / 400.0_rp ) + 0.5_rp
3048 zi = zit * ( 1.0_rp - we ) + zie * we
3051 end subroutine calc_zi_o2019
3054 subroutine calc_mflux( &
3062 SHFLX, SFLX_BUOY, SFLX_PT, SFLX_QV, &
3066 mflux, tflux, qflux, uflux, vflux, eflux, &
3067 tlh, tvh, qh, uh, vh, wh, eh, dh )
3079 atmos_saturation_moist_conversion_dens_liq
3080 integer,
intent(in) :: KA, KS, KE
3082 real(RP),
intent(in) :: DENS(KA)
3083 real(RP),
intent(in) :: POTV(KA)
3084 real(RP),
intent(in) :: POTL(KA)
3085 real(RP),
intent(in) :: Qw(KA)
3086 real(RP),
intent(in) :: U(KA)
3087 real(RP),
intent(in) :: V(KA)
3088 real(RP),
intent(in) :: W(KA)
3089 real(RP),
intent(in) :: tke(KA)
3090 real(RP),
intent(in) :: cldfrac(KA)
3091 real(RP),
intent(in) :: EXNER(KA)
3092 real(RP),
intent(in) :: SHFLX
3093 real(RP),
intent(in) :: SFLX_BUOY
3094 real(RP),
intent(in) :: SFLX_PT
3095 real(RP),
intent(in) :: SFLX_QV
3096 real(RP),
intent(in) :: SFC_DENS
3097 real(RP),
intent(in) :: Zi
3098 real(RP),
intent(in) :: Z(KA)
3099 real(RP),
intent(in) :: CDZ(KA)
3100 real(RP),
intent(in) :: F2H(KA,2)
3102 real(RP),
intent(out) :: mflux(0:KA)
3103 real(RP),
intent(out) :: tflux(0:KA)
3104 real(RP),
intent(out) :: qflux(0:KA)
3105 real(RP),
intent(out) :: uflux(0:KA)
3106 real(RP),
intent(out) :: vflux(0:KA)
3107 real(RP),
intent(out) :: eflux(0:KA)
3110 real(RP),
intent(out) :: tlh(KA)
3111 real(RP),
intent(out) :: tvh(KA)
3112 real(RP),
intent(out) :: qh(KA)
3113 real(RP),
intent(out) :: uh(KA)
3114 real(RP),
intent(out) :: vh(KA)
3115 real(RP),
intent(out) :: wh(KA)
3116 real(RP),
intent(out) :: eh(KA)
3117 real(RP),
intent(out) :: dh(KA)
3119 real(RP),
parameter :: amax = 0.1_rp
3120 real(RP),
parameter :: Ce = 0.35_rp
3121 real(RP),
parameter :: x = -1.9_rp
3122 real(RP),
parameter :: Cwt = 0.58_rp
3123 real(RP),
parameter :: Cs = 1.34_rp
3124 real(RP),
parameter :: zs = 50.0_rp
3125 real(RP),
parameter :: a = 2.0_rp
3128 real(RP) :: ap(nplume)
3129 real(RP) :: wp, tp, qp, up, vp, ep
3132 real(RP) :: sw, sq, st
3133 real(RP) :: ws, ts, qs
3138 real(RP) :: temp, qc
3139 real(RP) :: tps, qps
3142 real(RP) :: tmp, fact
3143 logical :: converged
3157 if ( sflx_buoy <= 0.0_rp )
then
3164 if ( z(k) > 50.0_rp )
exit
3165 if ( potv(k+1) >= potv(k) )
then
3173 if ( cldfrac(k) > 0.5_rp .and. z(k) <= 2000.0_rp )
then
3174 zmax = min( zmax, z(k) * 0.5_rp )
3181 if ( dplume(n) > zmax )
then
3186 if ( np == 0 )
return
3189 au = amax * ( tanh( ( shflx - 20.0_rp ) / 90.0_rp ) * 0.5_rp + 0.5_rp )
3194 dd = dplume(2) - dplume(1)
3195 else if ( n == np )
then
3196 dd = dplume(np) - dplume(np-1)
3198 dd = ( dplume(n+1) - dplume(n-1) ) * 0.5_rp
3200 ap(n) = dplume(n)**(x + 2.0_rp) * dd
3205 ap(n) = ap(n) * fact
3210 tlh(k) = f2h(k,1) * potl(k) + f2h(k,2) * potl(k+1)
3211 tvh(k) = f2h(k,1) * potv(k) + f2h(k,2) * potv(k+1)
3212 qh(k) = f2h(k,1) * qw(k) + f2h(k,2) * qw(k+1)
3213 uh(k) = f2h(k,1) * u(k) + f2h(k,2) * u(k+1)
3214 vh(k) = f2h(k,1) * v(k) + f2h(k,2) * v(k+1)
3215 wh(k) = f2h(k,1) * w(k) + f2h(k,2) * w(k+1)
3216 eh(k) = f2h(k,1) * tke(k) + f2h(k,2) * tke(k+1)
3217 dh(k) = f2h(k,1) * dens(k) + f2h(k,2) * dens(k+1)
3220 ws = max( ( zi * sflx_buoy )**oneoverthree, 1.0e-10_rp )
3221 ts = sflx_pt / ( sfc_dens * ws )
3222 qs = max( sflx_qv, 0.0_rp ) / ( sfc_dens * ws )
3223 tmp = ( zs / zi )**oneoverthree
3224 sw = cs * ws * tmp * ( 1.0_rp - 0.8_rp*zs/zi )
3230 wp = min( pw(n) * sw, 0.5_rp )
3231 tp = tlh(ks) + wp * cwt * st / sw
3232 qp = qh(ks) + wp * cwt * sq / sw
3238 mf = ap(n) * ( wp - wh(k) ) * dh(k)
3239 mflux(k) = mflux(k) + mf
3240 tflux(k) = tflux(k) + mf * ( tp - tlh(k) )
3241 qflux(k) = qflux(k) + mf * ( qp - qh(k) )
3242 uflux(k) = uflux(k) + mf * ( up - uh(k) )
3243 vflux(k) = vflux(k) + mf * ( vp - vh(k) )
3244 eflux(k) = eflux(k) + mf * ( ep - eh(k) )
3246 er = ce / ( wp * dplume(n) )
3249 fact = exp( - er * cdz(k+1) )
3250 tp = potl(k+1) + ( tp - potl(k+1) ) * fact
3251 qp = qw(k+1) + ( qp - qw(k+1) ) * fact
3252 up = u(k+1) + ( up - u(k+1) ) * fact
3253 vp = v(k+1) + ( vp - v(k+1) ) * fact
3254 ep = tke(k+1) + ( ep - tke(k+1) ) * fact
3258 temp = tp * exner(k+1)
3259 cp = cpdry * ( 1.0_rp - qp ) +
cp_vapor * qp
3260 cv = cvdry * ( 1.0_rp - qp ) +
cv_vapor * qp
3261 emoist = temp * cv + qp *
lhv
3262 call atmos_saturation_moist_conversion_dens_liq( dens(k+1), emoist, &
3266 if ( converged )
then
3267 tps = temp / exner(k+1)
3269 log_warn(
"calc_mflux",*)
"moist_conversion did not converged"
3274 buoy = grav * ( tps * ( 1.0_rp + epstvap * qps ) / potv(k+1) - 1.0_rp )
3275 if ( buoy > 0.0_rp )
then
3281 wp = sqrt( max( 0.0_rp, ( er * a * wp**2 - b * buoy ) * exp( - 2.0_rp * er * a * cdz(k+1) ) + b * buoy ) / ( er * a ) )
3282 if ( wp <= 0.0_rp )
then
3290 end subroutine calc_mflux