85 use constants_mod
, only: radius, pi=>pi_8, rvgas, rdgas, grav, hlv, hlf, cp_air, cp_vapor
86 use tracer_manager_mod
,only: get_tracer_index
87 use field_manager_mod
, only: model_atmos
90 use mpp_domains_mod
, only: mpp_update_domains, domain2d
91 use mpp_mod
, only: note, fatal, mpp_error, get_unit, mpp_root_pe, mpp_pe
102 use ccpp_api
, only: ccpp_initialized
103 use ccpp_static_api
, only: ccpp_physics_run
104 use ccpp_data
, only: ccpp_suite
106 use ccpp_api
, only: ccpp_initialized, ccpp_physics_run
108 use ccpp_data
, only: cdata => cdata_tile, ccpp_interstitial
117 real,
parameter::
r3 = 1./3.,
r23 = 2./3.,
r12 = 1./12.
119 real,
parameter::
cv_air = cp_air - rdgas
125 real,
parameter::
tice = 273.16
139 mdt, pdt, km, is,ie,js,je, isd,ied,jsd,jed, &
140 nq, nwat, sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, &
141 akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, &
142 ng, ua, va, omga, te, ws, fill, reproduce_sum, out_dt, dtdt, &
143 ptop, ak, bk, pfull, gridstruct, domain, do_sat_adj, &
144 hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init)
145 logical,
intent(in):: last_step
146 real,
intent(in):: mdt
147 real,
intent(in):: pdt
148 integer,
intent(in):: km
149 integer,
intent(in):: nq
150 integer,
intent(in):: nwat
151 integer,
intent(in):: sphum
152 integer,
intent(in):: ng
153 integer,
intent(in):: is,ie,isd,ied
154 integer,
intent(in):: js,je,jsd,jed
155 integer,
intent(in):: kord_mt
156 integer,
intent(in):: kord_wz
157 integer,
intent(in):: kord_tr(nq)
158 integer,
intent(in):: kord_tm
160 real,
intent(in):: consv
161 real,
intent(in):: r_vir
162 real,
intent(in):: cp
163 real,
intent(in):: akap
164 real,
intent(in):: hs(isd:ied,jsd:jed)
165 real,
intent(inout):: te0_2d(is:ie,js:je)
166 real,
intent(in):: ws(is:ie,js:je)
168 logical,
intent(in):: do_sat_adj
169 logical,
intent(in):: fill
170 logical,
intent(in):: reproduce_sum
171 logical,
intent(in):: do_omega, adiabatic, do_adiabatic_init
172 real,
intent(in) :: ptop
173 real,
intent(in) :: ak(km+1)
174 real,
intent(in) :: bk(km+1)
175 real,
intent(in):: pfull(km)
177 type(domain2d),
intent(INOUT) :: domain
180 real,
intent(inout):: pk(is:ie,js:je,km+1)
181 real,
intent(inout):: q(isd:ied,jsd:jed,km,*)
182 real,
intent(inout):: delp(isd:ied,jsd:jed,km)
183 real,
intent(inout):: pe(is-1:ie+1,km+1,js-1:je+1)
184 real,
intent(inout):: ps(isd:ied,jsd:jed)
187 real,
intent(inout):: u(isd:ied ,jsd:jed+1,km)
188 real,
intent(inout):: v(isd:ied+1,jsd:jed ,km)
189 real,
intent(inout):: w(isd: ,jsd: ,1:)
190 real,
intent(inout):: pt(isd:ied ,jsd:jed ,km)
192 real,
intent(inout),
dimension(isd:,jsd:,1:)::delz, q_con, cappa
193 logical,
intent(in):: hydrostatic
194 logical,
intent(in):: hybrid_z
195 logical,
intent(in):: out_dt
197 real,
intent(inout):: ua(isd:ied,jsd:jed,km)
198 real,
intent(inout):: va(isd:ied,jsd:jed,km)
199 real,
intent(inout):: omga(isd:ied,jsd:jed,km)
200 real,
intent(inout):: peln(is:ie,km+1,js:je)
201 real,
intent(inout):: dtdt(is:ie,js:je,km)
202 real,
intent(out):: pkz(is:ie,js:je,km)
203 real,
intent(out):: te(isd:ied,jsd:jed,km)
212 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1
214 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1, dpln
216 real,
dimension(is:ie,km) :: q2, dp2
217 real,
dimension(is:ie,km+1):: pe1, pe2, pk1, pk2, pn2, phis
218 real,
dimension(is:ie+1,km+1):: pe0, pe3
219 real,
dimension(is:ie):: gz, cvm, qv
220 real rcp, rg, rrg, bkh, dtmp, k1k
222 logical:: fast_mp_consv
227 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, iq, n, kp, k_next
230 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, iq, n, kmp, kp, k_next
234 ccpp_associate: associate( fast_mp_consv => ccpp_interstitial%fast_mp_consv, &
235 kmp => ccpp_interstitial%kmp )
243 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
244 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
245 rainwat = get_tracer_index(model_atmos,
'rainwat')
246 snowwat = get_tracer_index(model_atmos,
'snowwat')
247 graupel = get_tracer_index(model_atmos,
'graupel')
248 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
250 if ( do_sat_adj )
then 251 fast_mp_consv = (.not.do_adiabatic_init) .and. consv>
consv_min 255 if ( pfull(k) > 10.e2 )
exit 282 pe2(i,km+1) = pe(i,km+1,j)
285 if ( j /= (je+1) )
then 286 if ( kord_tm < 0 )
then 288 if ( hydrostatic )
then 293 pkz(i,j,k) = (pk(i,j,k+1)-pk(i,j,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
294 pkz(i,j,k) = exp(
virqd(q(i,j,k,1:
num_gas))/
vicpqd(q(i,j,k,1:
num_gas))*log(pkz(i,j,k)))
295 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
297 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)))
305 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
306 ice_wat, snowwat, graupel, q, gz, cvm)
310 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
312 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
314 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)))
319 pt(i,j,k) = pt(i,j,k)*exp(k1k*(
virqd(q(i,j,k,1:
num_gas))/
vicvqd(q(i,j,k,1:
num_gas))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
321 pt(i,j,k) = pt(i,j,k)*exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
330 elseif ( hydrostatic )
then 331 call pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, ptop)
336 pkz(i,j,k) = exp(
virqd(q(i,j,k,1:
num_gas))/
vicpqd(q(i,j,k,1:
num_gas))*log(pkz(i,j,k)))
338 te(i,j,k) = 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
339 v(i,j,k)**2+v(i+1,j,k)**2 - &
340 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)) &
341 + cp_air*pt(i,j,k)*pkz(i,j,k)
346 if ( .not. hydrostatic )
then 349 delz(i,j,k) = -delz(i,j,k) / delp(i,j,k)
356 ps(i,j) = pe1(i,km+1)
363 pe2(i,k) = ak(k) + bk(k)*pe(i,km+1,j)
368 dp2(i,k) = pe2(i,k+1) - pe2(i,k)
377 delp(i,j,k) = dp2(i,k)
391 pn2(i, 1) = peln(i, 1,j)
392 pn2(i,km+1) = peln(i,km+1,j)
393 pk2(i, 1) = pk1(i, 1)
394 pk2(i,km+1) = pk1(i,km+1)
399 pn2(i,k) = log(pe2(i,k))
400 pk2(i,k) = exp(akap*pn2(i,k))
404 if ( kord_tm<0 )
then 410 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm),
t_min)
415 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
422 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
423 is, ie, isd, ied, jsd, jed, 0., fill)
424 elseif ( nq > 0 )
then 427 call map1_q2(km, pe1, q(isd,jsd,1,iq), &
429 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
430 if (fill)
call fillz(ie-is+1, km, 1, q2, dp2)
433 q(i,j,k,iq) = q2(i,k)
439 if ( .not. hydrostatic )
then 441 call map1_ppm (km, pe1, w, ws(is,j), &
443 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
447 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
450 delz(i,j,k) = -delz(i,j,k)*dp2(i,k)
473 pe3(i,k) = omga(i,j,k-1)
480 pe0(i,k) = peln(i,k,j)
481 peln(i,k,j) = pn2(i,k)
489 if ( hydrostatic )
then 492 pkz(i,j,k) = (pk2(i,k+1)-pk2(i,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
494 pkz(i,j,k) = exp(
virqd(q(i,j,k,1:
num_gas))/
vicpqd(q(i,j,k,1:
num_gas))*log(pkz(i,j,k)))
502 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
503 ice_wat, snowwat, graupel, q, gz, cvm)
507 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
509 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
511 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
514 if ( kord_tm < 0 )
then 517 pkz(i,j,k) = exp(akap*
virqd(q(i,j,k,1:
num_gas))/
vicpqd(q(i,j,k,1:
num_gas))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
519 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
527 pkz(i,j,k) = exp(k1k*
virqd(q(i,j,k,1:
num_gas))/
vicvqd(q(i,j,k,1:
num_gas))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
529 pkz(i,j,k) = exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
534 if ( last_step .and. (.not.adiabatic) )
then 536 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
548 dp2(i,k) = 0.5*(peln(i,k,j) + peln(i,k+1,j))
556 if( dp2(i,n) <= pe0(i,k+1) .and. dp2(i,n) >= pe0(i,k) )
then 557 omga(i,j,n) = pe3(i,k) + (pe3(i,k+1) - pe3(i,k)) * &
558 (dp2(i,n)-pe0(i,k)) / (pe0(i,k+1)-pe0(i,k) )
577 pe0(i,k) = 0.5*(pe(i,k,j-1)+pe1(i,k))
584 pe3(i,k) = ak(k) + bkh*(pe(i,km+1,j-1)+pe1(i,km+1))
588 call map1_ppm( km, pe0(is:ie,:), u, gz, &
589 km, pe3(is:ie,:), u, &
590 is, ie, j, isd, ied, jsd, jed+1, -1, kord_mt)
603 pe0(i,k) = 0.5*(pe(i-1,k, j)+pe(i,k, j))
604 pe3(i,k) = ak(k) + bkh*(pe(i-1,km+1,j)+pe(i,km+1,j))
609 km, pe3, v, is, ie+1, &
610 j, isd, ied+1, jsd, jed, -1, kord_mt)
615 ua(i,j,k) = pe2(i,k+1)
621 #if defined(CCPP) && defined(__GFORTRAN__) 672 pe(i,k,j) = ua(i,j,k-1)
678 if( last_step .and. (.not.do_adiabatic_init) )
then 684 if ( hydrostatic )
then 688 gz(i) = gz(i) + rg*pt(i,j,k)*(peln(i,k+1,j)-peln(i,k,j))
692 te_2d(i,j) = pe(i,km+1,j)*hs(i,j) - pe(i,1,j)*gz(i)
697 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*pt(i,j,k) + &
698 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
699 v(i,j,k)**2+v(i+1,j,k)**2 - &
700 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)))
706 phis(i,km+1) = hs(i,j)
710 phis(i,k) = phis(i,k+1) - grav*delz(i,j,k)
716 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
717 ice_wat, snowwat, graupel, q, gz, cvm)
722 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cvm(i)*pt(i,j,k)/
virq(q(i,j,k,1:
num_gas)) + &
724 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))) + &
726 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
727 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
728 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
733 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k)/
virq(q(i,j,k,1:
num_gas)) + &
735 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))))
746 te_2d(i,j) = te0_2d(i,j) - te_2d(i,j)
747 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
751 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
754 if ( hydrostatic )
then 756 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
763 dtmp = consv*
g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.)
764 e_flux = dtmp / (grav*pdt*4.*pi*radius**2)
766 if ( hydrostatic )
then 767 dtmp = dtmp / (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
769 dtmp = dtmp / (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
778 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
782 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
785 if ( hydrostatic )
then 787 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
794 if ( hydrostatic )
then 795 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
796 (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
798 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
799 (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
808 if ( do_sat_adj )
then 811 if (ccpp_initialized(cdata))
then 813 call ccpp_physics_run(cdata, suite_name=trim(ccpp_suite), group_name=
'fast_physics', ierr=ierr)
815 call ccpp_physics_run(cdata, group_name=
'fast_physics', ierr=ierr)
817 if (ierr/=0)
call mpp_error(fatal,
"Call to ccpp_physics_run for group 'fast_physics' failed")
819 call mpp_error (fatal,
'Lagrangian_to_Eulerian: can not call CCPP fast physics because cdata not initialized')
826 dpln(i,j) = peln(i,k+1,j) - peln(i,k,j)
829 if (hydrostatic)
then 834 call fv_sat_adj(abs(mdt), r_vir, is, ie, js, je, ng, hydrostatic, fast_mp_consv, &
839 q(isd,jsd,k,sphum), q(isd,jsd,k,liq_wat), &
840 q(isd,jsd,k,ice_wat), q(isd,jsd,k,rainwat), &
841 q(isd,jsd,k,snowwat), q(isd,jsd,k,graupel), &
842 hs ,dpln, delz(isd:,jsd:,kdelz), pt(isd,jsd,k), delp(isd,jsd,k), q_con(isd:,jsd:,k), &
844 cappa(isd:,jsd:,k), gridstruct%area_64, dtdt(is,js,k), out_dt, last_step, cld_amt>0, q(isd,jsd,k,cld_amt))
846 if ( .not. hydrostatic )
then 850 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
853 pkz(i,j,k) = exp(akap*(
virqd(q(i,j,k,1:
num_gas))/
vicpqd(q(i,j,k,1:
num_gas))*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
855 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
864 if ( fast_mp_consv )
then 869 te0_2d(i,j) = te0_2d(i,j) + te(i,j,k)
879 if ( last_step )
then 888 gz(i) = max(0., q(i,j,k,liq_wat))
889 qv(i) = max(0., q(i,j,k,sphum))
891 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
893 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*qv(i))*(1.-gz(i)))
896 elseif ( nwat==6 )
then 898 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)
900 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/
virq(q(i,j,k,1:
num_gas))
902 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
906 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
907 ice_wat, snowwat, graupel, q, gz, cvm)
910 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
912 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
917 if ( .not. adiabatic )
then 920 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
922 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / (1.+r_vir*q(i,j,k,sphum))
930 if ( kord_tm < 0 )
then 935 pt(i,j,k) = pt(i,j,k)/pkz(i,j,k)
944 end associate ccpp_associate
953 u, v, w, delz, pt, delp, q, qc, pe, peln, hs, &
955 r_vir, cp, rg, hlv, te_2d, ua, va, teq, &
956 moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
961 integer,
intent(in):: km, is, ie, js, je, isd, ied, jsd, jed, id_te
962 integer,
intent(in):: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, nwat
963 real,
intent(inout),
dimension(isd:ied,jsd:jed,km):: ua, va
964 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: pt, delp
965 real,
intent(in),
dimension(isd:ied,jsd:jed,km,*):: q
966 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: qc
967 real,
intent(inout):: u(isd:ied, jsd:jed+1,km)
968 real,
intent(inout):: v(isd:ied+1,jsd:jed, km)
969 real,
intent(in):: w(isd:,jsd:,1:)
970 real,
intent(in):: delz(isd:,jsd:,1:)
971 real,
intent(in):: hs(isd:ied,jsd:jed)
972 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
973 real,
intent(in):: peln(is:ie,km+1,js:je)
974 real,
intent(in):: cp, rg, r_vir, hlv
975 real,
intent(in) :: rsin2_l(isd:ied, jsd:jed)
976 real,
intent(in) :: cosa_s_l(isd:ied, jsd:jed)
977 logical,
intent(in):: moist_phys, hydrostatic
979 real,
intent(out):: te_2d(is:ie,js:je)
980 real,
intent(out):: teq(is:ie,js:je)
982 real,
dimension(is:ie,km):: tv
983 real phiz(is:ie,km+1)
984 real cvm(is:ie), qd(is:ie)
1001 if ( hydrostatic )
then 1004 phiz(i,km+1) = hs(i,j)
1008 tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))
1009 phiz(i,k) = phiz(i,k+1) + rg*tv(i,k)*(peln(i,k+1,j)-peln(i,k,j))
1014 te_2d(i,j) = pe(i,km+1,j)*phiz(i,km+1) - pe(i,1,j)*phiz(i,1)
1019 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*tv(i,k) + &
1020 0.25*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1021 v(i,j,k)**2+v(i+1,j,k)**2 - &
1022 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j)))
1031 phiz(i,km+1) = hs(i,j)
1033 phiz(i,k) = phiz(i,k+1) - grav*delz(i,j,k)
1039 if ( moist_phys )
then 1042 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
1043 ice_wat, snowwat, graupel, q, qd, cvm)
1047 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*( cvm(i)*pt(i,j,k) + &
1050 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*vicvqd(q(i,j,k,1:num_gas) )*pt(i,j,k) + &
1052 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1055 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 + &
1056 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*vicvqd(q(i,j,k,1:num_gas))*pt(i,j,k) + &
1065 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1067 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 + &
1068 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))))
1082 teq(i,j) = te_2d(i,j)
1084 if ( moist_phys )
then 1087 teq(i,j) = teq(i,j) + hlv*q(i,j,k,sphum)*delp(i,j,k)
1096 subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, &
1097 pe, pk, akap, peln, pkz, ptop)
1100 integer,
intent(in):: km, j
1101 integer,
intent(in):: ifirst, ilast
1102 integer,
intent(in):: jfirst, jlast
1103 real,
intent(in):: akap
1104 real,
intent(in):: pe(ifirst-1:ilast+1,km+1,jfirst-1:jlast+1)
1105 real,
intent(in):: pk(ifirst:ilast,jfirst:jlast,km+1)
1106 real,
intent(IN):: ptop
1108 real,
intent(out):: pkz(ifirst:ilast,jfirst:jlast,km)
1109 real,
intent(inout):: peln(ifirst:ilast, km+1, jfirst:jlast)
1111 real pk2(ifirst:ilast, km+1)
1117 ak1 = (akap + 1.) / akap
1119 pek = pk(ifirst,j,1)
1127 pk2(i,k) = pk(i,j,k)
1132 if( ptop < ptop_min )
then 1134 peln(i,1,j) = peln(i,2,j) - ak1
1146 pkz(i,j,k) = (pk2(i,k+1) - pk2(i,k) ) / &
1147 (akap*(peln(i,k+1,j) - peln(i,k,j)) )
1155 subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
1158 integer,
intent(in) :: i1
1159 integer,
intent(in) :: i2
1160 integer,
intent(in) :: kord
1161 integer,
intent(in) :: km
1162 integer,
intent(in) :: kn
1163 integer,
intent(in) :: iv
1165 real,
intent(in) :: pe1(i1:i2,km+1)
1166 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
1244 integer,
intent(in) :: kord
1245 integer,
intent(in) :: j
1246 integer,
intent(in) :: ibeg, iend, jbeg, jend
1247 integer,
intent(in) :: km
1248 integer,
intent(in) :: kn
1249 real,
intent(in) :: qs(i1:i2)
1250 real,
intent(in) :: pe1(i1:i2,km+1)
1251 real,
intent(in) :: pe2(i1:i2,kn+1)
1252 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1254 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1255 real,
intent(in):: q_min
1266 real pl, pr, qsum, dp, esl
1267 integer i, k, l, m, k0
1271 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1272 q4(1,i,k) = q1(i,j,k)
1288 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1289 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1290 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1292 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1293 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1294 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1299 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1300 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1301 (
r3*(1.+pl*(1.+pl))))
1304 if( pe2(i,k+1) > pe1(i,m+1) )
then 1306 qsum = qsum + dp1(i,m)*q4(1,i,m)
1308 dp = pe2(i,k+1)-pe1(i,m)
1310 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1311 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1320 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1327 subroutine map1_ppm( km, pe1, q1, qs, &
1328 kn, pe2, q2, i1, i2, &
1329 j, ibeg, iend, jbeg, jend, iv, kord)
1330 integer,
intent(in) :: i1
1331 integer,
intent(in) :: i2
1332 integer,
intent(in) :: iv
1333 integer,
intent(in) :: kord
1334 integer,
intent(in) :: j
1335 integer,
intent(in) :: ibeg, iend, jbeg, jend
1336 integer,
intent(in) :: km
1337 integer,
intent(in) :: kn
1338 real,
intent(in) :: qs(i1:i2)
1339 real,
intent(in) :: pe1(i1:i2,km+1)
1340 real,
intent(in) :: pe2(i1:i2,kn+1)
1341 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1343 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1355 real pl, pr, qsum, dp, esl
1356 integer i, k, l, m, k0
1360 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1361 q4(1,i,k) = q1(i,j,k)
1367 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1377 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1378 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1379 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1381 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1382 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1383 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1388 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1389 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1390 (
r3*(1.+pl*(1.+pl))))
1393 if( pe2(i,k+1) > pe1(i,m+1) )
then 1395 qsum = qsum + dp1(i,m)*q4(1,i,m)
1397 dp = pe2(i,k+1)-pe1(i,m)
1399 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1400 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1409 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1416 subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, &
1417 i1, i2, isd, ied, jsd, jed, q_min, fill)
1419 integer,
intent(in):: km
1420 integer,
intent(in):: j, nq, i1, i2
1421 integer,
intent(in):: isd, ied, jsd, jed
1422 integer,
intent(in):: kord(nq)
1423 real,
intent(in):: pe1(i1:i2,km+1)
1424 real,
intent(in):: pe2(i1:i2,km+1)
1425 real,
intent(in):: dp2(i1:i2,km)
1426 real,
intent(in):: q_min
1427 logical,
intent(in):: fill
1428 real,
intent(inout):: q1(isd:ied,jsd:jed,km,nq)
1430 real:: q4(4,i1:i2,km,nq)
1431 real:: q2(i1:i2,km,nq)
1433 real:: dp1(i1:i2,km)
1435 real:: pl, pr, dp, esl, fac1, fac2
1436 integer:: i, k, l, m, k0, iq
1440 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1447 q4(1,i,k,iq) = q1(i,j,k,iq)
1450 call scalar_profile( qs, q4(1,i1,1,iq), dp1, km, i1, i2, 0, kord(iq), q_min )
1459 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1460 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1461 if(pe2(i,k+1) <= pe1(i,l+1))
then 1463 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1465 fac2 =
r3*(pr*fac1 + pl*pl)
1468 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 &
1475 dp = pe1(i,l+1) - pe2(i,k)
1477 fac2 =
r3*(1.+pl*fac1)
1480 qsum(iq) = dp*(q4(2,i,l,iq) + (q4(4,i,l,iq)+ &
1481 q4(3,i,l,iq) - q4(2,i,l,iq))*fac1 - q4(4,i,l,iq)*fac2)
1485 if(pe2(i,k+1) > pe1(i,m+1) )
then 1488 qsum(iq) = qsum(iq) + dp1(i,m)*q4(1,i,m,iq)
1491 dp = pe2(i,k+1)-pe1(i,m)
1496 qsum(iq) = qsum(iq) + dp*( q4(2,i,m,iq) + fac1*( &
1497 q4(3,i,m,iq)-q4(2,i,m,iq)+q4(4,i,m,iq)*fac2 ) )
1509 q2(i,k,iq) = qsum(iq) / dp2(i,k)
1514 if (fill)
call fillz(i2-i1+1, km, nq, q2, dp2)
1520 q1(i,j,k,iq) = q2(i,k,iq)
1528 subroutine map1_q2(km, pe1, q1, &
1530 i1, i2, iv, kord, j, &
1531 ibeg, iend, jbeg, jend, q_min )
1535 integer,
intent(in) :: j
1536 integer,
intent(in) :: i1, i2
1537 integer,
intent(in) :: ibeg, iend, jbeg, jend
1538 integer,
intent(in) :: iv
1539 integer,
intent(in) :: kord
1540 integer,
intent(in) :: km
1541 integer,
intent(in) :: kn
1543 real,
intent(in) :: pe1(i1:i2,km+1)
1544 real,
intent(in) :: pe2(i1:i2,kn+1)
1545 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1546 real,
intent(in) :: dp2(i1:i2,kn)
1547 real,
intent(in) :: q_min
1549 real,
intent(inout):: q2(i1:i2,kn)
1554 real pl, pr, qsum, dp, esl
1556 integer i, k, l, m, k0
1560 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1561 q4(1,i,k) = q1(i,j,k)
1578 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1579 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1580 if(pe2(i,k+1) <= pe1(i,l+1))
then 1582 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1583 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1584 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1589 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1590 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1591 (
r3*(1.+pl*(1.+pl))))
1594 if(pe2(i,k+1) > pe1(i,m+1) )
then 1596 qsum = qsum + dp1(i,m)*q4(1,i,m)
1598 dp = pe2(i,k+1)-pe1(i,m)
1600 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1601 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1610 123 q2(i,k) = qsum / dp2(i,k)
1621 integer,
intent(in):: i1, i2
1622 integer,
intent(in):: iv
1623 integer,
intent(in):: kord
1624 integer,
intent(in):: km
1625 integer,
intent(in):: kn
1626 real,
intent(in):: pe1(i1:i2,km+1)
1627 real,
intent(in):: pe2(i1:i2,kn+1)
1628 real,
intent(in) :: q1(i1:i2,km)
1629 real,
intent(out):: q2(i1:i2,kn)
1634 real pl, pr, qsum, dp, esl
1635 integer i, k, l, m, k0
1639 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1646 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1655 if( pe2(i,k+1) <= pe1(i,1) )
then 1658 elseif( pe2(i,k) < pe1(i,1) .and. pe2(i,k+1)>pe1(i,1) )
then 1662 if( pe2(i,k) <= pe1(i,1) )
then 1669 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1670 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1671 if(pe2(i,k+1) <= pe1(i,l+1))
then 1673 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1674 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1675 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1680 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1681 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1682 (
r3*(1.+pl*(1.+pl))))
1685 if(pe2(i,k+1) > pe1(i,m+1) )
then 1687 qsum = qsum + dp1(i,m)*q4(1,i,m)
1689 dp = pe2(i,k+1)-pe1(i,m)
1691 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1692 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1701 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1709 subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
1712 integer,
intent(in):: i1, i2
1713 integer,
intent(in):: km
1714 integer,
intent(in):: iv
1715 integer,
intent(in):: kord
1716 real,
intent(in) :: qs(i1:i2)
1717 real,
intent(in) :: delp(i1:i2,km)
1718 real,
intent(inout):: a4(4,i1:i2,km)
1719 real,
intent(in):: qmin
1721 logical,
dimension(i1:i2,km):: extm, ext5, ext6
1725 real bet, a_bot, grat
1726 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
1729 if ( iv .eq. -2 )
then 1732 q(i,1) = 1.5*a4(1,i,1)
1736 grat = delp(i,k-1) / delp(i,k)
1737 bet = 2. + grat + grat - gam(i,k)
1738 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
1739 gam(i,k+1) = grat / bet
1743 grat = delp(i,km-1) / delp(i,km)
1744 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
1745 (2. + grat + grat - gam(i,km))
1750 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
1755 grat = delp(i,2) / delp(i,1)
1756 bet = grat*(grat+0.5)
1757 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
1758 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
1763 d4(i) = delp(i,k-1) / delp(i,k)
1764 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
1765 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
1766 gam(i,k) = d4(i) / bet
1771 a_bot = 1. + d4(i)*(d4(i)+1.5)
1772 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
1773 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
1778 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
1784 if ( abs(kord) > 16 )
then 1788 a4(3,i,k) = q(i,k+1)
1789 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1802 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
1803 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
1808 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
1815 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 1817 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
1818 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
1820 if ( gam(i,k-1) > 0. )
then 1822 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
1825 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
1826 if ( iv==0 ) q(i,k) = max(0., q(i,k))
1834 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
1835 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
1841 a4(3,i,k) = q(i,k+1)
1846 if ( k==1 .or. k==km )
then 1848 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
1852 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
1855 if ( abs(kord) > 9 )
then 1857 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
1858 x1 = abs(a4(2,i,k)-a4(3,i,k))
1860 ext5(i,k) = abs(x0) > x1
1861 ext6(i,k) = abs(a4(4,i,k)) > x1
1874 a4(2,i,1) = max(0., a4(2,i,1))
1876 elseif ( iv==-1 )
then 1878 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
1880 elseif ( iv==2 )
then 1882 a4(2,i,1) = a4(1,i,1)
1883 a4(3,i,1) = a4(1,i,1)
1890 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
1897 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
1905 if ( abs(kord)<9 )
then 1908 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1909 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1910 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1911 max(a4(1,i,k), pmp_1, lac_1) )
1913 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1914 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1915 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1916 max(a4(1,i,k), pmp_2, lac_2) )
1918 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1921 elseif ( abs(kord)==9 )
then 1923 if ( extm(i,k) .and. extm(i,k-1) )
then 1925 a4(2,i,k) = a4(1,i,k)
1926 a4(3,i,k) = a4(1,i,k)
1928 else if ( extm(i,k) .and. extm(i,k+1) )
then 1930 a4(2,i,k) = a4(1,i,k)
1931 a4(3,i,k) = a4(1,i,k)
1933 else if ( extm(i,k) .and. a4(1,i,k)<qmin )
then 1935 a4(2,i,k) = a4(1,i,k)
1936 a4(3,i,k) = a4(1,i,k)
1939 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1941 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1942 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1943 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1944 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1945 max(a4(1,i,k), pmp_1, lac_1) )
1946 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1947 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1948 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1949 max(a4(1,i,k), pmp_2, lac_2) )
1950 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1954 elseif ( abs(kord)==10 )
then 1956 if( ext5(i,k) )
then 1957 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1958 a4(2,i,k) = a4(1,i,k)
1959 a4(3,i,k) = a4(1,i,k)
1960 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 1961 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1962 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1963 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1964 max(a4(1,i,k), pmp_1, lac_1) )
1965 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1966 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1967 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1968 max(a4(1,i,k), pmp_2, lac_2) )
1970 elseif( ext6(i,k) )
then 1971 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1972 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1973 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1974 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1975 max(a4(1,i,k), pmp_1, lac_1) )
1976 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1977 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1978 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1979 max(a4(1,i,k), pmp_2, lac_2) )
1984 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1986 elseif ( abs(kord)==12 )
then 1988 if( extm(i,k) )
then 1989 a4(2,i,k) = a4(1,i,k)
1990 a4(3,i,k) = a4(1,i,k)
1993 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
1995 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1996 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1997 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1998 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1999 max(a4(1,i,k), pmp_1, lac_1) )
2000 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2001 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2002 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2003 max(a4(1,i,k), pmp_2, lac_2) )
2004 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2008 elseif ( abs(kord)==13 )
then 2010 if( ext6(i,k) )
then 2011 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2013 a4(2,i,k) = a4(1,i,k)
2014 a4(3,i,k) = a4(1,i,k)
2019 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2021 elseif ( abs(kord)==14 )
then 2024 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2027 elseif ( abs(kord)==15 )
then 2029 if ( ext5(i,k) .and. ext5(i,k-1) )
then 2030 a4(2,i,k) = a4(1,i,k)
2031 a4(3,i,k) = a4(1,i,k)
2032 else if ( ext5(i,k) .and. ext5(i,k+1) )
then 2033 a4(2,i,k) = a4(1,i,k)
2034 a4(3,i,k) = a4(1,i,k)
2035 else if ( ext5(i,k) .and. a4(1,i,k)<qmin )
then 2036 a4(2,i,k) = a4(1,i,k)
2037 a4(3,i,k) = a4(1,i,k)
2038 elseif( ext6(i,k) )
then 2039 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2040 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2041 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2042 max(a4(1,i,k), pmp_1, lac_1) )
2043 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2044 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2045 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2046 max(a4(1,i,k), pmp_2, lac_2) )
2050 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2052 elseif ( abs(kord)==16 )
then 2054 if( ext5(i,k) )
then 2055 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2056 a4(2,i,k) = a4(1,i,k)
2057 a4(3,i,k) = a4(1,i,k)
2058 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2060 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2061 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2062 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2063 max(a4(1,i,k), pmp_1, lac_1) )
2065 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2066 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2067 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2068 max(a4(1,i,k), pmp_2, lac_2) )
2073 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2077 if ( ext5(i,k) .and. (ext5(i,k-1).or.ext5(i,k+1).or.a4(1,i,k)<qmin) )
then 2079 a4(2,i,k) = a4(1,i,k)
2080 a4(3,i,k) = a4(1,i,k)
2083 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2089 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2098 a4(3,i,km) = max(0., a4(3,i,km))
2100 elseif ( iv .eq. -1 )
then 2102 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2108 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2110 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2111 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2116 subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
2119 integer,
intent(in):: i1, i2
2120 integer,
intent(in):: km
2121 integer,
intent(in):: iv
2124 integer,
intent(in):: kord
2125 real,
intent(in) :: qs(i1:i2)
2126 real,
intent(in) :: delp(i1:i2,km)
2127 real,
intent(inout):: a4(4,i1:i2,km)
2129 logical,
dimension(i1:i2,km):: extm, ext5, ext6
2133 real bet, a_bot, grat
2134 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
2137 if ( iv .eq. -2 )
then 2140 q(i,1) = 1.5*a4(1,i,1)
2144 grat = delp(i,k-1) / delp(i,k)
2145 bet = 2. + grat + grat - gam(i,k)
2146 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
2147 gam(i,k+1) = grat / bet
2151 grat = delp(i,km-1) / delp(i,km)
2152 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
2153 (2. + grat + grat - gam(i,km))
2158 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
2163 grat = delp(i,2) / delp(i,1)
2164 bet = grat*(grat+0.5)
2165 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
2166 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
2171 d4(i) = delp(i,k-1) / delp(i,k)
2172 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
2173 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
2174 gam(i,k) = d4(i) / bet
2179 a_bot = 1. + d4(i)*(d4(i)+1.5)
2180 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
2181 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
2186 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
2191 if ( abs(kord) > 16 )
then 2195 a4(3,i,k) = q(i,k+1)
2196 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2210 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
2211 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
2216 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
2223 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 2225 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
2226 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
2228 if ( gam(i,k-1) > 0. )
then 2230 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
2233 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
2234 if ( iv==0 ) q(i,k) = max(0., q(i,k))
2242 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
2243 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
2249 a4(3,i,k) = q(i,k+1)
2254 if ( k==1 .or. k==km )
then 2256 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
2260 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
2263 if ( abs(kord) > 9 )
then 2265 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
2266 x1 = abs(a4(2,i,k)-a4(3,i,k))
2268 ext5(i,k) = abs(x0) > x1
2269 ext6(i,k) = abs(a4(4,i,k)) > x1
2282 a4(2,i,1) = max(0., a4(2,i,1))
2284 elseif ( iv==-1 )
then 2286 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2288 elseif ( iv==2 )
then 2290 a4(2,i,1) = a4(1,i,1)
2291 a4(3,i,1) = a4(1,i,1)
2298 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
2305 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
2313 if ( abs(kord)<9 )
then 2316 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2317 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2318 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2319 max(a4(1,i,k), pmp_1, lac_1) )
2321 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2322 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2323 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2324 max(a4(1,i,k), pmp_2, lac_2) )
2326 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2329 elseif ( abs(kord)==9 )
then 2331 if ( extm(i,k) .and. extm(i,k-1) )
then 2333 a4(2,i,k) = a4(1,i,k)
2334 a4(3,i,k) = a4(1,i,k)
2336 else if ( extm(i,k) .and. extm(i,k+1) )
then 2338 a4(2,i,k) = a4(1,i,k)
2339 a4(3,i,k) = a4(1,i,k)
2342 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2344 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2345 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2346 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2347 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2348 max(a4(1,i,k), pmp_1, lac_1) )
2349 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2350 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2351 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2352 max(a4(1,i,k), pmp_2, lac_2) )
2353 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2357 elseif ( abs(kord)==10 )
then 2359 if( ext5(i,k) )
then 2360 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2361 a4(2,i,k) = a4(1,i,k)
2362 a4(3,i,k) = a4(1,i,k)
2363 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2364 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2365 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2366 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2367 max(a4(1,i,k), pmp_1, lac_1) )
2368 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2369 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2370 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2371 max(a4(1,i,k), pmp_2, lac_2) )
2373 elseif( ext6(i,k) )
then 2374 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2375 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2376 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2377 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2378 max(a4(1,i,k), pmp_1, lac_1) )
2379 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2380 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2381 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2382 max(a4(1,i,k), pmp_2, lac_2) )
2387 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2389 elseif ( abs(kord)==12 )
then 2391 if( extm(i,k) )
then 2393 a4(2,i,k) = a4(1,i,k)
2394 a4(3,i,k) = a4(1,i,k)
2397 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2399 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2400 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2401 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2402 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2403 max(a4(1,i,k), pmp_1, lac_1) )
2404 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2405 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2406 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2407 max(a4(1,i,k), pmp_2, lac_2) )
2408 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2412 elseif ( abs(kord)==13 )
then 2414 if( ext6(i,k) )
then 2415 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2417 a4(2,i,k) = a4(1,i,k)
2418 a4(3,i,k) = a4(1,i,k)
2423 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2425 elseif ( abs(kord)==14 )
then 2428 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2431 elseif ( abs(kord)==15 )
then 2433 if ( ext5(i,k) )
then 2434 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2436 a4(2,i,k) = a4(1,i,k)
2437 a4(3,i,k) = a4(1,i,k)
2439 elseif( ext6(i,k) )
then 2441 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2442 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2443 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2444 max(a4(1,i,k), pmp_1, lac_1) )
2445 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2446 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2447 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2448 max(a4(1,i,k), pmp_2, lac_2) )
2452 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2454 elseif ( abs(kord)==16 )
then 2456 if( ext5(i,k) )
then 2457 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2458 a4(2,i,k) = a4(1,i,k)
2459 a4(3,i,k) = a4(1,i,k)
2460 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2462 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2463 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2464 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2465 max(a4(1,i,k), pmp_1, lac_1) )
2467 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2468 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2469 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2470 max(a4(1,i,k), pmp_2, lac_2) )
2475 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2479 if ( ext5(i,k) .and. (ext5(i,k-1) .or. ext5(i,k+1)) )
then 2481 a4(2,i,k) = a4(1,i,k)
2482 a4(3,i,k) = a4(1,i,k)
2485 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2491 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2500 a4(3,i,km) = max(0., a4(3,i,km))
2502 elseif ( iv .eq. -1 )
then 2504 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2510 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2512 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2513 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2520 integer,
intent(in) :: im
2521 integer,
intent(in) :: iv
2522 logical,
intent(in) :: extm(im)
2523 real ,
intent(inout) :: a4(4,im)
2531 if( a4(1,i)<=0.)
then 2536 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2537 if( (a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12) < 0. )
then 2539 if( a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i) )
then 2543 elseif( a4(3,i) > a4(2,i) )
then 2544 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2545 a4(3,i) = a4(2,i) - a4(4,i)
2547 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2548 a4(2,i) = a4(3,i) - a4(4,i)
2554 elseif ( iv==1 )
then 2556 if( (a4(1,i)-a4(2,i))*(a4(1,i)-a4(3,i))>=0. )
then 2561 da1 = a4(3,i) - a4(2,i)
2564 if(a6da < -da2)
then 2565 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2566 a4(3,i) = a4(2,i) - a4(4,i)
2567 elseif(a6da > da2)
then 2568 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2569 a4(2,i) = a4(3,i) - a4(4,i)
2581 da1 = a4(3,i) - a4(2,i)
2584 if(a6da < -da2)
then 2585 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2586 a4(3,i) = a4(2,i) - a4(4,i)
2587 elseif(a6da > da2)
then 2588 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2589 a4(2,i) = a4(3,i) - a4(4,i)
2598 subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
2601 integer,
intent(in):: iv
2602 integer,
intent(in):: i1
2603 integer,
intent(in):: i2
2604 integer,
intent(in):: km
2605 integer,
intent(in):: kord
2607 real ,
intent(in):: delp(i1:i2,km)
2610 real ,
intent(inout):: a4(4,i1:i2,km)
2627 integer i, k, km1, lmt, it
2629 real a1, a2, c1, c2, c3, d1, d2
2630 real qm, dq, lac, qmp, pmp
2637 delq(i,k-1) = a4(1,i,k) - a4(1,i,k-1)
2638 d4(i,k ) = delp(i,k-1) + delp(i,k)
2644 c1 = (delp(i,k-1)+0.5*delp(i,k))/d4(i,k+1)
2645 c2 = (delp(i,k+1)+0.5*delp(i,k))/d4(i,k)
2646 df2(i,k) = delp(i,k)*(c1*delq(i,k) + c2*delq(i,k-1)) / &
2647 (d4(i,k)+delp(i,k+1))
2648 dc(i,k) = sign( min(abs(df2(i,k)), &
2649 max(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))-a4(1,i,k), &
2650 a4(1,i,k)-min(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))), df2(i,k) )
2660 c1 = delq(i,k-1)*delp(i,k-1) / d4(i,k)
2661 a1 = d4(i,k-1) / (d4(i,k) + delp(i,k-1))
2662 a2 = d4(i,k+1) / (d4(i,k) + delp(i,k))
2663 a4(2,i,k) = a4(1,i,k-1) + c1 + 2./(d4(i,k-1)+d4(i,k+1)) * &
2664 ( delp(i,k)*(c1*(a1 - a2)+a2*dc(i,k-1)) - &
2665 delp(i,k-1)*a1*dc(i,k ) )
2676 qm = (d2*a4(1,i,1)+d1*a4(1,i,2)) / (d1+d2)
2677 dq = 2.*(a4(1,i,2)-a4(1,i,1)) / (d1+d2)
2678 c1 = 4.*(a4(2,i,3)-qm-d2*dq) / ( d2*(2.*d2*d2+d1*(d2+3.*d1)) )
2679 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2680 a4(2,i,2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
2683 a4(2,i,1) = d1*(2.*c1*d1**2-c3) + a4(2,i,2)
2688 a4(2,i,2) = max( a4(2,i,2), min(a4(1,i,1), a4(1,i,2)) )
2689 a4(2,i,2) = min( a4(2,i,2), max(a4(1,i,1), a4(1,i,2)) )
2690 dc(i,1) = 0.5*(a4(2,i,2) - a4(1,i,1))
2697 a4(2,i,1) = max(0., a4(2,i,1))
2698 a4(2,i,2) = max(0., a4(2,i,2))
2700 elseif( iv==-1 )
then 2702 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2704 elseif( abs(iv)==2 )
then 2706 a4(2,i,1) = a4(1,i,1)
2707 a4(3,i,1) = a4(1,i,1)
2716 qm = (d2*a4(1,i,km)+d1*a4(1,i,km1)) / (d1+d2)
2717 dq = 2.*(a4(1,i,km1)-a4(1,i,km)) / (d1+d2)
2718 c1 = (a4(2,i,km1)-qm-d2*dq) / (d2*(2.*d2*d2+d1*(d2+3.*d1)))
2719 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2720 a4(2,i,km) = qm - c1*d1*d2*(d2+3.*d1)
2723 a4(3,i,km) = d1*(8.*c1*d1**2-c3) + a4(2,i,km)
2728 a4(2,i,km) = max( a4(2,i,km), min(a4(1,i,km), a4(1,i,km1)) )
2729 a4(2,i,km) = min( a4(2,i,km), max(a4(1,i,km), a4(1,i,km1)) )
2730 dc(i,km) = 0.5*(a4(1,i,km) - a4(2,i,km))
2739 if( a4(3,i,km) * a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2740 d1 = a4(1,i,km) - a4(2,i,km)
2741 d2 = a4(3,i,km) - a4(1,i,km)
2742 if ( d1*d2 < 0. )
then 2743 a4(2,i,km) = a4(1,i,km)
2744 a4(3,i,km) = a4(1,i,km)
2746 dq = sign(min(abs(d1),abs(d2),0.5*abs(delq(i,km-1))), d1)
2747 a4(2,i,km) = a4(1,i,km) - dq
2748 a4(3,i,km) = a4(1,i,km) + dq
2754 a4(2,i,km) = max(0.,a4(2,i,km))
2755 a4(3,i,km) = max(0.,a4(3,i,km))
2759 if( a4(1,i,km)*a4(3,i,km) <= 0. ) a4(3,i,km) = 0.
2766 a4(3,i,k) = a4(2,i,k+1)
2776 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2790 h2(i,k) = 2.*(dc(i,k+1)/delp(i,k+1) - dc(i,k-1)/delp(i,k-1)) &
2791 / ( delp(i,k)+0.5*(delp(i,k-1)+delp(i,k+1)) ) &
2807 qmp = a4(1,i,k) + pmp
2808 lac = a4(1,i,k) + fac*h2(i,k-1) + dc(i,k)
2809 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), qmp, lac)), &
2810 max(a4(1,i,k), qmp, lac) )
2815 qmp = a4(1,i,k) - pmp
2816 lac = a4(1,i,k) + fac*h2(i,k+1) - dc(i,k)
2817 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), qmp, lac)), &
2818 max(a4(1,i,k), qmp, lac))
2822 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2825 if (iv == 0 .and. kord >= 6 ) &
2833 if (iv == 0) lmt = min(2, lmt)
2838 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2841 if(kord/=6)
call ppm_limiters(dc(i1,k), a4(1,i1,k), it, lmt)
2847 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2858 real ,
intent(in):: dm(*)
2859 integer,
intent(in) :: itot
2860 integer,
intent(in) :: lmt
2864 real ,
intent(inout) :: a4(4,*)
2873 if ( lmt == 3 )
return 2878 if(dm(i) == 0.)
then 2883 da1 = a4(3,i) - a4(2,i)
2886 if(a6da < -da2)
then 2887 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2888 a4(3,i) = a4(2,i) - a4(4,i)
2889 elseif(a6da > da2)
then 2890 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2891 a4(2,i) = a4(3,i) - a4(4,i)
2896 elseif (lmt == 1)
then 2902 a4(2,i) = a4(1,i)-sign(min(abs(qmp),abs(a4(2,i)-a4(1,i))), qmp)
2903 a4(3,i) = a4(1,i)+sign(min(abs(qmp),abs(a4(3,i)-a4(1,i))), qmp)
2904 a4(4,i) = 3.*( 2.*a4(1,i) - (a4(2,i)+a4(3,i)) )
2907 elseif (lmt == 2)
then 2911 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2912 fmin = a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12 2913 if( fmin < 0. )
then 2914 if(a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i))
then 2918 elseif(a4(3,i) > a4(2,i))
then 2919 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2920 a4(3,i) = a4(2,i) - a4(4,i)
2922 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2923 a4(2,i) = a4(3,i) - a4(4,i)
2935 subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
2936 integer,
intent(in) :: km, i1, i2
2937 real ,
intent(in) :: dp(i1:i2,km)
2938 real ,
intent(in) :: dq(i1:i2,km)
2939 real ,
intent(in) :: d4(i1:i2,km)
2940 real ,
intent(in) :: df2(i1:i2,km)
2941 real ,
intent(in) :: dm(i1:i2,km)
2943 real ,
intent(inout) :: a4(4,i1:i2,km)
2954 rat(i,k) = dq(i,k-1) / d4(i,k)
2961 f(i,k) = (rat(i,k+1) - rat(i,k)) &
2962 / ( dp(i,k-1)+dp(i,k)+dp(i,k+1) )
2968 if(f(i,k+1)*f(i,k-1)<0. .and. df2(i,k)/=0.)
then 2969 dg2 = (f(i,k+1)-f(i,k-1))*((dp(i,k+1)-dp(i,k-1))**2 &
2970 + d4(i,k)*d4(i,k+1) )
2971 alfa(i,k) = max(0., min(0.5, -0.1875*dg2/df2(i,k)))
2980 a4(2,i,k) = (1.-alfa(i,k-1)-alfa(i,k)) * a4(2,i,k) + &
2981 alfa(i,k-1)*(a4(1,i,k)-dm(i,k)) + &
2982 alfa(i,k)*(a4(1,i,k-1)+dm(i,k-1))
2991 subroutine rst_remap(km, kn, is,ie,js,je, isd,ied,jsd,jed, nq, ntp, &
2992 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, &
2993 delp, u, v, w, delz, pt, q, qdiag, &
2994 ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, &
2995 domain, square_domain)
3000 integer,
intent(in):: km
3001 integer,
intent(in):: kn
3002 integer,
intent(in):: nq, ntp
3003 integer,
intent(in):: is,ie,isd,ied
3004 integer,
intent(in):: js,je,jsd,jed
3005 logical,
intent(in):: hydrostatic, make_nh, square_domain
3006 real,
intent(IN) :: ptop
3007 real,
intent(in) :: ak_r(km+1)
3008 real,
intent(in) :: bk_r(km+1)
3009 real,
intent(in) :: ak(kn+1)
3010 real,
intent(in) :: bk(kn+1)
3011 real,
intent(in):: delp_r(is:ie,js:je,km)
3012 real,
intent(in):: u_r(is:ie, js:je+1,km)
3013 real,
intent(in):: v_r(is:ie+1,js:je ,km)
3014 real,
intent(inout):: pt_r(is:ie,js:je,km)
3015 real,
intent(in):: w_r(is:ie,js:je,km)
3016 real,
intent(in):: q_r(is:ie,js:je,km,1:ntp)
3017 real,
intent(in):: qdiag_r(is:ie,js:je,km,ntp+1:nq)
3018 real,
intent(inout)::delz_r(is:ie,js:je,km)
3019 type(domain2d),
intent(INOUT) :: domain
3021 real,
intent(out):: delp(isd:ied,jsd:jed,kn)
3022 real,
intent(out):: u(isd:ied ,jsd:jed+1,kn)
3023 real,
intent(out):: v(isd:ied+1,jsd:jed ,kn)
3024 real,
intent(out):: w(isd: ,jsd: ,1:)
3025 real,
intent(out):: pt(isd:ied ,jsd:jed ,kn)
3026 real,
intent(out):: q(isd:ied,jsd:jed,kn,1:ntp)
3027 real,
intent(out):: qdiag(isd:ied,jsd:jed,kn,ntp+1:nq)
3028 real,
intent(out):: delz(isd:,jsd:,1:)
3031 real ps(isd:ied,jsd:jed)
3032 real pe1(is:ie,km+1)
3033 real pe2(is:ie,kn+1)
3034 real pv1(is:ie+1,km+1)
3035 real pv2(is:ie+1,kn+1)
3038 integer,
parameter:: kord=4
3040 #ifdef HYDRO_DELZ_REMAP 3041 if (is_master() .and. .not. hydrostatic)
then 3043 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ' 3048 #ifdef HYDRO_DELZ_EXTRAP 3049 if (is_master() .and. .not. hydrostatic)
then 3051 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ABOVE INPUT MODEL TOP ' 3056 #ifdef ZERO_W_EXTRAP 3057 if (is_master() .and. .not. hydrostatic)
then 3059 print*,
' REMAPPING IC: INITIALIZING W TO ZERO ABOVE INPUT MODEL TOP ' 3064 r_vir = rvgas/rdgas - 1.
3079 ps(i,j) = ps(i,j) + delp_r(i,j,k)
3085 if ( square_domain )
then 3086 call mpp_update_domains(ps, domain, whalo=1, ehalo=1, shalo=1, nhalo=1, complete=.true.)
3088 call mpp_update_domains(ps, domain, complete=.true.)
3097 pt_r(i,j,k) = pt_r(i,j,k) * virq(q_r(i,j,k,:))
3099 pt_r(i,j,k) = pt_r(i,j,k) * (1.+r_vir*q_r(i,j,k,1))
3115 pe1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i,j-1)+ps(i,j))
3121 pe2(i,k) = ak(k) + 0.5*bk(k)*(ps(i,j-1)+ps(i,j))
3125 call remap_2d(km, pe1, u_r(is:ie,j:j,1:km), &
3126 kn, pe2, u(is:ie,j:j,1:kn), &
3129 if ( j /= (je+1) )
then 3136 pe1(i,k) = ak_r(k) + bk_r(k)*ps(i,j)
3142 pe2(i,k) = ak(k) + bk(k)*ps(i,j)
3151 delp(i,j,k) = pe2(i,k+1) - pe2(i,k)
3160 call remap_2d(km, pe1, q_r(is:ie,j:j,1:km,iq:iq), &
3161 kn, pe2, q(is:ie,j:j,1:kn,iq:iq), &
3165 call remap_2d(km, pe1, qdiag_r(is:ie,j:j,1:km,iq:iq), &
3166 kn, pe2, qdiag(is:ie,j:j,1:kn,iq:iq), &
3171 if ( .not. hydrostatic .and. .not. make_nh)
then 3173 call remap_2d(km, pe1, w_r(is:ie,j:j,1:km), &
3174 kn, pe2, w(is:ie,j:j,1:kn), &
3177 #ifdef ZERO_W_EXTRAP 3180 if (pe2(i,k) < pe1(i,1))
then 3187 #ifndef HYDRO_DELZ_REMAP 3191 delz_r(i,j,k) = -delz_r(i,j,k)/delp_r(i,j,k)
3194 call remap_2d(km, pe1, delz_r(is:ie,j:j,1:km), &
3195 kn, pe2, delz(is:ie,j:j,1:kn), &
3199 delz(i,j,k) = -delz(i,j,k)*delp(i,j,k)
3208 pe1(i,k) = log(pe1(i,k))
3213 pe2(i,k) = log(pe2(i,k))
3217 call remap_2d(km, pe1, pt_r(is:ie,j:j,1:km), &
3218 kn, pe2, pt(is:ie,j:j,1:kn), &
3221 #ifdef HYDRO_DELZ_REMAP 3225 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3229 #ifdef HYDRO_DELZ_EXTRAP 3233 if (pe2(i,k) < pe1(i,1))
then 3234 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3244 pv1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1,j)+ps(i,j))
3249 pv2(i,k) = ak(k) + 0.5*bk(k)*(ps(i-1,j)+ps(i,j))
3253 call remap_2d(km, pv1, v_r(is:ie+1,j:j,1:km), &
3254 kn, pv2, v(is:ie+1,j:j,1:kn), &
3265 pt(i,j,k) = pt(i,j,k) / virq(q(i,j,k,:))
3267 pt(i,j,k) = pt(i,j,k) / (1.+r_vir*q(i,j,k,1))
3277 subroutine mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
3290 integer,
intent(in):: i1, i2, km, kn, kord, iv
3291 real,
intent(in ):: pe1(i1:i2,km+1), pe2(i1:i2,kn+1)
3296 real,
intent(in ):: q1(i1:i2,km)
3297 real,
intent(out):: q2(i1:i2,kn)
3298 real,
intent(IN) :: ptop
3305 real pl, pr, tt, delp, qsum, dpsum, esl
3309 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
3315 call cs_profile( qs, a4, dp1, km, i1, i2, iv, kord )
3323 #ifdef NGGPS_SUBMITTED 3325 a4(2,i,km) = q1(i,km)
3326 a4(3,i,km) = q1(i,km)
3335 if(pe2(i,k) .le. pe1(i,1))
then 3338 elseif(pe2(i,k) .ge. pe1(i,km+1))
then 3340 #ifdef NGGPS_SUBMITTED 3341 q2(i,k) = a4(3,i,km)
3349 if( pe2(i,k) .ge. pe1(i,l) .and. &
3350 pe2(i,k) .le. pe1(i,l+1) )
then 3352 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
3353 if(pe2(i,k+1) .le. pe1(i,l+1))
then 3356 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
3357 tt =
r3*(pr*(pr+pl)+pl**2)
3358 q2(i,k) = a4(2,i,l) + 0.5*(a4(4,i,l)+a4(3,i,l) &
3359 - a4(2,i,l))*(pr+pl) - a4(4,i,l)*tt
3363 delp = pe1(i,l+1) - pe2(i,k)
3364 tt =
r3*(1.+pl*(1.+pl))
3365 qsum = delp*(a4(2,i,l)+0.5*(a4(4,i,l)+ &
3366 a4(3,i,l)-a4(2,i,l))*(1.+pl)-a4(4,i,l)*tt)
3376 if( pe2(i,k+1) .gt. pe1(i,l+1) )
then 3380 qsum = qsum + dp1(i,l)*q1(i,l)
3381 dpsum = dpsum + dp1(i,l)
3383 delp = pe2(i,k+1)-pe1(i,l)
3384 esl = delp / dp1(i,l)
3385 qsum = qsum + delp * (a4(2,i,l)+0.5*esl* &
3386 (a4(3,i,l)-a4(2,i,l)+a4(4,i,l)*(1.-
r23*esl)) )
3387 dpsum = dpsum + delp
3392 delp = pe2(i,k+1) - pe1(i,km+1)
3395 #ifdef NGGPS_SUBMITTED 3396 qsum = qsum + delp * a4(3,i,km)
3398 qsum = qsum + delp * q1(i,km)
3400 dpsum = dpsum + delp
3402 123 q2(i,k) = qsum / dpsum
3407 end subroutine mappm 3413 subroutine moist_cv(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3414 ice_wat, snowwat, graupel, q, qd, cvm, t1)
3415 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3416 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3417 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3418 real,
intent(out),
dimension(is:ie):: cvm, qd
3419 real,
intent(in),
optional:: t1(is:ie)
3421 real,
parameter:: t_i0 = 15.
3422 real,
dimension(is:ie):: qv, ql, qs
3428 if (
present(t1) )
then 3430 qd(i) = max(0., q(i,j,k,liq_wat))
3431 if ( t1(i) >
tice )
then 3433 elseif ( t1(i) <
tice-t_i0 )
then 3436 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3438 ql(i) = qd(i) - qs(i)
3439 qv(i) = max(0.,q(i,j,k,sphum))
3448 qv(i) = max(0.,q(i,j,k,sphum))
3449 qs(i) = max(0.,q(i,j,k,liq_wat))
3452 cvm(i) = (1.-qv(i))*
cv_air*vicvqd(q(i,j,k,1:num_gas)) + qv(i)*
cv_vap 3460 qv(i) = q(i,j,k,sphum)
3461 ql(i) = q(i,j,k,liq_wat)
3462 qs(i) = q(i,j,k,ice_wat)
3463 qd(i) = ql(i) + qs(i)
3468 qv(i) = q(i,j,k,sphum)
3469 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3471 cvm(i) = (1.-(qv(i)+qd(i)))*
cv_air*vicvqd(q(i,j,k,1:num_gas)) + qv(i)*
cv_vap + qd(i)*
c_liq 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)
3481 qd(i) = ql(i) + qs(i)
3490 qv(i) = q(i,j,k,sphum)
3491 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3492 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3493 qd(i) = ql(i) + qs(i)
3501 call mpp_error (note,
'fv_mapz::moist_cv - using default cv_air')
3505 cvm(i) =
cv_air*vicvqd(q(i,j,k,1:num_gas))
3516 subroutine moist_cp(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3517 ice_wat, snowwat, graupel, q, qd, cpm, t1)
3519 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3520 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3521 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3522 real,
intent(out),
dimension(is:ie):: cpm, qd
3523 real,
intent(in),
optional:: t1(is:ie)
3525 real,
parameter:: t_i0 = 15.
3526 real,
dimension(is:ie):: qv, ql, qs
3532 if (
present(t1) )
then 3534 qd(i) = max(0., q(i,j,k,liq_wat))
3535 if ( t1(i) >
tice )
then 3537 elseif ( t1(i) <
tice-t_i0 )
then 3540 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3542 ql(i) = qd(i) - qs(i)
3543 qv(i) = max(0.,q(i,j,k,sphum))
3545 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air * vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3547 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3552 qv(i) = max(0.,q(i,j,k,sphum))
3553 qs(i) = max(0.,q(i,j,k,liq_wat))
3556 cpm(i) = (1.-qv(i))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor
3558 cpm(i) = (1.-qv(i))*cp_air + qv(i)*cp_vapor
3565 qv(i) = q(i,j,k,sphum)
3566 ql(i) = q(i,j,k,liq_wat)
3567 qs(i) = q(i,j,k,ice_wat)
3568 qd(i) = ql(i) + qs(i)
3570 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3572 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3577 qv(i) = q(i,j,k,sphum)
3578 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3580 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + qd(i)*
c_liq 3582 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + qd(i)*
c_liq 3587 qv(i) = q(i,j,k,sphum)
3588 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3589 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat)
3590 qd(i) = ql(i) + qs(i)
3592 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3594 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3599 qv(i) = q(i,j,k,sphum)
3600 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3601 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3602 qd(i) = ql(i) + qs(i)
3604 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3606 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3610 call mpp_error (note,
'fv_mapz::moist_cp - using default cp_air')
3614 cpm(i) = cp_air*vicpqd(q(i,j,k,:))
real, parameter c_liq
GFS: heat capacity of water at 0C.
pure real function, public vicpqd(q)
subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
subroutine timing_off(blk_name)
The subroutine 'timing_off' stops a timer.
The type 'fv_grid_type' is made up of grid-dependent information from fv_grid_tools and fv_grid_utils...
subroutine, public fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, te0, qv, ql, qi, qr, qs, qg, hs, dpln, delz, pt, dp, q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
The subroutine 'fv_sat_adj' performs the fast processes in the GFDL microphysics. ...
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)
The subroutine 'moist_cv' computes the FV3-consistent moist heat capacity under constant volume...
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
The subroutine 'mappm' is a general-purpose routine for remapping one set of vertical levels to anoth...
The module 'multi_gases' peforms multi constitutents computations.
subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, peln, pkz, ptop)
subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
The function 'g_sum' is the fast version of 'globalsum'.
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)
The subroutine 'compute_total_energy' performs the FV3-consistent computation of the global total ene...
subroutine ppm_limiters(dm, a4, itot, lmt)
real, parameter c_ice
heat capacity of ice at -15.C
pure real function, public virqd(q)
subroutine remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
real, parameter consv_min
below which no correction applies
The module 'fv_timing' contains FV3 timers.
pure real function, public virq(q)
real, parameter cv_vap
1384.5
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, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init)
The subroutine 'Lagrangian_to_Eulerian' remaps deformed Lagrangian layers back to the reference Euler...
subroutine cs_limiters(im, extm, a4, iv)
real, parameter t_min
below which applies stricter constraint
real, parameter, public ptop_min
The module 'fv_mapz' contains the vertical mapping routines .
subroutine, public fillz(im, km, nq, q, dp)
The subroutine 'fillz' is for mass-conservative filling of nonphysical negative values in the tracers...
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)
The subroutine 'rst_remap' remaps all variables required for a restart.
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
subroutine map_scalar(km, pe1, q1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine 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)
The subroutine 'moist_cp' computes the FV3-consistent moist heat capacity under constant pressure...
subroutine timing_on(blk_name)
The subroutine 'timing_on' starts a timer.
subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
The module 'fv_grid_utils' contains routines for setting up and computing grid-related quantities...
subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
real, parameter cv_air
= rdgas * (7/2-1) = 2.5*rdgas=717.68
real(kind=4), public e_flux
subroutine, public qs_init(kmp)
The subroutine 'qs_init' initializes lookup tables for the saturation mixing ratio.
subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
The module 'fv_cmp' implements the fast procesesses in the GFDL microphysics >
subroutine map1_ppm(km, pe1, q1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
pure real function, public vicvqd(q)