41 real,
parameter::
r2=1./2.,
r0=0.0
42 real,
parameter::
r3 = 1./3.,
r23 = 2./3.,
r12 = 1./12.
47 real,
parameter::
c_liq = 4.1855e+3
50 real,
parameter::
tice = 273.16
61 mdt, pdt, km, is,ie,js,je, isd,ied,jsd,jed, &
62 nq, nwat, sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, &
63 akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, &
64 ng, ua, va, omga, te, ws, fill, reproduce_sum, out_dt, dtdt, &
65 ptop, ak, bk, pfull, flagstruct, gridstruct, domain, do_sat_adj, &
66 hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init, &
67 mfx, mfy, remap_option)
68 logical,
intent(in):: last_step
69 real,
intent(in):: mdt
70 real,
intent(in):: pdt
71 integer,
intent(in):: km
72 integer,
intent(in):: nq
73 integer,
intent(in):: nwat
74 integer,
intent(in):: sphum
75 integer,
intent(in):: ng
76 integer,
intent(in):: is,ie,isd,ied
77 integer,
intent(in):: js,je,jsd,jed
78 integer,
intent(in):: kord_mt
79 integer,
intent(in):: kord_wz
80 integer,
intent(in):: kord_tr(nq)
81 integer,
intent(in):: kord_tm
83 real,
intent(in):: consv
84 real,
intent(in):: r_vir
86 real,
intent(in):: akap
87 real,
intent(in):: hs(isd:ied,jsd:jed)
88 real,
intent(inout):: te0_2d(is:ie,js:je)
89 real,
intent(in):: ws(is:ie,js:je)
91 logical,
intent(in):: do_sat_adj
92 logical,
intent(in):: fill
93 logical,
intent(in):: reproduce_sum
94 logical,
intent(in):: do_omega, adiabatic, do_adiabatic_init
95 real,
intent(in) :: ptop
96 real,
intent(in) :: ak(km+1)
97 real,
intent(in) :: bk(km+1)
98 real,
intent(in):: pfull(km)
101 type(
domain2d),
intent(INOUT) :: domain
104 real,
intent(inout):: pk(is:ie,js:je,km+1)
105 real,
intent(inout):: q(isd:ied,jsd:jed,km,*)
106 real,
intent(inout):: delp(isd:ied,jsd:jed,km)
107 real,
intent(inout):: pe(is-1:ie+1,km+1,js-1:je+1)
108 real,
intent(inout):: ps(isd:ied,jsd:jed)
111 real,
intent(inout):: u(isd:ied ,jsd:jed+1,km)
112 real,
intent(inout):: v(isd:ied+1,jsd:jed ,km)
113 real,
intent(inout):: w(isd: ,jsd: ,1:)
114 real,
intent(inout):: pt(isd:ied ,jsd:jed ,km)
116 real,
intent(inout),
dimension(isd:,jsd:,1:)::delz, q_con, cappa
117 logical,
intent(in):: hydrostatic
118 logical,
intent(in):: hybrid_z
119 logical,
intent(in):: out_dt
121 real,
intent(inout):: ua(isd:ied,jsd:jed,km)
122 real,
intent(inout):: va(isd:ied,jsd:jed,km)
123 real,
intent(inout):: omga(isd:ied,jsd:jed,km)
124 real,
intent(inout):: peln(is:ie,km+1,js:je)
125 real,
intent(inout):: dtdt(is:,js:,1:)
126 real,
intent(out):: pkz(is:ie,js:je,km)
127 real,
intent(out):: te(isd:ied,jsd:jed,km)
129 real,
optional,
intent(inout):: mfx(is:ie+1,js:je ,km)
130 real,
optional,
intent(inout):: mfy(is:ie ,js:je+1,km)
131 integer,
intent(in):: remap_option
141 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1, dpln
142 real,
dimension(is:ie,km) :: q2, dp2
143 real,
dimension(is:ie,km+1):: pe1, pe2, pk1, pk2, pn2, phis
144 real,
dimension(is:ie+1,km+1):: pe0, pe3
145 real,
dimension(is:ie):: gz, cvm, qv
146 real rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
147 logical:: fast_mp_consv
149 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, iq, n, kmp, kp, k_next
150 logical:: remap_t, remap_pt, remap_te
155 select case (remap_option)
163 print*,
' INVALID REMAPPING OPTION ' 167 if (is_master() .and. flagstruct%fv_debug)
then 169 select case (remap_option)
171 print*,
' REMAPPING T in logP ' 173 print*,
' REMAPPING PT in P' 175 print*,
' REMAPPING TE in logP with GMAO cubic' 177 print*,
' REMAPPING CONSV: ', consv
178 print*,
' REMAPPING CONSV_MIN: ',
consv_min 182 if ( flagstruct%fv_debug )
then 207 if ( do_sat_adj )
then 208 fast_mp_consv = (.not.do_adiabatic_init) .and. consv>
consv_min 211 if ( pfull(k) > 10.e2 )
exit 234 pe2(i,km+1) = pe(i,km+1,j)
237 if ( j /= (je+1) )
then 242 if ( hydrostatic )
then 246 pt(i,j,k) = pt(i,j,k)*(pk(i,j,k+1)-pk(i,j,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
255 qv(i) =
max(0., q(i,j,k,sphum))
256 q_con(i,j,k) =
max(0., q(i,j,k,liq_wat))
258 cappa(i,j,k) =
rdgas / (
rdgas + cvm(i)/(1.+r_vir*qv(i)) )
259 pt(i,j,k) = pt(i,j,k)*exp(cappa(i,j,k)/(1.-cappa(i,j,k))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
262 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
263 ice_wat, snowwat, graupel, q, gz, cvm)
266 cappa(i,j,k) =
rdgas / (
rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
267 pt(i,j,k) = pt(i,j,k)*exp(cappa(i,j,k)/(1.-cappa(i,j,k))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
272 pt(i,j,k) = pt(i,j,k)*exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
280 elseif (remap_pt)
then 283 elseif (remap_te)
then 286 call pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, ptop)
290 te(i,j,k) = 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
291 v(i,j,k)**2+v(i+1,j,k)**2 - &
292 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)) &
293 +
cp_air*pt(i,j,k)*pkz(i,j,k)
298 if ( .not. hydrostatic )
then 301 delz(i,j,k) = -delz(i,j,k) / delp(i,j,k)
308 ps(i,j) = pe1(i,km+1)
315 pe2(i,k) = ak(k) + bk(k)*pe(i,km+1,j)
320 dp2(i,k) = pe2(i,k+1) - pe2(i,k)
329 delp(i,j,k) = dp2(i,k)
343 pn2(i, 1) = peln(i, 1,j)
344 pn2(i,km+1) = peln(i,km+1,j)
345 pk2(i, 1) = pk1(i, 1)
346 pk2(i,km+1) = pk1(i,km+1)
351 pn2(i,k) = log(pe2(i,k))
352 pk2(i,k) = exp(akap*pn2(i,k))
362 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm),
t_min)
363 elseif (remap_pt)
then 369 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
370 elseif (remap_te)
then 375 phis(i,km+1) = hs(i,j)
379 phis(i,k) = phis(i,k+1) +
cp_air*pt(i,j,k)*(pk1(i,k+1)-pk1(i,k))
384 phis(i,k) = phis(i,k) * pe1(i,k)
389 te(i,j,k) = te(i,j,k)+(phis(i,k+1)-phis(i,k))/(pe1(i,k+1)-pe1(i,k))
395 is, ie, j, isd, ied, jsd, jed, akap, t_var=1, conserv=.true.)
402 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
403 is, ie, isd, ied, jsd, jed, 0., fill)
404 elseif ( nq > 0 )
then 407 call map1_q2(km, pe1, q(isd,jsd,1,iq), &
409 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
410 if (fill)
call fillz(ie-is+1, km, 1, q2, dp2)
413 q(i,j,k,iq) = q2(i,k)
419 if ( .not. hydrostatic )
then 421 call map1_ppm (km, pe1, w, ws(is,j), &
423 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
427 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
430 delz(i,j,k) = -delz(i,j,k)*dp2(i,k)
453 pe3(i,k) = omga(i,j,k-1)
460 pe0(i,k) = peln(i,k,j)
461 peln(i,k,j) = pn2(i,k)
468 if ( hydrostatic )
then 471 pkz(i,j,k) = (pk2(i,k+1)-pk2(i,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
477 print*,
'TE remapping non-hydrostatic is invalid and cannot be run' 486 qv(i) =
max(0., q(i,j,k,sphum))
487 q_con(i,j,k) =
max(0., q(i,j,k,liq_wat))
489 cappa(i,j,k) =
rdgas / (
rdgas + cvm(i)/(1.+r_vir*qv(i)) )
490 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
493 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
494 ice_wat, snowwat, graupel, q, gz, cvm)
497 cappa(i,j,k) =
rdgas / (
rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
498 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
503 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
513 pkz(i,j,k) = exp( k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)) )
523 dp2(i,k) = 0.5*(peln(i,k,j) + peln(i,k+1,j))
531 if( dp2(i,n) <= pe0(i,k+1) .and. dp2(i,n) >= pe0(i,k) )
then 532 omga(i,j,n) = pe3(i,k) + (pe3(i,k+1) - pe3(i,k)) * &
533 (dp2(i,n)-pe0(i,k)) / (pe0(i,k+1)-pe0(i,k) )
552 pe0(i,k) = 0.5*(pe(i,k,j-1)+pe1(i,k))
559 pe3(i,k) = ak(k) + bkh*(pe(i,km+1,j-1)+pe1(i,km+1))
563 call map1_ppm( km, pe0(is:ie,:), u, gz, &
564 km, pe3(is:ie,:), u, &
565 is, ie, j, isd, ied, jsd, jed+1, -1, kord_mt)
566 if (
present(mfy))
then 567 call map1_ppm( km, pe0(is:ie,:), mfy, gz, &
568 km, pe3(is:ie,:), mfy, &
569 is, ie, j, is, ie, js, je+1, -1, kord_mt)
583 pe0(i,k) = 0.5*(pe(i-1,k, j)+pe(i,k, j))
584 pe3(i,k) = ak(k) + bkh*(pe(i-1,km+1,j)+pe(i,km+1,j))
589 km, pe3, v, is, ie+1, &
590 j, isd, ied+1, jsd, jed, -1, kord_mt)
591 if (
present(mfx))
then 593 km, pe3, mfx, is, ie+1, &
594 j, is, ie+1, js, je, -1, kord_mt)
600 ua(i,j,k) = pe2(i,k+1)
620 pe(i,k,j) = ua(i,j,k-1)
625 if ( flagstruct%fv_debug )
then 626 if (kord_tm < 0)
then 634 if( last_step .and. (.not.do_adiabatic_init) )
then 641 if ( hydrostatic )
then 645 gz(i) = gz(i) + rg*pt(i,j,k)*(peln(i,k+1,j)-peln(i,k,j))
649 te_2d(i,j) = pe(i,km+1,j)*hs(i,j) - pe(i,1,j)*gz(i)
654 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*pt(i,j,k) + &
655 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
656 v(i,j,k)**2+v(i+1,j,k)**2 - &
657 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)))
663 phis(i,km+1) = hs(i,j)
667 phis(i,k) = phis(i,k+1) -
grav*delz(i,j,k)
675 qv(i) =
max(0., q(i,j,k,sphum))
676 gz(i) =
max(0., q(i,j,k,liq_wat))
680 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
681 ice_wat, snowwat, graupel, q, gz, cvm)
686 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cvm(i)*pt(i,j,k)/((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i))) + &
687 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
688 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
689 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
693 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k)/(1.+r_vir*q(i,j,k,sphum)) + &
694 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
695 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
696 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
701 elseif (remap_pt)
then 702 if ( hydrostatic )
then 706 gz(i) = gz(i) +
cp_air*pt(i,j,k)*(pk(i,j,k+1)-pk(i,j,k))
711 te_2d(i,j) = pe(i,km+1,j)*hs(i,j) - pe(i,1,j)*gz(i)
715 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cp_air*pt(i,j,k)*pkz(i,j,k) + &
716 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
717 v(i,j,k)**2+v(i+1,j,k)**2 - &
718 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)))
726 phis(i,km+1) = hs(i,j)
728 phis(i,k) = phis(i,k+1) -
grav*delz(i,j,k)
736 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k)/(1.+r_vir*q(i,j,k,sphum)) + &
737 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
738 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
739 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
743 elseif (remap_te)
then 745 te_2d(i,j) = te(i,j,1)*delp(i,j,1)
749 te_2d(i,j) = te_2d(i,j) + te(i,j,k)*delp(i,j,k)
755 te_2d(i,j) = te0_2d(i,j) - te_2d(i,j)
756 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
760 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
763 if ( hydrostatic )
then 765 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
772 tpe = consv*
g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.)
775 if ( hydrostatic )
then 776 dtmp = tpe / (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
778 dtmp = tpe / (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
787 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
791 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
794 if ( hydrostatic )
then 796 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
803 if ( hydrostatic )
then 805 (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
808 (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
815 if ( remap_t .and. (.not.do_adiabatic_init) .and. do_sat_adj )
then 822 dpln(i,j) = peln(i,k+1,j) - peln(i,k,j)
825 call fv_sat_adj(abs(mdt), r_vir, is, ie, js, je, ng, hydrostatic, fast_mp_consv, &
826 te(isd,jsd,k), q(isd,jsd,k,sphum), q(isd,jsd,k,liq_wat), &
827 q(isd,jsd,k,ice_wat), q(isd,jsd,k,rainwat), &
828 q(isd,jsd,k,snowwat), q(isd,jsd,k,graupel), &
829 dpln, delz(isd:,jsd:,k), pt(isd,jsd,k), delp(isd,jsd,k), q_con(isd:,jsd:,k), &
830 cappa(isd:,jsd:,k), gridstruct%area_64, dtdt(is:,js:,k), out_dt, last_step, cld_amt>0, q(isd,jsd,k,cld_amt))
831 if ( .not. hydrostatic )
then 835 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
837 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
844 if ( fast_mp_consv )
then 849 te0_2d(i,j) = te0_2d(i,j) + te(i,j,k)
857 if ( last_step )
then 866 gz(i) =
max(0., q(i,j,k,liq_wat))
867 qv(i) =
max(0., q(i,j,k,sphum))
868 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*qv(i))*(1.-gz(i)))
870 elseif ( nwat==6 )
then 872 gz(i) = q(i,j,k,liq_wat)+q(i,j,k,rainwat)+q(i,j,k,ice_wat)+q(i,j,k,snowwat)+q(i,j,k,graupel)
873 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
876 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
877 ice_wat, snowwat, graupel, q, gz, cvm)
879 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
883 if ( .not. adiabatic )
then 885 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / (1.+r_vir*q(i,j,k,sphum))
891 elseif (remap_pt)
then 896 pt(i,j,k) = (pt(i,j,k) + dtmp)*pkz(i,j,k)/(1.+r_vir*q(i,j,k,sphum))
900 elseif (remap_te)
then 908 tpe = te(i,j,k) - gz(i) - 0.25*gridstruct%rsin2(i,j)*( &
909 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
910 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j) )
911 dlnp = rg*(peln(i,k+1,j) - peln(i,k,j))
912 tmp = tpe / ((cp - pe(i,k,j)*dlnp/delp(i,j,k))*(1.+r_vir*q(i,j,k,sphum)) )
913 pt(i,j,k) = tmp + dtmp*pkz(i,j,k) / (1.+r_vir*q(i,j,k,sphum))
914 gz(i) = gz(i) + dlnp*tmp*(1.+r_vir*q(i,j,k,sphum))
919 if ( flagstruct%fv_debug )
then 928 pt(i,j,k) = pt(i,j,k)/pkz(i,j,k)
932 elseif (remap_te)
then 940 tpe = te(i,j,k) - gz(i) - 0.25*gridstruct%rsin2(i,j)*( &
941 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
942 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j) )
943 dlnp = rg*(peln(i,k+1,j) - peln(i,k,j))
944 tmp = tpe / (cp - pe(i,k,j)*dlnp/delp(i,j,k))
945 pt(i,j,k) = (tmp/pkz(i,j,k) + dtmp)
946 gz(i) = gz(i) + dlnp*tmp
951 if ( flagstruct%fv_debug )
then 961 u, v, w, delz, pt, delp, q, qc, pe, peln, hs, &
963 r_vir, cp, rg, hlv, te_2d, ua, va, teq, &
964 moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
969 integer,
intent(in):: km, is, ie, js, je, isd, ied, jsd, jed, id_te
970 integer,
intent(in):: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, nwat
971 real,
intent(inout),
dimension(isd:ied,jsd:jed,km):: ua, va
972 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: pt, delp
973 real,
intent(in),
dimension(isd:ied,jsd:jed,km,*):: q
974 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: qc
975 real,
intent(inout):: u(isd:ied, jsd:jed+1,km)
976 real,
intent(inout):: v(isd:ied+1,jsd:jed, km)
977 real,
intent(in):: w(isd:,jsd:,1:)
978 real,
intent(in):: delz(isd:,jsd:,1:)
979 real,
intent(in):: hs(isd:ied,jsd:jed)
980 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
981 real,
intent(in):: peln(is:ie,km+1,js:je)
982 real,
intent(in):: cp, rg, r_vir,
hlv 983 real,
intent(in) :: rsin2_l(isd:ied, jsd:jed)
984 real,
intent(in) :: cosa_s_l(isd:ied, jsd:jed)
985 logical,
intent(in):: moist_phys, hydrostatic
987 real,
intent(out):: te_2d(is:ie,js:je)
988 real,
intent(out):: teq(is:ie,js:je)
990 real,
dimension(is:ie,km):: tv
991 real phiz(is:ie,km+1)
992 real cvm(is:ie), qd(is:ie)
1006 if ( hydrostatic )
then 1009 phiz(i,km+1) = hs(i,j)
1013 tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))
1014 phiz(i,k) = phiz(i,k+1) + rg*tv(i,k)*(peln(i,k+1,j)-peln(i,k,j))
1019 te_2d(i,j) = pe(i,km+1,j)*phiz(i,km+1) - pe(i,1,j)*phiz(i,1)
1024 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*tv(i,k) + &
1025 0.25*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1026 v(i,j,k)**2+v(i+1,j,k)**2 - &
1027 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j)))
1036 phiz(i,km+1) = hs(i,j)
1038 phiz(i,k) = phiz(i,k+1) -
grav*delz(i,j,k)
1044 if ( moist_phys )
then 1047 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
1048 ice_wat, snowwat, graupel, q, qd, cvm)
1052 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*( cvm(i)*pt(i,j,k) + &
1054 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1056 0.5*(phiz(i,k)+phiz(i,k+1)+w(i,j,k)**2+0.5*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1057 v(i,j,k)**2+v(i+1,j,k)**2-(u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j))))
1063 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1064 0.5*(phiz(i,k)+phiz(i,k+1)+w(i,j,k)**2+0.5*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1065 v(i,j,k)**2+v(i+1,j,k)**2-(u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j))))
1079 teq(i,j) = te_2d(i,j)
1081 if ( moist_phys )
then 1084 teq(i,j) = teq(i,j) +
hlv*q(i,j,k,sphum)*delp(i,j,k)
1094 subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, &
1095 pe, pk, akap, peln, pkz, ptop)
1098 integer,
intent(in):: km, j
1099 integer,
intent(in):: ifirst, ilast
1100 integer,
intent(in):: jfirst, jlast
1101 real,
intent(in):: akap
1102 real,
intent(in):: pe(ifirst-1:ilast+1,km+1,jfirst-1:jlast+1)
1103 real,
intent(in):: pk(ifirst:ilast,jfirst:jlast,km+1)
1104 real,
intent(IN):: ptop
1106 real,
intent(out):: pkz(ifirst:ilast,jfirst:jlast,km)
1107 real,
intent(inout):: peln(ifirst:ilast, km+1, jfirst:jlast)
1109 real pk2(ifirst:ilast, km+1)
1115 ak1 = (akap + 1.) / akap
1117 pek = pk(ifirst,j,1)
1125 pk2(i,k) = pk(i,j,k)
1132 peln(i,1,j) = peln(i,2,j) - ak1
1144 pkz(i,j,k) = (pk2(i,k+1) - pk2(i,k) ) / &
1145 (akap*(peln(i,k+1,j) - peln(i,k,j)) )
1153 subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
1156 integer,
intent(in) :: i1
1157 integer,
intent(in) :: i2
1158 integer,
intent(in) :: kord
1159 integer,
intent(in) :: km
1160 integer,
intent(in) :: kn
1161 integer,
intent(in) :: iv
1163 real,
intent(in) :: pe1(i1:i2,km+1)
1165 real,
intent(in) :: pe2(i1:i2,kn+1)
1167 real,
intent(in) :: q1(i1:i2,km)
1170 real,
intent(inout):: q2(i1:i2,kn)
1176 real pl, pr, qsum, delp, esl
1177 integer i, k, l, m, k0
1181 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1188 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1199 if(pe2(i,k) <= pe1(i,l) .and. pe2(i,k) >= pe1(i,l+1))
then 1200 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1201 if(pe2(i,k+1) >= pe1(i,l+1))
then 1203 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1204 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1205 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1210 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1211 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1212 (
r3*(1.+pl*(1.+pl))))
1215 if(pe2(i,k+1) < pe1(i,m+1) )
then 1217 qsum = qsum + dp1(i,m)*q4(1,i,m)
1219 delp = pe2(i,k+1)-pe1(i,m)
1220 esl = delp / dp1(i,m)
1221 qsum = qsum + delp*(q4(2,i,m)+0.5*esl* &
1222 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1231 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1238 kn, pe2, q2, i1, i2, &
1239 j, ibeg, iend, jbeg, jend, iv, kord, q_min)
1241 integer,
intent(in) :: i1
1242 integer,
intent(in) :: i2
1243 integer,
intent(in) :: iv
1245 integer,
intent(in) :: kord
1246 integer,
intent(in) :: j
1247 integer,
intent(in) :: ibeg, iend, jbeg, jend
1248 integer,
intent(in) :: km
1249 integer,
intent(in) :: kn
1250 real,
intent(in) :: qs(i1:i2)
1251 real,
intent(in) :: pe1(i1:i2,km+1)
1254 real,
intent(in) :: pe2(i1:i2,kn+1)
1257 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1259 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1260 real,
intent(in):: q_min
1271 real pl, pr, qsum, dp, esl
1272 integer i, k, l, m, k0
1276 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1277 q4(1,i,k) = q1(i,j,k)
1293 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1294 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1295 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1297 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1298 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1299 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1304 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1305 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1306 (
r3*(1.+pl*(1.+pl))))
1309 if( pe2(i,k+1) > pe1(i,m+1) )
then 1311 qsum = qsum + dp1(i,m)*q4(1,i,m)
1313 dp = pe2(i,k+1)-pe1(i,m)
1315 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1316 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1325 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1332 subroutine map1_ppm( km, pe1, q1, qs, &
1333 kn, pe2, q2, i1, i2, &
1334 j, ibeg, iend, jbeg, jend, iv, kord)
1335 integer,
intent(in) :: i1
1336 integer,
intent(in) :: i2
1337 integer,
intent(in) :: iv
1339 integer,
intent(in) :: kord
1340 integer,
intent(in) :: j
1341 integer,
intent(in) :: ibeg, iend, jbeg, jend
1342 integer,
intent(in) :: km
1343 integer,
intent(in) :: kn
1344 real,
intent(in) :: qs(i1:i2)
1345 real,
intent(in) :: pe1(i1:i2,km+1)
1348 real,
intent(in) :: pe2(i1:i2,kn+1)
1351 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1353 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1364 real pl, pr, qsum, dp, esl
1365 integer i, k, l, m, k0
1369 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1370 q4(1,i,k) = q1(i,j,k)
1376 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1386 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1387 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1388 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1390 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1391 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1392 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1397 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1398 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1399 (
r3*(1.+pl*(1.+pl))))
1402 if( pe2(i,k+1) > pe1(i,m+1) )
then 1404 qsum = qsum + dp1(i,m)*q4(1,i,m)
1406 dp = pe2(i,k+1)-pe1(i,m)
1408 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1409 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1418 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1425 subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, &
1426 i1, i2, isd, ied, jsd, jed, q_min, fill)
1428 integer,
intent(in):: km
1429 integer,
intent(in):: j, nq, i1, i2
1430 integer,
intent(in):: isd, ied, jsd, jed
1431 integer,
intent(in):: kord(nq)
1432 real,
intent(in):: pe1(i1:i2,km+1)
1435 real,
intent(in):: pe2(i1:i2,km+1)
1438 real,
intent(in):: dp2(i1:i2,km)
1439 real,
intent(in):: q_min
1440 logical,
intent(in):: fill
1441 real,
intent(inout):: q1(isd:ied,jsd:jed,km,nq)
1443 real:: q4(4,i1:i2,km,nq)
1444 real:: q2(i1:i2,km,nq)
1446 real:: dp1(i1:i2,km)
1448 real:: pl, pr, dp, esl, fac1, fac2
1449 integer:: i, k, l, m, k0, iq
1453 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1460 q4(1,i,k,iq) = q1(i,j,k,iq)
1463 call scalar_profile( qs, q4(1,i1,1,iq), dp1, km, i1, i2, 0, kord(iq), q_min )
1472 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1473 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1474 if(pe2(i,k+1) <= pe1(i,l+1))
then 1476 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1478 fac2 =
r3*(pr*fac1 + pl*pl)
1481 q2(i,k,iq) = q4(2,i,l,iq) + (q4(4,i,l,iq)+q4(3,i,l,iq)-q4(2,i,l,iq))*fac1 &
1488 dp = pe1(i,l+1) - pe2(i,k)
1490 fac2 =
r3*(1.+pl*fac1)
1493 qsum(iq) = dp*(q4(2,i,l,iq) + (q4(4,i,l,iq)+ &
1494 q4(3,i,l,iq) - q4(2,i,l,iq))*fac1 - q4(4,i,l,iq)*fac2)
1498 if(pe2(i,k+1) > pe1(i,m+1) )
then 1501 qsum(iq) = qsum(iq) + dp1(i,m)*q4(1,i,m,iq)
1504 dp = pe2(i,k+1)-pe1(i,m)
1509 qsum(iq) = qsum(iq) + dp*( q4(2,i,m,iq) + fac1*( &
1510 q4(3,i,m,iq)-q4(2,i,m,iq)+q4(4,i,m,iq)*fac2 ) )
1522 q2(i,k,iq) = qsum(iq) / dp2(i,k)
1527 if (fill)
call fillz(i2-i1+1, km, nq, q2, dp2)
1533 q1(i,j,k,iq) = q2(i,k,iq)
1541 subroutine map1_q2(km, pe1, q1, &
1543 i1, i2, iv, kord, j, &
1544 ibeg, iend, jbeg, jend, q_min )
1548 integer,
intent(in) :: j
1549 integer,
intent(in) :: i1, i2
1550 integer,
intent(in) :: ibeg, iend, jbeg, jend
1551 integer,
intent(in) :: iv
1552 integer,
intent(in) :: kord
1553 integer,
intent(in) :: km
1554 integer,
intent(in) :: kn
1556 real,
intent(in) :: pe1(i1:i2,km+1)
1559 real,
intent(in) :: pe2(i1:i2,kn+1)
1562 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1563 real,
intent(in) :: dp2(i1:i2,kn)
1564 real,
intent(in) :: q_min
1566 real,
intent(inout):: q2(i1:i2,kn)
1571 real pl, pr, qsum, dp, esl
1573 integer i, k, l, m, k0
1577 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1578 q4(1,i,k) = q1(i,j,k)
1595 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1596 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1597 if(pe2(i,k+1) <= pe1(i,l+1))
then 1599 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1600 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1601 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1606 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1607 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1608 (
r3*(1.+pl*(1.+pl))))
1611 if(pe2(i,k+1) > pe1(i,m+1) )
then 1613 qsum = qsum + dp1(i,m)*q4(1,i,m)
1615 dp = pe2(i,k+1)-pe1(i,m)
1617 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1618 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1627 123 q2(i,k) = qsum / dp2(i,k)
1638 integer,
intent(in):: i1, i2
1639 integer,
intent(in):: iv
1640 integer,
intent(in):: kord
1641 integer,
intent(in):: km
1642 integer,
intent(in):: kn
1643 real,
intent(in):: pe1(i1:i2,km+1)
1646 real,
intent(in):: pe2(i1:i2,kn+1)
1649 real,
intent(in) :: q1(i1:i2,km)
1650 real,
intent(out):: q2(i1:i2,kn)
1655 real pl, pr, qsum, dp, esl
1656 integer i, k, l, m, k0
1660 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1667 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1676 if( pe2(i,k+1) <= pe1(i,1) )
then 1679 elseif( pe2(i,k) < pe1(i,1) .and. pe2(i,k+1)>pe1(i,1) )
then 1683 if( pe2(i,k) <= pe1(i,1) )
then 1690 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1691 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1692 if(pe2(i,k+1) <= pe1(i,l+1))
then 1694 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1695 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1696 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1701 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1702 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1703 (
r3*(1.+pl*(1.+pl))))
1706 if(pe2(i,k+1) > pe1(i,m+1) )
then 1708 qsum = qsum + dp1(i,m)*q4(1,i,m)
1710 dp = pe2(i,k+1)-pe1(i,m)
1712 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1713 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1722 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1730 subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
1733 integer,
intent(in):: i1, i2
1734 integer,
intent(in):: km
1735 integer,
intent(in):: iv
1738 integer,
intent(in):: kord
1739 real,
intent(in) :: qs(i1:i2)
1740 real,
intent(in) :: delp(i1:i2,km)
1741 real,
intent(inout):: a4(4,i1:i2,km)
1742 real,
intent(in):: qmin
1744 logical,
dimension(i1:i2,km):: extm, ext6
1748 real bet, a_bot, grat
1749 real pmp_1, lac_1, pmp_2, lac_2
1752 if ( iv .eq. -2 )
then 1755 q(i,1) = 1.5*a4(1,i,1)
1759 grat = delp(i,k-1) / delp(i,k)
1760 bet = 2. + grat + grat - gam(i,k)
1761 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
1762 gam(i,k+1) = grat / bet
1766 grat = delp(i,km-1) / delp(i,km)
1767 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
1768 (2. + grat + grat - gam(i,km))
1773 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
1778 grat = delp(i,2) / delp(i,1)
1779 bet = grat*(grat+0.5)
1780 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
1781 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
1786 d4(i) = delp(i,k-1) / delp(i,k)
1787 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
1788 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
1789 gam(i,k) = d4(i) / bet
1794 a_bot = 1. + d4(i)*(d4(i)+1.5)
1795 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
1796 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
1801 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
1807 if ( abs(kord) > 16 )
then 1811 a4(3,i,k) = q(i,k+1)
1812 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1825 q(i,2) =
min( q(i,2),
max(a4(1,i,1), a4(1,i,2)) )
1826 q(i,2) =
max( q(i,2),
min(a4(1,i,1), a4(1,i,2)) )
1831 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
1838 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 1840 q(i,k) =
min( q(i,k),
max(a4(1,i,k-1),a4(1,i,k)) )
1841 q(i,k) =
max( q(i,k),
min(a4(1,i,k-1),a4(1,i,k)) )
1843 if ( gam(i,k-1) > 0. )
then 1845 q(i,k) =
max(q(i,k),
min(a4(1,i,k-1),a4(1,i,k)))
1848 q(i,k) =
min(q(i,k),
max(a4(1,i,k-1),a4(1,i,k)))
1849 if ( iv==0 ) q(i,k) =
max(0., q(i,k))
1857 q(i,km) =
min( q(i,km),
max(a4(1,i,km-1), a4(1,i,km)) )
1858 q(i,km) =
max( q(i,km),
min(a4(1,i,km-1), a4(1,i,km)) )
1864 a4(3,i,k) = q(i,k+1)
1869 if ( k==1 .or. k==km )
then 1871 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
1875 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
1878 if ( abs(kord)==16 )
then 1880 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1881 ext6(i,k) = abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k))
1894 a4(2,i,1) =
max(0., a4(2,i,1))
1896 elseif ( iv==-1 )
then 1898 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
1900 elseif ( iv==2 )
then 1902 a4(2,i,1) = a4(1,i,1)
1903 a4(3,i,1) = a4(1,i,1)
1910 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
1917 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
1925 if ( abs(kord)<9 )
then 1928 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1929 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1930 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
1931 max(a4(1,i,k), pmp_1, lac_1) )
1933 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1934 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1935 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
1936 max(a4(1,i,k), pmp_2, lac_2) )
1938 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1941 elseif ( abs(kord)==9 )
then 1943 if ( extm(i,k) .and. extm(i,k-1) )
then 1945 a4(2,i,k) = a4(1,i,k)
1946 a4(3,i,k) = a4(1,i,k)
1948 else if ( extm(i,k) .and. extm(i,k+1) )
then 1950 a4(2,i,k) = a4(1,i,k)
1951 a4(3,i,k) = a4(1,i,k)
1953 else if ( extm(i,k) .and. a4(1,i,k)<qmin )
then 1955 a4(2,i,k) = a4(1,i,k)
1956 a4(3,i,k) = a4(1,i,k)
1959 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1961 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1962 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1963 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1964 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
1965 max(a4(1,i,k), pmp_1, lac_1) )
1966 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1967 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1968 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
1969 max(a4(1,i,k), pmp_2, lac_2) )
1970 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1974 elseif ( abs(kord)==10 )
then 1976 if( extm(i,k) )
then 1977 if( a4(1,i,k)<qmin .or. extm(i,k-1) .or. extm(i,k+1) )
then 1979 a4(2,i,k) = a4(1,i,k)
1980 a4(3,i,k) = a4(1,i,k)
1984 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
1987 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
1989 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1990 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1991 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1992 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
1993 max(a4(1,i,k), pmp_1, lac_1) )
1994 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1995 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1996 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
1997 max(a4(1,i,k), pmp_2, lac_2) )
1998 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2002 elseif ( abs(kord)==12 )
then 2004 if( extm(i,k) )
then 2005 a4(2,i,k) = a4(1,i,k)
2006 a4(3,i,k) = a4(1,i,k)
2009 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2011 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2012 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2013 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2014 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2015 max(a4(1,i,k), pmp_1, lac_1) )
2016 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2017 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2018 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2019 max(a4(1,i,k), pmp_2, lac_2) )
2020 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2024 elseif ( abs(kord)==13 )
then 2026 if( extm(i,k) )
then 2027 if ( extm(i,k-1) .and. extm(i,k+1) )
then 2029 a4(2,i,k) = a4(1,i,k)
2030 a4(3,i,k) = a4(1,i,k)
2034 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2035 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2036 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2037 max(a4(1,i,k), pmp_1, lac_1) )
2039 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2040 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2041 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2042 max(a4(1,i,k), pmp_2, lac_2) )
2043 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2046 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2049 elseif ( abs(kord)==14 )
then 2051 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2053 elseif ( abs(kord)==16 )
then 2055 if( ext6(i,k) )
then 2056 if ( extm(i,k-1) .or. extm(i,k+1) )
then 2058 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2059 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2060 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2061 max(a4(1,i,k), pmp_1, lac_1) )
2063 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2064 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2065 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2066 max(a4(1,i,k), pmp_2, lac_2) )
2067 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2073 if ( extm(i,k) .and. (extm(i,k-1).or.extm(i,k+1).or.a4(1,i,k)<qmin) )
then 2075 a4(2,i,k) = a4(1,i,k)
2076 a4(3,i,k) = a4(1,i,k)
2079 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2085 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2094 a4(3,i,km) =
max(0., a4(3,i,km))
2096 elseif ( iv .eq. -1 )
then 2098 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2104 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2106 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2107 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2113 subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
2116 integer,
intent(in):: i1, i2
2117 integer,
intent(in):: km
2118 integer,
intent(in):: iv
2121 integer,
intent(in):: kord
2122 real,
intent(in) :: qs(i1:i2)
2123 real,
intent(in) :: delp(i1:i2,km)
2124 real,
intent(inout):: a4(4,i1:i2,km)
2126 logical:: extm(i1:i2,km)
2130 real bet, a_bot, grat
2131 real pmp_1, lac_1, pmp_2, lac_2
2134 if ( iv .eq. -2 )
then 2137 q(i,1) = 1.5*a4(1,i,1)
2141 grat = delp(i,k-1) / delp(i,k)
2142 bet = 2. + grat + grat - gam(i,k)
2143 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
2144 gam(i,k+1) = grat / bet
2148 grat = delp(i,km-1) / delp(i,km)
2149 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
2150 (2. + grat + grat - gam(i,km))
2155 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
2160 grat = delp(i,2) / delp(i,1)
2161 bet = grat*(grat+0.5)
2162 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
2163 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
2168 d4(i) = delp(i,k-1) / delp(i,k)
2169 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
2170 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
2171 gam(i,k) = d4(i) / bet
2176 a_bot = 1. + d4(i)*(d4(i)+1.5)
2177 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
2178 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
2183 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
2188 if ( abs(kord) > 16 )
then 2192 a4(3,i,k) = q(i,k+1)
2193 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2207 q(i,2) =
min( q(i,2),
max(a4(1,i,1), a4(1,i,2)) )
2208 q(i,2) =
max( q(i,2),
min(a4(1,i,1), a4(1,i,2)) )
2213 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
2220 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 2222 q(i,k) =
min( q(i,k),
max(a4(1,i,k-1),a4(1,i,k)) )
2223 q(i,k) =
max( q(i,k),
min(a4(1,i,k-1),a4(1,i,k)) )
2225 if ( gam(i,k-1) > 0. )
then 2227 q(i,k) =
max(q(i,k),
min(a4(1,i,k-1),a4(1,i,k)))
2230 q(i,k) =
min(q(i,k),
max(a4(1,i,k-1),a4(1,i,k)))
2231 if ( iv==0 ) q(i,k) =
max(0., q(i,k))
2239 q(i,km) =
min( q(i,km),
max(a4(1,i,km-1), a4(1,i,km)) )
2240 q(i,km) =
max( q(i,km),
min(a4(1,i,km-1), a4(1,i,km)) )
2246 a4(3,i,k) = q(i,k+1)
2251 if ( k==1 .or. k==km )
then 2253 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
2257 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
2270 a4(2,i,1) =
max(0., a4(2,i,1))
2272 elseif ( iv==-1 )
then 2274 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2276 elseif ( iv==2 )
then 2278 a4(2,i,1) = a4(1,i,1)
2279 a4(3,i,1) = a4(1,i,1)
2286 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
2293 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
2301 if ( abs(kord)<9 )
then 2304 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2305 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2306 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2307 max(a4(1,i,k), pmp_1, lac_1) )
2309 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2310 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2311 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2312 max(a4(1,i,k), pmp_2, lac_2) )
2314 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2317 elseif ( abs(kord)==9 )
then 2319 if ( extm(i,k) .and. extm(i,k-1) )
then 2321 a4(2,i,k) = a4(1,i,k)
2322 a4(3,i,k) = a4(1,i,k)
2324 else if ( extm(i,k) .and. extm(i,k+1) )
then 2326 a4(2,i,k) = a4(1,i,k)
2327 a4(3,i,k) = a4(1,i,k)
2330 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2332 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2333 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2334 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2335 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2336 max(a4(1,i,k), pmp_1, lac_1) )
2337 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2338 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2339 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2340 max(a4(1,i,k), pmp_2, lac_2) )
2341 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2345 elseif ( abs(kord)==10 )
then 2347 if( extm(i,k) )
then 2348 if( extm(i,k-1) .or. extm(i,k+1) )
then 2350 a4(2,i,k) = a4(1,i,k)
2351 a4(3,i,k) = a4(1,i,k)
2355 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2358 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2360 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2361 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2362 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2363 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2364 max(a4(1,i,k), pmp_1, lac_1) )
2365 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2366 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2367 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2368 max(a4(1,i,k), pmp_2, lac_2) )
2369 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2373 elseif ( abs(kord)==12 )
then 2375 if( extm(i,k) )
then 2377 a4(2,i,k) = a4(1,i,k)
2378 a4(3,i,k) = a4(1,i,k)
2381 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2383 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2384 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2385 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2386 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2387 max(a4(1,i,k), pmp_1, lac_1) )
2388 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2389 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2390 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2391 max(a4(1,i,k), pmp_2, lac_2) )
2392 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2396 elseif ( abs(kord)==13 )
then 2398 if( extm(i,k) )
then 2399 if ( extm(i,k-1) .and. extm(i,k+1) )
then 2401 a4(2,i,k) = a4(1,i,k)
2402 a4(3,i,k) = a4(1,i,k)
2406 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2407 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2408 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), pmp_1, lac_1)), &
2409 max(a4(1,i,k), pmp_1, lac_1) )
2411 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2412 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2413 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), pmp_2, lac_2)), &
2414 max(a4(1,i,k), pmp_2, lac_2) )
2415 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2418 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2421 elseif ( abs(kord)==14 )
then 2423 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2427 if ( extm(i,k) .and. (extm(i,k-1) .or. extm(i,k+1)) )
then 2429 a4(2,i,k) = a4(1,i,k)
2430 a4(3,i,k) = a4(1,i,k)
2433 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2439 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2448 a4(3,i,km) =
max(0., a4(3,i,km))
2450 elseif ( iv .eq. -1 )
then 2452 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2458 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2460 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2461 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2468 integer,
intent(in) :: im
2469 integer,
intent(in) :: iv
2470 logical,
intent(in) :: extm(im)
2471 real ,
intent(inout) :: a4(4,im)
2479 if( a4(1,i)<=0.)
then 2484 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2485 if( (a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12) < 0. )
then 2487 if( a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i) )
then 2491 elseif( a4(3,i) > a4(2,i) )
then 2492 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2493 a4(3,i) = a4(2,i) - a4(4,i)
2495 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2496 a4(2,i) = a4(3,i) - a4(4,i)
2502 elseif ( iv==1 )
then 2504 if( (a4(1,i)-a4(2,i))*(a4(1,i)-a4(3,i))>=0. )
then 2509 da1 = a4(3,i) - a4(2,i)
2512 if(a6da < -da2)
then 2513 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2514 a4(3,i) = a4(2,i) - a4(4,i)
2515 elseif(a6da > da2)
then 2516 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2517 a4(2,i) = a4(3,i) - a4(4,i)
2529 da1 = a4(3,i) - a4(2,i)
2532 if(a6da < -da2)
then 2533 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2534 a4(3,i) = a4(2,i) - a4(4,i)
2535 elseif(a6da > da2)
then 2536 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2537 a4(2,i) = a4(3,i) - a4(4,i)
2546 subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
2549 integer,
intent(in):: iv
2553 integer,
intent(in):: i1
2554 integer,
intent(in):: i2
2555 integer,
intent(in):: km
2556 integer,
intent(in):: kord
2558 real ,
intent(in):: delp(i1:i2,km)
2561 real ,
intent(inout):: a4(4,i1:i2,km)
2578 integer i, k, km1, lmt, it
2580 real a1, a2, c1, c2, c3, d1, d2
2581 real qm, dq, lac, qmp, pmp
2588 delq(i,k-1) = a4(1,i,k) - a4(1,i,k-1)
2589 d4(i,k ) = delp(i,k-1) + delp(i,k)
2595 c1 = (delp(i,k-1)+0.5*delp(i,k))/d4(i,k+1)
2596 c2 = (delp(i,k+1)+0.5*delp(i,k))/d4(i,k)
2597 df2(i,k) = delp(i,k)*(c1*delq(i,k) + c2*delq(i,k-1)) / &
2598 (d4(i,k)+delp(i,k+1))
2599 dc(i,k) = sign(
min(abs(df2(i,k)), &
2600 max(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))-a4(1,i,k), &
2601 a4(1,i,k)-
min(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))), df2(i,k) )
2611 c1 = delq(i,k-1)*delp(i,k-1) / d4(i,k)
2612 a1 = d4(i,k-1) / (d4(i,k) + delp(i,k-1))
2613 a2 = d4(i,k+1) / (d4(i,k) + delp(i,k))
2614 a4(2,i,k) = a4(1,i,k-1) + c1 + 2./(d4(i,k-1)+d4(i,k+1)) * &
2615 ( delp(i,k)*(c1*(a1 - a2)+a2*dc(i,k-1)) - &
2616 delp(i,k-1)*a1*dc(i,k ) )
2627 qm = (d2*a4(1,i,1)+d1*a4(1,i,2)) / (d1+d2)
2628 dq = 2.*(a4(1,i,2)-a4(1,i,1)) / (d1+d2)
2629 c1 = 4.*(a4(2,i,3)-qm-d2*dq) / ( d2*(2.*d2*d2+d1*(d2+3.*d1)) )
2630 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2631 a4(2,i,2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
2634 a4(2,i,1) = d1*(2.*c1*d1**2-c3) + a4(2,i,2)
2639 a4(2,i,2) =
max( a4(2,i,2),
min(a4(1,i,1), a4(1,i,2)) )
2640 a4(2,i,2) =
min( a4(2,i,2),
max(a4(1,i,1), a4(1,i,2)) )
2641 dc(i,1) = 0.5*(a4(2,i,2) - a4(1,i,1))
2648 a4(2,i,1) =
max(0., a4(2,i,1))
2649 a4(2,i,2) =
max(0., a4(2,i,2))
2651 elseif( iv==-1 )
then 2653 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2655 elseif( abs(iv)==2 )
then 2657 a4(2,i,1) = a4(1,i,1)
2658 a4(3,i,1) = a4(1,i,1)
2667 qm = (d2*a4(1,i,km)+d1*a4(1,i,km1)) / (d1+d2)
2668 dq = 2.*(a4(1,i,km1)-a4(1,i,km)) / (d1+d2)
2669 c1 = (a4(2,i,km1)-qm-d2*dq) / (d2*(2.*d2*d2+d1*(d2+3.*d1)))
2670 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2671 a4(2,i,km) = qm - c1*d1*d2*(d2+3.*d1)
2674 a4(3,i,km) = d1*(8.*c1*d1**2-c3) + a4(2,i,km)
2679 a4(2,i,km) =
max( a4(2,i,km),
min(a4(1,i,km), a4(1,i,km1)) )
2680 a4(2,i,km) =
min( a4(2,i,km),
max(a4(1,i,km), a4(1,i,km1)) )
2681 dc(i,km) = 0.5*(a4(1,i,km) - a4(2,i,km))
2690 if( a4(3,i,km) * a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2691 d1 = a4(1,i,km) - a4(2,i,km)
2692 d2 = a4(3,i,km) - a4(1,i,km)
2693 if ( d1*d2 < 0. )
then 2694 a4(2,i,km) = a4(1,i,km)
2695 a4(3,i,km) = a4(1,i,km)
2697 dq = sign(
min(abs(d1),abs(d2),0.5*abs(delq(i,km-1))), d1)
2698 a4(2,i,km) = a4(1,i,km) - dq
2699 a4(3,i,km) = a4(1,i,km) + dq
2705 a4(2,i,km) =
max(0.,a4(2,i,km))
2706 a4(3,i,km) =
max(0.,a4(3,i,km))
2710 if( a4(1,i,km)*a4(3,i,km) <= 0. ) a4(3,i,km) = 0.
2717 a4(3,i,k) = a4(2,i,k+1)
2727 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2741 h2(i,k) = 2.*(dc(i,k+1)/delp(i,k+1) - dc(i,k-1)/delp(i,k-1)) &
2742 / ( delp(i,k)+0.5*(delp(i,k-1)+delp(i,k+1)) ) &
2758 qmp = a4(1,i,k) + pmp
2759 lac = a4(1,i,k) + fac*h2(i,k-1) + dc(i,k)
2760 a4(3,i,k) =
min(
max(a4(3,i,k),
min(a4(1,i,k), qmp, lac)), &
2761 max(a4(1,i,k), qmp, lac) )
2766 qmp = a4(1,i,k) - pmp
2767 lac = a4(1,i,k) + fac*h2(i,k+1) - dc(i,k)
2768 a4(2,i,k) =
min(
max(a4(2,i,k),
min(a4(1,i,k), qmp, lac)), &
2769 max(a4(1,i,k), qmp, lac))
2773 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2776 if (iv == 0 .and. kord >= 6 ) &
2784 if (iv == 0) lmt =
min(2, lmt)
2789 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2792 if(kord/=6)
call ppm_limiters(dc(i1,k), a4(1,i1,k), it, lmt)
2798 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2809 real ,
intent(in):: dm(*)
2810 integer,
intent(in) :: itot
2811 integer,
intent(in) :: lmt
2816 real ,
intent(inout) :: a4(4,*)
2829 if ( lmt == 3 )
return 2834 if(dm(i) == 0.)
then 2839 da1 = a4(3,i) - a4(2,i)
2842 if(a6da < -da2)
then 2843 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2844 a4(3,i) = a4(2,i) - a4(4,i)
2845 elseif(a6da > da2)
then 2846 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2847 a4(2,i) = a4(3,i) - a4(4,i)
2852 elseif (lmt == 1)
then 2858 a4(2,i) = a4(1,i)-sign(
min(abs(qmp),abs(a4(2,i)-a4(1,i))), qmp)
2859 a4(3,i) = a4(1,i)+sign(
min(abs(qmp),abs(a4(3,i)-a4(1,i))), qmp)
2860 a4(4,i) = 3.*( 2.*a4(1,i) - (a4(2,i)+a4(3,i)) )
2863 elseif (lmt == 2)
then 2867 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2868 fmin = a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12 2869 if( fmin < 0. )
then 2870 if(a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i))
then 2874 elseif(a4(3,i) > a4(2,i))
then 2875 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2876 a4(3,i) = a4(2,i) - a4(4,i)
2878 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2879 a4(2,i) = a4(3,i) - a4(4,i)
2891 subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
2892 integer,
intent(in) :: km, i1, i2
2893 real ,
intent(in) :: dp(i1:i2,km)
2894 real ,
intent(in) :: dq(i1:i2,km)
2895 real ,
intent(in) :: d4(i1:i2,km)
2896 real ,
intent(in) :: df2(i1:i2,km)
2897 real ,
intent(in) :: dm(i1:i2,km)
2899 real ,
intent(inout) :: a4(4,i1:i2,km)
2910 rat(i,k) = dq(i,k-1) / d4(i,k)
2917 f(i,k) = (rat(i,k+1) - rat(i,k)) &
2918 / ( dp(i,k-1)+dp(i,k)+dp(i,k+1) )
2924 if(f(i,k+1)*f(i,k-1)<0. .and. df2(i,k)/=0.)
then 2925 dg2 = (f(i,k+1)-f(i,k-1))*((dp(i,k+1)-dp(i,k-1))**2 &
2926 + d4(i,k)*d4(i,k+1) )
2927 alfa(i,k) =
max(0.,
min(0.5, -0.1875*dg2/df2(i,k)))
2936 a4(2,i,k) = (1.-alfa(i,k-1)-alfa(i,k)) * a4(2,i,k) + &
2937 alfa(i,k-1)*(a4(1,i,k)-dm(i,k)) + &
2938 alfa(i,k)*(a4(1,i,k-1)+dm(i,k-1))
2946 subroutine rst_remap(km, kn, is,ie,js,je, isd,ied,jsd,jed, nq, ntp, &
2947 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, &
2948 delp, u, v, w, delz, pt, q, qdiag, &
2949 ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, &
2950 domain, square_domain)
2955 integer,
intent(in):: km
2956 integer,
intent(in):: kn
2957 integer,
intent(in):: nq, ntp
2958 integer,
intent(in):: is,ie,isd,ied
2959 integer,
intent(in):: js,je,jsd,jed
2960 logical,
intent(in):: hydrostatic, make_nh, square_domain
2961 real,
intent(IN) :: ptop
2962 real,
intent(in) :: ak_r(km+1)
2963 real,
intent(in) :: bk_r(km+1)
2964 real,
intent(in) :: ak(kn+1)
2965 real,
intent(in) :: bk(kn+1)
2966 real,
intent(in):: delp_r(is:ie,js:je,km)
2967 real,
intent(in):: u_r(is:ie, js:je+1,km)
2968 real,
intent(in):: v_r(is:ie+1,js:je ,km)
2969 real,
intent(inout):: pt_r(is:ie,js:je,km)
2970 real,
intent(in):: w_r(is:ie,js:je,km)
2971 real,
intent(in):: q_r(is:ie,js:je,km,1:ntp)
2972 real,
intent(in):: qdiag_r(is:ie,js:je,km,ntp+1:nq)
2973 real,
intent(inout)::delz_r(is:ie,js:je,km)
2974 type(
domain2d),
intent(INOUT) :: domain
2976 real,
intent(out):: delp(isd:ied,jsd:jed,kn)
2977 real,
intent(out):: u(isd:ied ,jsd:jed+1,kn)
2978 real,
intent(out):: v(isd:ied+1,jsd:jed ,kn)
2979 real,
intent(out):: w(isd: ,jsd: ,1:)
2980 real,
intent(out):: pt(isd:ied ,jsd:jed ,kn)
2981 real,
intent(out):: q(isd:ied,jsd:jed,kn,1:ntp)
2982 real,
intent(out):: qdiag(isd:ied,jsd:jed,kn,ntp+1:nq)
2983 real,
intent(out):: delz(isd:,jsd:,1:)
2986 real ps(isd:ied,jsd:jed)
2987 real pe1(is:ie,km+1)
2988 real pe2(is:ie,kn+1)
2989 real pv1(is:ie+1,km+1)
2990 real pv2(is:ie+1,kn+1)
2993 integer,
parameter:: kord=4
2995 #ifdef HYDRO_DELZ_REMAP 2996 if (is_master() .and. .not. hydrostatic)
then 2998 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ' 3003 #ifdef HYDRO_DELZ_EXTRAP 3004 if (is_master() .and. .not. hydrostatic)
then 3006 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ABOVE INPUT MODEL TOP ' 3011 #ifdef ZERO_W_EXTRAP 3012 if (is_master() .and. .not. hydrostatic)
then 3014 print*,
' REMAPPING IC: INITIALIZING W TO ZERO ABOVE INPUT MODEL TOP ' 3034 ps(i,j) = ps(i,j) + delp_r(i,j,k)
3040 if ( square_domain )
then 3041 call mpp_update_domains(ps, domain, whalo=1, ehalo=1, shalo=1, nhalo=1, complete=.true.)
3051 pt_r(i,j,k) = pt_r(i,j,k) * (1.+r_vir*q_r(i,j,k,1))
3066 pe1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i,j-1)+ps(i,j))
3072 pe2(i,k) = ak(k) + 0.5*bk(k)*(ps(i,j-1)+ps(i,j))
3076 call remap_2d(km, pe1, u_r(is:ie,j:j,1:km), &
3077 kn, pe2, u(is:ie,j:j,1:kn), &
3080 if ( j /= (je+1) )
then 3087 pe1(i,k) = ak_r(k) + bk_r(k)*ps(i,j)
3093 pe2(i,k) = ak(k) + bk(k)*ps(i,j)
3102 delp(i,j,k) = pe2(i,k+1) - pe2(i,k)
3111 call remap_2d(km, pe1, q_r(is:ie,j:j,1:km,iq:iq), &
3112 kn, pe2, q(is:ie,j:j,1:kn,iq:iq), &
3116 call remap_2d(km, pe1, qdiag_r(is:ie,j:j,1:km,iq:iq), &
3117 kn, pe2, qdiag(is:ie,j:j,1:kn,iq:iq), &
3122 if ( .not. hydrostatic .and. .not. make_nh)
then 3124 call remap_2d(km, pe1, w_r(is:ie,j:j,1:km), &
3125 kn, pe2, w(is:ie,j:j,1:kn), &
3128 #ifdef ZERO_W_EXTRAP 3131 if (pe2(i,k) < pe1(i,1))
then 3138 #ifndef HYDRO_DELZ_REMAP 3142 delz_r(i,j,k) = -delz_r(i,j,k)/delp_r(i,j,k)
3145 call remap_2d(km, pe1, delz_r(is:ie,j:j,1:km), &
3146 kn, pe2, delz(is:ie,j:j,1:kn), &
3150 delz(i,j,k) = -delz(i,j,k)*delp(i,j,k)
3159 pe1(i,k) = log(pe1(i,k))
3164 pe2(i,k) = log(pe2(i,k))
3168 call remap_2d(km, pe1, pt_r(is:ie,j:j,1:km), &
3169 kn, pe2, pt(is:ie,j:j,1:kn), &
3172 #ifdef HYDRO_DELZ_REMAP 3176 delz(i,j,k) = (
rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3180 #ifdef HYDRO_DELZ_EXTRAP 3184 if (pe2(i,k) < pe1(i,1))
then 3185 delz(i,j,k) = (
rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3195 pv1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1,j)+ps(i,j))
3200 pv2(i,k) = ak(k) + 0.5*bk(k)*(ps(i-1,j)+ps(i,j))
3204 call remap_2d(km, pv1, v_r(is:ie+1,j:j,1:km), &
3205 kn, pv2, v(is:ie+1,j:j,1:kn), &
3215 pt(i,j,k) = pt(i,j,k) / (1.+r_vir*q(i,j,k,1))
3224 subroutine mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
3237 integer,
intent(in):: i1, i2, km, kn, kord, iv
3238 real,
intent(in ):: pe1(i1:i2,km+1), pe2(i1:i2,kn+1)
3239 real,
intent(in ):: q1(i1:i2,km)
3240 real,
intent(out):: q2(i1:i2,kn)
3241 real,
intent(IN) :: ptop
3248 real pl, pr, tt, delp, qsum, dpsum, esl
3252 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
3258 call cs_profile( qs, a4, dp1, km, i1, i2, iv, kord )
3266 #ifdef NGGPS_SUBMITTED 3268 a4(2,i,km) = q1(i,km)
3269 a4(3,i,km) = q1(i,km)
3278 if(pe2(i,k) .le. pe1(i,1))
then 3281 elseif(pe2(i,k) .ge. pe1(i,km+1))
then 3283 #ifdef NGGPS_SUBMITTED 3284 q2(i,k) = a4(3,i,km)
3292 if( pe2(i,k) .ge. pe1(i,l) .and. &
3293 pe2(i,k) .le. pe1(i,l+1) )
then 3295 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
3296 if(pe2(i,k+1) .le. pe1(i,l+1))
then 3299 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
3300 tt =
r3*(pr*(pr+pl)+pl**2)
3301 q2(i,k) = a4(2,i,l) + 0.5*(a4(4,i,l)+a4(3,i,l) &
3302 - a4(2,i,l))*(pr+pl) - a4(4,i,l)*tt
3306 delp = pe1(i,l+1) - pe2(i,k)
3307 tt =
r3*(1.+pl*(1.+pl))
3308 qsum = delp*(a4(2,i,l)+0.5*(a4(4,i,l)+ &
3309 a4(3,i,l)-a4(2,i,l))*(1.+pl)-a4(4,i,l)*tt)
3319 if( pe2(i,k+1) .gt. pe1(i,l+1) )
then 3323 qsum = qsum + dp1(i,l)*q1(i,l)
3324 dpsum = dpsum + dp1(i,l)
3326 delp = pe2(i,k+1)-pe1(i,l)
3327 esl = delp / dp1(i,l)
3328 qsum = qsum + delp * (a4(2,i,l)+0.5*esl* &
3329 (a4(3,i,l)-a4(2,i,l)+a4(4,i,l)*(1.-
r23*esl)) )
3330 dpsum = dpsum + delp
3335 delp = pe2(i,k+1) - pe1(i,km+1)
3338 #ifdef NGGPS_SUBMITTED 3339 qsum = qsum + delp * a4(3,i,km)
3341 qsum = qsum + delp * q1(i,km)
3343 dpsum = dpsum + delp
3345 123 q2(i,k) = qsum / dpsum
3350 end subroutine mappm 3353 subroutine moist_cv(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3354 ice_wat, snowwat, graupel, q, qd, cvm, t1)
3355 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3356 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3357 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3358 real,
intent(out),
dimension(is:ie):: cvm, qd
3359 real,
intent(in),
optional:: t1(is:ie)
3361 real,
parameter:: t_i0 = 15.
3362 real,
dimension(is:ie):: qv, ql, qs
3368 if (
present(t1) )
then 3370 qd(i) =
max(0., q(i,j,k,liq_wat))
3371 if ( t1(i) >
tice )
then 3373 elseif ( t1(i) <
tice-t_i0 )
then 3376 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3378 ql(i) = qd(i) - qs(i)
3379 qv(i) =
max(0.,q(i,j,k,sphum))
3384 qv(i) =
max(0.,q(i,j,k,sphum))
3385 qs(i) =
max(0.,q(i,j,k,liq_wat))
3392 qv(i) = q(i,j,k,sphum)
3393 ql(i) = q(i,j,k,liq_wat)
3394 qs(i) = q(i,j,k,ice_wat)
3395 qd(i) = ql(i) + qs(i)
3400 qv(i) = q(i,j,k,sphum)
3401 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3407 qv(i) = q(i,j,k,sphum)
3408 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3409 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3410 qd(i) = ql(i) + qs(i)
3422 subroutine moist_cp(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3423 ice_wat, snowwat, graupel, q, qd, cpm, t1)
3425 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3426 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3427 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3428 real,
intent(out),
dimension(is:ie):: cpm, qd
3429 real,
intent(in),
optional:: t1(is:ie)
3431 real,
parameter:: t_i0 = 15.
3432 real,
dimension(is:ie):: qv, ql, qs
3438 if (
present(t1) )
then 3440 qd(i) =
max(0., q(i,j,k,liq_wat))
3441 if ( t1(i) >
tice )
then 3443 elseif ( t1(i) <
tice-t_i0 )
then 3446 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3448 ql(i) = qd(i) - qs(i)
3449 qv(i) =
max(0.,q(i,j,k,sphum))
3454 qv(i) =
max(0.,q(i,j,k,sphum))
3455 qs(i) =
max(0.,q(i,j,k,liq_wat))
3463 qv(i) = q(i,j,k,sphum)
3464 ql(i) = q(i,j,k,liq_wat)
3465 qs(i) = q(i,j,k,ice_wat)
3466 qd(i) = ql(i) + qs(i)
3471 qv(i) = q(i,j,k,sphum)
3472 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3478 qv(i) = q(i,j,k,sphum)
3479 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3480 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3481 qd(i) = ql(i) + qs(i)
3499 kn, pe2, q2, i1, i2, &
3500 j, ibeg, iend, jbeg, jend, akap, T_VAR, conserv)
3504 integer,
intent(in) :: i1
3505 integer,
intent(in) :: i2
3506 real,
intent(in) :: akap
3507 integer,
intent(in) :: T_VAR
3509 logical,
intent(in) :: conserv
3510 integer,
intent(in) :: j
3511 integer,
intent(in) :: ibeg, iend, jbeg, jend
3512 integer,
intent(in) :: km
3513 integer,
intent(in) :: kn
3515 real,
intent(in) :: pe1(i1:i2,km+1)
3518 real,
intent(in) :: pe2(i1:i2,kn+1)
3522 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
3524 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
3544 real logpl1(i1:i2,km)
3545 real logpl2(i1:i2,kn)
3546 real dlogp1(i1:i2,km)
3549 real am2,am1,ap0,ap1,P,PLP1,PLP0,PLM1,PLM2,DLP0,DLM1,DLM2
3551 integer i, k, LM2,LM1,LP0,LP1
3560 qx(:,k) = q1(i1:i2,j,k)
3561 logpl1(:,k) = log(
r2*(pe1(:,k)+pe1(:,k+1)) )
3564 logpl2(:,k) = log(
r2*(pe2(:,k)+pe2(:,k+1)) )
3568 dlogp1(:,k) = logpl1(:,k+1)-logpl1(:,k)
3574 qx(:,k) = q1(i1:i2,j,k)
3575 logpl1(:,k) = log(
r2*(pe1(:,k)+pe1(:,k+1)) )
3578 logpl2(:,k) = log(
r2*(pe2(:,k)+pe2(:,k+1)) )
3582 dlogp1(:,k) = logpl1(:,k+1)-logpl1(:,k)
3588 qx(:,k) = q1(i1:i2,j,k)
3589 logpl1(:,k) = exp( akap*log(
r2*(pe1(:,k)+pe1(:,k+1))) )
3592 logpl2(:,k) = exp( akap*log(
r2*(pe2(:,k)+pe2(:,k+1))) )
3596 dlogp1(:,k) = logpl1(:,k+1)-logpl1(:,k)
3607 vsum1(i) = vsum1(i) + qx(i,k)*( pe1(i,k+1)-pe1(i,k) )
3609 vsum1(i) = vsum1(i) / ( pe1(i,km+1)-pe1(i,1) )
3620 do while( lp0.le.km )
3621 if (logpl1(i,lp0).lt.logpl2(i,k))
then 3632 if( lm1.eq.1 .and. lp0.eq.1 )
then 3633 q2(i,j,k) = qx(i,1) + ( qx(i,2)-qx(i,1) )*( logpl2(i,k)-logpl1(i,1) ) &
3634 /( logpl1(i,2)-logpl1(i,1) )
3638 else if( lm1.eq.km .and. lp0.eq.km )
then 3639 q2(i,j,k) = qx(i,km) + ( qx(i,km)-qx(i,km-1) )*( logpl2(i,k )-logpl1(i,km ) ) &
3640 /( logpl1(i,km)-logpl1(i,km-1) )
3644 else if( lm1.eq.1 .or. lp0.eq.km )
then 3645 q2(i,j,k) = qx(i,lp0) + ( qx(i,lm1)-qx(i,lp0) )*( logpl2(i,k )-logpl1(i,lp0) ) &
3646 /( logpl1(i,lm1)-logpl1(i,lp0) )
3653 plp1 = logpl1(i,lp1)
3654 plp0 = logpl1(i,lp0)
3655 plm1 = logpl1(i,lm1)
3656 plm2 = logpl1(i,lm2)
3657 dlp0 = dlogp1(i,lp0)
3658 dlm1 = dlogp1(i,lm1)
3659 dlm2 = dlogp1(i,lm2)
3661 ap1 = (p-plp0)*(p-plm1)*(p-plm2)/( dlp0*(dlp0+dlm1)*(dlp0+dlm1+dlm2) )
3662 ap0 = (plp1-p)*(p-plm1)*(p-plm2)/( dlp0* dlm1 *( dlm1+dlm2) )
3663 am1 = (plp1-p)*(plp0-p)*(p-plm2)/( dlm1* dlm2 *(dlp0+dlm1 ) )
3664 am2 = (plp1-p)*(plp0-p)*(plm1-p)/( dlm2*(dlm1+dlm2)*(dlp0+dlm1+dlm2) )
3666 q2(i,j,k) = ap1*qx(i,lp1) + ap0*qx(i,lp0) + am1*qx(i,lm1) + am2*qx(i,lm2)
3679 vsum2(i) = vsum2(i) + q2(i,j,k)*( pe2(i,k+1)-pe2(i,k) )
3681 vsum2(i) = vsum2(i) / ( pe2(i,kn+1)-pe2(i,1) )
3688 q2(i,j,k) = q2(i,j,k) + vsum1(i)-vsum2(i)
real, parameter consv_min
real, parameter, public radius
Radius of the Earth [m].
integer, parameter, public model_atmos
subroutine, public moist_cv(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cvm, t1)
subroutine map1_cubic(km, pe1, q1, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, akap, T_VAR, conserv)
real, parameter, public ptop_min
subroutine, public fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, te0, qv, ql, qi, qr, qs, qg, dpln, delz, pt, dp, q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
subroutine cs_limiters(im, extm, a4, iv)
subroutine map1_ppm(km, pe1, q1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
real, parameter, public hlv
Latent heat of evaporation [J/kg].
subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
subroutine, public lagrangian_to_eulerian(last_step, consv, ps, pe, delp, pkz, pk, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, ng, ua, va, omga, te, ws, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option)
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, public fillz(im, km, nq, q, dp)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
subroutine, public map1_q2(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
subroutine, public moist_cp(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cpm, t1)
subroutine timing_on(blk_name)
subroutine, public compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, u, v, w, delz, pt, delp, q, qc, pe, peln, hs, rsin2_l, cosa_s_l, r_vir, cp, rg, hlv, te_2d, ua, va, teq, moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
subroutine, public qs_init(kmp)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine, public rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, domain, square_domain)
subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
subroutine map_scalar(km, pe1, q1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
real, parameter, public hlf
Latent heat of fusion [J/kg].
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)
subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, peln, pkz, ptop)
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
real(kind=4), public e_flux
subroutine ppm_limiters(dm, a4, itot, lmt)
subroutine remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
real(fp), parameter, public pi
subroutine timing_off(blk_name)