UPP  001
 All Data Structures Files Functions Pages
FRZLVL.f
Go to the documentation of this file.
1 
40  SUBROUTINE frzlvl(ZFRZ,RHFRZ,PFRZL)
41 
42 !
43 !
44  use vrbls3d, only: pint, t, zmid, q, pmid
45  use vrbls2d, only: fis, tshltr, pshltr, qshltr
46  use masks, only: lmh
47  use params_mod, only: gi, d00, capa, d0065, tfrz, pq0, a2, a3, a4
48  use ctlblk_mod, only: jsta, jend, spval, lm, modelname, im
49  use physcons_post, only: con_rd, con_rv, con_eps, con_epsm1
50  use upp_physics, only: fpvsnew
51 
52  implicit none
53 !
54 ! DECLARE VARIABLES.
55 !
56  REAL,dimension(im,jsta:jend) :: rhfrz, zfrz, pfrzl
57  integer i,j,llmh,l
58  real htsfc,psfc,tsfc,qsfc,qsat,rhsfc,delz,delt,delq,delalp, &
59  delzp,zl,dzabv,qfrz,alpl,alph,alpfrz,pfrz,qsfrz,rhz,zu, &
60  dzfr,es
61 !
62 !*********************************************************************
63 ! START FRZLVL.
64 !
65 !
66 !
67 ! LOOP OVER HORIZONTAL GRID.
68 !
69 !!$omp parallel do &
70 ! & private(i,j,alpfrz,alph,alpl,delalp,delq,delt,delz, &
71 ! & delzp,dzabv,dzfr,htsfc,l,llmh,psfc,qfrz, &
72 ! & qsat,qsfc,qsfrz,rhsfc,rhz,tsfc, &
73 ! & zl,zu)
74 
75  DO 20 j=jsta,jend
76  DO 20 i=1,im
77  htsfc = fis(i,j)*gi
78  llmh = nint(lmh(i,j))
79  rhfrz(i,j) = d00
80  zfrz(i,j) = htsfc
81  psfc = pint(i,j,llmh+1)
82  pfrzl(i,j) = psfc
83 !
84 ! CHECK IF FREEZING LEVEL IS AT THE GROUND.
85 !
86 ! IF(SM(I,J)/=SPVAL .AND. THZ0(I,J)/=SPVAL .AND. &
87 ! THS(I,J)/=SPVAL)THEN
88 ! TSFC = (SM(I,J)*THZ0(I,J)+(1.-SM(I,J))*THS(I,J)) &
89 ! *(PINT(I,J,NINT(LMH(I,J))+1)/P1000)**CAPA
90 ! Per AWC's request, use 2m T instead of skin T so that freezing level
91 ! would be above ground more often
92  IF(tshltr(i,j)/=spval .AND. pshltr(i,j)/=spval)THEN
93  tsfc=tshltr(i,j)*(pshltr(i,j)*1.e-5)**capa
94  ELSE
95 ! GFS analysis does not have flux file to retrieve TSFC from
96  tsfc=t(i,j,lm)+d0065*(zmid(i,j,lm)-htsfc-2.0)
97  END IF
98  IF (tsfc<=tfrz) THEN
99 ! ZFRZ(I,J) = HTSFC+(TSFC-TFRZ)/D0065
100  zfrz(i,j) = htsfc+2.0+(tsfc-tfrz)/d0065
101 ! IF(SM(I,J)/=SPVAL .AND. QZ0(I,J)/=SPVAL .AND. &
102 ! QS(I,J)/=SPVAL)THEN
103 ! QSFC = SM(I,J)*QZ0(I,J)+(1.-SM(I,J))*QS(I,J)
104 ! GFS does not output QS
105 ! ELSE IF(QSHLTR(I,J)/=SPVAL)THEN
106  IF(qshltr(i,j)/=spval)THEN
107  psfc=pshltr(i,j)
108  qsfc=qshltr(i,j)
109  ELSE
110  qsfc=q(i,j,lm)
111  psfc=pmid(i,j,lm)
112  END IF
113 !
114  IF(modelname == 'GFS' .OR. modelname == 'RAPR')THEN
115  es=fpvsnew(tsfc)
116  es=min(es,psfc)
117  qsat=con_eps*es/(psfc+con_epsm1*es)
118  ELSE
119  qsat=pq0/psfc*exp(a2*(tsfc-a3)/(tsfc-a4))
120  END IF
121 !
122  rhsfc = qsfc/qsat
123  rhsfc = amax1(0.01,rhsfc)
124  rhsfc = amin1(rhsfc,1.0)
125  rhfrz(i,j)= rhsfc
126  pfrzl(i,j)= psfc
127  cycle
128  ENDIF
129 !
130 ! OTHERWISE, LOCATE THE FREEZING LEVEL ALOFT.
131 !
132  DO 10 l = llmh,1,-1
133  IF (t(i,j,l)<=tfrz) THEN
134  IF (l<llmh) THEN
135  delz = zmid(i,j,l)-zmid(i,j,l+1)
136  zl = zmid(i,j,l+1)
137  delt = t(i,j,l)-t(i,j,l+1)
138  zfrz(i,j) = zl + (tfrz-t(i,j,l+1))/delt*delz
139 !
140  dzabv = zfrz(i,j)-zl
141  delq = q(i,j,l)-q(i,j,l+1)
142  qfrz = q(i,j,l+1) + delq/delz*dzabv
143  qfrz = amax1(0.0,qfrz)
144 !
145 !
146  alpl = alog(pmid(i,j,l+1))
147  alph = alog(pmid(i,j,l))
148  alpfrz = alpl + (alph-alpl)/delz*dzabv
149  pfrz = exp(alpfrz)
150  pfrzl(i,j) = pfrz
151  IF(modelname == 'GFS' .OR.modelname == 'RAPR')THEN
152  es=fpvsnew(tfrz)
153  es=min(es,pfrz)
154  qsfrz=con_eps*es/(pfrz+con_epsm1*es)
155  ELSE
156  qsfrz=pq0/pfrz &
157  *exp(a2*(tfrz-a3)/(tfrz-a4))
158  END IF
159 !
160  rhz = qfrz/qsfrz
161  rhz = amax1(0.01,rhz)
162  rhz = amin1(rhz,1.0)
163  rhfrz(i,j) = rhz
164 !
165  ELSE
166  zu = zmid(i,j,l)
167  zl = htsfc+2.0
168  delz = zu-zl
169  IF(tshltr(i,j)/=spval .AND. pshltr(i,j)/=spval)THEN
170  tsfc=tshltr(i,j)*(pshltr(i,j)*1.e-5)**capa
171  ELSE
172 ! GFS analysis does not have flux file to retrieve TSFC from
173  tsfc=t(i,j,lm)+d0065*(zmid(i,j,lm)-htsfc-2.0)
174  END IF
175  delt = t(i,j,l)-tsfc
176  zfrz(i,j) = zl + (tfrz-tsfc)/delt*delz
177 !
178  dzabv = zfrz(i,j)-zl
179 ! GFS does not output QS
180  IF(qshltr(i,j)/=spval)THEN
181  qsfc=qshltr(i,j)
182  ELSE
183  qsfc=q(i,j,lm)
184  END IF
185  delq = q(i,j,l)-qsfc
186  qfrz = qsfc + delq/delz*dzabv
187  qfrz = amax1(0.0,qfrz)
188 !
189  alph = alog(pmid(i,j,l))
190  alpl = alog(psfc)
191  delalp = alph-alpl
192  alpfrz = alpl + delalp/delz*dzabv
193  pfrz = exp(alpfrz)
194 !
195  pfrzl(i,j) = pfrz
196  IF(modelname == 'GFS'.OR.modelname == 'RAPR')THEN
197  es=fpvsnew(tfrz)
198  es=min(es,pfrz)
199  qsfrz=con_eps*es/(pfrz+con_epsm1*es)
200  ELSE
201  qsfrz=pq0/pfrz &
202  *exp(a2*(tfrz-a3)/(tfrz-a4))
203  END IF
204 !
205  rhz = qfrz/qsfrz
206  rhz = amax1(0.01,rhz)
207  rhz = amin1(rhz,1.0)
208  rhfrz(i,j)= rhz
209  ENDIF
210 !
211 ! BOUND FREEZING LEVEL RH. FREEZING LEVEL HEIGHT IS
212 ! MEASURED WITH RESPECT TO MEAN SEA LEVEL.
213 !
214 ! RHFRZ(I,J) = AMAX1(0.01,RHFRZ(I,J))
215 ! RHFRZ(I,J) = AMIN1(RHFRZ(I,J),1.00)
216  zfrz(i,j) = amax1(0.0,zfrz(i,j))
217  EXIT
218  ENDIF
219  10 CONTINUE
220 20 CONTINUE
221 !
222 ! END OF ROUTINE.
223 !
224  RETURN
225  END
Definition: MASKS_mod.f:1
Definition: physcons.f:1
elemental real function, public fpvsnew(t)
Definition: UPP_PHYSICS.f:341
calcape() computes CAPE/CINS and other storm related variables.
Definition: UPP_PHYSICS.f:27