43 subroutine p_var(km, ifirst, ilast, jfirst, jlast, ptop, ptop_min, &
44 delp, delz, pt, ps, pe, peln, pk, pkz, cappa, q, ng, nq, area, &
45 dry_mass, adjust_dry_mass, mountain, moist_phys, &
46 hydrostatic, nwat, domain, make_nh)
50 integer,
intent(in):: km
51 integer,
intent(in):: ifirst, ilast
52 integer,
intent(in):: jfirst, jlast
53 integer,
intent(in):: nq, nwat
54 integer,
intent(in):: ng
55 logical,
intent(in):: adjust_dry_mass, mountain, moist_phys, hydrostatic
56 real,
intent(in):: dry_mass, cappa, ptop, ptop_min
57 real,
intent(in ):: pt(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng, km)
58 real,
intent(inout):: delz(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng, km)
59 real,
intent(inout):: delp(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng, km)
60 real,
intent(inout):: q(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng, km, nq)
61 real(kind=R_GRID),
intent(IN) :: area(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng)
62 logical,
optional:: make_nh
64 real,
intent(out) :: ps(ifirst-ng:ilast+ng, jfirst-ng:jlast+ng)
65 real,
intent(out) :: pk(ifirst:ilast, jfirst:jlast, km+1)
66 real,
intent(out) :: pe(ifirst-1:ilast+1,km+1,jfirst-1:jlast+1)
67 real,
intent(out) :: peln(ifirst:ilast, km+1, jfirst:jlast)
68 real,
intent(out) :: pkz(ifirst:ilast, jfirst:jlast, km)
72 integer sphum, liq_wat, ice_wat
73 integer rainwat, snowwat, graupel
74 real ratio(ifirst:ilast)
75 real pek, lnp, ak1, rdg, dpd, zvir
79 if ( adjust_dry_mass ) &
80 call drymadj(km, ifirst, ilast, jfirst, jlast, ng, cappa, ptop, ps, &
81 delp, q, nq, area, nwat, dry_mass, adjust_dry_mass, moist_phys, dpd, domain)
95 if ( adjust_dry_mass )
then 97 ratio(i) = 1. + dpd/(ps(i,j)-ptop)
101 delp(i,j,k) = delp(i,j,k) * ratio(i)
108 pe(i,k,j) = pe(i,k-1,j) + delp(i,j,k-1)
109 peln(i,k,j) = log(pe(i,k,j))
110 pk(i,j,k) = exp( cappa*peln(i,k,j) )
115 ps(i,j) = pe(i,km+1,j)
118 if( ptop < ptop_min )
then 120 ak1 = (cappa + 1.) / cappa
122 peln(i,1,j) = peln(i,2,j) - ak1
131 if ( hydrostatic )
then 134 pkz(i,j,k) = (pk(i,j,k+1)-pk(i,j,k))/(cappa*(peln(i,k+1,j)-peln(i,k,j)))
141 if ( .not.hydrostatic )
then 144 if (
present(make_nh) )
then 151 delz(i,j,k) = rdg*pt(i,j,k)*(peln(i,k+1,j)-peln(i,k,j))
155 if(is_master())
write(*,*)
'delz computed from hydrostatic state' 159 if ( moist_phys )
then 174 pkz(i,j,k) = exp( cappa*log(rdg*delp(i,j,k)*pt(i,j,k)* &
175 (1.+zvir*q(i,j,k,sphum))/delz(i,j,k)) )
185 pkz(i,j,k) = exp( cappa*log(rdg*delp(i,j,k)*pt(i,j,k)/delz(i,j,k)) )
197 subroutine drymadj(km, ifirst, ilast, jfirst, jlast, ng, &
198 cappa, ptop, ps, delp, q, nq, area, nwat, &
199 dry_mass, adjust_dry_mass, moist_phys, dpd, domain)
203 integer ifirst, ilast
204 integer jfirst, jlast
206 real,
intent(in):: dry_mass
207 real,
intent(in):: ptop
208 real,
intent(in):: cappa
209 logical,
intent(in):: adjust_dry_mass
210 logical,
intent(in):: moist_phys
211 real(kind=R_GRID),
intent(IN) :: area(ifirst-ng:ilast+ng, jfirst-ng:jlast+ng)
212 type(domain2d),
intent(IN) :: domain
215 real,
intent(in):: q(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng,km,nq)
216 real,
intent(in)::delp(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng,km)
217 real,
intent(inout):: ps(ifirst-ng:ilast+ng,jfirst-ng:jlast+ng)
218 real,
intent(out):: dpd
220 real psd(ifirst:ilast,jfirst:jlast)
234 ps(i,j) = ps(i,j) + delp(i,j,k)
241 psd(i,j) = psd(i,j) + delp(i,j,k)*(1. - sum(q(i,j,k,1:nwat)))
253 psdry =
g_sum(domain, psd, ifirst, ilast, jfirst, jlast, ng, area, 1, .true.)
254 psmo =
g_sum(domain, ps(ifirst:ilast,jfirst:jlast), ifirst, ilast, jfirst, jlast, &
257 psdry =
g_sum(domain, psd, ifirst, ilast, jfirst, jlast, ng, area, 1)
258 psmo =
g_sum(domain, ps(ifirst:ilast,jfirst:jlast), ifirst, ilast, jfirst, jlast, &
263 write(*,*)
'Total surface pressure (mb) = ', 0.01*psmo
264 if ( moist_phys )
then 265 write(*,*)
'mean dry surface pressure = ', 0.01*psdry
266 write(*,*)
'Total Water (kg/m**2) =',
real(psmo-psdry,4)/GRAV
270 if( adjust_dry_mass )
Then 271 dpd =
real(dry_mass - psdry,4)
272 if(is_master())
write(*,*)
'dry mass to be added (pascals) =', dpd
279 subroutine hydro_eq(km, is, ie, js, je, ps, hs, drym, delp, ak, bk, &
280 pt, delz, area, ng, mountain, hydrostatic, hybrid_z, domain)
282 integer,
intent(in):: is, ie, js, je, km, ng
283 real,
intent(in):: ak(km+1), bk(km+1)
284 real,
intent(in):: hs(is-ng:ie+ng,js-ng:je+ng)
285 real,
intent(in):: drym
286 logical,
intent(in):: mountain
287 logical,
intent(in):: hydrostatic
288 logical,
intent(in):: hybrid_z
289 real(kind=R_GRID),
intent(IN) :: area(is-ng:ie+ng,js-ng:je+ng)
290 type(
domain2d),
intent(IN) :: domain
292 real,
intent(out):: ps(is-ng:ie+ng,js-ng:je+ng)
293 real,
intent(out):: pt(is-ng:ie+ng,js-ng:je+ng,km)
294 real,
intent(out):: delp(is-ng:ie+ng,js-ng:je+ng,km)
295 real,
intent(inout):: delz(is-ng:ie+ng,js-ng:je+ng,km)
299 real mslp, z1, t1, p1, t0, a0, psm
310 if ( is_master() )
write(*,*)
'Initializing ATM hydrostatically' 312 if ( is_master() )
write(*,*)
'Initializing Earth' 327 ztop = z1 + (
rdgas*t1)*log(p1/ptop)
328 if(is_master())
write(*,*)
'ZTOP is computed as', ztop/
grav*1.e-3
334 ps(i,j) = mslp*( c0/(hs(i,j)+c0))**(1./(a0*
rdgas))
337 psm =
g_sum(domain, ps(is:ie,js:je), is, ie, js, je, ng, area, 1, .true.)
339 if(is_master())
write(*,*)
'Computed mean ps=', psm
340 if(is_master())
write(*,*)
'Correction delta-ps=', dps
354 ps(i,j) = ps(i,j) + dps
367 gz(i,k) = gz(i,k+1) - delz(i,j,k)*
grav 372 delz(i,j,1) = (gz(i,2) - ztop) /
grav 377 if ( gz(i,k) >= z1 )
then 379 ph(i,k) = ptop*exp( (gz(i,1)-gz(i,k))/(
rdgas*t1) )
382 ph(i,k) = ps(i,j)*((hs(i,j)+c0)/(gz(i,k)+c0))**(1./(a0*
rdgas))
392 ph(i,k) = ak(k) + bk(k)*ps(i,j)
398 if ( ph(i,k) <= p1 )
then 400 gz(i,k) = ztop + (
rdgas*t1)*log(ptop/ph(i,k))
403 gz(i,k) = (hs(i,j)+c0)/(ph(i,k)/ps(i,j))**(a0*
rdgas) - c0
407 if ( .not. hydrostatic )
then 410 delz(i,j,k) = ( gz(i,k+1) - gz(i,k) ) /
grav 419 pt(i,j,k) = (gz(i,k)-gz(i,k+1))/(
rdgas*(log(ph(i,k+1)/ph(i,k))))
420 pt(i,j,k) =
max(t1, pt(i,j,k))
421 delp(i,j,k) = ph(i,k+1) - ph(i,k)
subroutine drymadj(km, ifirst, ilast, jfirst, jlast, ng, cappa, ptop, ps, delp, q, nq, area, nwat, dry_mass, adjust_dry_mass, moist_phys, dpd, domain)
integer, parameter, public model_atmos
subroutine, public p_var(km, ifirst, ilast, jfirst, jlast, ptop, ptop_min, delp, delz, pt, ps, pe, peln, pk, pkz, cappa, q, ng, nq, area, dry_mass, adjust_dry_mass, mountain, moist_phys, hydrostatic, nwat, domain, make_nh)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
subroutine, public hydro_eq(km, is, ie, js, je, ps, hs, drym, delp, ak, bk, pt, delz, area, ng, mountain, hydrostatic, hybrid_z, domain)
integer, parameter, public r_grid
real, parameter, public grav
Acceleration due to gravity [m/s^2].
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)