78 private :: cp_kf_param
79 private :: cp_kf_trigger
80 private :: cp_kf_updraft
81 private :: cp_kf_downdraft
82 private :: cp_kf_compensational
83 private :: cp_kf_calciexn
84 private :: cp_kf_precipitation_oc1973
85 private :: cp_kf_precipitation_kessler
86 private :: cp_kf_tpmix2
87 private :: cp_kf_dtfrznew
88 private :: cp_kf_prof5
89 private :: cp_kf_tpmix2dd
90 private :: cp_kf_envirtht
91 private :: cp_kf_lutab
95 subroutine kf_precipitation( &
96 G, DZ, BOTERM, ENTERM, &
97 WTW, QLIQ, QICE, QNEWLQ, QNEWIC, QLQOUT, QICOUT )
99 real(RP),
INTENT(IN ) :: G, DZ,BOTERM,ENTERM
100 real(RP),
INTENT(INOUT) :: WTW, QLIQ, QICE, QNEWLQ, QNEWIC, QLQOUT, QICOUT
101 end subroutine kf_precipitation
104 procedure(kf_precipitation),
pointer,
private :: CP_kf_precipitation => null()
112 integer,
private,
parameter :: KFNT=250,kfnp=220
113 real(RP),
private :: TTAB(KFNT,KFNP),QSTAB(KFNT,KFNP)
114 real(RP),
private :: THE0K(KFNP)
115 real(RP),
private :: ALU(200)
116 real(RP),
private :: RDPR,RDTHK,PLUTOP,PBOT
117 real(RP),
private :: GdCP
122 real(RP),
private,
parameter :: ALIQ = 6.112e2_rp
123 real(RP),
private,
parameter :: BLIQ = 17.67_rp
124 real(RP),
private,
parameter :: CLIQ = bliq*tem00
125 real(RP),
private,
parameter :: DLIQ = 29.65_rp
126 real(RP),
private,
parameter :: XLV0 = 3.15e6_rp
127 real(RP),
private,
parameter :: XLV1 = 2370._rp
128 real(RP),
private,
parameter :: KF_EPS = 1.e-12_rp
131 real(RP),
private :: RATE
133 integer ,
private :: TRIGGER_type
134 real(RP),
private :: DELCAPE
135 real(RP),
private :: DEEPLIFETIME
136 real(RP),
private :: SHALLOWLIFETIME
137 real(RP),
private :: DEPTH_USL
138 logical ,
private :: WARMRAIN
139 logical ,
private :: KF_LOG
140 real(RP),
private :: kf_threshold
141 integer ,
private :: prec_type
142 logical,
private :: DO_prec
144 real(RP),
private,
allocatable :: lifetime (:,:)
145 integer ,
private,
allocatable :: I_convflag(:,:)
147 real(RP),
private,
allocatable :: deltaz (:,:,:)
148 real(RP),
private,
allocatable :: Z (:,:,:)
149 real(RP),
private,
allocatable :: deltax (:,:)
152 integer,
parameter :: hist_vmax = 14
153 integer,
private :: hist_id(hist_vmax,0:1)
154 logical,
private :: hist_flag
155 integer,
parameter :: I_HIST_QV_FC = 1
156 integer,
parameter :: I_HIST_QV_UE = 2
157 integer,
parameter :: I_HIST_QV_DE = 3
158 integer,
parameter :: I_HIST_QV_UD = 4
159 integer,
parameter :: I_HIST_QV_DD = 5
160 integer,
parameter :: I_HIST_QV_NF = 6
161 integer,
parameter :: I_HIST_QC_FC = 7
162 integer,
parameter :: I_HIST_QC_UD = 8
163 integer,
parameter :: I_HIST_QI_FC = 9
164 integer,
parameter :: I_HIST_QI_UD = 10
165 integer,
parameter :: I_HIST_QR_FC = 11
166 integer,
parameter :: I_HIST_QR_RF = 12
167 integer,
parameter :: I_HIST_QS_FC = 13
168 integer,
parameter :: I_HIST_QS_SF = 14
169 integer,
parameter :: I_HIST_D = 0
170 integer,
parameter :: I_HIST_S = 1
172 real(RP),
private,
allocatable :: hist_work(:,:,:,:,:)
187 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
195 integer,
intent(in) ::
ka,
ks,
ke
196 integer,
intent(in) ::
ia,
is,
ie
197 integer,
intent(in) ::
ja,
js,
je
199 real(rp),
intent(in) :: cz(
ka,
ia,
ja)
200 real(rp),
intent(in) :: area(
ia,
ja)
201 logical,
intent(in) :: warmrain_in
204 integer :: atmos_phy_cp_kf_trigger_type = 1
205 integer :: atmos_phy_cp_kf_prec_type = 1
206 real(rp) :: atmos_phy_cp_kf_rate = 0.03_rp
207 logical :: atmos_phy_cp_kf_do_prec = .true.
208 real(rp) :: atmos_phy_cp_kf_dlcape = 0.1_rp
209 real(rp) :: atmos_phy_cp_kf_dlifetime = 1800.0_rp
210 real(rp) :: atmos_phy_cp_kf_slifetime = 2400.0_rp
211 real(rp) :: atmos_phy_cp_kf_depth_usl = 300.0_rp
212 real(rp) :: atmos_phy_cp_kf_thres = 1.e-3_rp
213 logical :: atmos_phy_cp_kf_log = .false.
215 namelist / param_atmos_phy_cp_kf / &
216 atmos_phy_cp_kf_rate, &
217 atmos_phy_cp_kf_trigger_type, &
218 atmos_phy_cp_kf_dlcape, &
219 atmos_phy_cp_kf_dlifetime, &
220 atmos_phy_cp_kf_slifetime, &
221 atmos_phy_cp_kf_depth_usl, &
222 atmos_phy_cp_kf_prec_type, &
223 atmos_phy_cp_kf_do_prec, &
224 atmos_phy_cp_kf_thres, &
233 log_info(
"ATMOS_PHY_CP_kf_setup",*)
'Setup'
234 log_info(
"ATMOS_PHY_CP_kf_setup",*)
'Kain-Fritsch scheme'
236 warmrain = warmrain_in
240 read(
io_fid_conf,nml=param_atmos_phy_cp_kf,iostat=ierr)
242 log_info(
"ATMOS_PHY_CP_kf_setup",*)
'Not found namelist. Default used.'
243 elseif( ierr > 0 )
then
244 log_error(
"ATMOS_PHY_CP_kf_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_PHY_CP_KF. Check!'
247 log_nml(param_atmos_phy_cp_kf)
251 call cp_kf_param( atmos_phy_cp_kf_prec_type, &
252 atmos_phy_cp_kf_rate, &
253 atmos_phy_cp_kf_do_prec, &
254 atmos_phy_cp_kf_dlcape, &
255 atmos_phy_cp_kf_dlifetime, &
256 atmos_phy_cp_kf_slifetime, &
257 atmos_phy_cp_kf_depth_usl, &
258 atmos_phy_cp_kf_thres, &
259 atmos_phy_cp_kf_log, &
260 atmos_phy_cp_kf_trigger_type )
264 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Ogura-Cho condense material convert rate : ", atmos_phy_cp_kf_rate
265 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Trigger function type, 1:KF2004 3:NO2007 : ", atmos_phy_cp_kf_trigger_type
266 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"CAPE decrease rate : ", atmos_phy_cp_kf_dlcape
267 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Minimum lifetime scale of deep convection [sec] : ", atmos_phy_cp_kf_dlifetime
268 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Lifetime of shallow convection [sec] : ", atmos_phy_cp_kf_slifetime
269 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Updraft souce layer depth [hPa] : ", atmos_phy_cp_kf_depth_usl
270 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Precipitation type 1:Ogura-Cho(1973) 2:Kessler : ", atmos_phy_cp_kf_prec_type
271 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Kessler type precipitation's threshold : ", atmos_phy_cp_kf_thres
272 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Enable sedimentation (precipitation) ? : ", atmos_phy_cp_kf_do_prec
273 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Warm rain? : ", warmrain
274 log_info(
"ATMOS_PHY_CP_kf_setup",*)
"Output log? : ", atmos_phy_cp_kf_log
277 allocate( lifetime(
ia,
ja) )
278 allocate( i_convflag(
ia,
ja) )
279 lifetime(:,:) = 0.0_rp
285 allocate( deltaz(
ka,
ia,
ja) )
287 deltaz(:,:,:) = 0.0_rp
291 deltaz(
k,i,j) = cz(
k+1,i,j) - cz(
k,i,j)
293 deltaz(
ke,i,j) = 0.0_rp
297 allocate( deltax(
ia,
ja) )
300 deltax(i,j) = sqrt( area(i,j) )
308 'QV tendency due to flux convergence (deep convection) in KF', &
310 hist_id(i_hist_qv_fc,i_hist_d) )
312 'QV tendency due to flux convergence (shallow convection) in KF', &
314 hist_id(i_hist_qv_fc,i_hist_s) )
316 'QV tendency due to entrainment of updraft (deep convection) in KF', &
318 hist_id(i_hist_qv_ue,i_hist_d) )
320 'QV tendency due to entrainment of updraft (shallow convection) in KF', &
322 hist_id(i_hist_qv_ue,i_hist_s) )
324 'QV tendency due to entrainment of downdraft (deep convection) in KF', &
326 hist_id(i_hist_qv_de,i_hist_d) )
328 'QV tendency due to detrainment of updraft (deep convection) in KF', &
330 hist_id(i_hist_qv_ud,i_hist_d) )
332 'QV tendency due to detrainment of updraft (shallow convection) in KF', &
334 hist_id(i_hist_qv_ud,i_hist_s) )
336 'QV tendency due to detrainment of downdraft (deep convection) in KF', &
338 hist_id(i_hist_qv_dd,i_hist_d) )
340 'QV tendency due to negative fixer (deep convection) in KF', &
342 hist_id(i_hist_qv_nf,i_hist_d) )
344 'QV tendency due to negative fixer (shallow convection) in KF', &
346 hist_id(i_hist_qv_nf,i_hist_s) )
349 'QC tendency due to flux convergence (deep convection) in KF', &
351 hist_id(i_hist_qc_fc,i_hist_d) )
353 'QC tendency due to flux convergence (shallow convection) in KF', &
355 hist_id(i_hist_qc_fc,i_hist_s) )
357 'QC tendency due to detrainment of updraft (deep convection) in KF', &
359 hist_id(i_hist_qc_ud,i_hist_d) )
361 'QC tendency due to detrainment of updraft (shallow convection) in KF', &
363 hist_id(i_hist_qc_ud,i_hist_s) )
366 'QI tendency due to flux convergence (deep convection) in KF', &
368 hist_id(i_hist_qi_fc,i_hist_d) )
370 'QI tendency due to flux convergence (shallow convection) in KF', &
372 hist_id(i_hist_qi_fc,i_hist_s) )
374 'QI tendency due to detrainment of updraft (deep convection) in KF', &
376 hist_id(i_hist_qi_ud,i_hist_d) )
378 'QI tendency due to detrainment of updraft (shallow convection) in KF', &
380 hist_id(i_hist_qi_ud,i_hist_s) )
383 'QR tendency due to flux convergence (deep convection) in KF', &
385 hist_id(i_hist_qr_fc,i_hist_d) )
387 'QR tendency due to flux convergence (shallow convection) in KF', &
389 hist_id(i_hist_qr_fc,i_hist_s) )
391 'QR tendency due to rain fall (deep convection) in KF', &
393 hist_id(i_hist_qr_rf,i_hist_d) )
395 'QR tendency due to rain fall (shallow convection) in KF', &
397 hist_id(i_hist_qr_rf,i_hist_s) )
400 'QS tendency due to flux convergence (deep convection) in KF', &
402 hist_id(i_hist_qs_fc,i_hist_d) )
404 'QS tendency due to flux convergence (shallow convection) in KF', &
406 hist_id(i_hist_qs_fc,i_hist_s) )
408 'QS tendency due to snow fall (deep convection) in KF', &
410 hist_id(i_hist_qs_sf,i_hist_d) )
412 'QS tendency due to snow fall (shallow convection) in KF', &
414 hist_id(i_hist_qs_sf,i_hist_s) )
417 if ( hist_id(n,0) > 0 .or. hist_id(n,1) > 0 )
then
418 allocate( hist_work(
ka,
ia,
ja,hist_vmax,0:1) )
419 hist_work(:,:,:,:,:) = 0.0_rp
436 deallocate( lifetime )
437 deallocate( i_convflag )
442 if (
allocated( hist_work ) )
deallocate( hist_work )
455 real(rp),
intent(in),
optional :: in_delcape
456 real(rp),
intent(in),
optional :: in_deeplifetime
457 real(rp),
intent(in),
optional :: in_shallowlifetime
460 if(
present(in_delcape ) ) delcape = in_delcape
461 if(
present(in_deeplifetime ) ) deeplifetime = in_deeplifetime
462 if(
present(in_shallowlifetime) ) shallowlifetime = in_shallowlifetime
472 out_shallowlifetime )
475 real(rp),
intent(out),
optional :: out_delcape
476 real(rp),
intent(out),
optional :: out_deeplifetime
477 real(rp),
intent(out),
optional :: out_shallowlifetime
480 if(
present(out_delcape ) ) out_delcape = delcape
481 if(
present(out_deeplifetime ) ) out_deeplifetime = deeplifetime
482 if(
present(out_shallowlifetime) ) out_shallowlifetime = shallowlifetime
491 subroutine cp_kf_param( & ! set kf tuning parametres
497 SHALLOWLIFETIME_in, &
505 integer,
intent(in) :: prec_type_in
506 real(rp),
intent(in) :: rate_in
507 logical,
intent(in) :: do_prec_in
508 real(rp),
intent(in) :: delcape_in
509 real(rp),
intent(in) :: deeplifetime_in
510 real(rp),
intent(in) :: shallowlifetime_in
511 real(rp),
intent(in) :: depth_usl_in
512 real(rp),
intent(in) :: kf_threshold_in
513 logical,
intent(in) :: kf_log_in
514 integer,
intent(in) :: trigger_type_in
518 deeplifetime = deeplifetime_in
519 shallowlifetime = shallowlifetime_in
520 depth_usl = depth_usl_in
521 prec_type = prec_type_in
523 kf_threshold = kf_threshold_in
525 trigger_type = trigger_type_in
527 if ( trigger_type /= 1 .and. trigger_type /=3 )
then
528 log_error(
"CP_kf_param",*)
"TRIGGER_type must be 1 or 3 but now : ",trigger_type
532 select case ( prec_type )
535 cp_kf_precipitation => cp_kf_precipitation_oc1973
539 cp_kf_precipitation => cp_kf_precipitation_kessler
542 log_error(
"CP_kf_param",*)
'KF namelist'
543 log_error_cont(*)
'prec_type must be 1 or 2 : ', prec_type
548 end subroutine cp_kf_param
581 file_history_query, &
601 saturation_psat_liq => atmos_saturation_psat_liq
603 integer,
intent(in) ::
ka,
ks,
ke
604 integer,
intent(in) ::
ia,
is,
ie
605 integer,
intent(in) ::
ja,
js,
je
607 real(rp),
intent(in) :: dens (
ka,
ia,
ja)
608 real(rp),
intent(in) :: u (
ka,
ia,
ja)
609 real(rp),
intent(in) :: v (
ka,
ia,
ja)
610 real(rp),
intent(in) :: rhot (
ka,
ia,
ja)
611 real(rp),
intent(in) :: temp (
ka,
ia,
ja)
612 real(rp),
intent(in) :: pres (
ka,
ia,
ja)
613 real(rp),
intent(in) :: qdry (
ka,
ia,
ja)
614 real(rp),
intent(in) :: qv_in(
ka,
ia,
ja)
615 real(rp),
intent(in) :: w0avg(
ka,
ia,
ja)
616 real(rp),
intent(in) :: fz (0:
ka,
ia,
ja)
617 real(
dp),
intent(in) :: kf_dtsecd
619 real(rp),
intent(inout) :: dens_t (
ka,
ia,
ja)
620 real(rp),
intent(inout) :: rhot_t (
ka,
ia,
ja)
621 real(rp),
intent(inout) :: rhoqv_t(
ka,
ia,
ja)
623 real(rp),
intent(inout) :: nca (
ia,
ja)
625 real(rp),
intent(inout) :: sflx_rain(
ia,
ja)
626 real(rp),
intent(inout) :: sflx_snow(
ia,
ja)
627 real(rp),
intent(inout) :: sflx_engi(
ia,
ja)
628 real(rp),
intent(inout) :: cloudtop (
ia,
ja)
629 real(rp),
intent(inout) :: cloudbase (
ia,
ja)
630 real(rp),
intent(inout) :: cldfrac_dp (
ka,
ia,
ja)
631 real(rp),
intent(inout) :: cldfrac_sh (
ka,
ia,
ja)
633 integer ::
k, i, j, iq
638 integer :: k_lc,k_let,k_pbl
643 real(rp) :: qsat (
ka)
645 real(rp) :: deltap(
ka)
647 real(rp) :: cldfrac_kf(
ka,2)
648 real(rp) :: dens_nw(
ka)
649 real(rp) :: time_advec
652 real(rp) :: upent(
ka)
653 real(rp) :: updet(
ka)
655 real(rp) :: temp_u(
ka)
656 real(rp) :: tempv(
ka)
662 real(rp) :: qvdet(
ka)
663 real(rp) :: qcdet(
ka)
664 real(rp) :: qidet(
ka)
665 real(rp) :: flux_qr(
ka)
666 real(rp) :: flux_qs(
ka)
668 real(rp) :: theta_eu(
ka)
669 real(rp) :: theta_ee(
ka)
672 real(rp) :: umfnewdold(
ka)
679 real(rp) :: downent(
ka)
680 real(rp) :: downdet(
ka)
681 real(rp) :: theta_d(
ka)
683 real(rp) :: rain_flux
684 real(rp) :: snow_flux
685 real(rp) :: prec_engi
688 real(rp) :: theta_nw(
ka)
689 real(rp) :: qv_nw(
ka)
690 real(rp) :: qc_nw(
ka)
691 real(rp) :: qi_nw(
ka)
692 real(rp) :: qr_nw(
ka)
693 real(rp) :: qs_nw(
ka)
697 real(rp) :: dqv, dqc, dqi, dqr, dqs
699 real(rp) :: r_convflag(
ia,
ja)
705 logical :: flag, logical
709 real(rp) :: work(
ka,24)
710 real(rp) :: work2(0:
ka,7)
711 integer :: iwork(
ka,1)
716 log_progress(*)
'atmosphere / physics / cumulus / KF'
717 log_info(
"ATMOS_PHY_CP_kf_tendency",*)
'KF Convection Check '
724 call file_history_query( hist_id(n,0), hist_flag )
725 if ( hist_flag )
exit
726 call file_history_query( hist_id(n,1), hist_flag )
727 if ( hist_flag )
exit
764 nca(i,j) = nca(i,j) - kf_dtsec
767 if ( nca(i,j) .lt. 0.5_rp * kf_dtsec )
then
771 rhod(
k) = dens(
k,i,j) * qdry(
k,i,j)
778 psat = aliq*exp((bliq*temp(
k,i,j)-cliq)/(temp(
k,i,j)-dliq))
779 qsat(
k) = epsvap * psat / ( pres(
k,i,j) - psat )
782 qv(
k) = max( kf_eps, min( qsat(
k), qv_in(
k,i,j) / qdry(
k,i,j) ) )
783 rh(
k) = qv(
k) / qsat(
k)
789 deltap(
k) = rhod(
k) * grav * ( fz(
k,i,j) - fz(
k-1,i,j) )
792 call cp_kf_trigger ( &
794 deltaz(:,i,j), z(:,i,j), &
797 deltap(:), deltax(i,j), &
801 work(:,:), iwork(:,:), &
805 temp_u(:), tempv(:), &
806 qv_u(:), qc(:), qi(:), &
807 qvdet(:), qcdet(:), qidet(:), &
808 flux_qr(:), flux_qs(:), &
809 theta_eu(:), theta_ee(:), &
812 upent(:), updet(:), &
813 k_lcl, k_lc, k_pbl, &
814 k_top, k_let, k_ml, &
817 cloudbase(i,j), zmix, &
821 if (i_convflag(i,j) /= 2)
then
824 ems(k_top+1:
ke) = 0._rp
825 emsd(k_top+1:
ke) = 0._rp
827 ems(
k) = deltap(
k) * deltax(i,j)**2 / grav
828 emsd(
k) = 1._rp/ems(
k)
829 umfnewdold(
k) = 1._rp/umfnewdold(
k)
832 call cp_kf_downdraft ( &
835 k_lcl, k_ml, k_top, k_pbl, k_let, k_lc, &
836 z(:,i,j), cloudbase(i,j), &
837 u(:,i,j), v(:,i,j), rh(:), qv(:), pres(:,i,j), &
838 deltap(:), deltax(i,j), &
842 flux_qr(:), flux_qs(:), tempv(:), &
846 wspd(:), dmf(:), downent(:), downdet(:), &
847 theta_d(:), qv_d(:), &
848 rain_flux, snow_flux, prec_engi, &
851 call cp_kf_compensational ( &
853 k_top, k_lc, k_pbl, k_ml, k_lfs, &
854 deltaz(:,i,j), z(:,i,j), pres(:,i,j), deltap(:), deltax(i,j), &
855 temp(:,i,j), qv(:), ems(:), emsd(:), &
856 presmix, zmix, dpthmx, &
858 temp_u(:), qvdet(:), umflcl, &
859 qc(:), qi(:), flux_qr(:), flux_qs(:), &
862 qv_d(:), theta_d(:), &
867 work(:,:), work2(:,:), &
869 i_convflag(i,j), k_lcl, &
870 umf(:), upent(:), updet(:), &
871 qcdet(:), qidet(:), dmf(:), downent(:), downdet(:), &
872 rain_flux, snow_flux, &
875 qv_nw(:), qc_nw(:), qi_nw(:), qr_nw(:), qs_nw(:), &
876 sflx_rain(i,j), sflx_snow(i,j), sflx_engi(i,j), &
877 cldfrac_kf, lifetime(i,j), time_advec, &
881 if (i_convflag(i,j) == 2)
then
883 sflx_rain(i,j) = 0.0_rp
884 sflx_snow(i,j) = 0.0_rp
885 sflx_engi(i,j) = 0.0_rp
886 cldfrac_kf(
ks:
ke,:) = 0.0_rp
887 lifetime(i,j) = 0.0_rp
888 cloudtop(i,j) = 0.0_rp
889 cloudbase(i,j) = 0.0_rp
892 dens_t(
ks:
ke,i,j) = 0.0_rp
893 rhot_t(
ks:
ke,i,j) = 0.0_rp
894 rhoqv_t(
ks:
ke,i,j) = 0.0_rp
896 rhoq_t(
ks:
ke,i,j,iq) = 0.0_rp
899 if ( hist_flag )
then
902 hist_work(:,i,j,n,m) = 0.0_rp
916 if (i_convflag(i,j) == 0)
then
917 if (time_advec < lifetime(i,j)) nic=nint(time_advec/kf_dtsec)
918 nca(i,j) = nic * kf_dtsec
919 elseif (i_convflag(i,j) == 1)
then
920 lifetime(i,j) = max(shallowlifetime, kf_dtsec)
926 dqv = rhod(
k) * ( qv_nw(
k) - qv(
k) )
927 rhoqv_t(
k,i,j) = dqv / lifetime(i,j)
929 dqc = qc_nw(
k) * rhod(
k)
930 dqr = qr_nw(
k) * rhod(
k)
931 rhoq_t(
k,i,j,
i_hc) = dqc / lifetime(i,j)
932 rhoq_t(
k,i,j,
i_hr) = dqr / lifetime(i,j)
934 if ( .not. warmrain )
then
935 dqi = qi_nw(
k) * rhod(
k)
936 dqs = qs_nw(
k) * rhod(
k)
941 rhoq_t(
k,i,j,
i_hi) = dqi / lifetime(i,j)
942 rhoq_t(
k,i,j,
i_hs) = dqs / lifetime(i,j)
944 dens_t(
k,i,j) = rhoqv_t(
k,i,j) &
947 dens_nw(
k) = dens(
k,i,j) + dqv + dqc + dqr + dqi + dqs
953 rhoq_t(
k,i,j,iq) = 0.0_rp
959 rhot_t(
k,i,j) = ( dens_nw(
k) * theta_nw(
k) - rhot(
k,i,j) ) / lifetime(i,j)
963 dens_t(
k,i,j) = 0.0_rp
964 rhot_t(
k,i,j) = 0.0_rp
965 rhoqv_t(
k,i,j) = 0.0_rp
967 rhoq_t(
k,i,j,iq) = 0.0_rp
975 cldfrac_sh(
ks:
ke,i,j) = cldfrac_kf(
ks:
ke,1)
976 cldfrac_dp(
ks:
ke,i,j) = cldfrac_kf(
ks:
ke,2)
991 call file_history_in( lifetime(:,:),
'KF_LIFETIME',
'lifetime of KF scheme',
's' )
992 r_convflag(:,:) = real(i_convflag(:,:),rp)
993 call file_history_in( r_convflag(:,:),
'KF_CONVFLAG',
'CONVECTION FLAG',
'' )
996 call file_history_query( hist_id(n,m), flag )
998 call file_history_put( hist_id(n,m), hist_work(:,:,:,n,m) )
1011 subroutine cp_kf_trigger ( &
1026 qvdet, qcdet, qidet, &
1028 theta_eu, theta_ee, &
1032 k_lcl, k_lc, k_pbl, &
1033 k_top, k_let, k_ml, &
1049 integer,
intent(in) ::
ka,
ks,
ke
1050 real(rp),
intent(in) :: dz_kf(
ka),z_kf(
ka)
1051 real(rp),
intent(in) :: qv(
ka)
1052 real(rp),
intent(in) :: qes(
ka)
1053 real(rp),
intent(in) :: pres(
ka)
1054 real(rp),
intent(in) :: deltap(
ka)
1055 real(rp),
intent(in) :: deltax
1056 real(rp),
intent(in) :: temp(
ka)
1057 real(rp),
intent(in) :: w0avg(
ka)
1060 real(rp),
intent(out) :: work(
ka,8)
1061 integer,
intent(out) :: iwork(
ka,1)
1064 integer,
intent(out) :: i_convflag
1068 real(rp),
intent(out) :: cloudtop
1069 real(rp),
intent(out) :: temp_u(
ka)
1070 real(rp),
intent(out) :: tempv(
ka)
1071 real(rp),
intent(out) :: qv_u(
ka)
1072 real(rp),
intent(out) :: qc(
ka)
1073 real(rp),
intent(out) :: qi(
ka)
1074 real(rp),
intent(out) :: qvdet(
ka)
1075 real(rp),
intent(out) :: qcdet(
ka)
1076 real(rp),
intent(out) :: qidet(
ka)
1077 real(rp),
intent(out) :: flux_qr(
ka)
1078 real(rp),
intent(out) :: flux_qs(
ka)
1079 real(rp),
intent(out) :: theta_eu(
ka)
1080 real(rp),
intent(out) :: theta_ee(
ka)
1081 real(rp),
intent(out) :: cape
1082 real(rp),
intent(out) :: umf(
ka)
1083 real(rp),
intent(out) :: umflcl
1084 real(rp),
intent(out) :: upent(
ka)
1085 real(rp),
intent(out) :: updet(
ka)
1086 integer,
intent(out) :: k_lcl
1087 integer,
intent(out) :: k_lc
1088 integer,
intent(out) :: k_pbl
1089 integer,
intent(out) :: k_top
1090 integer,
intent(out) :: k_let
1091 integer,
intent(out) :: k_ml
1092 real(rp),
intent(out) :: presmix
1093 real(rp),
intent(out) :: dpthmx
1094 real(rp),
intent(out) :: zlcl
1095 real(rp),
intent(out) :: zmix
1096 real(rp),
intent(out) :: umfnewdold(
ka)
1098 logical,
intent(out) :: error
1101 integer,
parameter :: itr_max = 10000
1106 integer :: n_uslcheck
1110 #define k_check(k) iwork(k,1)
1112 integer :: k_check(
ka)
1121 real(rp) :: cloudhight
1123 #define qrout_t(k) work(k,1)
1124 #define qsout_t(k) work(k,2)
1126 real(rp) :: qrout_t(
ka)
1127 real(rp) :: qsout_t(
ka)
1132 real(rp) :: theta_mix
1133 real(rp) :: temp_mix
1136 real(rp) :: temp_dew
1139 real(rp) :: temp_env
1140 real(rp) :: tempv_env
1145 real(rp) :: temp_lcl
1146 real(rp) :: tempv_lcl
1147 real(rp) :: pres_lcl
1154 real(rp) :: umfnew,umfold
1157 #define CLDHGT(k) work(k,3)
1159 real(rp) :: cldhgt(
ka)
1171 pres300 = pres(
ks) - depth_usl*100._rp
1173 tempv(kk) = temp(kk) * ( 1.0_rp + epstvap * qv(kk) )
1178 if (pres(kk) >= pres300) k_llfc = kk
1183 pres15 = pres(
ks) - 15.e2_rp
1186 do kk =
ks+1, k_llfc
1187 if(pres(kk) < pres15 )
then
1188 n_check = n_check + 1
1189 k_check(n_check) = kk
1190 pres15 = pres15 - 15.e2_rp
1202 n_uslcheck = n_uslcheck + 1
1205 if (n_uslcheck > n_check)
then
1206 if (i_convflag == 1)
then
1211 if (cldhgt(nnn) > chmax)
then
1217 n_uslcheck = nuchm - 1
1224 k_lc = k_check(n_uslcheck)
1231 if ( nk + 1 <
ks )
then
1234 log_info(
"CP_kf_trigger",*)
'would go off bottom: cu_kf',pres(
ks),k_lc,nk+1,n_uslcheck
1243 log_info(
"CP_kf_trigger",*)
'would go off top: cu_kf'
1248 dpthmx = dpthmx + deltap(nk)
1249 n_layers = n_layers + 1
1250 if (dpthmx > dpthmin)
then
1255 if (dpthmx < dpthmin)
then
1259 k_pbl = k_lc + n_layers -1
1261 theta_mix = 0._rp; temp_mix = 0._rp; qv_mix = 0._rp; zmix = 0._rp;presmix = 0._rp
1264 temp_mix = temp_mix + deltap(kk)*temp(kk)
1265 qv_mix = qv_mix + deltap(kk)*qv(kk)
1266 zmix = zmix + deltap(kk)*z_kf(kk)
1267 presmix = presmix + deltap(kk)*pres(kk)
1270 temp_mix = temp_mix/dpthmx
1271 qv_mix = qv_mix/dpthmx
1272 presmix = presmix/dpthmx
1274 emix = qv_mix * presmix / ( epsvap + qv_mix )
1278 templog = log(emix/aliq)
1279 temp_dew = (cliq - dliq*templog)/(bliq - templog)
1282 temp_lcl = temp_dew - (0.212_rp + 1.571e-3_rp*(temp_dew - tem00) &
1283 - 4.36e-4_rp*(temp_mix - tem00))*(temp_mix - temp_dew)
1284 temp_lcl = min(temp_lcl,temp_mix)
1285 tempv_lcl = temp_lcl * ( 1.0_rp + epstvap * qv_mix )
1286 zlcl = zmix + (temp_lcl - temp_mix)/gdcp
1291 if( zlcl <= z_kf(kk) )
exit
1294 if (zlcl > z_kf(
ke))
then
1299 deltaz = ( zlcl - z_kf(k_lclm1) )/( z_kf(k_lcl)- z_kf(k_lclm1 ) )
1300 temp_env = temp(k_lclm1) + ( temp(k_lcl) - temp(k_lclm1) )*deltaz
1301 qvenv = qv(k_lclm1) + ( qv(k_lcl) - qv(k_lclm1) )*deltaz
1302 tempv_env = temp_env * ( 1.0_rp + epstvap * qvenv )
1307 if (zlcl < 2.e3_rp)
then
1309 w_cz = 1.e-5_rp*zlcl
1316 w_g = (w0avg(k_lclm1) + (w0avg(k_lcl) - w0avg(k_lclm1))*deltaz )*deltax/25.e3_rp - w_cz
1317 if ( w_g < 1.e-4_rp)
then
1320 dtvv = 4.64_rp*w_g**0.33_rp
1325 if ( trigger_type == 2 )
then
1326 else if ( trigger_type == 3 )
then
1334 if(u00 < 1._rp)
then
1335 qs_lcl=qes(k_lclm1)+(qes(k_lcl)-qes(k_lclm1))*deltaz
1336 rh_lcl = qvenv/qs_lcl
1337 dqssdt = qv_mix*(cliq-bliq*dliq)/((temp_lcl-dliq)*(temp_lcl-dliq))
1338 if(rh_lcl >= 0.75_rp .and. rh_lcl <=0.95_rp)
then
1339 dtrh = 0.25_rp*(rh_lcl-0.75_rp)*qv_mix/dqssdt
1340 elseif(rh_lcl > 0.95_rp)
then
1341 dtrh = (1._rp/rh_lcl-1._rp)*qv_mix/dqssdt
1349 if (temp_lcl + dtvv + dtrh <= temp_env + eps*1e3_rp )
then
1357 call cp_kf_envirtht( presmix, temp_mix, qv_mix, &
1360 if (dtvv + dtrh > 1.e-4_rp )
then
1361 w_lcl = 1._rp + 0.5_rp*sqrt(2._rp*grav*(dtvv + dtrh)*500._rp/tempv_env)
1362 w_lcl = min(w_lcl,3._rp)
1368 pres_lcl = pres(k_lclm1) + (pres(k_lcl) - pres(k_lclm1))*deltaz
1371 if (w_g < 0._rp )
then
1373 elseif (w_g > 0.1_rp)
then
1376 radius = 1000._rp + 1000._rp*w_g*10._rp
1379 call cp_kf_updraft ( &
1381 k_lcl, k_pbl, dz_kf(:), z_kf(:), &
1382 w_lcl, temp_lcl, tempv_lcl, pres_lcl, &
1383 qv_mix, qv(:), temp(:), tempv_env, &
1384 zlcl, pres(:), deltap(:), &
1385 deltax, radius, dpthmx, &
1386 k_let, theta_eu(:), &
1392 upent(:), updet(:), &
1393 umfnewdold(:), umfnew, umfold, &
1394 temp_u(:), theta_ee(:), &
1395 cloudhight, cloudtop, &
1396 qv_u(:), qc(:), qi(:), &
1397 qrout_t(:), qsout_t(:), &
1398 qvdet(:), qcdet(:), qidet(:), &
1400 flux_qr(:), flux_qs(:) )
1403 cldhgt(k_lc) = cloudhight
1406 if(temp_lcl > 293._rp)
then
1408 elseif (temp_lcl < 293._rp .and. temp_lcl > 273._rp)
then
1409 d_min = 2.e3_rp + 100._rp*(temp_lcl - tem00)
1415 if ( k_top <= k_lcl .or. &
1416 k_top <= k_pbl .or. &
1417 k_let+1 <= k_pbl )
then
1419 cldhgt(k_lc) = cloudhight
1420 do kk = k_lclm1,k_top
1429 elseif (cloudhight > d_min .and. cape > 1._rp)
then
1438 if(n_uslcheck == nuchm)
then
1441 do kk = k_lclm1,k_top
1454 if ( itr .ge. itr_max )
then
1455 log_error(
"CP_kf_trigger",*)
'iteration max count was reached in the USL loop in the KF scheme'
1464 if (i_convflag == 1)
then
1465 k_start = max(k_pbl,k_lcl)
1471 if (k_let == k_top)
then
1472 updet(k_top) = umf(k_top) + updet(k_top) - upent(k_top)
1473 qcdet(k_top) = qc(k_top)*updet(k_top)*umfnew/umfold
1474 qidet(k_top) = qi(k_top)*updet(k_top)*umfnew/umfold
1475 upent(k_top) = 0._rp
1480 do kk = k_let+1,k_top
1481 dptt = dptt + deltap(kk)
1483 dumfdp = umf(k_let)/dptt
1492 do kk = k_let+1,k_top
1493 if(kk == k_top)
then
1494 updet(kk) = umf(kk-1)
1496 qcdet(kk) = updet(kk)*qc(kk)*umfnewdold(kk)
1497 qidet(kk) = updet(kk)*qi(kk)*umfnewdold(kk)
1499 umf(kk) = umf(kk-1) - deltap(kk)*dumfdp
1500 upent(kk) = umf(kk)*(1._rp - 1._rp/umfnewdold(kk))
1501 updet(kk) = umf(kk-1) - umf(kk) + upent(kk)
1502 qcdet(kk) = updet(kk)*qc(kk)*umfnewdold(kk)
1503 qidet(kk) = updet(kk)*qi(kk)*umfnewdold(kk)
1505 if (kk >= k_let+2)
then
1506 flux_qr(kk) = umf(kk-1)*qrout_t(kk)
1507 flux_qs(kk) = umf(kk-1)*qsout_t(kk)
1517 if(temp(kk) > tem00) k_ml = kk
1524 if (kk == k_lc)
then
1525 upent(kk) = umflcl*deltap(kk)/dpthmx
1526 umf(kk) = umflcl*deltap(kk)/dpthmx
1527 elseif (kk <= k_pbl)
then
1528 upent(kk) = umflcl*deltap(kk)/dpthmx
1529 umf(kk) = umf(kk-1) + upent(kk)
1535 temp_u(kk) = temp_mix + (z_kf(kk) - zmix)*gdcp
1556 call cp_kf_envirtht( pres(kk), temp(kk), qv(kk), &
1582 end subroutine cp_kf_trigger
1589 subroutine cp_kf_updraft ( &
1591 k_lcl, k_pbl, dz_kf, z_kf, &
1592 w_lcl, temp_lcl, tempv_lcl, pres_lcl, &
1593 qv_mix, qv, temp, tempv_env, &
1594 zlcl, pres, deltap, &
1595 deltax, radius, dpthmx, &
1603 umfnewdold, umfnew,umfold, &
1605 cloudhight, cloudtop, &
1606 qv_u, qc, qi, qrout, qsout, &
1607 qvdet, qcdet, qidet, &
1616 integer,
intent(in) ::
ka,
ks,
ke
1617 integer,
intent(in) :: k_lcl
1618 integer,
intent(in) :: k_pbl
1619 real(rp),
intent(in) :: dz_kf(
ka), z_kf(
ka)
1620 real(rp),
intent(in) :: w_lcl
1621 real(rp),
intent(in) :: temp_lcl
1622 real(rp),
intent(in) :: tempv_lcl
1623 real(rp),
intent(in) :: pres_lcl
1624 real(rp),
intent(in) :: qv_mix
1625 real(rp),
intent(in) :: qv(
ka)
1626 real(rp),
intent(in) :: temp(
ka)
1627 real(rp),
intent(in) :: tempv_env
1628 real(rp),
intent(in) :: zlcl
1629 real(rp),
intent(in) :: pres(
ka)
1630 real(rp),
intent(in) :: deltap(
ka)
1631 real(rp),
intent(in) :: deltax
1632 real(rp),
intent(in) :: radius
1633 real(rp),
intent(in) :: dpthmx
1635 integer,
intent(inout) :: k_let
1636 real(rp),
intent(inout) :: theta_eu(
ka)
1639 real(rp),
intent(out) :: work(
ka,5)
1642 integer,
intent(out) :: k_top
1643 real(rp),
intent(out) :: umf(
ka)
1644 real(rp),
intent(out) :: umflcl
1645 real(rp),
intent(out) :: upent(
ka)
1646 real(rp),
intent(out) :: updet(
ka)
1647 real(rp),
intent(out) :: umfnewdold(
ka)
1648 real(rp),
intent(out) :: umfnew,umfold
1649 real(rp),
intent(out) :: temp_u(
ka)
1650 real(rp),
intent(out) :: theta_ee(
ka)
1651 real(rp),
intent(out) :: cloudhight
1652 real(rp),
intent(out) :: cloudtop
1653 real(rp),
intent(out) :: qv_u(
ka)
1654 real(rp),
intent(out) :: qc(
ka)
1655 real(rp),
intent(out) :: qi(
ka)
1656 real(rp),
intent(out) :: qrout(
ka)
1657 real(rp),
intent(out) :: qsout(
ka)
1658 real(rp),
intent(out) :: qvdet(
ka)
1659 real(rp),
intent(out) :: qcdet(
ka)
1660 real(rp),
intent(out) :: qidet(
ka)
1661 real(rp),
intent(out) :: cape
1662 real(rp),
intent(out) :: flux_qr(
ka)
1663 real(rp),
intent(out) :: flux_qs(
ka)
1668 #define tempv_u(k) work(k,1)
1669 #define tempvq_uu(k) work(k,2)
1671 real(rp) :: tempv_u(
ka)
1672 real(rp) :: tempvq_uu(
ka)
1675 real(rp) :: ee1,ud1, ee2,ud2
1677 #define f_eq(k) work(k,3)
1679 real(rp) :: f_eq(
ka)
1681 real(rp) :: f_mix1,f_mix2
1682 real(rp) :: rei,dilbe
1683 real(rp) :: qcnew,qinew
1685 real(rp) :: f_frozen1
1687 real(rp) :: temptmp_ice
1689 #define tempv_ud(k) work(k,4)
1691 real(rp) :: tempv_ud(
ka)
1698 real(rp) :: theta_tmp
1700 #define wu(k) work(k,5)
1704 real(rp) :: qvtmp, qctmp, qitmp
1705 real(rp) :: temp_u95, temp_u10
1708 real(rp),
parameter :: temp_frzt = 268.16_rp
1709 real(rp),
parameter :: temp_frzb = 248.16_rp
1735 tempv_ud(kk) = temp(kk) *( 1.0_rp + epstvap * qv(kk) )
1738 umfnewdold(:) = 1._rp
1741 denslcl = pres_lcl/(rdry*tempv_lcl)
1742 umf(k_lclm1) = denslcl*1.e-2_rp*deltax**2
1743 umflcl = umf(k_lclm1)
1747 temp_u(k_lclm1) = temp_lcl
1748 tempv_u(k_lclm1) = tempv_lcl
1749 qv_u(k_lclm1) = qv_mix
1756 temptmp_ice = temp_frzt
1761 do kk = k_lclm1,
ke-1
1765 theta_eu(kkp1) = theta_eu(kk)
1766 qv_u(kkp1) = qv_u(kk)
1773 call cp_kf_tpmix2(pres(kkp1), theta_eu(kkp1), &
1774 qv_u(kkp1), qc(kkp1), qi(kkp1), &
1775 temp_u(kkp1), qcnew, qinew )
1781 if (temp_u(kkp1) <= temp_frzt )
then
1782 if (temp_u(kkp1) > temp_frzb)
then
1783 if (temptmp_ice > temp_frzt) temptmp_ice = temp_frzt
1785 f_frozen1 = (temptmp_ice - temp_u(kkp1))/(temptmp_ice - temp_frzb)
1789 f_frozen1 = min(1._rp, max(0._rp, f_frozen1))
1790 temptmp_ice = temp_u(kkp1)
1792 qfrz = (qc(kkp1) + qcnew)*f_frozen1
1793 qinew = qinew + qcnew*f_frozen1
1794 qcnew = qcnew - qcnew*f_frozen1
1795 qi(kkp1) = qi(kkp1) + qc(kkp1)*f_frozen1
1796 qc(kkp1) = qc(kkp1) - qc(kkp1)*f_frozen1
1799 call cp_kf_dtfrznew( pres(kkp1), qfrz, &
1801 temp_u(kkp1), qv_u(kkp1), qi(kkp1), &
1802 temptmp, theta_eu(kkp1), qvtmp, qitmp )
1803 temp_u(kkp1) = temptmp
1807 tempv_u(kkp1) = temp_u(kkp1) * ( 1.0_rp + epstvap * qv_u(kkp1) )
1809 if (kk == k_lclm1)
then
1810 boeff = (tempv_lcl + tempv_u(kkp1))/(tempv_env + tempv_ud(kkp1)) - 1._rp
1811 boterm = 2._rp*(z_kf(kkp1) - zlcl)*grav*boeff/1.5_rp
1812 dztmp = z_kf(kkp1) - zlcl
1814 boeff = (tempv_u(kk) + tempv_u(kkp1))/(tempv_ud(kk) + tempv_ud(kkp1)) - 1._rp
1815 boterm = 2._rp*(dz_kf(kk) )*grav*boeff/1.5_rp
1819 entterm = 2._rp*rei*wtw/umfold
1821 call cp_kf_precipitation( &
1822 grav, dztmp, boterm, entterm, &
1823 wtw, qc(kkp1), qi(kkp1), qcnew, qinew, qrout(kkp1), qsout(kkp1) )
1829 if (wtw < 1.e-3_rp )
then
1832 wu(kkp1) = sqrt(wtw)
1835 call cp_kf_envirtht( pres(kkp1), temp(kkp1), qv(kkp1), &
1838 rei = umflcl*deltap(kkp1)*0.03_rp/radius
1841 tempvq_uu(kkp1) = temp_u(kkp1) * ( 1.0_rp + epstvap * qv_u(kkp1) - qc(kkp1) - qi(kkp1) )
1842 if (kk == k_lclm1) then
1843 dilbe = ((tempv_lcl + tempvq_uu(kkp1))/(tempv_env + tempv_ud(kkp1)) - 1._rp)*dztmp
1845 dilbe = ((tempvq_uu(kk) + tempvq_uu(kkp1))/(tempv_ud(kk) + tempv_ud(kkp1)) - 1._rp)*dztmp
1847 if(dilbe > 0._rp) cape = cape + dilbe*grav
1853 if(tempvq_uu(kkp1) <= tempv_ud(kkp1))
then
1863 f_mix2 = 1._rp - f_mix1
1864 theta_tmp = f_mix1*theta_ee(kkp1) + f_mix2*theta_eu(kkp1)
1865 qvtmp = f_mix1*qv(kkp1) + f_mix2*qv_u(kkp1)
1866 qctmp = f_mix2*qc(kkp1)
1867 qitmp = f_mix2*qi(kkp1)
1869 call cp_kf_tpmix2( pres(kkp1), theta_tmp, &
1870 qvtmp, qctmp, qitmp, &
1871 temptmp, qcnew, qinew )
1873 temp_u95 = temptmp * ( 1.0_rp + epstvap * qvtmp - qctmp - qitmp )
1875 if ( temp_u95 > tempv_ud(kkp1))
then
1881 f_mix2 = 1._rp - f_mix1
1882 theta_tmp = f_mix1*theta_ee(kkp1) + f_mix2*theta_eu(kkp1)
1883 qvtmp = f_mix1*qv(kkp1) + f_mix2*qv_u(kkp1)
1884 qctmp = f_mix2*qc(kkp1)
1885 qitmp = f_mix2*qi(kkp1)
1887 call cp_kf_tpmix2( pres(kkp1), theta_tmp, &
1888 qvtmp, qctmp, qitmp, &
1889 temptmp, qcnew, qinew )
1891 temp_u10 = temptmp * (1.0 + epstvap * qvtmp - qctmp - qitmp )
1892 if (abs(temp_u10 - tempvq_uu(kkp1)) < 1.e-3_rp )
then
1897 f_eq(kkp1) = (tempv_ud(kkp1) - tempvq_uu(kkp1))*f_mix1 &
1898 & /(temp_u10 - tempvq_uu(kkp1))
1899 f_eq(kkp1) = max(0._rp,f_eq(kkp1) )
1900 f_eq(kkp1) = min(1._rp,f_eq(kkp1) )
1901 if (f_eq(kkp1) == 1._rp)
then
1904 elseif (f_eq(kkp1) == 0._rp)
then
1910 call cp_kf_prof5( f_eq(kkp1), &
1916 ee2 = max(ee2,0.5_rp)
1919 upent(kkp1) = 0.5_rp*rei*(ee1 + ee2)
1920 updet(kkp1) = 0.5_rp*rei*(ud1 + ud2)
1923 if (umf(kk) - updet(kkp1) < 10._rp)
then
1927 if (dilbe > 0._rp)
then
1928 cape = cape - dilbe*grav
1935 umfold = umf(kk) - updet(kkp1)
1936 umfnew = umfold + upent(kkp1)
1938 umfnewdold(kkp1) = umfnew/umfold
1939 qcdet(kkp1) = qc(kkp1)*updet(kkp1)
1940 qidet(kkp1) = qi(kkp1)*updet(kkp1)
1941 qvdet(kkp1) = qv_u(kkp1)
1945 qnew = ( umfold*qv_u(kkp1) + upent(kkp1)*qv(kkp1) ) / umfnew
1946 theta_eu(kkp1) = ( umfold * ( 1.0_rp + qold ) * theta_eu(kkp1) &
1947 + upent(kkp1) * ( 1.0_rp + qv(kkp1) ) * theta_ee(kkp1) &
1949 ) / ( umfnew * ( 1.0_rp + qnew ) )
1951 qc(kkp1) = qc(kkp1)*umfold/umfnew
1952 qi(kkp1) = qi(kkp1)*umfold/umfnew
1955 flux_qr(kkp1) = qrout(kkp1)*umf(kk)
1956 flux_qs(kkp1) = qsout(kkp1)*umf(kk)
1960 if(kkp1 <= k_pbl ) upent(kkp1) = upent(kkp1) + umflcl*deltap(kkp1)/dpthmx
1965 cloudhight = z_kf(k_top) - zlcl
1966 cloudtop = z_kf(k_top)
1969 end subroutine cp_kf_updraft
1976 subroutine cp_kf_downdraft ( &
1979 k_lcl, k_ml, k_top, k_pbl, k_let, k_lc, &
1981 u, v, rh, qv, pres, &
1986 flux_qr, flux_qs, tempv, &
1990 wspd, dmf, downent, downdet, &
1992 rain_flux, snow_flux, &
2010 atmos_saturation_psat_liq
2014 integer,
intent(in) ::
ka,
ks,
ke
2015 integer,
intent(in) :: i_convflag
2016 integer,
intent(in) :: k_lcl
2017 integer,
intent(in) :: k_ml
2018 integer,
intent(in) :: k_top
2019 integer,
intent(in) :: k_pbl
2020 integer,
intent(in) :: k_let
2021 integer,
intent(in) :: k_lc
2022 real(
rp),
intent(in) :: z_kf(
ka)
2023 real(
rp),
intent(in) :: zlcl
2024 real(
rp),
intent(in) :: u(
ka)
2025 real(
rp),
intent(in) :: v(
ka)
2026 real(
rp),
intent(in) :: rh(
ka)
2027 real(
rp),
intent(in) :: qv(
ka)
2028 real(
rp),
intent(in) :: pres(
ka)
2029 real(
rp),
intent(in) :: deltap(
ka)
2030 real(
rp),
intent(in) :: deltax
2031 real(
rp),
intent(in) :: ems(
ka)
2032 real(
rp),
intent(in) :: theta_ee(
ka)
2033 real(
rp),
intent(in) :: umf(
ka)
2034 real(
rp),
intent(in) :: temp_u(
ka)
2035 real(
rp),
intent(in) :: flux_qr(
ka)
2036 real(
rp),
intent(in) :: flux_qs(
ka)
2037 real(
rp),
intent(in) :: tempv(
ka)
2040 real(
rp),
intent(out) :: work(
ka,5)
2043 real(
rp),
intent(out) :: wspd(3)
2044 real(
rp),
intent(out) :: dmf(
ka)
2045 real(
rp),
intent(out) :: downent(
ka)
2046 real(
rp),
intent(out) :: downdet(
ka)
2047 real(
rp),
intent(out) :: theta_d(
ka)
2048 real(
rp),
intent(out) :: qv_d(
ka)
2049 real(
rp),
intent(out) :: rain_flux
2050 real(
rp),
intent(out) :: snow_flux
2051 real(
rp),
intent(out) :: prec_engi
2052 integer,
intent(out) :: k_lfs
2063 real(
rp) :: pef_wind
2064 real(
rp) :: pef_cloud
2078 #define temp_d(k) work(k,1)
2079 #define tempv_d(k) work(k,2)
2080 #define theta_ed(k) work(k,3)
2081 #define qvsd(k) work(k,4)
2083 real(
rp) :: temp_d(
ka)
2084 real(
rp) :: tempv_d(
ka)
2085 real(
rp) :: theta_ed(
ka)
2086 real(
rp) :: qvsd(
ka)
2090 #define iexn_d(k) work(k,5)
2092 real(
rp) :: iexn_d(
ka)
2098 real(
rp) :: total_prec
2099 real(
rp) :: total_rain
2100 real(
rp) :: total_snow
2101 logical :: flag_rain
2121 if (i_convflag == 2)
return
2125 if (pres(kk) >= pres(
ks)*0.5_rp) k_z5 = kk
2128 wspd(1) = sqrt(u(k_lcl)*u(k_lcl) + v(k_lcl)*v(k_lcl))
2129 wspd(2) = sqrt(u(k_z5)*u(k_z5) + v(k_z5)*v(k_z5))
2130 wspd(3) = sqrt(u(k_top)*u(k_top) + v(k_top)*v(k_top))
2135 if(wspd(3) > wspd(1))
then
2140 vws = (u(k_top) - u(k_lcl))*(u(k_top) - u(k_lcl)) &
2141 + (v(k_top) - v(k_lcl))*(v(k_top) - v(k_lcl))
2143 vws = 1.e3_rp*shsign*sqrt(vws)/(z_kf(k_top) - z_kf(k_lcl))
2146 pef_wind = 1.591_rp + vws*(-0.639_rp + vws*(9.53e-2_rp - vws*4.96e-3_rp) )
2148 pef_wind = max(pef_wind,0.2_rp)
2149 pef_wind = min(pef_wind,0.9_rp)
2153 cbh = (zlcl - z_kf(
ks))*3.281e-3_rp
2154 if( cbh < 3._rp)
then
2157 rcbh = 0.96729352_rp + cbh*(-0.70034167_rp + cbh*(0.162179896_rp + cbh*(- &
2158 1.2569798e-2_rp + cbh*(4.2772e-4_rp - cbh*5.44e-6_rp))))
2160 if(cbh > 25.0_rp) rcbh = 2.4_rp
2161 pef_cloud = 1._rp/(1._rp + rcbh)
2162 pef_cloud = min(pef_cloud,0.9_rp)
2164 pef = 0.5_rp*(pef_wind + pef_cloud)
2169 do kk = k_lcl, k_top
2170 total_rain = total_rain + flux_qr(kk)
2171 total_snow = total_snow + flux_qs(kk)
2175 if(i_convflag == 1)
then
2179 k_dstart = k_pbl + 1
2180 k_lfstmp = k_let - 1
2181 do kk = k_dstart+1,
ke
2182 dpthtmp = pres(k_dstart) - pres(kk)
2183 if(dpthtmp > 150.e2_rp)
then
2188 k_lfstmp = min(k_lfstmp, k_let - 1)
2195 if(pres(k_dstart) - pres(k_lfs) > 50.e2_rp)
then
2196 theta_ed(k_lfs) = theta_ee(k_lfs)
2197 qv_d(k_lfs) = qv(k_lfs)
2199 call cp_kf_tpmix2dd( pres(k_lfs), theta_ed(k_lfs), &
2200 temp_d(k_lfs), qvs_tmp )
2201 call cp_kf_calciexn( pres(k_lfs), qvs_tmp, &
2203 theta_d(k_lfs) = temp_d(k_lfs) * iexn_d(k_lfs)
2205 tempv_d(k_lfs) = temp_d(k_lfs) * ( 1.0_rp + epstvap * qvs_tmp )
2206 dens_d = pres(k_lfs)/(rdry*tempv_d(k_lfs))
2207 dmf(k_lfs) = -(1._rp - pef)*1.e-2_rp*deltax**2*dens_d
2208 downent(k_lfs) = dmf(k_lfs)
2209 downdet(k_lfs) = 0._rp
2210 rhbar = rh(k_lfs)*deltap(k_lfs)
2211 dpthtmp = deltap(k_lfs)
2215 do kk = k_lfs-1,k_dstart,-1
2217 downent(kk) = downent(k_lfs)*ems(kk)/ems(k_lfs)
2219 dmf(kk) = dmf(kkp1) + downent(kk)
2221 qv_d(kk) = ( qv_d(kkp1)*dmf(kkp1) + qv(kk)*downent(kk) ) / dmf(kk)
2222 theta_ed(kk) = ( theta_ed(kkp1) * dmf(kkp1) * ( 1.0_rp + qvold ) &
2223 + theta_ee(kk) * downent(kk) * ( 1.0_rp + qv(kk) ) &
2224 ) / ( dmf(kk) * ( 1.0_rp + qv_d(kk) ) )
2225 dpthtmp = dpthtmp + deltap(kk)
2226 rhbar = rhbar + rh(kk)*deltap(kk)
2228 rhbar = rhbar/dpthtmp
2229 f_dmf = 2._rp*(1._rp - rhbar)
2231 call cp_kf_tpmix2dd( pres(k_dstart), theta_ed(k_dstart), &
2232 temp_d(k_dstart), qvs_tmp )
2236 do kk = k_lcl, k_top
2237 dq = dq + ( flux_qr(kk) *
cv_water + flux_qs(kk) *
cv_ice ) * ( temp_d(k_dstart) - temp_u(kk) )
2239 temp_d(k_dstart) = temp_d(k_dstart) - dq / ( umf(k_lcl) * cpdry )
2242 if ( k_lc < k_ml )
then
2244 temp_d(k_dstart) = temp_d(k_dstart) - emelt * total_snow / ( umf(k_lcl) * cpdry )
2245 total_rain = total_rain + total_snow
2255 es = aliq*exp((bliq*temp_d(k_dstart)-cliq)/(temp_d(k_dstart)-dliq))
2257 qvs_tmp = epsvap * es / ( pres(k_dstart) - es )
2259 theta_ed(k_dstart) = temp_d(k_dstart)*(pre00/pres(k_dstart))**( ( rdry + rvap * qvs_tmp ) / ( cpdry + cpvap * qvs_tmp ) ) &
2260 * exp((3374.6525_rp/temp_d(k_dstart)-2.5403_rp)*qvs_tmp*(1._rp + 0.81_rp*qvs_tmp))
2261 k_ldt = min(k_lfs-1, k_dstart-1)
2265 dpthdet = dpthdet + deltap(kk)
2266 theta_ed(kk) = theta_ed(k_dstart)
2267 qv_d(kk) = qv_d(k_dstart)
2268 call cp_kf_tpmix2dd( pres(kk), theta_ed(kk), &
2269 temp_d(kk), qvs_tmp )
2274 rhh = 1._rp - 2.e-4_rp*(z_kf(k_dstart) -z_kf(kk) )
2278 if( rhh < 1._rp )
then
2280 dssdt = (cliq - bliq*dliq)/((temp_d(kk) - dliq)*(temp_d(kk) - dliq))
2281 rl = xlv0 - xlv1*temp_d(kk)
2282 dtmp = rl * qvs_tmp * ( 1.0_rp - rhh ) / ( cpdry + rl * rhh * qvs_tmp * dssdt )
2283 t1rh = temp_d(kk) + dtmp
2287 es = aliq*exp((bliq*t1rh-cliq)/(t1rh-dliq))
2290 qsrh = epsvap * es / ( pres(kk) - es )
2291 if(qsrh < qv_d(kk) )
then
2293 t1rh = temp_d(kk) + (qvs_tmp - qsrh) * rl / cpdry
2305 tempv_d(kk) = temp_d(kk) * ( 1.0_rp + epstvap * qvsd(kk) )
2306 if(tempv_d(kk) > tempv(kk) .or. kk ==
ks)
then
2313 if( (pres(k_ldb)-pres(k_lfs)) > 50.e2_rp )
then
2314 do kk = k_ldt,k_ldb,-1
2316 downdet(kk) = -dmf(k_dstart)*deltap(kk)/dpthdet
2318 dmf(kk) = dmf(kkp1) + downdet(kk)
2319 tder = tder + (qvsd(kk) - qv_d(kk))*downdet(kk)
2321 call cp_kf_calciexn( pres(kk), qv_d(kk), &
2323 theta_d(kk) = temp_d(kk)*iexn_d(kk)
2332 if (tder < 1._rp)
then
2333 rain_flux = total_rain
2334 snow_flux = total_snow
2346 ddinc = -f_dmf*umf(k_lcl)/dmf(k_dstart)
2347 if ( flag_rain )
then
2348 total_prec = total_rain
2350 total_prec = total_snow
2352 if( tder*ddinc > total_prec )
then
2353 ddinc = total_prec / tder
2355 tder = min(tder*ddinc, total_prec)
2357 dmf(kk) = dmf(kk)*ddinc
2358 downent(kk) = downent(kk)*ddinc
2359 downdet(kk) = downdet(kk)*ddinc
2362 if ( flag_rain )
then
2363 rain_flux = total_rain - tder
2364 snow_flux = total_snow
2366 rain_flux = total_rain
2367 snow_flux = total_snow - tder
2369 if ( total_prec < kf_eps )
then
2372 pef = ( rain_flux + snow_flux ) / total_prec
2374 prec_engi = rain_flux *
cv_water * temp_d(k_ldb) &
2375 + snow_flux * (
cv_ice * temp_d(k_ldb) -
lhf )
2391 if (k_ldb >
ks)
then
2411 do kk = k_ldt+1,k_lfs-1
2419 end subroutine cp_kf_downdraft
2426 subroutine cp_kf_compensational (&
2428 k_top, k_lc, k_pbl, k_ml, k_lfs, &
2429 dz_kf, z_kf, pres, deltap, deltax, &
2432 presmix, zmix, dpthmx, &
2434 temp_u, qvdet, umflcl, &
2435 qc, qi, flux_qr, flux_qs, &
2445 I_convflag, k_lcl_bf, &
2446 umf, upent, updet, &
2447 qcdet, qidet, dmf, downent, downdet, &
2448 rain_flux, snow_flux, &
2451 qv_g, qc_nw, qi_nw, qr_nw, qs_nw, &
2452 sflx_rain, sflx_snow, sflx_engi, &
2453 cldfrac_KF, timecp, time_advec, &
2467 atmos_saturation_psat_liq
2471 integer,
intent(in) ::
ka,
ks,
ke
2472 integer,
intent(in) :: k_top
2473 integer,
intent(in) :: k_lc
2474 integer,
intent(in) :: k_pbl
2475 integer,
intent(in) :: k_ml
2476 integer,
intent(in) :: k_lfs
2477 real(
rp),
intent(in) :: dz_kf(
ka),z_kf(
ka)
2478 real(
rp),
intent(in) :: pres(
ka)
2479 real(
rp),
intent(in) :: deltap(
ka)
2480 real(
rp),
intent(in) :: deltax
2481 real(
rp),
intent(in) :: temp_bf(
ka)
2482 real(
rp),
intent(in) :: qv(
ka)
2483 real(
rp),
intent(in) :: ems(
ka)
2484 real(
rp),
intent(in) :: emsd(
ka)
2485 real(
rp),
intent(in) :: presmix
2486 real(
rp),
intent(in) :: zmix
2487 real(
rp),
intent(in) :: dpthmx
2488 real(
rp),
intent(in) :: cape
2489 real(
rp),
intent(in) :: temp_u(
ka)
2490 real(
rp),
intent(in) :: qvdet(
ka)
2491 real(
rp),
intent(in) :: umflcl
2492 real(
rp),
intent(in) :: qc(
ka)
2493 real(
rp),
intent(in) :: qi(
ka)
2494 real(
rp),
intent(in) :: flux_qr(
ka)
2495 real(
rp),
intent(in) :: flux_qs(
ka)
2496 real(
rp),
intent(in) :: umfnewdold(
ka)
2497 real(
rp),
intent(in) :: wspd(3)
2498 real(
rp),
intent(in) :: qv_d(
ka)
2499 real(
rp),
intent(in) :: theta_d(
ka)
2500 real(
rp),
intent(in) :: prec_engi
2501 real(
rp),
intent(in) :: kf_dtsec
2502 real(
rp),
intent(in) :: rhod(
ka)
2503 integer,
intent(in) :: i, j
2506 real(
rp),
intent(out) :: work(
ka,24)
2507 real(
rp),
intent(out) :: work2(0:
ka,7)
2510 integer,
intent(inout) :: i_convflag
2511 integer,
intent(inout) :: k_lcl_bf
2512 real(
rp),
intent(inout) :: umf(
ka)
2513 real(
rp),
intent(inout) :: upent(
ka)
2514 real(
rp),
intent(inout) :: updet(
ka)
2515 real(
rp),
intent(inout) :: qcdet(
ka)
2516 real(
rp),
intent(inout) :: qidet(
ka)
2517 real(
rp),
intent(inout) :: dmf(
ka)
2518 real(
rp),
intent(inout) :: downent(
ka)
2519 real(
rp),
intent(inout) :: downdet(
ka)
2520 real(
rp),
intent(inout) :: rain_flux
2521 real(
rp),
intent(inout) :: snow_flux
2523 integer,
intent(out) :: nic
2526 real(
rp),
intent(out) :: theta_nw(
ka)
2527 real(
rp),
intent(out) :: qv_g(
ka)
2528 real(
rp),
intent(out) :: qc_nw(
ka)
2529 real(
rp),
intent(out) :: qi_nw(
ka)
2530 real(
rp),
intent(out) :: qr_nw(
ka)
2531 real(
rp),
intent(out) :: qs_nw(
ka)
2532 real(
rp),
intent(out) :: sflx_rain
2533 real(
rp),
intent(out) :: sflx_snow
2534 real(
rp),
intent(out) :: sflx_engi
2535 real(
rp),
intent(out) :: cldfrac_kf(
ka,2)
2536 real(
rp),
intent(out) :: timecp
2537 real(
rp),
intent(out) :: time_advec
2539 logical,
intent(out) :: error
2542 integer :: ntimecount
2547 integer :: k_lcl, k_lclm1
2550 #define umf2(k) work(k,1)
2551 #define dmf2(k) work(k,2)
2552 #define upent2(k) work(k,3)
2553 #define updet2(k) work(k,4)
2554 #define qcdet2(k) work(k,5)
2555 #define qidet2(k) work(k,6)
2556 #define downent2(k) work(k,7)
2557 #define downdet2(k) work(k,8)
2559 real(
rp) :: umf2(
ka), dmf2(
ka)
2560 real(
rp) :: upent2(
ka), updet2(
ka)
2561 real(
rp) :: qcdet2(
ka), qidet2(
ka)
2562 real(
rp) :: downent2(
ka), downdet2(
ka)
2564 real(
rp) :: rain_flux2
2565 real(
rp) :: snow_flux2
2569 #define theta(k) work(k,9)
2570 #define theta_u(k) work(k,10)
2571 #define theta_eu(k) work(k,11)
2572 #define theta_eg(k) work(k,12)
2573 #define iexn_c(k) work(k,13)
2575 real(
rp) :: theta(
ka)
2576 real(
rp) :: theta_u(
ka)
2577 real(
rp) :: theta_eu(
ka)
2578 real(
rp) :: theta_eg(
ka)
2579 real(
rp) :: iexn_c(
ka)
2584 #define qv_gu(k) work(k,14)
2585 #define temp_g(k) work(k,15)
2587 real(
rp) :: qv_gu(
ka)
2588 real(
rp) :: temp_g(
ka)
2590 real(
rp) :: temp_env
2591 real(
rp) :: tempv_env
2592 real(
rp) :: temp_lcl
2593 real(
rp) :: tempv_lcl
2594 real(
rp) :: temp_mix
2596 #define temp_gu(k) work(k,16)
2597 #define tempv_g(k) work(k,17)
2598 #define tempvq_uc(k) work(k,18)
2600 real(
rp) :: temp_gu(
ka)
2601 real(
rp) :: tempv_g(
ka)
2602 real(
rp) :: tempvq_uc(
ka)
2606 real(
rp) :: dq, tdpt, dssdt, emix, rl, tlog
2612 #define theta_g(k) work(k,19)
2613 #define qv_nw(k) work(k,20)
2615 real(
rp) :: theta_g(
ka)
2616 real(
rp) :: qv_nw(
ka)
2622 #define fxm(k) work(k,21)
2626 real(
rp) :: f_cape ,f_capeold
2631 real(
rp) :: tma,tmb,tmm
2633 real(
rp) :: ainc,ainctmp, aincmx,aincold
2636 #define omg(k) work2(k,1)
2638 real(
rp) :: omg(0:
ka)
2644 #define domg_dp(k) work(k,22)
2646 real(
rp) :: domg_dp(
ka)
2648 real(
rp) :: absomgtc,absomg
2652 #define theta_fx(k) work2(k,2)
2653 #define qv_fx(k) work2(k,3)
2654 #define qc_fx(k) work2(k,4)
2655 #define qi_fx(k) work2(k,5)
2656 #define qr_fx(k) work2(k,6)
2657 #define qs_fx(k) work2(k,7)
2658 #define rainfb(k) work(k,23)
2659 #define snowfb(k) work(k,24)
2661 real(
rp) :: theta_fx(0:
ka)
2662 real(
rp) :: qv_fx(0:
ka)
2663 real(
rp) :: qc_fx(0:
ka)
2664 real(
rp) :: qi_fx(0:
ka)
2665 real(
rp) :: qr_fx(0:
ka)
2666 real(
rp) :: qs_fx(0:
ka)
2667 real(
rp) :: rainfb(
ka), snowfb(
ka)
2678 real(
rp) :: xcldfrac
2691 if(i_convflag == 2)
return
2693 if ( do_prec .and. i_convflag == 0 )
then
2699 vconv = 0.5_rp*(wspd(1) + wspd(2))
2700 timecp = deltax/max(vconv, kf_eps)
2702 timecp = max(deeplifetime, timecp)
2703 timecp = min(3600._rp, timecp)
2704 if(i_convflag == 1) timecp = shallowlifetime
2705 nic = nint(timecp/kf_dtsec)
2706 timecp = nic * kf_dtsec
2710 k_lmax = max(k_lcl,k_lfs)
2712 if((upent(kk)-downent(kk)) > 1.e-3_rp)
then
2713 ainctmp = ems(kk)/( (upent(kk) -downent(kk))*timecp )
2714 aincmx = min(aincmx,ainctmp)
2719 if(aincmx < ainc ) ainc = aincmx
2721 rain_flux2 = rain_flux
2722 snow_flux2 = snow_flux
2725 upent2(kk) = upent(kk)
2726 updet2(kk) = updet(kk)
2727 qcdet2(kk) = qcdet(kk)
2728 qidet2(kk) = qidet(kk)
2730 downent2(kk) = downent(kk)
2731 downdet2(kk) = downdet(kk)
2734 stab = 1.05_rp - delcape
2736 if (i_convflag == 1)
then
2739 evac = 0.50_rp*tkemax*1.e-1_rp
2740 ainc = evac*dpthmx*deltax**2/( umflcl*grav*timecp)
2741 rain_flux = rain_flux2*ainc
2742 snow_flux = snow_flux2*ainc
2744 umf(kk) = umf2(kk)*ainc
2745 upent(kk) = upent2(kk)*ainc
2746 updet(kk) = updet2(kk)*ainc
2747 qcdet(kk) = qcdet2(kk)*ainc
2748 qidet(kk) = qidet2(kk)*ainc
2749 dmf(kk) = dmf2(kk)*ainc
2750 downent(kk) = downent2(kk)*ainc
2751 downdet(kk) = downdet2(kk)*ainc
2758 call cp_kf_calciexn( pres(kk), qv(kk), &
2760 theta(kk) = temp_bf(kk) * iexn_c(kk)
2761 call cp_kf_calciexn( pres(kk), qvdet(kk), &
2763 theta_u(kk) = temp_u(kk) * iexn_c(kk)
2765 temp_g(k_top+1:
ke) = temp_bf(k_top+1:
ke)
2766 qv_g(k_top+1:
ke) = qv(k_top+1:
ke)
2777 domg_dp(kk) = - ( upent(kk) - downent(kk) - updet(kk) - downdet(kk) ) * emsd(kk)
2778 omg(kk) = omg(kk-1) - deltap(kk) * domg_dp(kk)
2779 absomg = abs(omg(kk))
2780 absomgtc = absomg*timecp
2781 f_dp = 0.75_rp*deltap(kk)
2782 if(absomgtc > f_dp)
THEN
2783 dtt_tmp = f_dp/absomg
2784 dtt=min(dtt,dtt_tmp)
2789 theta_nw(kk) = theta(kk)
2793 fxm(kk) = - omg(kk) * deltax**2 / grav
2795 nstep = nint(timecp/dtt + 1)
2796 deltat = timecp/real(nstep,
rp)
2797 if ( hist_flag )
then
2800 hist_work(kk,i,j,i_hist_qv_fc,m) = 0.0_rp
2801 hist_work(kk,i,j,i_hist_qv_ue,m) = 0.0_rp
2802 hist_work(kk,i,j,i_hist_qv_ud,m) = 0.0_rp
2807 hist_work(kk,i,j,i_hist_qv_de,0) = 0.0_rp
2808 hist_work(kk,i,j,i_hist_qv_dd,0) = 0.0_rp
2811 theta_fx(
ks-1) = 0.0_rp
2812 qv_fx(
ks-1) = 0.0_rp
2813 theta_fx(k_top) = 0.0_rp
2814 qv_fx(k_top) = 0.0_rp
2815 do ntimecount = 1, nstep
2820 if( omg(kk) <= 0.0_rp )
then
2821 theta_fx(kk) = fxm(kk) * theta_nw(kk) * ( 1.0_rp + qv_nw(kk) )
2822 qv_fx(kk) = fxm(kk) * qv_nw(kk)
2824 theta_fx(kk) = fxm(kk) * theta_nw(kk+1) * ( 1.0_rp + qv_nw(kk+1) )
2825 qv_fx(kk) = fxm(kk) * qv_nw(kk+1)
2832 qv_nw(kk) = qv_nw(kk) &
2833 + ( - ( qv_fx(kk) - qv_fx(kk-1) ) &
2834 + updet(kk)*qvdet(kk) + downdet(kk)*qv_d(kk) &
2835 - ( upent(kk) - downent(kk) )*qv(kk) )*deltat*emsd(kk)
2836 theta_nw(kk) = ( theta_nw(kk) * ( 1.0_rp + qvold + qc(kk) + qi(kk) ) &
2837 + ( - ( theta_fx(kk) - theta_fx(kk-1) ) &
2838 + updet(kk) * theta_u(kk) * ( 1.0_rp + qvdet(kk) ) &
2839 + downdet(kk) * theta_d(kk) * ( 1.0_rp + qv_d(kk) ) &
2840 - ( upent(kk) - downent(kk) ) * theta(kk) * ( 1.0_rp + qv(kk) ) &
2841 ) * deltat * emsd(kk) &
2842 ) / ( 1.0_rp + qv_nw(kk) + qc(kk) + qi(kk) )
2844 if ( hist_flag )
then
2846 hist_work(kk,i,j,i_hist_qv_fc,i_convflag) = hist_work(kk,i,j,i_hist_qv_fc,i_convflag) &
2847 - ( qv_fx(kk) - qv_fx(kk-1) ) * emsd(kk) * rhod(kk) / nstep
2848 hist_work(kk,i,j,i_hist_qv_ud,i_convflag) = hist_work(kk,i,j,i_hist_qv_ud,i_convflag) &
2849 + updet(kk) * qvdet(kk) * emsd(kk) * rhod(kk) / nstep
2850 hist_work(kk,i,j,i_hist_qv_ue,i_convflag) = hist_work(kk,i,j,i_hist_qv_ue,i_convflag) &
2851 - upent(kk) * qv(kk) * emsd(kk) * rhod(kk) / nstep
2853 if ( i_convflag == 0 )
then
2855 hist_work(kk,i,j,i_hist_qv_dd,0) = hist_work(kk,i,j,i_hist_qv_dd,0) &
2856 + downdet(kk) * qv_d(kk) * emsd(kk) * rhod(kk) / nstep
2857 hist_work(kk,i,j,i_hist_qv_de,0) = hist_work(kk,i,j,i_hist_qv_de,0) &
2858 + downent(kk) * qv(kk) * emsd(kk) * rhod(kk) / nstep
2865 theta_g(kk) = theta_nw(kk)
2866 qv_g(kk) = qv_nw(kk)
2870 if ( qv_g(k_top) < kf_eps )
then
2871 qv_g(k_top-1) = qv_g(k_top-1) + ( qv_g(k_top) - kf_eps ) * ems(k_top) * emsd(k_top-1)
2872 qv_g(k_top) = kf_eps
2874 do kk = k_top-1,
ks+1, -1
2875 if( qv_g(kk) < kf_eps )
then
2876 tma = qv_g(kk+1) * ems(kk+1)
2877 tmb = max( qv_g(kk-1), kf_eps ) * ems(kk-1)
2878 tmm = ( qv_g(kk) - kf_eps ) * ems(kk)
2879 tma = tma * ( 1.0_rp + tmm / ( tma + tmb ) )
2880 tma = max( tma, kf_eps * ems(kk+1) )
2881 qv_g(kk-1) = qv_g(kk-1) + ( qv_g(kk+1) * ems(kk+1) - tma + tmm ) * emsd(kk-1)
2882 qv_g(kk+1) = tma * emsd(kk+1)
2886 if( qv_g(
ks) < kf_eps )
then
2887 log_error(
"CP_kf_compensational",*)
"error qv<0 @ Kain-Fritsch cumulus parameterization"
2894 if ( hist_flag )
then
2896 hist_work(kk,i,j,i_hist_qv_nf,i_convflag) = ( qv_g(kk) - qv_nw(kk) ) * rhod(kk) / timecp
2900 topomg = (updet(k_top) - upent(k_top))*deltap(k_top)*emsd(k_top)
2901 if( abs(topomg - omg(k_top-1)) > 1.e-3_rp)
then
2902 log_error(
"CP_kf_compensational",*)
"KF omega is not consistent",ncount
2903 log_error_cont(*)
"omega error",abs(topomg - omg(k_top-1)),k_top,topomg,omg(k_top-1)
2912 call cp_kf_calciexn( pres(kk), qv_g(kk), &
2914 temp_g(kk) = theta_g(kk) / iexn_c(kk)
2915 tempv_g(kk) = temp_g(kk) * ( 1.0_rp + epstvap * qv_g(kk) )
2919 if(i_convflag == 1)
then
2925 temp_mix = temp_mix + deltap(kk)*temp_g(kk)
2926 qv_mix = qv_mix + deltap(kk)*qv_g(kk)
2929 temp_mix = temp_mix/dpthmx
2930 qv_mix = qv_mix/dpthmx
2935 es = aliq*exp((bliq*temp_mix-cliq)/(temp_mix-dliq))
2937 qvss = epsvap * es / (presmix -es)
2940 if (qv_mix > qvss)
then
2941 rl = xlv0 -xlv1*temp_mix
2942 cpm = cpdry + ( cpvap - cpdry ) * qv_mix
2943 dssdt = qvss*(cliq-bliq*dliq)/( (temp_mix-dliq)**2)
2944 dq = (qv_mix -qvss)/(1._rp + rl*dssdt/cpm)
2945 temp_mix = temp_mix + rl / cpdry * dq
2946 qv_mix = qv_mix - dq
2949 qv_mix = max(qv_mix,0._rp)
2950 emix = qv_mix * presmix / ( epsvap + qv_mix )
2951 tlog = log(emix/aliq)
2953 tdpt = (cliq - dliq*tlog)/(bliq - tlog)
2954 temp_lcl = tdpt - (0.212_rp + 1.571e-3_rp*(tdpt - tem00) - 4.36e-4_rp*(temp_mix - tem00))*(temp_mix - tdpt)
2955 temp_lcl = min(temp_lcl,temp_mix)
2957 tempv_lcl = temp_lcl * ( 1.0_rp + epstvap * qv_mix )
2958 z_lcl = zmix + (temp_lcl - temp_mix)/gdcp
2961 if( z_lcl <= z_kf(kk) )
exit
2966 deltaz = ( z_lcl - z_kf(k_lclm1) )/( z_kf(k_lcl)- z_kf(k_lclm1 ) )
2967 temp_env = temp_g(k_lclm1) + ( temp_g(k_lcl) - temp_g(k_lclm1) )*deltaz
2968 qv_env = qv_g(k_lclm1) + ( qv_g(k_lcl) - qv_g(k_lclm1) )*deltaz
2969 tempv_env = temp_env * ( 1.0_rp + epstvap * qv_env )
2971 theta_eu(k_lclm1)=temp_mix*(pre00/presmix)**( ( rdry + rvap * qv_mix ) / ( cpdry + cpvap * qv_mix ) ) &
2972 * exp((3374.6525_rp/temp_lcl-2.5403_rp)*qv_mix*(1._rp + 0.81_rp*qv_mix))
2976 do kk=k_lclm1,k_top-1
2978 theta_eu(kkp1) = theta_eu(kk)
2980 call cp_kf_tpmix2dd( pres(kkp1), theta_eu(kkp1), &
2981 temp_gu(kkp1), qv_gu(kkp1) )
2982 tempvq_uc(kkp1) = temp_gu(kkp1) * ( 1.0_rp + epstvap * qv_gu(kkp1) - qc(kkp1)- qi(kkp1) )
2983 if(kk == k_lclm1)
then
2984 dzz = z_kf(k_lcl) - z_lcl
2985 dilbe = ((tempv_lcl + tempvq_uc(kkp1))/(tempv_env + tempv_g(kkp1)) - 1._rp)*dzz
2988 dilbe = ((tempvq_uc(kk) + tempvq_uc(kkp1))/(tempv_g(kk) + tempv_g(kkp1)) - 1._rp)*dzz
2990 if(dilbe > 0._rp) cape_g = cape_g + dilbe*grav
2993 call cp_kf_envirtht( pres(kkp1), temp_g(kkp1), qv_g(kkp1), &
2997 theta_eu(kkp1) = theta_eu(kkp1)*(umfnewdold(kkp1)) + theta_eg(kkp1)*(1._rp - (umfnewdold(kkp1)))
2999 if (noiter == 1)
exit
3000 dcape = max(cape - cape_g,cape*0.1_rp)
3001 f_cape = cape_g/cape
3002 if(f_cape > 1._rp .and. i_convflag == 0)
then
3006 if(ncount /= 1)
then
3007 if(abs(ainc - aincold) < 1.e-4_rp)
then
3012 dfda = (f_cape - f_capeold)/(ainc - aincold)
3013 if (dfda > 0._rp )
then
3025 if (ainc/aincmx > 0.999_rp .and. f_cape > 1.05_rp-stab )
then
3031 if( (f_cape <= 1.05_rp-stab .and. f_cape >= 0.95_rp-stab) .or. ncount == 10)
then
3034 if(ncount > 10)
exit
3035 if(f_cape == 0._rp)
then
3038 if(dcape < 1.e-4)
then
3043 ainc = ainc*stab*cape/max(dcape,kf_eps)
3046 ainc = min(aincmx,ainc)
3048 if (ainc < 0.05_rp)
then
3053 rain_flux = rain_flux2*ainc
3054 snow_flux = snow_flux2*ainc
3056 umf(kk) = umf2(kk)*ainc
3057 upent(kk) = upent2(kk)*ainc
3058 updet(kk) = updet2(kk)*ainc
3059 qcdet(kk) = qcdet2(kk)*ainc
3060 qidet(kk) = qidet2(kk)*ainc
3061 dmf(kk) = dmf2(kk)*ainc
3062 downent(kk) = downent2(kk)*ainc
3063 downdet(kk) = downdet2(kk)*ainc
3072 cldfrac_kf(:,:) = 0._rp
3073 if (i_convflag == 1)
then
3074 do kk = k_lcl-1, k_top
3075 umf_tmp = umf(kk)/(deltax**2)
3076 xcldfrac = 0.07_rp*log(1._rp+(500._rp*umf_tmp))
3077 xcldfrac = max(1.e-2_rp,xcldfrac)
3078 cldfrac_kf(kk,1) = min(2.e-2_rp,xcldfrac)
3081 do kk = k_lcl-1, k_top
3082 umf_tmp = umf(kk)/(deltax**2)
3083 xcldfrac = 0.14_rp*log(1._rp+(500._rp*umf_tmp))
3084 xcldfrac = max(1.e-2_rp,xcldfrac)
3085 cldfrac_kf(kk,2) = min(6.e-1_rp,xcldfrac)
3091 rainfb(kk) = flux_qr(kk) * fbfrc * aincfin
3094 snowfb(kk) = flux_qs(kk) * fbfrc * aincfin
3098 qc_nw(
ks:
ke) = 0._rp
3099 qi_nw(
ks:
ke) = 0._rp
3100 qr_nw(
ks:
ke) = 0._rp
3101 qs_nw(
ks:
ke) = 0._rp
3103 if ( hist_flag )
then
3106 hist_work(kk,i,j,i_hist_qc_fc,m) = 0.0_rp
3107 hist_work(kk,i,j,i_hist_qc_ud,m) = 0.0_rp
3108 hist_work(kk,i,j,i_hist_qi_fc,m) = 0.0_rp
3109 hist_work(kk,i,j,i_hist_qi_ud,m) = 0.0_rp
3110 hist_work(kk,i,j,i_hist_qr_fc,m) = 0.0_rp
3111 hist_work(kk,i,j,i_hist_qr_rf,m) = 0.0_rp
3112 hist_work(kk,i,j,i_hist_qs_fc,m) = 0.0_rp
3113 hist_work(kk,i,j,i_hist_qs_sf,m) = 0.0_rp
3117 qc_fx(
ks-1) = 0.0_rp
3118 qi_fx(
ks-1) = 0.0_rp
3119 qr_fx(
ks-1) = 0.0_rp
3120 qs_fx(
ks-1) = 0.0_rp
3121 qc_fx(k_top) = 0.0_rp
3122 qi_fx(k_top) = 0.0_rp
3123 qr_fx(k_top) = 0.0_rp
3124 qs_fx(k_top) = 0.0_rp
3125 do ntimecount = 1, nstep
3127 if( omg(kk) <= 0.0_rp )
then
3128 qc_fx(kk) = fxm(kk) * qc_nw(kk)
3129 qi_fx(kk) = fxm(kk) * qi_nw(kk)
3130 qr_fx(kk) = fxm(kk) * qr_nw(kk)
3131 qs_fx(kk) = fxm(kk) * qs_nw(kk)
3133 qc_fx(kk) = fxm(kk) * qc_nw(kk+1)
3134 qi_fx(kk) = fxm(kk) * qi_nw(kk+1)
3135 qr_fx(kk) = fxm(kk) * qr_nw(kk+1)
3136 qs_fx(kk) = fxm(kk) * qs_nw(kk+1)
3140 qc_nw(kk) = qc_nw(kk) + ( - ( qc_fx(kk) - qc_fx(kk-1) ) + qcdet(kk) )*deltat*emsd(kk)
3141 qi_nw(kk) = qi_nw(kk) + ( - ( qi_fx(kk) - qi_fx(kk-1) ) + qidet(kk) )*deltat*emsd(kk)
3142 qr_nw(kk) = qr_nw(kk) + ( - ( qr_fx(kk) - qr_fx(kk-1) ) + rainfb(kk) )*deltat*emsd(kk)
3143 qs_nw(kk) = qs_nw(kk) + ( - ( qs_fx(kk) - qs_fx(kk-1) ) + snowfb(kk) )*deltat*emsd(kk)
3145 if ( hist_flag )
then
3147 hist_work(kk,i,j,i_hist_qc_fc,i_convflag) = hist_work(kk,i,j,i_hist_qc_fc,i_convflag) &
3148 - ( qc_fx(kk) - qc_fx(kk-1) ) * emsd(kk) * rhod(kk) / nstep
3149 hist_work(kk,i,j,i_hist_qc_ud,i_convflag) = hist_work(kk,i,j,i_hist_qc_ud,i_convflag) &
3150 + qcdet(kk) * emsd(kk) * rhod(kk) / nstep
3151 hist_work(kk,i,j,i_hist_qi_fc,i_convflag) = hist_work(kk,i,j,i_hist_qi_fc,i_convflag) &
3152 - ( qi_fx(kk) - qi_fx(kk-1) ) * emsd(kk) * rhod(kk) / nstep
3153 hist_work(kk,i,j,i_hist_qi_ud,i_convflag) = hist_work(kk,i,j,i_hist_qi_ud,i_convflag) &
3154 + qidet(kk) * emsd(kk) * rhod(kk) / nstep
3155 hist_work(kk,i,j,i_hist_qr_fc,i_convflag) = hist_work(kk,i,j,i_hist_qr_fc,i_convflag) &
3156 - ( qr_fx(kk) - qr_fx(kk-1) ) * emsd(kk) * rhod(kk) / nstep
3157 hist_work(kk,i,j,i_hist_qr_rf,i_convflag) = hist_work(kk,i,j,i_hist_qr_rf,i_convflag) &
3158 + rainfb(kk) * emsd(kk) * rhod(kk) / nstep
3159 hist_work(kk,i,j,i_hist_qs_fc,i_convflag) = hist_work(kk,i,j,i_hist_qs_fc,i_convflag) &
3160 - ( qs_fx(kk) - qs_fx(kk-1) ) * emsd(kk) * rhod(kk) / nstep
3161 hist_work(kk,i,j,i_hist_qs_sf,i_convflag) = hist_work(kk,i,j,i_hist_qs_sf,i_convflag) &
3162 + snowfb(kk) * emsd(kk) * rhod(kk) / nstep
3171 sflx_rain = rain_flux*(1._rp - fbfrc)/(deltax**2)
3172 sflx_snow = snow_flux*(1._rp - fbfrc)/(deltax**2)
3173 sflx_engi = prec_engi*(1._rp - fbfrc)/(deltax**2)
3181 dpth = dpth + deltap(kk)
3182 qinit = qinit + qv(kk)*ems(kk)
3183 qvfnl = qvfnl + qv_g(kk)*ems(kk)
3184 qhydr = qhydr + (qc_nw(kk) + qi_nw(kk) + qr_nw(kk) + qs_nw(kk))*ems(kk)
3186 qpfnl = (rain_flux+snow_flux)*timecp*(1._rp - fbfrc)
3187 qfinl = qvfnl + qhydr + qpfnl
3188 err = ( qfinl - qinit )*100._rp/qinit
3189 if ( abs(err) > 0.05_rp )
then
3192 log_error(
"CP_kf_compensational",*)
"@KF,MOISTURE i,j=",i,j
3193 log_error_cont(*)
"--------------------------------------"
3194 log_error_cont(
'("vert accum rho*qhyd : ",ES20.12)') qhydr
3195 log_error_cont(
'("vert accum rho*qv : ",ES20.12)') qvfnl-qinit
3196 log_error_cont(
'("precipitation rate : ",ES20.12)') qpfnl
3197 log_error_cont(
'("conserv qhyd + qv : ",ES20.12)') qhydr + qpfnl
3198 log_error_cont(
'("conserv total : ",ES20.12)') qfinl-qinit
3199 log_error_cont(*)
"--------------------------------------"
3218 theta_nw(kk) = theta_nw(kk) - emelt * ( qi_nw(kk) + qs_nw(kk) ) * rhod(kk) / ( cpdry + ( cpvap - cpdry ) * qv_g(kk) ) * iexn_c(kk)
3219 qc_nw(kk) = qc_nw(kk) + qi_nw(kk)
3220 qr_nw(kk) = qr_nw(kk) + qs_nw(kk)
3225 if ( hist_flag )
then
3227 hist_work(kk,i,j,i_hist_qc_fc,i_convflag) = hist_work(kk,i,j,i_hist_qc_fc,i_convflag) + hist_work(kk,i,j,i_hist_qi_fc,i_convflag)
3228 hist_work(kk,i,j,i_hist_qc_ud,i_convflag) = hist_work(kk,i,j,i_hist_qc_ud,i_convflag) + hist_work(kk,i,j,i_hist_qi_ud,i_convflag)
3229 hist_work(kk,i,j,i_hist_qr_fc,i_convflag) = hist_work(kk,i,j,i_hist_qr_fc,i_convflag) + hist_work(kk,i,j,i_hist_qs_fc,i_convflag)
3230 hist_work(kk,i,j,i_hist_qr_rf,i_convflag) = hist_work(kk,i,j,i_hist_qr_rf,i_convflag) + hist_work(kk,i,j,i_hist_qs_sf,i_convflag)
3263 end subroutine cp_kf_compensational
3266 subroutine cp_kf_precipitation( &
3267 G, DZ, BOTERM, ENTERM, &
3268 WTW, QLIQ, QICE, QNEWLQ, QNEWIC, QLQOUT, QICOUT )
3271 real(
rp),
INTENT(IN ) :: g, dz,boterm,enterm
3272 real(
rp),
INTENT(INOUT) :: wtw, qliq, qice, qnewlq, qnewic, qlqout, qicout
3274 select case ( prec_type )
3276 call cp_kf_precipitation_oc1973( g, dz, boterm, enterm, &
3277 wtw, qliq, qice, qnewlq, qnewic, qlqout, qicout )
3279 call cp_kf_precipitation_kessler( g, dz, boterm, enterm, &
3280 wtw, qliq, qice, qnewlq, qnewic, qlqout, qicout )
3284 end subroutine cp_kf_precipitation
3292 subroutine cp_kf_calciexn( pres, qv, iexn )
3301 real(
rp),
intent(in) :: pres
3302 real(
rp),
intent(in) :: qv
3303 real(
rp),
intent(out) :: iexn
3305 iexn = (pre00/pres)**( ( rdry + rvap * qv ) / ( cpdry + cpvap * qv ) )
3308 end subroutine cp_kf_calciexn
3319 subroutine cp_kf_precipitation_oc1973( &
3320 G, DZ, BOTERM, ENTERM, &
3321 WTW, QLIQ, QICE, QNEWLQ, QNEWIC, QLQOUT, QICOUT )
3324 real(
rp),
intent(in) :: g
3325 real(
rp),
intent(in) :: dz
3326 real(
rp),
intent(in) :: boterm
3327 real(
rp),
intent(in) :: enterm
3328 real(
rp),
intent(inout) :: qlqout
3329 real(
rp),
intent(inout) :: qicout
3330 real(
rp),
intent(inout) :: wtw
3331 real(
rp),
intent(inout) :: qliq
3332 real(
rp),
intent(inout) :: qice
3333 real(
rp),
intent(inout) :: qnewlq
3334 real(
rp),
intent(inout) :: qnewic
3336 real(
rp) :: qtot,qnew,qest,g1,wavg,conv,ratio3,oldq,ratio4,dq,pptdrg
3344 qest=0.5_rp*(qtot+qnew)
3345 g1=wtw+boterm-enterm-2._rp*g*dz*qest/1.5_rp
3346 IF(g1.LT.0.0)g1=0._rp
3347 wavg=0.5_rp*(sqrt(wtw)+sqrt(g1))
3348 conv=rate*dz/max(wavg,kf_eps)
3354 ratio3=qnewlq/(qnew+1.e-8_rp)
3356 qtot=qtot+0.6_rp*qnew
3358 ratio4=(0.6_rp*qnewlq+qliq)/(qtot+1.e-8_rp)
3359 qtot=qtot*exp(-conv)
3365 qicout=(1._rp-ratio4)*dq
3369 pptdrg=0.5_rp*(oldq+qtot-0.2_rp*qnew)
3370 wtw=wtw+boterm-enterm-2._rp*g*dz*pptdrg/1.5_rp
3371 IF(abs(wtw).LT.1.e-4_rp)wtw=1.e-4_rp
3375 qliq=ratio4*qtot+ratio3*0.4_rp*qnew
3376 qice=(1._rp-ratio4)*qtot+(1._rp-ratio3)*0.4_rp*qnew
3380 end subroutine cp_kf_precipitation_oc1973
3386 subroutine cp_kf_precipitation_kessler( &
3387 G, DZ, BOTERM, ENTERM, &
3388 WTW, QLIQ, QICE, QNEWLQ, QNEWIC, QLQOUT, QICOUT )
3391 real(
rp),
intent(in) :: g
3392 real(
rp),
intent(in) :: dz
3393 real(
rp),
intent(in) :: boterm
3394 real(
rp),
intent(in) :: enterm
3395 real(
rp),
intent(inout) :: wtw
3396 real(
rp),
intent(inout) :: qliq
3397 real(
rp),
intent(inout) :: qice
3398 real(
rp),
intent(inout) :: qnewlq
3399 real(
rp),
intent(inout) :: qnewic
3400 real(
rp),
intent(inout) :: qlqout
3401 real(
rp),
intent(inout) :: qicout
3404 real(
rp) :: total_liq, total_ice
3406 real(
rp) :: auto_qc, auto_qi
3407 auto_qc = kf_threshold
3408 auto_qi = kf_threshold
3410 total_liq = qliq + qnewlq
3411 total_ice = qice + qnewic
3414 qlqout = max( total_liq - auto_qc, 0.0_rp )
3415 qicout = max( total_ice - auto_qi, 0.0_rp )
3417 pptdrg = max( 0.5_rp * ( total_liq + total_ice - qlqout - qicout ), 0.0_rp )
3418 wtw=wtw+boterm-enterm-2._rp*g*dz*pptdrg/1.5_rp
3419 IF(abs(wtw).LT.1.e-4_rp)wtw=1.e-4_rp
3421 qliq = max( total_liq - qlqout, 0.0_rp )
3422 qlqout = total_liq - qliq
3424 qice = max( total_ice - qicout, 0.0_rp )
3425 qicout = total_ice - qice
3431 end subroutine cp_kf_precipitation_kessler
3436 subroutine cp_kf_tpmix2( p,thes,qu,qliq,qice,tu,qnewlq,qnewic )
3442 real(
rp),
intent(in) :: p, thes
3443 real(
rp),
intent(inout) :: qu, qliq, qice
3444 real(
rp),
intent(out) :: tu, qnewlq, qnewic
3446 real(
rp) :: temp,qs,qnew,dq,qtot,rll,cpp
3449 call cp_kf_tpmix2dd( p, thes, temp, qs )
3473 qliq=qliq-dq*qliq/(qtot+1.e-10_rp)
3474 qice=qice-dq*qice/(qtot+1.e-10_rp)
3478 cpp = cpdry + ( cpvap - cpdry ) * qu
3479 IF(qtot.LT.1.e-10_rp)
THEN
3481 temp=temp+rll*(dq/(1._rp+dq))/cpp
3485 temp=temp+rll*((dq-qtot)/(1._rp+dq-qtot))/cpp
3496 end subroutine cp_kf_tpmix2
3503 subroutine cp_kf_dtfrznew( P, QFRZ, TU, QU, QICE, TUnew, THTEU, QUnew, QICEnew )
3519 atmos_saturation_psat_liq
3521 real(
rp),
intent(in) :: p, qfrz
3523 real(
rp),
intent(in) :: tu, qu, qice
3524 real(
rp),
intent(out) :: tunew, thteu, qunew, qicenew
3526 real(
rp) :: rls,rlf,cpp,a,dtfrz,es,qs,dqevap,pii
3535 cpp = cpdry + ( cpvap - cpdry ) * qu
3539 a=(cliq-bliq*dliq)/((tu-dliq)*(tu-dliq))
3540 dtfrz = rlf*qfrz/(cpp+rls*qu*a)
3544 es = aliq*exp((bliq*tunew-cliq)/(tunew-dliq))
3545 qs = es * epsvap / ( p - es )
3552 dqevap = max( min(qs-qu, qice), 0.0_rp )
3553 qicenew = qice-dqevap
3555 pii=(pre00/p)**( ( rdry + rvap * qunew ) / ( cpdry + cpvap * qunew ) )
3557 thteu = tunew*pii*exp((3374.6525_rp/tunew - 2.5403_rp)*qunew*(1._rp + 0.81_rp*qunew))
3559 end subroutine cp_kf_dtfrznew
3573 subroutine cp_kf_prof5( EQ, EE, UD )
3576 real(
rp),
intent(in) :: eq
3577 real(
rp),
intent(inout) :: ee, ud
3579 real(
rp) :: sqrt2p, a1, a2, a3, p, sigma, fe
3580 real(
rp) :: x, y, ey, e45, t1, t2, c1, c2
3582 DATA sqrt2p,a1,a2,a3,p,sigma,fe/2.506628_rp,0.4361836_rp,-0.1201676_rp, &
3583 0.9372980_rp,0.33267_rp,0.166666667_rp,0.202765151_rp/
3584 x = (eq - 0.5_rp)/sigma
3585 y = 6._rp*eq - 3._rp
3586 ey = exp(y*y/(-2._rp))
3588 t2 = 1._rp/(1._rp + p*abs(y))
3590 c1 = a1*t1+a2*t1*t1+a3*t1*t1*t1
3591 c2 = a1*t2+a2*t2*t2+a3*t2*t2*t2
3593 ee=sigma*(0.5_rp*(sqrt2p-e45*c1-ey*c2)+sigma*(e45-ey))-e45*eq*eq/2._rp
3594 ud=sigma*(0.5_rp*(ey*c2-e45*c1)+sigma*(e45-ey))-e45*(0.5_rp+eq*eq/2._rp- &
3597 ee=sigma*(0.5_rp*(ey*c2-e45*c1)+sigma*(e45-ey))-e45*eq*eq/2._rp
3598 ud=sigma*(0.5_rp*(sqrt2p-e45*c1-ey*c2)+sigma*(e45-ey))-e45*(0.5_rp+eq* &
3603 end subroutine cp_kf_prof5
3613 subroutine cp_kf_tpmix2dd( p, thes, ts, qs )
3616 real(
rp),
intent(in) :: p, thes
3617 real(
rp),
intent(out) :: ts, qs
3619 real(
rp) :: tp,qq,bth,tth,pp,t00,t10,t01,t11,q00,q10,q01,q11
3620 integer :: iptb, ithtb
3623 tp = ( p - plutop ) * rdpr
3626 if ( iptb < 1 .or. iptb >= kfnp )
then
3627 log_warn(
"CP_kf_tpmix2dd",*)
'OUT OF BOUNDS (p): ', p, plutop, pbot
3628 iptb = min( max( iptb, 1 ), kfnp-1 )
3629 qq = 0.5_rp + sign(0.5_rp, iptb-2.0_rp)
3634 bth = ( the0k(iptb+1) - the0k(iptb) ) * qq + the0k(iptb)
3635 tth = ( thes - bth ) * rdthk
3636 pp = tth - aint(tth)
3638 if ( ithtb < 1 .or. ithtb >= kfnt )
then
3639 log_warn(
"CP_kf_tpmix2dd",*)
'OUT OF BOUNDS (thes): ', thes, p, bth, bth + (kfnt-1) / rdthk
3640 ithtb = min( max( ithtb, 1 ), kfnt-1 )
3641 pp = 0.5_rp + sign(0.5_rp, ithtb-2.0_rp)
3645 t00=ttab(ithtb ,iptb )
3646 t10=ttab(ithtb+1,iptb )
3647 t01=ttab(ithtb ,iptb+1)
3648 t11=ttab(ithtb+1,iptb+1)
3650 q00=qstab(ithtb ,iptb )
3651 q10=qstab(ithtb+1,iptb )
3652 q01=qstab(ithtb ,iptb+1)
3653 q11=qstab(ithtb+1,iptb+1)
3656 ts = ( (t10-t00)*pp+(t01-t00)*qq+((t00-t10)-(t01-t11))*pp*qq )
3658 qs = ( (q10-q00)*pp+(q01-q00)*qq+((q00-q10)-(q01-q11))*pp*qq )
3662 end subroutine cp_kf_tpmix2dd
3674 subroutine cp_kf_envirtht( P1, T1, Q1, THT1 )
3684 real(
rp),
intent(in) :: p1, t1, q1
3685 real(
rp),
intent(out) :: tht1
3687 real(
rp) :: ee,tlog,tdpt,tsat,tht
3688 real(
rp),
parameter :: c1=3374.6525_rp
3689 real(
rp),
parameter :: c2=2.5403_rp
3690 ee = q1 * p1 / ( epsvap + q1 )
3705 tdpt=(cliq-dliq*tlog)/(bliq-tlog)
3707 tsat=tdpt - (0.212_rp+1.571e-3_rp*(tdpt-tem00)-4.36e-4_rp*(t1-tem00))*(t1-tdpt)
3710 tht=t1*(p00/p1)**( ( rdry + rvap * q1 ) / ( cpdry + cpvap * q1 ) )
3711 tht1=tht*exp((c1/tsat-c2)*q1*(1._rp+0.81_rp*q1))
3714 end subroutine cp_kf_envirtht
3722 subroutine cp_kf_lutab
3733 integer :: kp, it, itcnt, i
3734 real(
rp) :: dth = 1._rp
3735 real(
rp) :: tmin = 150._rp
3736 real(
rp) :: toler = 0.001_rp
3737 real(
rp) :: dpr, temp, p, es, qs, pi
3738 real(
rp) :: thes, tgues, thgues, thtgs
3739 real(
rp) :: dt, t1, t0, f0, f1, astrt, ainc, a1
3753 dpr=(pbot-plutop)/real(kfnp-1)
3765 es=aliq*exp((bliq*temp-cliq)/(temp-dliq))
3766 qs = epsvap * es / ( p - es )
3767 pi = (pre00/p)**( ( rdry + rvap * qs ) / ( cpdry + cpvap * qs ) )
3768 the0k(kp)=temp*pi*exp((3374.6525_rp/temp-2.5403_rp)*qs* &
3787 es=aliq*exp((bliq*tgues-cliq)/(tgues-dliq))
3788 qs = epsvap * es / ( p - es )
3789 pi = ( pre00 / p )**( ( rdry + rvap * qs ) / ( cpdry + cpvap * qs ) )
3790 thgues=tgues*pi*exp((3374.6525_rp/tgues-2.5403_rp)*qs* &
3791 (1._rp + 0.81_rp*qs))
3798 es=aliq*exp((bliq*t1-cliq)/(t1-dliq))
3799 qs = epsvap * es / ( p - es )
3800 pi = ( pre00 / p )**( ( rdry + rvap * qs ) / ( cpdry + cpvap * qs ) )
3801 thtgs=t1*pi*exp((3374.6525_rp/t1-2.5403_rp)*qs*(1._rp + 0.81_rp*qs))
3803 if(abs(f1).lt.toler)
then
3807 dt=f1*(t1-t0)/(f1-f0)
3828 gdcp = - grav / cpdry
3830 end subroutine cp_kf_lutab