UPP  001
 All Data Structures Files Functions Pages
MDL2SIGMA2.f
Go to the documentation of this file.
1 
2 !
44  SUBROUTINE mdl2sigma2
45 
46 !
47 !
48  use vrbls3d, only: pint, pmid, t, zint, q
49 ! use vrbls2d, only:
50  use masks, only: lmh
51  use params_mod, only: pq0, a2, a3, a4, rgamog
52  use ctlblk_mod, only: pt, jsta_2l, jend_2u, spval, lp1, lm, jsta, jend,&
53  grib, cfld, datapd, fld_info, im, jm, im_jm
54  use rqstfld_mod, only: iget, lvls, id, iavblfld, lvlsxml
55 !
56  implicit none
57 !
58  integer,PARAMETER :: lsig=5
59 !
60 ! DECLARE VARIABLES.
61 !
62  LOGICAL readthk
63 ! REAL,dimension(im,jm) :: FSL, TSL, QSL, osl, usl, vsl, q2sl, fsl1, &
64  REAL,dimension(im,jsta_2l:jend_2u) :: tsl
65  REAL,dimension(im,jsta_2l:jend_2u) :: grid1
66  REAL sigo(lsig+1),dsigo(lsig),asigo(lsig)
67 !
68 ! INTEGER,dimension(im,jm) :: IHOLD,JHOLD,NL1X,NL1XF
69  INTEGER,dimension(im,jsta_2l:jend_2u) :: nl1x
70 !
71 !
72 !--- Definition of the following 2D (horizontal) dummy variables
73 !
74 ! C1D - total condensate
75 ! QW1 - cloud water mixing ratio
76 ! QI1 - cloud ice mixing ratio
77 ! QR1 - rain mixing ratio
78 ! QS1 - snow mixing ratio
79 !
80 ! REAL,dimension(im,jm) :: C1D,QW1,QI1,QR1,qs1,qg1,akh
81 !
82  integer i,j,l,ll,lp,llmh,nhold,ii,jj
83  real ptsigo,psigo,apsigo,fact,ai,bi,tmt0,qsat,tvrl, &
84  tvrblo,tblo,ql,rhl,zl,pl,tl
85 !
86 !
87 !******************************************************************************
88 !
89 ! START MDL2P.
90 !
91 ! SET TOTAL NUMBER OF POINTS ON OUTPUT GRID.
92 !
93 !---------------------------------------------------------------
94 !
95 ! *** PART I ***
96 !
97 ! VERTICAL INTERPOLATION OF EVERYTHING ELSE. EXECUTE ONLY
98 ! IF THERE'S SOMETHING WE WANT.
99 !
100  IF((iget(296)>0) ) THEN !!Air Quality (Plee Oct2003)
101 !
102 !---------------------------------------------------------------------
103 !
104 !--- VERTICAL INTERPOLATION OF GEOPOTENTIAL, SPECIFIC HUMIDITY, TEMPERATURE,
105 ! OMEGA, TKE, & CLOUD FIELDS. START AT THE UPPERMOST TARGET SIGMA LEVEL.
106 !
107  ptsigo=pt
108  readthk=.false.
109  IF(readthk)THEN ! EITHER READ DSG THICKNESS
110  READ(41)dsigo !DSIGO FROM TOP TO BOTTOM
111 !
112  sigo(1)=0.0
113  DO l=2,lsig+1
114  sigo(l)=sigo(l-1)+dsigo(lsig-l+2)
115  END DO
116  sigo(lsig+1)=1.0
117  DO l=1,lsig
118  asigo(l)=0.5*(sigo(l)+sigo(l+1))
119  END DO
120  ELSE ! SPECIFY SIGO
121  asigo( 1)= 0.7000
122  asigo( 2)= 0.7500
123  asigo( 3)= 0.8000
124  asigo( 4)= 0.8500
125  asigo( 5)= 0.9000
126  END IF
127 !***
128 !*** BECAUSE SIGMA LAYERS DO NOT GO UNDERGROUND, DO ALL
129 !*** INTERPOLATION ABOVE GROUND NOW.
130 !***
131 !
132 
133  DO 310 lp=1,lsig
134  nhold=0
135 !
136  DO j=jsta_2l,jend_2u
137  DO i=1,im
138 
139 !
140  tsl(i,j)=spval
141 !
142 !*** LOCATE VERTICAL INDEX OF MODEL MIDLAYER JUST BELOW
143 !*** THE PRESSURE LEVEL TO WHICH WE ARE INTERPOLATING.
144 !
145  nl1x(i,j)=lp1
146  DO l=2,lm
147  llmh = nint(lmh(i,j))
148  psigo=ptsigo+asigo(lp)*(pint(i,j,llmh+1)-ptsigo)
149  IF(nl1x(i,j)==lp1.AND.pmid(i,j,l)>psigo)THEN
150  nl1x(i,j)=l
151  ENDIF
152  ENDDO
153 !
154 ! IF THE PRESSURE LEVEL IS BELOW THE LOWEST MODEL MIDLAYER
155 ! BUT STILL ABOVE THE LOWEST MODEL BOTTOM INTERFACE,
156 ! WE WILL NOT CONSIDER IT UNDERGROUND AND THE INTERPOLATION
157 ! WILL EXTRAPOLATE TO THAT POINT
158 !
159  IF(nl1x(i,j)==lp1.AND.pint(i,j,llmh+1)>=psigo)THEN
160  nl1x(i,j)=lm
161  ENDIF
162 !
163 ! if(NL1X(I,J)==LP1)print*,'Debug: NL1X=LP1 AT '
164 ! 1 ,i,j,lp
165  ENDDO
166  ENDDO
167 !
168 !mptest IF(NHOLD==0)GO TO 310
169 !
170 !!$omp parallel do
171 !!$omp& private(nn,i,j,ll,fact,qsat,rhl)
172 !hc DO 220 NN=1,NHOLD
173 !hc I=IHOLD(NN)
174 !hc J=JHOLD(NN)
175 ! DO 220 J=JSTA,JEND
176 ! DO 220 J=JSTA_2L,JEND_2U
177  DO 220 j=jsta,jend ! Moorthi on Nov 26, 2014
178  DO 220 i=1,im
179  ll=nl1x(i,j)
180 !---------------------------------------------------------------------
181 !*** VERTICAL INTERPOLATION OF GEOPOTENTIAL, TEMPERATURE, SPECIFIC
182 !*** HUMIDITY, CLOUD WATER/ICE, OMEGA, WINDS, AND TKE.
183 !---------------------------------------------------------------------
184 !
185 !HC IF(NL1X(I,J)<=LM)THEN
186  llmh = nint(lmh(i,j))
187  psigo=ptsigo+asigo(lp)*(pint(i,j,llmh+1)-ptsigo)
188  apsigo=log(psigo)
189  IF(nl1x(i,j)<=llmh.and. &
190  (pmid(i,j,ll)-pmid(i,j,ll-1))/=0.)THEN
191 !
192 !---------------------------------------------------------------------
193 ! INTERPOLATE LINEARLY IN LOG(P)
194 !*** EXTRAPOLATE ABOVE THE TOPMOST MIDLAYER OF THE MODEL
195 !*** INTERPOLATION BETWEEN NORMAL LOWER AND UPPER BOUNDS
196 !*** EXTRAPOLATE BELOW LOWEST MODEL MIDLAYER (BUT STILL ABOVE GROUND)
197 !---------------------------------------------------------------------
198 !
199 
200  fact=(apsigo-log(pmid(i,j,ll)))/ &
201  & (log(pmid(i,j,ll))-log(pmid(i,j,ll-1)))
202  tsl(i,j)=t(i,j,ll)+(t(i,j,ll)-t(i,j,ll-1))*fact
203 ! FOR UNDERGROUND PRESSURE LEVELS, ASSUME TEMPERATURE TO CHANGE
204 ! ADIABATICLY, RH TO BE THE SAME AS THE AVERAGE OF THE 2ND AND 3RD
205 ! LAYERS FROM THE GOUND, WIND TO BE THE SAME AS THE LOWEST LEVEL ABOVE
206 ! GOUND
207  ELSE
208  ii=91
209  jj=13
210 ! if(i==ii.and.j==jj) &
211 ! print*,'Debug: underg extra at i,j,lp',i,j,lp
212  pl = pint(i,j,lm-1)
213  zl = zint(i,j,lm-1)
214  tl = 0.5*(t(i,j,lm-2)+t(i,j,lm-1))
215  ql = 0.5*(q(i,j,lm-2)+q(i,j,lm-1))
216  tmt0 = tl - a3
217  ai = 0.008855
218  bi = 1.
219  IF(tmt0<-20.)THEN
220  ai = 0.007225
221  bi = 0.9674
222  ENDIF
223  qsat = pq0/pl*exp(a2*(tl-a3)/(tl-a4))
224 !
225  rhl = ql/qsat
226 !
227  IF(rhl>1.)THEN
228  rhl = 1.
229  ql = rhl*qsat
230  ENDIF
231 !
232  IF(rhl<0.01)THEN
233  rhl = 0.01
234  ql = rhl*qsat
235  ENDIF
236 !
237 ! print *,' tl=',tl,' ql=',ql,' i=',i,' j=',j,' pl=',pl
238  tvrl = tl*(1.+0.608*ql)
239  tvrblo = tvrl*(psigo/pl)**rgamog
240  tblo = tvrblo/(1.+0.608*ql)
241 !
242  tmt0 = tblo-a3
243  ai = 0.008855
244  bi = 1.
245  IF(tmt0<-20.)THEN
246  ai = 0.007225
247  bi = 0.9674
248  ENDIF
249  qsat = pq0/psigo*exp(a2*(tblo-a3)/(tblo-a4))
250 !
251  tsl(i,j) = tblo
252  END IF
253  220 CONTINUE
254 
255 !---------------------------------------------------------------------
256 ! *** PART II ***
257 !---------------------------------------------------------------------
258 !---------------------------------------------------------------------
259 !
260 ! OUTPUT SELECTED FIELDS.
261 !
262 !*** TEMPERATURE
263 !
264  IF(iget(296)>0) THEN
265  IF(lvls(lp,iget(296))>0)THEN
266  DO j=jsta,jend
267  DO i=1,im
268  grid1(i,j)=tsl(i,j)
269  ENDDO
270  ENDDO
271  if(grib=='grib2')then
272  cfld=cfld+1
273  fld_info(cfld)%ifld=iavblfld(iget(296))
274  fld_info(cfld)%lvl=lvlsxml(lp,iget(296))
275  datapd(1:im,1:jend-jsta+1,cfld)=grid1(1:im,jsta:jend)
276  endif
277  ENDIF
278  ENDIF
279 !
280 !*** END OF MAIN VERTICAL LOOP
281 !
282  310 CONTINUE
283 !*** ENDIF FOR IF TEST SEEING IF WE WANT ANY OTHER VARIABLES
284 !
285  ENDIF
286 !
287 ! END OF ROUTINE.
288 !
289  RETURN
290  END
Definition: MASKS_mod.f:1