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
94 use fv_mp_mod, only: is_master, mp_reduce_min, mp_reduce_max
98 use ccpp_static_api
, only: ccpp_physics_run
99 use ccpp_data
, only: ccpp_suite
100 use ccpp_data
, only: cdata => cdata_tile
101 use ccpp_data
, only: ccpp_interstitial
110 real,
parameter::
r3 = 1./3.,
r23 = 2./3.,
r12 = 1./12.
112 real,
parameter::
cv_air = cp_air - rdgas
118 real,
parameter::
tice = 273.16
135 mdt, pdt, npx, npy, km, is,ie,js,je, isd,ied,jsd,jed, &
136 nq, nwat, sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, &
137 akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, &
138 ng, ua, va, omga, te, ws, fill, reproduce_sum, out_dt, dtdt, &
139 ptop, ak, bk, pfull, gridstruct, domain, do_sat_adj, &
140 hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init, &
141 c2l_ord, bd, fv_debug, &
143 logical,
intent(in):: last_step
144 logical,
intent(in):: fv_debug
145 real,
intent(in):: mdt
146 real,
intent(in):: pdt
147 integer,
intent(in):: npx, npy
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
159 integer,
intent(in):: c2l_ord
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
181 real,
intent(inout):: pk(is:ie,js:je,km+1)
182 real,
intent(inout):: q(isd:ied,jsd:jed,km,*)
183 real,
intent(inout):: delp(isd:ied,jsd:jed,km)
184 real,
intent(inout):: pe(is-1:ie+1,km+1,js-1:je+1)
185 real,
intent(inout):: ps(isd:ied,jsd:jed)
188 real,
intent(inout):: u(isd:ied ,jsd:jed+1,km)
189 real,
intent(inout):: v(isd:ied+1,jsd:jed ,km)
190 real,
intent(inout):: w(isd: ,jsd: ,1:)
191 real,
intent(inout):: pt(isd:ied ,jsd:jed ,km)
193 real,
intent(inout),
dimension(isd:,jsd:,1:):: q_con, cappa
194 real,
intent(inout),
dimension(is:,js:,1:)::delz
195 logical,
intent(in):: hydrostatic
196 logical,
intent(in):: hybrid_z
197 logical,
intent(in):: out_dt
198 logical,
intent(in):: moist_phys
200 real,
intent(inout):: ua(isd:ied,jsd:jed,km)
201 real,
intent(inout):: va(isd:ied,jsd:jed,km)
202 real,
intent(inout):: omga(isd:ied,jsd:jed,km)
203 real,
intent(inout):: peln(is:ie,km+1,js:je)
204 real,
intent(inout):: dtdt(is:ie,js:je,km)
205 real,
intent(out):: pkz(is:ie,js:je,km)
206 real,
intent(out):: te(isd:ied,jsd:jed,km)
215 real,
allocatable,
dimension(:,:,:) :: dp0, u0, v0
216 real,
allocatable,
dimension(:,:,:) :: u_dt, v_dt
218 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1
220 real,
dimension(is:ie,js:je):: te_2d, zsum0, zsum1, dpln
222 real,
dimension(is:ie,km) :: q2, dp2, t0, w2
223 real,
dimension(is:ie,km+1):: pe1, pe2, pk1, pk2, pn2, phis
224 real,
dimension(isd:ied,jsd:jed,km):: pe4
225 real,
dimension(is:ie+1,km+1):: pe0, pe3
226 real,
dimension(is:ie):: gsize, gz, cvm, qv
228 real rcp, rg, rrg, bkh, dtmp, k1k
230 logical:: fast_mp_consv
235 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, ccn_cm3, iq, n, kp, k_next
238 integer:: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel, ccn_cm3, iq, n, kmp, kp, k_next
242 ccpp_associate: associate( fast_mp_consv => ccpp_interstitial%fast_mp_consv, &
243 kmp => ccpp_interstitial%kmp )
251 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
252 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
253 rainwat = get_tracer_index(model_atmos,
'rainwat')
254 snowwat = get_tracer_index(model_atmos,
'snowwat')
255 graupel = get_tracer_index(model_atmos,
'graupel')
256 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
257 ccn_cm3 = get_tracer_index(model_atmos,
'ccn_cm3')
259 if ( do_adiabatic_init .or. do_sat_adj )
then 260 fast_mp_consv = (.not.do_adiabatic_init) .and. consv>
consv_min 264 if ( pfull(k) > 10.e2 )
exit 291 pe2(i,km+1) = pe(i,km+1,j)
294 if ( j /= (je+1) )
then 295 if ( kord_tm < 0 )
then 297 if ( hydrostatic )
then 302 pkz(i,j,k) = (pk(i,j,k+1)-pk(i,j,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
303 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)))
304 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
306 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)))
314 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
315 ice_wat, snowwat, graupel, q, gz, cvm)
319 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
321 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
323 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)))
328 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)))
330 pt(i,j,k) = pt(i,j,k)*exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
339 elseif ( hydrostatic )
then 340 call pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, ptop)
345 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)))
347 te(i,j,k) = 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
348 v(i,j,k)**2+v(i+1,j,k)**2 - &
349 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)) &
350 + cp_air*pt(i,j,k)*pkz(i,j,k)
355 if ( .not. hydrostatic )
then 358 delz(i,j,k) = -delz(i,j,k) / delp(i,j,k)
365 ps(i,j) = pe1(i,km+1)
372 pe2(i,k) = ak(k) + bk(k)*pe(i,km+1,j)
377 dp2(i,k) = pe2(i,k+1) - pe2(i,k)
386 delp(i,j,k) = dp2(i,k)
400 pn2(i, 1) = peln(i, 1,j)
401 pn2(i,km+1) = peln(i,km+1,j)
402 pk2(i, 1) = pk1(i, 1)
403 pk2(i,km+1) = pk1(i,km+1)
408 pn2(i,k) = log(pe2(i,k))
409 pk2(i,k) = exp(akap*pn2(i,k))
413 if ( kord_tm<0 )
then 419 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm),
t_min)
424 is, ie, j, isd, ied, jsd, jed, 1, abs(kord_tm))
431 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
432 is, ie, isd, ied, jsd, jed, 0., fill)
433 elseif ( nq > 0 )
then 436 call map1_q2(km, pe1, q(isd,jsd,1,iq), &
438 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
439 if (fill)
call fillz(ie-is+1, km, 1, q2, dp2)
442 q(i,j,k,iq) = q2(i,k)
448 if ( .not. hydrostatic )
then 450 call map1_ppm (km, pe1, w, ws(is,j), &
452 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
456 is, ie, j, is, ie, js, je, 1, abs(kord_tm))
459 delz(i,j,k) = -delz(i,j,k)*dp2(i,k)
482 pe3(i,k) = omga(i,j,k-1)
489 pe0(i,k) = peln(i,k,j)
490 peln(i,k,j) = pn2(i,k)
498 if ( hydrostatic )
then 501 pkz(i,j,k) = (pk2(i,k+1)-pk2(i,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
503 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)))
511 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
512 ice_wat, snowwat, graupel, q, gz, cvm)
516 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/
virq(q(i,j,k,1:
num_gas)) )
518 cappa(i,j,k) = rdgas / ( rdgas + cvm(i)/(1.+r_vir*q(i,j,k,sphum)) )
520 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
523 if ( kord_tm < 0 )
then 526 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)))
528 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
536 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)))
538 pkz(i,j,k) = exp(k1k*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
543 if ( last_step .and. (.not.adiabatic) )
then 545 pt(i,j,k) = pt(i,j,k)*pkz(i,j,k)
557 dp2(i,k) = 0.5*(peln(i,k,j) + peln(i,k+1,j))
565 if( dp2(i,n) <= pe0(i,k+1) .and. dp2(i,n) >= pe0(i,k) )
then 566 omga(i,j,n) = pe3(i,k) + (pe3(i,k+1) - pe3(i,k)) * &
567 (dp2(i,n)-pe0(i,k)) / (pe0(i,k+1)-pe0(i,k) )
586 pe0(i,k) = 0.5*(pe(i,k,j-1)+pe1(i,k))
593 pe3(i,k) = ak(k) + bkh*(pe(i,km+1,j-1)+pe1(i,km+1))
597 call map1_ppm( km, pe0(is:ie,:), u, gz, &
598 km, pe3(is:ie,:), u, &
599 is, ie, j, isd, ied, jsd, jed+1, -1, kord_mt)
612 pe0(i,k) = 0.5*(pe(i-1,k, j)+pe(i,k, j))
613 pe3(i,k) = ak(k) + bkh*(pe(i-1,km+1,j)+pe(i,km+1,j))
618 km, pe3, v, is, ie+1, &
619 j, isd, ied+1, jsd, jed, -1, kord_mt)
624 pe4(i,j,k) = pe2(i,k+1)
630 #if defined(CCPP) && defined(__GFORTRAN__) 682 pe(i,k,j) = pe4(i,j,k-1)
688 if( last_step .and. (.not.do_adiabatic_init) )
then 694 if ( hydrostatic )
then 698 gz(i) = gz(i) + rg*pt(i,j,k)*(peln(i,k+1,j)-peln(i,k,j))
702 te_2d(i,j) = pe(i,km+1,j)*hs(i,j) - pe(i,1,j)*gz(i)
707 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*pt(i,j,k) + &
708 0.25*gridstruct%rsin2(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
709 v(i,j,k)**2+v(i+1,j,k)**2 - &
710 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j)))
716 phis(i,km+1) = hs(i,j)
720 phis(i,k) = phis(i,k+1) - grav*delz(i,j,k)
726 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
727 ice_wat, snowwat, graupel, q, gz, cvm)
732 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)) + &
734 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))) + &
736 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
737 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
738 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
743 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)) + &
745 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)) + &
747 0.5*(phis(i,k)+phis(i,k+1) + w(i,j,k)**2 + 0.5*gridstruct%rsin2(i,j)*( &
748 u(i,j,k)**2+u(i,j+1,k)**2 + v(i,j,k)**2+v(i+1,j,k)**2 - &
749 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*gridstruct%cosa_s(i,j))))
756 te_2d(i,j) = te0_2d(i,j) - te_2d(i,j)
757 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
761 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
764 if ( hydrostatic )
then 766 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
773 dtmp = consv*
g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.)
774 e_flux = dtmp / (grav*pdt*4.*pi*radius**2)
776 if ( hydrostatic )
then 777 dtmp = dtmp / (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
779 dtmp = dtmp / (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
788 zsum1(i,j) = pkz(i,j,1)*delp(i,j,1)
792 zsum1(i,j) = zsum1(i,j) + pkz(i,j,k)*delp(i,j,k)
795 if ( hydrostatic )
then 797 zsum0(i,j) = ptop*(pk(i,j,1)-pk(i,j,km+1)) + zsum1(i,j)
804 if ( hydrostatic )
then 805 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
806 (cp*
g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
808 dtmp =
e_flux*(grav*pdt*4.*pi*radius**2) / &
809 (
cv_air*
g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%area_64, 0, reproduce=.true.))
818 if ( do_sat_adj )
then 821 if (cdata%initialized())
then 822 call ccpp_physics_run(cdata, suite_name=trim(ccpp_suite), group_name=
'fast_physics', ierr=ierr)
823 if (ierr/=0)
call mpp_error(fatal,
"Call to ccpp_physics_run for group 'fast_physics' failed")
825 call mpp_error (fatal,
'Lagrangian_to_Eulerian: can not call CCPP fast physics because CCPP not initialized')
832 dpln(i,j) = peln(i,k+1,j) - peln(i,k,j)
835 if (hydrostatic)
then 840 call fv_sat_adj(abs(mdt), r_vir, is, ie, js, je, ng, hydrostatic, fast_mp_consv, &
845 q(isd,jsd,k,sphum), q(isd,jsd,k,liq_wat), &
846 q(isd,jsd,k,ice_wat), q(isd,jsd,k,rainwat), &
847 q(isd,jsd,k,snowwat), q(isd,jsd,k,graupel), &
848 hs, dpln, delz(is:ie,js:je,kdelz), pt(isd,jsd,k), delp(isd,jsd,k), q_con(isd:,jsd:,k), &
849 cappa(isd:,jsd:,k), gridstruct%area_64, dtdt(is,js,k), out_dt, last_step, cld_amt>0, q(isd,jsd,k,cld_amt))
850 if ( .not. hydrostatic )
then 854 pkz(i,j,k) = exp(cappa(i,j,k)*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
857 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)))
859 pkz(i,j,k) = exp(akap*log(rrg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)))
868 if ( fast_mp_consv )
then 873 te0_2d(i,j) = te0_2d(i,j) + te(i,j,k)
882 if ( last_step )
then 891 gz(i) = max(0., q(i,j,k,liq_wat))
892 qv(i) = max(0., q(i,j,k,sphum))
894 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
896 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / ((1.+r_vir*qv(i))*(1.-gz(i)))
899 elseif ( nwat==6 )
then 901 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)
903 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/
virq(q(i,j,k,1:
num_gas))
905 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k))/((1.+r_vir*q(i,j,k,sphum))*(1.-gz(i)))
909 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
910 ice_wat, snowwat, graupel, q, gz, cvm)
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*q(i,j,k,sphum))*(1.-gz(i)))
920 if ( .not. adiabatic )
then 923 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) /
virq(q(i,j,k,1:
num_gas))
925 pt(i,j,k) = (pt(i,j,k)+dtmp*pkz(i,j,k)) / (1.+r_vir*q(i,j,k,sphum))
933 if ( kord_tm < 0 )
then 938 pt(i,j,k) = pt(i,j,k)/pkz(i,j,k)
947 end associate ccpp_associate
956 u, v, w, delz, pt, delp, q, qc, pe, peln, hs, &
958 r_vir, cp, rg, hlv, te_2d, ua, va, teq, &
959 moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
964 integer,
intent(in):: km, is, ie, js, je, isd, ied, jsd, jed, id_te
965 integer,
intent(in):: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, nwat
966 real,
intent(inout),
dimension(isd:ied,jsd:jed,km):: ua, va
967 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: pt, delp
968 real,
intent(in),
dimension(isd:ied,jsd:jed,km,*):: q
969 real,
intent(in),
dimension(isd:ied,jsd:jed,km):: qc
970 real,
intent(inout):: u(isd:ied, jsd:jed+1,km)
971 real,
intent(inout):: v(isd:ied+1,jsd:jed, km)
972 real,
intent(in):: w(isd:,jsd:,1:)
973 real,
intent(in):: delz(is:,js:,1:)
974 real,
intent(in):: hs(isd:ied,jsd:jed)
975 real,
intent(in):: pe(is-1:ie+1,km+1,js-1:je+1)
976 real,
intent(in):: peln(is:ie,km+1,js:je)
977 real,
intent(in):: cp, rg, r_vir, hlv
978 real,
intent(in) :: rsin2_l(isd:ied, jsd:jed)
979 real,
intent(in) :: cosa_s_l(isd:ied, jsd:jed)
980 logical,
intent(in):: moist_phys, hydrostatic
982 real,
intent(out):: te_2d(is:ie,js:je)
983 real,
intent(out):: teq(is:ie,js:je)
985 real,
dimension(is:ie,km):: tv
986 real phiz(is:ie,km+1)
987 real cvm(is:ie), qd(is:ie)
1004 if ( hydrostatic )
then 1007 phiz(i,km+1) = hs(i,j)
1011 tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))
1012 phiz(i,k) = phiz(i,k+1) + rg*tv(i,k)*(peln(i,k+1,j)-peln(i,k,j))
1017 te_2d(i,j) = pe(i,km+1,j)*phiz(i,km+1) - pe(i,1,j)*phiz(i,1)
1022 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(cp*tv(i,k) + &
1023 0.25*rsin2_l(i,j)*(u(i,j,k)**2+u(i,j+1,k)**2 + &
1024 v(i,j,k)**2+v(i+1,j,k)**2 - &
1025 (u(i,j,k)+u(i,j+1,k))*(v(i,j,k)+v(i+1,j,k))*cosa_s_l(i,j)))
1034 phiz(i,km+1) = hs(i,j)
1036 phiz(i,k) = phiz(i,k+1) - grav*delz(i,j,k)
1042 if ( moist_phys )
then 1045 call moist_cv(is,ie,isd,ied,jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
1046 ice_wat, snowwat, graupel, q, qd, cvm)
1050 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*( cvm(i)*pt(i,j,k) + &
1053 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) + &
1055 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1058 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 + &
1059 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))))
1066 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) + &
1068 te_2d(i,j) = te_2d(i,j) + delp(i,j,k)*(
cv_air*pt(i,j,k) + &
1070 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 + &
1071 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 teq(i,j) = te_2d(i,j)
1087 if ( moist_phys )
then 1090 teq(i,j) = teq(i,j) + hlv*q(i,j,k,sphum)*delp(i,j,k)
1099 subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, &
1100 pe, pk, akap, peln, pkz, ptop)
1103 integer,
intent(in):: km, j
1104 integer,
intent(in):: ifirst, ilast
1105 integer,
intent(in):: jfirst, jlast
1106 real,
intent(in):: akap
1107 real,
intent(in):: pe(ifirst-1:ilast+1,km+1,jfirst-1:jlast+1)
1108 real,
intent(in):: pk(ifirst:ilast,jfirst:jlast,km+1)
1109 real,
intent(IN):: ptop
1111 real,
intent(out):: pkz(ifirst:ilast,jfirst:jlast,km)
1112 real,
intent(inout):: peln(ifirst:ilast, km+1, jfirst:jlast)
1114 real pk2(ifirst:ilast, km+1)
1120 ak1 = (akap + 1.) / akap
1122 pek = pk(ifirst,j,1)
1130 pk2(i,k) = pk(i,j,k)
1135 if( ptop < ptop_min )
then 1137 peln(i,1,j) = peln(i,2,j) - ak1
1149 pkz(i,j,k) = (pk2(i,k+1) - pk2(i,k) ) / &
1150 (akap*(peln(i,k+1,j) - peln(i,k,j)) )
1158 subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
1161 integer,
intent(in) :: i1
1162 integer,
intent(in) :: i2
1163 integer,
intent(in) :: kord
1164 integer,
intent(in) :: km
1165 integer,
intent(in) :: kn
1166 integer,
intent(in) :: iv
1168 real,
intent(in) :: pe1(i1:i2,km+1)
1169 real,
intent(in) :: pe2(i1:i2,kn+1)
1170 real,
intent(in) :: q1(i1:i2,km)
1173 real,
intent(inout):: q2(i1:i2,kn)
1179 real pl, pr, qsum, delp, esl
1180 integer i, k, l, m, k0
1184 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1191 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1202 if(pe2(i,k) <= pe1(i,l) .and. pe2(i,k) >= pe1(i,l+1))
then 1203 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1204 if(pe2(i,k+1) >= pe1(i,l+1))
then 1206 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1207 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1208 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1213 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1214 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1215 (
r3*(1.+pl*(1.+pl))))
1218 if(pe2(i,k+1) < pe1(i,m+1) )
then 1220 qsum = qsum + dp1(i,m)*q4(1,i,m)
1222 delp = pe2(i,k+1)-pe1(i,m)
1223 esl = delp / dp1(i,m)
1224 qsum = qsum + delp*(q4(2,i,m)+0.5*esl* &
1225 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1234 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1241 kn, pe2, q2, i1, i2, &
1242 j, ibeg, iend, jbeg, jend, iv, kord, q_min)
1244 integer,
intent(in) :: i1
1245 integer,
intent(in) :: i2
1246 integer,
intent(in) :: iv
1247 integer,
intent(in) :: kord
1248 integer,
intent(in) :: j
1249 integer,
intent(in) :: ibeg, iend, jbeg, jend
1250 integer,
intent(in) :: km
1251 integer,
intent(in) :: kn
1252 real,
intent(in) :: qs(i1:i2)
1253 real,
intent(in) :: pe1(i1:i2,km+1)
1254 real,
intent(in) :: pe2(i1:i2,kn+1)
1255 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1257 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1258 real,
intent(in):: q_min
1269 real pl, pr, qsum, dp, esl
1270 integer i, k, l, m, k0
1274 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1275 q4(1,i,k) = q1(i,j,k)
1291 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1292 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1293 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1295 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1296 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1297 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1302 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1303 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1304 (
r3*(1.+pl*(1.+pl))))
1307 if( pe2(i,k+1) > pe1(i,m+1) )
then 1309 qsum = qsum + dp1(i,m)*q4(1,i,m)
1311 dp = pe2(i,k+1)-pe1(i,m)
1313 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1314 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1323 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1330 subroutine map1_ppm( km, pe1, q1, qs, &
1331 kn, pe2, q2, i1, i2, &
1332 j, ibeg, iend, jbeg, jend, iv, kord)
1333 integer,
intent(in) :: i1
1334 integer,
intent(in) :: i2
1335 integer,
intent(in) :: iv
1336 integer,
intent(in) :: kord
1337 integer,
intent(in) :: j
1338 integer,
intent(in) :: ibeg, iend, jbeg, jend
1339 integer,
intent(in) :: km
1340 integer,
intent(in) :: kn
1341 real,
intent(in) :: qs(i1:i2)
1342 real,
intent(in) :: pe1(i1:i2,km+1)
1343 real,
intent(in) :: pe2(i1:i2,kn+1)
1344 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1346 real,
intent(inout):: q2(ibeg:iend,jbeg:jend,kn)
1358 real pl, pr, qsum, dp, esl
1359 integer i, k, l, m, k0
1363 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1364 q4(1,i,k) = q1(i,j,k)
1370 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1380 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1381 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1382 if( pe2(i,k+1) <= pe1(i,l+1) )
then 1384 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1385 q2(i,j,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1386 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1391 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1392 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1393 (
r3*(1.+pl*(1.+pl))))
1396 if( pe2(i,k+1) > pe1(i,m+1) )
then 1398 qsum = qsum + dp1(i,m)*q4(1,i,m)
1400 dp = pe2(i,k+1)-pe1(i,m)
1402 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1403 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1412 123 q2(i,j,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1419 subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, &
1420 i1, i2, isd, ied, jsd, jed, q_min, fill)
1422 integer,
intent(in):: km
1423 integer,
intent(in):: j, nq, i1, i2
1424 integer,
intent(in):: isd, ied, jsd, jed
1425 integer,
intent(in):: kord(nq)
1426 real,
intent(in):: pe1(i1:i2,km+1)
1427 real,
intent(in):: pe2(i1:i2,km+1)
1428 real,
intent(in):: dp2(i1:i2,km)
1429 real,
intent(in):: q_min
1430 logical,
intent(in):: fill
1431 real,
intent(inout):: q1(isd:ied,jsd:jed,km,nq)
1433 real:: q4(4,i1:i2,km,nq)
1434 real:: q2(i1:i2,km,nq)
1436 real:: dp1(i1:i2,km)
1438 real:: pl, pr, dp, esl, fac1, fac2
1439 integer:: i, k, l, m, k0, iq
1443 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1450 q4(1,i,k,iq) = q1(i,j,k,iq)
1453 call scalar_profile( qs, q4(1,i1,1,iq), dp1, km, i1, i2, 0, kord(iq), q_min )
1462 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1463 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1464 if(pe2(i,k+1) <= pe1(i,l+1))
then 1466 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1468 fac2 =
r3*(pr*fac1 + pl*pl)
1471 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 &
1478 dp = pe1(i,l+1) - pe2(i,k)
1480 fac2 =
r3*(1.+pl*fac1)
1483 qsum(iq) = dp*(q4(2,i,l,iq) + (q4(4,i,l,iq)+ &
1484 q4(3,i,l,iq) - q4(2,i,l,iq))*fac1 - q4(4,i,l,iq)*fac2)
1488 if(pe2(i,k+1) > pe1(i,m+1) )
then 1491 qsum(iq) = qsum(iq) + dp1(i,m)*q4(1,i,m,iq)
1494 dp = pe2(i,k+1)-pe1(i,m)
1499 qsum(iq) = qsum(iq) + dp*( q4(2,i,m,iq) + fac1*( &
1500 q4(3,i,m,iq)-q4(2,i,m,iq)+q4(4,i,m,iq)*fac2 ) )
1512 q2(i,k,iq) = qsum(iq) / dp2(i,k)
1517 if (fill)
call fillz(i2-i1+1, km, nq, q2, dp2)
1523 q1(i,j,k,iq) = q2(i,k,iq)
1531 subroutine map1_q2(km, pe1, q1, &
1533 i1, i2, iv, kord, j, &
1534 ibeg, iend, jbeg, jend, q_min )
1538 integer,
intent(in) :: j
1539 integer,
intent(in) :: i1, i2
1540 integer,
intent(in) :: ibeg, iend, jbeg, jend
1541 integer,
intent(in) :: iv
1542 integer,
intent(in) :: kord
1543 integer,
intent(in) :: km
1544 integer,
intent(in) :: kn
1546 real,
intent(in) :: pe1(i1:i2,km+1)
1547 real,
intent(in) :: pe2(i1:i2,kn+1)
1548 real,
intent(in) :: q1(ibeg:iend,jbeg:jend,km)
1549 real,
intent(in) :: dp2(i1:i2,kn)
1550 real,
intent(in) :: q_min
1552 real,
intent(inout):: q2(i1:i2,kn)
1557 real pl, pr, qsum, dp, esl
1559 integer i, k, l, m, k0
1563 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1564 q4(1,i,k) = q1(i,j,k)
1581 if(pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1))
then 1582 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1583 if(pe2(i,k+1) <= pe1(i,l+1))
then 1585 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1586 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1587 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1592 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1593 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1594 (
r3*(1.+pl*(1.+pl))))
1597 if(pe2(i,k+1) > pe1(i,m+1) )
then 1599 qsum = qsum + dp1(i,m)*q4(1,i,m)
1601 dp = pe2(i,k+1)-pe1(i,m)
1603 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1604 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1613 123 q2(i,k) = qsum / dp2(i,k)
1624 integer,
intent(in):: i1, i2
1625 integer,
intent(in):: iv
1626 integer,
intent(in):: kord
1627 integer,
intent(in):: km
1628 integer,
intent(in):: kn
1629 real,
intent(in):: pe1(i1:i2,km+1)
1630 real,
intent(in):: pe2(i1:i2,kn+1)
1631 real,
intent(in) :: q1(i1:i2,km)
1632 real,
intent(out):: q2(i1:i2,kn)
1637 real pl, pr, qsum, dp, esl
1638 integer i, k, l, m, k0
1642 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
1649 call cs_profile( qs, q4, dp1, km, i1, i2, iv, kord )
1658 if( pe2(i,k+1) <= pe1(i,1) )
then 1661 elseif( pe2(i,k) < pe1(i,1) .and. pe2(i,k+1)>pe1(i,1) )
then 1665 if( pe2(i,k) <= pe1(i,1) )
then 1672 if( pe2(i,k) >= pe1(i,l) .and. pe2(i,k) <= pe1(i,l+1) )
then 1673 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
1674 if(pe2(i,k+1) <= pe1(i,l+1))
then 1676 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
1677 q2(i,k) = q4(2,i,l) + 0.5*(q4(4,i,l)+q4(3,i,l)-q4(2,i,l)) &
1678 *(pr+pl)-q4(4,i,l)*
r3*(pr*(pr+pl)+pl**2)
1683 qsum = (pe1(i,l+1)-pe2(i,k))*(q4(2,i,l)+0.5*(q4(4,i,l)+ &
1684 q4(3,i,l)-q4(2,i,l))*(1.+pl)-q4(4,i,l)* &
1685 (
r3*(1.+pl*(1.+pl))))
1688 if(pe2(i,k+1) > pe1(i,m+1) )
then 1690 qsum = qsum + dp1(i,m)*q4(1,i,m)
1692 dp = pe2(i,k+1)-pe1(i,m)
1694 qsum = qsum + dp*(q4(2,i,m)+0.5*esl* &
1695 (q4(3,i,m)-q4(2,i,m)+q4(4,i,m)*(1.-
r23*esl)))
1704 123 q2(i,k) = qsum / ( pe2(i,k+1) - pe2(i,k) )
1712 subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
1715 integer,
intent(in):: i1, i2
1716 integer,
intent(in):: km
1717 integer,
intent(in):: iv
1718 integer,
intent(in):: kord
1719 real,
intent(in) :: qs(i1:i2)
1720 real,
intent(in) :: delp(i1:i2,km)
1721 real,
intent(inout):: a4(4,i1:i2,km)
1722 real,
intent(in):: qmin
1724 logical,
dimension(i1:i2,km):: extm, ext5, ext6
1728 real bet, a_bot, grat
1729 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
1732 if ( iv .eq. -2 )
then 1735 q(i,1) = 1.5*a4(1,i,1)
1739 grat = delp(i,k-1) / delp(i,k)
1740 bet = 2. + grat + grat - gam(i,k)
1741 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
1742 gam(i,k+1) = grat / bet
1746 grat = delp(i,km-1) / delp(i,km)
1747 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
1748 (2. + grat + grat - gam(i,km))
1753 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
1758 grat = delp(i,2) / delp(i,1)
1759 bet = grat*(grat+0.5)
1760 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
1761 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
1766 d4(i) = delp(i,k-1) / delp(i,k)
1767 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
1768 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
1769 gam(i,k) = d4(i) / bet
1774 a_bot = 1. + d4(i)*(d4(i)+1.5)
1775 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
1776 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
1781 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
1787 if ( abs(kord) > 16 )
then 1791 a4(3,i,k) = q(i,k+1)
1792 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1805 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
1806 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
1811 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
1818 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 1820 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
1821 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
1823 if ( gam(i,k-1) > 0. )
then 1825 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
1828 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
1829 if ( iv==0 ) q(i,k) = max(0., q(i,k))
1837 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
1838 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
1844 a4(3,i,k) = q(i,k+1)
1849 if ( k==1 .or. k==km )
then 1851 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
1855 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
1858 if ( abs(kord) > 9 )
then 1860 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
1861 x1 = abs(a4(2,i,k)-a4(3,i,k))
1863 ext5(i,k) = abs(x0) > x1
1864 ext6(i,k) = abs(a4(4,i,k)) > x1
1877 a4(2,i,1) = max(0., a4(2,i,1))
1879 elseif ( iv==-1 )
then 1881 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
1883 elseif ( iv==2 )
then 1885 a4(2,i,1) = a4(1,i,1)
1886 a4(3,i,1) = a4(1,i,1)
1893 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
1900 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
1908 if ( abs(kord)<9 )
then 1911 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1912 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1913 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1914 max(a4(1,i,k), pmp_1, lac_1) )
1916 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1917 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1918 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1919 max(a4(1,i,k), pmp_2, lac_2) )
1921 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1924 elseif ( abs(kord)==9 )
then 1926 if ( extm(i,k) .and. extm(i,k-1) )
then 1928 a4(2,i,k) = a4(1,i,k)
1929 a4(3,i,k) = a4(1,i,k)
1931 else if ( extm(i,k) .and. extm(i,k+1) )
then 1933 a4(2,i,k) = a4(1,i,k)
1934 a4(3,i,k) = a4(1,i,k)
1936 else if ( extm(i,k) .and. a4(1,i,k)<qmin )
then 1938 a4(2,i,k) = a4(1,i,k)
1939 a4(3,i,k) = a4(1,i,k)
1942 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1944 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1945 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1946 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1947 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1948 max(a4(1,i,k), pmp_1, lac_1) )
1949 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1950 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1951 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1952 max(a4(1,i,k), pmp_2, lac_2) )
1953 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1957 elseif ( abs(kord)==10 )
then 1959 if( ext5(i,k) )
then 1960 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1961 a4(2,i,k) = a4(1,i,k)
1962 a4(3,i,k) = a4(1,i,k)
1963 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
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) )
1973 elseif( ext6(i,k) )
then 1974 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 1975 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
1976 lac_1 = pmp_1 + 1.5*gam(i,k+2)
1977 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
1978 max(a4(1,i,k), pmp_1, lac_1) )
1979 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
1980 lac_2 = pmp_2 - 1.5*gam(i,k-1)
1981 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
1982 max(a4(1,i,k), pmp_2, lac_2) )
1987 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
1989 elseif ( abs(kord)==12 )
then 1991 if( extm(i,k) )
then 1992 a4(2,i,k) = a4(1,i,k)
1993 a4(3,i,k) = a4(1,i,k)
1996 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
1998 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 1999 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2000 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2001 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2002 max(a4(1,i,k), pmp_1, lac_1) )
2003 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2004 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2005 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2006 max(a4(1,i,k), pmp_2, lac_2) )
2007 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2011 elseif ( abs(kord)==13 )
then 2013 if( ext6(i,k) )
then 2014 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2016 a4(2,i,k) = a4(1,i,k)
2017 a4(3,i,k) = a4(1,i,k)
2022 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2024 elseif ( abs(kord)==14 )
then 2027 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2030 elseif ( abs(kord)==15 )
then 2032 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. ext5(i,k+1) )
then 2036 a4(2,i,k) = a4(1,i,k)
2037 a4(3,i,k) = a4(1,i,k)
2038 else if ( ext5(i,k) .and. a4(1,i,k)<qmin )
then 2039 a4(2,i,k) = a4(1,i,k)
2040 a4(3,i,k) = a4(1,i,k)
2041 elseif( ext6(i,k) )
then 2042 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2043 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2044 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2045 max(a4(1,i,k), pmp_1, lac_1) )
2046 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2047 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2048 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2049 max(a4(1,i,k), pmp_2, lac_2) )
2053 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2055 elseif ( abs(kord)==16 )
then 2057 if( ext5(i,k) )
then 2058 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2059 a4(2,i,k) = a4(1,i,k)
2060 a4(3,i,k) = a4(1,i,k)
2061 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2063 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2064 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2065 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2066 max(a4(1,i,k), pmp_1, lac_1) )
2068 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2069 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2070 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2071 max(a4(1,i,k), pmp_2, lac_2) )
2076 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2080 if ( ext5(i,k) .and. (ext5(i,k-1).or.ext5(i,k+1).or.a4(1,i,k)<qmin) )
then 2082 a4(2,i,k) = a4(1,i,k)
2083 a4(3,i,k) = a4(1,i,k)
2086 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2092 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2101 a4(3,i,km) = max(0., a4(3,i,km))
2103 elseif ( iv .eq. -1 )
then 2105 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2111 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2113 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2114 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2119 subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
2122 integer,
intent(in):: i1, i2
2123 integer,
intent(in):: km
2124 integer,
intent(in):: iv
2127 integer,
intent(in):: kord
2128 real,
intent(in) :: qs(i1:i2)
2129 real,
intent(in) :: delp(i1:i2,km)
2130 real,
intent(inout):: a4(4,i1:i2,km)
2132 logical,
dimension(i1:i2,km):: extm, ext5, ext6
2136 real bet, a_bot, grat
2137 real pmp_1, lac_1, pmp_2, lac_2, x0, x1
2140 if ( iv .eq. -2 )
then 2143 q(i,1) = 1.5*a4(1,i,1)
2147 grat = delp(i,k-1) / delp(i,k)
2148 bet = 2. + grat + grat - gam(i,k)
2149 q(i,k) = (3.*(a4(1,i,k-1)+a4(1,i,k)) - q(i,k-1))/bet
2150 gam(i,k+1) = grat / bet
2154 grat = delp(i,km-1) / delp(i,km)
2155 q(i,km) = (3.*(a4(1,i,km-1)+a4(1,i,km)) - grat*qs(i) - q(i,km-1)) / &
2156 (2. + grat + grat - gam(i,km))
2161 q(i,k) = q(i,k) - gam(i,k+1)*q(i,k+1)
2166 grat = delp(i,2) / delp(i,1)
2167 bet = grat*(grat+0.5)
2168 q(i,1) = ( (grat+grat)*(grat+1.)*a4(1,i,1) + a4(1,i,2) ) / bet
2169 gam(i,1) = ( 1. + grat*(grat+1.5) ) / bet
2174 d4(i) = delp(i,k-1) / delp(i,k)
2175 bet = 2. + d4(i) + d4(i) - gam(i,k-1)
2176 q(i,k) = ( 3.*(a4(1,i,k-1)+d4(i)*a4(1,i,k)) - q(i,k-1) )/bet
2177 gam(i,k) = d4(i) / bet
2182 a_bot = 1. + d4(i)*(d4(i)+1.5)
2183 q(i,km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1,i,km)+a4(1,i,km-1)-a_bot*q(i,km)) &
2184 / ( d4(i)*(d4(i)+0.5) - a_bot*gam(i,km) )
2189 q(i,k) = q(i,k) - gam(i,k)*q(i,k+1)
2194 if ( abs(kord) > 16 )
then 2198 a4(3,i,k) = q(i,k+1)
2199 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2213 q(i,2) = min( q(i,2), max(a4(1,i,1), a4(1,i,2)) )
2214 q(i,2) = max( q(i,2), min(a4(1,i,1), a4(1,i,2)) )
2219 gam(i,k) = a4(1,i,k) - a4(1,i,k-1)
2226 if ( gam(i,k-1)*gam(i,k+1)>0. )
then 2228 q(i,k) = min( q(i,k), max(a4(1,i,k-1),a4(1,i,k)) )
2229 q(i,k) = max( q(i,k), min(a4(1,i,k-1),a4(1,i,k)) )
2231 if ( gam(i,k-1) > 0. )
then 2233 q(i,k) = max(q(i,k), min(a4(1,i,k-1),a4(1,i,k)))
2236 q(i,k) = min(q(i,k), max(a4(1,i,k-1),a4(1,i,k)))
2237 if ( iv==0 ) q(i,k) = max(0., q(i,k))
2245 q(i,km) = min( q(i,km), max(a4(1,i,km-1), a4(1,i,km)) )
2246 q(i,km) = max( q(i,km), min(a4(1,i,km-1), a4(1,i,km)) )
2252 a4(3,i,k) = q(i,k+1)
2257 if ( k==1 .or. k==km )
then 2259 extm(i,k) = (a4(2,i,k)-a4(1,i,k)) * (a4(3,i,k)-a4(1,i,k)) > 0.
2263 extm(i,k) = gam(i,k)*gam(i,k+1) < 0.
2266 if ( abs(kord) > 9 )
then 2268 x0 = 2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k))
2269 x1 = abs(a4(2,i,k)-a4(3,i,k))
2271 ext5(i,k) = abs(x0) > x1
2272 ext6(i,k) = abs(a4(4,i,k)) > x1
2285 a4(2,i,1) = max(0., a4(2,i,1))
2287 elseif ( iv==-1 )
then 2289 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2291 elseif ( iv==2 )
then 2293 a4(2,i,1) = a4(1,i,1)
2294 a4(3,i,1) = a4(1,i,1)
2301 a4(4,i,1) = 3.*(2.*a4(1,i,1) - (a4(2,i,1)+a4(3,i,1)))
2308 a4(4,i,2) = 3.*(2.*a4(1,i,2) - (a4(2,i,2)+a4(3,i,2)))
2316 if ( abs(kord)<9 )
then 2319 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2320 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2321 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2322 max(a4(1,i,k), pmp_1, lac_1) )
2324 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2325 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2326 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2327 max(a4(1,i,k), pmp_2, lac_2) )
2329 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2332 elseif ( abs(kord)==9 )
then 2334 if ( extm(i,k) .and. extm(i,k-1) )
then 2336 a4(2,i,k) = a4(1,i,k)
2337 a4(3,i,k) = a4(1,i,k)
2339 else if ( extm(i,k) .and. extm(i,k+1) )
then 2341 a4(2,i,k) = a4(1,i,k)
2342 a4(3,i,k) = a4(1,i,k)
2345 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2347 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2348 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2349 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2350 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2351 max(a4(1,i,k), pmp_1, lac_1) )
2352 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2353 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2354 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2355 max(a4(1,i,k), pmp_2, lac_2) )
2356 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2360 elseif ( abs(kord)==10 )
then 2362 if( ext5(i,k) )
then 2363 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2364 a4(2,i,k) = a4(1,i,k)
2365 a4(3,i,k) = a4(1,i,k)
2366 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
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) )
2376 elseif( ext6(i,k) )
then 2377 if( ext5(i,k-1) .or. ext5(i,k+1) )
then 2378 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2379 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2380 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2381 max(a4(1,i,k), pmp_1, lac_1) )
2382 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2383 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2384 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2385 max(a4(1,i,k), pmp_2, lac_2) )
2390 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2392 elseif ( abs(kord)==12 )
then 2394 if( extm(i,k) )
then 2396 a4(2,i,k) = a4(1,i,k)
2397 a4(3,i,k) = a4(1,i,k)
2400 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2402 if( abs(a4(4,i,k)) > abs(a4(2,i,k)-a4(3,i,k)) )
then 2403 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2404 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2405 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2406 max(a4(1,i,k), pmp_1, lac_1) )
2407 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2408 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2409 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2410 max(a4(1,i,k), pmp_2, lac_2) )
2411 a4(4,i,k) = 6.*a4(1,i,k) - 3.*(a4(2,i,k)+a4(3,i,k))
2415 elseif ( abs(kord)==13 )
then 2417 if( ext6(i,k) )
then 2418 if ( ext6(i,k-1) .and. ext6(i,k+1) )
then 2420 a4(2,i,k) = a4(1,i,k)
2421 a4(3,i,k) = a4(1,i,k)
2426 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2428 elseif ( abs(kord)==14 )
then 2431 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2434 elseif ( abs(kord)==15 )
then 2436 if ( ext5(i,k) )
then 2437 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2439 a4(2,i,k) = a4(1,i,k)
2440 a4(3,i,k) = a4(1,i,k)
2442 elseif( ext6(i,k) )
then 2444 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2445 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2446 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2447 max(a4(1,i,k), pmp_1, lac_1) )
2448 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2449 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2450 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2451 max(a4(1,i,k), pmp_2, lac_2) )
2455 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2457 elseif ( abs(kord)==16 )
then 2459 if( ext5(i,k) )
then 2460 if ( ext5(i,k-1) .or. ext5(i,k+1) )
then 2461 a4(2,i,k) = a4(1,i,k)
2462 a4(3,i,k) = a4(1,i,k)
2463 elseif ( ext6(i,k-1) .or. ext6(i,k+1) )
then 2465 pmp_1 = a4(1,i,k) - 2.*gam(i,k+1)
2466 lac_1 = pmp_1 + 1.5*gam(i,k+2)
2467 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), pmp_1, lac_1)), &
2468 max(a4(1,i,k), pmp_1, lac_1) )
2470 pmp_2 = a4(1,i,k) + 2.*gam(i,k)
2471 lac_2 = pmp_2 - 1.5*gam(i,k-1)
2472 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), pmp_2, lac_2)), &
2473 max(a4(1,i,k), pmp_2, lac_2) )
2478 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2482 if ( ext5(i,k) .and. (ext5(i,k-1) .or. ext5(i,k+1)) )
then 2484 a4(2,i,k) = a4(1,i,k)
2485 a4(3,i,k) = a4(1,i,k)
2488 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2494 if ( iv==0 )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 0)
2503 a4(3,i,km) = max(0., a4(3,i,km))
2505 elseif ( iv .eq. -1 )
then 2507 if ( a4(3,i,km)*a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2513 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2515 if(k==(km-1))
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 2)
2516 if(k== km )
call cs_limiters(im, extm(i1,k), a4(1,i1,k), 1)
2523 integer,
intent(in) :: im
2524 integer,
intent(in) :: iv
2525 logical,
intent(in) :: extm(im)
2526 real ,
intent(inout) :: a4(4,im)
2534 if( a4(1,i)<=0.)
then 2539 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2540 if( (a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12) < 0. )
then 2542 if( a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i) )
then 2546 elseif( a4(3,i) > a4(2,i) )
then 2547 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2548 a4(3,i) = a4(2,i) - a4(4,i)
2550 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2551 a4(2,i) = a4(3,i) - a4(4,i)
2557 elseif ( iv==1 )
then 2559 if( (a4(1,i)-a4(2,i))*(a4(1,i)-a4(3,i))>=0. )
then 2564 da1 = a4(3,i) - a4(2,i)
2567 if(a6da < -da2)
then 2568 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2569 a4(3,i) = a4(2,i) - a4(4,i)
2570 elseif(a6da > da2)
then 2571 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2572 a4(2,i) = a4(3,i) - a4(4,i)
2584 da1 = a4(3,i) - a4(2,i)
2587 if(a6da < -da2)
then 2588 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2589 a4(3,i) = a4(2,i) - a4(4,i)
2590 elseif(a6da > da2)
then 2591 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2592 a4(2,i) = a4(3,i) - a4(4,i)
2601 subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
2604 integer,
intent(in):: iv
2605 integer,
intent(in):: i1
2606 integer,
intent(in):: i2
2607 integer,
intent(in):: km
2608 integer,
intent(in):: kord
2610 real ,
intent(in):: delp(i1:i2,km)
2613 real ,
intent(inout):: a4(4,i1:i2,km)
2630 integer i, k, km1, lmt, it
2632 real a1, a2, c1, c2, c3, d1, d2
2633 real qm, dq, lac, qmp, pmp
2640 delq(i,k-1) = a4(1,i,k) - a4(1,i,k-1)
2641 d4(i,k ) = delp(i,k-1) + delp(i,k)
2647 c1 = (delp(i,k-1)+0.5*delp(i,k))/d4(i,k+1)
2648 c2 = (delp(i,k+1)+0.5*delp(i,k))/d4(i,k)
2649 df2(i,k) = delp(i,k)*(c1*delq(i,k) + c2*delq(i,k-1)) / &
2650 (d4(i,k)+delp(i,k+1))
2651 dc(i,k) = sign( min(abs(df2(i,k)), &
2652 max(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))-a4(1,i,k), &
2653 a4(1,i,k)-min(a4(1,i,k-1),a4(1,i,k),a4(1,i,k+1))), df2(i,k) )
2663 c1 = delq(i,k-1)*delp(i,k-1) / d4(i,k)
2664 a1 = d4(i,k-1) / (d4(i,k) + delp(i,k-1))
2665 a2 = d4(i,k+1) / (d4(i,k) + delp(i,k))
2666 a4(2,i,k) = a4(1,i,k-1) + c1 + 2./(d4(i,k-1)+d4(i,k+1)) * &
2667 ( delp(i,k)*(c1*(a1 - a2)+a2*dc(i,k-1)) - &
2668 delp(i,k-1)*a1*dc(i,k ) )
2679 qm = (d2*a4(1,i,1)+d1*a4(1,i,2)) / (d1+d2)
2680 dq = 2.*(a4(1,i,2)-a4(1,i,1)) / (d1+d2)
2681 c1 = 4.*(a4(2,i,3)-qm-d2*dq) / ( d2*(2.*d2*d2+d1*(d2+3.*d1)) )
2682 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2683 a4(2,i,2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
2686 a4(2,i,1) = d1*(2.*c1*d1**2-c3) + a4(2,i,2)
2691 a4(2,i,2) = max( a4(2,i,2), min(a4(1,i,1), a4(1,i,2)) )
2692 a4(2,i,2) = min( a4(2,i,2), max(a4(1,i,1), a4(1,i,2)) )
2693 dc(i,1) = 0.5*(a4(2,i,2) - a4(1,i,1))
2700 a4(2,i,1) = max(0., a4(2,i,1))
2701 a4(2,i,2) = max(0., a4(2,i,2))
2703 elseif( iv==-1 )
then 2705 if ( a4(2,i,1)*a4(1,i,1) <= 0. ) a4(2,i,1) = 0.
2707 elseif( abs(iv)==2 )
then 2709 a4(2,i,1) = a4(1,i,1)
2710 a4(3,i,1) = a4(1,i,1)
2719 qm = (d2*a4(1,i,km)+d1*a4(1,i,km1)) / (d1+d2)
2720 dq = 2.*(a4(1,i,km1)-a4(1,i,km)) / (d1+d2)
2721 c1 = (a4(2,i,km1)-qm-d2*dq) / (d2*(2.*d2*d2+d1*(d2+3.*d1)))
2722 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
2723 a4(2,i,km) = qm - c1*d1*d2*(d2+3.*d1)
2726 a4(3,i,km) = d1*(8.*c1*d1**2-c3) + a4(2,i,km)
2731 a4(2,i,km) = max( a4(2,i,km), min(a4(1,i,km), a4(1,i,km1)) )
2732 a4(2,i,km) = min( a4(2,i,km), max(a4(1,i,km), a4(1,i,km1)) )
2733 dc(i,km) = 0.5*(a4(1,i,km) - a4(2,i,km))
2742 if( a4(3,i,km) * a4(1,i,km) <= 0. ) a4(3,i,km) = 0.
2743 d1 = a4(1,i,km) - a4(2,i,km)
2744 d2 = a4(3,i,km) - a4(1,i,km)
2745 if ( d1*d2 < 0. )
then 2746 a4(2,i,km) = a4(1,i,km)
2747 a4(3,i,km) = a4(1,i,km)
2749 dq = sign(min(abs(d1),abs(d2),0.5*abs(delq(i,km-1))), d1)
2750 a4(2,i,km) = a4(1,i,km) - dq
2751 a4(3,i,km) = a4(1,i,km) + dq
2757 a4(2,i,km) = max(0.,a4(2,i,km))
2758 a4(3,i,km) = max(0.,a4(3,i,km))
2762 if( a4(1,i,km)*a4(3,i,km) <= 0. ) a4(3,i,km) = 0.
2769 a4(3,i,k) = a4(2,i,k+1)
2779 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2793 h2(i,k) = 2.*(dc(i,k+1)/delp(i,k+1) - dc(i,k-1)/delp(i,k-1)) &
2794 / ( delp(i,k)+0.5*(delp(i,k-1)+delp(i,k+1)) ) &
2810 qmp = a4(1,i,k) + pmp
2811 lac = a4(1,i,k) + fac*h2(i,k-1) + dc(i,k)
2812 a4(3,i,k) = min(max(a4(3,i,k), min(a4(1,i,k), qmp, lac)), &
2813 max(a4(1,i,k), qmp, lac) )
2818 qmp = a4(1,i,k) - pmp
2819 lac = a4(1,i,k) + fac*h2(i,k+1) - dc(i,k)
2820 a4(2,i,k) = min(max(a4(2,i,k), min(a4(1,i,k), qmp, lac)), &
2821 max(a4(1,i,k), qmp, lac))
2825 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2828 if (iv == 0 .and. kord >= 6 ) &
2836 if (iv == 0) lmt = min(2, lmt)
2841 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2844 if(kord/=6)
call ppm_limiters(dc(i1,k), a4(1,i1,k), it, lmt)
2850 a4(4,i,k) = 3.*(2.*a4(1,i,k) - (a4(2,i,k)+a4(3,i,k)))
2861 real ,
intent(in):: dm(*)
2862 integer,
intent(in) :: itot
2863 integer,
intent(in) :: lmt
2867 real ,
intent(inout) :: a4(4,*)
2876 if ( lmt == 3 )
return 2881 if(dm(i) == 0.)
then 2886 da1 = a4(3,i) - a4(2,i)
2889 if(a6da < -da2)
then 2890 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2891 a4(3,i) = a4(2,i) - a4(4,i)
2892 elseif(a6da > da2)
then 2893 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2894 a4(2,i) = a4(3,i) - a4(4,i)
2899 elseif (lmt == 1)
then 2905 a4(2,i) = a4(1,i)-sign(min(abs(qmp),abs(a4(2,i)-a4(1,i))), qmp)
2906 a4(3,i) = a4(1,i)+sign(min(abs(qmp),abs(a4(3,i)-a4(1,i))), qmp)
2907 a4(4,i) = 3.*( 2.*a4(1,i) - (a4(2,i)+a4(3,i)) )
2910 elseif (lmt == 2)
then 2914 if( abs(a4(3,i)-a4(2,i)) < -a4(4,i) )
then 2915 fmin = a4(1,i)+0.25*(a4(3,i)-a4(2,i))**2/a4(4,i)+a4(4,i)*
r12 2916 if( fmin < 0. )
then 2917 if(a4(1,i)<a4(3,i) .and. a4(1,i)<a4(2,i))
then 2921 elseif(a4(3,i) > a4(2,i))
then 2922 a4(4,i) = 3.*(a4(2,i)-a4(1,i))
2923 a4(3,i) = a4(2,i) - a4(4,i)
2925 a4(4,i) = 3.*(a4(3,i)-a4(1,i))
2926 a4(2,i) = a4(3,i) - a4(4,i)
2938 subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
2939 integer,
intent(in) :: km, i1, i2
2940 real ,
intent(in) :: dp(i1:i2,km)
2941 real ,
intent(in) :: dq(i1:i2,km)
2942 real ,
intent(in) :: d4(i1:i2,km)
2943 real ,
intent(in) :: df2(i1:i2,km)
2944 real ,
intent(in) :: dm(i1:i2,km)
2946 real ,
intent(inout) :: a4(4,i1:i2,km)
2957 rat(i,k) = dq(i,k-1) / d4(i,k)
2964 f(i,k) = (rat(i,k+1) - rat(i,k)) &
2965 / ( dp(i,k-1)+dp(i,k)+dp(i,k+1) )
2971 if(f(i,k+1)*f(i,k-1)<0. .and. df2(i,k)/=0.)
then 2972 dg2 = (f(i,k+1)-f(i,k-1))*((dp(i,k+1)-dp(i,k-1))**2 &
2973 + d4(i,k)*d4(i,k+1) )
2974 alfa(i,k) = max(0., min(0.5, -0.1875*dg2/df2(i,k)))
2983 a4(2,i,k) = (1.-alfa(i,k-1)-alfa(i,k)) * a4(2,i,k) + &
2984 alfa(i,k-1)*(a4(1,i,k)-dm(i,k)) + &
2985 alfa(i,k)*(a4(1,i,k-1)+dm(i,k-1))
2994 subroutine rst_remap(km, kn, is,ie,js,je, isd,ied,jsd,jed, nq, ntp, &
2995 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, &
2996 delp, u, v, w, delz, pt, q, qdiag, &
2997 ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, &
2998 domain, square_domain)
3003 integer,
intent(in):: km
3004 integer,
intent(in):: kn
3005 integer,
intent(in):: nq, ntp
3006 integer,
intent(in):: is,ie,isd,ied
3007 integer,
intent(in):: js,je,jsd,jed
3008 logical,
intent(in):: hydrostatic, make_nh, square_domain
3009 real,
intent(IN) :: ptop
3010 real,
intent(in) :: ak_r(km+1)
3011 real,
intent(in) :: bk_r(km+1)
3012 real,
intent(in) :: ak(kn+1)
3013 real,
intent(in) :: bk(kn+1)
3014 real,
intent(in):: delp_r(is:ie,js:je,km)
3015 real,
intent(in):: u_r(is:ie, js:je+1,km)
3016 real,
intent(in):: v_r(is:ie+1,js:je ,km)
3017 real,
intent(inout):: pt_r(is:ie,js:je,km)
3018 real,
intent(in):: w_r(is:ie,js:je,km)
3019 real,
intent(in):: q_r(is:ie,js:je,km,1:ntp)
3020 real,
intent(in):: qdiag_r(is:ie,js:je,km,ntp+1:nq)
3021 real,
intent(inout)::delz_r(is:ie,js:je,km)
3022 type(domain2d),
intent(INOUT) :: domain
3024 real,
intent(out):: delp(isd:ied,jsd:jed,kn)
3025 real,
intent(out):: u(isd:ied ,jsd:jed+1,kn)
3026 real,
intent(out):: v(isd:ied+1,jsd:jed ,kn)
3027 real,
intent(out):: w(isd: ,jsd: ,1:)
3028 real,
intent(out):: pt(isd:ied ,jsd:jed ,kn)
3029 real,
intent(out):: q(isd:ied,jsd:jed,kn,1:ntp)
3030 real,
intent(out):: qdiag(isd:ied,jsd:jed,kn,ntp+1:nq)
3031 real,
intent(out):: delz(is:,js:,1:)
3034 real ps(isd:ied,jsd:jed)
3035 real pe1(is:ie,km+1)
3036 real pe2(is:ie,kn+1)
3037 real pv1(is:ie+1,km+1)
3038 real pv2(is:ie+1,kn+1)
3041 integer,
parameter:: kord=4
3043 #ifdef HYDRO_DELZ_REMAP 3044 if (is_master() .and. .not. hydrostatic)
then 3046 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ' 3051 #ifdef HYDRO_DELZ_EXTRAP 3052 if (is_master() .and. .not. hydrostatic)
then 3054 print*,
' REMAPPING IC: INITIALIZING DELZ WITH HYDROSTATIC STATE ABOVE INPUT MODEL TOP ' 3059 #ifdef ZERO_W_EXTRAP 3060 if (is_master() .and. .not. hydrostatic)
then 3062 print*,
' REMAPPING IC: INITIALIZING W TO ZERO ABOVE INPUT MODEL TOP ' 3067 r_vir = rvgas/rdgas - 1.
3082 ps(i,j) = ps(i,j) + delp_r(i,j,k)
3088 if ( square_domain )
then 3089 call mpp_update_domains(ps, domain, whalo=1, ehalo=1, shalo=1, nhalo=1, complete=.true.)
3091 call mpp_update_domains(ps, domain, complete=.true.)
3100 pt_r(i,j,k) = pt_r(i,j,k) * virq(q_r(i,j,k,:))
3102 pt_r(i,j,k) = pt_r(i,j,k) * (1.+r_vir*q_r(i,j,k,1))
3118 pe1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i,j-1)+ps(i,j))
3124 pe2(i,k) = ak(k) + 0.5*bk(k)*(ps(i,j-1)+ps(i,j))
3128 call remap_2d(km, pe1, u_r(is:ie,j:j,1:km), &
3129 kn, pe2, u(is:ie,j:j,1:kn), &
3132 if ( j /= (je+1) )
then 3139 pe1(i,k) = ak_r(k) + bk_r(k)*ps(i,j)
3145 pe2(i,k) = ak(k) + bk(k)*ps(i,j)
3154 delp(i,j,k) = pe2(i,k+1) - pe2(i,k)
3163 call remap_2d(km, pe1, q_r(is:ie,j:j,1:km,iq:iq), &
3164 kn, pe2, q(is:ie,j:j,1:kn,iq:iq), &
3168 call remap_2d(km, pe1, qdiag_r(is:ie,j:j,1:km,iq:iq), &
3169 kn, pe2, qdiag(is:ie,j:j,1:kn,iq:iq), &
3174 if ( .not. hydrostatic .and. .not. make_nh)
then 3176 call remap_2d(km, pe1, w_r(is:ie,j:j,1:km), &
3177 kn, pe2, w(is:ie,j:j,1:kn), &
3180 #ifdef ZERO_W_EXTRAP 3183 if (pe2(i,k) < pe1(i,1))
then 3190 #ifndef HYDRO_DELZ_REMAP 3194 delz_r(i,j,k) = -delz_r(i,j,k)/delp_r(i,j,k)
3197 call remap_2d(km, pe1, delz_r(is:ie,j:j,1:km), &
3198 kn, pe2, delz(is:ie,j:j,1:kn), &
3202 delz(i,j,k) = -delz(i,j,k)*delp(i,j,k)
3211 pe1(i,k) = log(pe1(i,k))
3216 pe2(i,k) = log(pe2(i,k))
3220 call remap_2d(km, pe1, pt_r(is:ie,j:j,1:km), &
3221 kn, pe2, pt(is:ie,j:j,1:kn), &
3224 #ifdef HYDRO_DELZ_REMAP 3228 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3232 #ifdef HYDRO_DELZ_EXTRAP 3236 if (pe2(i,k) < pe1(i,1))
then 3237 delz(i,j,k) = (rdgas*rgrav)*pt(i,j,k)*(pe2(i,k)-pe2(i,k+1))
3247 pv1(i,k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1,j)+ps(i,j))
3252 pv2(i,k) = ak(k) + 0.5*bk(k)*(ps(i-1,j)+ps(i,j))
3256 call remap_2d(km, pv1, v_r(is:ie+1,j:j,1:km), &
3257 kn, pv2, v(is:ie+1,j:j,1:kn), &
3268 pt(i,j,k) = pt(i,j,k) / virq(q(i,j,k,:))
3270 pt(i,j,k) = pt(i,j,k) / (1.+r_vir*q(i,j,k,1))
3280 subroutine mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
3293 integer,
intent(in):: i1, i2, km, kn, kord, iv
3294 real,
intent(in ):: pe1(i1:i2,km+1), pe2(i1:i2,kn+1)
3299 real,
intent(in ):: q1(i1:i2,km)
3300 real,
intent(out):: q2(i1:i2,kn)
3301 real,
intent(IN) :: ptop
3308 real pl, pr, tt, delp, qsum, dpsum, esl
3312 dp1(i,k) = pe1(i,k+1) - pe1(i,k)
3318 call cs_profile( qs, a4, dp1, km, i1, i2, iv, kord )
3326 #ifdef NGGPS_SUBMITTED 3328 a4(2,i,km) = q1(i,km)
3329 a4(3,i,km) = q1(i,km)
3338 if(pe2(i,k) .le. pe1(i,1))
then 3341 elseif(pe2(i,k) .ge. pe1(i,km+1))
then 3343 #ifdef NGGPS_SUBMITTED 3344 q2(i,k) = a4(3,i,km)
3352 if( pe2(i,k) .ge. pe1(i,l) .and. &
3353 pe2(i,k) .le. pe1(i,l+1) )
then 3355 pl = (pe2(i,k)-pe1(i,l)) / dp1(i,l)
3356 if(pe2(i,k+1) .le. pe1(i,l+1))
then 3359 pr = (pe2(i,k+1)-pe1(i,l)) / dp1(i,l)
3360 tt =
r3*(pr*(pr+pl)+pl**2)
3361 q2(i,k) = a4(2,i,l) + 0.5*(a4(4,i,l)+a4(3,i,l) &
3362 - a4(2,i,l))*(pr+pl) - a4(4,i,l)*tt
3366 delp = pe1(i,l+1) - pe2(i,k)
3367 tt =
r3*(1.+pl*(1.+pl))
3368 qsum = delp*(a4(2,i,l)+0.5*(a4(4,i,l)+ &
3369 a4(3,i,l)-a4(2,i,l))*(1.+pl)-a4(4,i,l)*tt)
3379 if( pe2(i,k+1) .gt. pe1(i,l+1) )
then 3383 qsum = qsum + dp1(i,l)*q1(i,l)
3384 dpsum = dpsum + dp1(i,l)
3386 delp = pe2(i,k+1)-pe1(i,l)
3387 esl = delp / dp1(i,l)
3388 qsum = qsum + delp * (a4(2,i,l)+0.5*esl* &
3389 (a4(3,i,l)-a4(2,i,l)+a4(4,i,l)*(1.-
r23*esl)) )
3390 dpsum = dpsum + delp
3395 delp = pe2(i,k+1) - pe1(i,km+1)
3398 #ifdef NGGPS_SUBMITTED 3399 qsum = qsum + delp * a4(3,i,km)
3401 qsum = qsum + delp * q1(i,km)
3403 dpsum = dpsum + delp
3405 123 q2(i,k) = qsum / dpsum
3410 end subroutine mappm 3416 subroutine moist_cv(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3417 ice_wat, snowwat, graupel, q, qd, cvm, t1)
3418 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3419 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3421 real,
intent(in),
dimension(isd:ied,jsd:jed,km,num_gas):: q
3423 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3426 real,
intent(out),
dimension(is:ie):: cvm, qd
3427 real,
intent(in),
optional:: t1(is:ie)
3429 real,
parameter:: t_i0 = 15.
3430 real,
dimension(is:ie):: qv, ql, qs
3436 if (
present(t1) )
then 3438 qd(i) = max(0., q(i,j,k,liq_wat))
3439 if ( t1(i) >
tice )
then 3441 elseif ( t1(i) <
tice-t_i0 )
then 3444 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3446 ql(i) = qd(i) - qs(i)
3447 qv(i) = max(0.,q(i,j,k,sphum))
3456 qv(i) = max(0.,q(i,j,k,sphum))
3457 qs(i) = max(0.,q(i,j,k,liq_wat))
3460 cvm(i) = (1.-qv(i))*
cv_air*vicvqd(q(i,j,k,1:num_gas)) + qv(i)*
cv_vap 3468 qv(i) = q(i,j,k,sphum)
3469 ql(i) = q(i,j,k,liq_wat)
3470 qs(i) = q(i,j,k,ice_wat)
3471 qd(i) = ql(i) + qs(i)
3477 qv(i) = q(i,j,k,sphum)
3478 qd(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3480 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 3485 qv(i) = q(i,j,k,sphum)
3486 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3487 qs(i) = q(i,j,k,ice_wat)
3488 qd(i) = ql(i) + qs(i)
3499 qv(i) = q(i,j,k,sphum)
3500 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3501 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat)
3502 qd(i) = ql(i) + qs(i)
3511 qv(i) = q(i,j,k,sphum)
3512 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3513 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3514 qd(i) = ql(i) + qs(i)
3522 call mpp_error (note,
'fv_mapz::moist_cv - using default cv_air')
3526 cvm(i) =
cv_air*vicvqd(q(i,j,k,1:num_gas))
3537 subroutine moist_cp(is,ie, isd,ied, jsd,jed, km, j, k, nwat, sphum, liq_wat, rainwat, &
3538 ice_wat, snowwat, graupel, q, qd, cpm, t1)
3540 integer,
intent(in):: is, ie, isd,ied, jsd,jed, km, nwat, j, k
3541 integer,
intent(in):: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
3542 real,
intent(in),
dimension(isd:ied,jsd:jed,km,nwat):: q
3543 real,
intent(out),
dimension(is:ie):: cpm, qd
3544 real,
intent(in),
optional:: t1(is:ie)
3546 real,
parameter:: t_i0 = 15.
3547 real,
dimension(is:ie):: qv, ql, qs
3553 if (
present(t1) )
then 3555 qd(i) = max(0., q(i,j,k,liq_wat))
3556 if ( t1(i) >
tice )
then 3558 elseif ( t1(i) <
tice-t_i0 )
then 3561 qs(i) = qd(i)*(
tice-t1(i))/t_i0
3563 ql(i) = qd(i) - qs(i)
3564 qv(i) = max(0.,q(i,j,k,sphum))
3566 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 3568 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3573 qv(i) = max(0.,q(i,j,k,sphum))
3574 qs(i) = max(0.,q(i,j,k,liq_wat))
3577 cpm(i) = (1.-qv(i))*cp_air*vicpqd(q(i,j,k,:)) + qv(i)*cp_vapor
3579 cpm(i) = (1.-qv(i))*cp_air + qv(i)*cp_vapor
3586 qv(i) = q(i,j,k,sphum)
3587 ql(i) = q(i,j,k,liq_wat)
3588 qs(i) = q(i,j,k,ice_wat)
3589 qd(i) = ql(i) + qs(i)
3591 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 3593 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 3607 qv(i) = q(i,j,k,sphum)
3608 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3609 qs(i) = q(i,j,k,ice_wat)
3610 qd(i) = ql(i) + qs(i)
3612 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 3614 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3622 qv(i) = q(i,j,k,sphum)
3623 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3624 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat)
3625 qd(i) = ql(i) + qs(i)
3627 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 3629 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3634 qv(i) = q(i,j,k,sphum)
3635 ql(i) = q(i,j,k,liq_wat) + q(i,j,k,rainwat)
3636 qs(i) = q(i,j,k,ice_wat) + q(i,j,k,snowwat) + q(i,j,k,graupel)
3637 qd(i) = ql(i) + qs(i)
3639 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 3641 cpm(i) = (1.-(qv(i)+qd(i)))*cp_air + qv(i)*cp_vapor + ql(i)*
c_liq + qs(i)*
c_ice 3645 call mpp_error (note,
'fv_mapz::moist_cp - using default cp_air')
3649 cpm(i) = cp_air*vicpqd(q(i,j,k,:))
real, parameter c_liq
GFS: heat capacity of water at 0C.
subroutine, public lagrangian_to_eulerian(last_step, consv, ps, pe, delp, pkz, pk, mdt, pdt, npx, npy, 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, c2l_ord, bd, fv_debug, moist_phys)
The subroutine 'Lagrangian_to_Eulerian' remaps deformed Lagrangian layers back to the reference Euler...
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...
integer, parameter, public r_grid
subroutine ppm_limiters(dm, a4, itot, lmt)
real, parameter c_ice
heat capacity of ice at -15.C
logical, parameter w_limiter
pure real function, public virqd(q)
real, parameter consv_min
below which no correction applies
subroutine, public remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
The module 'fv_timing' contains FV3 timers.
pure real function, public virq(q)
real, parameter cv_vap
1384.5
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.
subroutine, public cubed_to_latlon(u, v, ua, va, gridstruct, npx, npy, km, mode, grid_type, domain, bounded_domain, c2l_ord, bd)
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, public update_dwinds_phys(is, ie, js, je, isd, ied, jsd, jed, dt, u_dt, v_dt, u, v, gridstruct, npx, npy, npz, domain)
The subroutine 'update_dwinds_phys' transforms the wind tendencies from the A grid to the D grid for ...
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)