← Back to Documentation Home
CCPP SciDoc v8.0.0  v8.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
calpreciptype.f90
1
3
7contains
8
10 subroutine calpreciptype(kdt,nrcm,im,ix,lm,lp1,randomno, &
11 xlat,xlon, &
12 gt0,gq0,prsl,prsi,prec, & !input
13 phii,tskin, & !input
14 domr,domzr,domip,doms) !output
15
16!$$$ subprogram documentation block
17! . . .
18! subprogram: calpreciptype compute dominant precip type
19! prgrmmr: chuang org: w/np2 date: 2008-05-28
20!
21!
22! abstract:
23! this routine computes precipitation type.
24! . it is adopted from post but was made into a column to used by gfs model
25!
26! --------------------------------------------------------------------
27 use funcphys, only : fpvs,ftdp,fpkap,ftlcl,stma,fthe
28 use physcons
29 use machine , only : kind_phys
30!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 implicit none
32!
33 real(kind=kind_phys), parameter :: pthresh = 0.0, oneog = 1.0/con_g
34 integer,parameter :: nalg = 5
35!
36! declare variables.
37!
38 integer,intent(in) :: kdt,nrcm,im,ix,lm,lp1
39 real(kind=kind_phys),intent(in) :: xlat(im),xlon(im)
40 real(kind=kind_phys),intent(in) :: randomno(ix,nrcm)
41 real(kind=kind_phys),dimension(im), intent(in) :: prec,tskin
42 real(kind=kind_phys),dimension(ix,lm), intent(in) :: gt0,gq0,prsl
43 real(kind=kind_phys),dimension(ix,lp1),intent(in) :: prsi,phii
44 real(kind=kind_phys),dimension(im), intent(out) :: domr,domzr,domip,doms
45
46 integer, dimension(nalg) :: sleet,rain,freezr,snow
47 real(kind=kind_phys),dimension(lm) :: t,q,pmid
48 real(kind=kind_phys),dimension(lp1) :: pint,zint
49 real(kind=kind_phys), allocatable :: twet(:),rh(:),td(:)
50!
51 integer i,iwx,isno,iip,izr,irain,k,k1
52 real(kind=kind_phys) es,qc,pv,tdpd,pr,tr,pk,tlcl,thelcl,qwet, &
53 time_vert,time_ncep,time_ramer,time_bourg,time_revised,&
54 time_dominant,btim,timef,ranl(2)
55
56!
57! computes wet bulb here since two algorithms use it
58! lp1=lm+1
59! convert geopotential to height
60! do l=1,lp1
61! zint(l)=zint(l)/con_g
62! end do
63! don't forget to flip 3d arrays around because gfs counts from bottom up
64
65 allocate ( twet(lm),rh(lm),td(lm) )
66
67! print*,'debug calpreciptype: ', im,lm,lp1,nrcm
68
69! time_vert = 0.
70! time_ncep = 0.
71! time_ramer = 0.
72! time_bourg = 0.
73! time_revised = 0.
74
75 do i=1,im
76 if (prec(i) > pthresh) then
77 do k=1,lm
78 k1 = lm-k+1
79 t(k1) = gt0(i,k)
80 q(k1) = gq0(i,k)
81 pmid(k1) = prsl(i,k) ! pressure in pascals
82!
84!
85 pv = pmid(k1)*q(k1)/(con_eps-con_epsm1*q(k1))
86 td(k1) = ftdp(pv)
87 tdpd = t(k1)-td(k1)
88! if (pmid(k1) >= 50000.) then ! only compute twet below 500mb to save time
89 if (tdpd > 0.) then
90 pr = pmid(k1)
91 tr = t(k1)
92 pk = fpkap(pr)
93 tlcl = ftlcl(tr,tdpd)
94 thelcl = fthe(tlcl,pk*tlcl/tr)
95 call stma(thelcl,pk,twet(k1),qwet)
96 else
97 twet(k1) = t(k1)
98 endif
99! endif
100 es = min(fpvs(t(k1)), pmid(k1))
101 qc = con_eps*es / (pmid(k1)+con_epsm1*es)
102 rh(k1) = max(con_epsq,q(k1)) / qc
103
104 k1 = lp1-k+1
105 pint(k1) = prsi(i,k)
106 zint(k1) = phii(i,k) * oneog
107
108 enddo
109 pint(1) = prsi(i,lp1)
110 zint(1) = phii(i,lp1) * oneog
111
112!-------------------------------------------------------------------------------
113! if(kdt>15.and.kdt<20) time_vert = time_vert + (timef() - btim)
114! debug print statement
115! if (abs(xlon(i)*57.29578-114.0) .lt. 0.2 .and. &
116! abs(xlat(i)*57.29578-40.0) .lt. 0.2)then
117! print*,'debug in calpreciptype: i,im,lm,lp1,xlon,xlat,prec,tskin,nrcm,randomno', &
118! i,im,lm,lp1,xlon(i)*57.29578,xlat(i)*57.29578,prec(i),tskin(i),, &
119! nrcm,randomno(i,1:nrcm)
120! do l=1,lm
121! print*,'debug in calpreciptype: l,t,q,p,pint,z,twet', &
122! l,t(l),q(l), &
123! pmid(l),pint(l),zint(l),twet(l)
124! end do
125! print*,'debug in calpreciptype: lp1,pint,z ', lp1,pint(lp1),zint(lp1)
126! end if
127! end debug print statement
128! call wetbulb(lm,con_rocp,con_epsq,t,q,pmid,twet)
129! if(kdt>10.and.kdt<20)btim = timef()
130!-------------------------------------------------------------------------------
131!
132! instantaneous precipitation type.
133
135 call calwxt(lm,lp1,t,q,pmid,pint,con_fvirt,con_rog,con_epsq,zint,iwx,twet)
136 snow(1) = mod(iwx,2)
137 sleet(1) = mod(iwx,4)/2
138 freezr(1) = mod(iwx,8)/4
139 rain(1) = iwx/8
140
141! dominant precipitation type
142
143!gsm if dominant precip type is requested, 4 more algorithms
144!gsm will be called. the tallies are then summed in calwxt_dominant
145
146! ramer algorithm
147! allocate ( rh(lm),td(lm) )
148! do l=1,lm
149!hc: use rh and td consistent with gfs ice physics
150! es=fpvs(t(l))
151! es=min(es,pmid(l))
152! qc=con_eps*es/(pmid(l)+con_epsm1*es)
153! rh(l)=max(con_epsq,q(l))/qc
154! pv = pmid(l)*q(l)/(con_eps-con_epsm1*q(l))
155! td(l)=ftdp(pv)
156! end do
157! if(kdt>10.and.kdt<20)btim = timef()
158
159! write(0,*)' i=',i,' lm=',lm,' lp1=',lp1,' t=',t(1),q(1),pmid(1) &
160! &,' pint=',pint(1),' prec=',prec(i),' pthresh=',pthresh
161
163 call calwxt_ramer(lm,lp1,t,q,pmid,rh,td,pint,iwx)
164
165!
166 snow(2) = mod(iwx,2)
167 sleet(2) = mod(iwx,4)/2
168 freezr(2) = mod(iwx,8)/4
169 rain(2) = iwx/8
170
171! bourgouin algorithm
172! iseed=44641*(int(sdat(1)-1)*24*31+int(sdat(2))*24+ihrst)+ &
173! & mod(ifhr*60+ifmin,44641)+4357
174
176 ranl = randomno(i,1:2)
177 call calwxt_bourg(lm,lp1,ranl,con_g,t,q,pmid,pint,zint(1),iwx)
178
179!
180 snow(3) = mod(iwx,2)
181 sleet(3) = mod(iwx,4)/2
182 freezr(3) = mod(iwx,8)/4
183 rain(3) = iwx/8
184!
185! revised ncep algorithm
186!
188 call calwxt_revised(lm,lp1,t,q,pmid,pint, &
189 con_fvirt,con_rog,con_epsq,zint,twet,iwx)
190!
191 snow(4) = mod(iwx,2)
192 sleet(4) = mod(iwx,4)/2
193 freezr(4) = mod(iwx,8)/4
194 rain(4) = iwx/8
195!
196! explicit algorithm (under 18 not admitted without parent or guardian)
197
198 snow(5) = 0
199 sleet(5) = 0
200 freezr(5) = 0
201 rain(5) = 0
202!
203 call calwxt_dominant(nalg,rain(1),freezr(1),sleet(1), &
204 snow(1),domr(i),domzr(i),domip(i),doms(i))
205
206 else ! prec < pthresh
207 domr(i) = 0.
208 domzr(i) = 0.
209 domip(i) = 0.
210 doms(i) = 0.
211 end if
212 enddo ! end loop for i
213
214 deallocate (twet,rh,td)
215 return
216 end
217
221 subroutine calwxt(lm,lp1,t,q,pmid,pint, &
222 d608,rog,epsq,zint,iwx,twet)
223 use machine , only : kind_phys
224!
225! file: calwxt.f
226! written: 11 november 1993, michael baldwin
227! revisions:
228! 30 sept 1994-setup new decision tree (m baldwin)
229! 12 june 1998-conversion to 2-d (t black)
230! 01-10-25 h chuang - modified to process hybrid model output
231! 02-01-15 mike baldwin - wrf version
232!
233!
234! routine to compute precipitation type using a decision tree
235! approach that uses variables such as integrated wet bulb temp
236! below freezing and lowest layer temperature
237!
238! see baldwin and contorno preprint from 13th weather analysis
239! and forecasting conference for more details
240! (or baldwin et al, 10th nwp conference preprint)
241!
242!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
243 implicit none
244!
245! input:
246! t,q,pmid,htm,lmh,zint
247!
248 integer,intent(in) :: lm,lp1
249 real(kind=kind_phys),dimension(lm),intent(in) :: t,q,pmid,twet
250 real(kind=kind_phys),dimension(lp1),intent(in) :: zint,pint
251 integer,intent(out) :: iwx
252 real(kind=kind_phys),intent(in) :: d608,rog,epsq
253
254
255! output:
256! iwx - instantaneous weather type.
257! acts like a 4 bit binary
258! 1111 = rain/freezing rain/ice pellets/snow
259! where the one's digit is for snow
260! the two's digit is for ice pellets
261! the four's digit is for freezing rain
262! and the eight's digit is for rain
263!
264! internal:
265!
266! real(kind=kind_phys), allocatable :: twet(:)
267 real(kind=kind_phys), parameter :: d00=0.0
268 integer karr,licee
269 real(kind=kind_phys) tcold,twarm
270
271! subroutines called:
272! wetbulb
273!
274!
275! initialize weather type array to zero (ie, off).
276! we do this since we want iwx to represent the
277! instantaneous weather type on return.
278!
279!
280! allocate local storage
281!
282
283 integer l,lice,iwrml,ifrzl
284 logical :: needs_retry
285 real(kind=kind_phys) psfck,tdchk,a,tdkl,tdpre,tlmhk,twrmk,areas8,areap4, &
286 surfw,surfc,dzkl,area1,pintk1,pintk2,pm150,pkl,tkl,qkl
287
288! allocate ( twet(lm) )
289!
290 iwx = 0
291!
292! find coldest and warmest temps in saturated layer between
293! 70 mb above ground and 500 mb
294! also find highest saturated layer in that range
295!
296!meb
297 psfck = pint(lm+1)
298!meb
299 tdchk = 2.0
300 retry_loop: do while (needs_retry)
301 needs_retry = .false.
302
303 tcold = t(lm)
304 twarm = t(lm)
305 licee = lm
306!
307 do l=1,lm
308 qkl = q(l)
309 qkl = max(epsq,qkl)
310 tkl = t(l)
311 pkl = pmid(l)
312!
313! skip past this if the layer is not between 70 mb above ground and 500 mb
314!
315 if (pkl < 50000.0 .or. pkl > psfck-7000.0) cycle
316 a = log(qkl*pkl/(6.1078*(0.378*qkl+0.622)))
317 tdkl = (237.3*a) / (17.269-a) + 273.15
318 tdpre = tkl - tdkl
319 if (tdpre < tdchk .and. tkl < tcold) tcold = tkl
320 if (tdpre < tdchk .and. tkl > twarm) twarm = tkl
321 if (tdpre < tdchk .and. l < licee) licee = l
322 enddo
323!
324! if no sat layer at dew point dep=tdchk, increase tdchk
325! and start again (but don't make tdchk > 6)
326!
327 if (tcold == t(lm) .and. tdchk < 6.0) then
328 tdchk = tdchk + 2.0
329 needs_retry = .true.
330 endif
331 end do retry_loop
332!
333! lowest layer t
334!
335 karr = 0
336 tlmhk = t(lm)
337!
338! decision tree time
339!
340 if (tcold > 269.15) then
341 if (tlmhk <= 273.15) then
342
343! turn on the flag for freezing rain = 4 if its not on already
344! izr=mod(iwx(i,j),8)/4
345! if (izr.lt.1) iwx(i,j)=iwx(i,j)+4
346
347 iwx = iwx + 4
348 karr = 1
349 else
350! turn on the flag for rain = 8
351! if its not on already
352! irain=iwx(i,j)/8
353! if (irain.lt.1) iwx(i,j)=iwx(i,j)+8
354
355 iwx = iwx + 8
356 karr = 1
357 endif
358 endif
359!
360! compute wet bulb only at points that need it
361!
362! call wetbulb(lm,t,q,pmid,karr,twet)
363! call wetfrzlvl(twet,zwet)
364!
365 if (karr > 0) then
366 lice=licee
367!meb
368 psfck = pint(lm+1)
369!meb
370 tlmhk = t(lm)
371 twrmk = twarm
372!
373! twet area variables calculate only what is needed
374! from ground to 150 mb above surface from ground to tcold layer
375! and from ground to 1st layer where wet bulb t < 0.0
376!
377! pintk1 is the pressure at the bottom of the layer
378! pintk2 is the pressure at the top of the layer
379!
380! areap4 is the area of twet above -4 c below highest sat lyr
381!
382 areas8 = d00
383 areap4 = d00
384 surfw = d00
385 surfc = d00
386!
387 do l=lm,lice,-1
388 area1 = (twet(l)-269.15) * (zint(l)-zint(l+1))
389 if (twet(l) >= 269.15) areap4 = areap4 + area1
390 enddo
391!
392 if (areap4 < 3000.0) then
393! turn on the flag for snow = 1
394! if its not on already
395! isno=mod(iwx(i,j),2)
396! if (isno.lt.1) iwx(i,j)=iwx(i,j)+1
397
398 iwx = iwx + 1
399 return
400 endif
401!
402! areas8 is the net area of twet w.r.t. freezing in lowest 150mb
403!
404 pintk1 = psfck
405 pm150 = psfck - 15000.
406!
407 do l=lm,1,-1
408 pintk2 = pint(l)
409 if (pintk1 >= pm150) then
410 dzkl = zint(l)-zint(l+1)
411! sum partial layer if in 150 mb agl layer
412 if (pintk2 < pm150) &
413 dzkl = t(l)*(q(l)*d608+1.0)*rog*log(pintk1/pm150)
414 area1 = (twet(l)-273.15)*dzkl
415 areas8 = areas8 + area1
416 endif
417 pintk1 = pintk2
418 enddo
419!
420! surfw is the area of twet above freezing between the ground
421! and the first layer above ground below freezing
422! surfc is the area of twet below freezing between the ground
423! and the warmest sat layer
424!
425 ifrzl = 0
426 iwrml = 0
427!
428 do l=lm,1,-1
429 if (ifrzl == 0 .and. t(l) < 273.15) ifrzl = 1
430 if (iwrml == 0 .and. t(l) >= twrmk) iwrml = 1
431!
432 if (iwrml == 0 .or. ifrzl == 0) then
433! if(pmid(l) < 50000.)print*,'need twet above 500mb'
434 dzkl = zint(l)-zint(l+1)
435 area1 = (twet(l)-273.15)*dzkl
436 if(ifrzl == 0 .and. twet(l) >= 273.15) surfw = surfw + area1
437 if(iwrml == 0 .and. twet(l) <= 273.15) surfc = surfc + area1
438 endif
439 enddo
440 if(surfc < -3000.0 .or. (areas8 < -3000.0 .and. surfw < 50.0)) then
441! turn on the flag for ice pellets = 2 if its not on already
442! iip=mod(iwx(i,j),4)/2
443! if (iip.lt.1) iwx(i,j)=iwx(i,j)+2
444 iwx = iwx + 2
445!
446 elseif(tlmhk < 273.15) then
447! turn on the flag for freezing rain = 4 if its not on already
448! izr=mod(iwx(k),8)/4
449! if (izr.lt.1) iwx(k)=iwx(k)+4
450 iwx = iwx + 4
451 else
452! turn on the flag for rain = 8 if its not on already
453! irain=iwx(k)/8
454! if (irain.lt.1) iwx(k)=iwx(k)+8
455 iwx = iwx + 8
456 endif
457 endif
458!---------------------------------------------------------
459! deallocate (twet)
460
461 return
462 end
463!
464!
465!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
466!
467! dophase is a subroutine written and provided by jim ramer at noaa/fsl
468!
469! ramer, j, 1993: an empirical technique for diagnosing precipitation
470! type from model output. preprints, 5th conf. on aviation
471! weather systems, vienna, va, amer. meteor. soc., 227-230.
472!
473! code adapted for wrf post 24 august 2005 g manikin
474!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
477 subroutine calwxt_ramer(lm,lp1,t,q,pmid,rh,td,pint,ptyp)
478
479! subroutine dophase(pq, ! input pressure sounding mb
480! + t, ! input temperature sounding k
481! + pmid, ! input pressure
482! + pint, ! input interface pressure
483! + q, ! input spec humidityfraction
484! + lmh, ! input number of levels in sounding
485! + ptyp) ! output(2) phase 2=rain, 3=frzg, 4=solid,
486! 6=ip jc 9/16/99
487! use params_mod
488! use ctlblk_mod
489!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
490 use machine , only : kind_phys
491 implicit none
492!
493 real(kind=kind_phys),parameter :: twice=266.55,rhprcp=0.80,deltag=1.02, &
494 & emelt=0.045,rlim=0.04,slim=0.85
495 real(kind=kind_phys),parameter :: twmelt=273.15,tz=273.15,efac=1.0 ! specify in params now
496!
497 integer*4 i, k1, lll, k2, toodry
498!
499 real(kind=kind_phys) xxx ,mye, icefrac
500 integer, intent(in) :: lm,lp1
501 real(kind=kind_phys),dimension(lm), intent(in) :: t,q,pmid,rh,td
502 real(kind=kind_phys),dimension(lp1),intent(in) :: pint
503 integer, intent(out) :: ptyp
504!
505 real(kind=kind_phys),dimension(lm) :: tq,pq,rhq,twq
506!
507 integer j,l,lev,ii
508 real(kind=kind_phys) rhmax,twmax,ptop,dpdrh,twtop,rhtop,wgt1,wgt2, &
509 rhavg,dtavg,dpk,ptw,pbot
510! real(kind=kind_phys) b,qtmp,rate,qc
511!
512!
513! initialize.
514 icefrac = -9999.
515!
516
517 ptyp = 0
518 do l = 1,lm
519 lev = lp1 - l
520! p(l)=pmid(l)
521! qc=pq0/p(l) * exp(a2*(t(l)-a3)/(t(l)-a4))
522!gsm forcing q (qtmp) to be positive to deal with negative q values
523! causing problems later in this subroutine
524! qtmp=max(h1m12,q(l))
525! rhqtmp(lev)=qtmp/qc
526 rhq(lev) = rh(l)
527 pq(lev) = pmid(l) * 0.01
528 tq(lev) = t(l)
529 enddo
530
531
532!
533!cc rate restriction removed by john cortinas 3/16/99
534!
535! construct wet-bulb sounding, locate generating level.
536 twmax = -999.0
537 rhmax = 0.0
538 k1 = 0 ! top of precip generating layer
539 k2 = 0 ! layer of maximum rh
540!
541 if (rhq(1) < rhprcp) then
542 toodry = 1
543 else
544 toodry = 0
545 end if
546!
547 pbot = pq(1)
548! nq=lm
549 do l = 1, lm
550! xxx = tdofesat(esat(tq(l))*rhq(l))
551! xxx = td(l) !hc: use td consistent with gfs ice physics
552 xxx = td(lp1-l) !hc: use td consistent with gfs ice physics
553 if (xxx < -500.) return
554 twq(l) = xmytw(tq(l),xxx,pq(l))
555 twmax = max(twq(l),twmax)
556 if (pq(l) >= 400.0) then
557 if (rhq(l) > rhmax) then
558 rhmax = rhq(l)
559 k2 = l
560 end if
561!
562 if (l /= 1) then
563 if (rhq(l) >= rhprcp .or. toodry == 0) then
564 if (toodry /= 0) then
565 dpdrh = log(pq(l)/pq(l-1)) / (rhq(l)-rhq(l-1))
566 pbot = exp(log(pq(l))+(rhprcp-rhq(l))*dpdrh)
567!
568 ptw = pq(l)
569 toodry = 0
570 else if (rhq(l)>= rhprcp) then
571 ptw = pq(l)
572 else
573 toodry = 1
574 dpdrh = log(pq(l)/pq(l-1)) / (rhq(l)-rhq(l-1))
575 ptw = exp(log(pq(l))+(rhprcp-rhq(l))*dpdrh)
576
577!lin dpdrh = (pq(i)-pq(i-1))/(rhq(i)-rhq(i-1))
578!lin ptw = pq(i)+(rhprcp-rhq(i))*dpdrh
579!
580 end if
581!
582 if (pbot/ptw >= deltag) then
583!lin if (pbot-ptw.lt.deltag) goto 2003
584 k1 = l
585 ptop = ptw
586 end if
587 end if
588 end if
589 end if
590 enddo
591!
592! gross checks for liquid and solid precip which dont require generating level.
593!
594 if (twq(1) >= 273.15+2.0) then
595 ptyp = 8 ! liquid
596 icefrac = 0.0
597 return
598 end if
599!
600 if (twmax <= twice) then
601 icefrac = 1.0
602 ptyp = 1 ! solid
603 return
604 end if
605!
606! check to see if we had no success with locating a generating level.
607!
608 if (k1 == 0) return
609!
610 if (ptop == pq(k1)) then
611 twtop = twq(k1)
612 rhtop = rhq(k1)
613 k2 = k1
614 k1 = k1 - 1
615 else
616 k2 = k1
617 k1 = k1 - 1
618 wgt1 = log(ptop/pq(k2)) / log(pq(k1)/pq(k2))
619 wgt2 = 1.0 - wgt1
620 twtop = twq(k1) * wgt1 + twq(k2) * wgt2
621 rhtop = rhq(k1) * wgt1 + rhq(k2) * wgt2
622 end if
623!
624! calculate temp and wet-bulb ranges below precip generating level.
625 do l = 1, k1
626 twmax = max(twq(l),twmax)
627 enddo
628!
629! gross check for solid precip, initialize ice fraction.
630! if (i.eq.1.and.j.eq.1) write (*,*) 'twmax=',twmax,twice,'twtop=',twtop
631
632 if (twtop <= twice) then
633 icefrac = 1.0
634 if (twmax <= twmelt) then ! gross check for solid precip.
635 ptyp = 1 ! solid precip
636 return
637 end if
638 lll = 0
639 else
640 icefrac = 0.0
641 lll = 1
642 end if
643!
644! loop downward through sounding from highest precip generating level.
645 sounding_loop: do
646 process_level: do
647!
648 if (icefrac >= 1.0) then ! starting as all ice
649 if (twq(k1) < twmelt) exit process_level ! cannot commence melting
650 if (twq(k1) == twtop) exit process_level ! both equal twmelt, nothing h
651 wgt1 = (twmelt-twq(k1)) / (twtop-twq(k1))
652 rhavg = rhq(k1) + wgt1 * (rhtop-rhq(k1)) * 0.5
653 dtavg = (twmelt-twq(k1)) * 0.5
654 dpk = wgt1 * log(pq(k1)/ptop) !lin dpk=wgt1*(pq(k1)-ptop)
655! mye=emelt*(1.0-(1.0-rhavg)*efac)
656 mye = emelt * rhavg ** efac
657 icefrac = icefrac + dpk * dtavg / mye
658 else if (icefrac <= 0.0) then ! starting as all liquid
659 lll = 1
660! goto 1020
661 if (twq(k1) > twice) exit process_level ! cannot commence freezing
662 if (twq(k1) == twtop) then
663 wgt1 = 0.5
664 else
665 wgt1 = (twice-twq(k1)) / (twtop-twq(k1))
666 end if
667 rhavg = rhq(k1) + wgt1 * (rhtop-rhq(k1)) * 0.5
668 dtavg = twmelt - (twq(k1)+twice) * 0.5
669 dpk = wgt1 * log(pq(k1)/ptop) !lin dpk=wgt1*(pq(k1)-ptop)
670! mye = emelt*(1.0-(1.0-rhavg)*efac)
671 mye = emelt * rhavg ** efac
672 icefrac = icefrac + dpk * dtavg / mye
673 else if ((twq(k1) <= twmelt).and.(twq(k1) < twmelt)) then ! mix
674 rhavg = (rhq(k1)+rhtop) * 0.5
675 dtavg = twmelt - (twq(k1)+twtop) * 0.5
676 dpk = log(pq(k1)/ptop) !lin dpk=pq(k1)-ptop
677! mye = emelt*(1.0-(1.0-rhavg)*efac)
678 mye = emelt * rhavg ** efac
679 icefrac = icefrac + dpk * dtavg / mye
680 else ! mix where tw curve crosses twmelt in layer
681 if (twq(k1) == twtop) exit process_level ! both equal twmelt, nothing h
682 wgt1 = (twmelt-twq(k1)) / (twtop-twq(k1))
683 wgt2 = 1.0 - wgt1
684 rhavg = rhtop + wgt2 * (rhq(k1)-rhtop) * 0.5
685 dtavg = (twmelt-twtop) * 0.5
686 dpk = wgt2 * log(pq(k1)/ptop) !lin dpk=wgt2*(pq(k1)-ptop)
687! mye = emelt*(1.0-(1.0-rhavg)*efac)
688 mye = emelt * rhavg ** efac
689 icefrac = icefrac + dpk * dtavg / mye
690 icefrac = min(1.0,max(icefrac,0.0))
691 if (icefrac <= 0.0) then
692! goto 1020
693 if (twq(k1) > twice) exit process_level ! cannot commence freezin
694 wgt1 = (twice-twq(k1)) / (twtop-twq(k1))
695 dtavg = twmelt - (twq(k1)+twice) * 0.5
696 else
697 dtavg = (twmelt-twq(k1)) * 0.5
698 end if
699 rhavg = rhq(k1) + wgt1 * (rhtop-rhq(k1)) * 0.5
700 dpk = wgt1 * log(pq(k1)/ptop) !lin dpk=wgt1*(pq(k1)-ptop)
701! mye = emelt*(1.0-(1.0-rhavg)*efac)
702 mye = emelt * rhavg ** efac
703 icefrac = icefrac + dpk * dtavg / mye
704 end if
705!
706 icefrac = min(1.0,max(icefrac,0.0))
707 exit process_level
708 end do process_level
709
710! if (i.eq.1.and.j.eq.1) write (*,*) 'new icefrac:', icefrac, icefrac
711!
712! get next level down if there is one, loop back.
713
714 if (k1 > 1) then
715 twtop = twq(k1)
716 ptop = pq(k1)
717 rhtop = rhq(k1)
718 k1 = k1 - 1
719 else
720 exit sounding_loop
721 end if
722 end do sounding_loop
723!
724! determine precip type based on snow fraction and surface wet-bulb.
725!
726 if (icefrac >= slim) then
727 if (lll /= 0) then
728 ptyp = 2 ! ice pellets jc 9/16/99
729 else
730 ptyp = 1 ! snow
731 end if
732 else if (icefrac <= rlim) then
733 if (twq(1).lt.tz) then
734 ptyp = 4 ! freezing precip
735 else
736 ptyp = 8 ! rain
737 end if
738 else
739 if (twq(1) < tz) then
740!gsm not sure what to do when 'mix' is predicted; in previous
741!gsm versions of this code for which i had to have an answer,
742!gsm i chose sleet. here, though, since we have 4 other
743!gsm algorithms to provide an answer, i will not declare a
744!gsm type from the ramer in this situation and allow the
745!gsm other algorithms to make the call.
746
747 ptyp = 0 ! don't know
748! ptyp = 5 ! mix
749 else
750! ptyp = 5 ! mix
751 ptyp = 0 ! don't know
752 end if
753 end if
754
755 return
756!
757 end
758!
759!
760!--------------------------------------------------------------------------
761 function xmytw(t,td,p)
762!
763 use machine , only : kind_phys
764 implicit none
765!
766 integer*4 cflag, l
767 real(kind=kind_phys) f, c0, c1, c2, k, kd, kw, ew, t, td, p, ed, fp, s, &
768 & de, xmytw
769 data f, c0, c1, c2 /0.0006355, 26.66082, 0.0091379024, 6106.3960/
770!
771 xmytw = (t+td) / 2
772 if (td >= t) return
773!
774 if (t < 100.0) then
775 k = t + 273.15
776 kd = td + 273.15
777 if (kd >= k) return
778 cflag = 1
779 else
780 k = t
781 kd = td
782 cflag = 0
783 end if
784!
785 ed = c0 - c1 * kd - c2 / kd
786 if (ed < -14.0 .or. ed > 7.0) return
787 ed = exp(ed)
788 ew = c0 - c1 * k - c2 / k
789 if (ew < -14.0 .or. ew > 7.0) return
790 ew = exp(ew)
791 fp = p * f
792 s = (ew-ed) / (k-kd)
793 kw = (k*fp+kd*s) / (fp+s)
794!
795 do l = 1, 5
796 ew = c0 - c1 * kw - c2 / kw
797 if (ew < -14.0 .or. ew > 7.0) return
798 ew = exp(ew)
799 de = fp * (k-kw) + ed - ew
800 if (abs(de/ew) < 1e-5) exit
801 s = ew * (c1-c2/(kw*kw)) - fp
802 kw = kw - de / s
803 enddo
804!
805! print *, 'kw ', kw
806 if (cflag /= 0) then
807 xmytw = kw - 273.15
808 else
809 xmytw = kw
810 end if
811!
812 return
813 end
814!
815!
816!$$$ subprogram documentation block
817!
818! subprogram: calwxt_bourg calculate precipitation type (bourgouin)
819! prgmmr: baldwin org: np22 date: 1999-07-06
820!
821! abstract: this routine computes precipitation type
822! using a decision tree approach that uses the so-called
823! "energy method" of bourgouin of aes (canada) 1992
824!
825! program history log:
826! 1999-07-06 m baldwin
827! 1999-09-20 m baldwin make more consistent with bourgouin (1992)
828! 2005-08-24 g manikin added to wrf post
829! 2007-06-19 m iredell mersenne twister, best practices
830! 2008-03-03 g manikin added checks to prevent stratospheric warming
831! episodes from being seen as "warm" layers
832! impacting precip type
833!
834! usage: call calwxt_bourg(im,jm,jsta_2l,jend_2u,jsta,jend,lm,lp1, &
835! & iseed,g, &
836! & t,q,pmid,pint,lmh,zint,ptype)
837! input argument list:
838! im integer i dimension
839! jm integer j dimension
840! jsta_2l integer j dimension start point (including haloes)
841! jend_2u integer j dimension end point (including haloes)
842! jsta integer j dimension start point (excluding haloes)
843! jend integer j dimension end point (excluding haloes)
844! lm integer k dimension
845! lp1 integer k dimension plus 1
846! iseed integer random number seed
847! g real gravity (m/s**2)
848! pthresh real precipitation threshold (m)
849! t real(im,jsta_2l:jend_2u,lm) mid layer temp (k)
850! q real(im,jsta_2l:jend_2u,lm) specific humidity (kg/kg)
851! pmid real(im,jsta_2l:jend_2u,lm) mid layer pressure (pa)
852! pint real(im,jsta_2l:jend_2u,lp1) interface pressure (pa)
853! lmh real(im,jsta_2l:jend_2u) max number of layers
854! zint real(im,jsta_2l:jend_2u,lp1) interface height (m)
855! output argument list:
856! ptype real(im,jm) instantaneous weather type ()
857! acts like a 4 bit binary
858! 1111 = rain/freezing rain/ice pellets/snow
859! where the one's digit is for snow
860! the two's digit is for ice pellets
861! the four's digit is for freezing rain
862! and the eight's digit is for rain
863! in other words...
864! ptype=1 snow
865! ptype=2 ice pellets/mix with ice pellets
866! ptype=4 freezing rain/mix with freezing rain
867! ptype=8 rain
868!
869! modules used:
870! mersenne_twister pseudo-random number generator
871!
872! subprograms called:
873! random_number pseudo-random number generator
874!
875! attributes:
876! language: fortran 90
877!
878! remarks: vertical order of arrays must be layer 1 = top
879! and layer lmh = bottom
880!
881!$$$
885!of aes (canada) 1992
886 subroutine calwxt_bourg(lm,lp1,rn,g,t,q,pmid,pint,zint,ptype)
887 use machine , only : kind_phys
888 implicit none
889!
890! input:
891 integer,intent(in) :: lm,lp1
892 real(kind=kind_phys),intent(in) :: g,rn(2)
893 real(kind=kind_phys),intent(in), dimension(lm) :: t, q, pmid
894 real(kind=kind_phys),intent(in), dimension(lp1) :: pint, zint
895!
896! output:
897 integer, intent(out) :: ptype
898!
899 integer ifrzl,iwrml,l,lhiwrm
900 real(kind=kind_phys) pintk1,areane,tlmhk,areape,pintk2,surfw,area1,dzkl,psfck,r1,r2
901!
902! initialize weather type array to zero (ie, off).
903! we do this since we want ptype to represent the
904! instantaneous weather type on return.
905!
906 ptype = 0
907 psfck = pint(lm+1)
908
909! find the depth of the warm layer based at the surface
910! this will be the cut off point between computing
911! the surface based warm air and the warm air aloft
912!
913! lowest layer t
914!
915 tlmhk = t(lm)
916 iwrml = lm + 1
917 if (tlmhk >= 273.15) then
918 do l = lm, 2, -1
919 if (t(l) >= 273.15 .and. t(l-1) < 273.15 .and. &
920 & iwrml == lm+1) iwrml = l
921 end do
922 end if
923!
924! now find the highest above freezing level
925!
926 lhiwrm = lm + 1
927 do l = lm, 1, -1
928! gsm added 250 mb check to prevent stratospheric warming situations
929! from counting as warm layers aloft
930 if (t(l) >= 273.15 .and. pmid(l) > 25000.) lhiwrm = l
931 end do
932
933! energy variables
934! surfw is the positive energy between the ground
935! and the first sub-freezing layer above ground
936! areane is the negative energy between the ground
937! and the highest layer above ground
938! that is above freezing
939! areape is the positive energy "aloft"
940! which is the warm energy not based at the ground
941! (the total warm energy = surfw + areape)
942!
943! pintk1 is the pressure at the bottom of the layer
944! pintk2 is the pressure at the top of the layer
945! dzkl is the thickness of the layer
946! ifrzl is a flag that tells us if we have hit
947! a below freezing layer
948!
949 pintk1 = psfck
950 ifrzl = 0
951 areane = 0.0
952 areape = 0.0
953 surfw = 0.0
954
955 do l = lm, 1, -1
956 if (ifrzl == 0 .and. t(l) <= 273.15) ifrzl = 1
957 pintk2 = pint(l)
958 dzkl = zint(l)-zint(l+1)
959 if (t(l) >= 273.15 .and. pmid(l) > 25000.) then
960 area1 = log(t(l)/273.15) * g * dzkl
961 if (l < iwrml) then
962 areape = areape + area1
963 else
964 surfw = surfw + area1
965 endif
966 elseif (l > lhiwrm) then
967 area1 = log(t(l)/273.15) * g * dzkl
968 areane = areane + abs(area1)
969 endif
970 pintk1 = pintk2
971 enddo
972
973!
974! decision tree time
975!
976 if (areape < 2.0) then ! very little or no positive energy aloft, check for
977 ! positive energy just above the surface to determine rain vs. snow
978 if (surfw < 5.6) then ! not enough positive energy just above the surface snow = 1
979 ptype = 1
980 else if (surfw > 13.2) then ! enough positive energy just above the surface rain = 8
981 ptype = 8
982 else ! transition zone, assume equally likely rain/snow
983 ! picking a random number, if <=0.5 snow
984 r1 = rn(1)
985 if (r1 <= 0.5) then ! snow = 1
986 ptype = 1
987 else ! rain = 8
988 ptype = 8
989 end if
990 end if
991!
992 else ! some positive energy aloft, check for enough negative energy
993 ! to freeze and make ice pellets to determine ip vs. zr
994
995 if (areane > 66.0+0.66*areape) then
996! enough negative area to make ip,
997! now need to check if there is enough positive energy
998! just above the surface to melt ip to make rain
999 if (surfw < 5.6) then ! not enough energy at the surface to melt ip ice pellets = 2
1000 ptype = 2
1001 elseif (surfw > 13.2) then ! enough energy at the surface to melt ip rain = 8
1002 ptype = 8
1003 else ! transition zone, assume equally likely ip/rain picking a random number, if <=0.5 ip
1004 r1 = rn(1)
1005 if (r1 <= 0.5) then ! ice pellets = 2
1006 ptype = 2
1007 else ! rain = 8
1008 ptype = 8
1009 end if
1010 end if
1011 elseif (areane < 46.0+0.66*areape) then
1012! not enough negative energy to refreeze, check surface temp to determine rain vs. zr
1013 if (tlmhk < 273.15) then ! freezing rain = 4
1014 ptype = 4
1015 else ! rain = 8
1016 ptype = 8
1017 end if
1018 else
1019! transition zone, assume equally likely ip/zr picking a random number, if <=0.5 ip
1020 r1 = rn(1)
1021 if (r1 <= 0.5) then
1022! still need to check positive energy just above the surface to melt ip vs. rain
1023 if (surfw < 5.6) then ! ice pellets = 2
1024 ptype = 2
1025 else if (surfw > 13.2) then ! rain = 8
1026 ptype = 8
1027 else
1028! transition zone, assume equally likely ip/rain picking a random number, if <=0.5 ip
1029 r2 = rn(2)
1030 if (r2 <= 0.5) then ! ice pellets = 2
1031 ptype = 2
1032 else ! rain = 8
1033 ptype = 8
1034 end if
1035 end if
1036 else
1037! not enough negative energy to refreeze, check surface temp to determine rain vs. zr
1038 if (tlmhk < 273.15) then ! freezing rain = 4
1039 ptype = 4
1040 else ! rain = 8
1041 ptype = 8
1042 end if
1043 end if
1044 end if
1045 end if
1046!
1047 return
1048 end
1049!
1056 subroutine calwxt_revised(lm,lp1,t,q,pmid,pint, &
1057 d608,rog,epsq,zint,twet,iwx)
1058!
1059! file: calwxt.f
1060! written: 11 november 1993, michael baldwin
1061! revisions:
1062! 30 sept 1994-setup new decision tree (m baldwin)
1063! 12 june 1998-conversion to 2-d (t black)
1064! 01-10-25 h chuang - modified to process hybrid model output
1065! 02-01-15 mike baldwin - wrf version
1066! 05-07-07 binbin zhou - add prec for rsm
1067! 05-08-24 geoff manikin - modified the area requirements
1068! to make an alternate algorithm
1069!
1070!
1071! routine to compute precipitation type using a decision tree
1072! approach that uses variables such as integrated wet bulb temp
1073! below freezing and lowest layer temperature
1074!
1075! see baldwin and contorno preprint from 13th weather analysis
1076! and forecasting conference for more details
1077! (or baldwin et al, 10th nwp conference preprint)
1078!
1079! since the original version of the algorithm has a high bias
1080! for freezing rain and sleet, the goal is to balance that bias
1081! with a version more likely to predict snow
1082!
1083! use params_mod
1084! use ctlblk_mod
1085!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1086 use machine , only : kind_phys
1087 implicit none
1088!
1089! list of variables needed
1090! parameters:
1091! d608,rog,h1,d00
1092!hc parameter(d608=0.608,rog=287.04/9.8,h1=1.0,d00=0.0)
1093!
1094! input:
1095! t,q,pmid,htm,lmh,zint
1096
1097 integer,intent(in) :: lm,lp1
1098 real(kind=kind_phys),dimension(lm),intent(in) :: t,q,pmid,twet
1099 real(kind=kind_phys),dimension(lp1),intent(in) :: pint,zint
1100 real(kind=kind_phys),intent(in) :: d608,rog,epsq
1101! output:
1102! iwx - instantaneous weather type.
1103! acts like a 4 bit binary
1104! 1111 = rain/freezing rain/ice pellets/snow
1105! where the one's digit is for snow
1106! the two's digit is for ice pellets
1107! the four's digit is for freezing rain
1108! and the eight's digit is for rain
1109 integer, intent(out) :: iwx
1110! internal:
1111!
1112 real(kind=kind_phys), parameter :: d00=0.0
1113 integer karr,licee
1114 real(kind=kind_phys) tcold,twarm
1115 logical :: needs_retry
1116!
1117 integer l,lmhk,lice,iwrml,ifrzl
1118 real(kind=kind_phys) psfck,tdchk,a,tdkl,tdpre,tlmhk,twrmk,areas8,areap4,area1, &
1119 surfw,surfc,dzkl,pintk1,pintk2,pm150,qkl,tkl,pkl,area0,areap0
1120
1121! subroutines called:
1122! wetbulb
1123!
1124!
1125! initialize weather type array to zero (ie, off).
1126! we do this since we want iwx to represent the
1127! instantaneous weather type on return.
1128!
1129!
1130! allocate local storage
1131!
1132!
1133 iwx = 0
1134 lmhk=lm
1135!
1136! find coldest and warmest temps in saturated layer between
1137! 70 mb above ground and 500 mb
1138! also find highest saturated layer in that range
1139!
1140!meb
1141 psfck = pint(lp1)
1142!meb
1143 tdchk = 2.0
1144 needs_retry = .true.
1145
1146 retry_loop: do while (needs_retry)
1147 needs_retry = .false.
1148 tcold = t(lmhk)
1149 twarm = t(lmhk)
1150 licee = lmhk
1151!
1152 do l=1,lmhk
1153 qkl = q(l)
1154 qkl = max(epsq,qkl)
1155 tkl = t(l)
1156 pkl = pmid(l)
1157!
1158! skip past this if the layer is not between 70 mb above ground
1159! and 500 mb
1160!
1161 if (pkl < 50000.0 .or. pkl > psfck-7000.0) cycle
1162 a = log(qkl*pkl/(6.1078*(0.378*qkl+0.622)))
1163 tdkl = (237.3*a)/(17.269-a)+273.15
1164 tdpre = tkl-tdkl
1165 if (tdpre < tdchk .and. tkl < tcold) tcold = tkl
1166 if (tdpre < tdchk .and. tkl > twarm) twarm = tkl
1167 if (tdpre < tdchk .and. l < licee) licee = l
1168 enddo
1169!
1170! if no sat layer at dew point dep=tdchk, increase tdchk
1171! and start again (but don't make tdchk > 6)
1172!
1173 if (tcold == t(lmhk) .and. tdchk < 6.0) then
1174 tdchk = tdchk + 2.0
1175 needs_retry = .true.
1176 endif
1177
1178 end do retry_loop
1179!
1180! lowest layer t
1181!
1182 karr = 0
1183 lmhk = lm
1184 tlmhk = t(lmhk)
1185!
1186! decision tree time
1187!
1188 if (tcold > 269.15) then
1189 if (tlmhk <= 273.15) then
1190! turn on the flag for freezing rain = 4 if its not on already
1191! izr=mod(iwx,8)/4
1192! if (izr.lt.1) iwx=iwx+4
1193 iwx = iwx + 4
1194 karr = 1
1195 else
1196! turn on the flag for rain = 8 if its not on already
1197! irain=iwx/8
1198! if (irain.lt.1) iwx=iwx+8
1199 iwx = iwx + 8
1200 karr = 1
1201 endif
1202 endif
1203!
1204 if (karr > 0)then
1205 lmhk = lm
1206 lice = licee
1207!meb
1208 psfck = pint(lp1)
1209!meb
1210 tlmhk = t(lmhk)
1211 twrmk = twarm
1212!
1213! twet area variables
1214! calculate only what is needed
1215! from ground to 150 mb above surface
1216! from ground to tcold layer
1217! and from ground to 1st layer where wet bulb t < 0.0
1218!
1219! pintk1 is the pressure at the bottom of the layer
1220! pintk2 is the pressure at the top of the layer
1221!
1222! areap4 is the area of twet above -4 c below highest sat lyr
1223! areap0 is the area of twet above 0 c below highest sat lyr
1224!
1225 areas8 = d00
1226 areap4 = d00
1227 areap0 = d00
1228 surfw = d00
1229 surfc = d00
1230
1231!
1232 do l=lmhk,lice,-1
1233 dzkl = zint(l)-zint(l+1)
1234 area1 = (twet(l)-269.15)*dzkl
1235 area0 = (twet(l)-273.15)*dzkl
1236 if (twet(l) >= 269.15) areap4 = areap4 + area1
1237 if (twet(l) >= 273.15) areap0 = areap0 + area0
1238 enddo
1239!
1240! if (areap4.lt.3000.0) then turn on the flag for snow = 1 if its not on already
1241! isno=mod(iwx,2)
1242! if (isno.lt.1) iwx=iwx+1
1243! iwx=iwx+1
1244! go to 1900
1245! endif
1246 if (areap0 < 350.0) then ! turn on the flag for snow = 1
1247 iwx = iwx + 1
1248 return
1249 endif
1250!
1251! areas8 is the net area of twet w.r.t. freezing in lowest 150mb
1252!
1253 pintk1 = psfck
1254 pm150 = psfck - 15000.
1255!
1256 do l=lmhk,1,-1
1257 pintk2 = pint(l)
1258 if(pintk1 >= pm150) then
1259 dzkl = zint(l)-zint(l+1)
1260!
1261! sum partial layer if in 150 mb agl layer
1262!
1263 if(pintk2 < pm150) dzkl = t(l)*(q(l)*d608+1.0)*rog* &
1264 log(pintk1/pm150)
1265 area1 = (twet(l)-273.15)*dzkl
1266 areas8 = areas8 + area1
1267 endif
1268 pintk1=pintk2
1269 enddo
1270!
1271! surfw is the area of twet above freezing between the ground
1272! and the first layer above ground below freezing
1273! surfc is the area of twet below freezing between the ground
1274! and the warmest sat layer
1275!
1276 ifrzl = 0
1277 iwrml = 0
1278!
1279 do l=lmhk,1,-1
1280 if (ifrzl == 0 .and. t(l) < 273.15) ifrzl = 1
1281 if (iwrml == 0 .and. t(l) >= twrmk) iwrml = 1
1282!
1283 if (iwrml == 0 .or. ifrzl == 0) then
1284! if(pmid(l) .lt. 50000.)print*,'twet needed above 500mb'
1285 dzkl = zint(l)-zint(l+1)
1286 area1 = (twet(l)-273.15)*dzkl
1287 if(ifrzl == 0 .and. twet(l) >= 273.15) surfw = surfw + area1
1288 if(iwrml == 0 .and. twet(l) <= 273.15) surfc = surfc + area1
1289 endif
1290 enddo
1291 if (surfc < -3000.0 .or. &
1292 & (areas8 < -3000.0 .and. surfw < 50.0)) then
1293! turn on the flag for ice pellets = 2 if its not on already
1294! iip=mod(iwx,4)/2
1295! if (iip.lt.1) iwx=iwx+2
1296 iwx = iwx + 2
1297 return
1298 endif
1299!
1300 if (tlmhk < 273.15) then
1301! turn on the flag for freezing rain = 4 if its not on already
1302! izr=mod(iwx(k),8)/4
1303! if (izr.lt.1) iwx(k)=iwx(k)+4
1304 iwx = iwx + 4
1305 else
1306! turn on the flag for rain = 8 if its not on already
1307! irain=iwx(k)/8
1308! if (irain.lt.1) iwx(k)=iwx(k)+8
1309 iwx = iwx + 8
1310 endif
1311! print *, 'revised check ', iwx(500,800)
1312 endif
1313
1314 return
1315 end
1316!
1321 subroutine calwxt_dominant(nalg,rain,freezr,sleet,snow, &
1322 & domr,domzr,domip,doms)
1323!
1324! written: 24 august 2005, g manikin
1325!
1326! this routine takes the precip type solutions from different
1327! algorithms and sums them up to give a dominant type
1328!
1329!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1330 use machine , only : kind_phys
1331 implicit none
1332!
1333! input:
1334 integer,intent(in) :: nalg
1335 real(kind=kind_phys),intent(out) :: doms,domr,domzr,domip
1336 integer,dimension(nalg),intent(in) :: rain,snow,sleet,freezr
1337 integer l
1338 real(kind=kind_phys) totsn,totip,totr,totzr
1339!--------------------------------------------------------------------------
1340! print* , 'into dominant'
1341 domr = 0.
1342 doms = 0.
1343 domzr = 0.
1344 domip = 0.
1345!
1346 totsn = 0
1347 totip = 0
1348 totr = 0
1349 totzr = 0
1351 do l = 1, nalg
1352 if (rain(l) > 0) then
1353 totr = totr + 1
1354 elseif (snow(l) > 0) then
1355 totsn = totsn + 1
1356 elseif (sleet(l) > 0) then
1357 totip = totip + 1
1358 elseif (freezr(l) > 0) then
1359 totzr = totzr + 1
1360 endif
1361 enddo
1362
1365 if (totsn > totip) then
1366 if (totsn > totzr) then
1367 if (totsn >= totr) then
1368 doms = 1
1369 else
1370 domr = 1
1371 endif
1372 elseif (totzr >= totr) then
1373 domzr = 1
1374 else
1375 domr = 1
1376 endif
1377 else if (totip > totzr) then
1378 if (totip >= totr) then
1379 domip = 1
1380 else
1381 domr = 1
1382 endif
1383 else if (totzr >= totr) then
1384 domzr = 1
1385 else
1386 domr = 1
1387 endif
1388!
1389 return
1390 end
1391end module calpreciptype_mod
This module defines four algorithms that are called to calculate dominant precipitation type,...