79 itf,ktf,its,ite, kts,kte &
80 ,dicycle & ! diurnal cycle flag
81 ,ichoice & ! choice of closure, use "0" for ensemble average
82 ,ipr & ! this flag can be used for debugging prints
83 ,ccn & ! not well tested yet
85 ,dtime & ! dt over which forcing is applied
86 ,imid & ! flag to turn on mid level convection
87 ,kpbl & ! level of boundary layer height
88 ,dhdt & ! boundary layer forcing (one closure for shallow)
133 ,do_smoke_transport &
144 ,do_capsuppress,cap_suppress_j &
152 nranflag,itf,ktf,its,ite, kts,kte,ipr,imid,kdt
153 integer,
intent (in ) :: &
155 real(kind=kind_phys),
dimension (its:ite,4) &
156 ,
intent (in ) :: rand_clos
157 real(kind=kind_phys),
dimension (its:ite) &
158 ,
intent (in ) :: rand_mom,rand_vmas
161 integer,
intent(in) :: do_capsuppress
162 real(kind=kind_phys),
intent(in),
dimension(:),
optional :: cap_suppress_j
167 real(kind=kind_phys),
dimension (its:ite,1:maxens3) :: xf_ens,pr_ens
173 real(kind=kind_phys),
dimension (its:ite,kts:kte) &
174 ,
intent (inout ) :: &
175 cnvwt,outu,outv,outt,outq,outqc,cupclw
176 real(kind=kind_phys),
dimension (its:ite) &
179 real(kind=kind_phys),
dimension (its:ite) &
180 ,
intent (inout ) :: &
183 real(kind=kind_phys),
dimension (its:ite) &
185 hfx,qfx,xmbm_in,xmbs_in
187 integer,
dimension (its:ite) &
188 ,
intent (inout ) :: &
191 integer,
dimension (its:ite) &
200 real(kind=kind_phys),
dimension (its:ite,kts:kte) &
202 dhdt,rho,t,po,us,vs,tn
204 real(kind=kind_phys),
dimension (its:ite,kts:kte) &
205 ,
intent (inout ) :: &
208 real(kind=kind_phys),
dimension (its:ite,kts:kte) &
212 real(kind=kind_phys),
dimension (its:ite) &
216 real(kind=kind_phys),
dimension (its:ite) &
217 ,
intent (inout ) :: &
220 real(kind=kind_phys),
dimension (:,:,:) &
221 ,
intent (inout),
optional :: &
223 logical,
intent (in) :: do_smoke_transport
224 real(kind=kind_phys),
dimension (:,:) &
225 ,
intent (out),
optional :: wetdpc_deep
226 real(kind=kind_phys),
intent (in) :: fscav(:)
229 real(kind=kind_phys) &
237 real(kind=kind_phys),
dimension (its:ite,1) :: &
239 real(kind=kind_phys),
dimension (its:ite,1) :: &
241 real(kind=kind_phys),
dimension (its:ite,kts:kte,1) :: &
242 dellat_ens,dellaqc_ens,dellaq_ens,pwo_ens
309 real(kind=kind_phys),
dimension (its:ite,kts:kte,nchem) :: &
311 real(kind=kind_phys),
dimension (its:ite,kts:kte,nchem) :: &
312 chem_cup,chem_up,chem_down,dellac,dellac2,chem_c,chem_pw,chem_pwd
313 real(kind=kind_phys),
dimension (its:ite,nchem) :: &
315 real(kind=kind_phys):: dtime_max,sum1,sum2
316 real(kind=kind_phys),
dimension (kts:kte) :: trac,trcflx_in,trcflx_out,trc,trco
317 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: pwdper, massflx
322 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: &
323 entr_rate_2d,mentrd_rate_2d,he,hes,qes,z, heo,heso,qeso,zo, &
324 xhe,xhes,xqes,xz,xt,xq,qes_cup,q_cup,he_cup,hes_cup,z_cup, &
325 p_cup,gamma_cup,t_cup, qeso_cup,qo_cup,heo_cup,heso_cup, &
326 zo_cup,po_cup,gammao_cup,tn_cup, &
327 xqes_cup,xq_cup,xhe_cup,xhes_cup,xz_cup, &
328 xt_cup, dby,hc,zu,clw_all, &
329 dbyo,qco,qrcdo,pwdo,pwo,hcdo,qcdo,dbydo,hco,qrco, &
338 cd,cdd,dellah,dellaq,dellat,dellaqc, &
339 u_cup,v_cup,uc,vc,ucd,vcd,dellu,dellv
359 real(kind=kind_phys),
dimension (its:ite) :: &
360 edt,edto,edtm,aa1,aa0,xaa0,hkb, &
363 pwevo,bu,bud,cap_max, &
364 cap_max_increment,closure_n,psum,psumh,sig,sigd
365 real(kind=kind_phys),
dimension (its:ite) :: &
366 axx,edtmax,edtmin,entr_rate
367 integer,
dimension (its:ite) :: &
368 kzdown,kdet,k22,jmin,kstabi,kstabm,k22x,xland1, &
369 ktopdby,kbconx,ierr2,ierr3,kbmax
379 integer,
dimension (its:ite),
intent(inout) :: ierr
380 integer,
dimension (its:ite),
intent(in),
optional :: csum
383 iloop,nens3,ki,kk,i,k
384 real(kind=kind_phys) :: &
385 dz,dzo,mbdt,radius, &
386 zcutdown,depth_min,zkbmax,z_detr,zktop, &
387 dh,cap_maxs,trash,trash2,frh,sig_thresh
388 real(kind=kind_phys),
dimension (its:ite) :: pefc
389 real(kind=kind_phys) entdo,dp,subin,detdo,entup, &
390 detup,subdown,entdoj,entupk,detupk,totmas
392 real(kind=kind_phys),
dimension (its:ite) :: lambau,flux_tun,zws,ztexec,zqexec
395 integer :: jprnt,jmini,start_k22
396 logical :: keep_going,flg(its:ite)
399 character*50 :: ierrc(its:ite)
400 character*4 :: cumulus
401 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: &
402 up_massentr,up_massdetr,c1d &
403 ,up_massentro,up_massdetro,dd_massentro,dd_massdetro
404 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: &
405 up_massentru,up_massdetru,dd_massentru,dd_massdetru
408 real(kind=kind_phys) c1_max,buo_flux,pgcon,pgc,blqe
410 real(kind=kind_phys) :: xff_mid(its:ite,2)
412 integer :: iversion=1
413 real(kind=kind_phys) :: denom,h_entr,umean,t_star,dq
414 integer,
intent(in) :: dicycle
415 real(kind=kind_phys),
dimension (its:ite) :: aa1_bl,hkbo_bl,tau_bl,tau_ecmwf,wmean
416 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: tn_bl, qo_bl, qeso_bl, heo_bl, heso_bl &
417 ,qeso_cup_bl,qo_cup_bl, heo_cup_bl,heso_cup_bl &
418 ,gammao_cup_bl,tn_cup_bl,hco_bl,dbyo_bl
419 real(kind=kind_phys),
dimension(its:ite) :: xf_dicycle
424 real(kind=kind_phys),
intent(inout),
dimension(its:ite,10) :: forcing
426 integer :: turn,pmin_lev(its:ite),start_level(its:ite),ktopkeep(its:ite)
427 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: dtempdz
428 integer,
dimension (its:ite,kts:kte) :: k_inv_layers
429 real(kind=kind_phys),
dimension (its:ite) :: c0
430 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: c0t3d
434 real(kind=kind_phys) zuh2(40)
435 real(kind=kind_phys),
dimension (its:ite) :: rntot,delqev,delq2,qevap,rn,qcond
437 real(kind=kind_phys) :: rain,t1,q1,elocp,evef,el2orc,evfact,evfactl,g_rain,e_dn,c_up
438 real(kind=kind_phys) :: pgeoh,dts,fp,fpi,pmin,x_add,beta,beta_u
439 real(kind=kind_phys) :: cbeg,cmid,cend,const_a,const_b,const_c
442 real(kind=kind_phys),
dimension (its:ite,kts:kte) :: p_liq_ice,melting_layer,melting
449 melting_layer(:,:)=0.
455 if(imid.eq.1)cumulus=
'mid'
457 if(imid.eq.1)pmin=75.
463 el2orc=xlv*xlv/(r_v*cp)
476 if(imid.eq.1)lambau(:)=2.0
478 if(nranflag == 1)
then
479 lambau(:)=1.5+rand_mom(:)
491 xland1(i)=int(xland(i)+.0001)
492 if(xland(i).gt.1.5 .or. xland(i).lt.0.5)
then
495 if(xland1(i).eq.1)c0(i)=0.002
510 buo_flux= (hfx(i)/cp+0.608*t(i,1)*qfx(i)/xlv)/rho(i,1)
513 zws(i) = max(0.,flux_tun(i)*0.41*buo_flux*zo(i,2)*g/t(i,1))
514 if(zws(i) > tiny(pgeoh))
then
516 zws(i) = 1.2*zws(i)**.3333
518 ztexec(i) = max(flux_tun(i)*hfx(i)/(rho(i,1)*zws(i)*cp),0.0)
520 zqexec(i) = max(flux_tun(i)*qfx(i)/xlv/(rho(i,1)*zws(i)),0.)
524 zws(i) = max(0.,.001-flux_tun(i)*0.41*buo_flux*zo(i,kpbl(i))*g/t(i,kpbl(i)))
525 zws(i) = 1.2*zws(i)**.3333
526 zws(i) = zws(i)*rho(i,kpbl(i))
536 cap_max_increment(i)=20.
540 if (xland1(i)==0)
then
541 cap_max_increment(i)=20.
543 if(ztexec(i).gt.0.)cap_max(i)=cap_max(i)+25.
544 if(ztexec(i).lt.0.)cap_max(i)=cap_max(i)-25.
551 if(use_excess == 0 )
then
557 if(do_capsuppress == 1)
then
561 if (abs(cap_suppress_j(i) - 1.0 ) < 0.1 )
then
562 cap_max(i)=cap_maxs+75.
563 elseif (abs(cap_suppress_j(i) - 0.0 ) < 0.1 )
then
581 entr_rate(i)=7.e-5 - min(20.,float(csum(i))) * 3.e-6
582 if(xland1(i) == 0)entr_rate(i)=7.e-5
583 if(dx(i)<dx_thresh) entr_rate(i)=2.e-4
584 if(imid.eq.1)entr_rate(i)=3.e-4
585 radius=.2/entr_rate(i)
586 frh=min(1.,3.14*radius*radius/dx(i)/dx(i))
587 if(frh > frh_thresh)
then
589 radius=sqrt(frh*dx(i)*dx(i)/3.14)
590 entr_rate(i)=.2/radius
594 if(forcing(i,7).eq.0.)sig(i)=1.
595 if(kdt.le.(3600./dtime))sig(i)=1.
596 frh_out(i) = frh*sig(i)
599 sig_thresh = (1.-frh_thresh)**2
617 cd(i,k)=.1*entr_rate(i)
618 if(imid.eq.1)cd(i,k)=.5*entr_rate(i)
641 if(dx(its)<dx_thresh)depth_min=5000.
642 if(imid.eq.1)depth_min=2500.
663 if(imid.eq.1)zkbmax=2000.
688 call cup_env(z,qes,he,hes,t,q,po,z1, &
689 psur,ierr,tcrit,-1, &
692 call cup_env(zo,qeso,heo,heso,tn,qo,po,z1, &
693 psur,ierr,tcrit,-1, &
700 call cup_env_clev(t,qes,q,he,hes,z,po,qes_cup,q_cup,he_cup, &
701 hes_cup,z_cup,p_cup,gamma_cup,t_cup,psur, &
705 call cup_env_clev(tn,qeso,qo,heo,heso,zo,po,qeso_cup,qo_cup, &
706 heo_cup,heso_cup,zo_cup,po_cup,gammao_cup,tn_cup,psur, &
713 itf,ktf,its,ite,kts,kte,cumulus)
718 if(kpbl(i).gt.5 .and. imid.eq.1)cap_max(i)=po_cup(i,kpbl(i))
719 u_cup(i,kts)=us(i,kts)
720 v_cup(i,kts)=vs(i,kts)
722 u_cup(i,k)=.5*(us(i,k-1)+us(i,k))
723 v_cup(i,k)=.5*(vs(i,k-1)+vs(i,k))
730 if(zo_cup(i,k).gt.zkbmax+z1(i))
then
740 if(zo_cup(i,k).gt.z_detr+z1(i))
then
760 k22(i)=maxloc(heo_cup(i,start_k22:kbmax(i)+2),1)+start_k22-1
761 if(k22(i).ge.kbmax(i))
then
764 ierrc(i)=
"could not find k22"
781 x_add = xlv*zqexec(i)+cp*ztexec(i)
782 call get_cloud_bc(kte,he_cup(i,1:kte),hkb(i),k22(i),x_add)
783 call get_cloud_bc(kte,heo_cup(i,1:kte),hkbo(i),k22(i),x_add)
791 call cup_kbcon(ierrc,cap_max_increment,iloop,k22,kbcon,heo_cup,heso_cup, &
792 hkbo,ierr,kbmax,po_cup,cap_max, &
796 z_cup,entr_rate,heo,imid)
800 call cup_minimi(heso_cup,kbcon,kstabm,kstabi,ierr, &
806 frh = min(qo_cup(i,kbcon(i))/qeso_cup(i,kbcon(i)),1.)
807 if(frh >= rh_thresh .and. sig(i) <= sig_thresh )
then
817 if(po(i,kbcon(i))-po(i,k) > pmin+x_add)
then
825 start_level(i)=k22(i)
826 x_add = xlv*zqexec(i)+cp*ztexec(i)
827 call get_cloud_bc(kte,he_cup(i,1:kte),hkb(i),k22(i),x_add)
837 kbcon,kstabi,dtempdz,itf,ktf,its,ite, kts,kte)
841 if(kstabi(i).lt.kbcon(i))
then
846 entr_rate_2d(i,k)=entr_rate(i)
849 kbcon(i)=max(2,kbcon(i))
851 frh = min(qo_cup(i,k)/qeso_cup(i,k),1.)
852 entr_rate_2d(i,k)=entr_rate(i) *(1.3-frh)
855 if(k_inv_layers(i,2).gt.0 .and. &
856 (po_cup(i,k22(i))-po_cup(i,k_inv_layers(i,2))).lt.500.)
then
858 ktop(i)=min(kstabi(i),k_inv_layers(i,2))
863 if((po_cup(i,k22(i))-po_cup(i,k)).gt.500.)
then
883 call rates_up_pdf(rand_vmas,ipr,
'mid',ktop,ierr,po_cup,entr_rate_2d,hkbo,heo,heso_cup,zo_cup, &
884 xland1,kstabi,k22,kbcon,its,ite,itf,kts,kte,ktf,zuo,kpbl,ktopdby,csum,pmin_lev)
886 call rates_up_pdf(rand_vmas,ipr,
'deep',ktop,ierr,po_cup,entr_rate_2d,hkbo,heo,heso_cup,zo_cup, &
887 xland1,kstabi,k22,kbcon,its,ite,itf,kts,kte,ktf,zuo,kbcon,ktopdby,csum,pmin_lev)
923 ,ierr,ktop,zo_cup,zuo,cd,entr_rate_2d &
924 ,up_massentro, up_massdetro ,up_massentr, up_massdetr &
925 ,3,kbcon,k22,up_massentru,up_massdetru,lambau)
928 ,ierr,ktop,zo_cup,zuo,cd,entr_rate_2d &
929 ,up_massentro, up_massdetro ,up_massentr, up_massdetr &
930 ,1,kbcon,k22,up_massentru,up_massdetru,lambau)
951 do k=1,start_level(i)
955 do k=1,start_level(i)-1
957 hco(i,k)=heo_cup(i,k)
974 if(ierr(i) /= 0) cycle
977 do k=start_level(i) +1,ktop(i)
979 denom=zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1)
980 if(denom.lt.1.e-8)
then
984 hco(i,k)=(hco(i,k-1)*zuo(i,k-1)-.5*up_massdetro(i,k-1)*hco(i,k-1)+ &
985 up_massentro(i,k-1)*heo(i,k-1)) / &
986 (zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
987 dbyo(i,k)=hco(i,k)-heso_cup(i,k)
991 do k=ktop(i)-1,kbcon(i),-1
992 if(dbyo(i,k).gt.0.)
then
1003 if(ierr(i).eq.0)
then
1004 zktop=(zo_cup(i,ktop(i))-z1(i))*.6
1005 if(imid.eq.1)zktop=(zo_cup(i,ktop(i))-z1(i))*.4
1006 zktop=min(zktop+z1(i),zcutdown+z1(i))
1009 if(zo_cup(i,k).gt.zktop)
then
1011 kzdown(i)=min(kzdown(i),kstabi(i)-1)
1022 call cup_minimi(heso_cup,k22,kzdown,jmin,ierr, &
1027 if(ierr(i).eq.0)
then
1038 do while ( keep_going )
1039 keep_going = .false.
1040 if ( jmini - 1 .lt. kdet(i) ) kdet(i) = jmini-1
1041 if ( jmini .ge. ktop(i)-1 ) jmini = ktop(i) - 2
1043 hcdo(i,ki)=heso_cup(i,ki)
1044 dz=zo_cup(i,ki+1)-zo_cup(i,ki)
1048 hcdo(i,k)=heso_cup(i,jmini)
1049 dz=zo_cup(i,k+1)-zo_cup(i,k)
1050 dh=dh+dz*(hcdo(i,k)-heso_cup(i,k))
1053 if ( jmini .gt. 5 )
then
1058 ierrc(i) =
"could not find jmini9"
1066 if ( jmini .le. 5 )
then
1069 ierrc(i) =
"could not find jmini4"
1075 if(ierr(i) /= 0) cycle
1078 hco(i,k)=heso_cup(i,k)
1088 p_cup,kbcon,ktop,dbyo,clw_all,xland1, &
1089 qo,gammao_cup,zuo,qeso_cup,k22,qo_cup,c0,c0t3d, &
1090 zqexec,ccn,ccnclean,rho,c1d,tn_cup,autoconv,up_massentr,up_massdetr,psum,psumh, &
1095 p_cup,kbcon,ktop,dbyo,clw_all,xland1, &
1096 qo,gammao_cup,zuo,qeso_cup,k22,qo_cup,c0,c0t3d, &
1097 zqexec,ccn,ccnclean,rho,c1d,tn_cup,autoconv,up_massentr,up_massdetr,psum,psumh, &
1108 if(ierr(i) /= 0) cycle
1111 do k=start_level(i) +1,ktop(i)
1113 denom=zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1)
1114 if(denom.lt.1.e-8)
then
1119 hc(i,k)=(hc(i,k-1)*zu(i,k-1)-.5*up_massdetr(i,k-1)*hc(i,k-1)+ &
1120 up_massentr(i,k-1)*he(i,k-1)) / &
1121 (zu(i,k-1)-.5*up_massdetr(i,k-1)+up_massentr(i,k-1))
1122 uc(i,k)=(uc(i,k-1)*zu(i,k-1)-.5*up_massdetru(i,k-1)*uc(i,k-1)+ &
1123 up_massentru(i,k-1)*us(i,k-1) &
1124 -pgcon*.5*(zu(i,k)+zu(i,k-1))*(u_cup(i,k)-u_cup(i,k-1))) / &
1125 (zu(i,k-1)-.5*up_massdetru(i,k-1)+up_massentru(i,k-1))
1126 vc(i,k)=(vc(i,k-1)*zu(i,k-1)-.5*up_massdetru(i,k-1)*vc(i,k-1)+ &
1127 up_massentru(i,k-1)*vs(i,k-1) &
1128 -pgcon*.5*(zu(i,k)+zu(i,k-1))*(v_cup(i,k)-v_cup(i,k-1))) / &
1129 (zu(i,k-1)-.5*up_massdetru(i,k-1)+up_massentru(i,k-1))
1130 dby(i,k)=hc(i,k)-hes_cup(i,k)
1131 hco(i,k)=(hco(i,k-1)*zuo(i,k-1)-.5*up_massdetro(i,k-1)*hco(i,k-1)+ &
1132 up_massentro(i,k-1)*heo(i,k-1)) / &
1133 (zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
1138 hc(i,k)= hc(i,k)+(1.-p_liq_ice(i,k))*qrco(i,k)*xlf
1139 hco(i,k)= hco(i,k)+(1.-p_liq_ice(i,k))*qrco(i,k)*xlf
1141 dby(i,k)=hc(i,k)-hes_cup(i,k)
1143 dbyo(i,k)=hco(i,k)-heso_cup(i,k)
1144 dz=zo_cup(i,k+1)-zo_cup(i,k)
1145 dbyt(i,k)=dbyt(i,k-1)+dbyo(i,k)*dz
1149 kk=maxloc(dbyt(i,:),1)
1150 ki=maxloc(zuo(i,:),1)
1153 do k=ktop(i)-1,kbcon(i),-1
1154 if(dbyo(i,k).gt.0.)
then
1165 if(ierr(i) /= 0) cycle
1167 hc(i,k)=hes_cup(i,k)
1170 hco(i,k)=heso_cup(i,k)
1176 entr_rate_2d(i,k)=0.
1179 up_massentro(i,k)=0.
1180 up_massdetro(i,k)=0.
1186 if(ktop(i).lt.kbcon(i)+2)
then
1189 ierrc(i)=
'ktop too small deep'
1201 if(ierr(i).eq.0)
then
1202 if ( jmin(i) - 1 .lt. kdet(i) ) kdet(i) = jmin(i)-1
1203 if(-zo_cup(i,kbcon(i))+zo_cup(i,ktop(i)).lt.depth_min)
then
1206 ierrc(i)=
"cloud depth very shallow"
1222 dd_massentro(i,k)=0.
1223 dd_massdetro(i,k)=0.
1224 dd_massentru(i,k)=0.
1225 dd_massdetru(i,k)=0.
1226 hcdo(i,k)=heso_cup(i,k)
1230 mentrd_rate_2d(i,k)=entr_rate(i)
1238 beta=max(.025,.055-float(csum(i))*.0015)
1239 if(imid.eq.1)beta=.025
1241 cdd(i,1:jmin(i))=.1*entr_rate(i)
1243 dd_massdetro(i,:)=0.
1244 dd_massentro(i,:)=0.
1245 call get_zu_zd_pdf_fim(0,po_cup(i,:),rand_vmas(i),0.0_kind_phys,ipr,xland1(i),zuh2,4, &
1246 ierr(i),kdet(i),jmin(i)+1,zdo(i,:),kts,kte,ktf,beta,kpbl(i),csum(i),pmin_lev(i))
1247 if(zdo(i,jmin(i)) .lt.1.e-8)
then
1250 cdd(i,jmin(i):ktf)=0.
1251 zdo(i,jmin(i)+1:ktf)=0.
1252 if(zdo(i,jmin(i)) .lt.1.e-8)
then
1258 itemp = maxloc(zdo(i,:),1)
1259 do ki=jmin(i) , itemp,-1
1261 dzo=zo_cup(i,ki+1)-zo_cup(i,ki)
1262 dd_massdetro(i,ki)=cdd(i,ki)*dzo*zdo(i,ki+1)
1263 dd_massentro(i,ki)=zdo(i,ki)-zdo(i,ki+1)+dd_massdetro(i,ki)
1264 if(dd_massentro(i,ki).lt.0.)
then
1265 dd_massentro(i,ki)=0.
1266 dd_massdetro(i,ki)=zdo(i,ki+1)-zdo(i,ki)
1267 if(zdo(i,ki+1).gt.0.)cdd(i,ki)=dd_massdetro(i,ki)/(dzo*zdo(i,ki+1))
1269 if(zdo(i,ki+1).gt.0.)mentrd_rate_2d(i,ki)=dd_massentro(i,ki)/(dzo*zdo(i,ki+1))
1271 mentrd_rate_2d(i,1)=0.
1274 dzo=zo_cup(i,ki+1)-zo_cup(i,ki)
1275 dd_massentro(i,ki)=mentrd_rate_2d(i,ki)*dzo*zdo(i,ki+1)
1276 dd_massdetro(i,ki) = zdo(i,ki+1)+dd_massentro(i,ki)-zdo(i,ki)
1277 if(dd_massdetro(i,ki).lt.0.)
then
1278 dd_massdetro(i,ki)=0.
1279 dd_massentro(i,ki)=zdo(i,ki)-zdo(i,ki+1)
1280 if(zdo(i,ki+1).gt.0.)mentrd_rate_2d(i,ki)=dd_massentro(i,ki)/(dzo*zdo(i,ki+1))
1282 if(zdo(i,ki+1).gt.0.)cdd(i,ki)= dd_massdetro(i,ki)/(dzo*zdo(i,ki+1))
1287 dd_massentru(i,k-1)=dd_massentro(i,k-1)+lambau(i)*dd_massdetro(i,k-1)
1288 dd_massdetru(i,k-1)=dd_massdetro(i,k-1)+lambau(i)*dd_massdetro(i,k-1)
1290 dbydo(i,jmin(i))=hcdo(i,jmin(i))-heso_cup(i,jmin(i))
1291 bud(i)=dbydo(i,jmin(i))*(zo_cup(i,jmin(i)+1)-zo_cup(i,jmin(i)))
1292 ucd(i,jmin(i)+1)=.5*(uc(i,jmin(i)+1)+u_cup(i,jmin(i)+1))
1295 dzo=zo_cup(i,ki+1)-zo_cup(i,ki)
1296 h_entr=.5*(heo(i,ki)+.5*(hco(i,ki)+hco(i,ki+1)))
1297 ucd(i,ki)=(ucd(i,ki+1)*zdo(i,ki+1) &
1298 -.5*dd_massdetru(i,ki)*ucd(i,ki+1)+ &
1299 dd_massentru(i,ki)*us(i,ki) &
1300 -pgcon*zdo(i,ki+1)*(us(i,ki+1)-us(i,ki))) / &
1301 (zdo(i,ki+1)-.5*dd_massdetru(i,ki)+dd_massentru(i,ki))
1302 vcd(i,ki)=(vcd(i,ki+1)*zdo(i,ki+1) &
1303 -.5*dd_massdetru(i,ki)*vcd(i,ki+1)+ &
1304 dd_massentru(i,ki)*vs(i,ki) &
1305 -pgcon*zdo(i,ki+1)*(vs(i,ki+1)-vs(i,ki))) / &
1306 (zdo(i,ki+1)-.5*dd_massdetru(i,ki)+dd_massentru(i,ki))
1307 hcdo(i,ki)=(hcdo(i,ki+1)*zdo(i,ki+1) &
1308 -.5*dd_massdetro(i,ki)*hcdo(i,ki+1)+ &
1309 dd_massentro(i,ki)*h_entr) / &
1310 (zdo(i,ki+1)-.5*dd_massdetro(i,ki)+dd_massentro(i,ki))
1311 dbydo(i,ki)=hcdo(i,ki)-heso_cup(i,ki)
1312 bud(i)=bud(i)+dbydo(i,ki)*dzo
1318 ierrc(i)=
'downdraft is not negatively buoyant '
1328 pwdo,qo_cup,zo_cup,dd_massentro,dd_massdetro,jmin,ierr,gammao_cup, &
1329 pwevo,bu,qrcdo,po_cup,qo,heo,1, &
1337 dp=100.*(po_cup(i,1)-po_cup(i,2))
1338 cupclw(i,k)=qrco(i,k)
1339 cnvwt(i,k)=zuo(i,k)*cupclw(i,k)*g/dp
1346 call cup_up_aa0(aa0,z,zu,dby,gamma_cup,t_cup, &
1350 call cup_up_aa0(aa1,zo,zuo,dbyo,gammao_cup,tn_cup, &
1358 if(aa1(i).eq.0.)
then
1361 ierrc(i)=
"cloud work function zero"
1387 if(ierr(i).eq.0)
then
1390 if(imid.eq.1)wmean(i) = 3.0
1392 tau_ecmwf(i)=( zo_cup(i,ktop(i))- zo_cup(i,kbcon(i)) ) / wmean(i)
1393 tau_ecmwf(i)=max(tau_ecmwf(i),720.)
1394 tau_ecmwf(i)= tau_ecmwf(i) * (1.0061 + 1.23e-2 * (dx(i)/1000.))
1401 if(dicycle == 1)
then
1405 if(ierr(i).eq.0)
then
1406 if(xland1(i) == 0 )
then
1408 umean= 2.0+sqrt(0.5*(us(i,1)**2+vs(i,1)**2+us(i,kbcon(i))**2+vs(i,kbcon(i))**2))
1409 tau_bl(i) = (zo_cup(i,kbcon(i))- z1(i)) /umean
1412 tau_bl(i) =( zo_cup(i,ktopdby(i))- zo_cup(i,kbcon(i)) ) / wmean(i)
1421 tn_bl(i,:)=0.;qo_bl(i,:)=0.
1422 if ( ierr(i) == 0 )
then
1424 tn_bl(i,1:kbcon(i)) = tn(i,1:kbcon(i))
1425 qo_bl(i,1:kbcon(i)) = qo(i,1:kbcon(i))
1427 tn_bl(i,kbcon(i)+1:ktf) = t(i,kbcon(i)+1:ktf)
1428 qo_bl(i,kbcon(i)+1:ktf) = q(i,kbcon(i)+1:ktf)
1433 call cup_env(zo,qeso_bl,heo_bl,heso_bl,tn_bl,qo_bl,po,z1, &
1434 psur,ierr,tcrit,-1, &
1435 itf,ktf, its,ite, kts,kte)
1437 call cup_env_clev(tn_bl,qeso_bl,qo_bl,heo_bl,heso_bl,zo,po,qeso_cup_bl,qo_cup_bl, &
1438 heo_cup_bl,heso_cup_bl,zo_cup,po_cup,gammao_cup_bl,tn_cup_bl,psur, &
1440 itf,ktf,its,ite, kts,kte)
1442 if(iversion == 1)
then
1449 zo_cup,zuo,dbyo_bl,gammao_cup_bl,tn_cup_bl, &
1451 itf,ktf,its,ite, kts,kte)
1455 if(ierr(i).eq.0)
then
1463 aa1_bl(i) = ( aa1_bl(i)/t_star)* tau_bl(i)
1475 if(ierr(i).eq.0)
then
1476 hkbo_bl(i)=heo_cup_bl(i,k22(i))
1486 if(ierr(i).eq.0)
then
1488 hco_bl(i,k)=hkbo_bl(i)
1491 hco_bl(i,k)=hkbo_bl(i)
1492 dbyo_bl(i,k)=hkbo_bl(i) - heso_cup_bl(i,k)
1498 if(ierr(i).eq.0)
then
1499 do k=kbcon(i)+1,ktop(i)
1500 hco_bl(i,k)=(hco_bl(i,k-1)*zuo(i,k-1)-.5*up_massdetro(i,k-1)*hco_bl(i,k-1)+ &
1501 up_massentro(i,k-1)*heo_bl(i,k-1)) / &
1502 (zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
1503 dbyo_bl(i,k)=hco_bl(i,k)-heso_cup_bl(i,k)
1506 hco_bl(i,k)=heso_cup_bl(i,k)
1513 call cup_up_aa0(aa1_bl,zo,zuo,dbyo_bl,gammao_cup_bl,tn_cup_bl, &
1515 itf,ktf,its,ite, kts,kte)
1519 if(ierr(i).eq.0)
then
1521 aa1_bl(i) = aa1_bl(i) - aa0(i)
1527 aa1_bl(i) = aa1_bl(i)* tau_bl(i)/ dtime
1545 call cup_dd_edt(ierr,us,vs,zo,ktop,kbcon,edt,po,pwavo, &
1546 pwo,ccn,ccnclean,pwevo,edtmax,edtmin,edtc,psum,psumh, &
1547 rho,aeroevap,pefc,xland1,itf,ktf, &
1556 ,pwo,edto,pwdo,melting &
1557 ,itf,ktf,its,ite, kts,kte, cumulus )
1561 dellat_ens(i,k,1)=0.
1562 dellaq_ens(i,k,1)=0.
1563 dellaqc_ens(i,k,1)=0.
1625 dp=100.*(po_cup(i,1)-po_cup(i,2))
1626 dellu(i,1)=pgcd*(edto(i)*zdo(i,2)*ucd(i,2) &
1627 -edto(i)*zdo(i,2)*u_cup(i,2))*g/dp &
1628 -zuo(i,2)*(uc(i,2)-u_cup(i,2)) *g/dp
1629 dellv(i,1)=pgcd*(edto(i)*zdo(i,2)*vcd(i,2) &
1630 -edto(i)*zdo(i,2)*v_cup(i,2))*g/dp &
1631 -zuo(i,2)*(vc(i,2)-v_cup(i,2)) *g/dp
1637 if(k == k22(i)-1) entupk=zuo(i,k+1)
1641 detdo=edto(i)*dd_massdetro(i,k)
1642 entdo=edto(i)*dd_massentro(i,k)
1644 entup=up_massentro(i,k)
1645 detup=up_massdetro(i,k)
1647 subin=-zdo(i,k+1)*edto(i)
1648 subdown=-zdo(i,k)*edto(i)
1650 if(k.eq.ktop(i))
then
1651 detupk=zuo(i,ktop(i))
1659 totmas=subin-subdown+detup-entup-entdo+ &
1660 detdo-entupk-entdoj+detupk+zuo(i,k+1)-zuo(i,k)
1661 if(abs(totmas).gt.1.e-6)
then
1663 write(0,123)
'totmas=',k22(i),kbcon(i),k,entup,detup,edto(i),zdo(i,k+1),dd_massdetro(i,k),dd_massentro(i,k)
1664123
format(a7,1x,3i3,2e12.4,1(1x,f5.2),3e12.4)
1667 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
1669 if(k.ge.ktop(i))pgc=0.
1671 dellu(i,k) =-(zuo(i,k+1)*(uc(i,k+1)-u_cup(i,k+1) ) - &
1672 zuo(i,k )*(uc(i,k )-u_cup(i,k ) ) )*g/dp &
1673 +(zdo(i,k+1)*(ucd(i,k+1)-u_cup(i,k+1) ) - &
1674 zdo(i,k )*(ucd(i,k )-u_cup(i,k ) ) )*g/dp*edto(i)*pgcd
1675 dellv(i,k) =-(zuo(i,k+1)*(vc(i,k+1)-v_cup(i,k+1) ) - &
1676 zuo(i,k )*(vc(i,k )-v_cup(i,k ) ) )*g/dp &
1677 +(zdo(i,k+1)*(vcd(i,k+1)-v_cup(i,k+1) ) - &
1678 zdo(i,k )*(vcd(i,k )-v_cup(i,k ) ) )*g/dp*edto(i)*pgcd
1688 if(ierr(i).eq.0)
then
1690 dp=100.*(po_cup(i,1)-po_cup(i,2))
1692 dellah(i,1)=(edto(i)*zdo(i,2)*hcdo(i,2) &
1693 -edto(i)*zdo(i,2)*heo_cup(i,2))*g/dp &
1694 -zuo(i,2)*(hco(i,2)-heo_cup(i,2))*g/dp
1696 dellaq(i,1)=(edto(i)*zdo(i,2)*qcdo(i,2) &
1697 -edto(i)*zdo(i,2)*qo_cup(i,2))*g/dp &
1698 -zuo(i,2)*(qco(i,2)-qo_cup(i,2))*g/dp
1700 g_rain= 0.5*(pwo(i,1)+pwo(i,2))*g/dp
1701 e_dn = -0.5*(pwdo(i,1)+pwdo(i,2))*g/dp*edto(i)
1702 dellaq(i,1) = dellaq(i,1)+ e_dn-g_rain
1712 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
1715 dellah(i,k) =-(zuo(i,k+1)*(hco(i,k+1)-heo_cup(i,k+1) ) - &
1716 zuo(i,k )*(hco(i,k )-heo_cup(i,k ) ) )*g/dp &
1717 +(zdo(i,k+1)*(hcdo(i,k+1)-heo_cup(i,k+1) ) - &
1718 zdo(i,k )*(hcdo(i,k )-heo_cup(i,k ) ) )*g/dp*edto(i)
1722 dellah(i,k) = dellah(i,k) + xlf*((1.-p_liq_ice(i,k))*0.5*(qrco(i,k+1)+qrco(i,k)) &
1723 - melting(i,k))*g/dp
1732 detup=up_massdetro(i,k)
1733 dz=zo_cup(i,k)-zo_cup(i,k-1)
1734 if(k.lt.ktop(i))
then
1735 dellaqc(i,k) = zuo(i,k)*c1d(i,k)*qrco(i,k)*dz/dp*g
1737 dellaqc(i,k)= detup*0.5*(qrco(i,k+1)+qrco(i,k)) *g/dp
1740 g_rain= 0.5*(pwo(i,k)+pwo(i,k+1))*g/dp
1741 e_dn = -0.5*(pwdo(i,k)+pwdo(i,k+1))*g/dp*edto(i)
1745 c_up = dellaqc(i,k)+(zuo(i,k+1)* qrco(i,k+1) - &
1746 zuo(i,k )* qrco(i,k ) )*g/dp + g_rain
1751 dellaq(i,k) =-(zuo(i,k+1)*(qco(i,k+1)-qo_cup(i,k+1) ) - &
1752 zuo(i,k )*(qco(i,k )-qo_cup(i,k ) ) )*g/dp &
1753 +(zdo(i,k+1)*(qcdo(i,k+1)-qo_cup(i,k+1) ) - &
1754 zdo(i,k )*(qcdo(i,k )-qo_cup(i,k ) ) )*g/dp*edto(i) &
1765444
format(1x,i2,1x,7e12.4)
1776 if(ierr(i).eq.0)
then
1778 xhe(i,k)=dellah(i,k)*mbdt+heo(i,k)
1780 xq(i,k)=max(1.e-16,dellaq(i,k)*mbdt+qo(i,k))
1781 dellat(i,k)=(1./cp)*(dellah(i,k)-xlv*dellaq(i,k))
1783 xt(i,k)= dellat(i,k)*mbdt+tn(i,k)
1784 xt(i,k)=max(190.,xt(i,k))
1789 xt(i,k)=tn(i,k)+0.25*(dellat(i,k-1) + 2.*dellat(i,k) + dellat(i,k+1)) * mbdt
1790 xt(i,k)=max(190.,xt(i,k))
1791 xq(i,k)=max(1.e-16, qo(i,k)+0.25*(dellaq(i,k-1) + 2.*dellaq(i,k) + dellaq(i,k+1)) * mbdt)
1792 xhe(i,k)=heo(i,k)+0.25*(dellah(i,k-1) + 2.*dellah(i,k) + dellah(i,k+1)) * mbdt
1797 if(ierr(i).eq.0)
then
1798 xhe(i,ktf)=heo(i,ktf)
1807 call cup_env(xz,xqes,xhe,xhes,xt,xq,po,z1, &
1808 psur,ierr,tcrit,-1, &
1814 call cup_env_clev(xt,xqes,xq,xhe,xhes,xz,po,xqes_cup,xq_cup, &
1815 xhe_cup,xhes_cup,xz_cup,po_cup,gamma_cup,xt_cup,psur, &
1835 if(ierr(i).eq.0)
then
1836 x_add = xlv*zqexec(i)+cp*ztexec(i)
1837 call get_cloud_bc(kte,xhe_cup(i,1:kte),xhkb(i),k22(i),x_add)
1838 do k=1,start_level(i)-1
1839 xhc(i,k)=xhe_cup(i,k)
1850 if(ierr(i).eq.0)
then
1852 do k=start_level(i) +1,ktop(i)
1853 xhc(i,k)=(xhc(i,k-1)*xzu(i,k-1)-.5*up_massdetro(i,k-1)*xhc(i,k-1) + &
1854 up_massentro(i,k-1)*xhe(i,k-1)) / &
1855 (xzu(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
1862 xhc(i,k)= xhc(i,k)+ xlf*(1.-p_liq_ice(i,k))*qrco(i,k)
1865 xdby(i,k)=xhc(i,k)-xhes_cup(i,k)
1869 xhc(i,k)=xhes_cup(i,k)
1878 call cup_up_aa0(xaa0,xz,xzu,xdby,gamma_cup,xt_cup, &
1884 if(ierr(i).eq.0)
then
1885 xaa0_ens(i,1)=xaa0(i)
1892 pr_ens(i,nens3)=pr_ens(i,nens3) &
1893 +pwo(i,k)+edto(i)*pwdo(i,k)
1895 else if(nens3.eq.8)
then
1896 pr_ens(i,nens3)=pr_ens(i,nens3)+ &
1897 pwo(i,k)+edto(i)*pwdo(i,k)
1899 else if(nens3.eq.9)
then
1900 pr_ens(i,nens3)=pr_ens(i,nens3) &
1901 + pwo(i,k)+edto(i)*pwdo(i,k)
1903 pr_ens(i,nens3)=pr_ens(i,nens3)+ &
1904 pwo(i,k) +edto(i)*pwdo(i,k)
1908 if(pr_ens(i,7).lt.1.e-6)
then
1911 ierrc(i)=
"total normalized condensate too small"
1918 if(pr_ens(i,nens3).lt.1.e-5)
then
1945 call cup_kbcon(ierrc,cap_max_increment,iloop,k22x,kbconx,heo_cup, &
1946 heso_cup,hkbo,ierr2,kbmax,po_cup,cap_max, &
1950 z_cup,entr_rate,heo,imid)
1952 call cup_kbcon(ierrc,cap_max_increment,iloop,k22x,kbconx,heo_cup, &
1953 heso_cup,hkbo,ierr3,kbmax,po_cup,cap_max, &
1957 z_cup,entr_rate,heo,imid)
1967 dq=(qo_cup(i,k+1)-qo_cup(i,k))
1969 mconv(i)=mconv(i)+omeg(i,k)*dq/g
1974 ierr,ierr2,ierr3,xf_ens,axx,forcing, &
1975 maxens3,mconv,rand_clos, &
1976 po_cup,ktop,omeg,zdo,zdm,k22,zuo,pr_ens,edto,edtm,kbcon, &
1980 dicycle,tau_ecmwf,aa1_bl,xf_dicycle)
1985 if(ierr(i).eq.0)
then
1986 dellat_ens(i,k,1)=dellat(i,k)
1987 dellaq_ens(i,k,1)=dellaq(i,k)
1988 dellaqc_ens(i,k,1)=dellaqc(i,k)
1989 pwo_ens(i,k,1)=pwo(i,k) +edto(i)*pwdo(i,k)
1991 dellat_ens(i,k,1)=0.
1992 dellaq_ens(i,k,1)=0.
1993 dellaqc_ens(i,k,1)=0.
2004 if(imid.eq.1 .and. ichoice .le.2)
then
2010 if(ierr(i).eq.0)
then
2013 if(k22(i).lt.kpbl(i)+1)
then
2015 blqe=blqe+100.*dhdt(i,k)*(po_cup(i,k)-po_cup(i,k+1))/g
2017 trash=max((hco(i,kbcon(i))-heo_cup(i,kbcon(i))),1.e1)
2018 xff_mid(i,1)=max(0.,blqe/trash)
2019 xff_mid(i,1)=min(0.1,xff_mid(i,1))
2021 xff_mid(i,2)=min(0.1,.03*zws(i))
2022 forcing(i,1)=xff_mid(i,1)
2023 forcing(i,2)=xff_mid(i,2)
2029 dellaqc_ens,outt,outq,outqc,dx, &
2030 zuo,pre,pwo_ens,xmb,ktop, &
2031 edto,pwdo,
'deep',ierr2,ierr3, &
2032 po_cup,pr_ens,maxens3, &
2033 sig,closure_n,xland1,xmbm_in,xmbs_in, &
2034 ichoice,imid,ipr,itf,ktf, &
2036 dicycle,xf_dicycle )
2041 kts,kte,ierr,kbcon,xmb,psur,xland,qo_cup, &
2042 po_cup,qes_cup,pwavo,edto,pwevo,pre,outt,outq)
2049 if (do_smoke_transport .and. nchem > 0)
then
2058 chem(i,k,nv) = max(qamin, chem3d(i,k,nv))
2068 chem_pwd(:,:,:) = 0.
2070 chem_down(:,:,:) = 0.
2073 chem_cup(:,:,:) = 0.
2076 if(ierr(i).eq.0)
then
2078 if(pwavo(i).ne.0.) pwdper(i,k)=-edtc(i,1)*pwdo(i,k)/pwavo(i)
2083 chem_cup(i,k,nv)=.5*(chem(i,k-1,nv)+chem(i,k,nv))
2085 chem_cup(i,kts,nv)=chem(i,kts,nv)
2090 chem_up(i,k,nv)=chem_cup(i,k,nv)
2092 do k=k22(i)+1,ktop(i)
2093 chem_up(i,k,nv)=(chem_up(i,k-1,nv)*zuo(i,k-1) &
2094 -.5*up_massdetr(i,k-1)*chem_up(i,k-1,nv)+ &
2095 up_massentr(i,k-1)*chem(i,k-1,nv)) / &
2096 (zuo(i,k-1)-.5*up_massdetr(i,k-1)+up_massentr(i,k-1))
2097 chem_c(i,k,nv)=fscav(nv)*chem_up(i,k,nv)
2098 dz=zo_cup(i,k)-zo_cup(i,k-1)
2099 trash2=chem_up(i,k,nv)-chem_c(i,k,nv)
2100 trash=chem_c(i,k,nv)/(1.+c0t3d(i,k)*dz)
2101 chem_pw=c0t3d(i,k)*dz*trash*zuo(i,k)
2102 chem_up(i,k,nv)=trash2+trash
2103 chem_pwav(i,nv)=chem_pwav(i,nv)+chem_pw(i,k,nv)
2106 chem_up(i,k,nv)=chem_cup(i,k,nv)
2111 chem_down(i,jmin(i)+1,nv)=chem_cup(i,jmin(i)+1,nv)
2114 dp=100.*(po_cup(i,ki)-po_cup(i,ki+1))
2115 chem_down(i,ki,nv)=(chem_down(i,ki+1,nv)*zdo(i,ki+1) &
2116 -.5_kind_phys*dd_massdetro(i,ki)*chem_down(i,ki+1,nv)+ &
2117 dd_massentro(i,ki)*chem(i,ki,nv)) / &
2118 (zdo(i,ki+1)-.5_kind_phys*dd_massdetro(i,ki)+dd_massentro(i,ki))
2119 chem_down(i,ki,nv)=chem_down(i,ki,nv)+pwdper(i,ki)*chem_pwav(i,nv)
2120 chem_pwd(i,ki,nv)=max(0._kind_phys,pwdper(i,ki)*chem_pwav(i,nv))
2124 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
2125 chem_psum(i,nv)=chem_psum(i,nv)+chem_pw(i,k,nv)*g
2127 chem_psum(i,nv)=chem_psum(i,nv)*xmb(i)*dtime
2137 if(ierr(i).eq.0)
then
2138 dp=100.*(po_cup(i,1)-po_cup(i,2))
2139 dellac(i,1,nv)=dellac(i,1,nv)+(edto(i)*zdo(i,2)*chem_down(i,2,nv))*g/dp*xmb(i)
2142 dellac(i,1,nv)=dellac(i,1,nv)-entupk*chem_cup(i,2,nv)*g/dp*xmb(i)
2144 do k=kts+1,ktop(i)-1
2150 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
2152 entdo=edto(i)*dd_massentro(i,k)*chem(i,k,nv)
2153 detdo=edto(i)*dd_massdetro(i,k)*.5*(chem_down(i,k+1,nv)+chem_down(i,k,nv))
2154 entup=up_massentro(i,k)*chem(i,k,nv)
2155 detup=up_massdetro(i,k)*.5*(chem_up(i,k+1,nv)+chem_up(i,k,nv))
2157 if(k == k22(i)-1)
then
2158 entup=zuo(i,k+1)*chem_cup(i,k+1,nv)
2161 if(k.eq.jmin(i))entdoj=edto(i)*zdo(i,k)*chem_cup(i,k,nv)
2163 dellac(i,k,nv) =dellac(i,k,nv) + (detup+detdo-entdo-entup-entdoj)*g/dp*xmb(i)
2165 dellac(i,ktop(i),nv)=zuo(i,ktop(i))*chem_up(i,ktop(i),nv)*g/dp*xmb(i)
2176 if(ierr(i).eq.0)
then
2182 dp=100._kind_phys*(po_cup(i,k)-po_cup(i,k+1))
2183 dtime_max=min(dtime_max,.5_kind_phys*dp)
2184 massflx(i,k)=-xmb(i)*(zuo(i,k)-edto(i)*zdo(i,k))
2185 trcflx_in(k)=massflx(i,k)*chem_cup(i,k,nv)
2189 call fct1d3(ktop(i),kte,dtime_max,po_cup(i,:),chem(i,:,nv),massflx(i,:), &
2190 trcflx_in,dellac2(i,:,nv),g)
2193 chem(i,k,nv)=chem(i,k,nv) + (dellac(i,k,nv)+dellac2(i,k,nv))*dtime
2194 if(chem(i,k,nv).lt.qamin)
then
2195 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
2196 wetdpc_deep(i,nv)=wetdpc_deep(i,nv)+(qamin-chem(i,k,nv))*dp/g/dtime
2209 if(ierr(i).eq.0)
then
2210 if (k <= ktop(i))
then
2211 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
2212 wetdpc_deep(i,nv)=wetdpc_deep(i,nv) + ((chem3d(i,k,nv)-chem(i,k,nv))*dp/(g*dtime))
2213 chem3d(i,k,nv) = chem(i,k,nv)
2217 wetdpc_deep(i,nv)=max(wetdpc_deep(i,nv),qamin)
2227 if(ierr(i).eq.0 .and.pre(i).gt.0.)
then
2229 pre(i)=max(pre(i),0.)
2231 outu(i,1)=dellu(i,1)*xmb(i)
2232 outv(i,1)=dellv(i,1)*xmb(i)
2234 outu(i,k)=.25*(dellu(i,k-1)+2.*dellu(i,k)+dellu(i,k+1))*xmb(i)
2235 outv(i,k)=.25*(dellv(i,k-1)+2.*dellv(i,k)+dellv(i,k+1))*xmb(i)
2237 elseif(ierr(i).ne.0 .or. pre(i).eq.0.)
then
2251 if(irainevap.eq.1)
then
2260 if(ierr(i).eq.0)
then
2262 do k = ktop(i), 1, -1
2263 rain = pwo(i,k) + edto(i) * pwdo(i,k)
2265 rntot(i) = rntot(i) + rain * xmb(i)* .001 * dtime
2272 if(ierr(i).eq.0)
then
2273 evef = edt(i) * evfact * sig(i)**2
2274 if(xland(i).gt.0.5 .and. xland(i).lt.1.5) evef = edt(i) * evfactl * sig(i)**2
2276 do k = ktop(i), 1, -1
2277 rain = pwo(i,k) + edto(i) * pwdo(i,k)
2278 rn(i) = rn(i) + rain * xmb(i) * .001 * dtime
2281 q1=qo(i,k)+(outq(i,k))*dtime
2282 t1=tn(i,k)+(outt(i,k))*dtime
2283 qcond(i) = evef * (q1 - qeso(i,k)) &
2284 & / (1. + el2orc * qeso(i,k) / t1**2)
2285 dp = -100.*(p_cup(i,k+1)-p_cup(i,k))
2286 if(rn(i).gt.0. .and. qcond(i).lt.0.)
then
2287 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dtime*rn(i))))
2288 qevap(i) = min(qevap(i), rn(i)*1000.*g/dp)
2289 delq2(i) = delqev(i) + .001 * qevap(i) * dp / g
2291 if(rn(i).gt.0..and.qcond(i).lt.0..and. &
2292 & delq2(i).gt.rntot(i))
then
2293 qevap(i) = 1000.* g * (rntot(i) - delqev(i)) / dp
2296 if(rn(i).gt.0..and.qevap(i).gt.0.)
then
2297 outq(i,k) = outq(i,k) + qevap(i)/dtime
2298 outt(i,k) = outt(i,k) - elocp * qevap(i)/dtime
2299 rn(i) = max(0.,rn(i) - .001 * qevap(i) * dp / g)
2300 pre(i) = pre(i) - qevap(i) * dp /g/dtime
2301 pre(i)=max(pre(i),0.)
2302 delqev(i) = delqev(i) + .001*dp*qevap(i)/g
2315 if(ierr(i).eq.0)
then
2316 if(aeroevap.gt.1)
then
2318 ccnloss(i)=ccn(i)*pefc(i)*xmb(i)
2319 ccn(i) = ccn(i) - ccnloss(i)*scav_factor
2330 if(ierr(i).eq.0)
then
2334 dp=(po_cup(i,k)-po_cup(i,k+1))*100.
2336 dts= dts -(outu(i,k)*us(i,k)+outv(i,k)*vs(i,k))*dp/g
2338 fpi = fpi +sqrt(outu(i,k)*outu(i,k) + outv(i,k)*outv(i,k))*dp
2342 fp= sqrt((outu(i,k)*outu(i,k)+outv(i,k)*outv(i,k)))/fpi
2343 outt(i,k)=outt(i,k)+fp*dts*g/cp