UPP  001
 All Data Structures Files Functions Pages
CALWXT.f
1  SUBROUTINE calwxt_post(T,Q,PMID,PINT,HTM,LMH,PREC,ZINT,IWX,ZWET)
2 !
3 ! FILE: CALWXT.f
4 ! WRITTEN: 11 NOVEMBER 1993, MICHAEL BALDWIN
5 ! REVISIONS:
6 ! 30 SEPT 1994-SETUP NEW DECISION TREE (M BALDWIN)
7 ! 12 JUNE 1998-CONVERSION TO 2-D (T BLACK)
8 ! 01-10-25 H CHUANG - MODIFIED TO PROCESS HYBRID MODEL OUTPUT
9 ! 02-01-15 MIKE BALDWIN - WRF VERSION
10 ! 05-07-07 BINBIN ZHOU - ADD PREC FOR RSM
11 ! 19-10-30 Bo CUI - REMOVE "GOTO" STATEMENT
12 ! 21-07-26 Wen Meng - Restrict computation from undefined grids
13 !
14 !
15 ! ROUTINE TO COMPUTE PRECIPITATION TYPE USING A DECISION TREE
16 ! APPROACH THAT USES VARIABLES SUCH AS INTEGRATED WET BULB TEMP
17 ! BELOW FREEZING AND LOWEST LAYER TEMPERATURE
18 !
19 ! SEE BALDWIN AND CONTORNO PREPRINT FROM 13TH WEATHER ANALYSIS
20 ! AND FORECASTING CONFERENCE FOR MORE DETAILS
21 ! (OR BALDWIN ET AL, 10TH NWP CONFERENCE PREPRINT)
22 !
23  use params_mod, only: h1m12, d00, d608, h1, rog
24  use ctlblk_mod, only: jsta, jend, spval, modelname,pthresh, im, &
25  jsta_2l, jend_2u, lm, lp1
26 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27  implicit none
28 !
29 ! INPUT:
30 ! T,Q,PMID,HTM,LMH,PREC,ZINT
31 !
32  real,dimension(IM,jsta_2l:jend_2u),intent(in) :: lmh
33  real,dimension(IM,jsta_2l:jend_2u,LM),intent(in) :: t,q,pmid,htm
34  real,dimension(IM,jsta_2l:jend_2u,LP1),intent(in) :: zint,pint
35  integer,DIMENSION(IM,jsta:jend),intent(inout) :: iwx
36  real,dimension(IM,jsta_2l:jend_2u),intent(inout) :: prec
37  real,DIMENSION(IM,jsta:jend),intent(inout) :: zwet
38 
39 
40 ! OUTPUT:
41 ! IWX - INSTANTANEOUS WEATHER TYPE.
42 ! ACTS LIKE A 4 BIT BINARY
43 ! 1111 = RAIN/FREEZING RAIN/ICE PELLETS/SNOW
44 ! WHERE THE ONE'S DIGIT IS FOR SNOW
45 ! THE TWO'S DIGIT IS FOR ICE PELLETS
46 ! THE FOUR'S DIGIT IS FOR FREEZING RAIN
47 ! AND THE EIGHT'S DIGIT IS FOR RAIN
48 !
49 ! INTERNAL:
50 !
51  REAL, ALLOCATABLE :: twet(:,:,:)
52  integer,DIMENSION(IM,jsta:jend) :: karr,licee
53  real, DIMENSION(IM,jsta:jend) :: tcold,twarm
54 
55  logical :: jcontinue=.true.
56 ! SUBROUTINES CALLED:
57 ! WETBULB
58 !
59 !
60 ! INITIALIZE WEATHER TYPE ARRAY TO ZERO (IE, OFF).
61 ! WE DO THIS SINCE WE WANT IWX TO REPRESENT THE
62 ! INSTANTANEOUS WEATHER TYPE ON RETURN.
63 !
64 !
65 ! ALLOCATE LOCAL STORAGE
66 !
67 
68  integer i,j,l,lmhk,lice,ifrel,iwrml,ifrzl
69  real psfck,tdchk,a,tdkl,tdpre,tlmhk,twrmk,areas8,areap4, &
70  surfw,surfc,dzkl,area1,pintk1,pintk2,pm150,pkl,tkl,qkl
71 
72  ALLOCATE ( twet(im,jsta_2l:jend_2u,lm) )
73 
74 !
75 !!$omp parallel do
76  DO j=jsta,jend
77  DO i=1,im
78  iwx(i,j) = 0
79  zwet(i,j) = spval
80 ! if (I == 324 .and. J == 390) then
81 ! LMHK = NINT(LMH(I,J))
82 ! DO L=LMHK,1,-1
83 ! print *, 'tprof ', L, T(I,J,L)
84 ! ENDDO
85 ! endif
86  ENDDO
87  ENDDO
88 
89  IF(modelname=='RSM') THEN !add by Binbin because of different unit
90  DO j=jsta,jend
91  DO i=1,im
92  prec(i,j) = prec(i,j)*3*3600.0
93  ENDDO
94  ENDDO
95  END IF
96 
97 
98 !
99 !!$omp parallel do private(a,lmhk,pkl,psfck,qkl,tdchk,tdkl,tdpre,tkl)
100  DO 800 j=jsta,jend
101  DO 800 i=1,im
102  lmhk=nint(lmh(i,j))
103 !
104 ! SKIP THIS POINT IF NO PRECIP THIS TIME STEP
105 !
106  IF (prec(i,j)<=pthresh) cycle
107 !
108 ! FIND COLDEST AND WARMEST TEMPS IN SATURATED LAYER BETWEEN
109 ! 70 MB ABOVE GROUND AND 500 MB
110 ! ALSO FIND HIGHEST SATURATED LAYER IN THAT RANGE
111 !
112 !meb
113  psfck=pint(i,j,lmhk+1)
114 !meb
115  tdchk=2.0
116 
117  jcontinue=.true.
118  do while (jcontinue)
119 
120  760 tcold(i,j) = t(i,j,lmhk)
121  twarm(i,j) = t(i,j,lmhk)
122  licee(i,j) = lmhk
123 !
124  DO 775 l=1,lmhk
125  qkl = q(i,j,l)
126  qkl = max(h1m12,qkl)
127  tkl = t(i,j,l)
128  pkl = pmid(i,j,l)
129 !
130 ! SKIP PAST THIS IF THE LAYER IS NOT BETWEEN 70 MB ABOVE GROUND
131 ! AND 500 MB
132 !
133  IF (pkl<50000.0.OR.pkl>psfck-7000.0) cycle
134  IF(qkl<spval)THEN
135  a=alog(qkl*pkl/(610.78*(0.378*qkl+0.622)))
136  tdkl=(237.3*a)/(17.269-a)+273.15
137  tdpre=tkl-tdkl
138  IF (tdpre<tdchk.AND.tkl<tcold(i,j)) tcold(i,j)=tkl
139  IF (tdpre<tdchk.AND.tkl>twarm(i,j)) twarm(i,j)=tkl
140  IF (tdpre<tdchk.AND.l<licee(i,j)) licee(i,j)=l
141  ENDIF
142  775 CONTINUE
143 !
144 ! IF NO SAT LAYER AT DEW POINT DEP=TDCHK, INCREASE TDCHK
145 ! AND START AGAIN (BUT DON'T MAKE TDCHK > 6)
146 !
147  IF (tcold(i,j)==t(i,j,lmhk).AND.tdchk<6.0) THEN
148  tdchk=tdchk+2.0
149  ELSE
150  jcontinue=.false.
151  ENDIF
152  enddo ! enddo jcontinue
153  800 CONTINUE
154 !
155 ! LOWEST LAYER T
156 !
157  DO 850 j=jsta,jend
158  DO 850 i=1,im
159  karr(i,j)=0
160  IF (prec(i,j)<=pthresh) cycle
161  lmhk=nint(lmh(i,j))
162  tlmhk=t(i,j,lmhk)
163 !
164 ! DECISION TREE TIME
165 !
166  IF (tcold(i,j)>269.15) THEN
167  IF (tlmhk<=273.15) THEN
168 ! TURN ON THE FLAG FOR
169 ! FREEZING RAIN = 4
170 ! IF ITS NOT ON ALREADY
171 ! IZR=MOD(IWX(I,J),8)/4
172 ! IF (IZR<1) IWX(I,J)=IWX(I,J)+4
173  iwx(i,j)=iwx(i,j)+4
174  cycle
175  ELSE
176 ! TURN ON THE FLAG FOR
177 ! RAIN = 8
178 ! IF ITS NOT ON ALREADY
179 ! IRAIN=IWX(I,J)/8
180 ! IF (IRAIN<1) IWX(I,J)=IWX(I,J)+8
181  iwx(i,j)=iwx(i,j)+8
182  cycle
183  ENDIF
184  ENDIF
185  karr(i,j)=1
186  850 CONTINUE
187 !
188 ! COMPUTE WET BULB ONLY AT POINTS THAT NEED IT
189 !
190  CALL wetbulb(t,q,pmid,htm,karr,twet)
191  CALL wetfrzlvl(twet,zwet)
192 !
193 !!$omp parallel do &
194 ! & private(area1,areap4,areas8,dzkl,ifrzl,iwrml,lice, &
195 ! & lmhk,pintk1,pintk2,pm150,psfck,surfc,surfw, &
196 ! & tlmhk,twrmk)
197  DO 1900 j=jsta,jend
198  DO 1900 i=1,im
199 ! IF (I == 324 .AND. J == 390) THEN
200 ! LMHK=NINT(LMH(I,J))
201 ! DO L=LMHK,1,-1
202 ! print *, 'TW NCEP ', TWET(I,J,L)
203 ! ENDDO
204 ! ENDIF
205  IF(karr(i,j)>0)THEN
206  lmhk=nint(lmh(i,j))
207  lice=licee(i,j)
208 !meb
209  psfck=pint(i,j,lmhk+1)
210 !meb
211  tlmhk=t(i,j,lmhk)
212  twrmk=twarm(i,j)
213 !
214 ! TWET AREA VARIABLES
215 ! CALCULATE ONLY WHAT IS NEEDED
216 ! FROM GROUND TO 150 MB ABOVE SURFACE
217 ! FROM GROUND TO TCOLD LAYER
218 ! AND FROM GROUND TO 1ST LAYER WHERE WET BULB T < 0.0
219 !
220 ! PINTK1 IS THE PRESSURE AT THE BOTTOM OF THE LAYER
221 ! PINTK2 IS THE PRESSURE AT THE TOP OF THE LAYER
222 !
223 ! AREAP4 IS THE AREA OF TWET ABOVE -4 C BELOW HIGHEST SAT LYR
224 !
225  areas8=d00
226  areap4=d00
227  surfw =d00
228  surfc =d00
229 !
230  DO 1945 l=lmhk,lice,-1
231  dzkl=zint(i,j,l)-zint(i,j,l+1)
232  area1=(twet(i,j,l)-269.15)*dzkl
233  IF (twet(i,j,l)>=269.15) areap4=areap4+area1
234  1945 CONTINUE
235 !
236  IF (areap4<3000.0) THEN
237 ! TURN ON THE FLAG FOR
238 ! SNOW = 1
239 ! IF ITS NOT ON ALREADY
240 ! ISNO=MOD(IWX(I,J),2)
241 ! IF (ISNO<1) IWX(I,J)=IWX(I,J)+1
242  iwx(i,j)=iwx(i,j)+1
243  cycle
244  ENDIF
245 !
246 ! AREAS8 IS THE NET AREA OF TWET W.R.T. FREEZING IN LOWEST 150MB
247 !
248  pintk1=psfck
249  pm150=psfck-15000.
250 !
251  DO 1955 l=lmhk,1,-1
252  pintk2=pint(i,j,l)
253  IF(pintk1<pm150) THEN
254  pintk1=pintk2
255  ELSE
256  dzkl=zint(i,j,l)-zint(i,j,l+1)
257 !
258 ! SUM PARTIAL LAYER IF IN 150 MB AGL LAYER
259 !
260  IF(pintk2<pm150) &
261  dzkl=t(i,j,l)*(q(i,j,l)*d608+h1)*rog*alog(pintk1/pm150)
262  area1=(twet(i,j,l)-273.15)*dzkl
263  areas8=areas8+area1
264  pintk1=pintk2
265  ENDIF
266  1955 CONTINUE
267 !
268 ! SURFW IS THE AREA OF TWET ABOVE FREEZING BETWEEN THE GROUND
269 ! AND THE FIRST LAYER ABOVE GROUND BELOW FREEZING
270 ! SURFC IS THE AREA OF TWET BELOW FREEZING BETWEEN THE GROUND
271 ! AND THE WARMEST SAT LAYER
272 !
273  ifrzl=0
274  iwrml=0
275 !
276  DO 2050 l=lmhk,1,-1
277  IF (ifrzl==0.AND.t(i,j,l)<273.15) ifrzl=1
278  IF (iwrml==0.AND.t(i,j,l)>=twrmk) iwrml=1
279 !
280  IF (iwrml==0.OR.ifrzl==0) THEN
281  dzkl=zint(i,j,l)-zint(i,j,l+1)
282  area1=(twet(i,j,l)-273.15)*dzkl
283  IF(ifrzl==0.AND.twet(i,j,l)>=273.15)surfw=surfw+area1
284  IF(iwrml==0.AND.twet(i,j,l)<=273.15)surfc=surfc+area1
285  ENDIF
286  2050 CONTINUE
287  IF(surfc<-3000.0.OR. &
288  (areas8<-3000.0.AND.surfw<50.0)) THEN
289 ! TURN ON THE FLAG FOR
290 ! ICE PELLETS = 2
291 ! IF ITS NOT ON ALREADY
292 ! IIP=MOD(IWX(I,J),4)/2
293 ! IF (IIP<1) IWX(I,J)=IWX(I,J)+2
294  iwx(i,j)=iwx(i,j)+2
295  cycle
296  ENDIF
297 !
298  IF(tlmhk<273.15) THEN
299 ! TURN ON THE FLAG FOR
300 ! FREEZING RAIN = 4
301 ! IF ITS NOT ON ALREADY
302 ! IZR=MOD(IWX(K),8)/4
303 ! IF (IZR<1) IWX(K)=IWX(K)+4
304  iwx(i,j)=iwx(i,j)+4
305  ELSE
306 ! TURN ON THE FLAG FOR
307 ! RAIN = 8
308 ! IF ITS NOT ON ALREADY
309 ! IRAIN=IWX(K)/8
310 ! IF (IRAIN<1) IWX(K)=IWX(K)+8
311  iwx(i,j)=iwx(i,j)+8
312  ENDIF
313  ENDIF
314  1900 CONTINUE
315 !---------------------------------------------------------
316  DEALLOCATE (twet)
317 
318  IF(modelname == 'RSM') THEN !add by Binbin, change back
319 !!$omp parallel do private(i,j)
320  DO j=jsta,jend
321  DO i=1,im
322  prec(i,j) = prec(i,j)/(3*3600.0)
323  ENDDO
324  ENDDO
325  END IF
326 
327  RETURN
328  END