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)
204 #if !defined(CCPP) && defined(TRANSITION) 206 real,
volatile:: volatile_var
216 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1
218 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1, dpln
220 real,
dimension(is:ie,km) :: q2, dp2
221 real,
dimension(is:ie,km+1):: pe1, pe2, pk1, pk2, pn2, phis
222 real,
dimension(is:ie+1,km+1):: pe0, pe3
223 real,
dimension(is:ie):: gz, cvm, qv
224 real rcp, rg, rrg, bkh, dtmp, k1k
226 logical:: fast_mp_consv
231 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, iq, n, kp, k_next
234 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, iq, n, kmp, kp, k_next
238 ccpp_associate: associate( fast_mp_consv => ccpp_interstitial%fast_mp_consv, &
239 kmp => ccpp_interstitial%kmp )
247 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
248 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
249 rainwat = get_tracer_index(model_atmos,
'rainwat')
250 snowwat = get_tracer_index(model_atmos,
'snowwat')
251 graupel = get_tracer_index(model_atmos,
'graupel')
252 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
254 if ( do_sat_adj )
then 255 fast_mp_consv = (.not.do_adiabatic_init) .and. consv>
consv_min 259 if ( pfull(k) > 10.e2 )
exit 286 pe2(i,km+1) = pe(i,km+1,j)
289 if ( j /= (je+1) )
then 290 if ( kord_tm < 0 )
then 292 if ( hydrostatic )
then 297 pkz(i,j,k) = (pk(i,j,k+1)-pk(i,j,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
298 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)))
299 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
301 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)))
309 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
310 ice_wat, snowwat, graupel, q, gz, cvm)
314 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
316 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
318 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)))
323 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)))
325 pt(i,j,k) = pt(i,j,k)*exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
334 elseif ( hydrostatic )
then 335 call pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, ptop)
340 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)))
342 te(i,j,k) = 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
343 v(i,j,k)**2+v(i+1,j,k)**2 - &
344 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)) &
345 + cp_air*pt(i,j,k)*pkz(i,j,k)
350 if ( .not. hydrostatic )
then 353 delz(i,j,k) = -delz(i,j,k) / delp(i,j,k)
360 ps(i,j) = pe1(i,km+1)
367 pe2(i,k) = ak(k) + bk(k)*pe(i,km+1,j)
372 dp2(i,k) = pe2(i,k+1) - pe2(i,k)
381 delp(i,j,k) = dp2(i,k)
395 pn2(i, 1) = peln(i, 1,j)
396 pn2(i,km+1) = peln(i,km+1,j)
397 pk2(i, 1) = pk1(i, 1)
398 pk2(i,km+1) = pk1(i,km+1)
403 pn2(i,k) = log(pe2(i,k))
404 pk2(i,k) = exp(akap*pn2(i,k))
408 if ( kord_tm<0 )
then 414 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm),
t_min)
419 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
426 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
427 is, ie, isd, ied, jsd, jed, 0., fill)
428 elseif ( nq > 0 )
then 431 call map1_q2(km, pe1, q(isd,jsd,1,iq), &
433 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
434 if (fill)
call fillz(ie-is+1, km, 1, q2, dp2)
437 q(i,j,k,iq) = q2(i,k)
443 if ( .not. hydrostatic )
then 445 call map1_ppm (km, pe1, w, ws(is,j), &
447 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
451 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
454 delz(i,j,k) = -delz(i,j,k)*dp2(i,k)
477 pe3(i,k) = omga(i,j,k-1)
484 pe0(i,k) = peln(i,k,j)
485 peln(i,k,j) = pn2(i,k)
493 if ( hydrostatic )
then 496 pkz(i,j,k) = (pk2(i,k+1)-pk2(i,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
498 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)))
506 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
507 ice_wat, snowwat, graupel, q, gz, cvm)
511 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
513 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
515 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
518 if ( kord_tm < 0 )
then 521 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)))
523 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
531 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)))
533 pkz(i,j,k) = exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
538 if ( last_step .and. (.not.adiabatic) )
then 540 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
552 dp2(i,k) = 0.5*(peln(i,k,j) + peln(i,k+1,j))
560 if( dp2(i,n) <= pe0(i,k+1) .and. dp2(i,n) >= pe0(i,k) )
then 561 omga(i,j,n) = pe3(i,k) + (pe3(i,k+1) - pe3(i,k)) * &
562 (dp2(i,n)-pe0(i,k)) / (pe0(i,k+1)-pe0(i,k) )
581 pe0(i,k) = 0.5*(pe(i,k,j-1)+pe1(i,k))
588 pe3(i,k) = ak(k) + bkh*(pe(i,km+1,j-1)+pe1(i,km+1))
592 call map1_ppm( km, pe0(is:ie,:), u, gz, &
593 km, pe3(is:ie,:), u, &
594 is, ie, j, isd, ied, jsd, jed+1, -1, kord_mt)
607 pe0(i,k) = 0.5*(pe(i-1,k, j)+pe(i,k, j))
608 pe3(i,k) = ak(k) + bkh*(pe(i-1,km+1,j)+pe(i,km+1,j))
613 km, pe3, v, is, ie+1, &
614 j, isd, ied+1, jsd, jed, -1, kord_mt)
619 ua(i,j,k) = pe2(i,k+1)
625 #if defined(CCPP) && defined(__GFORTRAN__) 679 pe(i,k,j) = ua(i,j,k-1)
685 if( last_step .and. (.not.do_adiabatic_init) )
then 691 if ( hydrostatic )
then 695 gz(i) = gz(i) + rg*pt(i,j,k)*(peln(i,k+1,j)-peln(i,k,j))
699 te_2d(i,j) = pe(i,km+1,j)*hs(i,j) - pe(i,1,j)*gz(i)
704 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*pt(i,j,k) + &
705 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
706 v(i,j,k)**2+v(i+1,j,k)**2 - &
707 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)))
713 phis(i,km+1) = hs(i,j)
717 phis(i,k) = phis(i,k+1) - grav*delz(i,j,k)
723 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
724 ice_wat, snowwat, graupel, q, gz, cvm)
729 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)) + &
731 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))) + &
733 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
734 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
735 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
740 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)) + &
742 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)) + &
744 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
745 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
746 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
753 te_2d(i,j) = te0_2d(i,j) - te_2d(i,j)
754 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
758 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
761 if ( hydrostatic )
then 763 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
770 dtmp = consv*
g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.)
771 e_flux = dtmp / (grav*pdt*4.*pi*radius**2)
773 if ( hydrostatic )
then 774 dtmp = dtmp / (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
776 dtmp = dtmp / (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
785 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
789 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
792 if ( hydrostatic )
then 794 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
801 if ( hydrostatic )
then 802 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
803 (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
805 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
806 (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
815 if ( do_sat_adj )
then 818 if (ccpp_initialized(cdata))
then 820 call ccpp_physics_run(cdata, suite_name=trim(ccpp_suite), group_name=
'fast_physics', ierr=ierr)
822 call ccpp_physics_run(cdata, group_name=
'fast_physics', ierr=ierr)
824 if (ierr/=0)
call mpp_error(fatal,
"Call to ccpp_physics_run for group 'fast_physics' failed")
826 call mpp_error (fatal,
'Lagrangian_to_Eulerian: can not call CCPP fast physics because cdata not initialized')
833 dpln(i,j) = peln(i,k+1,j) - peln(i,k,j)
836 if (hydrostatic)
then 841 call fv_sat_adj(abs(mdt), r_vir, is, ie, js, je, ng, hydrostatic, fast_mp_consv, &
846 q(isd,jsd,k,sphum), q(isd,jsd,k,liq_wat), &
847 q(isd,jsd,k,ice_wat), q(isd,jsd,k,rainwat), &
848 q(isd,jsd,k,snowwat), q(isd,jsd,k,graupel), &
849 hs ,dpln, delz(isd:,jsd:,kdelz), pt(isd,jsd,k), delp(isd,jsd,k), q_con(isd:,jsd:,k), &
851 cappa(isd:,jsd:,k), gridstruct%area_64, dtdt(is,js,k), out_dt, last_step, cld_amt>0, q(isd,jsd,k,cld_amt))
853 if ( .not. hydrostatic )
then 858 volatile_var = log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k))
859 pkz(i,j,k) = exp(cappa(i,j,k)*volatile_var)
861 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
866 volatile_var = log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k))
869 volatile_var = log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k))
870 pkz(i,j,k) = exp(akap*volatile_var)
874 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)))
876 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
886 if ( fast_mp_consv )
then 891 te0_2d(i,j) = te0_2d(i,j) + te(i,j,k)
901 if ( last_step )
then 910 gz(i) = max(0., q(i,j,k,liq_wat))
911 qv(i) = max(0., q(i,j,k,sphum))
913 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
915 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*qv(i))*(1.-gz(i)))
918 elseif ( nwat==6 )
then 920 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)
922 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/
virq(q(i,j,k,1:
num_gas))
924 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
928 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
929 ice_wat, snowwat, graupel, q, gz, cvm)
932 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
934 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
939 if ( .not. adiabatic )
then 942 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
944 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / (1.+r_vir*q(i,j,k,sphum))
952 if ( kord_tm < 0 )
then 957 pt(i,j,k) = pt(i,j,k)/pkz(i,j,k)
966 end associate ccpp_associate
975 u, v, w, delz, pt, delp, q, qc, pe, peln, hs, &
977 r_vir, cp, rg, hlv, te_2d, ua, va, teq, &
978 moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
983 integer,
intent(in):: km, is, ie, js, je, isd, ied, jsd, jed, id_te
984 integer,
intent(in):: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, nwat
985 real,
intent(inout),
dimension(isd:ied,jsd:jed,km):: ua, va
986 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: pt, delp
987 real,
intent(in),
dimension(isd:ied,jsd:jed,km,*):: q
988 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: qc
989 real,
intent(inout):: u(isd:ied, jsd:jed+1,km)
990 real,
intent(inout):: v(isd:ied+1,jsd:jed, km)
991 real,
intent(in):: w(isd:,jsd:,1:)
992 real,
intent(in):: delz(isd:,jsd:,1:)
993 real,
intent(in):: hs(isd:ied,jsd:jed)
994 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
995 real,
intent(in):: peln(is:ie,km+1,js:je)
996 real,
intent(in):: cp, rg, r_vir, hlv
997 real,
intent(in) :: rsin2_l(isd:ied, jsd:jed)
998 real,
intent(in) :: cosa_s_l(isd:ied, jsd:jed)
999 logical,
intent(in):: moist_phys, hydrostatic
1001 real,
intent(out):: te_2d(is:ie,js:je)
1002 real,
intent(out):: teq(is:ie,js:je)
1004 real,
dimension(is:ie,km):: tv
1005 real phiz(is:ie,km+1)
1006 real cvm(is:ie), qd(is:ie)
1023 if ( hydrostatic )
then 1026 phiz(i,km+1) = hs(i,j)
1030 tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))
1031 phiz(i,k) = phiz(i,k+1) + rg*tv(i,k)*(peln(i,k+1,j)-peln(i,k,j))
1036 te_2d(i,j) = pe(i,km+1,j)*phiz(i,km+1) - pe(i,1,j)*phiz(i,1)
1041 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*tv(i,k) + &
1042 0.25*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1043 v(i,j,k)**2+v(i+1,j,k)**2 - &
1044 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j)))
1053 phiz(i,km+1) = hs(i,j)
1055 phiz(i,k) = phiz(i,k+1) - grav*delz(i,j,k)
1061 if ( moist_phys )
then 1064 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
1065 ice_wat, snowwat, graupel, q, qd, cvm)
1069 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*( cvm(i)*pt(i,j,k) + &
1072 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) + &
1074 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1077 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 + &
1078 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))))
1085 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) + &
1087 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1089 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 + &
1090 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))))
1104 teq(i,j) = te_2d(i,j)
1106 if ( moist_phys )
then 1109 teq(i,j) = teq(i,j) + hlv*q(i,j,k,sphum)*delp(i,j,k)
1118 subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, &
1119 pe, pk, akap, peln, pkz, ptop)
1122 integer,
intent(in):: km, j
1123 integer,
intent(in):: ifirst, ilast
1124 integer,
intent(in):: jfirst, jlast
1125 real,
intent(in):: akap
1126 real,
intent(in):: pe(ifirst-1:ilast+1,km+1,jfirst-1:jlast+1)
1127 real,
intent(in):: pk(ifirst:ilast,jfirst:jlast,km+1)
1128 real,
intent(IN):: ptop
1130 real,
intent(out):: pkz(ifirst:ilast,jfirst:jlast,km)
1131 real,
intent(inout):: peln(ifirst:ilast, km+1, jfirst:jlast)
1133 real pk2(ifirst:ilast, km+1)
1139 ak1 = (akap + 1.) / akap
1141 pek = pk(ifirst,j,1)
1149 pk2(i,k) = pk(i,j,k)
1154 if( ptop < ptop_min )
then 1156 peln(i,1,j) = peln(i,2,j) - ak1
1168 pkz(i,j,k) = (pk2(i,k+1) - pk2(i,k) ) / &
1169 (akap*(peln(i,k+1,j) - peln(i,k,j)) )
1177 subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
1180 integer,
intent(in) :: i1
1181 integer,
intent(in) :: i2
1182 integer,
intent(in) :: kord
1183 integer,
intent(in) :: km
1184 integer,
intent(in) :: kn
1185 integer,
intent(in) :: iv
1187 real,
intent(in) :: pe1(i1:i2,km+1)
1188 real,
intent(in) :: pe2(i1:i2,kn+1)
1189 real,
intent(in) :: q1(i1:i2,km)
1192 real,
intent(inout):: q2(i1:i2,kn)
1198 real pl, pr, qsum, delp, esl
1199 integer i, k, l, m, k0
1203 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1210 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1221 if(pe2(i,k) <= pe1(i,l) .and. pe2(i,k) >= pe1(i,l+1))
then 1222 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1223 if(pe2(i,k+1) >= pe1(i,l+1))
then 1225 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1226 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1227 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1232 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1233 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1234 (
r3*(1.+pl*(1.+pl))))
1237 if(pe2(i,k+1) < pe1(i,m+1) )
then 1239 qsum = qsum + dp1(i,m)*q4(1,i,m)
1241 delp = pe2(i,k+1)-pe1(i,m)
1242 esl = delp / dp1(i,m)
1243 qsum = qsum + delp*(q4(2,i,m)+0.5*esl* &
1244 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1253 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1260 kn, pe2, q2, i1, i2, &
1261 j, ibeg, iend, jbeg, jend, iv, kord, q_min)
1263 integer,
intent(in) :: i1
1264 integer,
intent(in) :: i2
1265 integer,
intent(in) :: iv
1266 integer,
intent(in) :: kord
1267 integer,
intent(in) :: j
1268 integer,
intent(in) :: ibeg, iend, jbeg, jend
1269 integer,
intent(in) :: km
1270 integer,
intent(in) :: kn
1271 real,
intent(in) :: qs(i1:i2)
1272 real,
intent(in) :: pe1(i1:i2,km+1)
1273 real,
intent(in) :: pe2(i1:i2,kn+1)
1274 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1276 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1277 real,
intent(in):: q_min
1288 real pl, pr, qsum, dp, esl
1289 integer i, k, l, m, k0
1293 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1294 q4(1,i,k) = q1(i,j,k)
1310 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1311 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1312 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1314 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1315 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1316 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1321 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1322 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1323 (
r3*(1.+pl*(1.+pl))))
1326 if( pe2(i,k+1) > pe1(i,m+1) )
then 1328 qsum = qsum + dp1(i,m)*q4(1,i,m)
1330 dp = pe2(i,k+1)-pe1(i,m)
1332 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1333 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1342 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1349 subroutine map1_ppm( km, pe1, q1, qs, &
1350 kn, pe2, q2, i1, i2, &
1351 j, ibeg, iend, jbeg, jend, iv, kord)
1352 integer,
intent(in) :: i1
1353 integer,
intent(in) :: i2
1354 integer,
intent(in) :: iv
1355 integer,
intent(in) :: kord
1356 integer,
intent(in) :: j
1357 integer,
intent(in) :: ibeg, iend, jbeg, jend
1358 integer,
intent(in) :: km
1359 integer,
intent(in) :: kn
1360 real,
intent(in) :: qs(i1:i2)
1361 real,
intent(in) :: pe1(i1:i2,km+1)
1362 real,
intent(in) :: pe2(i1:i2,kn+1)
1363 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1365 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1377 real pl, pr, qsum, dp, esl
1378 integer i, k, l, m, k0
1382 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1383 q4(1,i,k) = q1(i,j,k)
1389 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1399 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1400 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1401 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1403 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1404 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1405 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1410 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1411 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1412 (
r3*(1.+pl*(1.+pl))))
1415 if( pe2(i,k+1) > pe1(i,m+1) )
then 1417 qsum = qsum + dp1(i,m)*q4(1,i,m)
1419 dp = pe2(i,k+1)-pe1(i,m)
1421 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1422 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1431 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1438 subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, &
1439 i1, i2, isd, ied, jsd, jed, q_min, fill)
1441 integer,
intent(in):: km
1442 integer,
intent(in):: j, nq, i1, i2
1443 integer,
intent(in):: isd, ied, jsd, jed
1444 integer,
intent(in):: kord(nq)
1445 real,
intent(in):: pe1(i1:i2,km+1)
1446 real,
intent(in):: pe2(i1:i2,km+1)
1447 real,
intent(in):: dp2(i1:i2,km)
1448 real,
intent(in):: q_min
1449 logical,
intent(in):: fill
1450 real,
intent(inout):: q1(isd:ied,jsd:jed,km,nq)
1452 real:: q4(4,i1:i2,km,nq)
1453 real:: q2(i1:i2,km,nq)
1455 real:: dp1(i1:i2,km)
1457 real:: pl, pr, dp, esl, fac1, fac2
1458 integer:: i, k, l, m, k0, iq
1462 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1469 q4(1,i,k,iq) = q1(i,j,k,iq)
1472 call scalar_profile( qs, q4(1,i1,1,iq), dp1, km, i1, i2, 0, kord(iq), q_min )
1481 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1482 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1483 if(pe2(i,k+1) <= pe1(i,l+1))
then 1485 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1487 fac2 =
r3*(pr*fac1 + pl*pl)
1490 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 &
1497 dp = pe1(i,l+1) - pe2(i,k)
1499 fac2 =
r3*(1.+pl*fac1)
1502 qsum(iq) = dp*(q4(2,i,l,iq) + (q4(4,i,l,iq)+ &
1503 q4(3,i,l,iq) - q4(2,i,l,iq))*fac1 - q4(4,i,l,iq)*fac2)
1507 if(pe2(i,k+1) > pe1(i,m+1) )
then 1510 qsum(iq) = qsum(iq) + dp1(i,m)*q4(1,i,m,iq)
1513 dp = pe2(i,k+1)-pe1(i,m)
1518 qsum(iq) = qsum(iq) + dp*( q4(2,i,m,iq) + fac1*( &
1519 q4(3,i,m,iq)-q4(2,i,m,iq)+q4(4,i,m,iq)*fac2 ) )
1531 q2(i,k,iq) = qsum(iq) / dp2(i,k)
1536 if (fill)
call fillz(i2-i1+1, km, nq, q2, dp2)
1542 q1(i,j,k,iq) = q2(i,k,iq)
1550 subroutine map1_q2(km, pe1, q1, &
1552 i1, i2, iv, kord, j, &
1553 ibeg, iend, jbeg, jend, q_min )
1557 integer,
intent(in) :: j
1558 integer,
intent(in) :: i1, i2
1559 integer,
intent(in) :: ibeg, iend, jbeg, jend
1560 integer,
intent(in) :: iv
1561 integer,
intent(in) :: kord
1562 integer,
intent(in) :: km
1563 integer,
intent(in) :: kn
1565 real,
intent(in) :: pe1(i1:i2,km+1)
1566 real,
intent(in) :: pe2(i1:i2,kn+1)
1567 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1568 real,
intent(in) :: dp2(i1:i2,kn)
1569 real,
intent(in) :: q_min
1571 real,
intent(inout):: q2(i1:i2,kn)
1576 real pl, pr, qsum, dp, esl
1578 integer i, k, l, m, k0
1582 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1583 q4(1,i,k) = q1(i,j,k)
1600 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1601 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1602 if(pe2(i,k+1) <= pe1(i,l+1))
then 1604 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1605 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1606 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1611 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1612 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1613 (
r3*(1.+pl*(1.+pl))))
1616 if(pe2(i,k+1) > pe1(i,m+1) )
then 1618 qsum = qsum + dp1(i,m)*q4(1,i,m)
1620 dp = pe2(i,k+1)-pe1(i,m)
1622 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1623 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1632 123 q2(i,k) = qsum / dp2(i,k)
1643 integer,
intent(in):: i1, i2
1644 integer,
intent(in):: iv
1645 integer,
intent(in):: kord
1646 integer,
intent(in):: km
1647 integer,
intent(in):: kn
1648 real,
intent(in):: pe1(i1:i2,km+1)
1649 real,
intent(in):: pe2(i1:i2,kn+1)
1650 real,
intent(in) :: q1(i1:i2,km)
1651 real,
intent(out):: q2(i1:i2,kn)
1656 real pl, pr, qsum, dp, esl
1657 integer i, k, l, m, k0
1661 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1668 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1677 if( pe2(i,k+1) <= pe1(i,1) )
then 1680 elseif( pe2(i,k) < pe1(i,1) .and. pe2(i,k+1)>pe1(i,1) )
then 1684 if( pe2(i,k) <= pe1(i,1) )
then 1691 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1692 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1693 if(pe2(i,k+1) <= pe1(i,l+1))
then 1695 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1696 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1697 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1702 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1703 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1704 (
r3*(1.+pl*(1.+pl))))
1707 if(pe2(i,k+1) > pe1(i,m+1) )
then 1709 qsum = qsum + dp1(i,m)*q4(1,i,m)
1711 dp = pe2(i,k+1)-pe1(i,m)
1713 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1714 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1723 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1731 subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
1734 integer,
intent(in):: i1, i2
1735 integer,
intent(in):: km
1736 integer,
intent(in):: iv
1737 integer,
intent(in):: kord
1738 real,
intent(in) :: qs(i1:i2)
1739 real,
intent(in) :: delp(i1:i2,km)
1740 real,
intent(inout):: a4(4,i1:i2,km)
1741 real,
intent(in):: qmin
1743 logical,
dimension(i1:i2,km):: extm, ext5, ext6
1747 real bet, a_bot, grat
1748 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
1751 if ( iv .eq. -2 )
then 1754 q(i,1) = 1.5*a4(1,i,1)
1758 grat = delp(i,k-1) / delp(i,k)
1759 bet = 2. + grat + grat - gam(i,k)
1760 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
1761 gam(i,k+1) = grat / bet
1765 grat = delp(i,km-1) / delp(i,km)
1766 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
1767 (2. + grat + grat - gam(i,km))
1772 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
1777 grat = delp(i,2) / delp(i,1)
1778 bet = grat*(grat+0.5)
1779 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
1780 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
1785 d4(i) = delp(i,k-1) / delp(i,k)
1786 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
1787 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
1788 gam(i,k) = d4(i) / bet
1793 a_bot = 1. + d4(i)*(d4(i)+1.5)
1794 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
1795 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
1800 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
1806 if ( abs(kord) > 16 )
then 1810 a4(3,i,k) = q(i,k+1)
1811 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1824 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
1825 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
1830 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
1837 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 1839 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
1840 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
1842 if ( gam(i,k-1) > 0. )
then 1844 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
1847 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
1848 if ( iv==0 ) q(i,k) = max(0., q(i,k))
1856 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
1857 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
1863 a4(3,i,k) = q(i,k+1)
1868 if ( k==1 .or. k==km )
then 1870 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
1874 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
1877 if ( abs(kord) > 9 )
then 1879 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
1880 x1 = abs(a4(2,i,k)-a4(3,i,k))
1882 ext5(i,k) = abs(x0) > x1
1883 ext6(i,k) = abs(a4(4,i,k)) > x1
1896 a4(2,i,1) = max(0., a4(2,i,1))
1898 elseif ( iv==-1 )
then 1900 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
1902 elseif ( iv==2 )
then 1904 a4(2,i,1) = a4(1,i,1)
1905 a4(3,i,1) = a4(1,i,1)
1912 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
1919 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
1927 if ( abs(kord)<9 )
then 1930 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1931 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1932 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1933 max(a4(1,i,k), pmp_1, lac_1) )
1935 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1936 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1937 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1938 max(a4(1,i,k), pmp_2, lac_2) )
1940 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1943 elseif ( abs(kord)==9 )
then 1945 if ( extm(i,k) .and. extm(i,k-1) )
then 1947 a4(2,i,k) = a4(1,i,k)
1948 a4(3,i,k) = a4(1,i,k)
1950 else if ( extm(i,k) .and. extm(i,k+1) )
then 1952 a4(2,i,k) = a4(1,i,k)
1953 a4(3,i,k) = a4(1,i,k)
1955 else if ( extm(i,k) .and. a4(1,i,k)<qmin )
then 1957 a4(2,i,k) = a4(1,i,k)
1958 a4(3,i,k) = a4(1,i,k)
1961 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1963 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1964 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1965 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1966 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1967 max(a4(1,i,k), pmp_1, lac_1) )
1968 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1969 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1970 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1971 max(a4(1,i,k), pmp_2, lac_2) )
1972 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1976 elseif ( abs(kord)==10 )
then 1978 if( ext5(i,k) )
then 1979 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1980 a4(2,i,k) = a4(1,i,k)
1981 a4(3,i,k) = a4(1,i,k)
1982 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 1983 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1984 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1985 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1986 max(a4(1,i,k), pmp_1, lac_1) )
1987 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1988 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1989 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1990 max(a4(1,i,k), pmp_2, lac_2) )
1992 elseif( ext6(i,k) )
then 1993 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1994 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1995 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1996 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1997 max(a4(1,i,k), pmp_1, lac_1) )
1998 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1999 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2000 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2001 max(a4(1,i,k), pmp_2, lac_2) )
2006 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2008 elseif ( abs(kord)==12 )
then 2010 if( extm(i,k) )
then 2011 a4(2,i,k) = a4(1,i,k)
2012 a4(3,i,k) = a4(1,i,k)
2015 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2017 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2018 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2019 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2020 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2021 max(a4(1,i,k), pmp_1, lac_1) )
2022 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2023 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2024 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2025 max(a4(1,i,k), pmp_2, lac_2) )
2026 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2030 elseif ( abs(kord)==13 )
then 2032 if( ext6(i,k) )
then 2033 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2035 a4(2,i,k) = a4(1,i,k)
2036 a4(3,i,k) = a4(1,i,k)
2041 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2043 elseif ( abs(kord)==14 )
then 2046 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2049 elseif ( abs(kord)==15 )
then 2051 if ( ext5(i,k) .and. ext5(i,k-1) )
then 2052 a4(2,i,k) = a4(1,i,k)
2053 a4(3,i,k) = a4(1,i,k)
2054 else if ( ext5(i,k) .and. ext5(i,k+1) )
then 2055 a4(2,i,k) = a4(1,i,k)
2056 a4(3,i,k) = a4(1,i,k)
2057 else if ( ext5(i,k) .and. a4(1,i,k)<qmin )
then 2058 a4(2,i,k) = a4(1,i,k)
2059 a4(3,i,k) = a4(1,i,k)
2060 elseif( ext6(i,k) )
then 2061 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2062 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2063 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2064 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) )
2072 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2074 elseif ( abs(kord)==16 )
then 2076 if( ext5(i,k) )
then 2077 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2078 a4(2,i,k) = a4(1,i,k)
2079 a4(3,i,k) = a4(1,i,k)
2080 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2082 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2083 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2084 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2085 max(a4(1,i,k), pmp_1, lac_1) )
2087 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2088 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2089 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2090 max(a4(1,i,k), pmp_2, lac_2) )
2095 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2099 if ( ext5(i,k) .and. (ext5(i,k-1).or.ext5(i,k+1).or.a4(1,i,k)<qmin) )
then 2101 a4(2,i,k) = a4(1,i,k)
2102 a4(3,i,k) = a4(1,i,k)
2105 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2111 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2120 a4(3,i,km) = max(0., a4(3,i,km))
2122 elseif ( iv .eq. -1 )
then 2124 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2130 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2132 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2133 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2138 subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
2141 integer,
intent(in):: i1, i2
2142 integer,
intent(in):: km
2143 integer,
intent(in):: iv
2146 integer,
intent(in):: kord
2147 real,
intent(in) :: qs(i1:i2)
2148 real,
intent(in) :: delp(i1:i2,km)
2149 real,
intent(inout):: a4(4,i1:i2,km)
2151 logical,
dimension(i1:i2,km):: extm, ext5, ext6
2155 real bet, a_bot, grat
2156 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
2159 if ( iv .eq. -2 )
then 2162 q(i,1) = 1.5*a4(1,i,1)
2166 grat = delp(i,k-1) / delp(i,k)
2167 bet = 2. + grat + grat - gam(i,k)
2168 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
2169 gam(i,k+1) = grat / bet
2173 grat = delp(i,km-1) / delp(i,km)
2174 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
2175 (2. + grat + grat - gam(i,km))
2180 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
2185 grat = delp(i,2) / delp(i,1)
2186 bet = grat*(grat+0.5)
2187 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
2188 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
2193 d4(i) = delp(i,k-1) / delp(i,k)
2194 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
2195 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
2196 gam(i,k) = d4(i) / bet
2201 a_bot = 1. + d4(i)*(d4(i)+1.5)
2202 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
2203 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
2208 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
2213 if ( abs(kord) > 16 )
then 2217 a4(3,i,k) = q(i,k+1)
2218 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2232 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
2233 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
2238 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
2245 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 2247 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
2248 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
2250 if ( gam(i,k-1) > 0. )
then 2252 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
2255 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
2256 if ( iv==0 ) q(i,k) = max(0., q(i,k))
2264 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
2265 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
2271 a4(3,i,k) = q(i,k+1)
2276 if ( k==1 .or. k==km )
then 2278 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
2282 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
2285 if ( abs(kord) > 9 )
then 2287 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
2288 x1 = abs(a4(2,i,k)-a4(3,i,k))
2290 ext5(i,k) = abs(x0) > x1
2291 ext6(i,k) = abs(a4(4,i,k)) > x1
2304 a4(2,i,1) = max(0., a4(2,i,1))
2306 elseif ( iv==-1 )
then 2308 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2310 elseif ( iv==2 )
then 2312 a4(2,i,1) = a4(1,i,1)
2313 a4(3,i,1) = a4(1,i,1)
2320 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
2327 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
2335 if ( abs(kord)<9 )
then 2338 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2339 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2340 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2341 max(a4(1,i,k), pmp_1, lac_1) )
2343 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2344 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2345 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2346 max(a4(1,i,k), pmp_2, lac_2) )
2348 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2351 elseif ( abs(kord)==9 )
then 2353 if ( extm(i,k) .and. extm(i,k-1) )
then 2355 a4(2,i,k) = a4(1,i,k)
2356 a4(3,i,k) = a4(1,i,k)
2358 else if ( extm(i,k) .and. extm(i,k+1) )
then 2360 a4(2,i,k) = a4(1,i,k)
2361 a4(3,i,k) = a4(1,i,k)
2364 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2366 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2367 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2368 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2369 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2370 max(a4(1,i,k), pmp_1, lac_1) )
2371 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2372 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2373 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2374 max(a4(1,i,k), pmp_2, lac_2) )
2375 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2379 elseif ( abs(kord)==10 )
then 2381 if( ext5(i,k) )
then 2382 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2383 a4(2,i,k) = a4(1,i,k)
2384 a4(3,i,k) = a4(1,i,k)
2385 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2386 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2387 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2388 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2389 max(a4(1,i,k), pmp_1, lac_1) )
2390 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2391 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2392 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2393 max(a4(1,i,k), pmp_2, lac_2) )
2395 elseif( ext6(i,k) )
then 2396 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2397 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2398 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2399 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2400 max(a4(1,i,k), pmp_1, lac_1) )
2401 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2402 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2403 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2404 max(a4(1,i,k), pmp_2, lac_2) )
2409 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2411 elseif ( abs(kord)==12 )
then 2413 if( extm(i,k) )
then 2415 a4(2,i,k) = a4(1,i,k)
2416 a4(3,i,k) = a4(1,i,k)
2419 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2421 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2422 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2423 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2424 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2425 max(a4(1,i,k), pmp_1, lac_1) )
2426 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2427 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2428 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2429 max(a4(1,i,k), pmp_2, lac_2) )
2430 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2434 elseif ( abs(kord)==13 )
then 2436 if( ext6(i,k) )
then 2437 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2439 a4(2,i,k) = a4(1,i,k)
2440 a4(3,i,k) = a4(1,i,k)
2445 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2447 elseif ( abs(kord)==14 )
then 2450 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2453 elseif ( abs(kord)==15 )
then 2455 if ( ext5(i,k) )
then 2456 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)
2461 elseif( ext6(i,k) )
then 2463 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2464 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2465 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2466 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) )
2474 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2476 elseif ( abs(kord)==16 )
then 2478 if( ext5(i,k) )
then 2479 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2480 a4(2,i,k) = a4(1,i,k)
2481 a4(3,i,k) = a4(1,i,k)
2482 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2484 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2485 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2486 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2487 max(a4(1,i,k), pmp_1, lac_1) )
2489 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2490 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2491 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2492 max(a4(1,i,k), pmp_2, lac_2) )
2497 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2501 if ( ext5(i,k) .and. (ext5(i,k-1) .or. ext5(i,k+1)) )
then 2503 a4(2,i,k) = a4(1,i,k)
2504 a4(3,i,k) = a4(1,i,k)
2507 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2513 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2522 a4(3,i,km) = max(0., a4(3,i,km))
2524 elseif ( iv .eq. -1 )
then 2526 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2532 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2534 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2535 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2542 integer,
intent(in) :: im
2543 integer,
intent(in) :: iv
2544 logical,
intent(in) :: extm(im)
2545 real ,
intent(inout) :: a4(4,im)
2553 if( a4(1,i)<=0.)
then 2558 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2559 if( (a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12) < 0. )
then 2561 if( a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i) )
then 2565 elseif( a4(3,i) > a4(2,i) )
then 2566 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2567 a4(3,i) = a4(2,i) - a4(4,i)
2569 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2570 a4(2,i) = a4(3,i) - a4(4,i)
2576 elseif ( iv==1 )
then 2578 if( (a4(1,i)-a4(2,i))*(a4(1,i)-a4(3,i))>=0. )
then 2583 da1 = a4(3,i) - a4(2,i)
2586 if(a6da < -da2)
then 2587 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2588 a4(3,i) = a4(2,i) - a4(4,i)
2589 elseif(a6da > da2)
then 2590 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2591 a4(2,i) = a4(3,i) - a4(4,i)
2603 da1 = a4(3,i) - a4(2,i)
2606 if(a6da < -da2)
then 2607 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2608 a4(3,i) = a4(2,i) - a4(4,i)
2609 elseif(a6da > da2)
then 2610 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2611 a4(2,i) = a4(3,i) - a4(4,i)
2620 subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
2623 integer,
intent(in):: iv
2624 integer,
intent(in):: i1
2625 integer,
intent(in):: i2
2626 integer,
intent(in):: km
2627 integer,
intent(in):: kord
2629 real ,
intent(in):: delp(i1:i2,km)
2632 real ,
intent(inout):: a4(4,i1:i2,km)
2649 integer i, k, km1, lmt, it
2651 real a1, a2, c1, c2, c3, d1, d2
2652 real qm, dq, lac, qmp, pmp
2659 delq(i,k-1) = a4(1,i,k) - a4(1,i,k-1)
2660 d4(i,k ) = delp(i,k-1) + delp(i,k)
2666 c1 = (delp(i,k-1)+0.5*delp(i,k))/d4(i,k+1)
2667 c2 = (delp(i,k+1)+0.5*delp(i,k))/d4(i,k)
2668 df2(i,k) = delp(i,k)*(c1*delq(i,k) + c2*delq(i,k-1)) / &
2669 (d4(i,k)+delp(i,k+1))
2670 dc(i,k) = sign( min(abs(df2(i,k)), &
2671 max(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))-a4(1,i,k), &
2672 a4(1,i,k)-min(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))), df2(i,k) )
2682 c1 = delq(i,k-1)*delp(i,k-1) / d4(i,k)
2683 a1 = d4(i,k-1) / (d4(i,k) + delp(i,k-1))
2684 a2 = d4(i,k+1) / (d4(i,k) + delp(i,k))
2685 a4(2,i,k) = a4(1,i,k-1) + c1 + 2./(d4(i,k-1)+d4(i,k+1)) * &
2686 ( delp(i,k)*(c1*(a1 - a2)+a2*dc(i,k-1)) - &
2687 delp(i,k-1)*a1*dc(i,k ) )
2698 qm = (d2*a4(1,i,1)+d1*a4(1,i,2)) / (d1+d2)
2699 dq = 2.*(a4(1,i,2)-a4(1,i,1)) / (d1+d2)
2700 c1 = 4.*(a4(2,i,3)-qm-d2*dq) / ( d2*(2.*d2*d2+d1*(d2+3.*d1)) )
2701 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2702 a4(2,i,2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
2705 a4(2,i,1) = d1*(2.*c1*d1**2-c3) + a4(2,i,2)
2710 a4(2,i,2) = max( a4(2,i,2), min(a4(1,i,1), a4(1,i,2)) )
2711 a4(2,i,2) = min( a4(2,i,2), max(a4(1,i,1), a4(1,i,2)) )
2712 dc(i,1) = 0.5*(a4(2,i,2) - a4(1,i,1))
2719 a4(2,i,1) = max(0., a4(2,i,1))
2720 a4(2,i,2) = max(0., a4(2,i,2))
2722 elseif( iv==-1 )
then 2724 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2726 elseif( abs(iv)==2 )
then 2728 a4(2,i,1) = a4(1,i,1)
2729 a4(3,i,1) = a4(1,i,1)
2738 qm = (d2*a4(1,i,km)+d1*a4(1,i,km1)) / (d1+d2)
2739 dq = 2.*(a4(1,i,km1)-a4(1,i,km)) / (d1+d2)
2740 c1 = (a4(2,i,km1)-qm-d2*dq) / (d2*(2.*d2*d2+d1*(d2+3.*d1)))
2741 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2742 a4(2,i,km) = qm - c1*d1*d2*(d2+3.*d1)
2745 a4(3,i,km) = d1*(8.*c1*d1**2-c3) + a4(2,i,km)
2750 a4(2,i,km) = max( a4(2,i,km), min(a4(1,i,km), a4(1,i,km1)) )
2751 a4(2,i,km) = min( a4(2,i,km), max(a4(1,i,km), a4(1,i,km1)) )
2752 dc(i,km) = 0.5*(a4(1,i,km) - a4(2,i,km))
2761 if( a4(3,i,km) * a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2762 d1 = a4(1,i,km) - a4(2,i,km)
2763 d2 = a4(3,i,km) - a4(1,i,km)
2764 if ( d1*d2 < 0. )
then 2765 a4(2,i,km) = a4(1,i,km)
2766 a4(3,i,km) = a4(1,i,km)
2768 dq = sign(min(abs(d1),abs(d2),0.5*abs(delq(i,km-1))), d1)
2769 a4(2,i,km) = a4(1,i,km) - dq
2770 a4(3,i,km) = a4(1,i,km) + dq
2776 a4(2,i,km) = max(0.,a4(2,i,km))
2777 a4(3,i,km) = max(0.,a4(3,i,km))
2781 if( a4(1,i,km)*a4(3,i,km) <= 0. ) a4(3,i,km) = 0.
2788 a4(3,i,k) = a4(2,i,k+1)
2798 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2812 h2(i,k) = 2.*(dc(i,k+1)/delp(i,k+1) - dc(i,k-1)/delp(i,k-1)) &
2813 / ( delp(i,k)+0.5*(delp(i,k-1)+delp(i,k+1)) ) &
2829 qmp = a4(1,i,k) + pmp
2830 lac = a4(1,i,k) + fac*h2(i,k-1) + dc(i,k)
2831 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), qmp, lac)), &
2832 max(a4(1,i,k), qmp, lac) )
2837 qmp = a4(1,i,k) - pmp
2838 lac = a4(1,i,k) + fac*h2(i,k+1) - dc(i,k)
2839 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), qmp, lac)), &
2840 max(a4(1,i,k), qmp, lac))
2844 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2847 if (iv == 0 .and. kord >= 6 ) &
2855 if (iv == 0) lmt = min(2, lmt)
2860 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2863 if(kord/=6)
call ppm_limiters(dc(i1,k), a4(1,i1,k), it, lmt)
2869 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2880 real ,
intent(in):: dm(*)
2881 integer,
intent(in) :: itot
2882 integer,
intent(in) :: lmt
2886 real ,
intent(inout) :: a4(4,*)
2895 if ( lmt == 3 )
return 2900 if(dm(i) == 0.)
then 2905 da1 = a4(3,i) - a4(2,i)
2908 if(a6da < -da2)
then 2909 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2910 a4(3,i) = a4(2,i) - a4(4,i)
2911 elseif(a6da > da2)
then 2912 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2913 a4(2,i) = a4(3,i) - a4(4,i)
2918 elseif (lmt == 1)
then 2924 a4(2,i) = a4(1,i)-sign(min(abs(qmp),abs(a4(2,i)-a4(1,i))), qmp)
2925 a4(3,i) = a4(1,i)+sign(min(abs(qmp),abs(a4(3,i)-a4(1,i))), qmp)
2926 a4(4,i) = 3.*( 2.*a4(1,i) - (a4(2,i)+a4(3,i)) )
2929 elseif (lmt == 2)
then 2933 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2934 fmin = a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12 2935 if( fmin < 0. )
then 2936 if(a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i))
then 2940 elseif(a4(3,i) > a4(2,i))
then 2941 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2942 a4(3,i) = a4(2,i) - a4(4,i)
2944 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2945 a4(2,i) = a4(3,i) - a4(4,i)
2957 subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
2958 integer,
intent(in) :: km, i1, i2
2959 real ,
intent(in) :: dp(i1:i2,km)
2960 real ,
intent(in) :: dq(i1:i2,km)
2961 real ,
intent(in) :: d4(i1:i2,km)
2962 real ,
intent(in) :: df2(i1:i2,km)
2963 real ,
intent(in) :: dm(i1:i2,km)
2965 real ,
intent(inout) :: a4(4,i1:i2,km)
2976 rat(i,k) = dq(i,k-1) / d4(i,k)
2983 f(i,k) = (rat(i,k+1) - rat(i,k)) &
2984 / ( dp(i,k-1)+dp(i,k)+dp(i,k+1) )
2990 if(f(i,k+1)*f(i,k-1)<0. .and. df2(i,k)/=0.)
then 2991 dg2 = (f(i,k+1)-f(i,k-1))*((dp(i,k+1)-dp(i,k-1))**2 &
2992 + d4(i,k)*d4(i,k+1) )
2993 alfa(i,k) = max(0., min(0.5, -0.1875*dg2/df2(i,k)))
3002 a4(2,i,k) = (1.-alfa(i,k-1)-alfa(i,k)) * a4(2,i,k) + &
3003 alfa(i,k-1)*(a4(1,i,k)-dm(i,k)) + &
3004 alfa(i,k)*(a4(1,i,k-1)+dm(i,k-1))
3013 subroutine rst_remap(km, kn, is,ie,js,je, isd,ied,jsd,jed, nq, ntp, &
3014 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, &
3015 delp, u, v, w, delz, pt, q, qdiag, &
3016 ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, &
3017 domain, square_domain)
3022 integer,
intent(in):: km
3023 integer,
intent(in):: kn
3024 integer,
intent(in):: nq, ntp
3025 integer,
intent(in):: is,ie,isd,ied
3026 integer,
intent(in):: js,je,jsd,jed
3027 logical,
intent(in):: hydrostatic, make_nh, square_domain
3028 real,
intent(IN) :: ptop
3029 real,
intent(in) :: ak_r(km+1)
3030 real,
intent(in) :: bk_r(km+1)
3031 real,
intent(in) :: ak(kn+1)
3032 real,
intent(in) :: bk(kn+1)
3033 real,
intent(in):: delp_r(is:ie,js:je,km)
3034 real,
intent(in):: u_r(is:ie, js:je+1,km)
3035 real,
intent(in):: v_r(is:ie+1,js:je ,km)
3036 real,
intent(inout):: pt_r(is:ie,js:je,km)
3037 real,
intent(in):: w_r(is:ie,js:je,km)
3038 real,
intent(in):: q_r(is:ie,js:je,km,1:ntp)
3039 real,
intent(in):: qdiag_r(is:ie,js:je,km,ntp+1:nq)
3040 real,
intent(inout)::delz_r(is:ie,js:je,km)
3041 type(domain2d),
intent(INOUT) :: domain
3043 real,
intent(out):: delp(isd:ied,jsd:jed,kn)
3044 real,
intent(out):: u(isd:ied ,jsd:jed+1,kn)
3045 real,
intent(out):: v(isd:ied+1,jsd:jed ,kn)
3046 real,
intent(out):: w(isd: ,jsd: ,1:)
3047 real,
intent(out):: pt(isd:ied ,jsd:jed ,kn)
3048 real,
intent(out):: q(isd:ied,jsd:jed,kn,1:ntp)
3049 real,
intent(out):: qdiag(isd:ied,jsd:jed,kn,ntp+1:nq)
3050 real,
intent(out):: delz(isd:,jsd:,1:)
3053 real ps(isd:ied,jsd:jed)
3054 real pe1(is:ie,km+1)
3055 real pe2(is:ie,kn+1)
3056 real pv1(is:ie+1,km+1)
3057 real pv2(is:ie+1,kn+1)
3060 integer,
parameter:: kord=4
3062 #ifdef HYDRO_DELZ_REMAP 3063 if (is_master() .and. .not. hydrostatic)
then 3065 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ' 3070 #ifdef HYDRO_DELZ_EXTRAP 3071 if (is_master() .and. .not. hydrostatic)
then 3073 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ABOVE INPUT MODEL TOP ' 3078 #ifdef ZERO_W_EXTRAP 3079 if (is_master() .and. .not. hydrostatic)
then 3081 print*,
' REMAPPING IC: INITIALIZING W TO ZERO ABOVE INPUT MODEL TOP ' 3086 r_vir = rvgas/rdgas - 1.
3101 ps(i,j) = ps(i,j) + delp_r(i,j,k)
3107 if ( square_domain )
then 3108 call mpp_update_domains(ps, domain, whalo=1, ehalo=1, shalo=1, nhalo=1, complete=.true.)
3110 call mpp_update_domains(ps, domain, complete=.true.)
3119 pt_r(i,j,k) = pt_r(i,j,k) * virq(q_r(i,j,k,:))
3121 pt_r(i,j,k) = pt_r(i,j,k) * (1.+r_vir*q_r(i,j,k,1))
3137 pe1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i,j-1)+ps(i,j))
3143 pe2(i,k) = ak(k) + 0.5*bk(k)*(ps(i,j-1)+ps(i,j))
3147 call remap_2d(km, pe1, u_r(is:ie,j:j,1:km), &
3148 kn, pe2, u(is:ie,j:j,1:kn), &
3151 if ( j /= (je+1) )
then 3158 pe1(i,k) = ak_r(k) + bk_r(k)*ps(i,j)
3164 pe2(i,k) = ak(k) + bk(k)*ps(i,j)
3173 delp(i,j,k) = pe2(i,k+1) - pe2(i,k)
3182 call remap_2d(km, pe1, q_r(is:ie,j:j,1:km,iq:iq), &
3183 kn, pe2, q(is:ie,j:j,1:kn,iq:iq), &
3187 call remap_2d(km, pe1, qdiag_r(is:ie,j:j,1:km,iq:iq), &
3188 kn, pe2, qdiag(is:ie,j:j,1:kn,iq:iq), &
3193 if ( .not. hydrostatic .and. .not. make_nh)
then 3195 call remap_2d(km, pe1, w_r(is:ie,j:j,1:km), &
3196 kn, pe2, w(is:ie,j:j,1:kn), &
3199 #ifdef ZERO_W_EXTRAP 3202 if (pe2(i,k) < pe1(i,1))
then 3209 #ifndef HYDRO_DELZ_REMAP 3213 delz_r(i,j,k) = -delz_r(i,j,k)/delp_r(i,j,k)
3216 call remap_2d(km, pe1, delz_r(is:ie,j:j,1:km), &
3217 kn, pe2, delz(is:ie,j:j,1:kn), &
3221 delz(i,j,k) = -delz(i,j,k)*delp(i,j,k)
3230 pe1(i,k) = log(pe1(i,k))
3235 pe2(i,k) = log(pe2(i,k))
3239 call remap_2d(km, pe1, pt_r(is:ie,j:j,1:km), &
3240 kn, pe2, pt(is:ie,j:j,1:kn), &
3243 #ifdef HYDRO_DELZ_REMAP 3247 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3251 #ifdef HYDRO_DELZ_EXTRAP 3255 if (pe2(i,k) < pe1(i,1))
then 3256 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3266 pv1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1,j)+ps(i,j))
3271 pv2(i,k) = ak(k) + 0.5*bk(k)*(ps(i-1,j)+ps(i,j))
3275 call remap_2d(km, pv1, v_r(is:ie+1,j:j,1:km), &
3276 kn, pv2, v(is:ie+1,j:j,1:kn), &
3287 pt(i,j,k) = pt(i,j,k) / virq(q(i,j,k,:))
3289 pt(i,j,k) = pt(i,j,k) / (1.+r_vir*q(i,j,k,1))
3299 subroutine mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
3312 integer,
intent(in):: i1, i2, km, kn, kord, iv
3313 real,
intent(in ):: pe1(i1:i2,km+1), pe2(i1:i2,kn+1)
3318 real,
intent(in ):: q1(i1:i2,km)
3319 real,
intent(out):: q2(i1:i2,kn)
3320 real,
intent(IN) :: ptop
3327 real pl, pr, tt, delp, qsum, dpsum, esl
3331 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
3337 call cs_profile( qs, a4, dp1, km, i1, i2, iv, kord )
3345 #ifdef NGGPS_SUBMITTED 3347 a4(2,i,km) = q1(i,km)
3348 a4(3,i,km) = q1(i,km)
3357 if(pe2(i,k) .le. pe1(i,1))
then 3360 elseif(pe2(i,k) .ge. pe1(i,km+1))
then 3362 #ifdef NGGPS_SUBMITTED 3363 q2(i,k) = a4(3,i,km)
3371 if( pe2(i,k) .ge. pe1(i,l) .and. &
3372 pe2(i,k) .le. pe1(i,l+1) )
then 3374 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
3375 if(pe2(i,k+1) .le. pe1(i,l+1))
then 3378 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
3379 tt =
r3*(pr*(pr+pl)+pl**2)
3380 q2(i,k) = a4(2,i,l) + 0.5*(a4(4,i,l)+a4(3,i,l) &
3381 - a4(2,i,l))*(pr+pl) - a4(4,i,l)*tt
3385 delp = pe1(i,l+1) - pe2(i,k)
3386 tt =
r3*(1.+pl*(1.+pl))
3387 qsum = delp*(a4(2,i,l)+0.5*(a4(4,i,l)+ &
3388 a4(3,i,l)-a4(2,i,l))*(1.+pl)-a4(4,i,l)*tt)
3398 if( pe2(i,k+1) .gt. pe1(i,l+1) )
then 3402 qsum = qsum + dp1(i,l)*q1(i,l)
3403 dpsum = dpsum + dp1(i,l)
3405 delp = pe2(i,k+1)-pe1(i,l)
3406 esl = delp / dp1(i,l)
3407 qsum = qsum + delp * (a4(2,i,l)+0.5*esl* &
3408 (a4(3,i,l)-a4(2,i,l)+a4(4,i,l)*(1.-
r23*esl)) )
3409 dpsum = dpsum + delp
3414 delp = pe2(i,k+1) - pe1(i,km+1)
3417 #ifdef NGGPS_SUBMITTED 3418 qsum = qsum + delp * a4(3,i,km)
3420 qsum = qsum + delp * q1(i,km)
3422 dpsum = dpsum + delp
3424 123 q2(i,k) = qsum / dpsum
3429 end subroutine mappm 3435 subroutine moist_cv(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3436 ice_wat, snowwat, graupel, q, qd, cvm, t1)
3437 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3438 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3439 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3440 real,
intent(out),
dimension(is:ie):: cvm, qd
3441 real,
intent(in),
optional:: t1(is:ie)
3443 real,
parameter:: t_i0 = 15.
3444 real,
dimension(is:ie):: qv, ql, qs
3450 if (
present(t1) )
then 3452 qd(i) = max(0., q(i,j,k,liq_wat))
3453 if ( t1(i) >
tice )
then 3455 elseif ( t1(i) <
tice-t_i0 )
then 3458 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3460 ql(i) = qd(i) - qs(i)
3461 qv(i) = max(0.,q(i,j,k,sphum))
3470 qv(i) = max(0.,q(i,j,k,sphum))
3471 qs(i) = max(0.,q(i,j,k,liq_wat))
3474 cvm(i) = (1.-qv(i))*
cv_air*vicvqd(q(i,j,k,1:num_gas)) + qv(i)*
cv_vap 3482 qv(i) = q(i,j,k,sphum)
3483 ql(i) = q(i,j,k,liq_wat)
3484 qs(i) = q(i,j,k,ice_wat)
3485 qd(i) = ql(i) + qs(i)
3490 qv(i) = q(i,j,k,sphum)
3491 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3493 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 3500 qv(i) = q(i,j,k,sphum)
3501 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3502 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat)
3503 qd(i) = ql(i) + qs(i)
3512 qv(i) = q(i,j,k,sphum)
3513 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3514 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3515 qd(i) = ql(i) + qs(i)
3523 call mpp_error (note,
'fv_mapz::moist_cv - using default cv_air')
3527 cvm(i) =
cv_air*vicvqd(q(i,j,k,1:num_gas))
3538 subroutine moist_cp(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3539 ice_wat, snowwat, graupel, q, qd, cpm, t1)
3541 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3542 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3543 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3544 real,
intent(out),
dimension(is:ie):: cpm, qd
3545 real,
intent(in),
optional:: t1(is:ie)
3547 real,
parameter:: t_i0 = 15.
3548 real,
dimension(is:ie):: qv, ql, qs
3554 if (
present(t1) )
then 3556 qd(i) = max(0., q(i,j,k,liq_wat))
3557 if ( t1(i) >
tice )
then 3559 elseif ( t1(i) <
tice-t_i0 )
then 3562 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3564 ql(i) = qd(i) - qs(i)
3565 qv(i) = max(0.,q(i,j,k,sphum))
3567 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 3569 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3574 qv(i) = max(0.,q(i,j,k,sphum))
3575 qs(i) = max(0.,q(i,j,k,liq_wat))
3578 cpm(i) = (1.-qv(i))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor
3580 cpm(i) = (1.-qv(i))*cp_air + qv(i)*cp_vapor
3587 qv(i) = q(i,j,k,sphum)
3588 ql(i) = q(i,j,k,liq_wat)
3589 qs(i) = q(i,j,k,ice_wat)
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 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3602 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor + qd(i)*
c_liq 3604 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + qd(i)*
c_liq 3609 qv(i) = q(i,j,k,sphum)
3610 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3611 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat)
3612 qd(i) = ql(i) + qs(i)
3614 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 3616 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3621 qv(i) = q(i,j,k,sphum)
3622 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3623 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3624 qd(i) = ql(i) + qs(i)
3626 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 3628 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3632 call mpp_error (note,
'fv_mapz::moist_cp - using default cp_air')
3636 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)