39 real,
parameter::
esl = 0.621971831
40 real,
parameter::
tice = 273.16
43 real,
parameter::
c_liq = 4.1855e+3
52 real,
parameter::
hlv0 = 2.5e6
53 real,
parameter::
hlf0 = 3.3358e5
56 real,
parameter::
t_ice = 273.16
93 & , dt, tau, nwat, delp, pe, peln, pkz, ta, qa, ua, va, hydrostatic, w&
94 & , delz, u_dt, v_dt, t_dt, k_bot)
98 INTEGER,
INTENT(IN) :: is, ie, js, je, km, nq, nwat
99 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
101 INTEGER,
INTENT(IN) :: tau
103 REAL,
INTENT(IN) :: dt
104 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
105 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
107 REAL,
INTENT(IN) :: delp(isd:ied, jsd:jed, km)
109 REAL,
INTENT(IN) :: delz(isd:, jsd:, :)
110 REAL,
INTENT(IN) :: pkz(is:ie, js:je, km)
111 LOGICAL,
INTENT(IN) :: hydrostatic
112 INTEGER,
INTENT(IN),
OPTIONAL :: k_bot
114 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
115 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
116 REAL,
INTENT(INOUT) :: w(isd:, jsd:, :)
118 REAL,
INTENT(INOUT) :: ta(isd:ied, jsd:jed, km)
120 REAL,
INTENT(INOUT) :: qa(isd:ied, jsd:jed, km, nq)
121 REAL,
INTENT(INOUT) :: u_dt(isd:ied, jsd:jed, km)
122 REAL,
INTENT(INOUT) :: v_dt(isd:ied, jsd:jed, km)
123 REAL,
INTENT(INOUT) :: t_dt(is:ie, js:je, km)
125 REAL,
DIMENSION(is:ie, km) :: u0, v0, w0, t0, hd, te, gz, tvm, pm, &
127 REAL :: q0(is:ie, km, nq), qcon(is:ie, km)
128 REAL,
DIMENSION(is:ie) :: gzh, lcp2, icp2, cvm, cpm, qs
129 REAL :: ri_ref, ri, pt1, pt2, ratio, tv, cv, tmp, q_liq, q_sol
130 REAL :: tv1, tv2, g2, h0, mc, fra, rk, rz, rdt, tvd, tv_surf
131 REAL :: dh, dq, qsw, dqsdt, tcp3, t_max, t_min
132 INTEGER :: i, j, k, kk, n, m, iq, km1, im, kbot
133 REAL,
PARAMETER :: ustar2=1.e-4
135 INTEGER :: sphum, liq_wat, rainwat, snowwat, graupel, ice_wat, &
150 IF (
PRESENT(k_bot))
THEN 151 IF (k_bot .LT. 3)
THEN 162 IF (pe(is, 1, js) .LT. 2.)
THEN 172 IF (k_bot .LT. min1)
THEN 181 IF (nwat .EQ. 0)
THEN 189 IF (nwat .EQ. 3)
THEN 215 q0(i, k, iq) = qa(i, j, k, iq)
222 t0(i, k) = ta(i, j, k)
223 tvm(i, k) = t0(i, k)*(1.+xvir*q0(i, k, sphum))
225 u0(i, k) = ua(i, j, k)
227 v0(i, k) = va(i, j, k)
229 pm(i, k) = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
236 IF (hydrostatic)
THEN 242 gz(i, k) = gzh(i) + tv*(1.-pe(i, k, j)/pm(i, k))
244 hd(i, k) =
cp_air*tvm(i, k) + gz(i, k) + 0.5*(u0(i, k)**2+v0&
247 gzh(i) = gzh(i) + tv*(peln(i, k+1, j)-peln(i, k, j))
253 IF (nwat .EQ. 0)
THEN 261 ELSE IF (nwat .EQ. 1)
THEN 264 cpm(i) = (1.-q0(i, k, sphum))*
cp_air + q0(i, k, sphum)*&
267 cvm(i) = (1.-q0(i, k, sphum))*cv_air + q0(i, k, sphum)*&
271 ELSE IF (nwat .EQ. 2)
THEN 275 cpm(i) = (1.-q0(i, k, sphum))*
cp_air + q0(i, k, sphum)*&
278 cvm(i) = (1.-q0(i, k, sphum))*cv_air + q0(i, k, sphum)*&
282 ELSE IF (nwat .EQ. 3)
THEN 284 q_liq = q0(i, k, liq_wat)
285 q_sol = q0(i, k, ice_wat)
287 cpm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*
cp_air + q0(i&
290 cvm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*cv_air + q0(i&
294 ELSE IF (nwat .EQ. 4)
THEN 296 q_liq = q0(i, k, liq_wat) + q0(i, k, rainwat)
298 cpm(i) = (1.-(q0(i, k, sphum)+q_liq))*
cp_air + q0(i, k, &
301 cvm(i) = (1.-(q0(i, k, sphum)+q_liq))*cv_air + q0(i, k, &
307 q_liq = q0(i, k, liq_wat) + q0(i, k, rainwat)
308 q_sol = q0(i, k, ice_wat) + q0(i, k, snowwat) + q0(i, k, &
311 cpm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*
cp_air + q0(i&
314 cvm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*cv_air + q0(i&
321 w0(i, k) = w(i, j, k)
323 gz(i, k) = gzh(i) - g2*delz(i, j, k)
324 tmp = gz(i, k) + 0.5*(u0(i, k)**2+v0(i, k)**2+w0(i, k)**2)
326 hd(i, k) = cpm(i)*t0(i, k) + tmp
328 te(i, k) = cvm(i)*t0(i, k) + tmp
330 gzh(i) = gzh(i) -
grav*delz(i, j, k)
360 ratio =
REAL(n)/
REAL(m)
368 IF (nwat .LT. 2)
THEN 376 ELSE IF (nwat .EQ. 2)
THEN 381 qcon(i, k) = q0(i, k, liq_wat)
385 ELSE IF (nwat .EQ. 3)
THEN 389 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, ice_wat)
393 ELSE IF (nwat .EQ. 4)
THEN 397 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, rainwat)
405 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, ice_wat) + q0(i&
406 & , k, snowwat) + q0(i, k, rainwat) + q0(i, k, graupel)
416 tv1 = t0(i, km1)*(1.+xvir*q0(i, km1, sphum)-qcon(i, km1))
417 tv2 = t0(i, k)*(1.+xvir*q0(i, k, sphum)-qcon(i, k))
418 pt1 = tv1/pkz(i, j, km1)
419 pt2 = tv2/pkz(i, j, k)
422 ri = (gz(i, km1)-gz(i, k))*(pt1-pt2)/(0.5*(pt1+pt2)*((u0(i, &
423 & km1)-u0(i, k))**2+(v0(i, km1)-v0(i, k))**2+ustar2))
424 IF (tv1 .GT. t_max .AND. tv1 .GT. tv2)
THEN 428 ELSE IF (tv2 .LT. t_min)
THEN 429 IF (ri .GT. 0.2)
THEN 439 IF (400.e2 - pm(i, k) .LT. 0.)
THEN 443 max2 = 400.e2 - pm(i, k)
460 ELSE IF (k .EQ. 3)
THEN 463 ELSE IF (k .EQ. 4)
THEN 469 IF (ri .LT. ri_ref)
THEN 470 IF (0.0 .LT. ri/ri_ref)
THEN 480 mc = ratio*delp(i, j, km1)*delp(i, j, k)/(delp(i, j, km1)+&
481 & delp(i, j, k))*(1.-max1)**2
484 h0 = mc*(q0(i, k, iq)-q0(i, km1, iq))
486 q0(i, km1, iq) = q0(i, km1, iq) + h0/delp(i, j, km1)
488 q0(i, k, iq) = q0(i, k, iq) - h0/delp(i, j, k)
491 IF (nwat .LT. 2)
THEN 495 ELSE IF (nwat .EQ. 2)
THEN 498 qcon(i, km1) = q0(i, km1, liq_wat)
500 ELSE IF (nwat .EQ. 3)
THEN 503 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, ice_wat)
505 ELSE IF (nwat .EQ. 4)
THEN 508 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, rainwat)
512 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, ice_wat)&
513 & + q0(i, km1, snowwat) + q0(i, km1, rainwat) + q0(i, &
519 h0 = mc*(u0(i, k)-u0(i, k-1))
521 u0(i, k-1) = u0(i, k-1) + h0/delp(i, j, k-1)
523 u0(i, k) = u0(i, k) - h0/delp(i, j, k)
526 h0 = mc*(v0(i, k)-v0(i, k-1))
528 v0(i, k-1) = v0(i, k-1) + h0/delp(i, j, k-1)
530 v0(i, k) = v0(i, k) - h0/delp(i, j, k)
531 IF (hydrostatic)
THEN 534 h0 = mc*(hd(i, k)-hd(i, k-1))
536 hd(i, k-1) = hd(i, k-1) + h0/delp(i, j, k-1)
538 hd(i, k) = hd(i, k) - h0/delp(i, j, k)
543 h0 = mc*(hd(i, k)-hd(i, k-1))
545 te(i, k-1) = te(i, k-1) + h0/delp(i, j, k-1)
547 te(i, k) = te(i, k) - h0/delp(i, j, k)
549 h0 = mc*(w0(i, k)-w0(i, k-1))
551 w0(i, k-1) = w0(i, k-1) + h0/delp(i, j, k-1)
553 w0(i, k) = w0(i, k) - h0/delp(i, j, k)
563 IF (hydrostatic)
THEN 568 t0(i, kk) = (hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, kk)&
569 & **2))/(rk-pe(i, kk, j)/pm(i, kk))
571 gzh(i) = gzh(i) + t0(i, kk)*(peln(i, kk+1, j)-peln(i, kk, &
574 t0(i, kk) = t0(i, kk)/(
rdgas+rz*q0(i, kk, sphum))
579 t0(i, kk) = (hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, kk)&
580 & **2))/((rk-pe(i, kk, j)/pm(i, kk))*(
rdgas+rz*q0(i, kk, &
589 IF (nwat .EQ. 0)
THEN 597 ELSE IF (nwat .EQ. 1)
THEN 600 cpm(i) = (1.-q0(i, kk, sphum))*
cp_air + q0(i, kk, &
603 cvm(i) = (1.-q0(i, kk, sphum))*cv_air + q0(i, kk, &
607 ELSE IF (nwat .EQ. 2)
THEN 610 cpm(i) = (1.-q0(i, kk, sphum))*
cp_air + q0(i, kk, &
613 cvm(i) = (1.-q0(i, kk, sphum))*cv_air + q0(i, kk, &
617 ELSE IF (nwat .EQ. 3)
THEN 619 q_liq = q0(i, kk, liq_wat)
620 q_sol = q0(i, kk, ice_wat)
622 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*
cp_air + &
626 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*cv_air + &
630 ELSE IF (nwat .EQ. 4)
THEN 632 q_liq = q0(i, kk, liq_wat) + q0(i, kk, rainwat)
634 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq))*
cp_air + q0(i, &
637 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq))*cv_air + q0(i, &
643 q_liq = q0(i, kk, liq_wat) + q0(i, kk, rainwat)
644 q_sol = q0(i, kk, ice_wat) + q0(i, kk, snowwat) + q0(i&
647 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*
cp_air + &
651 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*cv_air + &
658 tv = gz(i, kk) + 0.5*(u0(i, kk)**2+v0(i, kk)**2+w0(i, kk&
661 t0(i, kk) = (te(i, kk)-tv)/cvm(i)
663 hd(i, kk) = cpm(i)*t0(i, kk) + tv
675 IF (fra .LT. 1.)
THEN 679 t0(i, k) = ta(i, j, k) + (t0(i, k)-ta(i, j, k))*fra
681 u0(i, k) = ua(i, j, k) + (u0(i, k)-ua(i, j, k))*fra
683 v0(i, k) = va(i, j, k) + (v0(i, k)-va(i, j, k))*fra
686 IF (.NOT.hydrostatic)
THEN 690 w0(i, k) = w(i, j, k) + (w0(i, k)-w(i, j, k))*fra
701 q0(i, k, iq) = qa(i, j, k, iq) + (q0(i, k, iq)-qa(i, j, k&
714 ta(i, j, k) = t0(i, k)
717 IF (.NOT.hydrostatic)
THEN 783 & , dt, tau, nwat, delp, delp_ad, pe, pe_ad, peln, peln_ad, pkz, &
784 & pkz_ad, ta, ta_ad, qa, qa_ad, ua, ua_ad, va, va_ad, hydrostatic, w, &
785 & w_ad, delz, delz_ad, u_dt, v_dt, t_dt, k_bot)
787 INTEGER,
INTENT(IN) :: is, ie, js, je, km, nq, nwat
788 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
789 INTEGER,
INTENT(IN) :: tau
790 REAL,
INTENT(IN) :: dt
791 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
792 REAL :: pe_ad(is-1:ie+1, km+1, js-1:je+1)
793 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
794 REAL :: peln_ad(is:ie, km+1, js:je)
795 REAL,
INTENT(IN) :: delp(isd:ied, jsd:jed, km)
796 REAL :: delp_ad(isd:ied, jsd:jed, km)
797 REAL,
INTENT(IN) :: delz(isd:, jsd:, :)
798 REAL :: delz_ad(isd:, jsd:, :)
799 REAL,
INTENT(IN) :: pkz(is:ie, js:je, km)
800 REAL :: pkz_ad(is:ie, js:je, km)
801 LOGICAL,
INTENT(IN) :: hydrostatic
802 INTEGER,
INTENT(IN),
OPTIONAL :: k_bot
803 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
804 REAL,
INTENT(INOUT) :: ua_ad(isd:ied, jsd:jed, km)
805 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
806 REAL,
INTENT(INOUT) :: va_ad(isd:ied, jsd:jed, km)
807 REAL,
INTENT(INOUT) :: w(isd:, jsd:, :)
808 REAL,
INTENT(INOUT) :: w_ad(isd:, jsd:, :)
809 REAL,
INTENT(INOUT) :: ta(isd:ied, jsd:jed, km)
810 REAL,
INTENT(INOUT) :: ta_ad(isd:ied, jsd:jed, km)
811 REAL,
INTENT(INOUT) :: qa(isd:ied, jsd:jed, km, nq)
812 REAL,
INTENT(INOUT) :: qa_ad(isd:ied, jsd:jed, km, nq)
813 REAL,
INTENT(INOUT) :: u_dt(isd:ied, jsd:jed, km)
814 REAL,
INTENT(INOUT) :: v_dt(isd:ied, jsd:jed, km)
815 REAL,
INTENT(INOUT) :: t_dt(is:ie, js:je, km)
816 REAL,
DIMENSION(is:ie, km) :: u0, v0, w0, t0, hd, te, gz, tvm, pm, &
818 REAL,
DIMENSION(is:ie, km) :: u0_ad, v0_ad, w0_ad, t0_ad, hd_ad, &
819 & te_ad, gz_ad, tvm_ad, pm_ad
820 REAL :: q0(is:ie, km, nq), qcon(is:ie, km)
821 REAL :: q0_ad(is:ie, km, nq), qcon_ad(is:ie, km)
822 REAL,
DIMENSION(is:ie) :: gzh, lcp2, icp2, cvm, cpm, qs
823 REAL,
DIMENSION(is:ie) :: gzh_ad, cvm_ad, cpm_ad
824 REAL :: ri_ref, ri, pt1, pt2, ratio, tv, cv, tmp, q_liq, q_sol
825 REAL :: ri_ref_ad, ri_ad, pt1_ad, pt2_ad, tv_ad, tmp_ad, q_liq_ad, &
827 REAL :: tv1, tv2, g2, h0, mc, fra, rk, rz, rdt, tvd, tv_surf
828 REAL :: tv1_ad, tv2_ad, h0_ad, mc_ad
829 REAL :: dh, dq, qsw, dqsdt, tcp3, t_max, t_min
830 INTEGER :: i, j, k, kk, n, m, iq, km1, im, kbot
831 REAL,
PARAMETER :: ustar2=1.e-4
833 INTEGER :: sphum, liq_wat, rainwat, snowwat, graupel, ice_wat, &
911 IF (branch .EQ. 0)
THEN 972 IF (branch .EQ. 0)
THEN 975 w0_ad(i, k) = w0_ad(i, k) + w_ad(i, j, k)
983 q0_ad(i, k, iq) = q0_ad(i, k, iq) + qa_ad(i, j, k, iq)
984 qa_ad(i, j, k, iq) = 0.0
988 v0_ad(i, k) = v0_ad(i, k) + va_ad(i, j, k)
990 u0_ad(i, k) = u0_ad(i, k) + ua_ad(i, j, k)
993 t0_ad(i, k) = t0_ad(i, k) + ta_ad(i, j, k)
998 IF (branch .NE. 0)
THEN 1003 qa_ad(i, j, k, iq) = qa_ad(i, j, k, iq) + (1.0-fra)*&
1005 q0_ad(i, k, iq) = fra*q0_ad(i, k, iq)
1010 IF (branch .NE. 0)
THEN 1014 w_ad(i, j, k) = w_ad(i, j, k) + (1.0-fra)*w0_ad(i, k)
1015 w0_ad(i, k) = fra*w0_ad(i, k)
1022 va_ad(i, j, k) = va_ad(i, j, k) + (1.0-fra)*v0_ad(i, k)
1023 v0_ad(i, k) = fra*v0_ad(i, k)
1025 ua_ad(i, j, k) = ua_ad(i, j, k) + (1.0-fra)*u0_ad(i, k)
1026 u0_ad(i, k) = fra*u0_ad(i, k)
1028 ta_ad(i, j, k) = ta_ad(i, j, k) + (1.0-fra)*t0_ad(i, k)
1029 t0_ad(i, k) = fra*t0_ad(i, k)
1036 IF (branch .EQ. 0)
THEN 1039 DO kk=ad_to,ad_from,-1
1042 cpm_ad(i) = cpm_ad(i) + t0(i, kk)*hd_ad(i, kk)
1043 t0_ad(i, kk) = t0_ad(i, kk) + cpm(i)*hd_ad(i, kk)
1045 temp_ad41 = t0_ad(i, kk)/cvm(i)
1046 tv_ad = hd_ad(i, kk) - temp_ad41
1048 te_ad(i, kk) = te_ad(i, kk) + temp_ad41
1049 cvm_ad(i) = cvm_ad(i) - (te(i, kk)-tv)*temp_ad41/cvm(i&
1053 temp_ad42 = 0.5*tv_ad
1054 gz_ad(i, kk) = gz_ad(i, kk) + tv_ad
1055 u0_ad(i, kk) = u0_ad(i, kk) + 2*u0(i, kk)*temp_ad42
1056 v0_ad(i, kk) = v0_ad(i, kk) + 2*v0(i, kk)*temp_ad42
1057 w0_ad(i, kk) = w0_ad(i, kk) + 2*w0(i, kk)*temp_ad42
1060 IF (branch .LT. 3)
THEN 1061 IF (branch .EQ. 0)
THEN 1063 temp_ad40 =
cp_air*cpm_ad(i)
1065 temp_ad39 = cv_air*cvm_ad(i)
1066 q_liq_ad =
c_liq*cpm_ad(i) - temp_ad40 +
c_liq*&
1067 & cvm_ad(i) - temp_ad39
1068 q_sol_ad =
c_ice*cpm_ad(i) - temp_ad40 +
c_ice*&
1069 & cvm_ad(i) - temp_ad39
1070 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + &
1076 q0_ad(i, kk, ice_wat) = q0_ad(i, kk, ice_wat) + &
1078 q0_ad(i, kk, snowwat) = q0_ad(i, kk, snowwat) + &
1080 q0_ad(i, kk, graupel) = q0_ad(i, kk, graupel) + &
1082 q0_ad(i, kk, liq_wat) = q0_ad(i, kk, liq_wat) + &
1084 q0_ad(i, kk, rainwat) = q0_ad(i, kk, rainwat) + &
1087 ELSE IF (branch .EQ. 1)
THEN 1092 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + (&
1098 q0_ad(i, kk, liq_wat) = q0_ad(i, kk, liq_wat) + &
1100 q0_ad(i, kk, rainwat) = q0_ad(i, kk, rainwat) + &
1105 temp_ad38 =
cp_air*cpm_ad(i)
1107 temp_ad37 = cv_air*cvm_ad(i)
1108 q_liq_ad =
c_liq*cpm_ad(i) - temp_ad38 +
c_liq*&
1109 & cvm_ad(i) - temp_ad37
1110 q_sol_ad =
c_ice*cpm_ad(i) - temp_ad38 +
c_ice*&
1111 & cvm_ad(i) - temp_ad37
1112 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + &
1118 q0_ad(i, kk, ice_wat) = q0_ad(i, kk, ice_wat) + &
1120 q0_ad(i, kk, liq_wat) = q0_ad(i, kk, liq_wat) + &
1124 ELSE IF (branch .EQ. 3)
THEN 1127 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + (&
1134 ELSE IF (branch .EQ. 4)
THEN 1137 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + (&
1157 temp15 =
rdgas + rz*q0(i, kk, sphum)
1159 temp13 = pe(i, kk, j)/temp14
1160 temp12 = (rk-temp13)*temp15
1161 temp_ad34 = t0_ad(i, kk)/temp12
1162 temp_ad35 = -((hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, &
1163 & kk)**2))*temp_ad34/temp12)
1164 temp_ad36 = -(temp15*temp_ad35/temp14)
1165 hd_ad(i, kk) = hd_ad(i, kk) + temp_ad34
1166 gzh_ad(i) = gzh_ad(i) - temp_ad34
1167 u0_ad(i, kk) = u0_ad(i, kk) - 0.5*2*u0(i, kk)*temp_ad34
1168 v0_ad(i, kk) = v0_ad(i, kk) - 0.5*2*v0(i, kk)*temp_ad34
1169 pe_ad(i, kk, j) = pe_ad(i, kk, j) + temp_ad36
1170 pm_ad(i, kk) = pm_ad(i, kk) - temp13*temp_ad36
1171 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) + (rk-temp13)*&
1178 temp11 =
rdgas + rz*q0(i, kk, sphum)
1179 q0_ad(i, kk, sphum) = q0_ad(i, kk, sphum) - t0(i, kk)*rz&
1180 & *t0_ad(i, kk)/temp11**2
1181 t0_ad(i, kk) = (peln(i, kk+1, j)-peln(i, kk, j))*gzh_ad(&
1182 & i) + t0_ad(i, kk)/temp11
1184 temp_ad31 = t0(i, kk)*gzh_ad(i)
1185 peln_ad(i, kk+1, j) = peln_ad(i, kk+1, j) + temp_ad31
1186 peln_ad(i, kk, j) = peln_ad(i, kk, j) - temp_ad31
1189 temp9 = pe(i, kk, j)/temp10
1190 temp_ad32 = t0_ad(i, kk)/(rk-temp9)
1191 temp_ad33 = (hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, kk&
1192 & )**2))*temp_ad32/((rk-temp9)*temp10)
1193 hd_ad(i, kk) = hd_ad(i, kk) + temp_ad32
1194 gzh_ad(i) = gzh_ad(i) - temp_ad32
1195 u0_ad(i, kk) = u0_ad(i, kk) - 0.5*2*u0(i, kk)*temp_ad32
1196 v0_ad(i, kk) = v0_ad(i, kk) - 0.5*2*v0(i, kk)*temp_ad32
1197 pe_ad(i, kk, j) = pe_ad(i, kk, j) + temp_ad33
1198 pm_ad(i, kk) = pm_ad(i, kk) - temp9*temp_ad33
1206 IF (branch .EQ. 0)
THEN 1210 IF (branch .EQ. 1)
THEN 1211 temp_ad30 = te_ad(i, k-1)/delp(i, j, k-1)
1212 temp_ad28 = w0_ad(i, k-1)/delp(i, j, k-1)
1214 temp_ad27 = -(w0_ad(i, k)/delp(i, j, k))
1215 h0_ad = temp_ad28 + temp_ad27
1216 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad27/&
1219 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) - h0*temp_ad28&
1221 mc_ad = (w0(i, k)-w0(i, k-1))*h0_ad
1222 w0_ad(i, k) = w0_ad(i, k) + mc*h0_ad
1223 w0_ad(i, k-1) = w0_ad(i, k-1) - mc*h0_ad
1224 h0 = mc*(hd(i, k)-hd(i, k-1))
1226 temp_ad29 = -(te_ad(i, k)/delp(i, j, k))
1227 h0_ad = temp_ad30 + temp_ad29
1228 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad29/&
1231 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) - h0*temp_ad30&
1234 mc_ad = mc_ad + (hd(i, k)-hd(i, k-1))*h0_ad
1235 hd_ad(i, k) = hd_ad(i, k) + mc*h0_ad
1236 hd_ad(i, k-1) = hd_ad(i, k-1) - mc*h0_ad
1238 temp_ad26 = hd_ad(i, k-1)/delp(i, j, k-1)
1240 temp_ad25 = -(hd_ad(i, k)/delp(i, j, k))
1241 h0_ad = temp_ad26 + temp_ad25
1242 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad25/&
1245 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) - h0*temp_ad26&
1248 mc_ad = (hd(i, k)-hd(i, k-1))*h0_ad
1249 hd_ad(i, k) = hd_ad(i, k) + mc*h0_ad
1250 hd_ad(i, k-1) = hd_ad(i, k-1) - mc*h0_ad
1252 temp_ad24 = u0_ad(i, k-1)/delp(i, j, k-1)
1253 temp_ad22 = v0_ad(i, k-1)/delp(i, j, k-1)
1255 temp_ad21 = -(v0_ad(i, k)/delp(i, j, k))
1256 h0_ad = temp_ad22 + temp_ad21
1257 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad21/delp(&
1260 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) - h0*temp_ad22/&
1263 mc_ad = mc_ad + (v0(i, k)-v0(i, k-1))*h0_ad
1264 v0_ad(i, k) = v0_ad(i, k) + mc*h0_ad
1265 v0_ad(i, k-1) = v0_ad(i, k-1) - mc*h0_ad
1267 temp_ad23 = -(u0_ad(i, k)/delp(i, j, k))
1268 h0_ad = temp_ad24 + temp_ad23
1269 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad23/delp(&
1272 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) - h0*temp_ad24/&
1275 mc_ad = mc_ad + (u0(i, k)-u0(i, k-1))*h0_ad
1276 u0_ad(i, k) = u0_ad(i, k) + mc*h0_ad
1277 u0_ad(i, k-1) = u0_ad(i, k-1) - mc*h0_ad
1279 IF (branch .LT. 2)
THEN 1280 IF (branch .EQ. 0)
THEN 1282 qcon_ad(i, km1) = 0.0
1285 q0_ad(i, km1, liq_wat) = q0_ad(i, km1, liq_wat) + &
1287 qcon_ad(i, km1) = 0.0
1289 ELSE IF (branch .EQ. 2)
THEN 1291 q0_ad(i, km1, liq_wat) = q0_ad(i, km1, liq_wat) + &
1293 q0_ad(i, km1, ice_wat) = q0_ad(i, km1, ice_wat) + &
1295 qcon_ad(i, km1) = 0.0
1296 ELSE IF (branch .EQ. 3)
THEN 1298 q0_ad(i, km1, liq_wat) = q0_ad(i, km1, liq_wat) + &
1300 q0_ad(i, km1, rainwat) = q0_ad(i, km1, rainwat) + &
1302 qcon_ad(i, km1) = 0.0
1305 q0_ad(i, km1, liq_wat) = q0_ad(i, km1, liq_wat) + &
1307 q0_ad(i, km1, ice_wat) = q0_ad(i, km1, ice_wat) + &
1309 q0_ad(i, km1, snowwat) = q0_ad(i, km1, snowwat) + &
1311 q0_ad(i, km1, rainwat) = q0_ad(i, km1, rainwat) + &
1313 q0_ad(i, km1, graupel) = q0_ad(i, km1, graupel) + &
1315 qcon_ad(i, km1) = 0.0
1318 temp_ad20 = q0_ad(i, km1, iq)/delp(i, j, km1)
1320 temp_ad19 = -(q0_ad(i, k, iq)/delp(i, j, k))
1321 h0_ad = temp_ad20 + temp_ad19
1322 delp_ad(i, j, k) = delp_ad(i, j, k) - h0*temp_ad19/&
1325 delp_ad(i, j, km1) = delp_ad(i, j, km1) - h0*temp_ad20&
1328 mc_ad = mc_ad + (q0(i, k, iq)-q0(i, km1, iq))*h0_ad
1329 q0_ad(i, k, iq) = q0_ad(i, k, iq) + mc*h0_ad
1330 q0_ad(i, km1, iq) = q0_ad(i, km1, iq) - mc*h0_ad
1333 temp8 = delp(i, j, km1) + delp(i, j, k)
1334 temp7 = delp(i, j, k)/temp8
1335 temp_ad16 = ratio*mc_ad
1336 temp_ad17 = delp(i, j, km1)*(1.-max1)**2*temp_ad16/temp8
1337 temp_ad18 = -(temp7*temp_ad17)
1338 delp_ad(i, j, km1) = delp_ad(i, j, km1) + temp_ad18 + &
1339 & temp7*(1.-max1)**2*temp_ad16
1340 max1_ad = -(2*(1.-max1)*delp(i, j, km1)*temp7*temp_ad16)
1341 delp_ad(i, j, k) = delp_ad(i, j, k) + temp_ad18 + &
1344 IF (branch .EQ. 0)
THEN 1346 ri_ad = max1_ad/ri_ref
1347 ri_ref_ad = -(ri*max1_ad/ri_ref**2)
1355 IF (branch .LT. 2)
THEN 1356 IF (branch .EQ. 0)
THEN 1357 ri_ref_ad = 4.*ri_ref_ad
1359 ri_ref_ad = 2.*ri_ref_ad
1361 ELSE IF (branch .EQ. 2)
THEN 1362 ri_ref_ad = 1.5*ri_ref_ad
1365 IF (branch .EQ. 0)
THEN 1374 IF (branch .NE. 0) pm_ad(i, k) = pm_ad(i, k) - max2_ad
1376 IF (branch .LT. 2)
THEN 1377 IF (branch .EQ. 0)
THEN 1378 tv2 = t0(i, k)*(1.+xvir*q0(i, k, sphum)-qcon(i, k))
1382 ELSE IF (branch .NE. 2)
THEN 1385 tv2 = t0(i, k)*(1.+xvir*q0(i, k, sphum)-qcon(i, k))
1386 100 tv1 = t0(i, km1)*(1.+xvir*q0(i, km1, sphum)-qcon(i, km1))
1387 pt1 = tv1/pkz(i, j, km1)
1388 pt2 = tv2/pkz(i, j, k)
1390 temp5 = v0(i, km1) - v0(i, k)
1391 temp4 = u0(i, km1) - u0(i, k)
1392 temp3 = ustar2 + temp4**2 + temp5**2
1393 temp2 = 0.5*(pt1+pt2)*temp3
1394 temp_ad6 = ri_ad/temp2
1395 temp6 = gz(i, km1) - gz(i, k)
1396 temp_ad7 = -(temp6*(pt1-pt2)*temp_ad6/temp2)
1397 temp_ad8 = temp3*0.5*temp_ad7
1398 temp_ad9 = 0.5*(pt1+pt2)*temp_ad7
1399 temp_ad10 = 2*temp4*temp_ad9
1400 temp_ad11 = 2*temp5*temp_ad9
1401 gz_ad(i, km1) = gz_ad(i, km1) + (pt1-pt2)*temp_ad6
1402 gz_ad(i, k) = gz_ad(i, k) - (pt1-pt2)*temp_ad6
1403 pt1_ad = temp_ad8 + temp6*temp_ad6
1404 pt2_ad = temp_ad8 - temp6*temp_ad6
1405 u0_ad(i, km1) = u0_ad(i, km1) + temp_ad10
1406 u0_ad(i, k) = u0_ad(i, k) - temp_ad10
1407 v0_ad(i, km1) = v0_ad(i, km1) + temp_ad11
1408 v0_ad(i, k) = v0_ad(i, k) - temp_ad11
1409 temp_ad12 = pt2_ad/pkz(i, j, k)
1411 pkz_ad(i, j, k) = pkz_ad(i, j, k) - tv2*temp_ad12/pkz(i, j&
1413 temp_ad13 = pt1_ad/pkz(i, j, km1)
1415 pkz_ad(i, j, km1) = pkz_ad(i, j, km1) - tv1*temp_ad13/pkz(&
1417 temp_ad14 = t0(i, k)*tv2_ad
1418 t0_ad(i, k) = t0_ad(i, k) + (xvir*q0(i, k, sphum)-qcon(i, &
1420 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) + xvir*temp_ad14
1421 qcon_ad(i, k) = qcon_ad(i, k) - temp_ad14
1422 temp_ad15 = t0(i, km1)*tv1_ad
1423 t0_ad(i, km1) = t0_ad(i, km1) + (xvir*q0(i, km1, sphum)-&
1424 & qcon(i, km1)+1.)*tv1_ad
1425 q0_ad(i, km1, sphum) = q0_ad(i, km1, sphum) + xvir*&
1427 qcon_ad(i, km1) = qcon_ad(i, km1) - temp_ad15
1431 IF (branch .LT. 2)
THEN 1432 IF (branch .EQ. 0)
THEN 1436 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + qcon_ad(&
1438 q0_ad(i, k, ice_wat) = q0_ad(i, k, ice_wat) + qcon_ad(&
1440 q0_ad(i, k, snowwat) = q0_ad(i, k, snowwat) + qcon_ad(&
1442 q0_ad(i, k, rainwat) = q0_ad(i, k, rainwat) + qcon_ad(&
1444 q0_ad(i, k, graupel) = q0_ad(i, k, graupel) + qcon_ad(&
1453 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + qcon_ad(&
1455 q0_ad(i, k, rainwat) = q0_ad(i, k, rainwat) + qcon_ad(&
1461 ELSE IF (branch .EQ. 2)
THEN 1465 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + qcon_ad(i&
1467 q0_ad(i, k, ice_wat) = q0_ad(i, k, ice_wat) + qcon_ad(i&
1472 ELSE IF (branch .EQ. 3)
THEN 1476 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + qcon_ad(i&
1494 IF (branch .EQ. 0)
THEN 1505 IF (branch .EQ. 0)
THEN 1508 tmp_ad = hd_ad(i, k) + te_ad(i, k)
1509 gz_ad(i, k) = gz_ad(i, k) + tmp_ad
1511 delz_ad(i, j, k) = delz_ad(i, j, k) - g2*gz_ad(i, k) - &
1514 cvm_ad(i) = cvm_ad(i) + t0(i, k)*te_ad(i, k)
1515 t0_ad(i, k) = t0_ad(i, k) + cpm(i)*hd_ad(i, k) + cvm(i)*&
1519 cpm_ad(i) = cpm_ad(i) + t0(i, k)*hd_ad(i, k)
1521 temp_ad5 = 0.5*tmp_ad
1522 u0_ad(i, k) = u0_ad(i, k) + 2*u0(i, k)*temp_ad5
1523 v0_ad(i, k) = v0_ad(i, k) + 2*v0(i, k)*temp_ad5
1524 w0_ad(i, k) = w0_ad(i, k) + 2*w0(i, k)*temp_ad5
1526 gzh_ad(i) = gzh_ad(i) + gz_ad(i, k)
1529 w_ad(i, j, k) = w_ad(i, j, k) + w0_ad(i, k)
1533 IF (branch .LT. 3)
THEN 1534 IF (branch .EQ. 0)
THEN 1536 temp_ad4 =
cp_air*cpm_ad(i)
1538 temp_ad3 = cv_air*cvm_ad(i)
1539 q_liq_ad =
c_liq*cpm_ad(i) - temp_ad4 +
c_liq*cvm_ad(i&
1541 q_sol_ad =
c_ice*cpm_ad(i) - temp_ad4 +
c_ice*cvm_ad(i&
1543 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) +
cp_vapor*&
1544 & cpm_ad(i) - temp_ad4 +
cv_vap*cvm_ad(i) - temp_ad3
1548 q0_ad(i, k, ice_wat) = q0_ad(i, k, ice_wat) + q_sol_ad
1549 q0_ad(i, k, snowwat) = q0_ad(i, k, snowwat) + q_sol_ad
1550 q0_ad(i, k, graupel) = q0_ad(i, k, graupel) + q_sol_ad
1551 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + q_liq_ad
1552 q0_ad(i, k, rainwat) = q0_ad(i, k, rainwat) + q_liq_ad
1554 ELSE IF (branch .EQ. 1)
THEN 1559 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) + (
cp_vapor-&
1564 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + q_liq_ad
1565 q0_ad(i, k, rainwat) = q0_ad(i, k, rainwat) + q_liq_ad
1569 temp_ad2 =
cp_air*cpm_ad(i)
1571 temp_ad1 = cv_air*cvm_ad(i)
1572 q_liq_ad =
c_liq*cpm_ad(i) - temp_ad2 +
c_liq*cvm_ad(i&
1574 q_sol_ad =
c_ice*cpm_ad(i) - temp_ad2 +
c_ice*cvm_ad(i&
1576 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) +
cp_vapor*&
1577 & cpm_ad(i) - temp_ad2 +
cv_vap*cvm_ad(i) - temp_ad1
1581 q0_ad(i, k, ice_wat) = q0_ad(i, k, ice_wat) + q_sol_ad
1582 q0_ad(i, k, liq_wat) = q0_ad(i, k, liq_wat) + q_liq_ad
1585 ELSE IF (branch .EQ. 3)
THEN 1588 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) + (
cp_vapor-&
1594 ELSE IF (branch .EQ. 4)
THEN 1597 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) + (
cp_vapor-&
1616 temp0 = pe(i, k, j)/temp1
1617 gz_ad(i, k) = gz_ad(i, k) + hd_ad(i, k)
1619 tv_ad = (1.-temp0)*gz_ad(i, k) + (peln(i, k+1, j)-peln(i, &
1621 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + tv*gzh_ad(i)
1622 peln_ad(i, k, j) = peln_ad(i, k, j) - tv*gzh_ad(i)
1624 tvm_ad(i, k) = tvm_ad(i, k) +
rdgas*tv_ad +
cp_air*hd_ad(i&
1626 u0_ad(i, k) = u0_ad(i, k) + 0.5*2*u0(i, k)*hd_ad(i, k)
1627 v0_ad(i, k) = v0_ad(i, k) + 0.5*2*v0(i, k)*hd_ad(i, k)
1630 temp_ad0 = -(tv*gz_ad(i, k)/temp1)
1631 gzh_ad(i) = gzh_ad(i) + gz_ad(i, k)
1632 pe_ad(i, k, j) = pe_ad(i, k, j) + temp_ad0
1633 pm_ad(i, k) = pm_ad(i, k) - temp0*temp_ad0
1646 temp = peln(i, k+1, j) - peln(i, k, j)
1647 temp_ad = -(delp(i, j, k)*pm_ad(i, k)/temp**2)
1648 delp_ad(i, j, k) = delp_ad(i, j, k) + pm_ad(i, k)/temp
1649 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad
1650 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad
1653 va_ad(i, j, k) = va_ad(i, j, k) + v0_ad(i, k)
1656 ua_ad(i, j, k) = ua_ad(i, j, k) + u0_ad(i, k)
1658 t0_ad(i, k) = t0_ad(i, k) + (xvir*q0(i, k, sphum)+1.)*tvm_ad&
1660 q0_ad(i, k, sphum) = q0_ad(i, k, sphum) + t0(i, k)*xvir*&
1664 ta_ad(i, j, k) = ta_ad(i, j, k) + t0_ad(i, k)
1672 qa_ad(i, j, k, iq) = qa_ad(i, j, k, iq) + q0_ad(i, k, iq)
1673 q0_ad(i, k, iq) = 0.0
1682 SUBROUTINE fv_subgrid_z(isd, ied, jsd, jed, is, ie, js, je, km, nq, dt&
1683 & , tau, nwat, delp, pe, peln, pkz, ta, qa, ua, va, hydrostatic, w, &
1684 & delz, u_dt, v_dt, t_dt, k_bot)
1688 INTEGER,
INTENT(IN) :: is, ie, js, je, km, nq, nwat
1689 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
1691 INTEGER,
INTENT(IN) :: tau
1693 REAL,
INTENT(IN) :: dt
1694 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
1695 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
1697 REAL,
INTENT(IN) :: delp(isd:ied, jsd:jed, km)
1699 REAL,
INTENT(IN) :: delz(isd:, jsd:, :)
1700 REAL,
INTENT(IN) :: pkz(is:ie, js:je, km)
1701 LOGICAL,
INTENT(IN) :: hydrostatic
1702 INTEGER,
INTENT(IN),
OPTIONAL :: k_bot
1704 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
1705 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
1706 REAL,
INTENT(INOUT) :: w(isd:, jsd:, :)
1708 REAL,
INTENT(INOUT) :: ta(isd:ied, jsd:jed, km)
1710 REAL,
INTENT(INOUT) :: qa(isd:ied, jsd:jed, km, nq)
1711 REAL,
INTENT(INOUT) :: u_dt(isd:ied, jsd:jed, km)
1712 REAL,
INTENT(INOUT) :: v_dt(isd:ied, jsd:jed, km)
1713 REAL,
INTENT(INOUT) :: t_dt(is:ie, js:je, km)
1715 REAL,
DIMENSION(is:ie, km) :: u0, v0, w0, t0, hd, te, gz, tvm, pm, &
1717 REAL :: q0(is:ie, km, nq), qcon(is:ie, km)
1718 REAL,
DIMENSION(is:ie) :: gzh, lcp2, icp2, cvm, cpm, qs
1719 REAL :: ri_ref, ri, pt1, pt2, ratio, tv, cv, tmp, q_liq, q_sol
1720 REAL :: tv1, tv2, g2, h0, mc, fra, rk, rz, rdt, tvd, tv_surf
1721 REAL :: dh, dq, qsw, dqsdt, tcp3, t_max, t_min
1722 INTEGER :: i, j, k, kk, n, m, iq, km1, im, kbot
1723 REAL,
PARAMETER :: ustar2=1.e-4
1724 REAL :: cv_air, xvir
1725 INTEGER :: sphum, liq_wat, rainwat, snowwat, graupel, ice_wat, &
1742 IF (
PRESENT(k_bot))
THEN 1743 IF (k_bot .LT. 3)
THEN 1751 IF (pe(is, 1, js) .LT. 2.)
THEN 1756 IF (km .GT. 24)
THEN 1761 IF (k_bot .LT. min1)
THEN 1770 IF (nwat .EQ. 0)
THEN 1777 IF (nwat .EQ. 3)
THEN 1799 q0(i, k, iq) = qa(i, j, k, iq)
1805 t0(i, k) = ta(i, j, k)
1806 tvm(i, k) = t0(i, k)*(1.+xvir*q0(i, k, sphum))
1807 u0(i, k) = ua(i, j, k)
1808 v0(i, k) = va(i, j, k)
1809 pm(i, k) = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
1815 IF (hydrostatic)
THEN 1818 tv =
rdgas*tvm(i, k)
1819 den(i, k) = pm(i, k)/tv
1820 gz(i, k) = gzh(i) + tv*(1.-pe(i, k, j)/pm(i, k))
1821 hd(i, k) =
cp_air*tvm(i, k) + gz(i, k) + 0.5*(u0(i, k)**2+v0&
1823 gzh(i) = gzh(i) + tv*(peln(i, k+1, j)-peln(i, k, j))
1828 IF (nwat .EQ. 0)
THEN 1833 ELSE IF (nwat .EQ. 1)
THEN 1835 cpm(i) = (1.-q0(i, k, sphum))*
cp_air + q0(i, k, sphum)*&
1837 cvm(i) = (1.-q0(i, k, sphum))*cv_air + q0(i, k, sphum)*&
1840 ELSE IF (nwat .EQ. 2)
THEN 1843 cpm(i) = (1.-q0(i, k, sphum))*
cp_air + q0(i, k, sphum)*&
1845 cvm(i) = (1.-q0(i, k, sphum))*cv_air + q0(i, k, sphum)*&
1848 ELSE IF (nwat .EQ. 3)
THEN 1850 q_liq = q0(i, k, liq_wat)
1851 q_sol = q0(i, k, ice_wat)
1852 cpm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*
cp_air + q0(i&
1854 cvm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*cv_air + q0(i&
1857 ELSE IF (nwat .EQ. 4)
THEN 1859 q_liq = q0(i, k, liq_wat) + q0(i, k, rainwat)
1860 cpm(i) = (1.-(q0(i, k, sphum)+q_liq))*
cp_air + q0(i, k, &
1862 cvm(i) = (1.-(q0(i, k, sphum)+q_liq))*cv_air + q0(i, k, &
1867 q_liq = q0(i, k, liq_wat) + q0(i, k, rainwat)
1868 q_sol = q0(i, k, ice_wat) + q0(i, k, snowwat) + q0(i, k, &
1870 cpm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*
cp_air + q0(i&
1872 cvm(i) = (1.-(q0(i, k, sphum)+q_liq+q_sol))*cv_air + q0(i&
1877 den(i, k) = -(delp(i, j, k)/(
grav*delz(i, j, k)))
1878 w0(i, k) = w(i, j, k)
1879 gz(i, k) = gzh(i) - g2*delz(i, j, k)
1880 tmp = gz(i, k) + 0.5*(u0(i, k)**2+v0(i, k)**2+w0(i, k)**2)
1881 hd(i, k) = cpm(i)*t0(i, k) + tmp
1882 te(i, k) = cvm(i)*t0(i, k) + tmp
1883 gzh(i) = gzh(i) -
grav*delz(i, j, k)
1889 IF (n .EQ. 1) ratio = 0.25
1890 IF (n .EQ. 2) ratio = 0.5
1891 IF (n .EQ. 3) ratio = 0.999
1893 ratio =
REAL(n)/
REAL(m)
1899 IF (nwat .LT. 2)
THEN 1905 ELSE IF (nwat .EQ. 2)
THEN 1909 qcon(i, k) = q0(i, k, liq_wat)
1912 ELSE IF (nwat .EQ. 3)
THEN 1915 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, ice_wat)
1918 ELSE IF (nwat .EQ. 4)
THEN 1921 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, rainwat)
1927 qcon(i, k) = q0(i, k, liq_wat) + q0(i, k, ice_wat) + q0(i&
1928 & , k, snowwat) + q0(i, k, rainwat) + q0(i, k, graupel)
1937 tv1 = t0(i, km1)*(1.+xvir*q0(i, km1, sphum)-qcon(i, km1))
1938 tv2 = t0(i, k)*(1.+xvir*q0(i, k, sphum)-qcon(i, k))
1939 pt1 = tv1/pkz(i, j, km1)
1940 pt2 = tv2/pkz(i, j, k)
1942 ri = (gz(i, km1)-gz(i, k))*(pt1-pt2)/(0.5*(pt1+pt2)*((u0(i, &
1943 & km1)-u0(i, k))**2+(v0(i, km1)-v0(i, k))**2+ustar2))
1944 IF (tv1 .GT. t_max .AND. tv1 .GT. tv2)
THEN 1947 ELSE IF (tv2 .LT. t_min)
THEN 1948 IF (ri .GT. 0.2)
THEN 1954 IF (400.e2 - pm(i, k) .LT. 0.)
THEN 1957 max2 = 400.e2 - pm(i, k)
1968 ELSE IF (k .EQ. 3)
THEN 1970 ELSE IF (k .EQ. 4)
THEN 1973 IF (ri .LT. ri_ref)
THEN 1974 IF (0.0 .LT. ri/ri_ref)
THEN 1979 mc = ratio*delp(i, j, km1)*delp(i, j, k)/(delp(i, j, km1)+&
1980 & delp(i, j, k))*(1.-max1)**2
1982 h0 = mc*(q0(i, k, iq)-q0(i, km1, iq))
1983 q0(i, km1, iq) = q0(i, km1, iq) + h0/delp(i, j, km1)
1984 q0(i, k, iq) = q0(i, k, iq) - h0/delp(i, j, k)
1987 IF (nwat .LT. 2)
THEN 1989 ELSE IF (nwat .EQ. 2)
THEN 1991 qcon(i, km1) = q0(i, km1, liq_wat)
1992 ELSE IF (nwat .EQ. 3)
THEN 1994 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, ice_wat)
1995 ELSE IF (nwat .EQ. 4)
THEN 1997 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, rainwat)
1999 qcon(i, km1) = q0(i, km1, liq_wat) + q0(i, km1, ice_wat)&
2000 & + q0(i, km1, snowwat) + q0(i, km1, rainwat) + q0(i, &
2004 h0 = mc*(u0(i, k)-u0(i, k-1))
2005 u0(i, k-1) = u0(i, k-1) + h0/delp(i, j, k-1)
2006 u0(i, k) = u0(i, k) - h0/delp(i, j, k)
2008 h0 = mc*(v0(i, k)-v0(i, k-1))
2009 v0(i, k-1) = v0(i, k-1) + h0/delp(i, j, k-1)
2010 v0(i, k) = v0(i, k) - h0/delp(i, j, k)
2011 IF (hydrostatic)
THEN 2013 h0 = mc*(hd(i, k)-hd(i, k-1))
2014 hd(i, k-1) = hd(i, k-1) + h0/delp(i, j, k-1)
2015 hd(i, k) = hd(i, k) - h0/delp(i, j, k)
2018 h0 = mc*(hd(i, k)-hd(i, k-1))
2019 te(i, k-1) = te(i, k-1) + h0/delp(i, j, k-1)
2020 te(i, k) = te(i, k) - h0/delp(i, j, k)
2022 h0 = mc*(w0(i, k)-w0(i, k-1))
2023 w0(i, k-1) = w0(i, k-1) + h0/delp(i, j, k-1)
2024 w0(i, k) = w0(i, k) - h0/delp(i, j, k)
2031 IF (hydrostatic)
THEN 2034 t0(i, kk) = (hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, kk)&
2035 & **2))/(rk-pe(i, kk, j)/pm(i, kk))
2036 gzh(i) = gzh(i) + t0(i, kk)*(peln(i, kk+1, j)-peln(i, kk, &
2038 t0(i, kk) = t0(i, kk)/(
rdgas+rz*q0(i, kk, sphum))
2042 t0(i, kk) = (hd(i, kk)-gzh(i)-0.5*(u0(i, kk)**2+v0(i, kk)&
2043 & **2))/((rk-pe(i, kk, j)/pm(i, kk))*(
rdgas+rz*q0(i, kk, &
2049 IF (nwat .EQ. 0)
THEN 2054 ELSE IF (nwat .EQ. 1)
THEN 2056 cpm(i) = (1.-q0(i, kk, sphum))*
cp_air + q0(i, kk, &
2058 cvm(i) = (1.-q0(i, kk, sphum))*cv_air + q0(i, kk, &
2061 ELSE IF (nwat .EQ. 2)
THEN 2063 cpm(i) = (1.-q0(i, kk, sphum))*
cp_air + q0(i, kk, &
2065 cvm(i) = (1.-q0(i, kk, sphum))*cv_air + q0(i, kk, &
2068 ELSE IF (nwat .EQ. 3)
THEN 2070 q_liq = q0(i, kk, liq_wat)
2071 q_sol = q0(i, kk, ice_wat)
2072 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*
cp_air + &
2075 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*cv_air + &
2078 ELSE IF (nwat .EQ. 4)
THEN 2080 q_liq = q0(i, kk, liq_wat) + q0(i, kk, rainwat)
2081 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq))*
cp_air + q0(i, &
2083 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq))*cv_air + q0(i, &
2088 q_liq = q0(i, kk, liq_wat) + q0(i, kk, rainwat)
2089 q_sol = q0(i, kk, ice_wat) + q0(i, kk, snowwat) + q0(i&
2091 cpm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*
cp_air + &
2094 cvm(i) = (1.-(q0(i, kk, sphum)+q_liq+q_sol))*cv_air + &
2099 tv = gz(i, kk) + 0.5*(u0(i, kk)**2+v0(i, kk)**2+w0(i, kk&
2101 t0(i, kk) = (te(i, kk)-tv)/cvm(i)
2102 hd(i, kk) = cpm(i)*t0(i, kk) + tv
2111 IF (fra .LT. 1.)
THEN 2114 t0(i, k) = ta(i, j, k) + (t0(i, k)-ta(i, j, k))*fra
2115 u0(i, k) = ua(i, j, k) + (u0(i, k)-ua(i, j, k))*fra
2116 v0(i, k) = va(i, j, k) + (v0(i, k)-va(i, j, k))*fra
2119 IF (.NOT.hydrostatic)
THEN 2122 w0(i, k) = w(i, j, k) + (w0(i, k)-w(i, j, k))*fra
2129 q0(i, k, iq) = qa(i, j, k, iq) + (q0(i, k, iq)-qa(i, j, k&
2137 u_dt(i, j, k) = rdt*(u0(i, k)-ua(i, j, k))
2138 v_dt(i, j, k) = rdt*(v0(i, k)-va(i, j, k))
2140 ta(i, j, k) = t0(i, k)
2141 ua(i, j, k) = u0(i, k)
2142 va(i, j, k) = v0(i, k)
2146 qa(i, j, k, iq) = q0(i, k, iq)
2150 IF (.NOT.hydrostatic)
THEN 2154 w(i, j, k) = w0(i, k)
2160 SUBROUTINE neg_adj3(is, ie, js, je, ng, kbot, hydrostatic, peln, delz&
2161 & , pt, dp, qv, ql, qr, qi, qs, qg, qa, check_negative)
2165 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, kbot
2166 LOGICAL,
INTENT(IN) :: hydrostatic
2168 REAL,
INTENT(IN) :: dp(is-ng:ie+ng, js-ng:je+ng, kbot)
2169 REAL,
INTENT(IN) :: delz(is-ng:, js-ng:, :)
2171 REAL,
INTENT(IN) :: peln(is:ie, kbot+1, js:je)
2172 LOGICAL,
INTENT(IN),
OPTIONAL :: check_negative
2173 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, kbot),
INTENT(INOUT) :: pt&
2174 & , qv, ql, qr, qi, qs, qg
2175 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, kbot),
INTENT(INOUT), &
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 wqs2(ta, den, dqdt)
integer, parameter, public model_atmos
real, parameter, public hlv
Latent heat of evaporation [J/kg].
subroutine, public pushcontrol(ctype, field)
real, parameter, public rdgas
Gas constant for dry air [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, k_bot)
real, parameter, public cp_vapor
Specific heat capacity of water vapor at constant pressure [J/kg/deg].
subroutine, public fv_subgrid_z_fwd(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, k_bot)
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].
real, dimension(:), allocatable des
real, parameter, public hlf
Latent heat of fusion [J/kg].
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public fv_subgrid_z_bwd(isd, ied, jsd, jed, is, ie, js, je, km, nq, dt, tau, nwat, delp, delp_ad, pe, pe_ad, peln, peln_ad, pkz, pkz_ad, ta, ta_ad, qa, qa_ad, ua, ua_ad, va, va_ad, hydrostatic, w, w_ad, delz, delz_ad, u_dt, v_dt, t_dt, k_bot)
real, dimension(:), allocatable table
real function, public wqsat2_moist(ta, qv, pa, dqdt)
real, parameter, public kappa
RDGAS / CP_AIR [dimensionless].
subroutine, public popcontrol(ctype, field)