4 SUBROUTINE diag_pld_stub
5 END SUBROUTINE diag_pld_stub
6 END MODULE module_diag_pld
8 !WRF:MEDIATION_LAYER:PHYSICS
11 MODULE module_diag_pld
14 SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, &
15 msfux,msfuy,msfvx,msfvy,msftx,msfty, &
17 use_tot_or_hyd_p,extrap_below_grnd,missing, &
18 num_press_levels,max_press_levels,press_levels, &
19 p_pl,u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl, &
21 ids,ide, jds,jde, kds,kde, &
22 ims,ime, jms,jme, kms,kme, &
23 its,ite, jts,jte, kts,kte )
25 USE module_model_constants
32 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
33 ims,ime, jms,jme, kms,kme, &
34 its,ite, jts,jte, kts,kte
35 REAL , INTENT(IN ) , DIMENSION(ims:ime , jms:jme) :: msfux,msfuy,msfvx,msfvy,msftx,msfty, &
37 INTEGER, INTENT(IN ) :: use_tot_or_hyd_p
38 INTEGER, INTENT(IN ) :: extrap_below_grnd
39 REAL , INTENT(IN ) :: missing
40 REAL , INTENT(IN ) , DIMENSION(ims:ime , kms:kme , jms:jme) :: u,v,w,t,qv,zp,zb,pp,pb,p,pw
41 INTEGER, INTENT(IN ) :: num_press_levels, max_press_levels
42 REAL , INTENT(IN ) , DIMENSION(max_press_levels) :: press_levels
46 REAL , INTENT( OUT) , DIMENSION(num_press_levels) :: p_pl
47 REAL , INTENT( OUT) , DIMENSION(ims:ime , num_press_levels , jms:jme) :: u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl,q_pl
51 REAL, PARAMETER :: eps = 0.622, t_kelvin = svpt0 , s1 = 243.5, s2 = svp2 , s3 = svp1*10., s4 = 611.0, s5 = 5418.12
52 REAL, PARAMETER :: zshul=75., tvshul=290.66
54 INTEGER :: i, j, ke, kp, ke_h, ke_f
55 REAL :: pu, pd, pm , &
65 REAL :: part, gammas, tvu, tvd
67 ! Silly, but transfer the small namelist.input array into the grid structure for output purposes.
69 DO kp = 1 , num_press_levels
70 p_pl(kp) = press_levels(kp)
73 ! Initialize pressure level data to un-initialized
76 DO kp = 1 , num_press_levels
78 u_pl (i,kp,j) = missing
79 v_pl (i,kp,j) = missing
80 t_pl (i,kp,j) = missing
81 rh_pl (i,kp,j) = missing
82 ght_pl(i,kp,j) = missing
83 s_pl (i,kp,j) = missing
84 td_pl (i,kp,j) = missing
89 ! Loop over each i,j location
91 j_loop : DO j = jts , MIN(jte,jde-1)
92 i_loop : DO i = its , MIN(ite,ide-1)
94 ! For each i,j location, loop over the selected
95 ! pressure levels to find
99 kp_loop : DO kp = 1 , num_press_levels
101 ! For this particular i,j and pressure level, find the
102 ! eta levels that surround this point on half-levels.
104 ke_loop_half : DO ke = ke_h , kte-2
106 IF ( use_tot_or_hyd_p .EQ. 1 ) THEN ! total pressure
107 pu = pp(i,ke+1,j)+pb(i,ke+1,j)
108 pd = pp(i,ke ,j)+pb(i,ke ,j)
109 ELSE IF ( use_tot_or_hyd_p .EQ. 2 ) THEN ! hydrostatic pressure
115 ! Added option to extrapolate below ground - GAC (AFWA)
117 IF ( ( extrap_below_grnd .EQ. 2 ) .AND. &
118 ( ke .EQ. ke_h ) .AND. ( pm .GT. pd )) THEN
120 ! Requested pressure level is below ground.
121 ! Extrapolate adiabatically if requested in namelist.
123 ! Methodology derived from Unified Post Processor (UPP).
124 ! Simply conserve first level U, V, and RH below ground.
125 ! Assume adiabatic lapse rate of gamma = 6.5 K/km
126 ! below ground, using Shuell correction to gamma
127 ! ("gammas") to find geopotential height, which is
128 ! computed by hydrostatically integrating mean isobaric
129 ! virtual temperature downward from the model surface.
130 ! Temperature is found by reducing adiabatically
131 ! from the first level temperature.
133 ! Chuang et al, NCEP's WRF Post Processor and
134 ! Verification Systems, MM5 Workshop Session 7, 2004.
135 ! Unipost source code: MDL2P.f
137 ! Z, T, Q, Tv at first half-eta level
139 zu = 0.5 * ( zp(i,ke ,j) + zb(i,ke ,j) + &
140 zp(i,ke+1,j) + zb(i,ke+1,j) ) / g
141 tu = ( t(i,ke,j) + t0 ) * ( pd / p1000mb ) ** rcp
142 qu = MAX(qv(i,ke,j),0.)
143 tvu = tu * ( 1. + 0.608 * qu )
145 ! 1. Geopotential height (m)
147 IF ( zu .GT. zshul ) THEN
148 tvd = tvu + zu * 6.5E-3
149 IF ( tvd .GT. tvshul ) THEN
150 IF ( tvu .GT. tvshul) THEN
151 tvd = tvshul - 5.E-3 * ( tvu - tvshul ) ** 2
156 gammas = ( tvu - tvd ) / zu
160 part = ( r_d / g ) * ( ALOG (pm) - ALOG (pd) )
161 ght_pl(i,kp,j) = zu - tvu * part / &
162 ( 1. + 0.5 * gammas * part )
166 t_pl(i,kp,j) = tu + ( zu - ght_pl(i,kp,j) ) * 6.5E-3
170 s_pl(i,kp,j) = 0.5 * SQRT ( ( u(i,ke ,j)+ &
171 u(i+1,ke ,j) )**2 + &
172 ( v(i,ke ,j) + v(i,ke ,j+1) )**2 )
176 u_pl(i,kp,j) = 0.5 * ( u(i,ke ,j) + u(i+1,ke ,j) )
177 v_pl(i,kp,j) = 0.5 * ( v(i,ke ,j) + v(i,ke ,j+1) )
179 ! 5. Relative humidity (%)
181 es = s4 * exp(s5 * (1.0 / 273.0 - 1.0 / tu) )
182 qs = eps * es / (pd - es)
183 rh_pl(i,kp,j) = MAX(qv(i,ke,j),0.) / qs * 100.
185 ! 6. Mixing ratio (kg/kg)
187 es = s4 * exp(s5 * (1.0 / 273.0 - 1.0 / t_pl(i,kp,j)))
188 qs = eps * es / (pm - es)
189 q_pl(i,kp,j) = rh_pl(i,kp,j) * qs / 100.
191 ! 7. Dewpoint (K) - Use Bolton's approximation
193 ed = q_pl(i,kp,j) * pm * 0.01 / ( eps + q_pl(i,kp,j) )
194 ed = max(ed, 0.001) ! water vapor pressure in mb.
195 td_pl(i,kp,j) = t_kelvin + (s1 / ((s2 / log(ed/s3)) - 1.0))
198 ELSEIF ( ( pd .GE. pm ) .AND. &
199 ( pu .LT. pm ) ) THEN
201 ! Found trapping pressure: up, middle, down.
202 ! We are doing first order interpolation.
203 ! Now we just put in a list of diagnostics for this level.
207 tu = (t(i,ke+1,j)+t0)*(pu/p1000mb)**rcp
208 td = (t(i,ke ,j)+t0)*(pd/p1000mb)**rcp
209 t_pl(i,kp,j) = ( tu * (pm-pd) + td * (pu-pm) ) / (pu-pd)
213 su = 0.5 * SQRT ( ( u(i,ke+1,j)+u(i+1,ke+1,j) )**2 + &
214 ( v(i,ke+1,j)+v(i,ke+1,j+1) )**2 )
215 sd = 0.5 * SQRT ( ( u(i,ke ,j)+u(i+1,ke ,j) )**2 + &
216 ( v(i,ke ,j)+v(i,ke ,j+1) )**2 )
217 s_pl(i,kp,j) = ( su * (pm-pd) + sd * (pu-pm) ) / (pu-pd)
221 uu = 0.5 * ( u(i,ke+1,j)+u(i+1,ke+1,j) )
222 ud = 0.5 * ( u(i,ke ,j)+u(i+1,ke ,j) )
223 u_pl(i,kp,j) = ( uu * (pm-pd) + ud * (pu-pm) ) / (pu-pd)
225 vu = 0.5 * ( v(i,ke+1,j)+v(i,ke+1,j+1) )
226 vd = 0.5 * ( v(i,ke ,j)+v(i,ke ,j+1) )
227 v_pl(i,kp,j) = ( vu * (pm-pd) + vd * (pu-pm) ) / (pu-pd)
229 ! 4. Mixing ratio (kg/kg)
231 qu = MAX(qv(i,ke+1,j),0.)
232 qd = MAX(qv(i,ke ,j),0.)
233 q_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd)
235 ! 5. Dewpoint (K) - Use Bolton's approximation
237 eu = qu * pu * 0.01 / ( eps + qu ) ! water vapor press (mb)
238 ed = qd * pd * 0.01 / ( eps + qd ) ! water vapor press (mb)
242 du = t_kelvin + ( s1 / ((s2 / log(eu/s3)) - 1.0) )
243 dd = t_kelvin + ( s1 / ((s2 / log(ed/s3)) - 1.0) )
244 td_pl(i,kp,j) = ( du * (pm-pd) + dd * (pu-pm) ) / (pu-pd)
247 ! 6. Relative humidity (%)
249 es = s4 * exp(s5 * (1.0 / 273.0 - 1.0 / t_pl(i,kp,j)))
250 qs = eps * es / (pm - es)
251 rh_pl(i,kp,j) = q_pl(i,kp,j) / qs * 100.
253 !em = qm * pm * 0.01 / ( eps + qm ) ! water vapor pressure at the level.
254 !es = s3 * exp( s2 * (t_pl(i,kp,j) - t_kelvin)/(t_pl(i,kp,j) - s4) ) ! sat vapor pressure over liquid water in mb.
255 !rh_pl(i,kp,j) = 100. * em * ( pm * 0.01 - es ) / ( es * ( pm * 0.01 - em ) )
262 ke_loop_full : DO ke = ke_f , kte-1
264 IF ( ( pw(i,ke ,j) .GE. p_pl(kp) ) .AND. &
265 ( pw(i,ke+1,j) .LT. p_pl(kp) ) ) THEN
267 ! Found trapping pressure: up, middle, down.
268 ! We are doing first order interpolation.
270 pu = LOG(pw(i,ke+1,j))
272 pd = LOG(pw(i,ke ,j))
274 ! Now we just put in a list of diagnostics for this level.
276 ! 1. Geopotential height (m)
278 zu = ( zp(i,ke+1,j)+zb(i,ke+1,j) ) / g
279 zd = ( zp(i,ke ,j)+zb(i,ke ,j) ) / g
280 ght_pl(i,kp,j) = ( zu * (pm-pd) + zd * (pu-pm) ) / (pu-pd)
293 END MODULE module_diag_pld