4 SUBROUTINE diag_zld_stub
5 END SUBROUTINE diag_zld_stub
6 END MODULE module_diag_zld
8 !WRF:MEDIATION_LAYER:PHYSICS
11 MODULE module_diag_zld
14 SUBROUTINE zld ( 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_z_levels,max_z_levels,z_levels, &
19 z_zl,u_zl,v_zl,t_zl,rh_zl,ght_zl,s_zl,td_zl, &
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_z_levels, max_z_levels
42 REAL , INTENT(IN ) , DIMENSION(max_z_levels) :: z_levels
46 REAL , INTENT( OUT) , DIMENSION(num_z_levels) :: z_zl
47 REAL , INTENT( OUT) , DIMENSION(ims:ime , num_z_levels , jms:jme) :: u_zl,v_zl,t_zl,rh_zl,ght_zl,s_zl,td_zl,q_zl,p_zl
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, kz, ke_h, ke_f
55 REAL :: zu, zd, zm , &
65 REAL :: part, gammas, tvu, tvd
67 ! Silly, but transfer the small namelist.input array into the grid structure for output purposes.
69 DO kz = 1 , num_z_levels
70 z_zl(kz) = z_levels(kz)
73 ! Initialize height level data to un-initialized
76 DO kz = 1 , num_z_levels
78 u_zl (i,kz,j) = missing
79 v_zl (i,kz,j) = missing
80 t_zl (i,kz,j) = missing
81 rh_zl (i,kz,j) = missing
82 ght_zl(i,kz,j) = missing
83 s_zl (i,kz,j) = missing
84 td_zl (i,kz,j) = missing
85 p_zl (i,kz,j) = missing
90 ! Loop over each i,j location
92 j_loop : DO j = jts , MIN(jte,jde-1)
93 i_loop : DO i = its , MIN(ite,ide-1)
95 ! For each i,j location, loop over the selected
96 ! pressure levels to find
100 kz_loop : DO kz = 1 , num_z_levels
102 ! For this particular i,j and height level, find the
103 ! eta levels that surround this point on half-levels.
104 ! Negative heights are a flag to do AGL.
106 ke_loop_half : DO ke = ke_h , kte-2
108 zu = ( zp(i,ke+1,j)+zb(i,ke+1,j) + zp(i,ke+2,j)+zb(i,ke+2,j) ) / 2.0 / g
109 zd = ( zp(i,ke ,j)+zb(i,ke ,j) + zp(i,ke+1,j)+zb(i,ke+1,j) ) / 2.0 / g
110 IF ( z_zl(kz) .LT. 1 ) THEN
111 zm = ABS(z_zl(kz)) + ht(i,j)
116 IF ( ( zd .LE. zm ) .AND. ( zu .GT. zm ) ) THEN
118 pu = pp(i,ke+1,j)+pb(i,ke+1,j)
119 pd = pp(i,ke ,j)+pb(i,ke ,j)
121 ! Found trapping height: up, middle, down.
122 ! We are doing first order interpolation.
123 ! Now we just put in a list of diagnostics for this level.
126 ! Note that it is ln(p) that varies linearly with height, not p itself
128 pm = exp( ( log(pu) * (zm-zd) + log(pd) * (zu-zm) ) / (zu-zd) )
133 tu = (t(i,ke+1,j)+t0)*(pu/p1000mb)**rcp
134 td = (t(i,ke ,j)+t0)*(pd/p1000mb)**rcp
135 t_zl(i,kz,j) = ( tu * (zm-zd) + td * (zu-zm) ) / (zu-zd)
139 su = 0.5 * SQRT ( ( u(i,ke+1,j)+u(i+1,ke+1,j) )**2 + &
140 ( v(i,ke+1,j)+v(i,ke+1,j+1) )**2 )
141 sd = 0.5 * SQRT ( ( u(i,ke ,j)+u(i+1,ke ,j) )**2 + &
142 ( v(i,ke ,j)+v(i,ke ,j+1) )**2 )
143 s_zl(i,kz,j) = ( su * (zm-zd) + sd * (zu-zm) ) / (zu-zd)
147 uu = 0.5 * ( u(i,ke+1,j)+u(i+1,ke+1,j) )
148 ud = 0.5 * ( u(i,ke ,j)+u(i+1,ke ,j) )
149 u_zl(i,kz,j) = ( uu * (zm-zd) + ud * (zu-zm) ) / (zu-zd)
151 vu = 0.5 * ( v(i,ke+1,j)+v(i,ke+1,j+1) )
152 vd = 0.5 * ( v(i,ke ,j)+v(i,ke ,j+1) )
153 v_zl(i,kz,j) = ( vu * (zm-zd) + vd * (zu-zm) ) / (zu-zd)
155 ! 4. Mixing ratio (kg/kg)
157 qu = MAX(qv(i,ke+1,j),0.)
158 qd = MAX(qv(i,ke ,j),0.)
159 q_zl(i,kz,j) = ( qu * (zm-zd) + qd * (zu-zm) ) / (zu-zd)
161 ! 5. Dewpoint (K) - Use Bolton's approximation
163 eu = qu * pu * 0.01 / ( eps + qu ) ! water vapor press (mb)
164 ed = qd * pd * 0.01 / ( eps + qd ) ! water vapor press (mb)
168 du = t_kelvin + ( s1 / ((s2 / log(eu/s3)) - 1.0) )
169 dd = t_kelvin + ( s1 / ((s2 / log(ed/s3)) - 1.0) )
170 td_zl(i,kz,j) = ( du * (zm-zd) + dd * (zu-zm) ) / (zu-zd)
173 ! 6. Relative humidity (%)
175 es = s4 * exp(s5 * (1.0 / 273.0 - 1.0 / t_zl(i,kz,j)))
176 qs = eps * es / (pm - es)
177 rh_zl(i,kz,j) = q_zl(i,kz,j) / qs * 100.
184 ke_loop_full : DO ke = ke_f , kte-1
186 zu = ( zp(i,ke+1,j)+zb(i,ke+1,j) ) / g
187 zd = ( zp(i,ke ,j)+zb(i,ke ,j) ) / g
188 IF ( z_zl(kz) .LT. 1 ) THEN
189 zm = ABS(z_zl(kz)) + ht(i,j)
194 IF ( ( zd .LE. zm ) .AND. &
197 ! Found trapping height: up, middle, down.
198 ! We are doing first order interpolation.
200 ! Now we just put in a list of diagnostics for this level.
202 ! 1. Geopotential height (m)
204 ght_zl(i,kz,j) = ( zu * (zm-zd) + zd * (zu-zm) ) / (zu-zd)
217 END MODULE module_diag_zld