9 !Including inline expansion statistical function
13 REAL, PARAMETER, PRIVATE :: dtcldcr = 120. ! maximum time step for minor loops
14 REAL, PARAMETER, PRIVATE :: n0r = 8.e6 ! intercept parameter rain
15 REAL, PARAMETER, PRIVATE :: avtr = 841.9 ! a constant for terminal velocity of rain
16 REAL, PARAMETER, PRIVATE :: bvtr = 0.8 ! a constant for terminal velocity of rain
17 REAL, PARAMETER, PRIVATE :: r0 = .8e-5 ! 8 microm in contrast to 10 micro m
18 REAL, PARAMETER, PRIVATE :: peaut = .55 ! collection efficiency
19 REAL, PARAMETER, PRIVATE :: xncr = 3.e8 ! maritime cloud in contrast to 3.e8 in tc80
20 REAL, PARAMETER, PRIVATE :: xmyu = 1.718e-5 ! the dynamic viscosity kgm-1s-1
21 REAL, PARAMETER, PRIVATE :: avts = 11.72 ! a constant for terminal velocity of snow
22 REAL, PARAMETER, PRIVATE :: bvts = .41 ! a constant for terminal velocity of snow
23 REAL, PARAMETER, PRIVATE :: n0smax = 1.e11 ! maximum n0s (t=-90C unlimited)
24 REAL, PARAMETER, PRIVATE :: lamdarmax = 8.e4 ! limited maximum value for slope parameter of rain
25 REAL, PARAMETER, PRIVATE :: lamdasmax = 1.e5 ! limited maximum value for slope parameter of snow
26 REAL, PARAMETER, PRIVATE :: lamdagmax = 6.e4 ! limited maximum value for slope parameter of graupel
27 REAL, PARAMETER, PRIVATE :: dicon = 11.9 ! constant for the cloud-ice diamter
28 REAL, PARAMETER, PRIVATE :: dimax = 500.e-6 ! limited maximum value for the cloud-ice diamter
29 REAL, PARAMETER, PRIVATE :: n0s = 2.e6 ! temperature dependent intercept parameter snow
30 REAL, PARAMETER, PRIVATE :: alpha = .12 ! .122 exponen factor for n0s
31 REAL, PARAMETER, PRIVATE :: pfrz1 = 100. ! constant in Biggs freezing
32 REAL, PARAMETER, PRIVATE :: pfrz2 = 0.66 ! constant in Biggs freezing
33 REAL, PARAMETER, PRIVATE :: qcrmin = 1.e-9 ! minimun values for qr, qs, and qg
34 REAL, PARAMETER, PRIVATE :: eacrc = 1.0 ! Snow/cloud-water collection efficiency
36 qc0, qck1,bvtr1,bvtr2,bvtr3,bvtr4,g1pbr, &
37 g3pbr,g4pbr,g5pbro2,pvtr,eacrr,pacrr, &
38 precr1,precr2,xmmax,roqimax,bvts1, &
39 bvts2,bvts3,bvts4,g1pbs,g3pbs,g4pbs, &
40 g5pbso2,pvts,pacrs,precs1,precs2,pidn0r, &
42 rslopermax,rslopesmax,rslopegmax, &
43 rsloperbmax,rslopesbmax,rslopegbmax, &
44 rsloper2max,rslopes2max,rslopeg2max, &
45 rsloper3max,rslopes3max,rslopeg3max
47 ! Specifies code-inlining of fpvs function in WSM52D below. JM 20040507
50 !===================================================================
52 SUBROUTINE wsm5(th, q, qc, qr, qi, qs &
54 ,delt,g, cpd, cpv, rd, rv, t0c &
56 ,XLS, XLV0, XLF0, den0, denr &
61 ,ids,ide, jds,jde, kds,kde &
62 ,ims,ime, jms,jme, kms,kme &
63 ,its,ite, jts,jte, kts,kte &
68 !-------------------------------------------------------------------
70 !-------------------------------------------------------------------
72 ! This code is a 5-class mixed ice microphyiscs scheme (WSM5) of the WRF
73 ! Single-Moment MicroPhyiscs (WSMMP). The WSMMP assumes that ice nuclei
74 ! number concentration is a function of temperature, and seperate assumption
75 ! is developed, in which ice crystal number concentration is a function
76 ! of ice amount. A theoretical background of the ice-microphysics and related
77 ! processes in the WSMMPs are described in Hong et al. (2004).
78 ! Production terms in the WSM6 scheme are described in Hong and Lim (2006).
79 ! All units are in m.k.s. and source/sink terms in kgkg-1s-1.
83 ! Coded by Song-You Hong (Yonsei Univ.)
84 ! Jimy Dudhia (NCAR) and Shu-Hua Chen (UC Davis)
87 ! Implemented by Song-You Hong (Yonsei Univ.) and Jimy Dudhia (NCAR)
90 ! Reference) Hong, Dudhia, Chen (HDC, 2004) Mon. Wea. Rev.
91 ! Rutledge, Hobbs (RH83, 1983) J. Atmos. Sci.
92 ! Hong and Lim (HL, 2006) J. Korean Meteor. Soc.
94 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde , &
95 ims,ime, jms,jme, kms,kme , &
96 its,ite, jts,jte, kts,kte
97 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
105 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
111 REAL, INTENT(IN ) :: delt, &
129 REAL, DIMENSION( ims:ime , jms:jme ), &
130 INTENT(INOUT) :: rain, &
134 REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, &
135 INTENT(INOUT) :: snow, &
139 REAL, DIMENSION( its:ite , kts:kte ) :: t
140 REAL, DIMENSION( its:ite , kts:kte, 2 ) :: qci, qrs
141 CHARACTER*256 :: emess
147 real*8 wsm3_t(8,256), wsm5_t(8,256), t1, t2
148 common /wsm_times/ wsm3_t(8,256), wsm5_t(8,256)
152 !-------------------------------------------------------------------
162 ! Need to send th, pii, qc, qi, qr, qs
165 CALL wsm52D(th, pii, q, qc, qr, qi, qs &
168 ,delt,g, cpd, cpv, rd, rv, t0c &
170 ,XLS, XLV0, XLF0, den0, denr &
174 ,ids,ide, jds,jde, kds,kde &
175 ,ims,ime, jms,jme, kms,kme &
176 ,its,ite, jts,jte, kts,kte &
185 t(i,k)=th(i,k,j)*pii(i,k,j)
186 qci(i,k,1) = qc(i,k,j)
187 qci(i,k,2) = qi(i,k,j)
188 qrs(i,k,1) = qr(i,k,j)
189 qrs(i,k,2) = qs(i,k,j)
193 ! Sending array starting locations of optional variables may cause
194 ! troubles, so we explicitly change the call.
196 CALL wsm52D(t, q(ims,kms,j), qci, qrs &
198 ,p(ims,kms,j), delz(ims,kms,j) &
199 ,delt,g, cpd, cpv, rd, rv, t0c &
201 ,XLS, XLV0, XLF0, den0, denr &
204 ,rain(ims,j),rainncv(ims,j) &
206 ,ids,ide, jds,jde, kds,kde &
207 ,ims,ime, jms,jme, kms,kme &
208 ,its,ite, jts,jte, kts,kte &
214 th(i,k,j)=t(i,k)/pii(i,k,j)
215 qc(i,k,j) = qci(i,k,1)
216 qi(i,k,j) = qci(i,k,2)
217 qr(i,k,j) = qrs(i,k,1)
218 qs(i,k,j) = qrs(i,k,2)
224 CALL get_wsm5_gpu_levels ( mkx_test )
225 IF ( mkx_test .LT. kte ) THEN
226 WRITE(emess,*)'Number of levels compiled for GPU WSM5 too small. ', &
228 CALL wrf_error_fatal(emess)
231 th(its:ite,kts:kte,jts:jte), pii(its:ite,kts:kte,jts:jte) &
232 ,q(its:ite,kts:kte,jts:jte), qc(its:ite,kts:kte,jts:jte) &
233 ,qi(its:ite,kts:kte,jts:jte), qr(its:ite,kts:kte,jts:jte) &
234 ,qs(its:ite,kts:kte,jts:jte), den(its:ite,kts:kte,jts:jte) &
235 ,p(its:ite,kts:kte,jts:jte), delz(its:ite,kts:kte,jts:jte) &
237 ,rain(its:ite,jts:jte),rainncv(its:ite,jts:jte) &
238 ,snow(its:ite,jts:jte),snowncv(its:ite,jts:jte) &
239 ,sr(its:ite,jts:jte) &
240 ,its, ite, jts, jte, kts, kte &
241 ,its, ite, jts, jte, kts, kte &
242 ,its, ite, jts, jte, kts, kte &
250 l = omp_get_thread_num() + 1
254 wsm5_t(1,l) = wsm5_t(1,l) + (t2 - t1)
262 !===================================================================
264 SUBROUTINE wsm52D(th, pii, q, qc, qr, qi, qqs, den, p, delz &
265 ,delt,g, cpd, cpv, rd, rv, t0c &
267 ,XLS, XLV0, XLF0, den0, denr &
271 ,ids,ide, jds,jde, kds,kde &
272 ,ims,ime, jms,jme, kms,kme &
273 ,its,ite, jts,jte, kts,kte &
276 !-------------------------------------------------------------------
278 !-------------------------------------------------------------------
279 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde , &
280 ims,ime, jms,jme, kms,kme , &
281 its,ite, jts,jte, kts,kte
282 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
285 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
288 REAL, DIMENSION( ims:ime , kms:kme, jms:jme ), &
294 REAL, DIMENSION( ims:ime , kms:kme, jms:jme ), &
297 REAL, DIMENSION( ims:ime , kms:kme, jms:jme ), &
302 REAL, INTENT(IN ) :: delt, &
320 REAL, DIMENSION( ims:ime, jms:jme ), &
321 INTENT(INOUT) :: rain, &
325 REAL, DIMENSION( ims:ime, jms:jme ), OPTIONAL, &
326 INTENT(INOUT) :: snow, &
330 REAL, DIMENSION( its:ite , kts:kte , 2) :: &
340 REAL, DIMENSION( its:ite , kts:kte, jts:jte ) :: &
342 REAL, DIMENSION( its:ite , kts:kte , 2 ) :: &
345 REAL, DIMENSION( its:ite , kts:kte ) :: &
357 REAL, DIMENSION( its:ite , kts:kte ) :: &
374 REAL dtcldden, rdelz, rdtcld
377 #define WSM_NO_CONDITIONAL_IN_VECTOR
378 #ifdef WSM_NO_CONDITIONAL_IN_VECTOR
383 cpmcal, xlcal, lamdar, lamdas, diffus, &
384 viscos, xka, venfac, conden, diffac, &
385 x, y, z, a, b, c, d, e, &
386 qdt, holdrr, holdrs, supcol, supcolt, pvt, &
387 coeres, supsat, dtcld, xmi, eacrs, satdt, &
389 qimax, diameter, xni0, roqi0, &
390 fallsum, fallsum_qsi, xlwork2, factor, source, &
391 value, xlf, pfrzdtc, pfrzdtr, supice, holdc, holdci
392 ! variables for optimization
393 REAL, DIMENSION( its:ite ) :: tvec1
395 INTEGER :: i, j, k, &
396 iprt, latd, lond, loop, loops, ifsat, n
397 ! Temporaries used for inlining fpvs function
398 REAL :: dldti, xb, xai, tr, xbi, xa, hvap, cvap, hsub, dldt, ttp
401 !=================================================================
402 ! compute internal functions
404 cpmcal(x) = cpd*(1.-max(x,qmin))+max(x,qmin)*cpv
405 xlcal(x) = xlv0-xlv1*(x-t0c)
406 !----------------------------------------------------------------
407 ! size distributions: (x=mixing ratio, y=air density):
408 ! valid for mixing ratio > 1.e-9 kg/kg.
410 ! Optimizatin : A**B => exp(log(A)*(B))
411 lamdar(x,y)= sqrt(sqrt(pidn0r/(x*y))) ! (pidn0r/(x*y))**.25
412 lamdas(x,y,z)= sqrt(sqrt(pidn0s*z/(x*y))) ! (pidn0s*z/(x*y))**.25
414 !----------------------------------------------------------------
415 ! diffus: diffusion coefficient of the water vapor
416 ! viscos: kinematic viscosity(m2s-1)
417 ! diffus(x,y) = 8.794e-5 * exp(log(x)*(1.81)) / y ! 8.794e-5*x**1.81/y
418 ! viscos(x,y) = 1.496e-6 * (x*sqrt(x)) /(x+120.)/y ! 1.496e-6*x**1.5/(x+120.)/y
419 ! xka(x,y) = 1.414e3*viscos(x,y)*y
420 ! diffac(a,b,c,d,e) = d*a*a/(xka(c,d)*rv*c*c)+1./(e*diffus(c,b))
421 ! venfac(a,b,c) = exp(log((viscos(b,c)/diffus(b,a)))*((.3333333))) &
422 ! /sqrt(viscos(b,c))*sqrt(sqrt(den0/c))
423 ! conden(a,b,c,d,e) = (max(b,qmin)-c)/(1.+d*d/(rv*e)*c/(a*a))
428 !----------------------------------------------------------------
429 ! paddint 0 for negative values generated by dynamics
433 ! Moved outside of accelerator region
435 loops = max(nint(delt/dtcldcr),1)
437 if(delt.le.dtcldcr) dtcld = delt
440 !....!$acc local(t) &
442 IF ( PRESENT (snowncv) .AND. PRESENT (snow)) THEN
446 !$acc copyin(delz(:,:,:),p(:,:,:),den(:,:,:),pii(:,:,:)) &
447 !$acc copyout(snowncv(:,:),rainncv(:,:),sr(:,:)) &
448 !$acc copy(qqs(:,:,:),qr(:,:,:),qi(:,:,:),qc(:,:,:)) &
449 !$acc copy(th(:,:,:),q(:,:,:),snow(:,:),rain(:,:))
451 !$acc private(rh,qs,rslope,rslope2,rslope3,rslopeb,falk,fall) &
452 !$acc private(work1,qci,qrs,falkc,fallc,xl,cpm,denfac,xni) &
453 !$acc private(n0sfac,work2,work1c,work2c,pigen,pidep,psdep) &
454 !$acc private(praut,psaut,prevp,psevp) &
455 !$acc private(pracw,psacw,psaci,pcond,psmlt) &
459 !$acc private(numdt,mstep) &
463 t(i,k,j)=th(i,k,j)*pii(i,k,j)
464 qci(i,k,1) = max(qc(i,k,j),0.0)
465 qci(i,k,2) = max(qi(i,k,j),0.0)
466 qrs(i,k,1) = max(qr(i,k,j),0.0)
467 qrs(i,k,2) = max(qqs(i,k,j),0.0)
470 !----------------------------------------------------------------
471 ! latent heat for phase changes and heat capacity. neglect the
472 ! changes during microphysical process calculation
476 cpm(i,k) = cpmcal(q(i,k,j))
477 xl(i,k) = xlcal(t(i,k,j))
480 !----------------------------------------------------------------
481 ! compute the minor time steps.
483 ! loops = max(nint(delt/dtcldcr),1)
485 ! if(delt.le.dtcldcr) dtcld = delt
489 !----------------------------------------------------------------
490 ! initialize the large scale variables
496 denfac(i,k) = sqrt(den0/den(i,k,j))
499 ! CALL VREC( tvec1(its), den(its,k,j), ite-its+1)
501 ! tvec1(i) = tvec1(i)*den0
503 ! CALL VSQRT( denfac(its,k), tvec1(its), ite-its+1)
506 ! Inline expansion for fpvs
507 ! qs(i,k,1) = fpvs(t(i,k,j),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
508 ! qs(i,k,2) = fpvs(t(i,k,j),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
518 xbi=xai+hsub/(rv*ttp)
520 ! this is for compilers where the conditional inhibits vectorization
521 #ifdef WSM_NO_CONDITIONAL_IN_VECTOR
523 if(t(i,k,j).lt.ttp) then
532 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
533 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
534 qs(i,k,1) = max(qs(i,k,1),qmin)
535 rh(i,k,1) = max(q(i,k,j) / qs(i,k,1),qmin)
536 qs(i,k,2)=psat*exp(logtr*(xal)+xbl*(1.-tr))
537 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k,j) - qs(i,k,2))
538 qs(i,k,2) = max(qs(i,k,2),qmin)
539 rh(i,k,2) = max(q(i,k,j) / qs(i,k,2),qmin)
545 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
546 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
547 qs(i,k,1) = max(qs(i,k,1),qmin)
548 rh(i,k,1) = max(q(i,k,j) / qs(i,k,1),qmin)
549 if(t(i,k,j).lt.ttp) then
550 qs(i,k,2)=psat*exp(logtr*(xai)+xbi*(1.-tr))
552 qs(i,k,2)=psat*exp(logtr*(xa)+xb*(1.-tr))
554 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k,j) - qs(i,k,2))
555 qs(i,k,2) = max(qs(i,k,2),qmin)
556 rh(i,k,2) = max(q(i,k,j) / qs(i,k,2),qmin)
561 !----------------------------------------------------------------
562 ! initialize the variables for microphysical physics
587 !----------------------------------------------------------------
588 ! compute the fallout term:
589 ! first, vertical terminal velosity for minor loops
592 supcol = t0c-t(i,k,j)
593 !---------------------------------------------------------------
594 ! n0s: Intercept parameter for snow [m-4] [HDC 6]
595 !---------------------------------------------------------------
596 n0sfac(i,k) = max(min(exp(alpha*supcol),n0smax/n0s),1.)
597 if(qrs(i,k,1).le.qcrmin)then
598 rslope(i,k,1) = rslopermax
599 rslopeb(i,k,1) = rsloperbmax
600 rslope2(i,k,1) = rsloper2max
601 rslope3(i,k,1) = rsloper3max
603 rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k,j))
604 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
605 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
606 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
608 if(qrs(i,k,2).le.qcrmin)then
609 rslope(i,k,2) = rslopesmax
610 rslopeb(i,k,2) = rslopesbmax
611 rslope2(i,k,2) = rslopes2max
612 rslope3(i,k,2) = rslopes3max
614 rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k,j),n0sfac(i,k))
615 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
616 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
617 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
619 !-------------------------------------------------------------
620 ! Ni: ice crystal number concentraiton [HDC 5c]
621 !-------------------------------------------------------------
622 ! xni(i,k) = min(max(5.38e7*(den(i,k,j) &
623 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
624 temp = (den(i,k,j)*max(qci(i,k,2),qmin))
625 temp = sqrt(sqrt(temp*temp*temp))
626 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
631 work1(i,k,1) = pvtr*rslopeb(i,k,1)*denfac(i,k)/delz(i,k,j)
632 work1(i,k,2) = pvts*rslopeb(i,k,2)*denfac(i,k)/delz(i,k,j)
633 numdt = max(nint(max(work1(i,k,1),work1(i,k,2))*dtcld+.5),1)
634 if(numdt.ge.mstep) mstep = numdt
640 ! falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)/mstep(i)
641 ! falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)/mstep(i)
642 falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)*rmstep
643 falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)*rmstep
644 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
645 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
646 ! qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcld/den(i,k,j),0.)
647 ! qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcld/den(i,k,j),0.)
648 dtcldden = dtcld/den(i,k,j)
649 qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcldden,0.)
650 qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcldden,0.)
652 do k = kte-1, kts, -1
653 falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)*rmstep
654 falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)*rmstep
655 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
656 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
657 dtcldden = dtcld/den(i,k,j)
658 rdelz = 1./delz(i,k,j)
659 qrs(i,k,1) = max(qrs(i,k,1)-(falk(i,k,1)-falk(i,k+1,1) &
660 *delz(i,k+1,j)*rdelz)*dtcldden,0.)
661 qrs(i,k,2) = max(qrs(i,k,2)-(falk(i,k,2)-falk(i,k+1,2) &
662 *delz(i,k+1,j)*rdelz)*dtcldden,0.)
665 if(t(i,k,j).gt.t0c.and.qrs(i,k,2).gt.0.) then
666 !----------------------------------------------------------------
667 ! psmlt: melting of snow [HL A33] [RH83 A25]
669 !----------------------------------------------------------------
671 ! work2(i,k)= venfac(p(i,k),t(i,k,j),den(i,k,j))
672 work2(i,k)= (exp(log(((1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))) &
673 /((t(i,k,j))+120.)/(den(i,k,j)))/(8.794e-5 &
674 *exp(log(t(i,k,j))*(1.81))/p(i,k,j)))) &
675 *((.3333333)))/sqrt((1.496e-6*((t(i,k,j)) &
676 *sqrt(t(i,k,j)))/((t(i,k,j))+120.)/(den(i,k,j)))) &
677 *sqrt(sqrt(den0/(den(i,k,j)))))
678 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
679 ! psmlt(i,k) = xka(t(i,k,j),den(i,k,j))/xlf*(t0c-t(i,k,j))*pi/2. &
680 ! *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
681 ! *work2(i,k)*coeres)
682 psmlt(i,k) = (1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))) &
683 /((t(i,k,j))+120.)/(den(i,k,j)) )*(den(i,k,j))) &
684 /xlf*(t0c-t(i,k,j))*pi/2. &
685 *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
687 psmlt(i,k) = min(max(psmlt(i,k)*dtcld/mstep, &
688 -qrs(i,k,2)/mstep),0.)
689 qrs(i,k,2) = qrs(i,k,2) + psmlt(i,k)
690 qrs(i,k,1) = qrs(i,k,1) - psmlt(i,k)
691 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*psmlt(i,k)
697 !---------------------------------------------------------------
698 ! Vice [ms-1] : fallout of ice crystal [HDC 5a]
699 !---------------------------------------------------------------
703 if(qci(i,k,2).le.0.) then
706 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
707 ! diameter = min(dicon * sqrt(xmi),dimax)
708 diameter = max(min(dicon * sqrt(xmi),dimax), 1.e-25)
709 work1c(i,k) = 1.49e4*exp(log(diameter)*(1.31))
710 work2c(i,k) = work1c(i,k)/delz(i,k,j)
712 numdt = max(nint(work2c(i,k)*dtcld+.5),1)
713 if(numdt.ge.mstep) mstep = numdt
718 falkc(i,k) = den(i,k,j)*qci(i,k,2)*work2c(i,k)/mstep
720 fallc(i,k) = fallc(i,k)+falkc(i,k)
722 qci(i,k,2) = max(qci(i,k,2)-falkc(i,k)*dtcld/den(i,k,j),0.)
724 do k = kte-1, kts, -1
725 falkc(i,k) = den(i,k,j)*qci(i,k,2)*work2c(i,k)/mstep
727 fallc(i,k) = fallc(i,k)+falkc(i,k)
729 qci(i,k,2) = max(qci(i,k,2)-(falkc(i,k)-falkc(i,k+1) &
730 *delz(i,k+1,j)/delz(i,k,j))*dtcld/den(i,k,j),0.)
736 !----------------------------------------------------------------
737 ! rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
739 fallsum = fall(i,1,1)+fall(i,1,2)+fallc(i,1)
740 fallsum_qsi = fall(i,1,2)+fallc(i,1)
742 if(fallsum.gt.0.) then
743 rainncv(i,j) = fallsum*delz(i,1,j)/denr*dtcld*1000.
744 rain(i,j) = fallsum*delz(i,1,j)/denr*dtcld*1000. + rain(i,j)
747 if(fallsum_qsi.gt.0.) then
748 snowncv(i,j) = fallsum_qsi*delz(i,kts,j)/denr*dtcld*1000.
749 snow(i,j) = fallsum_qsi*delz(i,kts,j)/denr*dtcld*1000. + snow(i,j)
752 if(fallsum.gt.0.)sr(i,j)=fallsum_qsi*delz(i,kts,j)/denr*dtcld*1000. &
753 /(rainncv(i,j)+1.e-12)
755 !---------------------------------------------------------------
756 ! pimlt: instantaneous melting of cloud ice [HL A47] [RH83 A28]
758 !---------------------------------------------------------------
760 supcol = t0c-t(i,k,j)
762 if(supcol.lt.0.) xlf = xlf0
763 if(supcol.lt.0.and.qci(i,k,2).gt.0.) then
764 qci(i,k,1) = qci(i,k,1) + qci(i,k,2)
765 t(i,k,j) = t(i,k,j) - xlf/cpm(i,k)*qci(i,k,2)
768 !---------------------------------------------------------------
769 ! pihmf: homogeneous freezing of cloud water below -40c [HL A45]
771 !---------------------------------------------------------------
772 if(supcol.gt.40..and.qci(i,k,1).gt.0.) then
773 qci(i,k,2) = qci(i,k,2) + qci(i,k,1)
774 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*qci(i,k,1)
777 !---------------------------------------------------------------
778 ! pihtf: heterogeneous freezing of cloud water [HL A44]
780 !---------------------------------------------------------------
781 if(supcol.gt.0..and.qci(i,k,1).gt.0.) then
782 supcolt=min(supcol,50.)
783 ! pfrzdtc = min(pfrz1*(exp(pfrz2*supcol)-1.) &
784 ! *den(i,k,j)/denr/xncr*qci(i,k,1)**2*dtcld,qci(i,k,1))
785 pfrzdtc = min(pfrz1*(exp(pfrz2*supcolt)-1.) &
786 *den(i,k,j)/denr/xncr*qci(i,k,1)*qci(i,k,1)*dtcld,qci(i,k,1))
787 qci(i,k,2) = qci(i,k,2) + pfrzdtc
788 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*pfrzdtc
789 qci(i,k,1) = qci(i,k,1)-pfrzdtc
791 !---------------------------------------------------------------
792 ! psfrz: freezing of rain water [HL A20] [LFO 45]
794 !---------------------------------------------------------------
795 if(supcol.gt.0..and.qrs(i,k,1).gt.0.) then
796 supcolt=min(supcol,50.)
797 ! pfrzdtr = min(20.*pi**2*pfrz1*n0r*denr/den(i,k,j) &
798 ! *(exp(pfrz2*supcol)-1.)*rslope(i,k,1)**7*dtcld, &
801 temp = temp*temp*temp*temp*temp*temp*temp
802 pfrzdtr = min(20.*(pi*pi)*pfrz1*n0r*denr/den(i,k,j) &
803 *(exp(pfrz2*supcolt)-1.)*temp*dtcld, &
805 qrs(i,k,2) = qrs(i,k,2) + pfrzdtr
806 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*pfrzdtr
807 qrs(i,k,1) = qrs(i,k,1)-pfrzdtr
811 !----------------------------------------------------------------
812 ! rsloper: reverse of the slope parameter of the rain(m)
813 ! xka: thermal conductivity of air(jm-1s-1k-1)
814 ! work1: the thermodynamic term in the denominator associated with
815 ! heat conduction and vapor diffusion
817 ! work2: parameter associated with the ventilation effects(y93)
820 if(qrs(i,k,1).le.qcrmin)then
821 rslope(i,k,1) = rslopermax
822 rslopeb(i,k,1) = rsloperbmax
823 rslope2(i,k,1) = rsloper2max
824 rslope3(i,k,1) = rsloper3max
826 ! rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k,j))
827 rslope(i,k,1) = 1./(sqrt(sqrt(pidn0r/((qrs(i,k,1))*(den(i,k,j))))))
828 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
829 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
830 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
832 if(qrs(i,k,2).le.qcrmin)then
833 rslope(i,k,2) = rslopesmax
834 rslopeb(i,k,2) = rslopesbmax
835 rslope2(i,k,2) = rslopes2max
836 rslope3(i,k,2) = rslopes3max
838 ! rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k,j),n0sfac(i,k))
839 rslope(i,k,2) = 1./(sqrt(sqrt(pidn0s*(n0sfac(i,k))/((qrs(i,k,2)) &
841 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
842 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
843 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
848 ! work1(i,k,1) = diffac(xl(i,k),p(i,k,j),t(i,k,j),den(i,k,j),qs(i,k,1))
849 work1(i,k,1) = ((((den(i,k,j))*(xl(i,k))*(xl(i,k)))*((t(i,k,j))+120.) &
850 *(den(i,k,j)))/(1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))))&
851 *(den(i,k,j))*(rv*(t(i,k,j))*(t(i,k,j))))) &
852 + p(i,k,j)/((qs(i,k,1))*(8.794e-5*exp(log(t(i,k,j))*(1.81))))
853 ! work1(i,k,2) = diffac(xls,p(i,k,j),t(i,k,j),den(i,k,j),qs(i,k,2))
854 work1(i,k,2) = ((((den(i,k,j))*(xls)*(xls))*((t(i,k,j))+120.)*(den(i,k,j)))&
855 /(1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))))*(den(i,k,j)) &
856 *(rv*(t(i,k,j))*(t(i,k,j)))) &
857 + p(i,k,j)/(qs(i,k,2)*(8.794e-5*exp(log(t(i,k,j))*(1.81)))))
858 ! work2(i,k) = venfac(p(i,k,j),t(i,k,j),den(i,k,j))
859 work2(i,k) = (exp(.3333333*log(((1.496e-6 * ((t(i,k,j))*sqrt(t(i,k,j)))) &
860 *p(i,k,j))/(((t(i,k,j))+120.)*den(i,k,j)*(8.794e-5 &
861 *exp(log(t(i,k,j))*(1.81))))))*sqrt(sqrt(den0/(den(i,k,j))))) &
862 /sqrt((1.496e-6*((t(i,k,j))*sqrt(t(i,k,j)))) &
863 /(((t(i,k,j))+120.)*den(i,k,j)))
866 !===============================================================
868 ! warm rain processes
870 ! - follows the processes in RH83 and LFO except for autoconcersion
872 !===============================================================
875 supsat = max(q(i,k,j),qmin)-qs(i,k,1)
877 !---------------------------------------------------------------
878 ! praut: auto conversion rate from cloud to rain [HDC 16]
880 !---------------------------------------------------------------
881 if(qci(i,k,1).gt.qc0) then
882 praut(i,k) = qck1*exp(log(qci(i,k,1))*((7./3.)))
883 praut(i,k) = min(praut(i,k),qci(i,k,1)/dtcld)
885 !---------------------------------------------------------------
886 ! pracw: accretion of cloud water by rain [HL A40] [LFO 51]
888 !---------------------------------------------------------------
889 if(qrs(i,k,1).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
890 pracw(i,k) = min(pacrr*rslope3(i,k,1)*rslopeb(i,k,1) &
891 *qci(i,k,1)*denfac(i,k),qci(i,k,1)/dtcld)
893 !---------------------------------------------------------------
894 ! prevp: evaporation/condensation rate of rain [HDC 14]
896 !---------------------------------------------------------------
897 if(qrs(i,k,1).gt.0.) then
898 coeres = rslope2(i,k,1)*sqrt(rslope(i,k,1)*rslopeb(i,k,1))
899 prevp(i,k) = (rh(i,k,1)-1.)*(precr1*rslope2(i,k,1) &
900 +precr2*work2(i,k)*coeres)/work1(i,k,1)
901 if(prevp(i,k).lt.0.) then
902 prevp(i,k) = max(prevp(i,k),-qrs(i,k,1)/dtcld)
903 prevp(i,k) = max(prevp(i,k),satdt/2)
905 prevp(i,k) = min(prevp(i,k),satdt/2)
910 !===============================================================
912 ! cold rain processes
914 ! - follows the revised ice microphysics processes in HDC
915 ! - the processes same as in RH83 and RH84 and LFO behave
916 ! following ice crystal hapits defined in HDC, inclduing
917 ! intercept parameter for snow (n0s), ice crystal number
918 ! concentration (ni), ice nuclei number concentration
919 ! (n0i), ice diameter (d)
921 !===============================================================
925 supcol = t0c-t(i,k,j)
926 supsat = max(q(i,k,j),qmin)-qs(i,k,2)
929 !-------------------------------------------------------------
930 ! Ni: ice crystal number concentraiton [HDC 5c]
931 !-------------------------------------------------------------
932 ! xni(i,k) = min(max(5.38e7*(den(i,k,j) &
933 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
934 temp = (den(i,k,j)*max(qci(i,k,2),qmin))
935 temp = sqrt(sqrt(temp*temp*temp))
936 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
937 eacrs = exp(0.07*(-supcol))
940 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,2).gt.qmin) then
941 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
942 diameter = min(dicon * sqrt(xmi),dimax)
943 vt2i = 1.49e4*diameter**1.31
944 vt2s = pvts*rslopeb(i,k,2)*denfac(i,k)
945 !-------------------------------------------------------------
946 ! psaci: Accretion of cloud ice by rain [HDC 10]
948 !-------------------------------------------------------------
949 acrfac = 2.*rslope3(i,k,2)+2.*diameter*rslope2(i,k,2) &
950 +diameter**2*rslope(i,k,2)
951 psaci(i,k) = pi*qci(i,k,2)*eacrs*n0s*n0sfac(i,k) &
952 *abs(vt2s-vt2i)*acrfac/4.
955 !-------------------------------------------------------------
956 ! psacw: Accretion of cloud water by snow [HL A7] [LFO 24]
957 ! (T<T0: C->S, and T>=T0: C->R)
958 !-------------------------------------------------------------
959 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
960 psacw(i,k) = min(pacrc*n0sfac(i,k)*rslope3(i,k,2) &
961 *rslopeb(i,k,2)*qci(i,k,1)*denfac(i,k) &
965 if(supcol .gt. 0) then
966 !-------------------------------------------------------------
967 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
968 ! (T<T0: V->I or I->V)
969 !-------------------------------------------------------------
970 if(qci(i,k,2).gt.0.and.ifsat.ne.1) then
971 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
972 diameter = dicon * sqrt(xmi)
973 pidep(i,k) = 4.*diameter*xni(i,k)*(rh(i,k,2)-1.)/work1(i,k,2)
974 supice = satdt-prevp(i,k)
975 if(pidep(i,k).lt.0.) then
976 ! pidep(i,k) = max(max(pidep(i,k),satdt/2),supice)
977 ! pidep(i,k) = max(pidep(i,k),-qci(i,k,2)/dtcld)
978 pidep(i,k) = max(max(pidep(i,k),satdt*.5),supice)
979 pidep(i,k) = max(pidep(i,k),-qci(i,k,2)*rdtcld)
981 ! pidep(i,k) = min(min(pidep(i,k),satdt/2),supice)
982 pidep(i,k) = min(min(pidep(i,k),satdt*.5),supice)
984 if(abs(prevp(i,k)+pidep(i,k)).ge.abs(satdt)) ifsat = 1
986 !-------------------------------------------------------------
987 ! psdep: deposition/sublimation rate of snow [HDC 14]
989 !-------------------------------------------------------------
990 if(qrs(i,k,2).gt.0..and.ifsat.ne.1) then
991 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
992 psdep(i,k) = (rh(i,k,2)-1.)*n0sfac(i,k) &
993 *(precs1*rslope2(i,k,2)+precs2 &
994 *work2(i,k)*coeres)/work1(i,k,2)
995 supice = satdt-prevp(i,k)-pidep(i,k)
996 if(psdep(i,k).lt.0.) then
997 ! psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)/dtcld)
998 ! psdep(i,k) = max(max(psdep(i,k),satdt/2),supice)
999 psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)*rdtcld)
1000 psdep(i,k) = max(max(psdep(i,k),satdt*.5),supice)
1002 ! psdep(i,k) = min(min(psdep(i,k),satdt/2),supice)
1003 psdep(i,k) = min(min(psdep(i,k),satdt*.5),supice)
1005 if(abs(prevp(i,k)+pidep(i,k)+psdep(i,k)).ge.abs(satdt)) &
1008 !-------------------------------------------------------------
1009 ! pigen: generation(nucleation) of ice from vapor [HL A50] [HDC 7-8]
1011 !-------------------------------------------------------------
1012 if(supsat.gt.0.and.ifsat.ne.1) then
1013 supice = satdt-prevp(i,k)-pidep(i,k)-psdep(i,k)
1014 xni0 = 1.e3*exp(0.1*supcol)
1015 roqi0 = 4.92e-11*exp(log(xni0)*(1.33))
1016 pigen(i,k) = max(0.,(roqi0/den(i,k,j)-max(qci(i,k,2),0.)) &
1019 pigen(i,k) = min(min(pigen(i,k),satdt),supice)
1022 !-------------------------------------------------------------
1023 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
1025 !-------------------------------------------------------------
1026 if(qci(i,k,2).gt.0.) then
1027 qimax = roqimax/den(i,k,j)
1028 ! psaut(i,k) = max(0.,(qci(i,k,2)-qimax)/dtcld)
1029 psaut(i,k) = max(0.,(qci(i,k,2)-qimax)*rdtcld)
1032 !-------------------------------------------------------------
1033 ! psevp: Evaporation of melting snow [HL A35] [RH83 A27]
1035 !-------------------------------------------------------------
1036 if(supcol.lt.0.) then
1037 if(qrs(i,k,2).gt.0..and.rh(i,k,1).lt.1.) &
1038 psevp(i,k) = psdep(i,k)*work1(i,k,2)/work1(i,k,1)
1039 ! psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)/dtcld),0.)
1040 psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)*rdtcld),0.)
1045 !----------------------------------------------------------------
1046 ! check mass conservation of generation terms and feedback to the
1050 if(t(i,k,j).le.t0c) then
1054 value = max(qmin,qci(i,k,1))
1055 source = (praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
1056 if (source.gt.value) then
1057 factor = value/source
1058 praut(i,k) = praut(i,k)*factor
1059 pracw(i,k) = pracw(i,k)*factor
1060 psacw(i,k) = psacw(i,k)*factor
1065 value = max(qmin,qci(i,k,2))
1066 source = (psaut(i,k)+psaci(i,k)-pigen(i,k)-pidep(i,k))*dtcld
1067 if (source.gt.value) then
1068 factor = value/source
1069 psaut(i,k) = psaut(i,k)*factor
1070 psaci(i,k) = psaci(i,k)*factor
1071 pigen(i,k) = pigen(i,k)*factor
1072 pidep(i,k) = pidep(i,k)*factor
1078 value = max(qmin,qrs(i,k,1))
1079 source = (-praut(i,k)-pracw(i,k)-prevp(i,k))*dtcld
1080 if (source.gt.value) then
1081 factor = value/source
1082 praut(i,k) = praut(i,k)*factor
1083 pracw(i,k) = pracw(i,k)*factor
1084 prevp(i,k) = prevp(i,k)*factor
1089 value = max(qmin,qrs(i,k,2))
1090 source = (-psdep(i,k)-psaut(i,k)-psaci(i,k)-psacw(i,k))*dtcld
1091 if (source.gt.value) then
1092 factor = value/source
1093 psdep(i,k) = psdep(i,k)*factor
1094 psaut(i,k) = psaut(i,k)*factor
1095 psaci(i,k) = psaci(i,k)*factor
1096 psacw(i,k) = psacw(i,k)*factor
1099 work2(i,k)=-(prevp(i,k)+psdep(i,k)+pigen(i,k)+pidep(i,k))
1101 q(i,k,j) = q(i,k,j)+work2(i,k)*dtcld
1102 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
1103 +psacw(i,k))*dtcld,0.)
1104 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
1105 +prevp(i,k))*dtcld,0.)
1106 qci(i,k,2) = max(qci(i,k,2)-(psaut(i,k)+psaci(i,k) &
1107 -pigen(i,k)-pidep(i,k))*dtcld,0.)
1108 qrs(i,k,2) = max(qrs(i,k,2)+(psdep(i,k)+psaut(i,k) &
1109 +psaci(i,k)+psacw(i,k))*dtcld,0.)
1111 xlwork2 = -xls*(psdep(i,k)+pidep(i,k)+pigen(i,k)) &
1112 -xl(i,k)*prevp(i,k)-xlf*psacw(i,k)
1113 t(i,k,j) = t(i,k,j)-xlwork2/cpm(i,k)*dtcld
1118 value = max(qmin,qci(i,k,1))
1119 source=(praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
1120 if (source.gt.value) then
1121 factor = value/source
1122 praut(i,k) = praut(i,k)*factor
1123 pracw(i,k) = pracw(i,k)*factor
1124 psacw(i,k) = psacw(i,k)*factor
1129 value = max(qmin,qrs(i,k,1))
1130 source = (-praut(i,k)-pracw(i,k)-prevp(i,k)-psacw(i,k))*dtcld
1131 if (source.gt.value) then
1132 factor = value/source
1133 praut(i,k) = praut(i,k)*factor
1134 pracw(i,k) = pracw(i,k)*factor
1135 prevp(i,k) = prevp(i,k)*factor
1136 psacw(i,k) = psacw(i,k)*factor
1141 value = max(qcrmin,qrs(i,k,2))
1142 source=(-psevp(i,k))*dtcld
1143 if (source.gt.value) then
1144 factor = value/source
1145 psevp(i,k) = psevp(i,k)*factor
1147 work2(i,k)=-(prevp(i,k)+psevp(i,k))
1149 q(i,k,j) = q(i,k,j)+work2(i,k)*dtcld
1150 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
1151 +psacw(i,k))*dtcld,0.)
1152 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
1153 +prevp(i,k) +psacw(i,k))*dtcld,0.)
1154 qrs(i,k,2) = max(qrs(i,k,2)+psevp(i,k)*dtcld,0.)
1156 xlwork2 = -xl(i,k)*(prevp(i,k)+psevp(i,k))
1157 t(i,k,j) = t(i,k,j)-xlwork2/cpm(i,k)*dtcld
1161 ! Inline expansion for fpvs
1162 ! qs(i,k,1) = fpvs(t(i,k,j),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1163 ! qs(i,k,2) = fpvs(t(i,k,j),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1173 xbi=xai+hsub/(rv*ttp)
1177 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
1178 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
1179 qs(i,k,1) = max(qs(i,k,1),qmin)
1182 !----------------------------------------------------------------
1183 ! pcond: condensational/evaporational rate of cloud water [HL A46] [RH83 A6]
1184 ! if there exists additional water vapor condensated/if
1185 ! evaporation of cloud water is not enough to remove subsaturation
1188 ! work1(i,k,1) = conden(t(i,k,j),q(i,k,j),qs(i,k,1),xl(i,k),cpm(i,k))
1189 work1(i,k,1) = ((max(q(i,k,j),qmin)-(qs(i,k,1)))/(1.+(xl(i,k)) &
1190 *(xl(i,k))/(rv*(cpm(i,k)))*(qs(i,k,1)) &
1191 /((t(i,k,j))*(t(i,k,j)))))
1192 work2(i,k) = qci(i,k,1)+work1(i,k,1)
1193 pcond(i,k) = min(max(work1(i,k,1)/dtcld,0.),max(q(i,k,j),0.)/dtcld)
1194 if(qci(i,k,1).gt.0..and.work1(i,k,1).lt.0.) &
1195 pcond(i,k) = max(work1(i,k,1),-qci(i,k,1))/dtcld
1196 q(i,k,j) = q(i,k,j)-pcond(i,k)*dtcld
1197 qci(i,k,1) = max(qci(i,k,1)+pcond(i,k)*dtcld,0.)
1198 t(i,k,j) = t(i,k,j)+pcond(i,k)*xl(i,k)/cpm(i,k)*dtcld
1202 !----------------------------------------------------------------
1203 ! padding for small values
1206 if(qci(i,k,1).le.qmin) qci(i,k,1) = 0.0
1207 if(qci(i,k,2).le.qmin) qci(i,k,2) = 0.0
1212 th(i,k,j)=t(i,k,j)/pii(i,k,j)
1213 qc(i,k,j) = qci(i,k,1)
1214 qi(i,k,j) = qci(i,k,2)
1215 qr(i,k,j) = qrs(i,k,1)
1216 qqs(i,k,j) = qrs(i,k,2)
1228 ! Moved outside of accelerator region
1230 loops = max(nint(delt/dtcldcr),1)
1232 if(delt.le.dtcldcr) dtcld = delt
1236 !$acc copyin(delz(:,:,:),p(:,:,:),den(:,:,:),pii(:,:,:)) &
1237 !$acc copyout(rainncv(:,:),sr(:,:)) &
1238 !$acc copy(qqs(:,:,:),qr(:,:,:),qi(:,:,:),qc(:,:,:)) &
1239 !$acc copy(th(:,:,:),q(:,:,:),rain(:,:))
1241 !$acc private(rh,qs,rslope,rslope2,rslope3,rslopeb,falk,fall) &
1242 !$acc private(work1,qci,qrs,falkc,fallc,xl,cpm,denfac,xni) &
1243 !$acc private(n0sfac,work2,work1c,work2c,pigen,pidep,psdep) &
1244 !$acc private(praut,psaut,prevp,psevp) &
1245 !$acc private(pracw,psacw,psaci,pcond,psmlt) &
1249 !$acc private(numdt,mstep) &
1253 t(i,k,j)=th(i,k,j)*pii(i,k,j)
1254 qci(i,k,1) = max(qc(i,k,j),0.0)
1255 qci(i,k,2) = max(qi(i,k,j),0.0)
1256 qrs(i,k,1) = max(qr(i,k,j),0.0)
1257 qrs(i,k,2) = max(qqs(i,k,j),0.0)
1260 !----------------------------------------------------------------
1261 ! latent heat for phase changes and heat capacity. neglect the
1262 ! changes during microphysical process calculation
1266 cpm(i,k) = cpmcal(q(i,k,j))
1267 xl(i,k) = xlcal(t(i,k,j))
1270 !----------------------------------------------------------------
1271 ! compute the minor time steps.
1273 ! loops = max(nint(delt/dtcldcr),1)
1274 ! dtcld = delt/loops
1275 ! if(delt.le.dtcldcr) dtcld = delt
1279 !----------------------------------------------------------------
1280 ! initialize the large scale variables
1286 denfac(i,k) = sqrt(den0/den(i,k,j))
1289 ! CALL VREC( tvec1(its), den(its,k,j), ite-its+1)
1291 ! tvec1(i) = tvec1(i)*den0
1293 ! CALL VSQRT( denfac(its,k), tvec1(its), ite-its+1)
1296 ! Inline expansion for fpvs
1297 ! qs(i,k,1) = fpvs(t(i,k,j),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1298 ! qs(i,k,2) = fpvs(t(i,k,j),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1308 xbi=xai+hsub/(rv*ttp)
1310 ! this is for compilers where the conditional inhibits vectorization
1311 #ifdef WSM_NO_CONDITIONAL_IN_VECTOR
1313 if(t(i,k,j).lt.ttp) then
1322 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
1323 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
1324 qs(i,k,1) = max(qs(i,k,1),qmin)
1325 rh(i,k,1) = max(q(i,k,j) / qs(i,k,1),qmin)
1326 qs(i,k,2)=psat*exp(logtr*(xal)+xbl*(1.-tr))
1327 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k,j) - qs(i,k,2))
1328 qs(i,k,2) = max(qs(i,k,2),qmin)
1329 rh(i,k,2) = max(q(i,k,j) / qs(i,k,2),qmin)
1335 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
1336 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
1337 qs(i,k,1) = max(qs(i,k,1),qmin)
1338 rh(i,k,1) = max(q(i,k,j) / qs(i,k,1),qmin)
1339 if(t(i,k,j).lt.ttp) then
1340 qs(i,k,2)=psat*exp(logtr*(xai)+xbi*(1.-tr))
1342 qs(i,k,2)=psat*exp(logtr*(xa)+xb*(1.-tr))
1344 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k,j) - qs(i,k,2))
1345 qs(i,k,2) = max(qs(i,k,2),qmin)
1346 rh(i,k,2) = max(q(i,k,j) / qs(i,k,2),qmin)
1350 !----------------------------------------------------------------
1351 ! initialize the variables for microphysical physics
1376 !----------------------------------------------------------------
1377 ! compute the fallout term:
1378 ! first, vertical terminal velosity for minor loops
1381 supcol = t0c-t(i,k,j)
1382 !---------------------------------------------------------------
1383 ! n0s: Intercept parameter for snow [m-4] [HDC 6]
1384 !---------------------------------------------------------------
1385 n0sfac(i,k) = max(min(exp(alpha*supcol),n0smax/n0s),1.)
1386 if(qrs(i,k,1).le.qcrmin)then
1387 rslope(i,k,1) = rslopermax
1388 rslopeb(i,k,1) = rsloperbmax
1389 rslope2(i,k,1) = rsloper2max
1390 rslope3(i,k,1) = rsloper3max
1392 rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k,j))
1393 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
1394 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
1395 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
1397 if(qrs(i,k,2).le.qcrmin)then
1398 rslope(i,k,2) = rslopesmax
1399 rslopeb(i,k,2) = rslopesbmax
1400 rslope2(i,k,2) = rslopes2max
1401 rslope3(i,k,2) = rslopes3max
1403 rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k,j),n0sfac(i,k))
1404 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
1405 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
1406 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
1408 !-------------------------------------------------------------
1409 ! Ni: ice crystal number concentraiton [HDC 5c]
1410 !-------------------------------------------------------------
1411 ! xni(i,k) = min(max(5.38e7*(den(i,k,j) &
1412 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
1413 temp = (den(i,k,j)*max(qci(i,k,2),qmin))
1414 temp = sqrt(sqrt(temp*temp*temp))
1415 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
1420 work1(i,k,1) = pvtr*rslopeb(i,k,1)*denfac(i,k)/delz(i,k,j)
1421 work1(i,k,2) = pvts*rslopeb(i,k,2)*denfac(i,k)/delz(i,k,j)
1422 numdt = max(nint(max(work1(i,k,1),work1(i,k,2))*dtcld+.5),1)
1423 if(numdt.ge.mstep) mstep = numdt
1429 ! falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)/mstep(i)
1430 ! falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)/mstep(i)
1431 falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)*rmstep
1432 falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)*rmstep
1433 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
1434 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
1435 ! qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcld/den(i,k,j),0.)
1436 ! qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcld/den(i,k,j),0.)
1437 dtcldden = dtcld/den(i,k,j)
1438 qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcldden,0.)
1439 qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcldden,0.)
1441 do k = kte-1, kts, -1
1442 falk(i,k,1) = den(i,k,j)*qrs(i,k,1)*work1(i,k,1)*rmstep
1443 falk(i,k,2) = den(i,k,j)*qrs(i,k,2)*work1(i,k,2)*rmstep
1444 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
1445 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
1446 dtcldden = dtcld/den(i,k,j)
1447 rdelz = 1./delz(i,k,j)
1448 qrs(i,k,1) = max(qrs(i,k,1)-(falk(i,k,1)-falk(i,k+1,1) &
1449 *delz(i,k+1,j)*rdelz)*dtcldden,0.)
1450 qrs(i,k,2) = max(qrs(i,k,2)-(falk(i,k,2)-falk(i,k+1,2) &
1451 *delz(i,k+1,j)*rdelz)*dtcldden,0.)
1454 if(t(i,k,j).gt.t0c.and.qrs(i,k,2).gt.0.) then
1455 !----------------------------------------------------------------
1456 ! psmlt: melting of snow [HL A33] [RH83 A25]
1458 !----------------------------------------------------------------
1460 ! work2(i,k)= venfac(p(i,k),t(i,k,j),den(i,k,j))
1461 work2(i,k)= (exp(log(((1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))) &
1462 /((t(i,k,j))+120.)/(den(i,k,j)))/(8.794e-5 &
1463 *exp(log(t(i,k,j))*(1.81))/p(i,k,j)))) &
1464 *((.3333333)))/sqrt((1.496e-6*((t(i,k,j)) &
1465 *sqrt(t(i,k,j)))/((t(i,k,j))+120.)/(den(i,k,j)))) &
1466 *sqrt(sqrt(den0/(den(i,k,j)))))
1467 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
1468 ! psmlt(i,k) = xka(t(i,k,j),den(i,k,j))/xlf*(t0c-t(i,k,j))*pi/2. &
1469 ! *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
1470 ! *work2(i,k)*coeres)
1471 psmlt(i,k) = (1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))) &
1472 /((t(i,k,j))+120.)/(den(i,k,j)) )*(den(i,k,j))) &
1473 /xlf*(t0c-t(i,k,j))*pi/2. &
1474 *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
1476 psmlt(i,k) = min(max(psmlt(i,k)*dtcld/mstep, &
1477 -qrs(i,k,2)/mstep),0.)
1478 qrs(i,k,2) = qrs(i,k,2) + psmlt(i,k)
1479 qrs(i,k,1) = qrs(i,k,1) - psmlt(i,k)
1480 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*psmlt(i,k)
1484 !---------------------------------------------------------------
1485 ! Vice [ms-1] : fallout of ice crystal [HDC 5a]
1486 !---------------------------------------------------------------
1490 if(qci(i,k,2).le.0.) then
1493 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
1494 ! diameter = min(dicon * sqrt(xmi),dimax)
1495 diameter = max(min(dicon * sqrt(xmi),dimax), 1.e-25)
1496 work1c(i,k) = 1.49e4*exp(log(diameter)*(1.31))
1497 work2c(i,k) = work1c(i,k)/delz(i,k,j)
1499 numdt = max(nint(work2c(i,k)*dtcld+.5),1)
1500 if(numdt.ge.mstep) mstep = numdt
1505 falkc(i,k) = den(i,k,j)*qci(i,k,2)*work2c(i,k)/mstep
1507 fallc(i,k) = fallc(i,k)+falkc(i,k)
1509 qci(i,k,2) = max(qci(i,k,2)-falkc(i,k)*dtcld/den(i,k,j),0.)
1510 do k = kte-1, kts, -1
1511 falkc(i,k) = den(i,k,j)*qci(i,k,2)*work2c(i,k)/mstep
1513 fallc(i,k) = fallc(i,k)+falkc(i,k)
1515 qci(i,k,2) = max(qci(i,k,2)-(falkc(i,k)-falkc(i,k+1) &
1516 *delz(i,k+1,j)/delz(i,k,j))*dtcld/den(i,k,j),0.)
1521 !----------------------------------------------------------------
1522 ! rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
1524 fallsum = fall(i,1,1)+fall(i,1,2)+fallc(i,1)
1525 fallsum_qsi = fall(i,1,2)+fallc(i,1)
1527 if(fallsum.gt.0.) then
1528 rainncv(i,j) = fallsum*delz(i,1,j)/denr*dtcld*1000.
1529 rain(i,j) = fallsum*delz(i,1,j)/denr*dtcld*1000. + rain(i,j)
1532 if(fallsum.gt.0.)sr(i,j)=fallsum_qsi*delz(i,kts,j)/denr*dtcld*1000. &
1533 /(rainncv(i,j)+1.e-12)
1535 !---------------------------------------------------------------
1536 ! pimlt: instantaneous melting of cloud ice [HL A47] [RH83 A28]
1538 !---------------------------------------------------------------
1540 supcol = t0c-t(i,k,j)
1542 if(supcol.lt.0.) xlf = xlf0
1543 if(supcol.lt.0.and.qci(i,k,2).gt.0.) then
1544 qci(i,k,1) = qci(i,k,1) + qci(i,k,2)
1545 t(i,k,j) = t(i,k,j) - xlf/cpm(i,k)*qci(i,k,2)
1548 !---------------------------------------------------------------
1549 ! pihmf: homogeneous freezing of cloud water below -40c [HL A45]
1551 !---------------------------------------------------------------
1552 if(supcol.gt.40..and.qci(i,k,1).gt.0.) then
1553 qci(i,k,2) = qci(i,k,2) + qci(i,k,1)
1554 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*qci(i,k,1)
1557 !---------------------------------------------------------------
1558 ! pihtf: heterogeneous freezing of cloud water [HL A44]
1560 !---------------------------------------------------------------
1561 if(supcol.gt.0..and.qci(i,k,1).gt.0.) then
1562 supcolt=min(supcol,50.)
1563 ! pfrzdtc = min(pfrz1*(exp(pfrz2*supcol)-1.) &
1564 ! *den(i,k,j)/denr/xncr*qci(i,k,1)**2*dtcld,qci(i,k,1))
1565 pfrzdtc = min(pfrz1*(exp(pfrz2*supcolt)-1.) &
1566 *den(i,k,j)/denr/xncr*qci(i,k,1)*qci(i,k,1)*dtcld,qci(i,k,1))
1567 qci(i,k,2) = qci(i,k,2) + pfrzdtc
1568 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*pfrzdtc
1569 qci(i,k,1) = qci(i,k,1)-pfrzdtc
1571 !---------------------------------------------------------------
1572 ! psfrz: freezing of rain water [HL A20] [LFO 45]
1574 !---------------------------------------------------------------
1575 if(supcol.gt.0..and.qrs(i,k,1).gt.0.) then
1576 supcolt=min(supcol,50.)
1577 ! pfrzdtr = min(20.*pi**2*pfrz1*n0r*denr/den(i,k,j) &
1578 ! *(exp(pfrz2*supcol)-1.)*rslope(i,k,1)**7*dtcld, &
1580 temp = rslope(i,k,1)
1581 temp = temp*temp*temp*temp*temp*temp*temp
1582 pfrzdtr = min(20.*(pi*pi)*pfrz1*n0r*denr/den(i,k,j) &
1583 *(exp(pfrz2*supcolt)-1.)*temp*dtcld, &
1585 qrs(i,k,2) = qrs(i,k,2) + pfrzdtr
1586 t(i,k,j) = t(i,k,j) + xlf/cpm(i,k)*pfrzdtr
1587 qrs(i,k,1) = qrs(i,k,1)-pfrzdtr
1591 !----------------------------------------------------------------
1592 ! rsloper: reverse of the slope parameter of the rain(m)
1593 ! xka: thermal conductivity of air(jm-1s-1k-1)
1594 ! work1: the thermodynamic term in the denominator associated with
1595 ! heat conduction and vapor diffusion
1597 ! work2: parameter associated with the ventilation effects(y93)
1600 if(qrs(i,k,1).le.qcrmin)then
1601 rslope(i,k,1) = rslopermax
1602 rslopeb(i,k,1) = rsloperbmax
1603 rslope2(i,k,1) = rsloper2max
1604 rslope3(i,k,1) = rsloper3max
1606 ! rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k,j))
1607 rslope(i,k,1) = 1./(sqrt(sqrt(pidn0r/((qrs(i,k,1))*(den(i,k,j))))))
1608 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
1609 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
1610 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
1612 if(qrs(i,k,2).le.qcrmin)then
1613 rslope(i,k,2) = rslopesmax
1614 rslopeb(i,k,2) = rslopesbmax
1615 rslope2(i,k,2) = rslopes2max
1616 rslope3(i,k,2) = rslopes3max
1618 ! rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k,j),n0sfac(i,k))
1619 rslope(i,k,2) = 1./(sqrt(sqrt(pidn0s*(n0sfac(i,k))/((qrs(i,k,2)) &
1621 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
1622 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
1623 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
1628 ! work1(i,k,1) = diffac(xl(i,k),p(i,k,j),t(i,k,j),den(i,k,j),qs(i,k,1))
1629 work1(i,k,1) = ((((den(i,k,j))*(xl(i,k))*(xl(i,k)))*((t(i,k,j))+120.) &
1630 *(den(i,k,j)))/(1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))))&
1631 *(den(i,k,j))*(rv*(t(i,k,j))*(t(i,k,j))))) &
1632 + p(i,k,j)/((qs(i,k,1))*(8.794e-5*exp(log(t(i,k,j))*(1.81))))
1633 ! work1(i,k,2) = diffac(xls,p(i,k,j),t(i,k,j),den(i,k,j),qs(i,k,2))
1634 work1(i,k,2) = ((((den(i,k,j))*(xls)*(xls))*((t(i,k,j))+120.)*(den(i,k,j)))&
1635 /(1.414e3*(1.496e-6*((t(i,k,j))*sqrt(t(i,k,j))))*(den(i,k,j)) &
1636 *(rv*(t(i,k,j))*(t(i,k,j)))) &
1637 + p(i,k,j)/(qs(i,k,2)*(8.794e-5*exp(log(t(i,k,j))*(1.81)))))
1638 ! work2(i,k) = venfac(p(i,k,j),t(i,k,j),den(i,k,j))
1639 work2(i,k) = (exp(.3333333*log(((1.496e-6 * ((t(i,k,j))*sqrt(t(i,k,j)))) &
1640 *p(i,k,j))/(((t(i,k,j))+120.)*den(i,k,j)*(8.794e-5 &
1641 *exp(log(t(i,k,j))*(1.81))))))*sqrt(sqrt(den0/(den(i,k,j))))) &
1642 /sqrt((1.496e-6*((t(i,k,j))*sqrt(t(i,k,j)))) &
1643 /(((t(i,k,j))+120.)*den(i,k,j)))
1646 !===============================================================
1648 ! warm rain processes
1650 ! - follows the processes in RH83 and LFO except for autoconcersion
1652 !===============================================================
1655 supsat = max(q(i,k,j),qmin)-qs(i,k,1)
1656 satdt = supsat/dtcld
1657 !---------------------------------------------------------------
1658 ! praut: auto conversion rate from cloud to rain [HDC 16]
1660 !---------------------------------------------------------------
1661 if(qci(i,k,1).gt.qc0) then
1662 praut(i,k) = qck1*exp(log(qci(i,k,1))*((7./3.)))
1663 praut(i,k) = min(praut(i,k),qci(i,k,1)/dtcld)
1665 !---------------------------------------------------------------
1666 ! pracw: accretion of cloud water by rain [HL A40] [LFO 51]
1668 !---------------------------------------------------------------
1669 if(qrs(i,k,1).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
1670 pracw(i,k) = min(pacrr*rslope3(i,k,1)*rslopeb(i,k,1) &
1671 *qci(i,k,1)*denfac(i,k),qci(i,k,1)/dtcld)
1673 !---------------------------------------------------------------
1674 ! prevp: evaporation/condensation rate of rain [HDC 14]
1676 !---------------------------------------------------------------
1677 if(qrs(i,k,1).gt.0.) then
1678 coeres = rslope2(i,k,1)*sqrt(rslope(i,k,1)*rslopeb(i,k,1))
1679 prevp(i,k) = (rh(i,k,1)-1.)*(precr1*rslope2(i,k,1) &
1680 +precr2*work2(i,k)*coeres)/work1(i,k,1)
1681 if(prevp(i,k).lt.0.) then
1682 prevp(i,k) = max(prevp(i,k),-qrs(i,k,1)/dtcld)
1683 prevp(i,k) = max(prevp(i,k),satdt/2)
1685 prevp(i,k) = min(prevp(i,k),satdt/2)
1690 !===============================================================
1692 ! cold rain processes
1694 ! - follows the revised ice microphysics processes in HDC
1695 ! - the processes same as in RH83 and RH84 and LFO behave
1696 ! following ice crystal hapits defined in HDC, inclduing
1697 ! intercept parameter for snow (n0s), ice crystal number
1698 ! concentration (ni), ice nuclei number concentration
1699 ! (n0i), ice diameter (d)
1701 !===============================================================
1705 supcol = t0c-t(i,k,j)
1706 supsat = max(q(i,k,j),qmin)-qs(i,k,2)
1707 satdt = supsat/dtcld
1709 !-------------------------------------------------------------
1710 ! Ni: ice crystal number concentraiton [HDC 5c]
1711 !-------------------------------------------------------------
1712 ! xni(i,k) = min(max(5.38e7*(den(i,k,j) &
1713 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
1714 temp = (den(i,k,j)*max(qci(i,k,2),qmin))
1715 temp = sqrt(sqrt(temp*temp*temp))
1716 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
1717 eacrs = exp(0.07*(-supcol))
1719 if(supcol.gt.0) then
1720 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,2).gt.qmin) then
1721 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
1722 diameter = min(dicon * sqrt(xmi),dimax)
1723 vt2i = 1.49e4*diameter**1.31
1724 vt2s = pvts*rslopeb(i,k,2)*denfac(i,k)
1725 !-------------------------------------------------------------
1726 ! psaci: Accretion of cloud ice by rain [HDC 10]
1728 !-------------------------------------------------------------
1729 acrfac = 2.*rslope3(i,k,2)+2.*diameter*rslope2(i,k,2) &
1730 +diameter**2*rslope(i,k,2)
1731 psaci(i,k) = pi*qci(i,k,2)*eacrs*n0s*n0sfac(i,k) &
1732 *abs(vt2s-vt2i)*acrfac/4.
1735 !-------------------------------------------------------------
1736 ! psacw: Accretion of cloud water by snow [HL A7] [LFO 24]
1737 ! (T<T0: C->S, and T>=T0: C->R)
1738 !-------------------------------------------------------------
1739 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
1740 psacw(i,k) = min(pacrc*n0sfac(i,k)*rslope3(i,k,2) &
1741 *rslopeb(i,k,2)*qci(i,k,1)*denfac(i,k) &
1742 ! ,qci(i,k,1)/dtcld)
1745 if(supcol .gt. 0) then
1746 !-------------------------------------------------------------
1747 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
1748 ! (T<T0: V->I or I->V)
1749 !-------------------------------------------------------------
1750 if(qci(i,k,2).gt.0.and.ifsat.ne.1) then
1751 xmi = den(i,k,j)*qci(i,k,2)/xni(i,k)
1752 diameter = dicon * sqrt(xmi)
1753 pidep(i,k) = 4.*diameter*xni(i,k)*(rh(i,k,2)-1.)/work1(i,k,2)
1754 supice = satdt-prevp(i,k)
1755 if(pidep(i,k).lt.0.) then
1756 ! pidep(i,k) = max(max(pidep(i,k),satdt/2),supice)
1757 ! pidep(i,k) = max(pidep(i,k),-qci(i,k,2)/dtcld)
1758 pidep(i,k) = max(max(pidep(i,k),satdt*.5),supice)
1759 pidep(i,k) = max(pidep(i,k),-qci(i,k,2)*rdtcld)
1761 ! pidep(i,k) = min(min(pidep(i,k),satdt/2),supice)
1762 pidep(i,k) = min(min(pidep(i,k),satdt*.5),supice)
1764 if(abs(prevp(i,k)+pidep(i,k)).ge.abs(satdt)) ifsat = 1
1766 !-------------------------------------------------------------
1767 ! psdep: deposition/sublimation rate of snow [HDC 14]
1769 !-------------------------------------------------------------
1770 if(qrs(i,k,2).gt.0..and.ifsat.ne.1) then
1771 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
1772 psdep(i,k) = (rh(i,k,2)-1.)*n0sfac(i,k) &
1773 *(precs1*rslope2(i,k,2)+precs2 &
1774 *work2(i,k)*coeres)/work1(i,k,2)
1775 supice = satdt-prevp(i,k)-pidep(i,k)
1776 if(psdep(i,k).lt.0.) then
1777 ! psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)/dtcld)
1778 ! psdep(i,k) = max(max(psdep(i,k),satdt/2),supice)
1779 psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)*rdtcld)
1780 psdep(i,k) = max(max(psdep(i,k),satdt*.5),supice)
1782 ! psdep(i,k) = min(min(psdep(i,k),satdt/2),supice)
1783 psdep(i,k) = min(min(psdep(i,k),satdt*.5),supice)
1785 if(abs(prevp(i,k)+pidep(i,k)+psdep(i,k)).ge.abs(satdt)) &
1788 !-------------------------------------------------------------
1789 ! pigen: generation(nucleation) of ice from vapor [HL A50] [HDC 7-8]
1791 !-------------------------------------------------------------
1792 if(supsat.gt.0.and.ifsat.ne.1) then
1793 supice = satdt-prevp(i,k)-pidep(i,k)-psdep(i,k)
1794 xni0 = 1.e3*exp(0.1*supcol)
1795 roqi0 = 4.92e-11*exp(log(xni0)*(1.33))
1796 pigen(i,k) = max(0.,(roqi0/den(i,k,j)-max(qci(i,k,2),0.)) &
1799 pigen(i,k) = min(min(pigen(i,k),satdt),supice)
1802 !-------------------------------------------------------------
1803 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
1805 !-------------------------------------------------------------
1806 if(qci(i,k,2).gt.0.) then
1807 qimax = roqimax/den(i,k,j)
1808 ! psaut(i,k) = max(0.,(qci(i,k,2)-qimax)/dtcld)
1809 psaut(i,k) = max(0.,(qci(i,k,2)-qimax)*rdtcld)
1812 !-------------------------------------------------------------
1813 ! psevp: Evaporation of melting snow [HL A35] [RH83 A27]
1815 !-------------------------------------------------------------
1816 if(supcol.lt.0.) then
1817 if(qrs(i,k,2).gt.0..and.rh(i,k,1).lt.1.) &
1818 psevp(i,k) = psdep(i,k)*work1(i,k,2)/work1(i,k,1)
1819 ! psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)/dtcld),0.)
1820 psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)*rdtcld),0.)
1825 !----------------------------------------------------------------
1826 ! check mass conservation of generation terms and feedback to the
1830 if(t(i,k,j).le.t0c) then
1834 value = max(qmin,qci(i,k,1))
1835 source = (praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
1836 if (source.gt.value) then
1837 factor = value/source
1838 praut(i,k) = praut(i,k)*factor
1839 pracw(i,k) = pracw(i,k)*factor
1840 psacw(i,k) = psacw(i,k)*factor
1845 value = max(qmin,qci(i,k,2))
1846 source = (psaut(i,k)+psaci(i,k)-pigen(i,k)-pidep(i,k))*dtcld
1847 if (source.gt.value) then
1848 factor = value/source
1849 psaut(i,k) = psaut(i,k)*factor
1850 psaci(i,k) = psaci(i,k)*factor
1851 pigen(i,k) = pigen(i,k)*factor
1852 pidep(i,k) = pidep(i,k)*factor
1858 value = max(qmin,qrs(i,k,1))
1859 source = (-praut(i,k)-pracw(i,k)-prevp(i,k))*dtcld
1860 if (source.gt.value) then
1861 factor = value/source
1862 praut(i,k) = praut(i,k)*factor
1863 pracw(i,k) = pracw(i,k)*factor
1864 prevp(i,k) = prevp(i,k)*factor
1869 value = max(qmin,qrs(i,k,2))
1870 source = (-psdep(i,k)-psaut(i,k)-psaci(i,k)-psacw(i,k))*dtcld
1871 if (source.gt.value) then
1872 factor = value/source
1873 psdep(i,k) = psdep(i,k)*factor
1874 psaut(i,k) = psaut(i,k)*factor
1875 psaci(i,k) = psaci(i,k)*factor
1876 psacw(i,k) = psacw(i,k)*factor
1879 work2(i,k)=-(prevp(i,k)+psdep(i,k)+pigen(i,k)+pidep(i,k))
1881 q(i,k,j) = q(i,k,j)+work2(i,k)*dtcld
1882 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
1883 +psacw(i,k))*dtcld,0.)
1884 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
1885 +prevp(i,k))*dtcld,0.)
1886 qci(i,k,2) = max(qci(i,k,2)-(psaut(i,k)+psaci(i,k) &
1887 -pigen(i,k)-pidep(i,k))*dtcld,0.)
1888 qrs(i,k,2) = max(qrs(i,k,2)+(psdep(i,k)+psaut(i,k) &
1889 +psaci(i,k)+psacw(i,k))*dtcld,0.)
1891 xlwork2 = -xls*(psdep(i,k)+pidep(i,k)+pigen(i,k)) &
1892 -xl(i,k)*prevp(i,k)-xlf*psacw(i,k)
1893 t(i,k,j) = t(i,k,j)-xlwork2/cpm(i,k)*dtcld
1898 value = max(qmin,qci(i,k,1))
1899 source=(praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
1900 if (source.gt.value) then
1901 factor = value/source
1902 praut(i,k) = praut(i,k)*factor
1903 pracw(i,k) = pracw(i,k)*factor
1904 psacw(i,k) = psacw(i,k)*factor
1909 value = max(qmin,qrs(i,k,1))
1910 source = (-praut(i,k)-pracw(i,k)-prevp(i,k)-psacw(i,k))*dtcld
1911 if (source.gt.value) then
1912 factor = value/source
1913 praut(i,k) = praut(i,k)*factor
1914 pracw(i,k) = pracw(i,k)*factor
1915 prevp(i,k) = prevp(i,k)*factor
1916 psacw(i,k) = psacw(i,k)*factor
1921 value = max(qcrmin,qrs(i,k,2))
1922 source=(-psevp(i,k))*dtcld
1923 if (source.gt.value) then
1924 factor = value/source
1925 psevp(i,k) = psevp(i,k)*factor
1927 work2(i,k)=-(prevp(i,k)+psevp(i,k))
1929 q(i,k,j) = q(i,k,j)+work2(i,k)*dtcld
1930 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
1931 +psacw(i,k))*dtcld,0.)
1932 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
1933 +prevp(i,k) +psacw(i,k))*dtcld,0.)
1934 qrs(i,k,2) = max(qrs(i,k,2)+psevp(i,k)*dtcld,0.)
1936 xlwork2 = -xl(i,k)*(prevp(i,k)+psevp(i,k))
1937 t(i,k,j) = t(i,k,j)-xlwork2/cpm(i,k)*dtcld
1941 ! Inline expansion for fpvs
1942 ! qs(i,k,1) = fpvs(t(i,k,j),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1943 ! qs(i,k,2) = fpvs(t(i,k,j),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
1953 xbi=xai+hsub/(rv*ttp)
1957 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
1958 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k,j) - qs(i,k,1))
1959 qs(i,k,1) = max(qs(i,k,1),qmin)
1962 !----------------------------------------------------------------
1963 ! pcond: condensational/evaporational rate of cloud water [HL A46] [RH83 A6]
1964 ! if there exists additional water vapor condensated/if
1965 ! evaporation of cloud water is not enough to remove subsaturation
1968 ! work1(i,k,1) = conden(t(i,k,j),q(i,k,j),qs(i,k,1),xl(i,k),cpm(i,k))
1969 work1(i,k,1) = ((max(q(i,k,j),qmin)-(qs(i,k,1)))/(1.+(xl(i,k)) &
1970 *(xl(i,k))/(rv*(cpm(i,k)))*(qs(i,k,1)) &
1971 /((t(i,k,j))*(t(i,k,j)))))
1972 work2(i,k) = qci(i,k,1)+work1(i,k,1)
1973 pcond(i,k) = min(max(work1(i,k,1)/dtcld,0.),max(q(i,k,j),0.)/dtcld)
1974 if(qci(i,k,1).gt.0..and.work1(i,k,1).lt.0.) &
1975 pcond(i,k) = max(work1(i,k,1),-qci(i,k,1))/dtcld
1976 q(i,k,j) = q(i,k,j)-pcond(i,k)*dtcld
1977 qci(i,k,1) = max(qci(i,k,1)+pcond(i,k)*dtcld,0.)
1978 t(i,k,j) = t(i,k,j)+pcond(i,k)*xl(i,k)/cpm(i,k)*dtcld
1982 !----------------------------------------------------------------
1983 ! padding for small values
1986 if(qci(i,k,1).le.qmin) qci(i,k,1) = 0.0
1987 if(qci(i,k,2).le.qmin) qci(i,k,2) = 0.0
1992 th(i,k,j)=t(i,k,j)/pii(i,k,j)
1993 qc(i,k,j) = qci(i,k,1)
1994 qi(i,k,j) = qci(i,k,2)
1995 qr(i,k,j) = qrs(i,k,1)
1996 qqs(i,k,j) = qrs(i,k,2)
2005 END SUBROUTINE wsm52d
2010 !===================================================================
2012 SUBROUTINE wsm52D(t, q, qci, qrs, den, p, delz &
2013 ,delt,g, cpd, cpv, rd, rv, t0c &
2015 ,XLS, XLV0, XLF0, den0, denr &
2020 ,ids,ide, jds,jde, kds,kde &
2021 ,ims,ime, jms,jme, kms,kme &
2022 ,its,ite, jts,jte, kts,kte &
2025 !-------------------------------------------------------------------
2027 !-------------------------------------------------------------------
2028 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde , &
2029 ims,ime, jms,jme, kms,kme , &
2030 its,ite, jts,jte, kts,kte, &
2032 REAL, DIMENSION( its:ite , kts:kte ), &
2035 REAL, DIMENSION( its:ite , kts:kte, 2 ), &
2039 REAL, DIMENSION( ims:ime , kms:kme ), &
2042 REAL, DIMENSION( ims:ime , kms:kme ), &
2047 REAL, INTENT(IN ) :: delt, &
2065 REAL, DIMENSION( ims:ime ), &
2066 INTENT(INOUT) :: rain, &
2070 REAL, DIMENSION( ims:ime, jms:jme ), OPTIONAL, &
2071 INTENT(INOUT) :: snow, &
2075 REAL, DIMENSION( its:ite , kts:kte , 2) :: &
2086 REAL, DIMENSION( its:ite , kts:kte ) :: &
2098 REAL, DIMENSION( its:ite , kts:kte ) :: &
2111 INTEGER, DIMENSION( its:ite ) :: &
2114 REAL, DIMENSION(its:ite) :: rmstep
2115 REAL dtcldden, rdelz, rdtcld
2116 LOGICAL, DIMENSION( its:ite ) :: flgcld
2118 #define WSM_NO_CONDITIONAL_IN_VECTOR
2119 #ifdef WSM_NO_CONDITIONAL_IN_VECTOR
2120 REAL, DIMENSION(its:ite) :: xal, xbl
2124 cpmcal, xlcal, lamdar, lamdas, diffus, &
2125 viscos, xka, venfac, conden, diffac, &
2126 x, y, z, a, b, c, d, e, &
2127 qdt, holdrr, holdrs, supcol, supcolt, pvt, &
2128 coeres, supsat, dtcld, xmi, eacrs, satdt, &
2130 qimax, diameter, xni0, roqi0, &
2131 fallsum, fallsum_qsi, xlwork2, factor, source, &
2132 value, xlf, pfrzdtc, pfrzdtr, supice, holdc, holdci
2133 ! variables for optimization
2134 REAL, DIMENSION( its:ite ) :: tvec1
2136 INTEGER :: i, j, k, mstepmax, &
2137 iprt, latd, lond, loop, loops, ifsat, n
2138 ! Temporaries used for inlining fpvs function
2139 REAL :: dldti, xb, xai, tr, xbi, xa, hvap, cvap, hsub, dldt, ttp
2142 !=================================================================
2143 ! compute internal functions
2145 cpmcal(x) = cpd*(1.-max(x,qmin))+max(x,qmin)*cpv
2146 xlcal(x) = xlv0-xlv1*(x-t0c)
2147 !----------------------------------------------------------------
2148 ! size distributions: (x=mixing ratio, y=air density):
2149 ! valid for mixing ratio > 1.e-9 kg/kg.
2151 ! Optimizatin : A**B => exp(log(A)*(B))
2152 lamdar(x,y)= sqrt(sqrt(pidn0r/(x*y))) ! (pidn0r/(x*y))**.25
2153 lamdas(x,y,z)= sqrt(sqrt(pidn0s*z/(x*y))) ! (pidn0s*z/(x*y))**.25
2155 !----------------------------------------------------------------
2156 ! diffus: diffusion coefficient of the water vapor
2157 ! viscos: kinematic viscosity(m2s-1)
2158 ! diffus(x,y) = 8.794e-5 * exp(log(x)*(1.81)) / y ! 8.794e-5*x**1.81/y
2159 ! viscos(x,y) = 1.496e-6 * (x*sqrt(x)) /(x+120.)/y ! 1.496e-6*x**1.5/(x+120.)/y
2160 ! xka(x,y) = 1.414e3*viscos(x,y)*y
2161 ! diffac(a,b,c,d,e) = d*a*a/(xka(c,d)*rv*c*c)+1./(e*diffus(c,b))
2162 ! venfac(a,b,c) = exp(log((viscos(b,c)/diffus(b,a)))*((.3333333))) &
2163 ! /sqrt(viscos(b,c))*sqrt(sqrt(den0/c))
2164 ! conden(a,b,c,d,e) = (max(b,qmin)-c)/(1.+d*d/(rv*e)*c/(a*a))
2169 !----------------------------------------------------------------
2170 ! paddint 0 for negative values generated by dynamics
2174 qci(i,k,1) = max(qci(i,k,1),0.0)
2175 qrs(i,k,1) = max(qrs(i,k,1),0.0)
2176 qci(i,k,2) = max(qci(i,k,2),0.0)
2177 qrs(i,k,2) = max(qrs(i,k,2),0.0)
2181 !----------------------------------------------------------------
2182 ! latent heat for phase changes and heat capacity. neglect the
2183 ! changes during microphysical process calculation
2188 cpm(i,k) = cpmcal(q(i,k))
2189 xl(i,k) = xlcal(t(i,k))
2193 !----------------------------------------------------------------
2194 ! compute the minor time steps.
2196 loops = max(nint(delt/dtcldcr),1)
2198 if(delt.le.dtcldcr) dtcld = delt
2202 !----------------------------------------------------------------
2203 ! initialize the large scale variables
2212 ! denfac(i,k) = sqrt(den0/den(i,k))
2216 CALL VREC( tvec1(its), den(its,k), ite-its+1)
2218 tvec1(i) = tvec1(i)*den0
2220 CALL VSQRT( denfac(its,k), tvec1(its), ite-its+1)
2223 ! Inline expansion for fpvs
2224 ! qs(i,k,1) = fpvs(t(i,k),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
2225 ! qs(i,k,2) = fpvs(t(i,k),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
2235 xbi=xai+hsub/(rv*ttp)
2237 ! this is for compilers where the conditional inhibits vectorization
2238 #ifdef WSM_NO_CONDITIONAL_IN_VECTOR
2241 if(t(i,k).lt.ttp) then
2252 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
2253 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k) - qs(i,k,1))
2254 qs(i,k,1) = max(qs(i,k,1),qmin)
2255 rh(i,k,1) = max(q(i,k) / qs(i,k,1),qmin)
2256 qs(i,k,2)=psat*exp(logtr*(xal(i))+xbl(i)*(1.-tr))
2257 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k) - qs(i,k,2))
2258 qs(i,k,2) = max(qs(i,k,2),qmin)
2259 rh(i,k,2) = max(q(i,k) / qs(i,k,2),qmin)
2267 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
2268 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k) - qs(i,k,1))
2269 qs(i,k,1) = max(qs(i,k,1),qmin)
2270 rh(i,k,1) = max(q(i,k) / qs(i,k,1),qmin)
2271 if(t(i,k).lt.ttp) then
2272 qs(i,k,2)=psat*exp(logtr*(xai)+xbi*(1.-tr))
2274 qs(i,k,2)=psat*exp(logtr*(xa)+xb*(1.-tr))
2276 qs(i,k,2) = ep2 * qs(i,k,2) / (p(i,k) - qs(i,k,2))
2277 qs(i,k,2) = max(qs(i,k,2),qmin)
2278 rh(i,k,2) = max(q(i,k) / qs(i,k,2),qmin)
2283 !----------------------------------------------------------------
2284 ! initialize the variables for microphysical physics
2311 !----------------------------------------------------------------
2312 ! compute the fallout term:
2313 ! first, vertical terminal velosity for minor loops
2318 !---------------------------------------------------------------
2319 ! n0s: Intercept parameter for snow [m-4] [HDC 6]
2320 !---------------------------------------------------------------
2321 n0sfac(i,k) = max(min(exp(alpha*supcol),n0smax/n0s),1.)
2322 if(qrs(i,k,1).le.qcrmin)then
2323 rslope(i,k,1) = rslopermax
2324 rslopeb(i,k,1) = rsloperbmax
2325 rslope2(i,k,1) = rsloper2max
2326 rslope3(i,k,1) = rsloper3max
2328 rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k))
2329 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
2330 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
2331 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
2333 if(qrs(i,k,2).le.qcrmin)then
2334 rslope(i,k,2) = rslopesmax
2335 rslopeb(i,k,2) = rslopesbmax
2336 rslope2(i,k,2) = rslopes2max
2337 rslope3(i,k,2) = rslopes3max
2339 rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k),n0sfac(i,k))
2340 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
2341 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
2342 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
2344 !-------------------------------------------------------------
2345 ! Ni: ice crystal number concentraiton [HDC 5c]
2346 !-------------------------------------------------------------
2347 ! xni(i,k) = min(max(5.38e7*(den(i,k) &
2348 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
2349 temp = (den(i,k)*max(qci(i,k,2),qmin))
2350 temp = sqrt(sqrt(temp*temp*temp))
2351 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
2359 work1(i,k,1) = pvtr*rslopeb(i,k,1)*denfac(i,k)/delz(i,k)
2360 work1(i,k,2) = pvts*rslopeb(i,k,2)*denfac(i,k)/delz(i,k)
2361 numdt(i) = max(nint(max(work1(i,k,1),work1(i,k,2))*dtcld+.5),1)
2362 if(numdt(i).ge.mstep(i)) mstep(i) = numdt(i)
2366 if(mstepmax.le.mstep(i)) mstepmax = mstep(i)
2367 rmstep(i) = 1./mstep(i)
2373 if(n.le.mstep(i)) then
2374 ! falk(i,k,1) = den(i,k)*qrs(i,k,1)*work1(i,k,1)/mstep(i)
2375 ! falk(i,k,2) = den(i,k)*qrs(i,k,2)*work1(i,k,2)/mstep(i)
2376 falk(i,k,1) = den(i,k)*qrs(i,k,1)*work1(i,k,1)*rmstep(i)
2377 falk(i,k,2) = den(i,k)*qrs(i,k,2)*work1(i,k,2)*rmstep(i)
2378 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
2379 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
2380 ! qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcld/den(i,k),0.)
2381 ! qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcld/den(i,k),0.)
2382 dtcldden = dtcld/den(i,k)
2383 qrs(i,k,1) = max(qrs(i,k,1)-falk(i,k,1)*dtcldden,0.)
2384 qrs(i,k,2) = max(qrs(i,k,2)-falk(i,k,2)*dtcldden,0.)
2387 do k = kte-1, kts, -1
2389 if(n.le.mstep(i)) then
2390 falk(i,k,1) = den(i,k)*qrs(i,k,1)*work1(i,k,1)*rmstep(i)
2391 falk(i,k,2) = den(i,k)*qrs(i,k,2)*work1(i,k,2)*rmstep(i)
2392 fall(i,k,1) = fall(i,k,1)+falk(i,k,1)
2393 fall(i,k,2) = fall(i,k,2)+falk(i,k,2)
2394 dtcldden = dtcld/den(i,k)
2395 rdelz = 1./delz(i,k)
2396 qrs(i,k,1) = max(qrs(i,k,1)-(falk(i,k,1)-falk(i,k+1,1) &
2397 *delz(i,k+1)*rdelz)*dtcldden,0.)
2398 qrs(i,k,2) = max(qrs(i,k,2)-(falk(i,k,2)-falk(i,k+1,2) &
2399 *delz(i,k+1)*rdelz)*dtcldden,0.)
2405 if(n.le.mstep(i)) then
2406 if(t(i,k).gt.t0c.and.qrs(i,k,2).gt.0.) then
2407 !----------------------------------------------------------------
2408 ! psmlt: melting of snow [HL A33] [RH83 A25]
2410 !----------------------------------------------------------------
2412 ! work2(i,k)= venfac(p(i,k),t(i,k),den(i,k))
2413 work2(i,k)= (exp(log(((1.496e-6*((t(i,k))*sqrt(t(i,k))) &
2414 /((t(i,k))+120.)/(den(i,k)))/(8.794e-5 &
2415 *exp(log(t(i,k))*(1.81))/p(i,k)))) &
2416 *((.3333333)))/sqrt((1.496e-6*((t(i,k)) &
2417 *sqrt(t(i,k)))/((t(i,k))+120.)/(den(i,k)))) &
2418 *sqrt(sqrt(den0/(den(i,k)))))
2419 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
2420 ! psmlt(i,k) = xka(t(i,k),den(i,k))/xlf*(t0c-t(i,k))*pi/2. &
2421 ! *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
2422 ! *work2(i,k)*coeres)
2423 psmlt(i,k) = (1.414e3*(1.496e-6*((t(i,k))*sqrt(t(i,k))) &
2424 /((t(i,k))+120.)/(den(i,k)) )*(den(i,k))) &
2425 /xlf*(t0c-t(i,k))*pi/2. &
2426 *n0sfac(i,k)*(precs1*rslope2(i,k,2)+precs2 &
2428 psmlt(i,k) = min(max(psmlt(i,k)*dtcld/mstep(i), &
2429 -qrs(i,k,2)/mstep(i)),0.)
2430 qrs(i,k,2) = qrs(i,k,2) + psmlt(i,k)
2431 qrs(i,k,1) = qrs(i,k,1) - psmlt(i,k)
2432 t(i,k) = t(i,k) + xlf/cpm(i,k)*psmlt(i,k)
2438 !---------------------------------------------------------------
2439 ! Vice [ms-1] : fallout of ice crystal [HDC 5a]
2440 !---------------------------------------------------------------
2446 if(qci(i,k,2).le.0.) then
2449 xmi = den(i,k)*qci(i,k,2)/xni(i,k)
2450 ! diameter = min(dicon * sqrt(xmi),dimax)
2451 diameter = max(min(dicon * sqrt(xmi),dimax), 1.e-25)
2452 work1c(i,k) = 1.49e4*exp(log(diameter)*(1.31))
2453 work2c(i,k) = work1c(i,k)/delz(i,k)
2455 numdt(i) = max(nint(work2c(i,k)*dtcld+.5),1)
2456 if(numdt(i).ge.mstep(i)) mstep(i) = numdt(i)
2460 if(mstepmax.le.mstep(i)) mstepmax = mstep(i)
2466 if(n.le.mstep(i)) then
2467 falkc(i,k) = den(i,k)*qci(i,k,2)*work2c(i,k)/mstep(i)
2469 fallc(i,k) = fallc(i,k)+falkc(i,k)
2471 qci(i,k,2) = max(qci(i,k,2)-falkc(i,k)*dtcld/den(i,k),0.)
2474 do k = kte-1, kts, -1
2476 if(n.le.mstep(i)) then
2477 falkc(i,k) = den(i,k)*qci(i,k,2)*work2c(i,k)/mstep(i)
2479 fallc(i,k) = fallc(i,k)+falkc(i,k)
2481 qci(i,k,2) = max(qci(i,k,2)-(falkc(i,k)-falkc(i,k+1) &
2482 *delz(i,k+1)/delz(i,k))*dtcld/den(i,k),0.)
2489 !----------------------------------------------------------------
2490 ! rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
2493 fallsum = fall(i,1,1)+fall(i,1,2)+fallc(i,1)
2494 fallsum_qsi = fall(i,1,2)+fallc(i,1)
2496 if(fallsum.gt.0.) then
2497 rainncv(i) = fallsum*delz(i,1)/denr*dtcld*1000.
2498 rain(i) = fallsum*delz(i,1)/denr*dtcld*1000. + rain(i)
2500 IF ( PRESENT (snowncv) .AND. PRESENT (snow)) THEN
2502 if(fallsum_qsi.gt.0.) then
2503 snowncv(i,lat) = fallsum_qsi*delz(i,kts)/denr*dtcld*1000.
2504 snow(i,lat) = fallsum_qsi*delz(i,kts)/denr*dtcld*1000. + snow(i,lat)
2508 if(fallsum.gt.0.)sr(i)=fallsum_qsi*delz(i,kts)/denr*dtcld*1000. &
2509 /(rainncv(i)+1.e-12)
2512 !---------------------------------------------------------------
2513 ! pimlt: instantaneous melting of cloud ice [HL A47] [RH83 A28]
2515 !---------------------------------------------------------------
2520 if(supcol.lt.0.) xlf = xlf0
2521 if(supcol.lt.0.and.qci(i,k,2).gt.0.) then
2522 qci(i,k,1) = qci(i,k,1) + qci(i,k,2)
2523 t(i,k) = t(i,k) - xlf/cpm(i,k)*qci(i,k,2)
2526 !---------------------------------------------------------------
2527 ! pihmf: homogeneous freezing of cloud water below -40c [HL A45]
2529 !---------------------------------------------------------------
2530 if(supcol.gt.40..and.qci(i,k,1).gt.0.) then
2531 qci(i,k,2) = qci(i,k,2) + qci(i,k,1)
2532 t(i,k) = t(i,k) + xlf/cpm(i,k)*qci(i,k,1)
2535 !---------------------------------------------------------------
2536 ! pihtf: heterogeneous freezing of cloud water [HL A44]
2538 !---------------------------------------------------------------
2539 if(supcol.gt.0..and.qci(i,k,1).gt.0.) then
2540 supcolt=min(supcol,50.)
2541 ! pfrzdtc = min(pfrz1*(exp(pfrz2*supcol)-1.) &
2542 ! *den(i,k)/denr/xncr*qci(i,k,1)**2*dtcld,qci(i,k,1))
2543 pfrzdtc = min(pfrz1*(exp(pfrz2*supcolt)-1.) &
2544 *den(i,k)/denr/xncr*qci(i,k,1)*qci(i,k,1)*dtcld,qci(i,k,1))
2545 qci(i,k,2) = qci(i,k,2) + pfrzdtc
2546 t(i,k) = t(i,k) + xlf/cpm(i,k)*pfrzdtc
2547 qci(i,k,1) = qci(i,k,1)-pfrzdtc
2549 !---------------------------------------------------------------
2550 ! psfrz: freezing of rain water [HL A20] [LFO 45]
2552 !---------------------------------------------------------------
2553 if(supcol.gt.0..and.qrs(i,k,1).gt.0.) then
2554 supcolt=min(supcol,50.)
2555 ! pfrzdtr = min(20.*pi**2*pfrz1*n0r*denr/den(i,k) &
2556 ! *(exp(pfrz2*supcol)-1.)*rslope(i,k,1)**7*dtcld, &
2558 temp = rslope(i,k,1)
2559 temp = temp*temp*temp*temp*temp*temp*temp
2560 pfrzdtr = min(20.*(pi*pi)*pfrz1*n0r*denr/den(i,k) &
2561 *(exp(pfrz2*supcolt)-1.)*temp*dtcld, &
2563 qrs(i,k,2) = qrs(i,k,2) + pfrzdtr
2564 t(i,k) = t(i,k) + xlf/cpm(i,k)*pfrzdtr
2565 qrs(i,k,1) = qrs(i,k,1)-pfrzdtr
2570 !----------------------------------------------------------------
2571 ! rsloper: reverse of the slope parameter of the rain(m)
2572 ! xka: thermal conductivity of air(jm-1s-1k-1)
2573 ! work1: the thermodynamic term in the denominator associated with
2574 ! heat conduction and vapor diffusion
2576 ! work2: parameter associated with the ventilation effects(y93)
2580 if(qrs(i,k,1).le.qcrmin)then
2581 rslope(i,k,1) = rslopermax
2582 rslopeb(i,k,1) = rsloperbmax
2583 rslope2(i,k,1) = rsloper2max
2584 rslope3(i,k,1) = rsloper3max
2586 ! rslope(i,k,1) = 1./lamdar(qrs(i,k,1),den(i,k))
2587 rslope(i,k,1) = 1./(sqrt(sqrt(pidn0r/((qrs(i,k,1))*(den(i,k))))))
2588 rslopeb(i,k,1) = exp(log(rslope(i,k,1))*(bvtr))
2589 rslope2(i,k,1) = rslope(i,k,1)*rslope(i,k,1)
2590 rslope3(i,k,1) = rslope2(i,k,1)*rslope(i,k,1)
2592 if(qrs(i,k,2).le.qcrmin)then
2593 rslope(i,k,2) = rslopesmax
2594 rslopeb(i,k,2) = rslopesbmax
2595 rslope2(i,k,2) = rslopes2max
2596 rslope3(i,k,2) = rslopes3max
2598 ! rslope(i,k,2) = 1./lamdas(qrs(i,k,2),den(i,k),n0sfac(i,k))
2599 rslope(i,k,2) = 1./(sqrt(sqrt(pidn0s*(n0sfac(i,k))/((qrs(i,k,2)) &
2601 rslopeb(i,k,2) = exp(log(rslope(i,k,2))*(bvts))
2602 rslope2(i,k,2) = rslope(i,k,2)*rslope(i,k,2)
2603 rslope3(i,k,2) = rslope2(i,k,2)*rslope(i,k,2)
2610 ! work1(i,k,1) = diffac(xl(i,k),p(i,k),t(i,k),den(i,k),qs(i,k,1))
2611 work1(i,k,1) = ((((den(i,k))*(xl(i,k))*(xl(i,k)))*((t(i,k))+120.) &
2612 *(den(i,k)))/(1.414e3*(1.496e-6*((t(i,k))*sqrt(t(i,k))))&
2613 *(den(i,k))*(rv*(t(i,k))*(t(i,k))))) &
2614 + p(i,k)/((qs(i,k,1))*(8.794e-5*exp(log(t(i,k))*(1.81))))
2615 ! work1(i,k,2) = diffac(xls,p(i,k),t(i,k),den(i,k),qs(i,k,2))
2616 work1(i,k,2) = ((((den(i,k))*(xls)*(xls))*((t(i,k))+120.)*(den(i,k)))&
2617 /(1.414e3*(1.496e-6*((t(i,k))*sqrt(t(i,k))))*(den(i,k)) &
2618 *(rv*(t(i,k))*(t(i,k)))) &
2619 + p(i,k)/(qs(i,k,2)*(8.794e-5*exp(log(t(i,k))*(1.81)))))
2620 ! work2(i,k) = venfac(p(i,k),t(i,k),den(i,k))
2621 work2(i,k) = (exp(.3333333*log(((1.496e-6 * ((t(i,k))*sqrt(t(i,k)))) &
2622 *p(i,k))/(((t(i,k))+120.)*den(i,k)*(8.794e-5 &
2623 *exp(log(t(i,k))*(1.81))))))*sqrt(sqrt(den0/(den(i,k))))) &
2624 /sqrt((1.496e-6*((t(i,k))*sqrt(t(i,k)))) &
2625 /(((t(i,k))+120.)*den(i,k)))
2629 !===============================================================
2631 ! warm rain processes
2633 ! - follows the processes in RH83 and LFO except for autoconcersion
2635 !===============================================================
2639 supsat = max(q(i,k),qmin)-qs(i,k,1)
2640 satdt = supsat/dtcld
2641 !---------------------------------------------------------------
2642 ! praut: auto conversion rate from cloud to rain [HDC 16]
2644 !---------------------------------------------------------------
2645 if(qci(i,k,1).gt.qc0) then
2646 praut(i,k) = qck1*exp(log(qci(i,k,1))*((7./3.)))
2647 praut(i,k) = min(praut(i,k),qci(i,k,1)/dtcld)
2649 !---------------------------------------------------------------
2650 ! pracw: accretion of cloud water by rain [HL A40] [LFO 51]
2652 !---------------------------------------------------------------
2653 if(qrs(i,k,1).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
2654 pracw(i,k) = min(pacrr*rslope3(i,k,1)*rslopeb(i,k,1) &
2655 *qci(i,k,1)*denfac(i,k),qci(i,k,1)/dtcld)
2657 !---------------------------------------------------------------
2658 ! prevp: evaporation/condensation rate of rain [HDC 14]
2660 !---------------------------------------------------------------
2661 if(qrs(i,k,1).gt.0.) then
2662 coeres = rslope2(i,k,1)*sqrt(rslope(i,k,1)*rslopeb(i,k,1))
2663 prevp(i,k) = (rh(i,k,1)-1.)*(precr1*rslope2(i,k,1) &
2664 +precr2*work2(i,k)*coeres)/work1(i,k,1)
2665 if(prevp(i,k).lt.0.) then
2666 prevp(i,k) = max(prevp(i,k),-qrs(i,k,1)/dtcld)
2667 prevp(i,k) = max(prevp(i,k),satdt/2)
2669 prevp(i,k) = min(prevp(i,k),satdt/2)
2675 !===============================================================
2677 ! cold rain processes
2679 ! - follows the revised ice microphysics processes in HDC
2680 ! - the processes same as in RH83 and RH84 and LFO behave
2681 ! following ice crystal hapits defined in HDC, inclduing
2682 ! intercept parameter for snow (n0s), ice crystal number
2683 ! concentration (ni), ice nuclei number concentration
2684 ! (n0i), ice diameter (d)
2686 !===============================================================
2692 supsat = max(q(i,k),qmin)-qs(i,k,2)
2693 satdt = supsat/dtcld
2695 !-------------------------------------------------------------
2696 ! Ni: ice crystal number concentraiton [HDC 5c]
2697 !-------------------------------------------------------------
2698 ! xni(i,k) = min(max(5.38e7*(den(i,k) &
2699 ! *max(qci(i,k,2),qmin))**0.75,1.e3),1.e6)
2700 temp = (den(i,k)*max(qci(i,k,2),qmin))
2701 temp = sqrt(sqrt(temp*temp*temp))
2702 xni(i,k) = min(max(5.38e7*temp,1.e3),1.e6)
2703 eacrs = exp(0.07*(-supcol))
2705 if(supcol.gt.0) then
2706 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,2).gt.qmin) then
2707 xmi = den(i,k)*qci(i,k,2)/xni(i,k)
2708 diameter = min(dicon * sqrt(xmi),dimax)
2709 vt2i = 1.49e4*diameter**1.31
2710 vt2s = pvts*rslopeb(i,k,2)*denfac(i,k)
2711 !-------------------------------------------------------------
2712 ! psaci: Accretion of cloud ice by rain [HDC 10]
2714 !-------------------------------------------------------------
2715 acrfac = 2.*rslope3(i,k,2)+2.*diameter*rslope2(i,k,2) &
2716 +diameter**2*rslope(i,k,2)
2717 psaci(i,k) = pi*qci(i,k,2)*eacrs*n0s*n0sfac(i,k) &
2718 *abs(vt2s-vt2i)*acrfac/4.
2721 !-------------------------------------------------------------
2722 ! psacw: Accretion of cloud water by snow [HL A7] [LFO 24]
2723 ! (T<T0: C->S, and T>=T0: C->R)
2724 !-------------------------------------------------------------
2725 if(qrs(i,k,2).gt.qcrmin.and.qci(i,k,1).gt.qmin) then
2726 psacw(i,k) = min(pacrc*n0sfac(i,k)*rslope3(i,k,2) &
2727 *rslopeb(i,k,2)*qci(i,k,1)*denfac(i,k) &
2728 ! ,qci(i,k,1)/dtcld)
2731 if(supcol .gt. 0) then
2732 !-------------------------------------------------------------
2733 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
2734 ! (T<T0: V->I or I->V)
2735 !-------------------------------------------------------------
2736 if(qci(i,k,2).gt.0.and.ifsat.ne.1) then
2737 xmi = den(i,k)*qci(i,k,2)/xni(i,k)
2738 diameter = dicon * sqrt(xmi)
2739 pidep(i,k) = 4.*diameter*xni(i,k)*(rh(i,k,2)-1.)/work1(i,k,2)
2740 supice = satdt-prevp(i,k)
2741 if(pidep(i,k).lt.0.) then
2742 ! pidep(i,k) = max(max(pidep(i,k),satdt/2),supice)
2743 ! pidep(i,k) = max(pidep(i,k),-qci(i,k,2)/dtcld)
2744 pidep(i,k) = max(max(pidep(i,k),satdt*.5),supice)
2745 pidep(i,k) = max(pidep(i,k),-qci(i,k,2)*rdtcld)
2747 ! pidep(i,k) = min(min(pidep(i,k),satdt/2),supice)
2748 pidep(i,k) = min(min(pidep(i,k),satdt*.5),supice)
2750 if(abs(prevp(i,k)+pidep(i,k)).ge.abs(satdt)) ifsat = 1
2752 !-------------------------------------------------------------
2753 ! psdep: deposition/sublimation rate of snow [HDC 14]
2755 !-------------------------------------------------------------
2756 if(qrs(i,k,2).gt.0..and.ifsat.ne.1) then
2757 coeres = rslope2(i,k,2)*sqrt(rslope(i,k,2)*rslopeb(i,k,2))
2758 psdep(i,k) = (rh(i,k,2)-1.)*n0sfac(i,k) &
2759 *(precs1*rslope2(i,k,2)+precs2 &
2760 *work2(i,k)*coeres)/work1(i,k,2)
2761 supice = satdt-prevp(i,k)-pidep(i,k)
2762 if(psdep(i,k).lt.0.) then
2763 ! psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)/dtcld)
2764 ! psdep(i,k) = max(max(psdep(i,k),satdt/2),supice)
2765 psdep(i,k) = max(psdep(i,k),-qrs(i,k,2)*rdtcld)
2766 psdep(i,k) = max(max(psdep(i,k),satdt*.5),supice)
2768 ! psdep(i,k) = min(min(psdep(i,k),satdt/2),supice)
2769 psdep(i,k) = min(min(psdep(i,k),satdt*.5),supice)
2771 if(abs(prevp(i,k)+pidep(i,k)+psdep(i,k)).ge.abs(satdt)) &
2774 !-------------------------------------------------------------
2775 ! pigen: generation(nucleation) of ice from vapor [HL A50] [HDC 7-8]
2777 !-------------------------------------------------------------
2778 if(supsat.gt.0.and.ifsat.ne.1) then
2779 supice = satdt-prevp(i,k)-pidep(i,k)-psdep(i,k)
2780 xni0 = 1.e3*exp(0.1*supcol)
2781 roqi0 = 4.92e-11*exp(log(xni0)*(1.33))
2782 pigen(i,k) = max(0.,(roqi0/den(i,k)-max(qci(i,k,2),0.)) &
2785 pigen(i,k) = min(min(pigen(i,k),satdt),supice)
2788 !-------------------------------------------------------------
2789 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
2791 !-------------------------------------------------------------
2792 if(qci(i,k,2).gt.0.) then
2793 qimax = roqimax/den(i,k)
2794 ! psaut(i,k) = max(0.,(qci(i,k,2)-qimax)/dtcld)
2795 psaut(i,k) = max(0.,(qci(i,k,2)-qimax)*rdtcld)
2798 !-------------------------------------------------------------
2799 ! psevp: Evaporation of melting snow [HL A35] [RH83 A27]
2801 !-------------------------------------------------------------
2802 if(supcol.lt.0.) then
2803 if(qrs(i,k,2).gt.0..and.rh(i,k,1).lt.1.) &
2804 psevp(i,k) = psdep(i,k)*work1(i,k,2)/work1(i,k,1)
2805 ! psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)/dtcld),0.)
2806 psevp(i,k) = min(max(psevp(i,k),-qrs(i,k,2)*rdtcld),0.)
2812 !----------------------------------------------------------------
2813 ! check mass conservation of generation terms and feedback to the
2818 if(t(i,k).le.t0c) then
2822 value = max(qmin,qci(i,k,1))
2823 source = (praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
2824 if (source.gt.value) then
2825 factor = value/source
2826 praut(i,k) = praut(i,k)*factor
2827 pracw(i,k) = pracw(i,k)*factor
2828 psacw(i,k) = psacw(i,k)*factor
2833 value = max(qmin,qci(i,k,2))
2834 source = (psaut(i,k)+psaci(i,k)-pigen(i,k)-pidep(i,k))*dtcld
2835 if (source.gt.value) then
2836 factor = value/source
2837 psaut(i,k) = psaut(i,k)*factor
2838 psaci(i,k) = psaci(i,k)*factor
2839 pigen(i,k) = pigen(i,k)*factor
2840 pidep(i,k) = pidep(i,k)*factor
2846 value = max(qmin,qrs(i,k,1))
2847 source = (-praut(i,k)-pracw(i,k)-prevp(i,k))*dtcld
2848 if (source.gt.value) then
2849 factor = value/source
2850 praut(i,k) = praut(i,k)*factor
2851 pracw(i,k) = pracw(i,k)*factor
2852 prevp(i,k) = prevp(i,k)*factor
2857 value = max(qmin,qrs(i,k,2))
2858 source = (-psdep(i,k)-psaut(i,k)-psaci(i,k)-psacw(i,k))*dtcld
2859 if (source.gt.value) then
2860 factor = value/source
2861 psdep(i,k) = psdep(i,k)*factor
2862 psaut(i,k) = psaut(i,k)*factor
2863 psaci(i,k) = psaci(i,k)*factor
2864 psacw(i,k) = psacw(i,k)*factor
2867 work2(i,k)=-(prevp(i,k)+psdep(i,k)+pigen(i,k)+pidep(i,k))
2869 q(i,k) = q(i,k)+work2(i,k)*dtcld
2870 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
2871 +psacw(i,k))*dtcld,0.)
2872 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
2873 +prevp(i,k))*dtcld,0.)
2874 qci(i,k,2) = max(qci(i,k,2)-(psaut(i,k)+psaci(i,k) &
2875 -pigen(i,k)-pidep(i,k))*dtcld,0.)
2876 qrs(i,k,2) = max(qrs(i,k,2)+(psdep(i,k)+psaut(i,k) &
2877 +psaci(i,k)+psacw(i,k))*dtcld,0.)
2879 xlwork2 = -xls*(psdep(i,k)+pidep(i,k)+pigen(i,k)) &
2880 -xl(i,k)*prevp(i,k)-xlf*psacw(i,k)
2881 t(i,k) = t(i,k)-xlwork2/cpm(i,k)*dtcld
2886 value = max(qmin,qci(i,k,1))
2887 source=(praut(i,k)+pracw(i,k)+psacw(i,k))*dtcld
2888 if (source.gt.value) then
2889 factor = value/source
2890 praut(i,k) = praut(i,k)*factor
2891 pracw(i,k) = pracw(i,k)*factor
2892 psacw(i,k) = psacw(i,k)*factor
2897 value = max(qmin,qrs(i,k,1))
2898 source = (-praut(i,k)-pracw(i,k)-prevp(i,k)-psacw(i,k))*dtcld
2899 if (source.gt.value) then
2900 factor = value/source
2901 praut(i,k) = praut(i,k)*factor
2902 pracw(i,k) = pracw(i,k)*factor
2903 prevp(i,k) = prevp(i,k)*factor
2904 psacw(i,k) = psacw(i,k)*factor
2909 value = max(qcrmin,qrs(i,k,2))
2910 source=(-psevp(i,k))*dtcld
2911 if (source.gt.value) then
2912 factor = value/source
2913 psevp(i,k) = psevp(i,k)*factor
2915 work2(i,k)=-(prevp(i,k)+psevp(i,k))
2917 q(i,k) = q(i,k)+work2(i,k)*dtcld
2918 qci(i,k,1) = max(qci(i,k,1)-(praut(i,k)+pracw(i,k) &
2919 +psacw(i,k))*dtcld,0.)
2920 qrs(i,k,1) = max(qrs(i,k,1)+(praut(i,k)+pracw(i,k) &
2921 +prevp(i,k) +psacw(i,k))*dtcld,0.)
2922 qrs(i,k,2) = max(qrs(i,k,2)+psevp(i,k)*dtcld,0.)
2924 xlwork2 = -xl(i,k)*(prevp(i,k)+psevp(i,k))
2925 t(i,k) = t(i,k)-xlwork2/cpm(i,k)*dtcld
2930 ! Inline expansion for fpvs
2931 ! qs(i,k,1) = fpvs(t(i,k),0,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
2932 ! qs(i,k,2) = fpvs(t(i,k),1,rd,rv,cpv,cliq,cice,xlv0,xls,psat,t0c)
2942 xbi=xai+hsub/(rv*ttp)
2947 qs(i,k,1)=psat*exp(logtr*(xa)+xb*(1.-tr))
2948 qs(i,k,1) = ep2 * qs(i,k,1) / (p(i,k) - qs(i,k,1))
2949 qs(i,k,1) = max(qs(i,k,1),qmin)
2953 !----------------------------------------------------------------
2954 ! pcond: condensational/evaporational rate of cloud water [HL A46] [RH83 A6]
2955 ! if there exists additional water vapor condensated/if
2956 ! evaporation of cloud water is not enough to remove subsaturation
2960 ! work1(i,k,1) = conden(t(i,k),q(i,k),qs(i,k,1),xl(i,k),cpm(i,k))
2961 work1(i,k,1) = ((max(q(i,k),qmin)-(qs(i,k,1)))/(1.+(xl(i,k)) &
2962 *(xl(i,k))/(rv*(cpm(i,k)))*(qs(i,k,1)) &
2963 /((t(i,k))*(t(i,k)))))
2964 work2(i,k) = qci(i,k,1)+work1(i,k,1)
2965 pcond(i,k) = min(max(work1(i,k,1)/dtcld,0.),max(q(i,k),0.)/dtcld)
2966 if(qci(i,k,1).gt.0..and.work1(i,k,1).lt.0.) &
2967 pcond(i,k) = max(work1(i,k,1),-qci(i,k,1))/dtcld
2968 q(i,k) = q(i,k)-pcond(i,k)*dtcld
2969 qci(i,k,1) = max(qci(i,k,1)+pcond(i,k)*dtcld,0.)
2970 t(i,k) = t(i,k)+pcond(i,k)*xl(i,k)/cpm(i,k)*dtcld
2975 !----------------------------------------------------------------
2976 ! padding for small values
2980 if(qci(i,k,1).le.qmin) qci(i,k,1) = 0.0
2981 if(qci(i,k,2).le.qmin) qci(i,k,2) = 0.0
2985 END SUBROUTINE wsm52d
2989 ! ...................................................................
2990 REAL FUNCTION rgmma(x)
2991 !-------------------------------------------------------------------
2993 !-------------------------------------------------------------------
2994 ! rgmma function: use infinite product form
2996 PARAMETER (euler=0.577215664901532)
3002 rgmma=x*exp(euler*x)
3005 rgmma=rgmma*(1.000+x/y)*exp(-x/y)
3011 !--------------------------------------------------------------------------
3012 REAL FUNCTION fpvs(t,ice,rd,rv,cvap,cliq,cice,hvap,hsub,psat,t0c)
3013 !--------------------------------------------------------------------------
3015 !--------------------------------------------------------------------------
3016 REAL t,rd,rv,cvap,cliq,cice,hvap,hsub,psat,t0c,dldt,xa,xb,dldti, &
3019 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3026 xbi=xai+hsub/(rv*ttp)
3028 if(t.lt.ttp.and.ice.eq.1) then
3029 fpvs=psat*exp(log(tr)*(xai))*exp(xbi*(1.-tr))
3031 fpvs=psat*exp(log(tr)*(xa))*exp(xb*(1.-tr))
3033 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3035 !-------------------------------------------------------------------
3036 SUBROUTINE wsm5init(den0,denr,dens,cl,cpv,allowed_to_read)
3037 !-------------------------------------------------------------------
3039 !-------------------------------------------------------------------
3040 !.... constants which may not be tunable
3041 REAL, INTENT(IN) :: den0,denr,dens,cl,cpv
3042 LOGICAL, INTENT(IN) :: allowed_to_read
3048 qc0 = 4./3.*pi*denr*r0**3*xncr/den0 ! 0.419e-3 -- .61e-3
3049 qck1 = .104*9.8*peaut/(xncr*denr)**(1./3.)/xmyu*den0**(4./3.) ! 7.03
3055 g1pbr = rgmma(bvtr1)
3056 g3pbr = rgmma(bvtr3)
3057 g4pbr = rgmma(bvtr4) ! 17.837825
3058 g5pbro2 = rgmma(bvtr2) ! 1.8273
3059 pvtr = avtr*g4pbr/6.
3061 pacrr = pi*n0r*avtr*g3pbr*.25*eacrr
3062 precr1 = 2.*pi*n0r*.78
3063 precr2 = 2.*pi*n0r*.31*avtr**.5*g5pbro2
3064 xmmax = (dimax/dicon)**2
3065 roqimax = 2.08e22*dimax**8
3071 g1pbs = rgmma(bvts1) !.8875
3072 g3pbs = rgmma(bvts3)
3073 g4pbs = rgmma(bvts4) ! 12.0786
3074 g5pbso2 = rgmma(bvts2)
3075 pvts = avts*g4pbs/6.
3076 pacrs = pi*n0s*avts*g3pbs*.25
3078 precs2 = 4.*n0s*.44*avts**.5*g5pbso2
3079 pidn0r = pi*denr*n0r
3080 pidn0s = pi*dens*n0s
3081 pacrc = pi*n0s*avts*g3pbs*.25*eacrc
3083 rslopermax = 1./lamdarmax
3084 rslopesmax = 1./lamdasmax
3085 rsloperbmax = rslopermax ** bvtr
3086 rslopesbmax = rslopesmax ** bvts
3087 rsloper2max = rslopermax * rslopermax
3088 rslopes2max = rslopesmax * rslopesmax
3089 rsloper3max = rsloper2max * rslopermax
3090 rslopes3max = rslopes2max * rslopesmax
3092 END SUBROUTINE wsm5init
3093 END MODULE module_mp_wsm5