36 real,
parameter::
esl = 0.621971831
37 real,
parameter::
tice = 273.16
40 real,
parameter::
c_liq = 4.1855e+3
49 real,
parameter::
hlv0 = 2.5e6
50 real,
parameter::
hlf0 = 3.3358e5
53 real,
parameter::
t_ice = 273.16
69 #if defined(GFS_PHYS) || defined(MAPL_MODE) 70 subroutine fv_subgrid_z( isd, ied, jsd, jed, is, ie, js, je, km, nq, dt, &
71 tau, nwat, delp, pe, peln, pkz, ta, qa, ua, va, &
72 hydrostatic, w, delz, u_dt, v_dt, t_dt, k_bot )
75 integer,
intent(in):: is, ie, js, je, km, nq, nwat
76 integer,
intent(in):: isd, ied, jsd, jed
77 integer,
intent(in):: tau
79 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
80 real,
intent(in):: peln(is :ie, km+1,js :je)
81 real,
intent(in):: delp(isd:ied,jsd:jed,km)
82 real,
intent(in):: delz(isd:,jsd:,1:)
83 real,
intent(in):: pkz(is:ie,js:je,km)
84 logical,
intent(in):: hydrostatic
85 integer,
intent(in),
optional:: k_bot
87 real,
intent(inout):: ua(isd:ied,jsd:jed,km)
88 real,
intent(inout):: va(isd:ied,jsd:jed,km)
89 real,
intent(inout):: w(isd:,jsd:,1:)
90 real,
intent(inout):: ta(isd:ied,jsd:jed,km)
91 real,
intent(inout):: qa(isd:ied,jsd:jed,km,nq)
92 real,
intent(inout):: u_dt(isd:ied,jsd:jed,km)
93 real,
intent(inout):: v_dt(isd:ied,jsd:jed,km)
94 real,
intent(inout):: t_dt(is:ie,js:je,km)
96 real,
dimension(is:ie,km):: u0, v0, w0, t0, hd, te, gz, tvm, pm, den
97 real q0(is:ie,km,nq), qcon(is:ie,km)
98 real,
dimension(is:ie):: gzh, lcp2, icp2, cvm, cpm, qs
99 real ri_ref, ri, pt1, pt2, ratio, tv, cv, tmp, q_liq, q_sol
100 real tv1, tv2, g2, h0, mc, fra, rk, rz, rdt, tvd, tv_surf
101 real dh, dq, qsw, dqsdt, tcp3, t_max, t_min
102 integer i, j, k, kk, n, m, iq, km1, im, kbot
103 real,
parameter:: ustar2 = 1.e-4
105 integer :: sphum, liq_wat, rainwat, snowwat, graupel, ice_wat, cld_amt
116 if (
present(k_bot) )
then 117 if ( k_bot < 3 )
return 122 if ( pe(is,1,js) < 2. )
then 128 if ( k_bot <
min(km,24) )
then 136 if ( nwat == 0 )
then 149 if ( nwat == 0 )
then 183 q0(i,k,iq) = qa(i,j,k,iq)
191 tvm(i,k) = t0(i,k)*(1.+xvir*q0(i,k,sphum))
194 pm(i,k) = delp(i,j,k)/(peln(i,k+1,j)-peln(i,k,j))
202 if( hydrostatic )
then 206 den(i,k) = pm(i,k)/tv
207 gz(i,k) = gzh(i) + tv*(1.-pe(i,k,j)/pm(i,k))
208 hd(i,k) =
cp_air*tvm(i,k)+gz(i,k)+0.5*(u0(i,k)**2+v0(i,k)**2)
209 gzh(i) = gzh(i) + tv*(peln(i,k+1,j)-peln(i,k,j))
214 if ( nwat == 0 )
then 219 elseif ( nwat==1 )
then 222 cvm(i) = (1.-q0(i,k,sphum))*cv_air + q0(i,k,sphum)*
cv_vap 224 elseif ( nwat==2 )
then 227 cvm(i) = (1.-q0(i,k,sphum))*cv_air + q0(i,k,sphum)*
cv_vap 229 elseif ( nwat==3 )
then 231 q_liq = q0(i,k,liq_wat)
232 q_sol = q0(i,k,ice_wat)
234 cvm(i) = (1.-(q0(i,k,sphum)+q_liq+q_sol))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 236 elseif ( nwat==4 )
then 238 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
240 cvm(i) = (1.-(q0(i,k,sphum)+q_liq))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq 244 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
245 q_sol = q0(i,k,ice_wat) + q0(i,k,snowwat) + q0(i,k,graupel)
247 cvm(i) = (1.-(q0(i,k,sphum)+q_liq+q_sol))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 252 den(i,k) = -delp(i,j,k)/(
grav*delz(i,j,k))
254 gz(i,k) = gzh(i) - g2*delz(i,j,k)
255 tmp = gz(i,k) + 0.5*(u0(i,k)**2+v0(i,k)**2+w0(i,k)**2)
256 hd(i,k) = cpm(i)*t0(i,k) + tmp
257 te(i,k) = cvm(i)*t0(i,k) + tmp
258 gzh(i) = gzh(i) -
grav*delz(i,j,k)
266 if ( n==1) ratio = 0.25
267 if ( n==2) ratio = 0.5
268 if ( n==3) ratio = 0.999
270 ratio =
real(n)/
real(m)
284 elseif ( nwat==2 )
then 287 qcon(i,k) = q0(i,k,liq_wat)
290 elseif ( nwat==3 )
then 293 qcon(i,k) = q0(i,k,liq_wat) + q0(i,k,ice_wat)
296 elseif ( nwat==4 )
then 299 qcon(i,k) = q0(i,k,liq_wat) + q0(i,k,rainwat)
305 qcon(i,k) = q0(i,k,liq_wat)+q0(i,k,ice_wat)+q0(i,k,snowwat)+q0(i,k,rainwat)+q0(i,k,graupel)
315 tv1 = t0(i,km1)*(1.+xvir*q0(i,km1,sphum)-qcon(i,km1))
316 tv2 = t0(i,k )*(1.+xvir*q0(i,k ,sphum)-qcon(i,k))
317 pt1 = tv1 / pkz(i,j,km1)
318 pt2 = tv2 / pkz(i,j,k )
320 ri = (gz(i,km1)-gz(i,k))*(pt1-pt2)/( 0.5*(pt1+pt2)* &
321 ((u0(i,km1)-u0(i,k))**2+(v0(i,km1)-v0(i,k))**2+ustar2) )
322 if ( tv1>t_max .and. tv1>tv2 )
then 325 elseif ( tv2<t_min )
then 342 if ( ri < ri_ref )
then 343 mc = ratio*delp(i,j,km1)*delp(i,j,k)/(delp(i,j,km1)+delp(i,j,k))*(1.-
max(0.0,ri/ri_ref))**2
345 h0 = mc*(q0(i,k,iq)-q0(i,km1,iq))
346 q0(i,km1,iq) = q0(i,km1,iq) + h0/delp(i,j,km1)
347 q0(i,k ,iq) = q0(i,k ,iq) - h0/delp(i,j,k )
352 elseif ( nwat==2 )
then 353 qcon(i,km1) = q0(i,km1,liq_wat)
354 elseif ( nwat==3 )
then 355 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,ice_wat)
356 elseif ( nwat==4 )
then 357 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,rainwat)
359 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,ice_wat) + &
360 q0(i,km1,snowwat) + q0(i,km1,rainwat) + q0(i,km1,graupel)
363 h0 = mc*(u0(i,k)-u0(i,k-1))
364 u0(i,k-1) = u0(i,k-1) + h0/delp(i,j,k-1)
365 u0(i,k ) = u0(i,k ) - h0/delp(i,j,k )
367 h0 = mc*(v0(i,k)-v0(i,k-1))
368 v0(i,k-1) = v0(i,k-1) + h0/delp(i,j,k-1)
369 v0(i,k ) = v0(i,k ) - h0/delp(i,j,k )
371 if ( hydrostatic )
then 373 h0 = mc*(hd(i,k)-hd(i,k-1))
374 hd(i,k-1) = hd(i,k-1) + h0/delp(i,j,k-1)
375 hd(i,k ) = hd(i,k ) - h0/delp(i,j,k )
378 h0 = mc*(hd(i,k)-hd(i,k-1))
379 te(i,k-1) = te(i,k-1) + h0/delp(i,j,k-1)
380 te(i,k ) = te(i,k ) - h0/delp(i,j,k )
382 h0 = mc*(w0(i,k)-w0(i,k-1))
383 w0(i,k-1) = w0(i,k-1) + h0/delp(i,j,k-1)
384 w0(i,k ) = w0(i,k ) - h0/delp(i,j,k )
392 if ( hydrostatic )
then 395 t0(i,kk) = (hd(i,kk)-gzh(i)-0.5*(u0(i,kk)**2+v0(i,kk)**2)) &
396 / ( rk - pe(i,kk,j)/pm(i,kk) )
397 gzh(i) = gzh(i) + t0(i,kk)*(peln(i,kk+1,j)-peln(i,kk,j))
398 t0(i,kk) = t0(i,kk) / (
rdgas + rz*q0(i,kk,sphum) )
402 t0(i,kk) = (hd(i,kk)-gzh(i)-0.5*(u0(i,kk)**2+v0(i,kk)**2)) &
403 / ((rk-pe(i,kk,j)/pm(i,kk))*(
rdgas+rz*q0(i,kk,sphum)))
408 if ( nwat == 0 )
then 413 elseif ( nwat == 1 )
then 416 cvm(i) = (1.-q0(i,kk,sphum))*cv_air + q0(i,kk,sphum)*
cv_vap 418 elseif ( nwat == 2 )
then 421 cvm(i) = (1.-q0(i,kk,sphum))*cv_air + q0(i,kk,sphum)*
cv_vap 423 elseif ( nwat == 3 )
then 425 q_liq = q0(i,kk,liq_wat)
426 q_sol = q0(i,kk,ice_wat)
428 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq+q_sol))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 430 elseif ( nwat == 4 )
then 432 q_liq = q0(i,kk,liq_wat) + q0(i,kk,rainwat)
434 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq 438 q_liq = q0(i,kk,liq_wat) + q0(i,kk,rainwat)
439 q_sol = q0(i,kk,ice_wat) + q0(i,kk,snowwat) + q0(i,kk,graupel)
441 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq+q_sol))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 446 tv = gz(i,kk) + 0.5*(u0(i,kk)**2+v0(i,kk)**2+w0(i,kk)**2)
447 t0(i,kk) = (te(i,kk)- tv) / cvm(i)
448 hd(i,kk) = cpm(i)*t0(i,kk) + tv
459 t0(i,k) = ta(i,j,k) + (t0(i,k) - ta(i,j,k))*fra
460 u0(i,k) = ua(i,j,k) + (u0(i,k) - ua(i,j,k))*fra
461 v0(i,k) = va(i,j,k) + (v0(i,k) - va(i,j,k))*fra
465 if ( .not. hydrostatic )
then 468 w0(i,k) = w(i,j,k) + (w0(i,k) - w(i,j,k))*fra
476 q0(i,k,iq) = qa(i,j,k,iq) + (q0(i,k,iq) - qa(i,j,k,iq))*fra
484 u_dt(i,j,k) = rdt*(u0(i,k) - ua(i,j,k))
485 v_dt(i,j,k) = rdt*(v0(i,k) - va(i,j,k))
487 #if defined(GFS_PHYS) || defined(MAPL_MODE) 494 qa(i,j,k,iq) = q0(i,k,iq)
499 if ( .not. hydrostatic )
then 512 subroutine fv_subgrid_z( isd, ied, jsd, jed, is, ie, js, je, km, nq, dt, &
513 tau, nwat, delp, pe, peln, pkz, ta, qa, ua, va, &
514 hydrostatic, w, delz, u_dt, v_dt, t_dt, q_dt, k_bot )
517 integer,
intent(in):: is, ie, js, je, km, nq, nwat
518 integer,
intent(in):: isd, ied, jsd, jed
519 integer,
intent(in):: tau
520 real,
intent(in):: dt
521 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
522 real,
intent(in):: peln(is :ie, km+1,js :je)
523 real,
intent(in):: delp(isd:ied,jsd:jed,km)
524 real,
intent(in):: delz(isd:,jsd:,1:)
525 real,
intent(in):: pkz(is:ie,js:je,km)
526 logical,
intent(in):: hydrostatic
527 integer,
intent(in),
optional:: k_bot
529 real,
intent(inout):: ua(isd:ied,jsd:jed,km)
530 real,
intent(inout):: va(isd:ied,jsd:jed,km)
531 real,
intent(inout):: w(isd:,jsd:,1:)
532 real,
intent(inout):: ta(isd:ied,jsd:jed,km)
533 real,
intent(inout):: qa(isd:ied,jsd:jed,km,nq)
534 real,
intent(inout):: u_dt(isd:ied,jsd:jed,km)
535 real,
intent(inout):: v_dt(isd:ied,jsd:jed,km)
536 real,
intent(inout):: t_dt(is:ie,js:je,km)
537 real,
intent(inout):: q_dt(is:ie,js:je,km,nq)
539 real,
dimension(is:ie,km):: u0, v0, w0, t0, hd, te, gz, tvm, pm, den
540 real q0(is:ie,km,nq), qcon(is:ie,km)
541 real,
dimension(is:ie):: gzh, lcp2, icp2, cvm, cpm, qs
542 real ri_ref, ri, pt1, pt2, ratio, tv, cv, tmp, q_liq, q_sol
543 real tv1, tv2, g2, h0, mc, fra, rk, rz, rdt, tvd, tv_surf
544 real dh, dq, qsw, dqsdt, tcp3
545 integer i, j, k, kk, n, m, iq, km1, im, kbot
546 real,
parameter:: ustar2 = 1.e-4
548 integer :: sphum, liq_wat, rainwat, snowwat, graupel, ice_wat, cld_amt
559 if (
present(k_bot) )
then 560 if ( k_bot < 3 )
return 567 if ( nwat == 0 )
then 600 q0(i,k,iq) = qa(i,j,k,iq)
608 tvm(i,k) = t0(i,k)*(1.+xvir*q0(i,k,sphum))
611 pm(i,k) = delp(i,j,k)/(peln(i,k+1,j)-peln(i,k,j))
619 if( hydrostatic )
then 623 den(i,k) = pm(i,k)/tv
624 gz(i,k) = gzh(i) + tv*(1.-pe(i,k,j)/pm(i,k))
625 hd(i,k) =
cp_air*tvm(i,k)+gz(i,k)+0.5*(u0(i,k)**2+v0(i,k)**2)
626 gzh(i) = gzh(i) + tv*(peln(i,k+1,j)-peln(i,k,j))
631 if ( nwat == 0 )
then 636 elseif ( nwat==1 )
then 639 cvm(i) = (1.-q0(i,k,sphum))*cv_air + q0(i,k,sphum)*
cv_vap 641 elseif ( nwat==2 )
then 643 q_sol = q0(i,k,liq_wat)
645 cvm(i) = (1.-q0(i,k,sphum))*cv_air + q0(i,k,sphum)*
cv_vap 647 elseif ( nwat==3 )
then 649 q_liq = q0(i,k,liq_wat)
650 q_sol = q0(i,k,ice_wat)
652 cvm(i) = (1.-(q0(i,k,sphum)+q_liq+q_sol))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 654 elseif ( nwat==4 )
then 656 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
658 cvm(i) = (1.-(q0(i,k,sphum)+q_liq))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq 662 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
663 q_sol = q0(i,k,ice_wat) + q0(i,k,snowwat) + q0(i,k,graupel)
665 cvm(i) = (1.-(q0(i,k,sphum)+q_liq+q_sol))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 670 den(i,k) = -delp(i,j,k)/(
grav*delz(i,j,k))
672 gz(i,k) = gzh(i) - g2*delz(i,j,k)
673 tmp = gz(i,k) + 0.5*(u0(i,k)**2+v0(i,k)**2+w0(i,k)**2)
674 hd(i,k) = cpm(i)*t0(i,k) + tmp
675 te(i,k) = cvm(i)*t0(i,k) + tmp
676 gzh(i) = gzh(i) -
grav*delz(i,j,k)
684 if ( n==1) ratio = 0.25
685 if ( n==2) ratio = 0.5
686 if ( n==3) ratio = 0.999
688 ratio =
real(n)/
real(m)
702 elseif ( nwat==2 )
then 705 qcon(i,k) = q0(i,k,liq_wat)
708 elseif ( nwat==3 )
then 711 qcon(i,k) = q0(i,k,liq_wat) + q0(i,k,ice_wat)
714 elseif ( nwat==4 )
then 717 qcon(i,k) = q0(i,k,liq_wat) + q0(i,k,rainwat)
723 qcon(i,k) = q0(i,k,liq_wat)+q0(i,k,ice_wat)+q0(i,k,snowwat)+q0(i,k,rainwat)+q0(i,k,graupel)
731 if(nwat>0)
call qsmith(im, 1, 1, t0(is,km1), pm(is,km1), q0(is,km1,sphum), qs)
736 tv1 = t0(i,km1)*(1.+xvir*q0(i,km1,sphum)-qcon(i,km1))
737 tv2 = t0(i,k )*(1.+xvir*q0(i,k ,sphum)-qcon(i,k))
738 pt1 = tv1 / pkz(i,j,km1)
739 pt2 = tv2 / pkz(i,j,k )
740 ri = (gz(i,km1)-gz(i,k))*(pt1-pt2)/( 0.5*(pt1+pt2)* &
741 ((u0(i,km1)-u0(i,k))**2+(v0(i,km1)-v0(i,k))**2+ustar2) )
749 h0 = hd(i,k)-hd(i,km1) +
hlv0*(q0(i,k,sphum)-qs(i))
750 if ( h0 > 0. ) ri_ref = 5.*ri_ref
753 if ( ri < ri_ref )
then 754 mc = ratio*delp(i,j,km1)*delp(i,j,k)/(delp(i,j,km1)+delp(i,j,k))*(1.-
max(0.0,ri/ri_ref))**2
756 h0 = mc*(q0(i,k,iq)-q0(i,km1,iq))
757 q0(i,km1,iq) = q0(i,km1,iq) + h0/delp(i,j,km1)
758 q0(i,k ,iq) = q0(i,k ,iq) - h0/delp(i,j,k )
763 elseif ( nwat==2 )
then 764 qcon(i,km1) = q0(i,km1,liq_wat)
765 elseif ( nwat==3 )
then 766 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,ice_wat)
767 elseif ( nwat==4 )
then 768 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,rainwat)
770 qcon(i,km1) = q0(i,km1,liq_wat) + q0(i,km1,ice_wat) + &
771 q0(i,km1,snowwat) + q0(i,km1,rainwat) + q0(i,km1,graupel)
774 h0 = mc*(u0(i,k)-u0(i,k-1))
775 u0(i,k-1) = u0(i,k-1) + h0/delp(i,j,k-1)
776 u0(i,k ) = u0(i,k ) - h0/delp(i,j,k )
778 h0 = mc*(v0(i,k)-v0(i,k-1))
779 v0(i,k-1) = v0(i,k-1) + h0/delp(i,j,k-1)
780 v0(i,k ) = v0(i,k ) - h0/delp(i,j,k )
782 if ( hydrostatic )
then 784 h0 = mc*(hd(i,k)-hd(i,k-1))
785 hd(i,k-1) = hd(i,k-1) + h0/delp(i,j,k-1)
786 hd(i,k ) = hd(i,k ) - h0/delp(i,j,k )
789 h0 = mc*(hd(i,k)-hd(i,k-1))
790 te(i,k-1) = te(i,k-1) + h0/delp(i,j,k-1)
791 te(i,k ) = te(i,k ) - h0/delp(i,j,k )
793 h0 = mc*(w0(i,k)-w0(i,k-1))
794 w0(i,k-1) = w0(i,k-1) + h0/delp(i,j,k-1)
795 w0(i,k ) = w0(i,k ) - h0/delp(i,j,k )
803 if ( hydrostatic )
then 806 t0(i,kk) = (hd(i,kk)-gzh(i)-0.5*(u0(i,kk)**2+v0(i,kk)**2)) &
807 / ( rk - pe(i,kk,j)/pm(i,kk) )
808 gzh(i) = gzh(i) + t0(i,kk)*(peln(i,kk+1,j)-peln(i,kk,j))
809 t0(i,kk) = t0(i,kk) / (
rdgas + rz*q0(i,kk,sphum) )
813 t0(i,kk) = (hd(i,kk)-gzh(i)-0.5*(u0(i,kk)**2+v0(i,kk)**2)) &
814 / ((rk-pe(i,kk,j)/pm(i,kk))*(
rdgas+rz*q0(i,kk,sphum)))
819 if ( nwat == 0 )
then 824 elseif ( nwat == 1 )
then 827 cvm(i) = (1.-q0(i,kk,sphum))*cv_air + q0(i,kk,sphum)*
cv_vap 829 elseif ( nwat == 2 )
then 832 cvm(i) = (1.-q0(i,kk,sphum))*cv_air + q0(i,kk,sphum)*
cv_vap 834 elseif ( nwat == 3 )
then 836 q_liq = q0(i,kk,liq_wat)
837 q_sol = q0(i,kk,ice_wat)
839 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq+q_sol))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 841 elseif ( nwat == 4 )
then 843 q_liq = q0(i,kk,liq_wat) + q0(i,kk,rainwat)
845 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq 849 q_liq = q0(i,kk,liq_wat) + q0(i,kk,rainwat)
850 q_sol = q0(i,kk,ice_wat) + q0(i,kk,snowwat) + q0(i,kk,graupel)
852 cvm(i) = (1.-(q0(i,kk,sphum)+q_liq+q_sol))*cv_air + q0(i,kk,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 858 tv = gz(i,kk) + 0.5*(u0(i,kk)**2+v0(i,kk)**2+w0(i,kk)**2)
859 t0(i,kk) = (te(i,kk)- tv) / cvm(i)
860 hd(i,kk) = cpm(i)*t0(i,kk) + tv
871 t0(i,k) = ta(i,j,k) + (t0(i,k) - ta(i,j,k))*fra
872 u0(i,k) = ua(i,j,k) + (u0(i,k) - ua(i,j,k))*fra
873 v0(i,k) = va(i,j,k) + (v0(i,k) - va(i,j,k))*fra
877 if ( .not. hydrostatic )
then 880 w0(i,k) = w(i,j,k) + (w0(i,k) - w(i,j,k))*fra
888 q0(i,k,iq) = qa(i,j,k,iq) + (q0(i,k,iq) - qa(i,j,k,iq))*fra
900 if ( hydrostatic )
then 903 den(i,k) = pm(i,k)/(
rdgas*t0(i,k)*(1.+xvir*q0(i,k,sphum)))
904 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
905 q_sol = q0(i,k,ice_wat) + q0(i,k,snowwat) + q0(i,k,graupel)
907 lcp2(i) =
hlv / cpm(i)
908 icp2(i) =
hlf / cpm(i)
912 den(i,k) = -delp(i,j,k)/(
grav*delz(i,j,k))
913 q_liq = q0(i,k,liq_wat) + q0(i,k,rainwat)
914 q_sol = q0(i,k,ice_wat) + q0(i,k,snowwat) + q0(i,k,graupel)
915 cvm(i) = (1.-(q0(i,k,sphum)+q_liq+q_sol))*cv_air + q0(i,k,sphum)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 923 qsw =
wqs2(t0(i,k), den(i,k), dqsdt)
924 dq = q0(i,k,sphum) - qsw
926 tcp3 = lcp2(i) + icp2(i)*
min(1., dim(
tice,t0(i,k))/40.)
927 tmp = dq/(1.+tcp3*dqsdt)
928 t0(i,k) = t0(i,k) + tmp*lcp2(i)
929 q0(i,k, sphum) = q0(i,k, sphum) - tmp
930 q0(i,k,liq_wat) = q0(i,k,liq_wat) + tmp
932 if (cld_amt .gt. 0)
then 933 qa(i,j,k,cld_amt) =
max(0.5,
min(1., qa(i,j,k,cld_amt)+25.*tmp/qsw))
937 tmp =
tice-40. - t0(i,k)
938 if( tmp>0.0 .and. q0(i,k,liq_wat)>0. )
then 939 dh =
min( q0(i,k,liq_wat), q0(i,k,liq_wat)*tmp*0.125, tmp/icp2(i) )
940 q0(i,k,liq_wat) = q0(i,k,liq_wat) - dh
941 q0(i,k,ice_wat) = q0(i,k,ice_wat) + dh
942 t0(i,k) = t0(i,k) + dh*icp2(i)
951 u_dt(i,j,k) = rdt*(u0(i,k) - ua(i,j,k))
952 v_dt(i,j,k) = rdt*(v0(i,k) - va(i,j,k))
954 #if defined(GFS_PHYS) || defined(MAPL_MODE) 960 if (iq .ne. cld_amt )
then 962 qa(i,j,k,iq) = q0(i,k,iq)
968 if ( .not. hydrostatic )
then 984 integer,
parameter:: length=2621
987 if( .not.
allocated(
table) )
then 990 allocate (
table(length) )
991 allocate (
des(length) )
998 des(length) =
des(length-1)
1004 subroutine qsmith(im, km, k1, t, p, q, qs, dqdt)
1006 integer,
intent(in):: im, km, k1
1007 real,
intent(in),
dimension(im,km):: t, p, q
1008 real,
intent(out),
dimension(im,km):: qs
1009 real,
intent(out),
optional:: dqdt(im,km)
1023 ap1 = 10.*dim(t(i,k), tmin) + 1.
1024 ap1 =
min(2621., ap1)
1026 es(i,k) =
table(it) + (ap1-it)*
des(it)
1027 qs(i,k) =
esl*es(i,k)*(1.+
zvir*q(i,k))/p(i,k)
1031 if (
present(dqdt) )
then 1034 ap1 = 10.*dim(t(i,k), tmin) + 1.
1035 ap1 =
min(2621., ap1) - 0.5
1037 dqdt(i,k) = eps10*(
des(it)+(ap1-it)*(
des(it+1)-
des(it)))*(1.+
zvir*q(i,k))/p(i,k)
1046 integer,
intent(in):: n
1049 real esbasw, tbasw, esbasi, tbasi, Tmin, tem, aa, b, c, d, e, esh20
1060 tem = tmin+dt*
real(i-1)
1061 aa = -7.90298*(tbasw/tem-1)
1062 b = 5.02808*alog10(tbasw/tem)
1063 c = -1.3816e-07*(10**((1-tem/tbasw)*11.344)-1)
1064 d = 8.1328e-03*(10**((tbasw/tem-1)*(-3.49149))-1)
1066 table(i) = 0.1*10**(aa+b+c+d+e)
1073 integer,
intent(in):: n
1077 real esbasw, tbasw, esbasi, tbasi, Tmin, tem, aa, b, c, d, e, esh20
1091 tem = tmin+dt*
real(i-1)
1092 aa = -9.09718 *(tbasi/tem-1.0)
1093 b = -3.56654 *alog10(tbasi/tem)
1094 c = 0.876793*(1.0-tem/tbasi)
1096 table(i)=10**(aa+b+c+e)
1102 tem = 253.16+dt*
real(i-1)
1103 aa = -7.90298*(tbasw/tem-1)
1104 b = 5.02808*alog10(tbasw/tem)
1105 c = -1.3816e-07*(10**((1-tem/tbasw)*11.344)-1)
1106 d = 8.1328e-03*(10**((tbasw/tem-1)*(-3.49149))-1)
1108 esh20 = 10**(aa+b+c+d+e)
1112 table(i+1400) = esh20
1118 tem = 253.16+dt*
real(i-1)
1119 wice = 0.05*(273.16-tem)
1120 wh2o = 0.05*(tem-253.16)
1121 table(i+1400) = wice*table(i+1400)+wh2o*esupc(i)
1125 table(i) = table(i)*0.1
1130 subroutine neg_adj3(is, ie, js, je, ng, kbot, hydrostatic, &
1131 peln, delz, pt, dp, qv, ql, qr, qi, qs, qg, qa, check_negative)
1134 integer,
intent(in):: is, ie, js, je, ng, kbot
1135 logical,
intent(in):: hydrostatic
1136 real,
intent(in):: dp(is-ng:ie+ng,js-ng:je+ng,kbot)
1137 real,
intent(in):: delz(is-ng:,js-ng:,1:)
1138 real,
intent(in):: peln(is:ie,kbot+1,js:je)
1139 logical,
intent(in),
OPTIONAL :: check_negative
1140 real,
intent(inout),
dimension(is-ng:ie+ng,js-ng:je+ng,kbot):: &
1141 pt, qv, ql, qr, qi, qs,
qg 1142 real,
intent(inout),
OPTIONAL,
dimension(is-ng:ie+ng,js-ng:je+ng,kbot):: qa
1144 logical:: sat_adj = .false.
1145 real,
parameter :: t48 =
tice - 48.
1146 real,
dimension(is:ie,kbot):: dpk, q2
1147 real,
dimension(is:ie,js:je):: pt2, qv2, ql2, qi2, qs2, qr2, qg2, dp2, p2, icpk, lcpk
1149 real:: dq, qsum, dq1, q_liq, q_sol, cpm, sink, qsw, dwsdt
1154 if (
present(check_negative) )
then 1155 if ( check_negative )
then 1156 call prt_negative(
'Temperature', pt, is, ie, js, je, ng, kbot, 165.)
1157 call prt_negative(
'sphum', qv, is, ie, js, je, ng, kbot, -1.e-8)
1158 call prt_negative(
'liq_wat', ql, is, ie, js, je, ng, kbot, -1.e-7)
1159 call prt_negative(
'rainwat', qr, is, ie, js, je, ng, kbot, -1.e-7)
1160 call prt_negative(
'ice_wat', qi, is, ie, js, je, ng, kbot, -1.e-7)
1161 call prt_negative(
'snowwat', qs, is, ie, js, je, ng, kbot, -1.e-7)
1162 call prt_negative(
'graupel',
qg, is, ie, js, je, ng, kbot, -1.e-7)
1166 if ( hydrostatic )
then 1180 qv2(i,j) = qv(i,j,k)
1181 ql2(i,j) = ql(i,j,k)
1182 qi2(i,j) = qi(i,j,k)
1183 qs2(i,j) = qs(i,j,k)
1184 qr2(i,j) = qr(i,j,k)
1185 qg2(i,j) =
qg(i,j,k)
1186 dp2(i,j) = dp(i,j,k)
1187 pt2(i,j) = pt(i,j,k)
1191 if ( hydrostatic )
then 1194 p2(i,j) = dp2(i,j)/(peln(i,k+1,j)-peln(i,k,j))
1195 q_liq =
max(0., ql2(i,j) + qr2(i,j))
1196 q_sol =
max(0., qi2(i,j) + qs2(i,j))
1198 lcpk(i,j) =
hlv / cpm
1199 icpk(i,j) =
hlf / cpm
1205 p2(i,j) = -dp2(i,j)/(
grav*delz(i,j,k))*
rdgas*pt2(i,j)*(1.+
zvir*qv2(i,j))
1206 q_liq =
max(0., ql2(i,j) + qr2(i,j))
1207 q_sol =
max(0., qi2(i,j) + qs2(i,j))
1208 cpm = (1.-(qv2(i,j)+q_liq+q_sol))*cv_air + qv2(i,j)*
cv_vap + q_liq*
c_liq + q_sol*
c_ice 1221 qsum = qi2(i,j) + qs2(i,j)
1222 if ( qsum > 0. )
then 1223 if ( qi2(i,j) < 0. )
then 1226 elseif ( qs2(i,j) < 0. )
then 1234 qg2(i,j) = qg2(i,j) + qsum
1239 if ( qg2(i,j) < 0. )
then 1240 dq =
min( qs2(i,j), -qg2(i,j) )
1241 qs2(i,j) = qs2(i,j) - dq
1242 qg2(i,j) = qg2(i,j) + dq
1243 if ( qg2(i,j) < 0. )
then 1245 dq =
min( qi2(i,j), -qg2(i,j) )
1246 qi2(i,j) = qi2(i,j) - dq
1247 qg2(i,j) = qg2(i,j) + dq
1252 if ( qg2(i,j)<0. .and. qr2(i,j)>0. )
then 1253 dq =
min( qr2(i,j), -qg2(i,j) )
1254 qg2(i,j) = qg2(i,j) + dq
1255 qr2(i,j) = qr2(i,j) - dq
1256 pt2(i,j) = pt2(i,j) + dq*icpk(i,j)
1259 if ( qg2(i,j)<0. .and. ql2(i,j)>0. )
then 1260 dq =
min( ql2(i,j), -qg2(i,j) )
1261 qg2(i,j) = qg2(i,j) + dq
1262 ql2(i,j) = ql2(i,j) - dq
1263 pt2(i,j) = pt2(i,j) + dq*icpk(i,j)
1266 if ( qg2(i,j)<0. .and. qv2(i,j)>0. )
then 1267 dq =
min( 0.999*qv2(i,j), -qg2(i,j) )
1268 qg2(i,j) = qg2(i,j) + dq
1269 qv2(i,j) = qv2(i,j) - dq
1270 pt2(i,j) = pt2(i,j) + dq*(icpk(i,j)+lcpk(i,j))
1276 qsum = ql2(i,j) + qr2(i,j)
1277 if ( qsum > 0. )
then 1278 if ( qr2(i,j) < 0. )
then 1281 elseif ( ql2(i,j) < 0. )
then 1289 dq =
min(
max(0.0, qg2(i,j)), -qr2(i,j) )
1290 qr2(i,j) = qr2(i,j) + dq
1291 qg2(i,j) = qg2(i,j) - dq
1292 pt2(i,j) = pt2(i,j) - dq*icpk(i,j)
1293 if ( qr(i,j,k) < 0. )
then 1295 dq =
min( qi2(i,j)+qs2(i,j), -qr2(i,j) )
1296 qr2(i,j) = qr2(i,j) + dq
1297 dq1 =
min( dq, qs2(i,j) )
1298 qs2(i,j) = qs2(i,j) - dq1
1299 qi2(i,j) = qi2(i,j) + dq1 - dq
1300 pt2(i,j) = pt2(i,j) - dq*icpk(i,j)
1303 if ( qr2(i,j)<0. .and. qv2(i,j)>0. )
then 1304 dq =
min( 0.999*qv2(i,j), -qr2(i,j) )
1305 qv2(i,j) = qv2(i,j) - dq
1306 qr2(i,j) = qr2(i,j) + dq
1307 pt2(i,j) = pt2(i,j) + dq*lcpk(i,j)
1322 if ( qi2(i,j)>1.e-8 .and. pt2(i,j) >
tice )
then 1323 sink =
min( qi2(i,j), (pt2(i,j)-
tice)/icpk(i,j) )
1324 ql2(i,j) = ql2(i,j) + sink
1325 qi2(i,j) = qi2(i,j) - sink
1326 pt2(i,j) = pt2(i,j) - sink*icpk(i,j)
1331 sink =
min( ql2(i,j), (qsw-qv2(i,j))/(1.+lcpk(i,j)*dwsdt) )
1332 qv2(i,j) = qv2(i,j) + sink
1333 ql2(i,j) = ql2(i,j) - sink
1334 pt2(i,j) = pt2(i,j) - sink*lcpk(i,j)
1338 if( ql2(i,j)>1.e-8 .and. pt2(i,j) < t48 )
then 1340 sink =
min( ql2(i,j), (t48-pt2(i,j))/icpk(i,j) )
1341 ql2(i,j) = ql2(i,j) - sink
1342 qi2(i,j) = qi2(i,j) + sink
1343 pt2(i,j) = pt2(i,j) + sink*icpk(i,j)
1354 qv(i,j,k) = qv2(i,j)
1355 ql(i,j,k) = ql2(i,j)
1356 qi(i,j,k) = qi2(i,j)
1357 qs(i,j,k) = qs2(i,j)
1358 qr(i,j,k) = qr2(i,j)
1359 qg(i,j,k) = qg2(i,j)
1360 pt(i,j,k) = pt2(i,j)
1372 dpk(i,k) = dp(i,j,k)
1376 call fillq(ie-is+1, kbot, q2, dpk)
1388 call fillq(ie-is+1, kbot, q2, dpk)
1404 if( qv(i,j,k) < 0. )
then 1405 qv(i,j,k+1) = qv(i,j,k+1) + qv(i,j,k)*dp(i,j,k)/dp(i,j,k+1)
1417 if( qv(i,j,k) < 0. .and. qv(i,j,k-1) > 0. )
then 1418 dq =
min(-qv(i,j,k)*dp(i,j,k), qv(i,j,k-1)*dp(i,j,k-1))
1419 qv(i,j,k-1) = qv(i,j,k-1) - dq/dp(i,j,k-1)
1420 qv(i,j,k ) = qv(i,j,k ) + dq/dp(i,j,k )
1422 if( qv(i,j,k) < 0. )
then 1423 qv(i,j,k+1) = qv(i,j,k+1) + qv(i,j,k)*dp(i,j,k)/dp(i,j,k+1)
1434 if( qv(i,j,kbot) < 0. )
then 1436 if ( qv(i,j,kbot)>=0. )
goto 123
1437 if ( qv(i,j,k) > 0. )
then 1438 dq =
min(-qv(i,j,kbot)*dp(i,j,kbot), qv(i,j,k)*dp(i,j,k))
1439 qv(i,j,k ) = qv(i,j,k ) - dq/dp(i,j,k)
1440 qv(i,j,kbot) = qv(i,j,kbot) + dq/dp(i,j,kbot)
1449 if (
present(qa))
then 1458 if( qa(i,j,k) < 0. )
then 1459 qa(i,j,k+1) = qa(i,j,k+1) + qa(i,j,k)*dp(i,j,k)/dp(i,j,k+1)
1471 if( qa(i,j,kbot) < 0. .and. qa(i,j,kbot-1)>0.)
then 1472 dq =
min(-qa(i,j,kbot)*dp(i,j,kbot), qa(i,j,kbot-1)*dp(i,j,kbot-1))
1473 qa(i,j,kbot-1) = qa(i,j,kbot-1) - dq/dp(i,j,kbot-1)
1474 qa(i,j,kbot ) = qa(i,j,kbot ) + dq/dp(i,j,kbot )
1477 qa(i,j,kbot) =
max(0., qa(i,j,kbot))
1485 subroutine fillq(im, km, q, dp)
1487 integer,
intent(in):: im, km
1488 real,
intent(inout),
dimension(im,km):: q, dp
1490 real:: sum1, sum2, dq
1495 if ( q(i,k)>0. )
then 1496 sum1 = sum1 + q(i,k)*dp(i,k)
1499 if ( sum1<1.e-12 )
goto 500
1502 if ( q(i,k)<0.0 .and. sum1>0. )
then 1503 dq =
min( sum1, -q(i,k)*dp(i,k) )
1506 q(i,k) = q(i,k) + dq/dp(i,k)
1510 if ( q(i,k)>0.0 .and. sum2>0. )
then 1511 dq =
min( sum2, q(i,k)*dp(i,k) )
1513 q(i,k) = q(i,k) - dq/dp(i,k)
1518 end subroutine fillq 1520 subroutine prt_negative(qname, q, is, ie, js, je, n_g, km, threshold)
1521 character(len=*),
intent(in):: qname
1522 integer,
intent(in):: is, ie, js, je
1523 integer,
intent(in):: n_g, km
1524 real,
intent(in):: q(is-n_g:ie+n_g, js-n_g:je+n_g, km)
1525 real,
intent(in):: threshold
1533 qmin =
min(qmin, q(i,j,k))
1537 call mp_reduce_min(qmin)
1538 if(is_master() .and. qmin<threshold)
write(6,*) qname,
' min (negative) = ', qmin
real function, public wqs2(ta, den, dqdt)
integer, parameter, public model_atmos
real, parameter, public hlv
Latent heat of evaporation [J/kg].
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
real, parameter, public cp_vapor
Specific heat capacity of water vapor at constant pressure [J/kg/deg].
subroutine prt_negative(qname, q, is, ie, js, je, n_g, km, threshold)
real, dimension(:), allocatable table
subroutine qs_table_m(n, table)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine, public fv_subgrid_z(isd, ied, jsd, jed, is, ie, js, je, km, nq, dt, tau, nwat, delp, pe, peln, pkz, ta, qa, ua, va, hydrostatic, w, delz, u_dt, v_dt, t_dt, q_dt, k_bot)
subroutine qs_table(n, table)
subroutine, public qsmith(im, km, k1, t, p, q, qs, dqdt)
real, parameter, public hlf
Latent heat of fusion [J/kg].
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public neg_adj3(is, ie, js, je, ng, kbot, hydrostatic, peln, delz, pt, dp, qv, ql, qr, qi, qs, qg, qa, check_negative)
real function, public wqsat2_moist(ta, qv, pa, dqdt)
subroutine fillq(im, km, q, dp)
real, dimension(:), allocatable des
real, parameter, public kappa
RDGAS / CP_AIR [dimensionless].
The namespace for the qg model.