77 & ntiw,ntke,grav,rd,cp,rv,hvap,hfus,fv,eps,epsm1, &
78 & dv,du,tdt,rtg,u1,v1,t1,q1,usfco,vsfco,icplocn2atm, &
79 & swh,hlw,xmu,garea,zvfun,sigmaf, &
80 & psk,rbsoil,zorl,u10m,v10m,fm,fh, &
81 & tsea,heat,evap,stress,spd1,kpbl, &
82 & prsi,del,prsl,prslk,phii,phil,delt, &
83 & dspheat,dusfc,dvsfc,dtsfc,dqsfc,hpbl,dkt,dku, &
84 & kinver,xkzm_m,xkzm_h,xkzm_s,dspfac,bl_upfr,bl_dnfr, &
85 & rlmx,elmx,sfc_rlm,tc_pbl, &
86 & ntqv,dtend,dtidx,index_of_temperature,index_of_x_wind, &
87 & index_of_y_wind,index_of_process_pbl,gen_tend,ldiag3d, &
90 use machine ,
only : kind_phys
91 use funcphys ,
only : fpvs
96 integer,
intent(in) :: im, km, ntrac, ntcw, ntrw, ntiw, &
98 integer,
intent(in) :: sfc_rlm
99 integer,
intent(in) :: tc_pbl
100 integer,
intent(in) :: kinver(:)
101 integer,
intent(out) :: kpbl(:)
102 logical,
intent(in) :: gen_tend,ldiag3d
104 real(kind=kind_phys),
intent(in) :: grav,rd,cp,rv,hvap,hfus,fv, &
106 real(kind=kind_phys),
intent(in) :: delt, xkzm_m, xkzm_h, xkzm_s
107 real(kind=kind_phys),
intent(in) :: dspfac, bl_upfr, bl_dnfr
108 real(kind=kind_phys),
intent(in) :: rlmx, elmx
109 real(kind=kind_phys),
intent(inout) :: dv(:,:), du(:,:), &
110 & tdt(:,:), rtg(:,:,:)
111 real(kind=kind_phys),
intent(in) :: &
112 & u1(:,:), v1(:,:), &
113 & usfco(:), vsfco(:), &
114 & t1(:,:), q1(:,:,:), &
115 & swh(:,:), hlw(:,:), &
116 & xmu(:), garea(:), &
117 & zvfun(:), sigmaf(:), &
118 & psk(:), rbsoil(:), &
119 & zorl(:), tsea(:), &
120 & u10m(:), v10m(:), &
122 & evap(:), heat(:), &
123 & stress(:), spd1(:), &
124 & prsi(:,:), del(:,:), &
125 & prsl(:,:), prslk(:,:), &
126 & phii(:,:), phil(:,:)
127 real(kind=kind_phys),
intent(inout),
dimension(:,:,:),
optional ::&
129 integer,
intent(in) :: dtidx(:,:), index_of_temperature, &
130 & index_of_x_wind, index_of_y_wind, index_of_process_pbl
131 integer,
intent(in) :: icplocn2atm
132 real(kind=kind_phys),
intent(out) :: &
133 & dusfc(:), dvsfc(:), &
134 & dtsfc(:), dqsfc(:), &
136 real(kind=kind_phys),
intent(out) :: &
139 logical,
intent(in) :: dspheat
140 character(len=*),
intent(out) :: errmsg
141 integer,
intent(out) :: errflg
148 real(kind=kind_phys) spd1_m
150 integer i,is,k,n,ndt,km1,kmpbl,kmscu,ntrac1,idtend
152 integer lcld(im),kcld(im),krad(im),mrad(im)
153 integer kx1(im), kb1(im), kpblx(im)
155 real(kind=kind_phys) tke(im,km), tkeh(im,km-1), e2(im,0:km)
157 real(kind=kind_phys) theta(im,km),thvx(im,km), thlvx(im,km),
158 & qlx(im,km), thetae(im,km),thlx(im,km),
159 & slx(im,km), svx(im,km), qtx(im,km),
160 & tvx(im,km), pix(im,km), radx(im,km-1),
161 & dkq(im,km-1),cku(im,km-1), ckt(im,km-1)
163 real(kind=kind_phys) plyr(im,km), rhly(im,km), cfly(im,km),
166 real(kind=kind_phys) dtdz1(im), gdx(im),
167 & phih(im), phim(im),
168 & phims(im), prn(im,km-1),
169 & rbdn(im), rbup(im), thermal(im),
170 & ustar(im), wstar(im), hpblx(im),
171 & ust3(im), wst3(im), rho_a(im),
172 & z0(im), crb(im), tkemean(im),
173 & hgamt(im), hgamq(im),
174 & wscale(im),vpert(im),
175 & zol(im), sflux(im),
176 & sumx(im), tx1(im), tx2(im)
178 real(kind=kind_phys) radmin(im)
180 real(kind=kind_phys) zi(im,km+1), zl(im,km), zm(im,km),
181 & xkzo(im,km-1),xkzmo(im,km-1),
182 & xkzm_hx(im), xkzm_mx(im), tkmnz(im,km-1),
183 & rdzt(im,km-1),rlmnz(im,km),
184 & al(im,km-1), ad(im,km), au(im,km-1),
185 & f1(im,km), f2(im,km*(ntrac-1))
187 real(kind=kind_phys) elm(im,km), ele(im,km),
188 & ckz(im,km), chz(im,km),
189 & diss(im,km-1),prod(im,km-1),
190 & bf(im,km-1), shr2(im,km-1), wush(im,km),
191 & xlamue(im,km-1), xlamde(im,km-1),
192 & gotvx(im,km), rlam(im,km-1)
196 real(kind=kind_phys) tcko(im,km), qcko(im,km,ntrac),
197 & ucko(im,km), vcko(im,km),
198 & buou(im,km), xmf(im,km)
202 real(kind=kind_phys) tcdo(im,km), qcdo(im,km,ntrac),
203 & ucdo(im,km), vcdo(im,km),
204 & buod(im,km), xmfd(im,km)
208 real(kind=kind_phys) e_half(im,km-1), e_diff(im,0:km-1),
209 & q_half(im,km-1,ntrac-1),
210 & qh(im,km-1,ntrac-1),
211 & q_diff(im,0:km-1,ntrac-1)
212 real(kind=kind_phys) rrkp, phkp
213 real(kind=kind_phys) tsumn(im), tsump(im), rtnp(im)
214 real(kind=kind_phys) sfcpbl(im), vez0fun(im)
216 logical pblflg(im), sfcflg(im), flg(im)
217 logical scuflg(im), pcnvflg(im)
222 real(kind=kind_phys) aphi16, aphi5,
224 & gamcrt, gamcrq, sfcfrac,
226 & dsdz2, dsdzt, dkmax,
228 & dtodsu, g, factor, dz,
229 & gocp, gravi, zol1, zolcru,
231 & prnum, prmax, prmin, prtke,
234 & elmfac, elefac, dspmax,
236 & f0, robn, crbmin, crbmax,
237 & es, qs,
value, onemrh,
238 & cfh, gamma, elocp, el2orc,
239 & epsi, beta, chx, cqx,
240 & rdt, rdz, qmin, qlmin,
241 & rimin, rbcr, rbint, tdzmin,
242 & rlmn, rlmn0, rlmn1, rlmn2,
243 & ttend, utend, vtend, qtend,
244 & zfac, zfmin, vk, spdk2,
245 & tkmin, tkbmx, xkgdx,
247 & zlup, zldn, cs0, csmf,
248 & tem, tem1, tem2, tem3,
249 & ptem, ptem0, ptem1, ptem2
251 real(kind=kind_phys) slfac
253 real(kind=kind_phys) vegflo, vegfup, z0lo, z0up, vc0, zc0
255 real(kind=kind_phys) ck0, ck1, ch0, ch1, ce0, rchck
257 real(kind=kind_phys) qlcr, zstblmax, hcrinv
259 real(kind=kind_phys) h1
261 real(kind=kind_phys) bfac, mffac
264 parameter(wfac=7.0,cfac=4.5)
265 parameter(gamcrt=3.,gamcrq=0.,sfcfrac=0.1)
266 parameter(vk=0.4,rimin=-100.,slfac=0.1)
267 parameter(rbcr=0.25,zolcru=-0.02,tdzmin=1.e-3)
268 parameter(rlmn=30.,rlmn0=5.,rlmn1=5.,rlmn2=10.)
269 parameter(prmin=0.25,prmax=4.0)
270 parameter(pr0=1.0,prtke=1.0,prscu=0.67)
271 parameter(f0=1.e-4,crbmin=0.15,crbmax=0.35)
272 parameter(tkmin=1.e-9,tkbmx=0.2,dspmax=10.0)
273 parameter(qmin=1.e-8,qlmin=1.e-12,zfmin=1.e-8)
274 parameter(aphi5=5.,aphi16=16.)
275 parameter(elmfac=1.0,elefac=1.0,cql=100.)
276 parameter(dw2min=1.e-4,dkmax=1000.,xkgdx=1000.)
277 parameter(qlcr=3.5e-5,zstblmax=2500.)
278 parameter(xkinv1=0.4,xkinv2=0.3)
279 parameter(h1=0.33333333,hcrinv=250.)
280 parameter(vegflo=0.1,vegfup=1.0,z0lo=0.1,z0up=1.0)
281 parameter(vc0=1.0,zc0=1.0)
282 parameter(ck1=0.15,ch1=0.15)
283 parameter(cs0=0.4,csmf=0.5)
284 parameter(rchck=1.5,ndt=20)
286 if (tc_pbl == 0)
then
290 else if (tc_pbl == 1)
then
303 el2orc = hvap * hvap / (rv * cp)
325 zi(i,k) = phii(i,k) * gravi
326 zl(i,k) = phil(i,k) * gravi
338 zi(i,km+1) = phii(i,km+1) * gravi
347 gdx(i) = sqrt(garea(i))
353 tke(i,k) = max(q1(i,k,ntke), tkmin)
358 tkeh(i,k) = 0.5 * (tke(i,k) + tke(i,k+1))
364 rdzt(i,k) = 1.0 / (zl(i,k+1) - zl(i,k))
382 tx1(i) = 1.0 / prsi(i,1)
384 if(gdx(i) >= xkgdx)
then
389 xkzm_hx(i) = xkzm_h * tem
390 xkzm_mx(i) = xkzm_m * tem
397 if (k < kinver(i))
then
399 ptem = prsi(i,k+1) * tx1(i)
401 tem2 = tem1 * tem1 * 2.5
402 tem2 = min(1.0, exp(-tem2))
403 rlmnz(i,k)= rlmn * tem2
404 rlmnz(i,k)= max(rlmnz(i,k), rlmn0)
406 tem2 = tem1 * tem1 * 10.0
407 tem2 = min(1.0, exp(-tem2))
408 xkzo(i,k) = xkzm_hx(i) * tem2
411 if (ptem >= xkzm_s)
then
412 xkzmo(i,k) = xkzm_mx(i)
415 if (k == kx1(i) .and. k > 1) tx2(i) = 1.0 / prsi(i,k)
416 tem1 = 1.0 - prsi(i,k+1) * tx2(i)
417 tem1 = tem1 * tem1 * 5.0
418 xkzmo(i,k) = xkzm_mx(i) * min(1.0, exp(-tem1))
426 z0(i) = 0.01 * zorl(i)
427 rho_a(i) = prsl(i,1)/(rd*t1(i,1)*(1.+fv*max(q1(i,1,1),qmin)))
438 if(rbsoil(i) > 0.) sfcflg(i) = .false.
455 tem = (sigmaf(i) - vegflo) / (vegfup - vegflo)
456 tem = min(max(tem, 0.), 1.)
458 ptem = (z0(i) - z0lo) / (z0up - z0lo)
459 ptem = min(max(ptem, 0.), 1.)
460 vez0fun(i) = (1. + vc0 * tem1) * (1. + zc0 * ptem)
467 pix(i,k) = psk(i) / prslk(i,k)
468 theta(i,k) = t1(i,k) * pix(i,k)
470 tem = max(q1(i,k,ntcw),qlmin)
471 tem1 = max(q1(i,k,ntiw),qlmin)
472 qlx(i,k) = tem + tem1
473 ptem = hvap*tem + (hvap+hfus)*tem1
474 slx(i,k) = cp * t1(i,k) + phil(i,k) - ptem
476 qlx(i,k) = max(q1(i,k,ntcw),qlmin)
477 slx(i,k) = cp * t1(i,k) + phil(i,k) - hvap*qlx(i,k)
479 tem2 = 1.+fv*max(q1(i,k,1),qmin)-qlx(i,k)
480 thvx(i,k) = theta(i,k) * tem2
481 tvx(i,k) = t1(i,k) * tem2
482 qtx(i,k) = max(q1(i,k,1),qmin)+qlx(i,k)
483 thlx(i,k) = theta(i,k) - pix(i,k)*elocp*qlx(i,k)
484 thlvx(i,k) = thlx(i,k) * (1. + fv * qtx(i,k))
485 svx(i,k) = cp * tvx(i,k)
486 ptem1 = elocp * pix(i,k) * max(q1(i,k,1),qmin)
487 thetae(i,k)= theta(i,k) + ptem1
489 gotvx(i,k) = g / thvx(i,k)
497 plyr(i,k) = 0.01 * prsl(i,k)
499 es = 0.01 * fpvs(t1(i,k))
500 qs = max(qmin, eps * es / (plyr(i,k) + epsm1*es))
501 rhly(i,k) = max(0.0, min(1.0, max(qmin, q1(i,k,1))/qs))
509 clwt = 1.0e-6 * (plyr(i,k)*0.001)
510 if (qlx(i,k) > clwt)
then
511 onemrh = max(1.e-10, 1.0-rhly(i,k))
512 tem1 = min(max((onemrh*qstl(i,k))**0.49,0.0001),1.0)
514 value = max(min( tem1*qlx(i,k), 50.0), 0.0)
515 tem2 = sqrt(sqrt(rhly(i,k)))
516 cfly(i,k) = min(max(tem2*(1.0-exp(-
value)), 0.0), 1.0)
525 tem = 0.5 * (svx(i,k) + svx(i,k+1))
526 tem1 = 0.5 * (t1(i,k) + t1(i,k+1))
527 tem2 = 0.5 * (qstl(i,k) + qstl(i,k+1))
528 cfh = min(cfly(i,k+1),0.5*(cfly(i,k)+cfly(i,k+1)))
530 gamma = el2orc * tem2 / (tem1**2)
532 beta = (1. + gamma*epsi*(1.+fv)) / (1. + gamma)
533 chx = cfh * alp * beta + (1. - cfh) * alp
534 cqx = cfh * alp * hvap * (beta - epsi)
535 cqx = cqx + (1. - cfh) * fv * g
536 ptem1 = (slx(i,k+1)-slx(i,k))*rdzt(i,k)
537 ptem2 = (qtx(i,k+1)-qtx(i,k))*rdzt(i,k)
538 bf(i,k) = chx * ptem1 + cqx * ptem2
557 tem = zi(i,k+1)-zi(i,k)
558 radx(i,k) = tem*(swh(i,k)*xmu(i)+hlw(i,k))
565 sflux(i) = heat(i) + evap(i)*fv*theta(i,1)
566 if(.not.sfcflg(i) .or. sflux(i) <= 0.) pblflg(i)=.false.
589 thermal(i) = thlvx(i,1)
592 thermal(i) = tsea(i)*(1.+fv*max(q1(i,1,1),qmin))
593 tem = sqrt(u10m(i)**2+v10m(i)**2)
595 robn = tem / (f0 * z0(i))
597 crb(i) = 0.16 * (tem1 ** (-0.18))
598 crb(i) = max(min(crb(i), crbmax), crbmin)
603 dtdz1(i) = dt2 / (zi(i,2)-zi(i,1))
607 ustar(i) = sqrt(stress(i))
617 dw2 = (u1(i,k)-u1(i,k+1))**2
618 & + (v1(i,k)-v1(i,k+1))**2
619 shr2(i,k) = max(dw2,dw2min)*rdz*rdz
639 if (tc_pbl == 0)
then
640 spdk2 = max((u1(i,k)**2+v1(i,k)**2),1.)
643 rbup(i) = (thlvx(i,k)-thermal(i))*
644 & (g*zl(i,k)/thlvx(i,1))/spdk2
645 else if (tc_pbl == 1)
then
646 spdk2 = max((u1(i,k)-u1(i,1))**2+(v1(i,k)-v1(i,1))**2,1.)
648 rbup(i) = (thlvx(i,k)-thermal(i))*
649 & (g*(zl(i,k)-zl(i,1))/thlvx(i,1))/spdk2
652 flg(i) = rbup(i) > crb(i)
660 if(kpblx(i) > 1)
then
662 if(rbdn(i) >= crb(i))
then
664 elseif(rbup(i) <= crb(i))
then
667 rbint = (crb(i)-rbdn(i))/(rbup(i)-rbdn(i))
669 hpblx(i) = zl(i,k-1) + rbint*(zl(i,k)-zl(i,k-1))
670 if(hpblx(i) < zi(i,kpblx(i))) kpblx(i)=kpblx(i)-1
677 if(kpbl(i) <= 1) pblflg(i)=.false.
683 sfcpbl(i) = slfac * hpbl(i)
692 if (flg(i) .and. zl(i,k) <= sfcpbl(i))
then
700 if(pblflg(i)) kb1(i)=min(kb1(i),kpbl(i))
707 if(pblflg(i) .and. kb1(i) > 1)
then
711 thermal(i) = thlvx(i,kb1(i))
713 hpblx(i) = zl(i,kb1(i))
718 if(.not.flg(i) .and. k > kb1(i))
then
720 if (tc_pbl == 0)
then
721 spdk2 = max((u1(i,k)**2+v1(i,k)**2),1.)
724 rbup(i) = (thlvx(i,k)-thermal(i))*
725 & (g*zl(i,k)/thlvx(i,1))/spdk2
726 else if (tc_pbl == 1)
then
727 spdk2 = max((u1(i,k)-u1(i,1))**2+(v1(i,k)-v1(i,1))**2,1.)
729 rbup(i) = (thlvx(i,k)-thermal(i))*
730 & (g*(zl(i,k)-zl(i,1))/thlvx(i,1))/spdk2
733 flg(i) = rbup(i) > crb(i)
738 if(pblflg(i) .and. kb1(i) > 1)
then
740 if(rbdn(i) >= crb(i))
then
742 elseif(rbup(i) <= crb(i))
then
745 rbint = (crb(i)-rbdn(i))/(rbup(i)-rbdn(i))
747 hpblx(i) = zl(i,k-1) + rbint*(zl(i,k)-zl(i,k-1))
748 if(hpblx(i) < zi(i,kpblx(i))) kpblx(i)=kpblx(i)-1
763 dz = zi(i,k+1) - zi(i,k)
764 tkemean(i) = tkemean(i) + tke(i,k) * dz
765 sumx(i) = sumx(i) + dz
770 if(tkemean(i) > 0. .and. sumx(i) > 0.)
then
771 tkemean(i) = tkemean(i) / sumx(i)
778 kps = max(kmpbl, kmscu)
781 dz = zi(i,k+1) - zi(i,k)
782 tem = (0.5*(u1(i,k-1)-u1(i,k+1))/dz)**2
783 tem1 = tem+(0.5*(v1(i,k-1)-v1(i,k+1))/dz)**2
784 wush(i,k) = csmf * sqrt(tem1)
798 zol(i) = max(rbsoil(i)*fm(i)*fm(i)/fh(i),rimin)
800 zol(i) = min(zol(i),-zfmin)
802 zol(i) = max(zol(i),zfmin)
815 zol1 = zol(i)*sfcfrac*hpbl(i)/zl(i,1)
817 tem = 1.0 / (1. - aphi16*zol1)
819 phim(i) = sqrt(phih(i))
820 tem1 = 1.0 / (1. - aphi16*zol(i))
821 phims(i) = sqrt(sqrt(tem1))
823 phim(i) = 1. + aphi5*zol1
825 phims(i) = 1. + aphi5*zol(i)
846 if(zol(i) < zolcru)
then
849 wst3(i) = gotvx(i,1)*sflux(i)*hpbl(i)
850 wstar(i)= wst3(i)**h1
851 ust3(i) = ustar(i)**3.
852 wscale(i)=(ust3(i)+wfac*vk*wst3(i)*sfcfrac)**h1
853 ptem = ustar(i)/aphi5
854 wscale(i) = max(wscale(i),ptem)
863 hgamt(i) = heat(i)/wscale(i)
864 hgamq(i) = evap(i)/wscale(i)
865 vpert(i) = hgamt(i) + hgamq(i)*fv*theta(i,1)
866 vpert(i) = max(vpert(i),0.)
867 tem = min(cfac*vpert(i),gamcrt)
868 thermal(i)= thermal(i) + tem
884 if(.not.flg(i) .and. k > kb1(i))
then
886 if (tc_pbl == 0)
then
887 spdk2 = max((u1(i,k)**2+v1(i,k)**2),1.)
888 rbup(i) = (thlvx(i,k)-thermal(i))*
889 & (g*zl(i,k)/thlvx(i,1))/spdk2
890 else if (tc_pbl == 1)
then
891 spdk2 = max((u1(i,k)-u1(i,1))**2+(v1(i,k)-v1(i,1))**2,1.)
893 rbup(i) = (thlvx(i,k)-thermal(i))*
894 & (g*(zl(i,k)-zl(i,1))/thlvx(i,1))/spdk2
897 flg(i) = rbup(i) > crb(i)
904 if(rbdn(i) >= crb(i))
then
906 elseif(rbup(i) <= crb(i))
then
909 rbint = (crb(i)-rbdn(i))/(rbup(i)-rbdn(i))
911 hpbl(i) = zl(i,k-1) + rbint*(zl(i,k)-zl(i,k-1))
912 if(hpbl(i) < zi(i,kpbl(i)))
then
913 kpbl(i) = kpbl(i) - 1
915 if(kpbl(i) <= 1)
then
933 if(flg(i).and.zl(i,k) >= zstblmax)
then
944 if(flg(i) .and. k <= lcld(i))
then
945 if(qlx(i,k) >= qlcr)
then
953 if(scuflg(i) .and. kcld(i)==km1) scuflg(i)=.false.
965 if(flg(i) .and. k <= kcld(i))
then
966 if(qlx(i,k) >= qlcr)
then
967 if(radx(i,k) < radmin(i))
then
978 if(scuflg(i) .and. krad(i) <= 1) scuflg(i)=.false.
979 if(scuflg(i) .and. radmin(i)>=0.) scuflg(i)=.false.
1005 qcko(i,k,n) = q1(i,k,n)
1008 qcdo(i,k,n) = q1(i,k,n)
1015 call mfpbltq(im,im,km,kmpbl,ntcw,ntrac1,dt2,
1016 & pcnvflg,zl,zm,q1,t1,u1,v1,plyr,pix,thlx,thvx,
1017 & gdx,hpbl,kpbl,vpert,buou,wush,tkemean,vez0fun,xmf,
1018 & tcko,qcko,ucko,vcko,xlamue,bl_upfr)
1021 call mfscuq(im,im,km,kmscu,ntcw,ntrac1,dt2,
1022 & scuflg,zl,zm,q1,t1,u1,v1,plyr,pix,
1023 & thlx,thvx,thlvx,gdx,thetae,
1024 & krad,mrad,radmin,buod,wush,tkemean,vez0fun,xmfd,
1025 & tcdo,qcdo,ucdo,vcdo,xlamde,bl_dnfr)
1027 if (tc_pbl == 1)
then
1030 if(zol(i) > -0.5)
then
1038 tem = sqrt(u10m(i)**2+v10m(i)**2)
1039 mffac = (1. - min(max(tem - 20.0, 0.0), 10.0)/10.)
1041 xmf(i,k) = xmf(i,k)*mffac
1042 xmfd(i,k) = xmfd(i,k)*mffac
1052 if(k < kpbl(i))
then
1053 tem = phih(i)/phim(i)
1054 ptem = sfcfrac*hpbl(i)
1055 tem1 = max(zi(i,k+1)-ptem, 0.)
1056 tem2 = tem1 / (hpbl(i) - ptem)
1059 prn(i,k) = tem + (pr0 - tem) * tem2
1064 prn(i,k) = min(prn(i,k),prmax)
1065 prn(i,k) = max(prn(i,k),prmin)
1067 ckz(i,k) = ck0 + (ck1 - ck0) * tem2
1068 ckz(i,k) = max(min(ckz(i,k), ck0), ck1)
1069 chz(i,k) = ch0 + (ch1 - ch0) * tem2
1070 chz(i,k) = max(min(chz(i,k), ch0), ch1)
1088 if(zi(i,k+1) > hcrinv)
then
1089 tem1 = tvx(i,k+1)-tvx(i,k)
1091 xkzo(i,k) = min(xkzo(i,k), xkinv1)
1092 xkzmo(i,k) = min(xkzmo(i,k), xkinv1)
1093 rlmnz(i,k) = min(rlmnz(i,k), rlmn1)
1096 tem1 = tvx(i,k+1)-tvx(i,k)
1098 ptem = xkzo(i,k) * zvfun(i)
1099 xkzo(i,k) = min(max(ptem, xkinv2), xkzo(i,k))
1100 ptem = xkzmo(i,k) * zvfun(i)
1101 xkzmo(i,k) = min(max(ptem, xkinv2), xkzmo(i,k))
1102 ptem = rlmnz(i,k) * zvfun(i)
1103 rlmnz(i,k) = min(max(ptem, rlmn2), rlmnz(i,k))
1110 rlmnz(i,k) = 0.5 * (rlmnz(i,k-1) + rlmnz(i,k))
1121 e2(i,k) = max(2.*tke(i,k), 0.001)
1124 dz = zl(i,n+1) - zl(i,n)
1125 tem1 = 2.*gotvx(i,n+1)*(thvx(i,k)-thvx(i,n+1))
1126 tem2 = cs0*sqrt(e2(i,n))*sqrt(shr2(i,n))
1127 e2(i,n+1) = e2(i,n) + (tem1 - tem2) * dz
1129 if(e2(i,n+1) < 0.)
then
1130 ptem = e2(i,n+1) / (e2(i,n+1) - e2(i,n))
1131 zlup = zlup - ptem * dz
1132 zlup = max(zlup, 0.)
1143 tem = tsea(i)*(1.+fv*max(q1(i,1,1),qmin))
1144 tem1 = 2.*gotvx(i,n)*(tem-thvx(i,k))
1145 tem2 = ustar(i)*phims(i)/(vk*dz)
1146 tem2 = cs0*sqrt(e2(i,n))*tem2
1147 e2(i,n-1) = e2(i,n) + (tem1 - tem2) * dz
1149 dz = zl(i,n) - zl(i,n-1)
1150 tem1 = 2.*gotvx(i,n-1)*(thvx(i,n-1)-thvx(i,k))
1151 tem2 = cs0*sqrt(e2(i,n))*sqrt(shr2(i,n-1))
1152 e2(i,n-1) = e2(i,n) + (tem1 - tem2) * dz
1155 if(e2(i,n-1) < 0.)
then
1156 ptem = e2(i,n-1) / (e2(i,n-1) - e2(i,n))
1157 zldn = zldn - ptem * dz
1158 zldn = max(zldn, 0.)
1164 tem = 0.5 * (zi(i,k+1)-zi(i,k))
1165 tem1 = min(tem, rlmnz(i,k))
1182 ptem2 = min(zlup,zldn)
1183 rlam(i,k) = elmfac * ptem2
1184 rlam(i,k) = max(rlam(i,k), tem1)
1185 rlam(i,k) = min(rlam(i,k), rlmx)
1187 ptem2 = sqrt(zlup*zldn)
1188 ele(i,k) = elefac * ptem2
1189 ele(i,k) = max(ele(i,k), tem1)
1190 ele(i,k) = min(ele(i,k), elmx)
1199 if (zol(i) < 0.)
then
1200 ptem = 1. - 100. * zol(i)
1203 elseif (zol(i) >= 1.)
then
1206 ptem = 1. + 2.7 * zol(i)
1210 if (tc_pbl == 0)
then
1211 elm(i,k) = zk*rlam(i,k)/(rlam(i,k)+zk)
1213 if ( sfc_rlm == 1 )
then
1214 if ( sfcflg(i) .and.
1215 & zl(i,k) < min(100.0,hpbl(i)*0.05) ) elm(i,k)=zk
1217 else if (tc_pbl == 1)
then
1219 elm(i,k) = sqrt( 1.0/( 1.0/(zk**2)+1.0/(rlam(i,k)**2) ) )
1223 if(k == 1) elm(i,k)=zk
1225 dz = zi(i,k+1) - zi(i,k)
1226 tem = max(gdx(i),dz)
1227 elm(i,k) = min(elm(i,k), tem)
1229 if (tc_pbl == 0)
then
1230 ele(i,k) = min(ele(i,k), tem)
1231 else if (tc_pbl == 1)
then
1238 elm(i,km) = elm(i,km1)
1239 ele(i,km) = ele(i,km1)
1248 tem = 0.5 * (elm(i,k) + elm(i,k+1))
1249 tem = tem * sqrt(tkeh(i,k))
1250 ri = max(bf(i,k)/shr2(i,k),rimin)
1251 if(k < kpbl(i))
then
1253 dku(i,k) = ckz(i,k) * tem
1254 dkt(i,k) = dku(i,k) / prn(i,k)
1257 dku(i,k) = ckz(i,k) * tem
1258 dkt(i,k) = dku(i,k) / prn(i,k)
1260 dkt(i,k) = chz(i,k) * tem
1261 dku(i,k) = dkt(i,k) * prn(i,k)
1266 dku(i,k) = ck1 * tem
1267 dkt(i,k) = rchck * dku(i,k)
1269 dkt(i,k) = ch1 * tem
1270 prnum = 1.0 + 2.1 * ri
1271 prnum = min(prnum,prmax)
1272 dku(i,k) = dkt(i,k) * prnum
1277 if(k >= mrad(i) .and. k < krad(i))
then
1278 tem1 = ckz(i,k) * tem
1279 ptem1 = tem1 / prscu
1280 dku(i,k) = max(dku(i,k), tem1)
1281 dkt(i,k) = max(dkt(i,k), ptem1)
1285 dkq(i,k) = prtke * dkt(i,k)
1287 dkt(i,k) = min(dkt(i,k),dkmax)
1288 dkt(i,k) = max(dkt(i,k),xkzo(i,k))
1289 dkq(i,k) = min(dkq(i,k),dkmax)
1290 dkq(i,k) = max(dkq(i,k),xkzo(i,k))
1291 dku(i,k) = min(dku(i,k),dkmax)
1292 dku(i,k) = max(dku(i,k),xkzmo(i,k))
1303 tem1 = 0.5 * xkzmo(i,1)
1305 tem = 0.5 * (ckz(i,k-1) + ckz(i,k))
1306 tem1 = 0.5 * (xkzmo(i,k-1) + xkzmo(i,k))
1308 ptem = tem1 / (tem * elm(i,k))
1309 tkmnz(i,k) = ptem * ptem
1310 tkmnz(i,k) = min(tkmnz(i,k), tkbmx)
1311 tkmnz(i,k) = max(tkmnz(i,k), tkmin)
1322 tem = -dkt(i,1) * bf(i,1)
1328 if(scuflg(i) .and. mrad(i) == 1)
then
1329 ptem2 = xmfd(i,1) * buod(i,1)
1333 tem = tem + ptem1 + ptem2
1334 buop = 0.5 * (gotvx(i,1) * sflux(i) + tem)
1336 tem1 = dku(i,1) * shr2(i,1)
1338 tem = (u1(i,2)-u1(i,1))*rdzt(i,1)
1345 if(scuflg(i) .and. mrad(i) == 1)
then
1346 ptem = ucdo(i,1)+ucdo(i,2)-u1(i,1)-u1(i,2)
1347 ptem = 0.5 * tem * xmfd(i,1) * ptem
1351 ptem1 = ptem1 + ptem
1353 tem = (v1(i,2)-v1(i,1))*rdzt(i,1)
1360 if(scuflg(i) .and. mrad(i) == 1)
then
1361 ptem = vcdo(i,1)+vcdo(i,2)-v1(i,1)-v1(i,2)
1362 ptem = 0.5 * tem * xmfd(i,1) * ptem
1366 ptem2 = ptem2 + ptem
1368 tem2 = stress(i)*ustar(i)*phims(i)/(vk*zl(i,1))
1369 shrp = 0.5 * (tem1 + ptem1 + ptem2 + tem2)
1371 tem1 = -dkt(i,k-1) * bf(i,k-1)
1372 tem2 = -dkt(i,k) * bf(i,k)
1373 tem = 0.5 * (tem1 + tem2)
1374 if(pcnvflg(i) .and. k <= kpbl(i))
then
1375 ptem = 0.5 * (xmf(i,k-1) + xmf(i,k))
1376 ptem1 = ptem * buou(i,k)
1381 if(k >= mrad(i) .and. k < krad(i))
then
1382 ptem0 = 0.5 * (xmfd(i,k-1) + xmfd(i,k))
1383 ptem2 = ptem0 * buod(i,k)
1390 buop = tem + ptem1 + ptem2
1392 tem1 = dku(i,k-1) * shr2(i,k-1)
1393 tem2 = dku(i,k) * shr2(i,k)
1394 tem = 0.5 * (tem1 + tem2)
1395 tem1 = (u1(i,k+1)-u1(i,k))*rdzt(i,k)
1396 tem2 = (u1(i,k)-u1(i,k-1))*rdzt(i,k-1)
1397 if(pcnvflg(i) .and. k <= kpbl(i))
then
1398 ptem = xmf(i,k) * tem1 + xmf(i,k-1) * tem2
1399 ptem1 = 0.5 * ptem * (u1(i,k)-ucko(i,k))
1404 if(k >= mrad(i) .and. k < krad(i))
then
1405 ptem0 = xmfd(i,k) * tem1 + xmfd(i,k-1) * tem2
1406 ptem2 = 0.5 * ptem0 * (ucdo(i,k)-u1(i,k))
1413 shrp = tem + ptem1 + ptem2
1414 tem1 = (v1(i,k+1)-v1(i,k))*rdzt(i,k)
1415 tem2 = (v1(i,k)-v1(i,k-1))*rdzt(i,k-1)
1416 if(pcnvflg(i) .and. k <= kpbl(i))
then
1417 ptem = xmf(i,k) * tem1 + xmf(i,k-1) * tem2
1418 ptem1 = 0.5 * ptem * (v1(i,k)-vcko(i,k))
1423 if(k >= mrad(i) .and. k < krad(i))
then
1424 ptem0 = xmfd(i,k) * tem1 + xmfd(i,k-1) * tem2
1425 ptem2 = 0.5 * ptem0 * (vcdo(i,k)-v1(i,k))
1432 shrp = shrp + ptem1 + ptem2
1434 prod(i,k) = buop + shrp
1441 dtn = dt2 / float(ndt)
1445 tem = sqrt(tke(i,k))
1446 ptem = ce0 / ele(i,k)
1447 diss(i,k) = ptem * tke(i,k) * tem
1448 tem1 = prod(i,k) + tke(i,k) / dtn
1449 diss(i,k)=max(min(diss(i,k), tem1), 0.)
1450 tke(i,k) = tke(i,k) + dtn * (prod(i,k)-diss(i,k))
1452 tke(i,k) = max(tke(i,k), tkmnz(i,k))
1462 qcko(i,k,ntke) = tke(i,k)
1465 qcdo(i,k,ntke) = tke(i,k)
1471 if (pcnvflg(i) .and. k <= kpbl(i))
then
1472 dz = zl(i,k) - zl(i,k-1)
1473 tem = 0.5 * xlamue(i,k-1) * dz
1475 qcko(i,k,ntke)=((1.-tem)*qcko(i,k-1,ntke)+tem*
1476 & (tke(i,k)+tke(i,k-1)))/factor
1482 if (scuflg(i) .and. k < krad(i))
then
1483 if(k >= mrad(i))
then
1484 dz = zl(i,k+1) - zl(i,k)
1485 tem = 0.5 * xlamde(i,k) * dz
1487 qcdo(i,k,ntke)=((1.-tem)*qcdo(i,k+1,ntke)+tem*
1488 & (tke(i,k)+tke(i,k+1)))/factor
1498 kps = max(kmpbl, kmscu)
1505 qh(i,k,n) = 0.5 * (q1(i,k,n)+q1(i,k+1,n))
1510 q_diff(i,k,n) = q1(i,k,n) - q1(i,k+1,n)
1514 if(q1(i,1,n) >= 0.)
then
1515 q_diff(i,0,n) = max(0.,2.*q1(i,1,n)-q1(i,2,n))-
1518 q_diff(i,0,n) = min(0.,2.*q1(i,1,n)-q1(i,2,n))-
1528 kmx = max(kpbl(i), krad(i))
1529 q_half(i,k,n) = qh(i,k,n)
1530 if((pcnvflg(i) .or. scuflg(i)) .and. k < kmx)
then
1532 if(pcnvflg(i) .and. k < kpbl(i))
then
1536 & (k >= mrad(i) .and. k < krad(i)))
then
1537 tem = tem - xmfd(i,k)
1541 if(abs(q_diff(i,k,n)) > 1.e-22)
1542 & rrkp = q_diff(i,k+1,n) / q_diff(i,k,n)
1543 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1544 q_half(i,k,n) = q1(i,k+1,n) +
1545 & phkp*(qh(i,k,n)-q1(i,k+1,n))
1546 elseif (tem < 0.)
then
1548 if(abs(q_diff(i,k,n)) > 1.e-22)
1549 & rrkp = q_diff(i,k-1,n) / q_diff(i,k,n)
1550 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1551 q_half(i,k,n) = q1(i,k,n) +
1552 & phkp*(qh(i,k,n)-q1(i,k,n))
1564 tkeh(i,k) = 0.5 * (tke(i,k)+tke(i,k+1))
1569 e_diff(i,k) = tke(i,k) - tke(i,k+1)
1573 if(tke(i,1) >= 0.)
then
1574 e_diff(i,0) = max(0.,2.*tke(i,1)-tke(i,2))-
1577 e_diff(i,0) = min(0.,2.*tke(i,1)-tke(i,2))-
1584 kmx = max(kpbl(i), krad(i))
1585 e_half(i,k) = tkeh(i,k)
1586 if((pcnvflg(i) .or. scuflg(i)) .and. (k < kmx))
then
1588 if(pcnvflg(i) .and. k < kpbl(i))
then
1592 & (k >= mrad(i) .and. k < krad(i)))
then
1593 tem = tem - xmfd(i,k)
1597 if(abs(e_diff(i,k)) > 1.e-22)
1598 & rrkp = e_diff(i,k+1) / e_diff(i,k)
1599 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1600 e_half(i,k) = tke(i,k+1) +
1601 & phkp*(tkeh(i,k)-tke(i,k+1))
1602 elseif (tem < 0.)
then
1604 if(abs(e_diff(i,k)) > 1.e-22)
1605 & rrkp = e_diff(i,k-1) / e_diff(i,k)
1606 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1607 e_half(i,k) = tke(i,k) +
1608 & phkp*(tkeh(i,k)-tke(i,k))
1624 dtodsd = dt2/del(i,k)
1625 dtodsu = dt2/del(i,k+1)
1626 dsig = prsl(i,k)-prsl(i,k+1)
1628 tem1 = dsig * dkq(i,k) * rdz
1630 au(i,k) = -dtodsd*dsdz2
1631 al(i,k) = -dtodsu*dsdz2
1632 ad(i,k) = ad(i,k)-au(i,k)
1633 ad(i,k+1)= 1.-al(i,k)
1636 if(pcnvflg(i) .and. k < kpbl(i))
then
1637 ptem = 0.5 * tem2 * xmf(i,k)
1638 ptem1 = dtodsd * ptem
1639 ptem2 = dtodsu * ptem
1640 ptem = qcko(i,k,ntke) + qcko(i,k+1,ntke)
1641 f1(i,k) = f1(i,k) - ptem * ptem1
1642 f1(i,k+1) = tke(i,k+1) + ptem * ptem2
1644 f1(i,k+1) = tke(i,k+1)
1648 if(k >= mrad(i) .and. k < krad(i))
then
1649 ptem = 0.5 * tem2 * xmfd(i,k)
1650 ptem1 = dtodsd * ptem
1651 ptem2 = dtodsu * ptem
1652 ptem = qcdo(i,k,ntke) + qcdo(i,k+1,ntke)
1653 f1(i,k) = f1(i,k) + ptem * ptem1
1654 f1(i,k+1) = f1(i,k+1) - ptem * ptem2
1658 kmx = max(kpbl(i), krad(i))
1659 if((pcnvflg(i) .or. scuflg(i)) .and. (k < kmx))
then
1660 ptem = tem2 * (xmf(i,k) - xmfd(i,k))
1661 ptem1 = dtodsd * ptem
1662 ptem2 = dtodsu * ptem
1663 f1(i,k) = f1(i,k) + e_half(i,k) * ptem1
1664 f1(i,k+1) = f1(i,k+1) - e_half(i,k) * ptem2
1672 call tridit(im,km,1,al,ad,au,f1,au,f1)
1684 if(pcnvflg(i) .and. scuflg(i))
then
1686 kmx = max(kpbl(i), krad(i))
1687 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
1690 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
1694 if((pcnvflg(i) .or. scuflg(i)) .and.
1695 & (k >= kbx .and. k <= kmx))
then
1696 tem = f1(i,k) * del(i,k) * gravi
1697 if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
1698 if(f1(i,k) > 0.) tsump(i) = tsump(i) + tem
1703 if(pcnvflg(i) .or. scuflg(i))
then
1704 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
1705 if(tsump(i) > abs(tsumn(i)))
then
1706 rtnp(i) = tsumn(i) / tsump(i)
1708 rtnp(i) = tsump(i) / tsumn(i)
1715 if(pcnvflg(i) .and. scuflg(i))
then
1717 kmx = max(kpbl(i), krad(i))
1718 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
1721 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
1725 if((pcnvflg(i) .or. scuflg(i)) .and.
1726 & (k >= kbx .and. k <= kmx))
then
1727 if(rtnp(i) < 0.)
then
1728 if(tsump(i) > abs(tsumn(i)))
then
1729 if(f1(i,k) < 0.) f1(i,k) = 0.
1730 if(f1(i,k) > 0.) f1(i,k) = (1.+rtnp(i))*f1(i,k)
1732 if(f1(i,k) < 0.) f1(i,k) = (1.+rtnp(i))*f1(i,k)
1733 if(f1(i,k) > 0.) f1(i,k) = 0.
1751 tem = f1(i,k) * del(i,k) * gravi
1752 if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
1753 if(f1(i,k) > 0.) tsump(i) = tsump(i) + tem
1757 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
1758 if(tsump(i) > abs(tsumn(i)))
then
1759 rtnp(i) = tsumn(i) / tsump(i)
1761 rtnp(i) = tsump(i) / tsumn(i)
1767 if(rtnp(i) < 0.)
then
1768 if(tsump(i) > abs(tsumn(i)))
then
1769 if(f1(i,k) < 0.) f1(i,k) = 0.
1770 if(f1(i,k) > 0.) f1(i,k) = (1.+rtnp(i))*f1(i,k)
1772 if(f1(i,k) < 0.) f1(i,k) = (1.+rtnp(i))*f1(i,k)
1773 if(f1(i,k) > 0.) f1(i,k) = 0.
1784 qtend = (f1(i,k)-q1(i,k,ntke))*rdt
1785 rtg(i,k,ntke) = rtg(i,k,ntke)+qtend
1789 idtend = dtidx(ntke+100,index_of_process_pbl)
1791 dtend(1:im,1:km,idtend) = dtend(1:im,1:km,idtend) + &
1792 & (f1(1:im,1:km)-q1(1:im,1:km,ntke))*rdt
1800 f1(i,1) = t1(i,1) + dtdz1(i) * heat(i)
1801 f2(i,1) = q1(i,1,1) + dtdz1(i) * evap(i)
1803 if(ntrac1 >= 2)
then
1807 f2(i,1+is) = q1(i,1,n)
1814 dtodsd = dt2/del(i,k)
1815 dtodsu = dt2/del(i,k+1)
1816 dsig = prsl(i,k)-prsl(i,k+1)
1818 tem1 = dsig * dkt(i,k) * rdz
1821 au(i,k) = -dtodsd*dsdz2
1822 al(i,k) = -dtodsu*dsdz2
1823 ad(i,k) = ad(i,k)-au(i,k)
1824 ad(i,k+1)= 1.-al(i,k)
1827 if(pcnvflg(i) .and. k < kpbl(i))
then
1828 ptem = 0.5 * tem2 * xmf(i,k)
1829 ptem1 = dtodsd * ptem
1830 ptem2 = dtodsu * ptem
1831 tem = t1(i,k) + t1(i,k+1)
1832 ptem = tcko(i,k) + tcko(i,k+1)
1833 f1(i,k) = f1(i,k)+dtodsd*dsdzt-(ptem-tem)*ptem1
1834 f1(i,k+1) = t1(i,k+1)-dtodsu*dsdzt+(ptem-tem)*ptem2
1835 ptem = qcko(i,k,1) + qcko(i,k+1,1)
1836 f2(i,k) = f2(i,k) - ptem * ptem1
1837 f2(i,k+1) = q1(i,k+1,1) + ptem * ptem2
1839 f1(i,k) = f1(i,k)+dtodsd*dsdzt
1840 f1(i,k+1) = t1(i,k+1)-dtodsu*dsdzt
1841 f2(i,k+1) = q1(i,k+1,1)
1845 if(k >= mrad(i) .and. k < krad(i))
then
1846 ptem = 0.5 * tem2 * xmfd(i,k)
1847 ptem1 = dtodsd * ptem
1848 ptem2 = dtodsu * ptem
1849 ptem = tcdo(i,k) + tcdo(i,k+1)
1850 tem = t1(i,k) + t1(i,k+1)
1851 f1(i,k) = f1(i,k) + (ptem - tem) * ptem1
1852 f1(i,k+1) = f1(i,k+1) - (ptem - tem) * ptem2
1853 ptem = qcdo(i,k,1) + qcdo(i,k+1,1)
1854 f2(i,k) = f2(i,k) + ptem * ptem1
1855 f2(i,k+1) = f2(i,k+1) - ptem * ptem2
1859 kmx = max(kpbl(i), krad(i))
1860 if((pcnvflg(i) .or. scuflg(i)) .and. (k < kmx))
then
1861 ptem = tem2 * (xmf(i,k) - xmfd(i,k))
1862 ptem1 = dtodsd * ptem
1863 ptem2 = dtodsu * ptem
1864 f2(i,k) = f2(i,k) + q_half(i,k,1) * ptem1
1865 f2(i,k+1) = f2(i,k+1) - q_half(i,k,1) * ptem2
1871 if(ntrac1 >= 2)
then
1876 dtodsd = dt2/del(i,k)
1877 dtodsu = dt2/del(i,k+1)
1878 dsig = prsl(i,k)-prsl(i,k+1)
1879 tem2 = dsig * rdzt(i,k)
1881 if(pcnvflg(i) .and. k < kpbl(i))
then
1882 ptem = 0.5 * tem2 * xmf(i,k)
1883 ptem1 = dtodsd * ptem
1884 ptem2 = dtodsu * ptem
1885 ptem = qcko(i,k,n) + qcko(i,k+1,n)
1886 f2(i,k+is) = f2(i,k+is) - ptem * ptem1
1887 f2(i,k+1+is)= q1(i,k+1,n) + ptem * ptem2
1889 f2(i,k+1+is) = q1(i,k+1,n)
1893 if(k >= mrad(i) .and. k < krad(i))
then
1894 ptem = 0.5 * tem2 * xmfd(i,k)
1895 ptem1 = dtodsd * ptem
1896 ptem2 = dtodsu * ptem
1897 ptem = qcdo(i,k,n) + qcdo(i,k+1,n)
1898 f2(i,k+is) = f2(i,k+is) + ptem * ptem1
1899 f2(i,k+1+is)= f2(i,k+1+is) - ptem * ptem2
1903 kmx = max(kpbl(i), krad(i))
1904 if((pcnvflg(i) .or. scuflg(i)) .and. (k < kmx))
then
1905 ptem = tem2 * (xmf(i,k) - xmfd(i,k))
1906 ptem1 = dtodsd * ptem
1907 ptem2 = dtodsu * ptem
1908 f2(i,k+is) = f2(i,k+is) + q_half(i,k,n) * ptem1
1909 f2(i,k+1+is) = f2(i,k+1+is) - q_half(i,k,n) * ptem2
1919 call tridin(im,km,ntrac1,al,ad,au,f1,f2,au,f1,f2)
1931 if(pcnvflg(i) .and. scuflg(i))
then
1933 kmx = max(kpbl(i), krad(i))
1934 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
1937 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
1941 if((pcnvflg(i) .or. scuflg(i)) .and.
1942 & (k >= kbx .and. k <= kmx))
then
1943 tem = f2(i,k) * del(i,k) * gravi
1944 if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + tem
1945 if(f2(i,k) > 0.) tsump(i) = tsump(i) + tem
1950 if(pcnvflg(i) .or. scuflg(i))
then
1951 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
1952 if(tsump(i) > abs(tsumn(i)))
then
1953 rtnp(i) = tsumn(i) / tsump(i)
1955 rtnp(i) = tsump(i) / tsumn(i)
1962 if(pcnvflg(i) .and. scuflg(i))
then
1964 kmx = max(kpbl(i), krad(i))
1965 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
1968 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
1972 if((pcnvflg(i) .or. scuflg(i)) .and.
1973 & (k >= kbx .and. k <= kmx))
then
1974 if(rtnp(i) < 0.)
then
1975 if(tsump(i) > abs(tsumn(i)))
then
1976 if(f2(i,k) < 0.) f2(i,k) = 0.
1977 if(f2(i,k) > 0.) f2(i,k) = (1.+rtnp(i))*f2(i,k)
1979 if(f2(i,k) < 0.) f2(i,k) = (1.+rtnp(i))*f2(i,k)
1980 if(f2(i,k) > 0.) f2(i,k) = 0.
1999 tem = f2(i,k) * del(i,k) * gravi
2000 if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + tem
2001 if(f2(i,k) > 0.) tsump(i) = tsump(i) + tem
2005 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
2006 if(tsump(i) > abs(tsumn(i)))
then
2007 rtnp(i) = tsumn(i) / tsump(i)
2009 rtnp(i) = tsump(i) / tsumn(i)
2015 if(rtnp(i) < 0.)
then
2016 if(tsump(i) > abs(tsumn(i)))
then
2017 if(f2(i,k) < 0.) f2(i,k) = 0.
2018 if(f2(i,k) > 0.) f2(i,k) = (1.+rtnp(i))*f2(i,k)
2020 if(f2(i,k) < 0.) f2(i,k) = (1.+rtnp(i))*f2(i,k)
2021 if(f2(i,k) > 0.) f2(i,k) = 0.
2035 if(ntrac1 >= 2)
then
2039 if(pcnvflg(i) .and. scuflg(i))
then
2041 kmx = max(kpbl(i), krad(i))
2042 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
2045 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
2049 if((pcnvflg(i) .or. scuflg(i)) .and.
2050 & (k >= kbx .and. k <= kmx))
then
2051 if(f2(i,k+is) < 0.)
then
2052 tem = f2(i,k) + f2(i,k+is)
2055 f1(i,k) = f1(i,k) - elocp * f2(i,k+is)
2057 elseif (f2(i,k) > 0.0)
then
2059 f1(i,k) = f1(i,k) + elocp * f2(i,k)
2072 if(ntrac1 >= 2 .and. ntrw > 0)
then
2076 if(pcnvflg(i) .and. scuflg(i))
then
2078 kmx = max(kpbl(i), krad(i))
2079 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
2082 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
2086 if((pcnvflg(i) .or. scuflg(i)) .and.
2087 & (k >= kbx .and. k <= kmx))
then
2088 if(f2(i,k+is) < 0.)
then
2089 tem = f2(i,k) + f2(i,k+is)
2092 f1(i,k) = f1(i,k) - elocp * f2(i,k+is)
2094 elseif (f2(i,k) > 0.0)
then
2096 f1(i,k) = f1(i,k) + elocp * f2(i,k)
2105 if(ntrac1 >= 2)
then
2116 if(pcnvflg(i) .and. scuflg(i))
then
2118 kmx = max(kpbl(i), krad(i))
2119 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
2122 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
2126 if((pcnvflg(i) .or. scuflg(i)) .and.
2127 & (k >= kbx .and. k <= kmx))
then
2128 tem = f2(i,k+is) * del(i,k) * gravi
2129 if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + tem
2130 if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + tem
2135 if(pcnvflg(i) .or. scuflg(i))
then
2136 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
2137 if(tsump(i) > abs(tsumn(i)))
then
2138 rtnp(i) = tsumn(i) / tsump(i)
2140 rtnp(i) = tsump(i) / tsumn(i)
2147 if(pcnvflg(i) .and. scuflg(i))
then
2149 kmx = max(kpbl(i), krad(i))
2150 elseif(pcnvflg(i) .and. .not. scuflg(i))
then
2153 elseif(.not. pcnvflg(i) .and. scuflg(i))
then
2157 if((pcnvflg(i) .or. scuflg(i)) .and.
2158 & (k >= kbx .and. k <= kmx))
then
2159 if(rtnp(i) < 0.)
then
2160 if(tsump(i) > abs(tsumn(i)))
then
2161 if(f2(i,k+is)<0.) f2(i,k+is)=0.
2162 if(f2(i,k+is)>0.) f2(i,k+is)=(1.+rtnp(i))*f2(i,k+is)
2164 if(f2(i,k+is)<0.) f2(i,k+is)=(1.+rtnp(i))*f2(i,k+is)
2165 if(f2(i,k+is)>0.) f2(i,k+is)=0.
2184 tem = f2(i,k+is) * del(i,k) * gravi
2185 if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + tem
2186 if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + tem
2190 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
2191 if(tsump(i) > abs(tsumn(i)))
then
2192 rtnp(i) = tsumn(i) / tsump(i)
2194 rtnp(i) = tsump(i) / tsumn(i)
2200 if(rtnp(i) < 0.)
then
2201 if(tsump(i) > abs(tsumn(i)))
then
2202 if(f2(i,k+is)<0.) f2(i,k+is)=0.
2203 if(f2(i,k+is)>0.) f2(i,k+is)=(1.+rtnp(i))*f2(i,k+is)
2205 if(f2(i,k+is)<0.) f2(i,k+is)=(1.+rtnp(i))*f2(i,k+is)
2206 if(f2(i,k+is)>0.) f2(i,k+is)=0.
2219 ttend = (f1(i,k)-t1(i,k))*rdt
2220 qtend = (f2(i,k)-q1(i,k,1))*rdt
2221 tdt(i,k) = tdt(i,k)+ttend
2222 rtg(i,k,1) = rtg(i,k,1)+qtend
2229 dtsfc(i) = rho_a(i) * cp * heat(i)
2230 dqsfc(i) = rho_a(i) * hvap * evap(i)
2233 if(ldiag3d .and. .not. gen_tend)
then
2234 idtend = dtidx(index_of_temperature,index_of_process_pbl)
2238 ttend = (f1(i,k)-t1(i,k))*rdt
2239 dtend(i,k,idtend) = dtend(i,k,idtend)+ttend*delt
2244 idtend = dtidx(100+ntqv,index_of_process_pbl)
2248 qtend = (f2(i,k)-q1(i,k,1))*rdt
2249 dtend(i,k,idtend) = dtend(i,k,idtend)+qtend*delt
2255 if(ntrac1 >= 2)
then
2260 qtend = (f2(i,k+is)-q1(i,k,n))*rdt
2261 rtg(i,k,n) = rtg(i,k,n)+qtend
2265 if(ldiag3d .and. .not. gen_tend)
then
2269 idtend = dtidx(n+100,index_of_process_pbl)
2274 qtend = (f2(i,k+is)-q1(i,k,n))*rdt
2275 dtend(i,k,idtend) = dtend(i,k,idtend)+qtend*delt
2291 ttend = diss(i,k) / cp
2292 tdt(i,k) = tdt(i,k) + dspfac * ttend
2295 if(ldiag3d .and. .not. gen_tend)
then
2296 idtend = dtidx(index_of_temperature,index_of_process_pbl)
2300 ttend = diss(i,k) / cp
2301 dtend(i,k,idtend) = dtend(i,k,idtend)+dspfac*ttend*delt
2311 ad(i,1) = 1.0 + dtdz1(i) * stress(i) / spd1(i)
2318 dtodsd = dt2/del(i,k)
2319 dtodsu = dt2/del(i,k+1)
2320 dsig = prsl(i,k)-prsl(i,k+1)
2322 tem1 = dsig * dku(i,k) * rdz
2324 au(i,k) = -dtodsd*dsdz2
2325 al(i,k) = -dtodsu*dsdz2
2326 ad(i,k) = ad(i,k)-au(i,k)
2327 ad(i,k+1)= 1.-al(i,k)
2330 if(pcnvflg(i) .and. k < kpbl(i))
then
2331 ptem = 0.5 * tem2 * xmf(i,k)
2332 ptem1 = dtodsd * ptem
2333 ptem2 = dtodsu * ptem
2334 tem = u1(i,k) + u1(i,k+1)
2335 ptem = ucko(i,k) + ucko(i,k+1)
2336 f1(i,k) = f1(i,k) - (ptem - tem) * ptem1
2337 f1(i,k+1) = u1(i,k+1) + (ptem - tem) * ptem2
2338 tem = v1(i,k) + v1(i,k+1)
2339 ptem = vcko(i,k) + vcko(i,k+1)
2340 f2(i,k) = f2(i,k) - (ptem - tem) * ptem1
2341 f2(i,k+1) = v1(i,k+1) + (ptem - tem) * ptem2
2343 f1(i,k+1) = u1(i,k+1)
2344 f2(i,k+1) = v1(i,k+1)
2348 if(k >= mrad(i) .and. k < krad(i))
then
2349 ptem = 0.5 * tem2 * xmfd(i,k)
2350 ptem1 = dtodsd * ptem
2351 ptem2 = dtodsu * ptem
2352 tem = u1(i,k) + u1(i,k+1)
2353 ptem = ucdo(i,k) + ucdo(i,k+1)
2354 f1(i,k) = f1(i,k) + (ptem - tem) *ptem1
2355 f1(i,k+1) = f1(i,k+1) - (ptem - tem) *ptem2
2356 tem = v1(i,k) + v1(i,k+1)
2357 ptem = vcdo(i,k) + vcdo(i,k+1)
2358 f2(i,k) = f2(i,k) + (ptem - tem) * ptem1
2359 f2(i,k+1) = f2(i,k+1) - (ptem - tem) * ptem2
2368 call tridi2(im,km,al,ad,au,f1,f2,au,f1,f2)
2374 utend = (f1(i,k)-u1(i,k))*rdt
2375 vtend = (f2(i,k)-v1(i,k))*rdt
2376 du(i,k) = du(i,k)+utend
2377 dv(i,k) = dv(i,k)+vtend
2383 if(icplocn2atm == 0)
then
2384 dusfc(i) = -1.*rho_a(i)*stress(i)*u1(i,1)/spd1(i)
2385 dvsfc(i) = -1.*rho_a(i)*stress(i)*v1(i,1)/spd1(i)
2386 else if (icplocn2atm ==1)
then
2387 spd1_m=sqrt( (u1(i,1)-usfco(i))**2+(v1(i,1)-vsfco(i))**2 )
2388 dusfc(i) = -1.*rho_a(i)*stress(i)*(u1(i,1)-usfco(i))/spd1_m
2389 dvsfc(i) = -1.*rho_a(i)*stress(i)*(v1(i,1)-vsfco(i))/spd1_m
2393 if(ldiag3d .and. .not. gen_tend)
then
2394 idtend = dtidx(index_of_x_wind,index_of_process_pbl)
2398 utend = (f1(i,k)-u1(i,k))*rdt
2399 dtend(i,k,idtend) = dtend(i,k,idtend) + utend*delt
2404 idtend = dtidx(index_of_y_wind,index_of_process_pbl)
2408 vtend = (f2(i,k)-v1(i,k))*rdt
2409 dtend(i,k,idtend) = dtend(i,k,idtend) + vtend*delt