44 real,
parameter::
r2=1./2.,
r0=0.0
45 real,
parameter::
r3 = 1./3.,
r23 = 2./3.,
r12 = 1./12.
50 real,
parameter::
c_liq = 4.1855e+3
53 real,
parameter::
tice = 273.16
70 & , pe_tl, delp, delp_tl, pkz, pkz_tl, pk, pk_tl, mdt, pdt, km, is, ie&
71 & , js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, u_tl, v, &
72 & v_tl, w, w_tl, delz, delz_tl, pt, pt_tl, q, q_tl, hs, r_vir, cp, &
73 & akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, peln_tl, &
74 & te0_2d, te0_2d_tl, ng, ua, ua_tl, va, omga, omga_tl, te, te_tl, ws, &
75 & ws_tl, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, &
76 & flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, &
77 & do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, &
78 & kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
81 LOGICAL,
INTENT(IN) :: last_step
83 REAL,
INTENT(IN) :: mdt
85 REAL,
INTENT(IN) :: pdt
86 INTEGER,
INTENT(IN) :: km
88 INTEGER,
INTENT(IN) :: nq
89 INTEGER,
INTENT(IN) :: nwat
91 INTEGER,
INTENT(IN) :: sphum
92 INTEGER,
INTENT(IN) :: ng
94 INTEGER,
INTENT(IN) :: is, ie, isd, ied
96 INTEGER,
INTENT(IN) :: js, je, jsd, jed
98 INTEGER,
INTENT(IN) :: kord_mt
100 INTEGER,
INTENT(IN) :: kord_wz
102 INTEGER,
INTENT(IN) :: kord_tr(nq)
104 INTEGER,
INTENT(IN) :: kord_tm
106 INTEGER,
INTENT(IN) :: kord_mt_pert
108 INTEGER,
INTENT(IN) :: kord_wz_pert
110 INTEGER,
INTENT(IN) :: kord_tr_pert(nq)
112 INTEGER,
INTENT(IN) :: kord_tm_pert
114 REAL,
INTENT(IN) :: consv
115 REAL,
INTENT(IN) :: r_vir
116 REAL,
INTENT(IN) :: cp
117 REAL,
INTENT(IN) :: akap
119 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
120 REAL,
INTENT(INOUT) :: te0_2d(is:ie, js:je)
121 REAL,
INTENT(INOUT) :: te0_2d_tl(is:ie, js:je)
122 REAL,
INTENT(IN) :: ws(is:ie, js:je)
123 REAL,
INTENT(IN) :: ws_tl(is:ie, js:je)
124 LOGICAL,
INTENT(IN) :: do_sat_adj
126 LOGICAL,
INTENT(IN) :: fill
127 LOGICAL,
INTENT(IN) :: reproduce_sum
128 LOGICAL,
INTENT(IN) :: do_omega, adiabatic, do_adiabatic_init
129 REAL,
INTENT(IN) :: ptop
130 REAL,
INTENT(IN) :: ak(km+1)
131 REAL,
INTENT(IN) :: bk(km+1)
132 REAL,
INTENT(IN) :: pfull(km)
135 TYPE(
domain2d),
INTENT(INOUT) :: domain
138 REAL,
INTENT(INOUT) :: pk(is:ie, js:je, km+1)
139 REAL,
INTENT(INOUT) :: pk_tl(is:ie, js:je, km+1)
140 REAL,
INTENT(INOUT) :: q(isd:ied, jsd:jed, km, nq)
141 REAL,
INTENT(INOUT) :: q_tl(isd:ied, jsd:jed, km, nq)
143 REAL,
INTENT(INOUT) :: delp(isd:ied, jsd:jed, km)
144 REAL,
INTENT(INOUT) :: delp_tl(isd:ied, jsd:jed, km)
146 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
147 REAL,
INTENT(INOUT) :: pe_tl(is-1:ie+1, km+1, js-1:je+1)
149 REAL,
INTENT(INOUT) :: ps(isd:ied, jsd:jed)
150 REAL,
INTENT(INOUT) :: ps_tl(isd:ied, jsd:jed)
153 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
154 REAL,
INTENT(INOUT) :: u_tl(isd:ied, jsd:jed+1, km)
156 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
157 REAL,
INTENT(INOUT) :: v_tl(isd:ied+1, jsd:jed, km)
159 REAL,
INTENT(INOUT) :: w(isd:ied, jsd:jed, km)
160 REAL,
INTENT(INOUT) :: w_tl(isd:ied, jsd:jed, km)
162 REAL,
INTENT(INOUT) :: pt(isd:ied, jsd:jed, km)
163 REAL,
INTENT(INOUT) :: pt_tl(isd:ied, jsd:jed, km)
165 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz
166 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz_tl
167 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: q_con, cappa
168 LOGICAL,
INTENT(IN) :: hydrostatic
169 LOGICAL,
INTENT(IN) :: hybrid_z
170 LOGICAL,
INTENT(IN) :: out_dt
172 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
173 REAL,
INTENT(INOUT) :: ua_tl(isd:ied, jsd:jed, km)
175 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
177 REAL,
INTENT(INOUT) :: omga(isd:ied, jsd:jed, km)
178 REAL,
INTENT(INOUT) :: omga_tl(isd:ied, jsd:jed, km)
180 REAL,
INTENT(INOUT) :: peln(is:ie, km+1, js:je)
181 REAL,
INTENT(INOUT) :: peln_tl(is:ie, km+1, js:je)
182 REAL,
INTENT(INOUT) :: dtdt(is:ie, js:je, km)
184 REAL,
INTENT(OUT) :: pkz(is:ie, js:je, km)
185 REAL,
INTENT(OUT) :: pkz_tl(is:ie, js:je, km)
186 REAL,
INTENT(OUT) :: te(isd:ied, jsd:jed, km)
187 REAL,
INTENT(OUT) :: te_tl(isd:ied, jsd:jed, km)
190 REAL,
OPTIONAL,
INTENT(INOUT) :: mfx(is:ie+1, js:je, km)
192 REAL,
OPTIONAL,
INTENT(INOUT) :: mfy(is:ie, js:je+1, km)
194 INTEGER,
INTENT(IN) :: remap_option
203 REAL,
DIMENSION(is:ie, js:je) :: te_2d, zsum0, zsum1, dpln
204 REAL,
DIMENSION(is:ie, js:je) :: te_2d_tl, zsum0_tl, zsum1_tl
205 REAL,
DIMENSION(is:ie, km) :: q2, dp2
206 REAL,
DIMENSION(is:ie, km) :: q2_tl, dp2_tl
207 REAL,
DIMENSION(is:ie, km+1) :: pe1, pe2, pk1, pk2, pn2, phis
208 REAL,
DIMENSION(is:ie, km+1) :: pe1_tl, pe2_tl, pk1_tl, pk2_tl, &
210 REAL,
DIMENSION(is:ie+1, km+1) :: pe0, pe3
211 REAL,
DIMENSION(is:ie+1, km+1) :: pe0_tl, pe3_tl
212 REAL,
DIMENSION(is:ie) :: gz, cvm, qv
213 REAL,
DIMENSION(is:ie) :: gz_tl
214 REAL :: rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
215 REAL :: tmp_tl, tpe_tl, dtmp_tl, dlnp_tl
216 LOGICAL :: fast_mp_consv
218 INTEGER :: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel&
219 & , iq, n, kmp, kp, k_next
220 LOGICAL :: remap_t, remap_pt, remap_te
221 INTEGER :: abs_kord_tm, abs_kord_tm_pert
222 INTEGER :: iep1, jep1, iedp1, jedp1
235 REAL :: pt_tj(isd:ied, jsd:jed, km)
236 REAL :: q_tj(isd:ied, jsd:jed, km, nq)
237 REAL :: q2_tj(is:ie, km)
238 REAL :: delz_tj(isd:ied, jsd:jed, km)
239 REAL :: u_tj(isd:ied, jsd:jed+1, km)
240 REAL :: v_tj(isd:ied+1, jsd:jed, km)
241 REAL :: w_tj(isd:ied, jsd:jed, km)
243 IF (kord_tm .GE. 0.)
THEN 244 abs_kord_tm = kord_tm
246 abs_kord_tm = -kord_tm
248 IF (kord_tm_pert .GE. 0.)
THEN 249 abs_kord_tm_pert = kord_tm_pert
251 abs_kord_tm_pert = -kord_tm_pert
260 SELECT CASE (remap_option)
268 print*,
' INVALID REMAPPING OPTION ' 271 IF (is_master() .AND. flagstruct%fv_debug)
THEN 273 SELECT CASE (remap_option)
275 print*,
' REMAPPING T in logP ' 277 print*,
' REMAPPING PT in P' 279 print*,
' REMAPPING TE in logP with GMAO cubic' 281 print*,
' REMAPPING CONSV: ', consv
282 print*,
' REMAPPING CONSV_MIN: ',
consv_min 285 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-0 PT', pt, is, ie, js&
286 & , je, ng, km, 1., gridstruct%area_64&
293 IF (
fpp%fpp_mapl_mode)
THEN 309 fast_mp_consv = .NOT.do_adiabatic_init .AND. consv .GT.
consv_min 312 IF (pfull(k) .GT. 10.e2)
EXIT 348 pe1_tl(i, k) = pe_tl(i, k, j)
349 pe1(i, k) = pe(i, k, j)
355 pe2_tl(i, km+1) = pe_tl(i, km+1, j)
356 pe2(i, km+1) = pe(i, km+1, j)
359 IF (j .NE. je + 1)
THEN 364 IF (hydrostatic)
THEN 368 pt_tl(i, j, k) = ((pt_tl(i, j, k)*(pk(i, j, k+1)-pk(i, j&
369 & , k))+pt(i, j, k)*(pk_tl(i, j, k+1)-pk_tl(i, j, k)))*&
370 & akap*(peln(i, k+1, j)-peln(i, k, j))-pt(i, j, k)*(pk(i&
371 & , j, k+1)-pk(i, j, k))*akap*(peln_tl(i, k+1, j)-&
372 & peln_tl(i, k, j)))/(akap*(peln(i, k+1, j)-peln(i, k, j&
374 pt(i, j, k) = pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k))/(&
375 & akap*(peln(i, k+1, j)-peln(i, k, j)))
382 arg1_tl = (rrg*delp_tl(i, j, k)*delz(i, j, k)-rrg*delp(i&
383 & , j, k)*delz_tl(i, j, k))*pt(i, j, k)/delz(i, j, k)**2&
384 & + rrg*delp(i, j, k)*pt_tl(i, j, k)/delz(i, j, k)
385 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
386 arg2_tl = k1k*arg1_tl/arg1
388 pt_tl(i, j, k) = pt_tl(i, j, k)*exp(arg2) + pt(i, j, k)*&
390 pt(i, j, k) = pt(i, j, k)*exp(arg2)
394 ELSE IF (.NOT.remap_pt)
THEN 403 CALL pkez_tlm(km, is, ie, js, je, j, pe, pk, pk_tl, akap, &
404 & peln, peln_tl, pkz, pkz_tl, ptop)
408 te_tl(i, j, k) = 0.25*gridstruct%rsin2(i, j)*(2*u(i, j, &
409 & k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(i&
410 & , j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k)-&
411 & gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl(i, j+1, k&
412 & ))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+1, k))&
413 & *(v_tl(i, j, k)+v_tl(i+1, j, k)))) +
cp_air*(pt_tl(i, &
414 & j, k)*pkz(i, j, k)+pt(i, j, k)*pkz_tl(i, j, k))
415 te(i, j, k) = 0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2&
416 & +u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j&
417 & , k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
418 & gridstruct%cosa_s(i, j)) +
cp_air*pt(i, j, k)*pkz(i, j&
424 IF (.NOT.hydrostatic)
THEN 428 delz_tl(i, j, k) = -((delz_tl(i, j, k)*delp(i, j, k)-delz(&
429 & i, j, k)*delp_tl(i, j, k))/delp(i, j, k)**2)
430 delz(i, j, k) = -(delz(i, j, k)/delp(i, j, k))
436 ps_tl(i, j) = pe1_tl(i, km+1)
437 ps(i, j) = pe1(i, km+1)
444 pe2_tl(i, k) = bk(k)*pe_tl(i, km+1, j)
445 pe2(i, k) = ak(k) + bk(k)*pe(i, km+1, j)
450 dp2_tl(i, k) = pe2_tl(i, k+1) - pe2_tl(i, k)
451 dp2(i, k) = pe2(i, k+1) - pe2(i, k)
459 delp_tl(i, j, k) = dp2_tl(i, k)
460 delp(i, j, k) = dp2(i, k)
468 pk1_tl(i, k) = pk_tl(i, j, k)
469 pk1(i, k) = pk(i, j, k)
473 pn2_tl(i, 1) = peln_tl(i, 1, j)
474 pn2(i, 1) = peln(i, 1, j)
475 pn2_tl(i, km+1) = peln_tl(i, km+1, j)
476 pn2(i, km+1) = peln(i, km+1, j)
477 pk2_tl(i, 1) = pk1_tl(i, 1)
478 pk2(i, 1) = pk1(i, 1)
479 pk2_tl(i, km+1) = pk1_tl(i, km+1)
480 pk2(i, km+1) = pk1(i, km+1)
484 pn2_tl(i, k) = pe2_tl(i, k)/pe2(i, k)
485 pn2(i, k) = log(pe2(i, k))
486 pk2_tl(i, k) = akap*pn2_tl(i, k)*exp(akap*pn2(i, k))
487 pk2(i, k) = exp(akap*pn2(i, k))
494 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 496 & is:ie, 1:km+1, j), gz, km, pn2, pn2_tl, pt&
497 & , pt_tl, is, ie, j, isd, ied, jsd, jed, 1, &
498 & abs_kord_tm,
t_min)
502 & ie, 1:km+1, j), gz, km, pn2, pn2_tl, pt_tj, pt_tl&
503 & , is, ie, j, isd, ied, jsd, jed, 1, &
504 & abs_kord_tm_pert,
t_min)
505 call map_scalar(km, peln(is:ie,1:km+1,j), gz, &
507 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm,
t_min)
509 ELSE IF (remap_pt)
THEN 513 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 515 CALL map1_ppm_tlm(km, pe1, pe1_tl, gz, gz_tl, km, pe2, &
516 & pe2_tl, pt, pt_tl, is, ie, j, isd, ied, jsd, &
517 & jed, 1, abs_kord_tm)
521 CALL map1_ppm_tlm(km, pe1, pe1_tl, gz, gz_tl, km, pe2, &
522 & pe2_tl, pt_tj, pt_tl, is, ie, j, isd, ied, jsd, jed&
523 & , 1, abs_kord_tm_pert)
526 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm)
528 ELSE IF (remap_te)
THEN 533 phis_tl(i, km+1) = 0.0
534 phis(i, km+1) = hs(i, j)
538 phis_tl(i, k) = phis_tl(i, k+1) +
cp_air*(pt_tl(i, j, k)*(&
539 & pk1(i, k+1)-pk1(i, k))+pt(i, j, k)*(pk1_tl(i, k+1)-&
541 phis(i, k) = phis(i, k+1) +
cp_air*pt(i, j, k)*(pk1(i, k+1&
547 phis_tl(i, k) = phis_tl(i, k)*pe1(i, k) + phis(i, k)*&
549 phis(i, k) = phis(i, k)*pe1(i, k)
554 te_tl(i, j, k) = te_tl(i, j, k) + ((phis_tl(i, k+1)-&
555 & phis_tl(i, k))*(pe1(i, k+1)-pe1(i, k))-(phis(i, k+1)-&
556 & phis(i, k))*(pe1_tl(i, k+1)-pe1_tl(i, k)))/(pe1(i, k+1)-&
558 te(i, j, k) = te(i, j, k) + (phis(i, k+1)-phis(i, k))/(pe1&
559 & (i, k+1)-pe1(i, k))
564 & te_tl, is, ie, j, isd, ied, jsd, jed, akap, &
565 & t_var=1, conserv=.true.)
571 IF (kord_tr(1) .EQ. kord_tr_pert(1))
THEN 573 & , q_tl, dp2, dp2_tl, kord_tr, j, is, ie, &
574 & isd, ied, jsd, jed, 0., fill)
578 & q_tl, dp2, dp2_tl, kord_tr_pert, j, is, ie, &
579 & isd, ied, jsd, jed, 0., fill)
580 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
581 is, ie, isd, ied, jsd, jed, 0., fill)
583 ELSE IF (nq .GT. 0)
THEN 586 IF (kord_tr(iq) .EQ. kord_tr_pert(iq))
THEN 587 CALL map1_q2_tlm(km, pe1, pe1_tl, q(isd:ied, jsd:jed, 1&
588 & :km, iq), q_tl(isd:ied, jsd:jed, 1:km, iq), &
589 & km, pe2, pe2_tl, q2, q2_tl, dp2, dp2_tl, is&
590 & , ie, 0, kord_tr(iq), j, isd, ied, jsd, jed&
594 CALL map1_q2_tlm(km, pe1, pe1_tl, q(isd:ied, jsd:jed, 1:km&
595 & , iq), q_tl(isd:ied, jsd:jed, 1:km, iq), km, &
596 & pe2, pe2_tl, q2_tj, q2_tl, dp2, dp2_tl, is, ie, 0&
597 & , kord_tr_pert(iq), j, isd, ied, jsd, jed, 0.)
598 call map1_q2(km, pe1, q(isd:ied,jsd:jed,1:km,iq), &
600 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
602 IF (fill)
CALL fillz(ie - is + 1, km, 1, q2, dp2)
605 q_tl(i, j, k, iq) = q2_tl(i, k)
606 q(i, j, k, iq) = q2(i, k)
611 IF (.NOT.hydrostatic)
THEN 613 IF (kord_wz .EQ. kord_wz_pert)
THEN 614 CALL map1_ppm_tlm(km, pe1, pe1_tl, ws(is:ie, j), ws_tl(is&
615 & :ie, j), km, pe2, pe2_tl, w, w_tl, is, ie, j&
616 & , isd, ied, jsd, jed, -2, kord_wz)
619 CALL map1_ppm_tlm(km, pe1, pe1_tl, ws(is:ie, j), ws_tl(is:ie&
620 & , j), km, pe2, pe2_tl, w_tj, w_tl, is, ie, j, isd, &
621 & ied, jsd, jed, -2, kord_wz_pert)
622 call map1_ppm (km, pe1, ws(is:ie,j), &
624 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
627 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 629 CALL map1_ppm_tlm(km, pe1, pe1_tl, gz, gz_tl, km, pe2, &
630 & pe2_tl, delz, delz_tl, is, ie, j, isd, ied, &
631 & jsd, jed, 1, abs_kord_tm)
635 CALL map1_ppm_tlm(km, pe1, pe1_tl, gz, gz_tl, km, pe2, &
636 & pe2_tl, delz_tj, delz_tl, is, ie, j, isd, ied, jsd&
637 & , jed, 1, abs_kord_tm_pert)
640 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm)
644 delz_tl(i, j, k) = -(delz_tl(i, j, k)*dp2(i, k)+delz(i, j&
646 delz(i, j, k) = -(delz(i, j, k)*dp2(i, k))
655 pk_tl(i, j, k) = pk2_tl(i, k)
656 pk(i, j, k) = pk2(i, k)
669 pe3_tl(i, k) = omga_tl(i, j, k-1)
670 pe3(i, k) = omga(i, j, k-1)
676 pe0_tl(i, k) = peln_tl(i, k, j)
677 pe0(i, k) = peln(i, k, j)
678 peln_tl(i, k, j) = pn2_tl(i, k)
679 peln(i, k, j) = pn2(i, k)
685 IF (hydrostatic)
THEN 688 pkz_tl(i, j, k) = ((pk2_tl(i, k+1)-pk2_tl(i, k))*akap*(&
689 & peln(i, k+1, j)-peln(i, k, j))-(pk2(i, k+1)-pk2(i, k))*&
690 & akap*(peln_tl(i, k+1, j)-peln_tl(i, k, j)))/(akap*(peln(&
691 & i, k+1, j)-peln(i, k, j)))**2
692 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1&
693 & , j)-peln(i, k, j)))
696 ELSE IF (remap_te)
THEN 699 ELSE IF (remap_t)
THEN 703 arg1_tl = (rrg*delp_tl(i, j, k)*delz(i, j, k)-rrg*delp(i, &
704 & j, k)*delz_tl(i, j, k))*pt(i, j, k)/delz(i, j, k)**2 + &
705 & rrg*delp(i, j, k)*pt_tl(i, j, k)/delz(i, j, k)
706 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
707 arg2_tl = akap*arg1_tl/arg1
708 arg2 = akap*log(arg1)
709 pkz_tl(i, j, k) = arg2_tl*exp(arg2)
710 pkz(i, j, k) = exp(arg2)
719 arg1_tl = (rrg*delp_tl(i, j, k)*delz(i, j, k)-rrg*delp(i, &
720 & j, k)*delz_tl(i, j, k))*pt(i, j, k)/delz(i, j, k)**2 + &
721 & rrg*delp(i, j, k)*pt_tl(i, j, k)/delz(i, j, k)
722 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
723 arg2_tl = k1k*arg1_tl/arg1
725 pkz_tl(i, j, k) = arg2_tl*exp(arg2)
726 pkz(i, j, k) = exp(arg2)
735 dp2_tl(i, k) = 0.5*(peln_tl(i, k, j)+peln_tl(i, k+1, j))
736 dp2(i, k) = 0.5*(peln(i, k, j)+peln(i, k+1, j))
744 IF (dp2(i, n) .LE. pe0(i, k+1) .AND. dp2(i, n) .GE. pe0(&
748 100 omga_tl(i, j, n) = pe3_tl(i, k) + (((pe3_tl(i, k+1)-pe3_tl&
749 & (i, k))*(dp2(i, n)-pe0(i, k))+(pe3(i, k+1)-pe3(i, k))*(&
750 & dp2_tl(i, n)-pe0_tl(i, k)))*(pe0(i, k+1)-pe0(i, k))-(pe3&
751 & (i, k+1)-pe3(i, k))*(dp2(i, n)-pe0(i, k))*(pe0_tl(i, k+1&
752 & )-pe0_tl(i, k)))/(pe0(i, k+1)-pe0(i, k))**2
753 omga(i, j, n) = pe3(i, k) + (pe3(i, k+1)-pe3(i, k))*(dp2(i&
754 & , n)-pe0(i, k))/(pe0(i, k+1)-pe0(i, k))
761 pe0_tl(i, 1) = pe_tl(i, 1, j)
762 pe0(i, 1) = pe(i, 1, j)
769 pe0_tl(i, k) = 0.5*(pe_tl(i, k, j-1)+pe1_tl(i, k))
770 pe0(i, k) = 0.5*(pe(i, k, j-1)+pe1(i, k))
776 pe3_tl(i, k) = bkh*(pe_tl(i, km+1, j-1)+pe1_tl(i, km+1))
777 pe3(i, k) = ak(k) + bkh*(pe(i, km+1, j-1)+pe1(i, km+1))
780 IF (kord_mt .EQ. kord_mt_pert)
THEN 782 CALL map1_ppm_tlm(km, pe0(is:ie, :), pe0_tl(is:ie, :), gz, &
783 & gz_tl, km, pe3(is:ie, :), pe3_tl(is:ie, :), u, &
784 & u_tl, is, ie, j, isd, ied, jsd, jedp1, -1, &
789 CALL map1_ppm_tlm(km, pe0(is:ie, :), pe0_tl(is:ie, :), gz, gz_tl&
790 & , km, pe3(is:ie, :), pe3_tl(is:ie, :), u_tj, u_tl, is, &
791 & ie, j, isd, ied, jsd, jedp1, -1, kord_mt_pert)
792 call map1_ppm( km, pe0(is:ie,:), gz, &
793 km, pe3(is:ie,:), u, &
794 is, ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
796 IF (
PRESENT(mfy))
CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:&
797 & ie, :), mfy, is, ie, j, is, ie, js, jep1&
800 IF (j .LT. je + 1)
THEN 811 pe0_tl(i, k) = 0.5*(pe_tl(i-1, k, j)+pe_tl(i, k, j))
812 pe0(i, k) = 0.5*(pe(i-1, k, j)+pe(i, k, j))
813 pe3_tl(i, k) = bkh*(pe_tl(i-1, km+1, j)+pe_tl(i, km+1, j))
814 pe3(i, k) = ak(k) + bkh*(pe(i-1, km+1, j)+pe(i, km+1, j))
817 IF (kord_mt .EQ. kord_mt_pert)
THEN 819 CALL map1_ppm_tlm(km, pe0, pe0_tl, gz, gz_tl, km, pe3, &
820 & pe3_tl, v, v_tl, is, iep1, j, isd, iedp1, jsd, &
825 CALL map1_ppm_tlm(km, pe0, pe0_tl, gz, gz_tl, km, pe3, pe3_tl&
826 & , v_tj, v_tl, is, iep1, j, isd, iedp1, jsd, jed, -1, &
829 km, pe3, v, is, ie+1, &
830 j, isd, iedp1, jsd, jed, -1, kord_mt)
832 IF (
PRESENT(mfx))
CALL map1_ppm(km, pe0, gz, km, pe3, mfx, is, &
833 & iep1, j, is, iep1, js, je, -1, kord_mt&
838 ua_tl(i, j, k) = pe2_tl(i, k+1)
839 ua(i, j, k) = pe2(i, k+1)
856 pe_tl(i, k, j) = ua_tl(i, j, k-1)
857 pe(i, k, j) = ua(i, j, k-1)
861 IF (flagstruct%fv_debug)
THEN 862 IF (kord_tm .LT. 0)
THEN 863 CALL prt_mxm(
'remap-1 TV', pt, is, ie, js, je, ng, km, 1., &
864 & gridstruct%area_64, domain)
866 CALL prt_mxm(
'remap-1 PT', pt, is, ie, js, je, ng, km, 1., &
867 & gridstruct%area_64, domain)
872 IF (last_step .AND. (.NOT.do_adiabatic_init))
THEN 883 IF (hydrostatic)
THEN 888 gz_tl(i) = gz_tl(i) + rg*(pt_tl(i, j, k)*(peln(i, k+1&
889 & , j)-peln(i, k, j))+pt(i, j, k)*(peln_tl(i, k+1, j)-&
891 gz(i) = gz(i) + rg*pt(i, j, k)*(peln(i, k+1, j)-peln(i&
896 te_2d_tl(i, j) = hs(i, j)*pe_tl(i, km+1, j) - pe_tl(i, 1&
897 & , j)*gz(i) - pe(i, 1, j)*gz_tl(i)
898 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
903 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(cp&
904 & *pt(i, j, k)+0.25*gridstruct%rsin2(i, j)*(u(i, j, k)&
905 & **2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u&
906 & (i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
907 & gridstruct%cosa_s(i, j))) + delp(i, j, k)*(cp*pt_tl(&
908 & i, j, k)+0.25*gridstruct%rsin2(i, j)*(2*u(i, j, k)*&
909 & u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(i, &
910 & j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k)-&
911 & gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl(i, j+1&
912 & , k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+1&
913 & , k))*(v_tl(i, j, k)+v_tl(i+1, j, k)))))
914 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*pt(i, j&
915 & , k)+0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i&
916 & , j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, &
917 & k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
918 & gridstruct%cosa_s(i, j)))
925 phis_tl(i, km+1) = 0.0
926 phis(i, km+1) = hs(i, j)
930 phis_tl(i, k) = phis_tl(i, k+1) -
grav*delz_tl(i, j, k&
932 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
937 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(&
938 &
cv_air*pt(i, j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*&
939 & (phis(i, k)+phis(i, k+1)+w(i, j, k)**2+0.5*&
940 & gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i, j+1, k)**&
941 & 2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1&
942 & , k))*(v(i, j, k)+v(i+1, j, k))*gridstruct%cosa_s(i&
943 & , j)))) + delp(i, j, k)*((
cv_air*pt_tl(i, j, k)*(1.+&
944 & r_vir*q(i, j, k, sphum))-
cv_air*pt(i, j, k)*r_vir*&
945 & q_tl(i, j, k, sphum))/(1.+r_vir*q(i, j, k, sphum))**&
946 & 2+0.5*(phis_tl(i, k)+phis_tl(i, k+1)+2*w(i, j, k)*&
947 & w_tl(i, j, k)+0.5*gridstruct%rsin2(i, j)*(2*u(i, j, &
948 & k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(&
949 & i, j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k&
950 & )-gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl(i, j+&
951 & 1, k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+&
952 & 1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k))))))
953 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
954 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
955 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
956 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
957 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
958 & i+1, j, k))*gridstruct%cosa_s(i, j))))
962 ELSE IF (remap_pt)
THEN 964 IF (hydrostatic)
THEN 969 gz_tl(i) = gz_tl(i) +
cp_air*(pt_tl(i, j, k)*(pk(i, j&
970 & , k+1)-pk(i, j, k))+pt(i, j, k)*(pk_tl(i, j, k+1)-&
972 gz(i) = gz(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i&
977 te_2d_tl(i, j) = hs(i, j)*pe_tl(i, km+1, j) - pe_tl(i, 1&
978 & , j)*gz(i) - pe(i, 1, j)*gz_tl(i)
979 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
984 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(&
985 &
cp_air*pt(i, j, k)*pkz(i, j, k)+0.25*gridstruct%&
986 & rsin2(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k&
987 & )**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i&
988 & , j, k)+v(i+1, j, k))*gridstruct%cosa_s(i, j))) + &
989 & delp(i, j, k)*(
cp_air*(pt_tl(i, j, k)*pkz(i, j, k)+&
990 & pt(i, j, k)*pkz_tl(i, j, k))+0.25*gridstruct%rsin2(i&
991 & , j)*(2*u(i, j, k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl&
992 & (i, j+1, k)+2*v(i, j, k)*v_tl(i, j, k)+2*v(i+1, j, k&
993 & )*v_tl(i+1, j, k)-gridstruct%cosa_s(i, j)*((u_tl(i, &
994 & j, k)+u_tl(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))+(u(&
995 & i, j, k)+u(i, j+1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k&
997 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cp_air*pt(i&
998 & , j, k)*pkz(i, j, k)+0.25*gridstruct%rsin2(i, j)*(u(&
999 & i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, &
1000 & k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j&
1001 & , k))*gridstruct%cosa_s(i, j)))
1009 phis_tl(i, km+1) = 0.0
1010 phis(i, km+1) = hs(i, j)
1012 phis_tl(i, k) = phis_tl(i, k+1) -
grav*delz_tl(i, j, k&
1014 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
1018 te_2d_tl(i, j) = 0.0
1023 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(&
1024 &
cv_air*pt(i, j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*&
1025 & (phis(i, k)+phis(i, k+1)+w(i, j, k)**2+0.5*&
1026 & gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i, j+1, k)**&
1027 & 2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1&
1028 & , k))*(v(i, j, k)+v(i+1, j, k))*gridstruct%cosa_s(i&
1029 & , j)))) + delp(i, j, k)*((
cv_air*pt_tl(i, j, k)*(1.+&
1030 & r_vir*q(i, j, k, sphum))-
cv_air*pt(i, j, k)*r_vir*&
1031 & q_tl(i, j, k, sphum))/(1.+r_vir*q(i, j, k, sphum))**&
1032 & 2+0.5*(phis_tl(i, k)+phis_tl(i, k+1)+2*w(i, j, k)*&
1033 & w_tl(i, j, k)+0.5*gridstruct%rsin2(i, j)*(2*u(i, j, &
1034 & k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(&
1035 & i, j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k&
1036 & )-gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl(i, j+&
1037 & 1, k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+&
1038 & 1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k))))))
1039 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
1040 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
1041 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
1042 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
1043 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
1044 & i+1, j, k))*gridstruct%cosa_s(i, j))))
1048 ELSE IF (remap_te)
THEN 1050 te_2d_tl(i, j) = te_tl(i, j, 1)*delp(i, j, 1) + te(i, j, 1&
1051 & )*delp_tl(i, j, 1)
1052 te_2d(i, j) = te(i, j, 1)*delp(i, j, 1)
1056 te_2d_tl(i, j) = te_2d_tl(i, j) + te_tl(i, j, k)*delp(i&
1057 & , j, k) + te(i, j, k)*delp_tl(i, j, k)
1058 te_2d(i, j) = te_2d(i, j) + te(i, j, k)*delp(i, j, k)
1063 te_2d_tl(i, j) = te0_2d_tl(i, j) - te_2d_tl(i, j)
1064 te_2d(i, j) = te0_2d(i, j) - te_2d(i, j)
1065 zsum1_tl(i, j) = pkz_tl(i, j, 1)*delp(i, j, 1) + pkz(i, j, 1&
1066 & )*delp_tl(i, j, 1)
1067 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
1071 zsum1_tl(i, j) = zsum1_tl(i, j) + pkz_tl(i, j, k)*delp(i, &
1072 & j, k) + pkz(i, j, k)*delp_tl(i, j, k)
1073 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
1076 IF (hydrostatic)
THEN 1078 zsum0_tl(i, j) = ptop*(pk_tl(i, j, 1)-pk_tl(i, j, km+1)) +&
1080 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
1087 result1_tl =
g_sum_tlm(domain, te_2d, te_2d_tl, is, ie, js, je, &
1088 & ng, gridstruct%area_64, 0, reproduce=.true., g_sum=result1)
1089 tpe_tl = consv*result1_tl
1094 IF (hydrostatic)
THEN 1095 result1_tl =
g_sum_tlm(domain, zsum0, zsum0_tl, is, ie, js, je&
1096 & , ng, gridstruct%area_64, 0, reproduce=.true., g_sum=result1&
1098 dtmp_tl = (tpe_tl*cp*result1-tpe*cp*result1_tl)/(cp*result1)**&
1100 dtmp = tpe/(cp*result1)
1102 result1_tl =
g_sum_tlm(domain, zsum1, zsum1_tl, is, ie, js, je&
1103 & , ng, gridstruct%area_64, 0, reproduce=.true., g_sum=result1&
1105 dtmp_tl = (tpe_tl*
cv_air*result1-tpe*
cv_air*result1_tl)/(&
1107 dtmp = tpe/(
cv_air*result1)
1116 zsum1_tl(i, j) = pkz_tl(i, j, 1)*delp(i, j, 1) + pkz(i, j, 1&
1117 & )*delp_tl(i, j, 1)
1118 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
1122 zsum1_tl(i, j) = zsum1_tl(i, j) + pkz_tl(i, j, k)*delp(i, &
1123 & j, k) + pkz(i, j, k)*delp_tl(i, j, k)
1124 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
1127 IF (hydrostatic)
THEN 1129 zsum0_tl(i, j) = ptop*(pk_tl(i, j, 1)-pk_tl(i, j, km+1)) +&
1131 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
1138 IF (hydrostatic)
THEN 1139 result1_tl =
g_sum_tlm(domain, zsum0, zsum0_tl, is, ie, js, je&
1140 & , ng, gridstruct%area_64, 0, reproduce=.true., g_sum=result1&
1147 result1_tl =
g_sum_tlm(domain, zsum1, zsum1_tl, is, ie, js, je&
1148 & , ng, gridstruct%area_64, 0, reproduce=.true., g_sum=result1&
1166 IF (remap_t .AND. (.NOT.do_adiabatic_init) .AND. do_sat_adj)
THEN 1173 dpln(i, j) = peln(i, k+1, j) - peln(i, k, j)
1176 IF (mdt .GE. 0.)
THEN 1181 CALL fv_sat_adj(abs0, r_vir, is, ie, js, je, ng, hydrostatic, &
1182 & fast_mp_consv, te(isd:ied, jsd:jed, k), q(isd:ied, jsd&
1183 & :jed, k, sphum), q(isd:ied, jsd:jed, k, liq_wat), q(&
1184 & isd:ied, jsd:jed, k, ice_wat), q(isd:ied, jsd:jed, k, &
1185 & rainwat), q(isd:ied, jsd:jed, k, snowwat), q(isd:ied, &
1186 & jsd:jed, k, graupel), dpln, delz(isd:ied, jsd:jed, k)&
1187 & , pt(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k), &
1188 & q_con(isd:ied, jsd:jed, k), cappa(isd:ied, jsd:jed, k)&
1189 & , gridstruct%area_64, dtdt(is:ie, js:je, k), out_dt, &
1190 & last_step, cld_amt .GT. 0, q(isd:ied, jsd:jed, k, &
1192 IF (.NOT.hydrostatic)
THEN 1195 arg1_tl = (rrg*delp_tl(i, j, k)*delz(i, j, k)-rrg*delp(i, &
1196 & j, k)*delz_tl(i, j, k))*pt(i, j, k)/delz(i, j, k)**2 + &
1197 & rrg*delp(i, j, k)*pt_tl(i, j, k)/delz(i, j, k)
1198 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
1199 arg2_tl = akap*arg1_tl/arg1
1200 arg2 = akap*log(arg1)
1201 pkz_tl(i, j, k) = arg2_tl*exp(arg2)
1202 pkz(i, j, k) = exp(arg2)
1208 IF (fast_mp_consv)
THEN 1213 te0_2d_tl(i, j) = te0_2d_tl(i, j) + te_tl(i, j, k)
1214 te0_2d(i, j) = te0_2d(i, j) + te(i, j, k)
1228 IF (.NOT.adiabatic)
THEN 1230 pt_tl(i, j, k) = ((pt_tl(i, j, k)+dtmp_tl*pkz(i, j, k)+&
1231 & dtmp*pkz_tl(i, j, k))*(1.+r_vir*q(i, j, k, sphum))-(pt&
1232 & (i, j, k)+dtmp*pkz(i, j, k))*r_vir*q_tl(i, j, k, sphum&
1233 & ))/(1.+r_vir*q(i, j, k, sphum))**2
1234 pt(i, j, k) = (pt(i, j, k)+dtmp*pkz(i, j, k))/(1.+r_vir*&
1235 & q(i, j, k, sphum))
1240 ELSE IF (remap_pt)
THEN 1247 pt_tl(i, j, k) = (((pt_tl(i, j, k)+dtmp_tl)*pkz(i, j, k)+(&
1248 & pt(i, j, k)+dtmp)*pkz_tl(i, j, k))*(1.+r_vir*q(i, j, k, &
1249 & sphum))-(pt(i, j, k)+dtmp)*pkz(i, j, k)*r_vir*q_tl(i, j&
1250 & , k, sphum))/(1.+r_vir*q(i, j, k, sphum))**2
1251 pt(i, j, k) = (pt(i, j, k)+dtmp)*pkz(i, j, k)/(1.+r_vir*q(&
1256 ELSE IF (remap_te)
THEN 1265 tpe_tl = te_tl(i, j, k) - gz_tl(i) - 0.25*gridstruct%rsin2&
1266 & (i, j)*(2*u(i, j, k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i&
1267 & , j+1, k)+2*v(i, j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl&
1268 & (i+1, j, k)-gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl&
1269 & (i, j+1, k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, &
1270 & j+1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k))))
1271 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
1272 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
1273 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1274 & gridstruct%cosa_s(i, j))
1275 dlnp_tl = rg*(peln_tl(i, k+1, j)-peln_tl(i, k, j))
1276 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
1277 tmp_tl = (tpe_tl*(cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+&
1278 & r_vir*q(i, j, k, sphum))-tpe*((cp-pe(i, k, j)*dlnp/delp(&
1279 & i, j, k))*r_vir*q_tl(i, j, k, sphum)-((pe_tl(i, k, j)*&
1280 & dlnp+pe(i, k, j)*dlnp_tl)*delp(i, j, k)-pe(i, k, j)*dlnp&
1281 & *delp_tl(i, j, k))*(1.+r_vir*q(i, j, k, sphum))/delp(i, &
1282 & j, k)**2))/((cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+&
1283 & r_vir*q(i, j, k, sphum)))**2
1284 tmp = tpe/((cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+r_vir*q&
1285 & (i, j, k, sphum)))
1286 pt_tl(i, j, k) = tmp_tl + ((dtmp_tl*pkz(i, j, k)+dtmp*&
1287 & pkz_tl(i, j, k))*(1.+r_vir*q(i, j, k, sphum))-dtmp*pkz(i&
1288 & , j, k)*r_vir*q_tl(i, j, k, sphum))/(1.+r_vir*q(i, j, k&
1290 pt(i, j, k) = tmp + dtmp*pkz(i, j, k)/(1.+r_vir*q(i, j, k&
1292 gz_tl(i) = gz_tl(i) + (dlnp_tl*tmp+dlnp*tmp_tl)*(1.+r_vir*&
1293 & q(i, j, k, sphum)) + dlnp*tmp*r_vir*q_tl(i, j, k, sphum)
1294 gz(i) = gz(i) + dlnp*tmp*(1.+r_vir*q(i, j, k, sphum))
1300 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 TA', pt, is, ie, &
1301 & js, je, ng, km, 1., gridstruct%&
1310 pt_tl(i, j, k) = (pt_tl(i, j, k)*pkz(i, j, k)-pt(i, j, k)*&
1311 & pkz_tl(i, j, k))/pkz(i, j, k)**2
1312 pt(i, j, k) = pt(i, j, k)/pkz(i, j, k)
1316 ELSE IF (remap_te)
THEN 1325 tpe_tl = te_tl(i, j, k) - gz_tl(i) - 0.25*gridstruct%rsin2&
1326 & (i, j)*(2*u(i, j, k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i&
1327 & , j+1, k)+2*v(i, j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl&
1328 & (i+1, j, k)-gridstruct%cosa_s(i, j)*((u_tl(i, j, k)+u_tl&
1329 & (i, j+1, k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, k)+u(i, &
1330 & j+1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k))))
1331 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
1332 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
1333 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1334 & gridstruct%cosa_s(i, j))
1335 dlnp_tl = rg*(peln_tl(i, k+1, j)-peln_tl(i, k, j))
1336 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
1337 tmp_tl = (tpe_tl*(cp-pe(i, k, j)*dlnp/delp(i, j, k))+tpe*(&
1338 & (pe_tl(i, k, j)*dlnp+pe(i, k, j)*dlnp_tl)*delp(i, j, k)-&
1339 & pe(i, k, j)*dlnp*delp_tl(i, j, k))/delp(i, j, k)**2)/(cp&
1340 & -pe(i, k, j)*dlnp/delp(i, j, k))**2
1341 tmp = tpe/(cp-pe(i, k, j)*dlnp/delp(i, j, k))
1342 pt_tl(i, j, k) = (tmp_tl*pkz(i, j, k)-tmp*pkz_tl(i, j, k))&
1343 & /pkz(i, j, k)**2 + dtmp_tl
1344 pt(i, j, k) = tmp/pkz(i, j, k) + dtmp
1345 gz_tl(i) = gz_tl(i) + dlnp_tl*tmp + dlnp*tmp_tl
1346 gz(i) = gz(i) + dlnp*tmp
1352 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 PT', pt, is, ie, &
1353 & js, je, ng, km, 1., gridstruct%&
1357 120 print*,
'TE remapping non-hydrostatic is invalid and cannot be run' 1362 & , pk, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, &
1363 & sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, akap, cappa, &
1364 & kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, ng, ua, va, omga, &
1365 & te, ws, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, &
1366 & flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, &
1367 & do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, &
1368 & kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
1371 LOGICAL,
INTENT(IN) :: last_step
1373 REAL,
INTENT(IN) :: mdt
1375 REAL,
INTENT(IN) :: pdt
1376 INTEGER,
INTENT(IN) :: km
1378 INTEGER,
INTENT(IN) :: nq
1379 INTEGER,
INTENT(IN) :: nwat
1381 INTEGER,
INTENT(IN) :: sphum
1382 INTEGER,
INTENT(IN) :: ng
1384 INTEGER,
INTENT(IN) :: is, ie, isd, ied
1386 INTEGER,
INTENT(IN) :: js, je, jsd, jed
1388 INTEGER,
INTENT(IN) :: kord_mt
1390 INTEGER,
INTENT(IN) :: kord_wz
1392 INTEGER,
INTENT(IN) :: kord_tr(nq)
1394 INTEGER,
INTENT(IN) :: kord_tm
1396 INTEGER,
INTENT(IN) :: kord_mt_pert
1398 INTEGER,
INTENT(IN) :: kord_wz_pert
1400 INTEGER,
INTENT(IN) :: kord_tr_pert(nq)
1402 INTEGER,
INTENT(IN) :: kord_tm_pert
1404 REAL,
INTENT(IN) :: consv
1405 REAL,
INTENT(IN) :: r_vir
1406 REAL,
INTENT(IN) :: cp
1407 REAL,
INTENT(IN) :: akap
1409 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
1410 REAL,
INTENT(INOUT) :: te0_2d(is:ie, js:je)
1411 REAL,
INTENT(IN) :: ws(is:ie, js:je)
1412 LOGICAL,
INTENT(IN) :: do_sat_adj
1414 LOGICAL,
INTENT(IN) :: fill
1415 LOGICAL,
INTENT(IN) :: reproduce_sum
1416 LOGICAL,
INTENT(IN) :: do_omega, adiabatic, do_adiabatic_init
1417 REAL,
INTENT(IN) :: ptop
1418 REAL,
INTENT(IN) :: ak(km+1)
1419 REAL,
INTENT(IN) :: bk(km+1)
1420 REAL,
INTENT(IN) :: pfull(km)
1423 TYPE(
domain2d),
INTENT(INOUT) :: domain
1426 REAL,
INTENT(INOUT) :: pk(is:ie, js:je, km+1)
1427 REAL,
INTENT(INOUT) :: q(isd:ied, jsd:jed, km, nq)
1429 REAL,
INTENT(INOUT) :: delp(isd:ied, jsd:jed, km)
1431 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
1433 REAL,
INTENT(INOUT) :: ps(isd:ied, jsd:jed)
1436 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
1438 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
1440 REAL,
INTENT(INOUT) :: w(isd:ied, jsd:jed, km)
1442 REAL,
INTENT(INOUT) :: pt(isd:ied, jsd:jed, km)
1444 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz
1445 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: q_con, cappa
1446 LOGICAL,
INTENT(IN) :: hydrostatic
1447 LOGICAL,
INTENT(IN) :: hybrid_z
1448 LOGICAL,
INTENT(IN) :: out_dt
1450 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
1452 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
1454 REAL,
INTENT(INOUT) :: omga(isd:ied, jsd:jed, km)
1456 REAL,
INTENT(INOUT) :: peln(is:ie, km+1, js:je)
1457 REAL,
INTENT(INOUT) :: dtdt(is:ie, js:je, km)
1459 REAL,
INTENT(OUT) :: pkz(is:ie, js:je, km)
1460 REAL,
INTENT(OUT) :: te(isd:ied, jsd:jed, km)
1463 REAL,
OPTIONAL,
INTENT(INOUT) :: mfx(is:ie+1, js:je, km)
1465 REAL,
OPTIONAL,
INTENT(INOUT) :: mfy(is:ie, js:je+1, km)
1467 INTEGER,
INTENT(IN) :: remap_option
1476 REAL,
DIMENSION(is:ie, js:je) :: te_2d, zsum0, zsum1, dpln
1477 REAL,
DIMENSION(is:ie, km) :: q2, dp2
1478 REAL,
DIMENSION(is:ie, km+1) :: pe1, pe2, pk1, pk2, pn2, phis
1479 REAL,
DIMENSION(is:ie+1, km+1) :: pe0, pe3
1480 REAL,
DIMENSION(is:ie) :: gz, cvm, qv
1481 REAL :: rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
1482 LOGICAL :: fast_mp_consv
1484 INTEGER :: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel&
1485 & , iq, n, kmp, kp, k_next
1486 LOGICAL :: remap_t, remap_pt, remap_te
1487 INTEGER :: abs_kord_tm, abs_kord_tm_pert
1488 INTEGER :: iep1, jep1, iedp1, jedp1
1497 IF (kord_tm .GE. 0.)
THEN 1498 abs_kord_tm = kord_tm
1500 abs_kord_tm = -kord_tm
1502 IF (kord_tm_pert .GE. 0.)
THEN 1503 abs_kord_tm_pert = kord_tm_pert
1505 abs_kord_tm_pert = -kord_tm_pert
1514 SELECT CASE (remap_option)
1522 print*,
' INVALID REMAPPING OPTION ' 1525 IF (is_master() .AND. flagstruct%fv_debug)
THEN 1527 SELECT CASE (remap_option)
1529 print*,
' REMAPPING T in logP ' 1531 print*,
' REMAPPING PT in P' 1533 print*,
' REMAPPING TE in logP with GMAO cubic' 1535 print*,
' REMAPPING CONSV: ', consv
1536 print*,
' REMAPPING CONSV_MIN: ',
consv_min 1539 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-0 PT', pt, is, ie, js&
1540 & , je, ng, km, 1., gridstruct%area_64&
1547 IF (
fpp%fpp_mapl_mode)
THEN 1562 IF (do_sat_adj)
THEN 1563 fast_mp_consv = .NOT.do_adiabatic_init .AND. consv .GT.
consv_min 1566 IF (pfull(k) .GT. 10.e2)
GOTO 100
1581 pe1(i, k) = pe(i, k, j)
1586 pe2(i, km+1) = pe(i, km+1, j)
1589 IF (j .NE. je + 1)
THEN 1594 IF (hydrostatic)
THEN 1598 pt(i, j, k) = pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k))/(&
1599 & akap*(peln(i, k+1, j)-peln(i, k, j)))
1606 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
1607 arg2 = k1k*log(arg1)
1608 pt(i, j, k) = pt(i, j, k)*exp(arg2)
1612 ELSE IF (.NOT.remap_pt)
THEN 1621 CALL pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, &
1626 te(i, j, k) = 0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2&
1627 & +u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j&
1628 & , k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1629 & gridstruct%cosa_s(i, j)) +
cp_air*pt(i, j, k)*pkz(i, j&
1635 IF (.NOT.hydrostatic)
THEN 1639 delz(i, j, k) = -(delz(i, j, k)/delp(i, j, k))
1645 ps(i, j) = pe1(i, km+1)
1652 pe2(i, k) = ak(k) + bk(k)*pe(i, km+1, j)
1657 dp2(i, k) = pe2(i, k+1) - pe2(i, k)
1665 delp(i, j, k) = dp2(i, k)
1673 pk1(i, k) = pk(i, j, k)
1677 pn2(i, 1) = peln(i, 1, j)
1678 pn2(i, km+1) = peln(i, km+1, j)
1679 pk2(i, 1) = pk1(i, 1)
1680 pk2(i, km+1) = pk1(i, km+1)
1684 pn2(i, k) = log(pe2(i, k))
1685 pk2(i, k) = exp(akap*pn2(i, k))
1692 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 1693 CALL map_scalar(km, peln(is:ie, 1:km+1, j), gz, km, pn2, &
1694 & pt, is, ie, j, isd, ied, jsd, jed, 1, &
1695 & abs_kord_tm,
t_min)
1697 call map_scalar(km, peln(is:ie,1:km+1,j), gz, &
1699 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm,
t_min)
1701 ELSE IF (remap_pt)
THEN 1705 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 1706 CALL map1_ppm(km, pe1, gz, km, pe2, pt, is, ie, j, isd, &
1707 & ied, jsd, jed, 1, abs_kord_tm)
1711 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm)
1713 ELSE IF (remap_te)
THEN 1718 phis(i, km+1) = hs(i, j)
1722 phis(i, k) = phis(i, k+1) +
cp_air*pt(i, j, k)*(pk1(i, k+1&
1728 phis(i, k) = phis(i, k)*pe1(i, k)
1733 te(i, j, k) = te(i, j, k) + (phis(i, k+1)-phis(i, k))/(pe1&
1734 & (i, k+1)-pe1(i, k))
1738 CALL map1_cubic(km, pe1, km, pe2, te, is, ie, j, isd, ied, jsd&
1739 & , jed, akap, 1, .true.)
1745 IF (kord_tr(1) .EQ. kord_tr_pert(1))
THEN 1746 CALL mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, is&
1747 & , ie, isd, ied, jsd, jed, 0., fill)
1749 call mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
1750 is, ie, isd, ied, jsd, jed, 0., fill)
1752 ELSE IF (nq .GT. 0)
THEN 1755 IF (kord_tr(iq) .EQ. kord_tr_pert(iq))
THEN 1756 CALL map1_q2(km, pe1, q(isd:ied, jsd:jed, 1:km, iq), km&
1757 & , pe2, q2, dp2, is, ie, 0, kord_tr(iq), j, isd, &
1758 & ied, jsd, jed, 0.)
1760 call map1_q2(km, pe1, q(isd:ied,jsd:jed,1:km,iq), &
1762 is, ie, 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
1764 IF (fill)
CALL fillz(ie - is + 1, km, 1, q2, dp2)
1767 q(i, j, k, iq) = q2(i, k)
1772 IF (.NOT.hydrostatic)
THEN 1774 IF (kord_wz .EQ. kord_wz_pert)
THEN 1775 CALL map1_ppm(km, pe1, ws(is:ie, j), km, pe2, w, is, ie, &
1776 & j, isd, ied, jsd, jed, -2, kord_wz)
1778 call map1_ppm (km, pe1, ws(is:ie,j), &
1780 is, ie, j, isd, ied, jsd, jed, -2, kord_wz)
1783 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 1784 CALL map1_ppm(km, pe1, gz, km, pe2, delz, is, ie, j, isd&
1785 & , ied, jsd, jed, 1, abs_kord_tm)
1789 is, ie, j, isd, ied, jsd, jed, 1, abs_kord_tm)
1793 delz(i, j, k) = -(delz(i, j, k)*dp2(i, k))
1802 pk(i, j, k) = pk2(i, k)
1814 pe3(i, k) = omga(i, j, k-1)
1820 pe0(i, k) = peln(i, k, j)
1821 peln(i, k, j) = pn2(i, k)
1827 IF (hydrostatic)
THEN 1830 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1&
1831 & , j)-peln(i, k, j)))
1834 ELSE IF (remap_te)
THEN 1837 &
'TE remapping non-hydrostatic is invalid and cannot be run' 1839 ELSE IF (remap_t)
THEN 1843 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
1844 arg2 = akap*log(arg1)
1845 pkz(i, j, k) = exp(arg2)
1854 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
1855 arg2 = k1k*log(arg1)
1856 pkz(i, j, k) = exp(arg2)
1865 dp2(i, k) = 0.5*(peln(i, k, j)+peln(i, k+1, j))
1873 IF (dp2(i, n) .LE. pe0(i, k+1) .AND. dp2(i, n) .GE. pe0(&
1875 omga(i, j, n) = pe3(i, k) + (pe3(i, k+1)-pe3(i, k))*(&
1876 & dp2(i, n)-pe0(i, k))/(pe0(i, k+1)-pe0(i, k))
1886 pe0(i, 1) = pe(i, 1, j)
1893 pe0(i, k) = 0.5*(pe(i, k, j-1)+pe1(i, k))
1899 pe3(i, k) = ak(k) + bkh*(pe(i, km+1, j-1)+pe1(i, km+1))
1902 IF (kord_mt .EQ. kord_mt_pert)
THEN 1903 CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:ie, :), u, is&
1904 & , ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
1906 call map1_ppm( km, pe0(is:ie,:), gz, &
1907 km, pe3(is:ie,:), u, &
1908 is, ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
1910 IF (
PRESENT(mfy))
CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:&
1911 & ie, :), mfy, is, ie, j, is, ie, js, jep1&
1914 IF (j .LT. je + 1)
THEN 1924 pe0(i, k) = 0.5*(pe(i-1, k, j)+pe(i, k, j))
1925 pe3(i, k) = ak(k) + bkh*(pe(i-1, km+1, j)+pe(i, km+1, j))
1928 IF (kord_mt .EQ. kord_mt_pert)
THEN 1929 CALL map1_ppm(km, pe0, gz, km, pe3, v, is, iep1, j, isd, &
1930 & iedp1, jsd, jed, -1, kord_mt)
1933 km, pe3, v, is, ie+1, &
1934 j, isd, iedp1, jsd, jed, -1, kord_mt)
1936 IF (
PRESENT(mfx))
CALL map1_ppm(km, pe0, gz, km, pe3, mfx, is, &
1937 & iep1, j, is, iep1, js, je, -1, kord_mt&
1942 ua(i, j, k) = pe2(i, k+1)
1959 pe(i, k, j) = ua(i, j, k-1)
1963 IF (flagstruct%fv_debug)
THEN 1964 IF (kord_tm .LT. 0)
THEN 1965 CALL prt_mxm(
'remap-1 TV', pt, is, ie, js, je, ng, km, 1., &
1966 & gridstruct%area_64, domain)
1968 CALL prt_mxm(
'remap-1 PT', pt, is, ie, js, je, ng, km, 1., &
1969 & gridstruct%area_64, domain)
1974 IF (last_step .AND. (.NOT.do_adiabatic_init))
THEN 1981 IF (hydrostatic)
THEN 1985 gz(i) = gz(i) + rg*pt(i, j, k)*(peln(i, k+1, j)-peln(i&
1990 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
1995 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*pt(i, j&
1996 & , k)+0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i&
1997 & , j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, &
1998 & k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1999 & gridstruct%cosa_s(i, j)))
2005 phis(i, km+1) = hs(i, j)
2009 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
2014 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
2015 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
2016 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
2017 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
2018 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
2019 & i+1, j, k))*gridstruct%cosa_s(i, j))))
2023 ELSE IF (remap_pt)
THEN 2025 IF (hydrostatic)
THEN 2029 gz(i) = gz(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i&
2034 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
2039 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cp_air*pt(i&
2040 & , j, k)*pkz(i, j, k)+0.25*gridstruct%rsin2(i, j)*(u(&
2041 & i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, &
2042 & k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j&
2043 & , k))*gridstruct%cosa_s(i, j)))
2051 phis(i, km+1) = hs(i, j)
2053 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
2061 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
2062 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
2063 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
2064 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
2065 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
2066 & i+1, j, k))*gridstruct%cosa_s(i, j))))
2070 ELSE IF (remap_te)
THEN 2072 te_2d(i, j) = te(i, j, 1)*delp(i, j, 1)
2076 te_2d(i, j) = te_2d(i, j) + te(i, j, k)*delp(i, j, k)
2081 te_2d(i, j) = te0_2d(i, j) - te_2d(i, j)
2082 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
2086 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
2089 IF (hydrostatic)
THEN 2091 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
2098 result1 = g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%&
2099 & area_64, 0, .true.)
2104 IF (hydrostatic)
THEN 2105 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
2106 & area_64, 0, .true.)
2107 dtmp = tpe/(cp*result1)
2109 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
2110 & area_64, 0, .true.)
2111 dtmp = tpe/(
cv_air*result1)
2118 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
2122 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
2125 IF (hydrostatic)
THEN 2127 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
2134 IF (hydrostatic)
THEN 2135 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
2136 & area_64, 0, .true.)
2139 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
2140 & area_64, 0, .true.)
2148 IF (remap_t .AND. (.NOT.do_adiabatic_init) .AND. do_sat_adj)
THEN 2155 dpln(i, j) = peln(i, k+1, j) - peln(i, k, j)
2158 IF (mdt .GE. 0.)
THEN 2163 CALL fv_sat_adj(abs0, r_vir, is, ie, js, je, ng, hydrostatic, &
2164 & fast_mp_consv, te(isd:ied, jsd:jed, k), q(isd:ied, jsd&
2165 & :jed, k, sphum), q(isd:ied, jsd:jed, k, liq_wat), q(&
2166 & isd:ied, jsd:jed, k, ice_wat), q(isd:ied, jsd:jed, k, &
2167 & rainwat), q(isd:ied, jsd:jed, k, snowwat), q(isd:ied, &
2168 & jsd:jed, k, graupel), dpln, delz(isd:ied, jsd:jed, k)&
2169 & , pt(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k), &
2170 & q_con(isd:ied, jsd:jed, k), cappa(isd:ied, jsd:jed, k)&
2171 & , gridstruct%area_64, dtdt(is:ie, js:je, k), out_dt, &
2172 & last_step, cld_amt .GT. 0, q(isd:ied, jsd:jed, k, &
2174 IF (.NOT.hydrostatic)
THEN 2177 arg1 = rrg*delp(i, j, k)/delz(i, j, k)*pt(i, j, k)
2178 arg2 = akap*log(arg1)
2179 pkz(i, j, k) = exp(arg2)
2185 IF (fast_mp_consv)
THEN 2190 te0_2d(i, j) = te0_2d(i, j) + te(i, j, k)
2204 IF (.NOT.adiabatic)
THEN 2206 pt(i, j, k) = (pt(i, j, k)+dtmp*pkz(i, j, k))/(1.+r_vir*&
2207 & q(i, j, k, sphum))
2212 ELSE IF (remap_pt)
THEN 2219 pt(i, j, k) = (pt(i, j, k)+dtmp)*pkz(i, j, k)/(1.+r_vir*q(&
2224 ELSE IF (remap_te)
THEN 2232 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
2233 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
2234 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
2235 & gridstruct%cosa_s(i, j))
2236 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
2237 tmp = tpe/((cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+r_vir*q&
2238 & (i, j, k, sphum)))
2239 pt(i, j, k) = tmp + dtmp*pkz(i, j, k)/(1.+r_vir*q(i, j, k&
2241 gz(i) = gz(i) + dlnp*tmp*(1.+r_vir*q(i, j, k, sphum))
2247 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 TA', pt, is, ie, &
2248 & js, je, ng, km, 1., gridstruct%&
2257 pt(i, j, k) = pt(i, j, k)/pkz(i, j, k)
2261 ELSE IF (remap_te)
THEN 2269 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
2270 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
2271 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
2272 & gridstruct%cosa_s(i, j))
2273 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
2274 tmp = tpe/(cp-pe(i, k, j)*dlnp/delp(i, j, k))
2275 pt(i, j, k) = tmp/pkz(i, j, k) + dtmp
2276 gz(i) = gz(i) + dlnp*tmp
2282 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 PT', pt, is, ie, &
2283 & js, je, ng, km, 1., gridstruct%&
2292 & , km, u, u_tl, v, v_tl, w, w_tl, delz, delz_tl, pt, pt_tl, delp, &
2293 & delp_tl, q, q_tl, qc, qc_tl, pe, pe_tl, peln, peln_tl, hs, rsin2_l, &
2294 & cosa_s_l, r_vir, cp, rg, hlv, te_2d, te_2d_tl, ua, va, teq, teq_tl, &
2295 & moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel&
2296 & , hydrostatic, id_te)
2302 INTEGER,
INTENT(IN) :: km, is, ie, js, je, isd, ied, jsd, jed, id_te
2303 INTEGER,
INTENT(IN) :: sphum, liq_wat, ice_wat, rainwat, snowwat, &
2305 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: ua, va
2306 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt, delp
2307 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt_tl, delp_tl
2308 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q
2309 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q_tl
2310 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc
2311 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc_tl
2312 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
2313 REAL,
INTENT(INOUT) :: u_tl(isd:ied, jsd:jed+1, km)
2314 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
2315 REAL,
INTENT(INOUT) :: v_tl(isd:ied+1, jsd:jed, km)
2317 REAL,
INTENT(IN) :: w(isd:ied, jsd:jed, km)
2318 REAL,
INTENT(IN) :: w_tl(isd:ied, jsd:jed, km)
2319 REAL,
INTENT(IN) :: delz(isd:ied, jsd:jed, km)
2320 REAL,
INTENT(IN) :: delz_tl(isd:ied, jsd:jed, km)
2322 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
2324 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
2325 REAL,
INTENT(IN) :: pe_tl(is-1:ie+1, km+1, js-1:je+1)
2327 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
2328 REAL,
INTENT(IN) :: peln_tl(is:ie, km+1, js:je)
2329 REAL,
INTENT(IN) :: cp, rg, r_vir,
hlv 2330 REAL,
INTENT(IN) :: rsin2_l(isd:ied, jsd:jed)
2331 REAL,
INTENT(IN) :: cosa_s_l(isd:ied, jsd:jed)
2332 LOGICAL,
INTENT(IN) :: moist_phys, hydrostatic
2335 REAL,
INTENT(OUT) :: te_2d(is:ie, js:je)
2336 REAL,
INTENT(OUT) :: te_2d_tl(is:ie, js:je)
2338 REAL,
INTENT(OUT) :: teq(is:ie, js:je)
2339 REAL,
INTENT(OUT) :: teq_tl(is:ie, js:je)
2341 REAL,
DIMENSION(is:ie, km) :: tv
2342 REAL,
DIMENSION(is:ie, km) :: tv_tl
2343 REAL :: phiz(is:ie, km+1)
2344 REAL :: phiz_tl(is:ie, km+1)
2345 REAL :: cvm(is:ie), qd(is:ie)
2359 IF (hydrostatic)
THEN 2361 phiz_tl(i, km+1) = 0.0
2362 phiz(i, km+1) = hs(i, j)
2366 tv_tl(i, k) = pt_tl(i, j, k)*(1.+qc(i, j, k)) + pt(i, j, k)*&
2368 tv(i, k) = pt(i, j, k)*(1.+qc(i, j, k))
2369 phiz_tl(i, k) = phiz_tl(i, k+1) + rg*(tv_tl(i, k)*(peln(i, k&
2370 & +1, j)-peln(i, k, j))+tv(i, k)*(peln_tl(i, k+1, j)-peln_tl&
2372 phiz(i, k) = phiz(i, k+1) + rg*tv(i, k)*(peln(i, k+1, j)-&
2377 te_2d_tl(i, j) = pe_tl(i, km+1, j)*phiz(i, km+1) + pe(i, km+1&
2378 & , j)*phiz_tl(i, km+1) - pe_tl(i, 1, j)*phiz(i, 1) - pe(i, 1&
2379 & , j)*phiz_tl(i, 1)
2380 te_2d(i, j) = pe(i, km+1, j)*phiz(i, km+1) - pe(i, 1, j)*phiz(&
2385 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(cp*tv(i&
2386 & , k)+0.25*rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i&
2387 & , j, k)**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i&
2388 & , j, k)+v(i+1, j, k))*cosa_s_l(i, j))) + delp(i, j, k)*(cp&
2389 & *tv_tl(i, k)+0.25*rsin2_l(i, j)*(2*u(i, j, k)*u_tl(i, j, k&
2390 & )+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(i, j, k)*v_tl(i, j, k&
2391 & )+2*v(i+1, j, k)*v_tl(i+1, j, k)-cosa_s_l(i, j)*((u_tl(i, &
2392 & j, k)+u_tl(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))+(u(i, j, &
2393 & k)+u(i, j+1, k))*(v_tl(i, j, k)+v_tl(i+1, j, k)))))
2394 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*tv(i, k)+0.25*&
2395 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2&
2396 & +v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i&
2397 & +1, j, k))*cosa_s_l(i, j)))
2405 phiz_tl(i, km+1) = 0.0
2406 phiz(i, km+1) = hs(i, j)
2408 phiz_tl(i, k) = phiz_tl(i, k+1) -
grav*delz_tl(i, j, k)
2409 phiz(i, k) = phiz(i, k+1) -
grav*delz(i, j, k)
2413 te_2d_tl(i, j) = 0.0
2416 IF (moist_phys)
THEN 2419 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(
cv_air&
2420 & *pt(i, j, k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+&
2421 & 0.5*rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j&
2422 & , k)**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, &
2423 & j, k)+v(i+1, j, k))*cosa_s_l(i, j)))) + delp(i, j, k)*(&
2424 &
cv_air*pt_tl(i, j, k)+0.5*(phiz_tl(i, k)+phiz_tl(i, k+1)&
2425 & +2*w(i, j, k)*w_tl(i, j, k)+0.5*rsin2_l(i, j)*(2*u(i, j&
2426 & , k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(i&
2427 & , j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k)-&
2428 & cosa_s_l(i, j)*((u_tl(i, j, k)+u_tl(i, j+1, k))*(v(i, j&
2429 & , k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+1, k))*(v_tl(i, j&
2430 & , k)+v_tl(i+1, j, k))))))
2431 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
2432 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
2433 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
2434 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
2435 & )+v(i+1, j, k))*cosa_s_l(i, j))))
2441 te_2d_tl(i, j) = te_2d_tl(i, j) + delp_tl(i, j, k)*(
cv_air&
2442 & *pt(i, j, k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+&
2443 & 0.5*rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j&
2444 & , k)**2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, &
2445 & j, k)+v(i+1, j, k))*cosa_s_l(i, j)))) + delp(i, j, k)*(&
2446 &
cv_air*pt_tl(i, j, k)+0.5*(phiz_tl(i, k)+phiz_tl(i, k+1)&
2447 & +2*w(i, j, k)*w_tl(i, j, k)+0.5*rsin2_l(i, j)*(2*u(i, j&
2448 & , k)*u_tl(i, j, k)+2*u(i, j+1, k)*u_tl(i, j+1, k)+2*v(i&
2449 & , j, k)*v_tl(i, j, k)+2*v(i+1, j, k)*v_tl(i+1, j, k)-&
2450 & cosa_s_l(i, j)*((u_tl(i, j, k)+u_tl(i, j+1, k))*(v(i, j&
2451 & , k)+v(i+1, j, k))+(u(i, j, k)+u(i, j+1, k))*(v_tl(i, j&
2452 & , k)+v_tl(i+1, j, k))))))
2453 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
2454 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
2455 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
2456 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
2457 & )+v(i+1, j, k))*cosa_s_l(i, j))))
2466 IF (id_te .GT. 0)
THEN 2471 teq_tl(i, j) = te_2d_tl(i, j)
2472 teq(i, j) = te_2d(i, j)
2474 IF (moist_phys)
THEN 2477 teq_tl(i, j) = teq_tl(i, j) +
hlv*(q_tl(i, j, k, sphum)*&
2478 & delp(i, j, k)+q(i, j, k, sphum)*delp_tl(i, j, k))
2479 teq(i, j) = teq(i, j) +
hlv*q(i, j, k, sphum)*delp(i, j, k&
2490 & , u, v, w, delz, pt, delp, q, qc, pe, peln, hs, rsin2_l, cosa_s_l, &
2491 & r_vir, cp, rg, hlv, te_2d, ua, va, teq, moist_phys, nwat, sphum, &
2492 & liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
2498 INTEGER,
INTENT(IN) :: km, is, ie, js, je, isd, ied, jsd, jed, id_te
2499 INTEGER,
INTENT(IN) :: sphum, liq_wat, ice_wat, rainwat, snowwat, &
2501 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: ua, va
2502 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt, delp
2503 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q
2504 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc
2505 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
2506 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
2508 REAL,
INTENT(IN) :: w(isd:ied, jsd:jed, km)
2509 REAL,
INTENT(IN) :: delz(isd:ied, jsd:jed, km)
2511 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
2513 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
2515 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
2516 REAL,
INTENT(IN) :: cp, rg, r_vir,
hlv 2517 REAL,
INTENT(IN) :: rsin2_l(isd:ied, jsd:jed)
2518 REAL,
INTENT(IN) :: cosa_s_l(isd:ied, jsd:jed)
2519 LOGICAL,
INTENT(IN) :: moist_phys, hydrostatic
2522 REAL,
INTENT(OUT) :: te_2d(is:ie, js:je)
2524 REAL,
INTENT(OUT) :: teq(is:ie, js:je)
2526 REAL,
DIMENSION(is:ie, km) :: tv
2527 REAL :: phiz(is:ie, km+1)
2528 REAL :: cvm(is:ie), qd(is:ie)
2539 IF (hydrostatic)
THEN 2541 phiz(i, km+1) = hs(i, j)
2545 tv(i, k) = pt(i, j, k)*(1.+qc(i, j, k))
2546 phiz(i, k) = phiz(i, k+1) + rg*tv(i, k)*(peln(i, k+1, j)-&
2551 te_2d(i, j) = pe(i, km+1, j)*phiz(i, km+1) - pe(i, 1, j)*phiz(&
2556 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*tv(i, k)+0.25*&
2557 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2&
2558 & +v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i&
2559 & +1, j, k))*cosa_s_l(i, j)))
2567 phiz(i, km+1) = hs(i, j)
2569 phiz(i, k) = phiz(i, k+1) -
grav*delz(i, j, k)
2575 IF (moist_phys)
THEN 2578 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
2579 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
2580 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
2581 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
2582 & )+v(i+1, j, k))*cosa_s_l(i, j))))
2588 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
2589 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
2590 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
2591 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
2592 & )+v(i+1, j, k))*cosa_s_l(i, j))))
2601 IF (id_te .GT. 0)
THEN 2605 teq(i, j) = te_2d(i, j)
2607 IF (moist_phys)
THEN 2610 teq(i, j) = teq(i, j) +
hlv*q(i, j, k, sphum)*delp(i, j, k&
2621 SUBROUTINE pkez_tlm(km, ifirst, ilast, jfirst, jlast, j, pe, pk, pk_tl&
2622 & , akap, peln, peln_tl, pkz, pkz_tl, ptop)
2625 INTEGER,
INTENT(IN) :: km, j
2627 INTEGER,
INTENT(IN) :: ifirst, ilast
2629 INTEGER,
INTENT(IN) :: jfirst, jlast
2630 REAL,
INTENT(IN) :: akap
2631 REAL,
INTENT(IN) :: pe(ifirst-1:ilast+1, km+1, jfirst-1:jlast+1)
2632 REAL,
INTENT(IN) :: pk(ifirst:ilast, jfirst:jlast, km+1)
2633 REAL,
INTENT(IN) :: pk_tl(ifirst:ilast, jfirst:jlast, km+1)
2634 REAL,
INTENT(IN) :: ptop
2636 REAL,
INTENT(OUT) :: pkz(ifirst:ilast, jfirst:jlast, km)
2637 REAL,
INTENT(OUT) :: pkz_tl(ifirst:ilast, jfirst:jlast, km)
2639 REAL,
INTENT(INOUT) :: peln(ifirst:ilast, km+1, jfirst:jlast)
2640 REAL,
INTENT(INOUT) :: peln_tl(ifirst:ilast, km+1, jfirst:jlast)
2642 REAL :: pk2(ifirst:ilast, km+1)
2643 REAL :: pk2_tl(ifirst:ilast, km+1)
2650 ak1 = (akap+1.)/akap
2651 pek_tl = pk_tl(ifirst, j, 1)
2652 pek = pk(ifirst, j, 1)
2655 pk2_tl(i, 1) = pek_tl
2661 pk2_tl(i, k) = pk_tl(i, j, k)
2662 pk2(i, k) = pk(i, j, k)
2668 peln_tl(i, 1, j) = peln_tl(i, 2, j)
2669 peln(i, 1, j) = peln(i, 2, j) - ak1
2674 peln_tl(i, 1, j) = 0.0
2681 pkz_tl(i, j, k) = ((pk2_tl(i, k+1)-pk2_tl(i, k))*akap*(peln(i, k&
2682 & +1, j)-peln(i, k, j))-(pk2(i, k+1)-pk2(i, k))*akap*(peln_tl(i&
2683 & , k+1, j)-peln_tl(i, k, j)))/(akap*(peln(i, k+1, j)-peln(i, k&
2685 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1, j)-&
2690 SUBROUTINE pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, &
2694 INTEGER,
INTENT(IN) :: km, j
2696 INTEGER,
INTENT(IN) :: ifirst, ilast
2698 INTEGER,
INTENT(IN) :: jfirst, jlast
2699 REAL,
INTENT(IN) :: akap
2700 REAL,
INTENT(IN) :: pe(ifirst-1:ilast+1, km+1, jfirst-1:jlast+1)
2701 REAL,
INTENT(IN) :: pk(ifirst:ilast, jfirst:jlast, km+1)
2702 REAL,
INTENT(IN) :: ptop
2704 REAL,
INTENT(OUT) :: pkz(ifirst:ilast, jfirst:jlast, km)
2706 REAL,
INTENT(INOUT) :: peln(ifirst:ilast, km+1, jfirst:jlast)
2708 REAL :: pk2(ifirst:ilast, km+1)
2714 ak1 = (akap+1.)/akap
2715 pek = pk(ifirst, j, 1)
2722 pk2(i, k) = pk(i, j, k)
2728 peln(i, 1, j) = peln(i, 2, j) - ak1
2739 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1, j)-&
2744 SUBROUTINE remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
2748 INTEGER,
INTENT(IN) :: i1
2750 INTEGER,
INTENT(IN) :: i2
2752 INTEGER,
INTENT(IN) :: kord
2754 INTEGER,
INTENT(IN) :: km
2756 INTEGER,
INTENT(IN) :: kn
2757 INTEGER,
INTENT(IN) :: iv
2759 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
2762 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
2765 REAL,
INTENT(IN) :: q1(i1:i2, km)
2768 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
2771 REAL :: dp1(i1:i2, km)
2772 REAL :: q4(4, i1:i2, km)
2773 REAL :: pl, pr, qsum, delp, esl
2774 INTEGER :: i, k, l, m, k0
2778 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
2779 q4(1, i, k) = q1(i, k)
2783 IF (kord .GT. 7)
THEN 2784 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
2794 IF (pe2(i, k) .LE. pe1(i, l) .AND. pe2(i, k) .GE. pe1(i, l+1)&
2796 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
2797 IF (pe2(i, k+1) .GE. pe1(i, l+1))
THEN 2799 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
2800 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
2801 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
2806 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
2807 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
2811 IF (pe2(i, k+1) .LT. pe1(i, m+1))
THEN 2813 qsum = qsum + dp1(i, m)*q4(1, i, m)
2815 delp = pe2(i, k+1) - pe1(i, m)
2816 esl = delp/dp1(i, m)
2817 qsum = qsum + delp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-&
2818 & q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
2827 123 q2(i, k) = qsum/(pe2(i, k+1)-pe2(i, k))
2832 SUBROUTINE map_scalar(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend&
2833 & , jbeg, jend, iv, kord, q_min)
2837 INTEGER,
INTENT(IN) :: i1
2839 INTEGER,
INTENT(IN) :: i2
2841 INTEGER,
INTENT(IN) :: iv
2844 INTEGER,
INTENT(IN) :: kord
2846 INTEGER,
INTENT(IN) :: j
2847 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
2849 INTEGER,
INTENT(IN) :: km
2851 INTEGER,
INTENT(IN) :: kn
2853 REAL,
INTENT(IN) :: qs(i1:i2)
2855 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
2859 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
2865 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
2866 REAL,
INTENT(IN) :: q_min
2874 REAL :: dp1(i1:i2, km)
2875 REAL :: q4(4, i1:i2, km)
2876 REAL :: pl, pr, qsum, dp, esl
2877 INTEGER :: i, k, l, m, k0
2880 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
2881 q4(1, i, k) = q2(i, j, k)
2885 IF (kord .GT. 7)
THEN 2895 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
2897 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
2898 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 2900 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
2901 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-&
2902 & q4(2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
2907 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
2908 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
2912 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 2914 qsum = qsum + dp1(i, m)*q4(1, i, m)
2916 dp = pe2(i, k+1) - pe1(i, m)
2918 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
2919 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
2928 123 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
2933 SUBROUTINE map1_ppm(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, &
2934 & jbeg, jend, iv, kord)
2937 INTEGER,
INTENT(IN) :: i1
2939 INTEGER,
INTENT(IN) :: i2
2941 INTEGER,
INTENT(IN) :: iv
2944 INTEGER,
INTENT(IN) :: kord
2946 INTEGER,
INTENT(IN) :: j
2947 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
2949 INTEGER,
INTENT(IN) :: km
2951 INTEGER,
INTENT(IN) :: kn
2953 REAL,
INTENT(IN) :: qs(i1:i2)
2955 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
2959 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
2965 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
2973 REAL :: dp1(i1:i2, km)
2974 REAL :: q4(4, i1:i2, km)
2975 REAL :: pl, pr, qsum, dp, esl
2976 INTEGER :: i, k, l, m, k0
2979 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
2980 q4(1, i, k) = q2(i, j, k)
2984 IF (kord .GT. 7)
THEN 2985 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
2994 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
2996 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
2997 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 2999 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
3000 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-&
3001 & q4(2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
3006 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
3007 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
3011 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 3013 qsum = qsum + dp1(i, m)*q4(1, i, m)
3015 dp = pe2(i, k+1) - pe1(i, m)
3017 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
3018 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
3027 123 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
3032 SUBROUTINE mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd&
3033 & , ied, jsd, jed, q_min, fill)
3037 INTEGER,
INTENT(IN) :: km
3038 INTEGER,
INTENT(IN) :: j, nq, i1, i2
3039 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
3040 INTEGER,
INTENT(IN) :: kord(nq)
3042 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
3046 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
3049 REAL,
INTENT(IN) :: dp2(i1:i2, km)
3050 REAL,
INTENT(IN) :: q_min
3051 LOGICAL,
INTENT(IN) :: fill
3053 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
3055 REAL :: q4(4, i1:i2, km, nq)
3057 REAL :: q2(i1:i2, km, nq)
3059 REAL :: dp1(i1:i2, km)
3061 REAL :: pl, pr, dp, esl, fac1, fac2
3062 INTEGER :: i, k, l, m, k0, iq
3065 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
3071 q4(1, i, k, iq) = q1(i, j, k, iq)
3074 CALL scalar_profile(qs, q4(1:4, i1:i2, 1:km, iq), dp1, km, i1, i2&
3075 & , 0, kord(iq), q_min)
3083 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
3085 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
3086 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 3088 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
3090 fac2 =
r3*(pr*fac1+pl*pl)
3093 q2(i, k, iq) = q4(2, i, l, iq) + (q4(4, i, l, iq)+q4(3, &
3094 & i, l, iq)-q4(2, i, l, iq))*fac1 - q4(4, i, l, iq)*fac2
3100 dp = pe1(i, l+1) - pe2(i, k)
3102 fac2 =
r3*(1.+pl*fac1)
3105 qsum(iq) = dp*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, i&
3106 & , l, iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2)
3110 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 3113 qsum(iq) = qsum(iq) + dp1(i, m)*q4(1, i, m, iq)
3116 dp = pe2(i, k+1) - pe1(i, m)
3121 qsum(iq) = qsum(iq) + dp*(q4(2, i, m, iq)+fac1*(q4(3&
3122 & , i, m, iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2))
3134 q2(i, k, iq) = qsum(iq)/dp2(i, k)
3139 IF (fill)
CALL fillz(i2 - i1 + 1, km, nq, q2, dp2)
3144 q1(i, j, k, iq) = q2(i, k, iq)
3149 SUBROUTINE map1_q2(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j&
3150 & , ibeg, iend, jbeg, jend, q_min)
3153 INTEGER,
INTENT(IN) :: j
3154 INTEGER,
INTENT(IN) :: i1, i2
3155 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
3157 INTEGER,
INTENT(IN) :: iv
3158 INTEGER,
INTENT(IN) :: kord
3160 INTEGER,
INTENT(IN) :: km
3162 INTEGER,
INTENT(IN) :: kn
3164 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
3168 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
3172 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
3173 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
3174 REAL,
INTENT(IN) :: q_min
3177 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
3180 REAL :: dp1(i1:i2, km)
3181 REAL :: q4(4, i1:i2, km)
3182 REAL :: pl, pr, qsum, dp, esl
3183 INTEGER :: i, k, l, m, k0
3186 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
3187 q4(1, i, k) = q1(i, j, k)
3191 IF (kord .GT. 7)
THEN 3202 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
3204 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
3205 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 3207 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
3208 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
3209 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
3214 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
3215 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
3219 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 3221 qsum = qsum + dp1(i, m)*q4(1, i, m)
3223 dp = pe2(i, k+1) - pe1(i, m)
3225 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
3226 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
3235 123 q2(i, k) = qsum/dp2(i, k)
3240 SUBROUTINE scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
3244 INTEGER,
INTENT(IN) :: i1, i2
3246 INTEGER,
INTENT(IN) :: km
3248 INTEGER,
INTENT(IN) :: iv
3251 INTEGER,
INTENT(IN) :: kord
3252 REAL,
INTENT(IN) :: qs(i1:i2)
3254 REAL,
INTENT(IN) :: delp(i1:i2, km)
3256 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
3257 REAL,
INTENT(IN) :: qmin
3259 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
3260 REAL :: gam(i1:i2, km)
3261 REAL :: q(i1:i2, km+1)
3263 REAL :: bet, a_bot, grat
3264 REAL :: pmp_1, lac_1, pmp_2, lac_2
3330 IF (iv .EQ. -2)
THEN 3333 q(i, 1) = 1.5*a4(1, i, 1)
3337 grat = delp(i, k-1)/delp(i, k)
3338 bet = 2. + grat + grat - gam(i, k)
3339 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
3340 gam(i, k+1) = grat/bet
3344 grat = delp(i, km-1)/delp(i, km)
3345 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
3346 & 1))/(2.+grat+grat-gam(i, km))
3351 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
3357 grat = delp(i, 2)/delp(i, 1)
3358 bet = grat*(grat+0.5)
3359 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
3360 gam(i, 1) = (1.+grat*(grat+1.5))/bet
3364 d4(i) = delp(i, k-1)/delp(i, k)
3365 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
3366 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
3367 gam(i, k) = d4(i)/bet
3371 a_bot = 1. + d4(i)*(d4(i)+1.5)
3372 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
3373 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
3377 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
3381 IF (kord .GE. 0.)
THEN 3387 IF (abs0 .GT. 16)
THEN 3390 a4(2, i, k) = q(i, k)
3391 a4(3, i, k) = q(i, k+1)
3392 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
3404 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 3409 IF (q(i, 2) .GT. y1)
THEN 3414 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 3419 IF (q(i, 2) .LT. y2)
THEN 3427 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
3433 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 3434 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 3439 IF (q(i, k) .GT. y3)
THEN 3444 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 3449 IF (q(i, k) .LT. y4)
THEN 3454 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 3455 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 3460 IF (q(i, k) .LT. y5)
THEN 3466 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 3471 IF (q(i, k) .GT. y6)
THEN 3477 IF (0. .LT. q(i, k))
THEN 3488 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 3493 IF (q(i, km) .GT. y7)
THEN 3498 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 3503 IF (q(i, km) .LT. y8)
THEN 3511 a4(2, i, k) = q(i, k)
3512 a4(3, i, k) = q(i, k+1)
3516 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 3518 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
3523 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
3526 IF (kord .GE. 0.)
THEN 3531 IF (abs1 .EQ. 16)
THEN 3533 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
3534 IF (a4(4, i, k) .GE. 0.)
THEN 3539 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 3540 abs13 = a4(2, i, k) - a4(3, i, k)
3542 abs13 = -(a4(2, i, k)-a4(3, i, k))
3544 ext6(i, k) = abs2 .GT. abs13
3555 IF (0. .LT. a4(2, i, 1))
THEN 3556 a4(2, i, 1) = a4(2, i, 1)
3561 ELSE IF (iv .EQ. -1)
THEN 3563 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
3565 ELSE IF (iv .EQ. 2)
THEN 3567 a4(2, i, 1) = a4(1, i, 1)
3568 a4(3, i, 1) = a4(1, i, 1)
3574 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
3576 CALL cs_limiters(im, extm(i1, 1), a4(1, i1, 1), 1)
3580 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
3582 CALL cs_limiters(im, extm(i1, 2), a4(1, i1, 2), 2)
3587 IF (kord .GE. 0.)
THEN 3592 IF (abs3 .LT. 9)
THEN 3595 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
3596 lac_1 = pmp_1 + 1.5*gam(i, k+2)
3597 IF (a4(1, i, k) .GT. pmp_1)
THEN 3598 IF (pmp_1 .GT. lac_1)
THEN 3603 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 3608 IF (a4(2, i, k) .LT. y21)
THEN 3613 IF (a4(1, i, k) .LT. pmp_1)
THEN 3614 IF (pmp_1 .LT. lac_1)
THEN 3619 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 3624 IF (x1 .GT. y9)
THEN 3630 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
3631 lac_2 = pmp_2 - 1.5*gam(i, k-1)
3632 IF (a4(1, i, k) .GT. pmp_2)
THEN 3633 IF (pmp_2 .GT. lac_2)
THEN 3638 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 3643 IF (a4(3, i, k) .LT. y22)
THEN 3648 IF (a4(1, i, k) .LT. pmp_2)
THEN 3649 IF (pmp_2 .LT. lac_2)
THEN 3654 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 3659 IF (x2 .GT. y10)
THEN 3664 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
3667 IF (kord .GE. 0.)
THEN 3672 IF (abs4 .EQ. 9)
THEN 3674 IF (extm(i, k) .AND. extm(i, k-1))
THEN 3676 a4(2, i, k) = a4(1, i, k)
3677 a4(3, i, k) = a4(1, i, k)
3679 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 3681 a4(2, i, k) = a4(1, i, k)
3682 a4(3, i, k) = a4(1, i, k)
3684 ELSE IF (extm(i, k) .AND. a4(1, i, k) .LT. qmin)
THEN 3686 a4(2, i, k) = a4(1, i, k)
3687 a4(3, i, k) = a4(1, i, k)
3690 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k&
3692 IF (a4(4, i, k) .GE. 0.)
THEN 3697 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 3698 abs14 = a4(2, i, k) - a4(3, i, k)
3700 abs14 = -(a4(2, i, k)-a4(3, i, k))
3703 IF (abs5 .GT. abs14)
THEN 3704 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
3705 lac_1 = pmp_1 + 1.5*gam(i, k+2)
3706 IF (a4(1, i, k) .GT. pmp_1)
THEN 3707 IF (pmp_1 .GT. lac_1)
THEN 3712 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 3717 IF (a4(2, i, k) .LT. y23)
THEN 3722 IF (a4(1, i, k) .LT. pmp_1)
THEN 3723 IF (pmp_1 .LT. lac_1)
THEN 3728 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 3733 IF (x3 .GT. y11)
THEN 3738 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
3739 lac_2 = pmp_2 - 1.5*gam(i, k-1)
3740 IF (a4(1, i, k) .GT. pmp_2)
THEN 3741 IF (pmp_2 .GT. lac_2)
THEN 3746 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 3751 IF (a4(3, i, k) .LT. y24)
THEN 3756 IF (a4(1, i, k) .LT. pmp_2)
THEN 3757 IF (pmp_2 .LT. lac_2)
THEN 3762 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 3767 IF (x4 .GT. y12)
THEN 3772 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i&
3778 IF (kord .GE. 0.)
THEN 3783 IF (abs6 .EQ. 10)
THEN 3785 IF (extm(i, k))
THEN 3786 IF ((a4(1, i, k) .LT. qmin .OR. extm(i, k-1)) .OR. &
3787 & extm(i, k+1))
THEN 3789 a4(2, i, k) = a4(1, i, k)
3790 a4(3, i, k) = a4(1, i, k)
3794 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
3799 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
3801 IF (a4(4, i, k) .GE. 0.)
THEN 3806 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 3807 abs15 = a4(2, i, k) - a4(3, i, k)
3809 abs15 = -(a4(2, i, k)-a4(3, i, k))
3812 IF (abs7 .GT. abs15)
THEN 3813 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
3814 lac_1 = pmp_1 + 1.5*gam(i, k+2)
3815 IF (a4(1, i, k) .GT. pmp_1)
THEN 3816 IF (pmp_1 .GT. lac_1)
THEN 3821 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 3826 IF (a4(2, i, k) .LT. y25)
THEN 3831 IF (a4(1, i, k) .LT. pmp_1)
THEN 3832 IF (pmp_1 .LT. lac_1)
THEN 3837 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 3842 IF (x5 .GT. y13)
THEN 3847 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
3848 lac_2 = pmp_2 - 1.5*gam(i, k-1)
3849 IF (a4(1, i, k) .GT. pmp_2)
THEN 3850 IF (pmp_2 .GT. lac_2)
THEN 3855 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 3860 IF (a4(3, i, k) .LT. y26)
THEN 3865 IF (a4(1, i, k) .LT. pmp_2)
THEN 3866 IF (pmp_2 .LT. lac_2)
THEN 3871 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 3876 IF (x6 .GT. y14)
THEN 3881 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
3887 IF (kord .GE. 0.)
THEN 3892 IF (abs8 .EQ. 12)
THEN 3894 IF (extm(i, k))
THEN 3895 a4(2, i, k) = a4(1, i, k)
3896 a4(3, i, k) = a4(1, i, k)
3900 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
3902 IF (a4(4, i, k) .GE. 0.)
THEN 3907 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 3908 abs16 = a4(2, i, k) - a4(3, i, k)
3910 abs16 = -(a4(2, i, k)-a4(3, i, k))
3913 IF (abs9 .GT. abs16)
THEN 3914 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
3915 lac_1 = pmp_1 + 1.5*gam(i, k+2)
3916 IF (a4(1, i, k) .GT. pmp_1)
THEN 3917 IF (pmp_1 .GT. lac_1)
THEN 3922 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 3927 IF (a4(2, i, k) .LT. y27)
THEN 3932 IF (a4(1, i, k) .LT. pmp_1)
THEN 3933 IF (pmp_1 .LT. lac_1)
THEN 3938 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 3943 IF (x7 .GT. y15)
THEN 3948 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
3949 lac_2 = pmp_2 - 1.5*gam(i, k-1)
3950 IF (a4(1, i, k) .GT. pmp_2)
THEN 3951 IF (pmp_2 .GT. lac_2)
THEN 3956 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 3961 IF (a4(3, i, k) .LT. y28)
THEN 3966 IF (a4(1, i, k) .LT. pmp_2)
THEN 3967 IF (pmp_2 .LT. lac_2)
THEN 3972 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 3977 IF (x8 .GT. y16)
THEN 3982 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
3988 IF (kord .GE. 0.)
THEN 3993 IF (abs10 .EQ. 13)
THEN 3995 IF (extm(i, k))
THEN 3996 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 3998 a4(2, i, k) = a4(1, i, k)
3999 a4(3, i, k) = a4(1, i, k)
4003 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
4004 lac_1 = pmp_1 + 1.5*gam(i, k+2)
4005 IF (a4(1, i, k) .GT. pmp_1)
THEN 4006 IF (pmp_1 .GT. lac_1)
THEN 4011 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 4016 IF (a4(2, i, k) .LT. y29)
THEN 4021 IF (a4(1, i, k) .LT. pmp_1)
THEN 4022 IF (pmp_1 .LT. lac_1)
THEN 4027 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 4032 IF (x9 .GT. y17)
THEN 4038 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
4039 lac_2 = pmp_2 - 1.5*gam(i, k-1)
4040 IF (a4(1, i, k) .GT. pmp_2)
THEN 4041 IF (pmp_2 .GT. lac_2)
THEN 4046 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 4051 IF (a4(3, i, k) .LT. y30)
THEN 4056 IF (a4(1, i, k) .LT. pmp_2)
THEN 4057 IF (pmp_2 .LT. lac_2)
THEN 4062 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 4067 IF (x10 .GT. y18)
THEN 4072 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
4076 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
4081 IF (kord .GE. 0.)
THEN 4086 IF (abs11 .EQ. 14)
THEN 4088 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
4092 IF (kord .GE. 0.)
THEN 4097 IF (abs12 .EQ. 16)
THEN 4099 IF (ext6(i, k))
THEN 4100 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 4102 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
4103 lac_1 = pmp_1 + 1.5*gam(i, k+2)
4104 IF (a4(1, i, k) .GT. pmp_1)
THEN 4105 IF (pmp_1 .GT. lac_1)
THEN 4110 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 4115 IF (a4(2, i, k) .LT. y31)
THEN 4120 IF (a4(1, i, k) .LT. pmp_1)
THEN 4121 IF (pmp_1 .LT. lac_1)
THEN 4126 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 4131 IF (x11 .GT. y19)
THEN 4137 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
4138 lac_2 = pmp_2 - 1.5*gam(i, k-1)
4139 IF (a4(1, i, k) .GT. pmp_2)
THEN 4140 IF (pmp_2 .GT. lac_2)
THEN 4145 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 4150 IF (a4(3, i, k) .LT. y32)
THEN 4155 IF (a4(1, i, k) .LT. pmp_2)
THEN 4156 IF (pmp_2 .LT. lac_2)
THEN 4161 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 4166 IF (x12 .GT. y20)
THEN 4171 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k&
4179 IF (extm(i, k) .AND. ((extm(i, k-1) .OR. extm(i&
4180 & , k+1)) .OR. a4(1, i, k) .LT. qmin))
THEN 4182 a4(2, i, k) = a4(1, i, k)
4183 a4(3, i, k) = a4(1, i, k)
4186 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+&
4198 IF (iv .EQ. 0)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 0&
4207 IF (0. .LT. a4(3, i, km))
THEN 4208 a4(3, i, km) = a4(3, i, km)
4213 ELSE IF (iv .EQ. -1)
THEN 4215 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.) a4(3, i, km) = 0.
4220 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
4222 IF (k .EQ. km - 1)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k&
4224 IF (k .EQ. km)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 1&
4234 INTEGER,
INTENT(IN) :: im
4235 INTEGER,
INTENT(IN) :: iv
4236 LOGICAL,
INTENT(IN) :: extm(im)
4238 REAL,
INTENT(INOUT) :: a4(4, im)
4239 REAL,
INTENT(INOUT) :: a4_tl(4, im)
4241 REAL :: da1, da2, a6da
4248 IF (a4(1, i) .LE. 0.)
THEN 4249 a4_tl(2, i) = a4_tl(1, i)
4251 a4_tl(3, i) = a4_tl(1, i)
4256 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 4257 abs0 = a4(3, i) - a4(2, i)
4259 abs0 = -(a4(3, i)-a4(2, i))
4261 IF (abs0 .LT. -a4(4, i))
THEN 4262 IF (a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4, &
4263 & i)*
r12 .LT. 0.)
THEN 4265 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
4267 a4_tl(3, i) = a4_tl(1, i)
4269 a4_tl(2, i) = a4_tl(1, i)
4273 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 4274 a4_tl(4, i) = 3.*(a4_tl(2, i)-a4_tl(1, i))
4275 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
4276 a4_tl(3, i) = a4_tl(2, i) - a4_tl(4, i)
4277 a4(3, i) = a4(2, i) - a4(4, i)
4279 a4_tl(4, i) = 3.*(a4_tl(3, i)-a4_tl(1, i))
4280 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
4281 a4_tl(2, i) = a4_tl(3, i) - a4_tl(4, i)
4282 a4(2, i) = a4(3, i) - a4(4, i)
4288 ELSE IF (iv .EQ. 1)
THEN 4290 IF ((a4(1, i)-a4(2, i))*(a4(1, i)-a4(3, i)) .GE. 0.)
THEN 4291 a4_tl(2, i) = a4_tl(1, i)
4293 a4_tl(3, i) = a4_tl(1, i)
4298 da1 = a4(3, i) - a4(2, i)
4301 IF (a6da .LT. -da2)
THEN 4302 a4_tl(4, i) = 3.*(a4_tl(2, i)-a4_tl(1, i))
4303 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
4304 a4_tl(3, i) = a4_tl(2, i) - a4_tl(4, i)
4305 a4(3, i) = a4(2, i) - a4(4, i)
4306 ELSE IF (a6da .GT. da2)
THEN 4307 a4_tl(4, i) = 3.*(a4_tl(3, i)-a4_tl(1, i))
4308 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
4309 a4_tl(2, i) = a4_tl(3, i) - a4_tl(4, i)
4310 a4(2, i) = a4(3, i) - a4(4, i)
4318 a4_tl(2, i) = a4_tl(1, i)
4320 a4_tl(3, i) = a4_tl(1, i)
4325 da1 = a4(3, i) - a4(2, i)
4328 IF (a6da .LT. -da2)
THEN 4329 a4_tl(4, i) = 3.*(a4_tl(2, i)-a4_tl(1, i))
4330 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
4331 a4_tl(3, i) = a4_tl(2, i) - a4_tl(4, i)
4332 a4(3, i) = a4(2, i) - a4(4, i)
4333 ELSE IF (a6da .GT. da2)
THEN 4334 a4_tl(4, i) = 3.*(a4_tl(3, i)-a4_tl(1, i))
4335 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
4336 a4_tl(2, i) = a4_tl(3, i) - a4_tl(4, i)
4337 a4(2, i) = a4(3, i) - a4(4, i)
4346 SUBROUTINE ppm_profile_tlm(a4, a4_tl, delp, delp_tl, km, i1, i2, iv, &
4351 INTEGER,
INTENT(IN) :: iv
4356 INTEGER,
INTENT(IN) :: i1
4358 INTEGER,
INTENT(IN) :: i2
4360 INTEGER,
INTENT(IN) :: km
4362 INTEGER,
INTENT(IN) :: kord
4365 REAL,
INTENT(IN) :: delp(i1:i2, km)
4366 REAL,
INTENT(IN) :: delp_tl(i1:i2, km)
4369 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
4370 REAL,
INTENT(INOUT) :: a4_tl(4, i1:i2, km)
4379 REAL :: dc(i1:i2, km)
4380 REAL :: dc_tl(i1:i2, km)
4381 REAL :: h2(i1:i2, km)
4382 REAL :: h2_tl(i1:i2, km)
4383 REAL :: delq(i1:i2, km)
4384 REAL :: delq_tl(i1:i2, km)
4385 REAL :: df2(i1:i2, km)
4386 REAL :: df2_tl(i1:i2, km)
4387 REAL :: d4(i1:i2, km)
4388 REAL :: d4_tl(i1:i2, km)
4390 INTEGER :: i, k, km1, lmt, it
4392 REAL :: a1, a2, c1, c2, c3, d1, d2
4393 REAL :: a1_tl, a2_tl, c1_tl, c2_tl, c3_tl, d1_tl, d2_tl
4394 REAL :: qm, dq, lac, qmp, pmp
4395 REAL :: qm_tl, dq_tl, lac_tl, qmp_tl, pmp_tl
4439 delq_tl(i, k-1) = a4_tl(1, i, k) - a4_tl(1, i, k-1)
4440 delq(i, k-1) = a4(1, i, k) - a4(1, i, k-1)
4441 d4_tl(i, k) = delp_tl(i, k-1) + delp_tl(i, k)
4442 d4(i, k) = delp(i, k-1) + delp(i, k)
4449 c1_tl = ((delp_tl(i, k-1)+0.5*delp_tl(i, k))*d4(i, k+1)-(delp(i&
4450 & , k-1)+0.5*delp(i, k))*d4_tl(i, k+1))/d4(i, k+1)**2
4451 c1 = (delp(i, k-1)+0.5*delp(i, k))/d4(i, k+1)
4452 c2_tl = ((delp_tl(i, k+1)+0.5*delp_tl(i, k))*d4(i, k)-(delp(i, k&
4453 & +1)+0.5*delp(i, k))*d4_tl(i, k))/d4(i, k)**2
4454 c2 = (delp(i, k+1)+0.5*delp(i, k))/d4(i, k)
4455 df2_tl(i, k) = ((delp_tl(i, k)*(c1*delq(i, k)+c2*delq(i, k-1))+&
4456 & delp(i, k)*(c1_tl*delq(i, k)+c1*delq_tl(i, k)+c2_tl*delq(i, k-&
4457 & 1)+c2*delq_tl(i, k-1)))*(d4(i, k)+delp(i, k+1))-delp(i, k)*(c1&
4458 & *delq(i, k)+c2*delq(i, k-1))*(d4_tl(i, k)+delp_tl(i, k+1)))/(&
4459 & d4(i, k)+delp(i, k+1))**2
4460 df2(i, k) = delp(i, k)*(c1*delq(i, k)+c2*delq(i, k-1))/(d4(i, k)&
4462 IF (df2(i, k) .GE. 0.)
THEN 4463 x1_tl = df2_tl(i, k)
4466 x1_tl = -df2_tl(i, k)
4469 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 4470 IF (a4(1, i, k) .LT. a4(1, i, k+1))
THEN 4471 max1_tl = a4_tl(1, i, k+1)
4472 max1 = a4(1, i, k+1)
4474 max1_tl = a4_tl(1, i, k)
4477 ELSE IF (a4(1, i, k-1) .LT. a4(1, i, k+1))
THEN 4478 max1_tl = a4_tl(1, i, k+1)
4479 max1 = a4(1, i, k+1)
4481 max1_tl = a4_tl(1, i, k-1)
4482 max1 = a4(1, i, k-1)
4484 y1_tl = max1_tl - a4_tl(1, i, k)
4485 y1 = max1 - a4(1, i, k)
4486 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 4487 IF (a4(1, i, k) .GT. a4(1, i, k+1))
THEN 4488 min2_tl = a4_tl(1, i, k+1)
4489 min2 = a4(1, i, k+1)
4491 min2_tl = a4_tl(1, i, k)
4494 ELSE IF (a4(1, i, k-1) .GT. a4(1, i, k+1))
THEN 4495 min2_tl = a4_tl(1, i, k+1)
4496 min2 = a4(1, i, k+1)
4498 min2_tl = a4_tl(1, i, k-1)
4499 min2 = a4(1, i, k-1)
4501 z1_tl = a4_tl(1, i, k) - min2_tl
4502 z1 = a4(1, i, k) - min2
4503 IF (x1 .GT. y1)
THEN 4504 IF (y1 .GT. z1)
THEN 4511 ELSE IF (x1 .GT. z1)
THEN 4518 dc_tl(i, k) = min1_tl*sign(1.d0, min1*df2(i, k))
4519 dc(i, k) = sign(min1, df2(i, k))
4527 c1_tl = ((delq_tl(i, k-1)*delp(i, k-1)+delq(i, k-1)*delp_tl(i, k&
4528 & -1))*d4(i, k)-delq(i, k-1)*delp(i, k-1)*d4_tl(i, k))/d4(i, k)&
4530 c1 = delq(i, k-1)*delp(i, k-1)/d4(i, k)
4531 a1_tl = (d4_tl(i, k-1)*(d4(i, k)+delp(i, k-1))-d4(i, k-1)*(d4_tl&
4532 & (i, k)+delp_tl(i, k-1)))/(d4(i, k)+delp(i, k-1))**2
4533 a1 = d4(i, k-1)/(d4(i, k)+delp(i, k-1))
4534 a2_tl = (d4_tl(i, k+1)*(d4(i, k)+delp(i, k))-d4(i, k+1)*(d4_tl(i&
4535 & , k)+delp_tl(i, k)))/(d4(i, k)+delp(i, k))**2
4536 a2 = d4(i, k+1)/(d4(i, k)+delp(i, k))
4537 a4_tl(2, i, k) = a4_tl(1, i, k-1) + c1_tl + 2.*(delp_tl(i, k)*(&
4538 & c1*(a1-a2)+a2*dc(i, k-1))+delp(i, k)*(c1_tl*(a1-a2)+c1*(a1_tl-&
4539 & a2_tl)+a2_tl*dc(i, k-1)+a2*dc_tl(i, k-1))-delp_tl(i, k-1)*a1*&
4540 & dc(i, k)-delp(i, k-1)*(a1_tl*dc(i, k)+a1*dc_tl(i, k)))/(d4(i, &
4541 & k-1)+d4(i, k+1)) - 2.*(d4_tl(i, k-1)+d4_tl(i, k+1))*(delp(i, k&
4542 & )*(c1*(a1-a2)+a2*dc(i, k-1))-delp(i, k-1)*a1*dc(i, k))/(d4(i, &
4543 & k-1)+d4(i, k+1))**2
4544 a4(2, i, k) = a4(1, i, k-1) + c1 + 2./(d4(i, k-1)+d4(i, k+1))*(&
4545 & delp(i, k)*(c1*(a1-a2)+a2*dc(i, k-1))-delp(i, k-1)*a1*dc(i, k)&
4553 d1_tl = delp_tl(i, 1)
4555 d2_tl = delp_tl(i, 2)
4557 qm_tl = ((d2_tl*a4(1, i, 1)+d2*a4_tl(1, i, 1)+d1_tl*a4(1, i, 2)+d1&
4558 & *a4_tl(1, i, 2))*(d1+d2)-(d2*a4(1, i, 1)+d1*a4(1, i, 2))*(d1_tl+&
4559 & d2_tl))/(d1+d2)**2
4560 qm = (d2*a4(1, i, 1)+d1*a4(1, i, 2))/(d1+d2)
4561 dq_tl = (2.*(a4_tl(1, i, 2)-a4_tl(1, i, 1))*(d1+d2)-2.*(a4(1, i, 2&
4562 & )-a4(1, i, 1))*(d1_tl+d2_tl))/(d1+d2)**2
4563 dq = 2.*(a4(1, i, 2)-a4(1, i, 1))/(d1+d2)
4564 c1_tl = (4.*(a4_tl(2, i, 3)-qm_tl-d2_tl*dq-d2*dq_tl)*d2*(2.*d2*d2+&
4565 & d1*(d2+3.*d1))-4.*(a4(2, i, 3)-qm-d2*dq)*(d2_tl*(2.*d2*d2+d1*(d2&
4566 & +3.*d1))+d2*(2.*(d2_tl*d2+d2*d2_tl)+d1_tl*(d2+3.*d1)+d1*(d2_tl+&
4567 & 3.*d1_tl))))/(d2*(2.*d2*d2+d1*(d2+3.*d1)))**2
4568 c1 = 4.*(a4(2, i, 3)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
4569 c3_tl = dq_tl - 0.5*(c1_tl*(d2*(5.*d1+d2)-3.*d1*d1)+c1*(d2_tl*(5.*&
4570 & d1+d2)+d2*(5.*d1_tl+d2_tl)-3.*(d1_tl*d1+d1*d1_tl)))
4571 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
4572 a4_tl(2, i, 2) = qm_tl - 0.25*(((c1_tl*d1+c1*d1_tl)*d2+c1*d1*d2_tl&
4573 & )*(d2+3.*d1)+c1*d1*d2*(d2_tl+3.*d1_tl))
4574 a4(2, i, 2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
4577 a4_tl(2, i, 1) = d1_tl*(2.*c1*d1**2-c3) + d1*(2.*(c1_tl*d1**2+c1*2&
4578 & *d1*d1_tl)-c3_tl) + a4_tl(2, i, 2)
4579 a4(2, i, 1) = d1*(2.*c1*d1**2-c3) + a4(2, i, 2)
4580 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 4581 y2_tl = a4_tl(1, i, 2)
4584 y2_tl = a4_tl(1, i, 1)
4587 IF (a4(2, i, 2) .LT. y2)
THEN 4588 a4_tl(2, i, 2) = y2_tl
4591 a4(2, i, 2) = a4(2, i, 2)
4593 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 4594 y3_tl = a4_tl(1, i, 2)
4597 y3_tl = a4_tl(1, i, 1)
4600 IF (a4(2, i, 2) .GT. y3)
THEN 4601 a4_tl(2, i, 2) = y3_tl
4604 a4(2, i, 2) = a4(2, i, 2)
4606 dc_tl(i, 1) = 0.5*(a4_tl(2, i, 2)-a4_tl(1, i, 1))
4607 dc(i, 1) = 0.5*(a4(2, i, 2)-a4(1, i, 1))
4612 IF (0. .LT. a4(2, i, 1))
THEN 4613 a4(2, i, 1) = a4(2, i, 1)
4615 a4_tl(2, i, 1) = 0.0
4618 IF (0. .LT. a4(2, i, 2))
THEN 4619 a4(2, i, 2) = a4(2, i, 2)
4621 a4_tl(2, i, 2) = 0.0
4625 ELSE IF (iv .EQ. -1)
THEN 4627 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.)
THEN 4628 a4_tl(2, i, 1) = 0.0
4633 IF (iv .GE. 0.)
THEN 4638 IF (abs0 .EQ. 2)
THEN 4640 a4_tl(2, i, 1) = a4_tl(1, i, 1)
4641 a4(2, i, 1) = a4(1, i, 1)
4642 a4_tl(3, i, 1) = a4_tl(1, i, 1)
4643 a4(3, i, 1) = a4(1, i, 1)
4650 d1_tl = delp_tl(i, km)
4652 d2_tl = delp_tl(i, km1)
4654 qm_tl = ((d2_tl*a4(1, i, km)+d2*a4_tl(1, i, km)+d1_tl*a4(1, i, km1&
4655 & )+d1*a4_tl(1, i, km1))*(d1+d2)-(d2*a4(1, i, km)+d1*a4(1, i, km1)&
4656 & )*(d1_tl+d2_tl))/(d1+d2)**2
4657 qm = (d2*a4(1, i, km)+d1*a4(1, i, km1))/(d1+d2)
4658 dq_tl = (2.*(a4_tl(1, i, km1)-a4_tl(1, i, km))*(d1+d2)-2.*(a4(1, i&
4659 & , km1)-a4(1, i, km))*(d1_tl+d2_tl))/(d1+d2)**2
4660 dq = 2.*(a4(1, i, km1)-a4(1, i, km))/(d1+d2)
4661 c1_tl = ((a4_tl(2, i, km1)-qm_tl-d2_tl*dq-d2*dq_tl)*d2*(2.*d2*d2+&
4662 & d1*(d2+3.*d1))-(a4(2, i, km1)-qm-d2*dq)*(d2_tl*(2.*d2*d2+d1*(d2+&
4663 & 3.*d1))+d2*(2.*(d2_tl*d2+d2*d2_tl)+d1_tl*(d2+3.*d1)+d1*(d2_tl+3.&
4664 & *d1_tl))))/(d2*(2.*d2*d2+d1*(d2+3.*d1)))**2
4665 c1 = (a4(2, i, km1)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
4666 c3_tl = dq_tl - 2.0*(c1_tl*(d2*(5.*d1+d2)-3.*d1*d1)+c1*(d2_tl*(5.*&
4667 & d1+d2)+d2*(5.*d1_tl+d2_tl)-3.*(d1_tl*d1+d1*d1_tl)))
4668 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
4669 a4_tl(2, i, km) = qm_tl - ((c1_tl*d1+c1*d1_tl)*d2+c1*d1*d2_tl)*(d2&
4670 & +3.*d1) - c1*d1*d2*(d2_tl+3.*d1_tl)
4671 a4(2, i, km) = qm - c1*d1*d2*(d2+3.*d1)
4674 a4_tl(3, i, km) = d1_tl*(8.*c1*d1**2-c3) + d1*(8.*(c1_tl*d1**2+c1*&
4675 & 2*d1*d1_tl)-c3_tl) + a4_tl(2, i, km)
4676 a4(3, i, km) = d1*(8.*c1*d1**2-c3) + a4(2, i, km)
4677 IF (a4(1, i, km) .GT. a4(1, i, km1))
THEN 4678 y4_tl = a4_tl(1, i, km1)
4681 y4_tl = a4_tl(1, i, km)
4684 IF (a4(2, i, km) .LT. y4)
THEN 4685 a4_tl(2, i, km) = y4_tl
4688 a4(2, i, km) = a4(2, i, km)
4690 IF (a4(1, i, km) .LT. a4(1, i, km1))
THEN 4691 y5_tl = a4_tl(1, i, km1)
4694 y5_tl = a4_tl(1, i, km)
4697 IF (a4(2, i, km) .GT. y5)
THEN 4698 a4_tl(2, i, km) = y5_tl
4701 a4(2, i, km) = a4(2, i, km)
4703 dc_tl(i, km) = 0.5*(a4_tl(1, i, km)-a4_tl(2, i, km))
4704 dc(i, km) = 0.5*(a4(1, i, km)-a4(2, i, km))
4709 IF (0. .LT. a4(2, i, km))
THEN 4710 a4(2, i, km) = a4(2, i, km)
4712 a4_tl(2, i, km) = 0.0
4715 IF (0. .LT. a4(3, i, km))
THEN 4716 a4(3, i, km) = a4(3, i, km)
4718 a4_tl(3, i, km) = 0.0
4722 ELSE IF (iv .LT. 0)
THEN 4724 IF (a4(1, i, km)*a4(3, i, km) .LE. 0.)
THEN 4725 a4_tl(3, i, km) = 0.0
4732 a4_tl(3, i, k) = a4_tl(2, i, k+1)
4733 a4(3, i, k) = a4(2, i, k+1)
4742 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(3, i&
4744 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
4747 & (1, i1, k), it, 0)
4749 IF (kord .GE. 7)
THEN 4759 h2_tl(i, k) = (2.*((dc_tl(i, k+1)*delp(i, k+1)-dc(i, k+1)*&
4760 & delp_tl(i, k+1))/delp(i, k+1)**2-(dc_tl(i, k-1)*delp(i, k-1)&
4761 & -dc(i, k-1)*delp_tl(i, k-1))/delp(i, k-1)**2)*(delp(i, k)+&
4762 & 0.5*(delp(i, k-1)+delp(i, k+1)))-2.*(dc(i, k+1)/delp(i, k+1)&
4763 & -dc(i, k-1)/delp(i, k-1))*(delp_tl(i, k)+0.5*(delp_tl(i, k-1&
4764 & )+delp_tl(i, k+1))))*delp(i, k)**2/(delp(i, k)+0.5*(delp(i, &
4765 & k-1)+delp(i, k+1)))**2 + 2.*(dc(i, k+1)/delp(i, k+1)-dc(i, k&
4766 & -1)/delp(i, k-1))*2*delp(i, k)*delp_tl(i, k)/(delp(i, k)+0.5&
4767 & *(delp(i, k-1)+delp(i, k+1)))
4768 h2(i, k) = 2.*(dc(i, k+1)/delp(i, k+1)-dc(i, k-1)/delp(i, k-1)&
4769 & )/(delp(i, k)+0.5*(delp(i, k-1)+delp(i, k+1)))*delp(i, k)**2
4782 pmp_tl = 2.*dc_tl(i, k)
4784 qmp_tl = a4_tl(1, i, k) + pmp_tl
4785 qmp = a4(1, i, k) + pmp
4786 lac_tl = a4_tl(1, i, k) + fac*h2_tl(i, k-1) + dc_tl(i, k)
4787 lac = a4(1, i, k) + fac*h2(i, k-1) + dc(i, k)
4788 IF (a4(1, i, k) .GT. qmp)
THEN 4789 IF (qmp .GT. lac)
THEN 4796 ELSE IF (a4(1, i, k) .GT. lac)
THEN 4800 y8_tl = a4_tl(1, i, k)
4803 IF (a4(3, i, k) .LT. y8)
THEN 4807 x2_tl = a4_tl(3, i, k)
4810 IF (a4(1, i, k) .LT. qmp)
THEN 4811 IF (qmp .LT. lac)
THEN 4818 ELSE IF (a4(1, i, k) .LT. lac)
THEN 4822 y6_tl = a4_tl(1, i, k)
4825 IF (x2 .GT. y6)
THEN 4826 a4_tl(3, i, k) = y6_tl
4829 a4_tl(3, i, k) = x2_tl
4836 qmp_tl = a4_tl(1, i, k) - pmp_tl
4837 qmp = a4(1, i, k) - pmp
4838 lac_tl = a4_tl(1, i, k) + fac*h2_tl(i, k+1) - dc_tl(i, k)
4839 lac = a4(1, i, k) + fac*h2(i, k+1) - dc(i, k)
4840 IF (a4(1, i, k) .GT. qmp)
THEN 4841 IF (qmp .GT. lac)
THEN 4848 ELSE IF (a4(1, i, k) .GT. lac)
THEN 4852 y9_tl = a4_tl(1, i, k)
4855 IF (a4(2, i, k) .LT. y9)
THEN 4859 x3_tl = a4_tl(2, i, k)
4862 IF (a4(1, i, k) .LT. qmp)
THEN 4863 IF (qmp .LT. lac)
THEN 4870 ELSE IF (a4(1, i, k) .LT. lac)
THEN 4874 y7_tl = a4_tl(1, i, k)
4877 IF (x3 .GT. y7)
THEN 4878 a4_tl(2, i, k) = y7_tl
4881 a4_tl(2, i, k) = x3_tl
4887 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(3&
4889 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
4900 IF (0 .LT. lmt)
THEN 4906 IF (2 .GT. lmt)
THEN 4913 IF (kord .NE. 4)
THEN 4915 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(&
4917 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
4921 & a4(1, i1, k), a4_tl(1, i1, k), &
4927 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(3, i&
4929 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
4932 & (1, i1, k), it, 0)
4942 REAL,
INTENT(IN) :: dm(*)
4943 REAL,
INTENT(IN) :: dm_tl(*)
4945 INTEGER,
INTENT(IN) :: itot
4947 INTEGER,
INTENT(IN) :: lmt
4953 REAL,
INTENT(INOUT) :: a4(4, *)
4954 REAL,
INTENT(INOUT) :: a4_tl(4, *)
4962 REAL :: da1, da2, a6da
4982 IF (lmt .EQ. 3)
THEN 4984 ELSE IF (lmt .EQ. 0)
THEN 4987 IF (dm(i) .EQ. 0.)
THEN 4988 a4_tl(2, i) = a4_tl(1, i)
4990 a4_tl(3, i) = a4_tl(1, i)
4995 da1 = a4(3, i) - a4(2, i)
4998 IF (a6da .LT. -da2)
THEN 4999 a4_tl(4, i) = 3.*(a4_tl(2, i)-a4_tl(1, i))
5000 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
5001 a4_tl(3, i) = a4_tl(2, i) - a4_tl(4, i)
5002 a4(3, i) = a4(2, i) - a4(4, i)
5003 ELSE IF (a6da .GT. da2)
THEN 5004 a4_tl(4, i) = 3.*(a4_tl(3, i)-a4_tl(1, i))
5005 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
5006 a4_tl(2, i) = a4_tl(3, i) - a4_tl(4, i)
5007 a4(2, i) = a4(3, i) - a4(4, i)
5011 ELSE IF (lmt .EQ. 1)
THEN 5015 qmp_tl = 2.*dm_tl(i)
5017 IF (qmp .GE. 0.)
THEN 5024 IF (a4(2, i) - a4(1, i) .GE. 0.)
THEN 5025 y1_tl = a4_tl(2, i) - a4_tl(1, i)
5026 y1 = a4(2, i) - a4(1, i)
5028 y1_tl = -(a4_tl(2, i)-a4_tl(1, i))
5029 y1 = -(a4(2, i)-a4(1, i))
5031 IF (x1 .GT. y1)
THEN 5038 a4_tl(2, i) = a4_tl(1, i) - min1_tl*sign(1.d0, min1*qmp)
5039 a4(2, i) = a4(1, i) - sign(min1, qmp)
5040 IF (qmp .GE. 0.)
THEN 5047 IF (a4(3, i) - a4(1, i) .GE. 0.)
THEN 5048 y2_tl = a4_tl(3, i) - a4_tl(1, i)
5049 y2 = a4(3, i) - a4(1, i)
5051 y2_tl = -(a4_tl(3, i)-a4_tl(1, i))
5052 y2 = -(a4(3, i)-a4(1, i))
5054 IF (x2 .GT. y2)
THEN 5061 a4_tl(3, i) = a4_tl(1, i) + min2_tl*sign(1.d0, min2*qmp)
5062 a4(3, i) = a4(1, i) + sign(min2, qmp)
5063 a4_tl(4, i) = 3.*(2.*a4_tl(1, i)-a4_tl(2, i)-a4_tl(3, i))
5064 a4(4, i) = 3.*(2.*a4(1, i)-(a4(2, i)+a4(3, i)))
5066 ELSE IF (lmt .EQ. 2)
THEN 5069 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 5070 abs0 = a4(3, i) - a4(2, i)
5072 abs0 = -(a4(3, i)-a4(2, i))
5074 IF (abs0 .LT. -a4(4, i))
THEN 5075 fmin = a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4&
5077 IF (fmin .LT. 0.)
THEN 5078 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
5080 a4_tl(3, i) = a4_tl(1, i)
5082 a4_tl(2, i) = a4_tl(1, i)
5086 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 5087 a4_tl(4, i) = 3.*(a4_tl(2, i)-a4_tl(1, i))
5088 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
5089 a4_tl(3, i) = a4_tl(2, i) - a4_tl(4, i)
5090 a4(3, i) = a4(2, i) - a4(4, i)
5092 a4_tl(4, i) = 3.*(a4_tl(3, i)-a4_tl(1, i))
5093 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
5094 a4_tl(2, i) = a4_tl(3, i) - a4_tl(4, i)
5095 a4(2, i) = a4(3, i) - a4(4, i)
5102 SUBROUTINE steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
5104 INTEGER,
INTENT(IN) :: km, i1, i2
5106 REAL,
INTENT(IN) :: dp(i1:i2, km)
5108 REAL,
INTENT(IN) :: dq(i1:i2, km)
5110 REAL,
INTENT(IN) :: d4(i1:i2, km)
5112 REAL,
INTENT(IN) :: df2(i1:i2, km)
5114 REAL,
INTENT(IN) :: dm(i1:i2, km)
5117 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
5120 REAL :: alfa(i1:i2, km)
5121 REAL :: f(i1:i2, km)
5122 REAL :: rat(i1:i2, km)
5130 rat(i, k) = dq(i, k-1)/d4(i, k)
5136 f(i, k) = (rat(i, k+1)-rat(i, k))/(dp(i, k-1)+dp(i, k)+dp(i, k+1&
5142 IF (f(i, k+1)*f(i, k-1) .LT. 0. .AND. df2(i, k) .NE. 0.)
THEN 5143 dg2 = (f(i, k+1)-f(i, k-1))*((dp(i, k+1)-dp(i, k-1))**2+d4(i, &
5145 IF (0.5 .GT. -(0.1875*dg2/df2(i, k)))
THEN 5146 y1 = -(0.1875*dg2/df2(i, k))
5150 IF (0. .LT. y1)
THEN 5162 a4(2, i, k) = (1.-alfa(i, k-1)-alfa(i, k))*a4(2, i, k) + alfa(i&
5163 & , k-1)*(a4(1, i, k)-dm(i, k)) + alfa(i, k)*(a4(1, i, k-1)+dm(i&
5168 SUBROUTINE rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, &
5169 & ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, &
5170 & w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, &
5171 & make_nh, domain, square_domain)
5178 INTEGER,
INTENT(IN) :: km
5180 INTEGER,
INTENT(IN) :: kn
5182 INTEGER,
INTENT(IN) :: nq, ntp
5184 INTEGER,
INTENT(IN) :: is, ie, isd, ied
5186 INTEGER,
INTENT(IN) :: js, je, jsd, jed
5187 LOGICAL,
INTENT(IN) :: hydrostatic, make_nh, square_domain
5188 REAL,
INTENT(IN) :: ptop
5189 REAL,
INTENT(IN) :: ak_r(km+1)
5190 REAL,
INTENT(IN) :: bk_r(km+1)
5191 REAL,
INTENT(IN) :: ak(kn+1)
5192 REAL,
INTENT(IN) :: bk(kn+1)
5194 REAL,
INTENT(IN) :: delp_r(is:ie, js:je, km)
5196 REAL,
INTENT(IN) :: u_r(is:ie, js:je+1, km)
5198 REAL,
INTENT(IN) :: v_r(is:ie+1, js:je, km)
5199 REAL,
INTENT(INOUT) :: pt_r(is:ie, js:je, km)
5200 REAL,
INTENT(IN) :: w_r(is:ie, js:je, km)
5201 REAL,
INTENT(IN) :: q_r(is:ie, js:je, km, ntp)
5202 REAL,
INTENT(IN) :: qdiag_r(is:ie, js:je, km, ntp+1:nq)
5203 REAL,
INTENT(INOUT) :: delz_r(is:ie, js:je, km)
5204 TYPE(
domain2d),
INTENT(INOUT) :: domain
5207 REAL,
INTENT(OUT) :: delp(isd:ied, jsd:jed, kn)
5209 REAL,
INTENT(OUT) :: u(isd:ied, jsd:jed+1, kn)
5211 REAL,
INTENT(OUT) :: v(isd:ied+1, jsd:jed, kn)
5213 REAL,
INTENT(OUT) :: w(isd:, jsd:, :)
5215 REAL,
INTENT(OUT) :: pt(isd:ied, jsd:jed, kn)
5216 REAL,
INTENT(OUT) :: q(isd:ied, jsd:jed, kn, ntp)
5217 REAL,
INTENT(OUT) :: qdiag(isd:ied, jsd:jed, kn, ntp+1:nq)
5219 REAL,
INTENT(OUT) :: delz(isd:, jsd:, :)
5221 REAL :: r_vir, rgrav
5223 REAL :: ps(isd:ied, jsd:jed)
5224 REAL :: pe1(is:ie, km+1)
5225 REAL :: pe2(is:ie, kn+1)
5226 REAL :: pv1(is:ie+1, km+1)
5227 REAL :: pv2(is:ie+1, kn+1)
5228 INTEGER :: i, j, k, iq
5229 INTEGER,
PARAMETER :: kord=4
5244 ps(i, j) = ps(i, j) + delp_r(i, j, k)
5249 IF (square_domain)
THEN 5251 & ehalo=1, shalo=1, nhalo=1)
5260 pt_r(i, j, k) = pt_r(i, j, k)*(1.+r_vir*q_r(i, j, k, 1))
5274 pe1(i, k) = ak_r(k) + 0.5*bk_r(k)*(ps(i, j-1)+ps(i, j))
5279 pe2(i, k) = ak(k) + 0.5*bk(k)*(ps(i, j-1)+ps(i, j))
5282 CALL remap_2d(km, pe1, u_r(is:ie, j:j, 1:km), kn, pe2, u(is:ie, j:&
5283 & j, 1:kn), is, ie, -1, kord)
5285 IF (j .NE. je + 1)
THEN 5291 pe1(i, k) = ak_r(k) + bk_r(k)*ps(i, j)
5296 pe2(i, k) = ak(k) + bk(k)*ps(i, j)
5304 delp(i, j, k) = pe2(i, k+1) - pe2(i, k)
5312 CALL remap_2d(km, pe1, q_r(is:ie, j:j, 1:km, iq:iq), kn, pe2&
5313 & , q(is:ie, j:j, 1:kn, iq:iq), is, ie, 0, kord)
5316 CALL remap_2d(km, pe1, qdiag_r(is:ie, j:j, 1:km, iq:iq), kn&
5317 & , pe2, qdiag(is:ie, j:j, 1:kn, iq:iq), is, ie, 0, &
5321 IF (.NOT.hydrostatic .AND. (.NOT.make_nh))
THEN 5323 CALL remap_2d(km, pe1, w_r(is:ie, j:j, 1:km), kn, pe2, w(is:ie&
5324 & , j:j, 1:kn), is, ie, -1, kord)
5329 delz_r(i, j, k) = -(delz_r(i, j, k)/delp_r(i, j, k))
5332 CALL remap_2d(km, pe1, delz_r(is:ie, j:j, 1:km), kn, pe2, delz&
5333 & (is:ie, j:j, 1:kn), is, ie, 1, kord)
5336 delz(i, j, k) = -(delz(i, j, k)*delp(i, j, k))
5343 pe1(i, k) = log(pe1(i, k))
5348 pe2(i, k) = log(pe2(i, k))
5351 CALL remap_2d(km, pe1, pt_r(is:ie, j:j, 1:km), kn, pe2, pt(is:ie&
5352 & , j:j, 1:kn), is, ie, 1, kord)
5358 pv1(i, k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1, j)+ps(i, j))
5363 pv2(i, k) = ak(k) + 0.5*bk(k)*(ps(i-1, j)+ps(i, j))
5366 CALL remap_2d(km, pv1, v_r(is:ie+1, j:j, 1:km), kn, pv2, v(is:ie&
5367 & +1, j:j, 1:kn), is, ie + 1, -1, kord)
5374 pt(i, j, k) = pt(i, j, k)/(1.+r_vir*q(i, j, k, 1))
5379 SUBROUTINE remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
5381 INTEGER,
INTENT(IN) :: i1, i2
5383 INTEGER,
INTENT(IN) :: iv
5384 INTEGER,
INTENT(IN) :: kord
5386 INTEGER,
INTENT(IN) :: km
5388 INTEGER,
INTENT(IN) :: kn
5390 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5394 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5398 REAL,
INTENT(IN) :: q1(i1:i2, km)
5400 REAL,
INTENT(OUT) :: q2(i1:i2, kn)
5403 REAL :: dp1(i1:i2, km)
5404 REAL :: q4(4, i1:i2, km)
5405 REAL :: pl, pr, qsum, dp, esl
5406 INTEGER :: i, k, l, m, k0
5409 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5410 q4(1, i, k) = q1(i, k)
5414 IF (kord .GT. 7)
THEN 5415 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
5422 IF (pe2(i, k) .LE. pe1(i, 1))
THEN 5428 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1&
5430 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5431 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5433 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5434 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4&
5435 & (2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
5440 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i&
5441 & , l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*&
5445 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 5447 qsum = qsum + dp1(i, m)*q4(1, i, m)
5449 dp = pe2(i, k+1) - pe1(i, m)
5451 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-&
5452 & q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
5461 123 q2(i, k) = qsum/(pe2(i, k+1)-pe2(i, k))
5467 SUBROUTINE mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
5477 INTEGER,
INTENT(IN) :: i1, i2, km, kn, kord, iv
5478 REAL,
INTENT(IN) :: pe1(i1:i2, km+1), pe2(i1:i2, kn+1)
5479 REAL,
INTENT(IN) :: q1(i1:i2, km)
5480 REAL,
INTENT(OUT) :: q2(i1:i2, kn)
5481 REAL,
INTENT(IN) :: ptop
5484 REAL :: dp1(i1:i2, km)
5485 REAL :: a4(4, i1:i2, km)
5488 REAL :: pl, pr, tt, delp, qsum, dpsum, esl
5491 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5492 a4(1, i, k) = q1(i, k)
5495 IF (kord .GT. 7)
THEN 5496 CALL cs_profile(qs, a4, dp1, km, i1, i2, iv, kord)
5506 IF (pe2(i, k) .LE. pe1(i, 1))
THEN 5509 ELSE IF (pe2(i, k) .GE. pe1(i, km+1))
THEN 5511 q2(i, k) = q1(i, km)
5515 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1&
5518 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5519 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5521 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5522 tt =
r3*(pr*(pr+pl)+pl**2)
5523 q2(i, k) = a4(2, i, l) + 0.5*(a4(4, i, l)+a4(3, i, l)-a4&
5524 & (2, i, l))*(pr+pl) - a4(4, i, l)*tt
5528 delp = pe1(i, l+1) - pe2(i, k)
5529 tt =
r3*(1.+pl*(1.+pl))
5530 qsum = delp*(a4(2, i, l)+0.5*(a4(4, i, l)+a4(3, i, l)-a4&
5531 & (2, i, l))*(1.+pl)-a4(4, i, l)*tt)
5540 IF (pe2(i, k+1) .GT. pe1(i, l+1))
THEN 5542 qsum = qsum + dp1(i, l)*q1(i, l)
5543 dpsum = dpsum + dp1(i, l)
5545 delp = pe2(i, k+1) - pe1(i, l)
5546 esl = delp/dp1(i, l)
5547 qsum = qsum + delp*(a4(2, i, l)+0.5*esl*(a4(3, i, l)-a4(2&
5548 & , i, l)+a4(4, i, l)*(1.-
r23*esl)))
5549 dpsum = dpsum + delp
5554 delp = pe2(i, k+1) - pe1(i, km+1)
5555 IF (delp .GT. 0.)
THEN 5557 qsum = qsum + delp*q1(i, km)
5558 dpsum = dpsum + delp
5560 123 q2(i, k) = qsum/dpsum
5565 END SUBROUTINE mappm 5566 SUBROUTINE cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
5570 INTEGER,
INTENT(IN) :: i1, i2
5572 INTEGER,
INTENT(IN) :: km
5574 INTEGER,
INTENT(IN) :: iv
5577 INTEGER,
INTENT(IN) :: kord
5578 REAL,
INTENT(IN) :: qs(i1:i2)
5580 REAL,
INTENT(IN) :: delp(i1:i2, km)
5582 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
5584 LOGICAL :: extm(i1:i2, km)
5585 REAL :: gam(i1:i2, km)
5586 REAL :: q(i1:i2, km+1)
5588 REAL :: bet, a_bot, grat
5589 REAL :: pmp_1, lac_1, pmp_2, lac_2
5645 IF (iv .EQ. -2)
THEN 5648 q(i, 1) = 1.5*a4(1, i, 1)
5652 grat = delp(i, k-1)/delp(i, k)
5653 bet = 2. + grat + grat - gam(i, k)
5654 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
5655 gam(i, k+1) = grat/bet
5659 grat = delp(i, km-1)/delp(i, km)
5660 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
5661 & 1))/(2.+grat+grat-gam(i, km))
5666 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
5672 grat = delp(i, 2)/delp(i, 1)
5673 bet = grat*(grat+0.5)
5674 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
5675 gam(i, 1) = (1.+grat*(grat+1.5))/bet
5679 d4(i) = delp(i, k-1)/delp(i, k)
5680 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
5681 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
5682 gam(i, k) = d4(i)/bet
5686 a_bot = 1. + d4(i)*(d4(i)+1.5)
5687 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
5688 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
5692 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
5696 IF (kord .GE. 0.)
THEN 5702 IF (abs0 .GT. 16)
THEN 5705 a4(2, i, k) = q(i, k)
5706 a4(3, i, k) = q(i, k+1)
5707 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
5719 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 5724 IF (q(i, 2) .GT. y1)
THEN 5729 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 5734 IF (q(i, 2) .LT. y2)
THEN 5742 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
5748 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 5749 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 5754 IF (q(i, k) .GT. y3)
THEN 5759 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 5764 IF (q(i, k) .LT. y4)
THEN 5769 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 5770 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 5775 IF (q(i, k) .LT. y5)
THEN 5781 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 5786 IF (q(i, k) .GT. y6)
THEN 5792 IF (0. .LT. q(i, k))
THEN 5803 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 5808 IF (q(i, km) .GT. y7)
THEN 5813 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 5818 IF (q(i, km) .LT. y8)
THEN 5826 a4(2, i, k) = q(i, k)
5827 a4(3, i, k) = q(i, k+1)
5831 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 5833 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
5838 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
5849 IF (0. .LT. a4(2, i, 1))
THEN 5850 a4(2, i, 1) = a4(2, i, 1)
5855 ELSE IF (iv .EQ. -1)
THEN 5857 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
5859 ELSE IF (iv .EQ. 2)
THEN 5861 a4(2, i, 1) = a4(1, i, 1)
5862 a4(3, i, 1) = a4(1, i, 1)
5868 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
5870 CALL cs_limiters(im, extm(i1, 1), a4(1, i1, 1), 1)
5874 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
5876 CALL cs_limiters(im, extm(i1, 2), a4(1, i1, 2), 2)
5881 IF (kord .GE. 0.)
THEN 5886 IF (abs1 .LT. 9)
THEN 5889 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
5890 lac_1 = pmp_1 + 1.5*gam(i, k+2)
5891 IF (a4(1, i, k) .GT. pmp_1)
THEN 5892 IF (pmp_1 .GT. lac_1)
THEN 5897 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 5902 IF (a4(2, i, k) .LT. y19)
THEN 5907 IF (a4(1, i, k) .LT. pmp_1)
THEN 5908 IF (pmp_1 .LT. lac_1)
THEN 5913 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 5918 IF (x1 .GT. y9)
THEN 5924 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
5925 lac_2 = pmp_2 - 1.5*gam(i, k-1)
5926 IF (a4(1, i, k) .GT. pmp_2)
THEN 5927 IF (pmp_2 .GT. lac_2)
THEN 5932 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 5937 IF (a4(3, i, k) .LT. y20)
THEN 5942 IF (a4(1, i, k) .LT. pmp_2)
THEN 5943 IF (pmp_2 .LT. lac_2)
THEN 5948 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 5953 IF (x2 .GT. y10)
THEN 5958 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
5961 IF (kord .GE. 0.)
THEN 5966 IF (abs2 .EQ. 9)
THEN 5968 IF (extm(i, k) .AND. extm(i, k-1))
THEN 5971 a4(2, i, k) = a4(1, i, k)
5972 a4(3, i, k) = a4(1, i, k)
5974 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 5977 a4(2, i, k) = a4(1, i, k)
5978 a4(3, i, k) = a4(1, i, k)
5981 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i, &
5983 IF (a4(4, i, k) .GE. 0.)
THEN 5988 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 5989 abs10 = a4(2, i, k) - a4(3, i, k)
5991 abs10 = -(a4(2, i, k)-a4(3, i, k))
5994 IF (abs3 .GT. abs10)
THEN 5995 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
5996 lac_1 = pmp_1 + 1.5*gam(i, k+2)
5997 IF (a4(1, i, k) .GT. pmp_1)
THEN 5998 IF (pmp_1 .GT. lac_1)
THEN 6003 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 6008 IF (a4(2, i, k) .LT. y21)
THEN 6013 IF (a4(1, i, k) .LT. pmp_1)
THEN 6014 IF (pmp_1 .LT. lac_1)
THEN 6019 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 6024 IF (x3 .GT. y11)
THEN 6029 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
6030 lac_2 = pmp_2 - 1.5*gam(i, k-1)
6031 IF (a4(1, i, k) .GT. pmp_2)
THEN 6032 IF (pmp_2 .GT. lac_2)
THEN 6037 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 6042 IF (a4(3, i, k) .LT. y22)
THEN 6047 IF (a4(1, i, k) .LT. pmp_2)
THEN 6048 IF (pmp_2 .LT. lac_2)
THEN 6053 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 6058 IF (x4 .GT. y12)
THEN 6063 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
6069 IF (kord .GE. 0.)
THEN 6074 IF (abs4 .EQ. 10)
THEN 6076 IF (extm(i, k))
THEN 6077 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 6079 a4(2, i, k) = a4(1, i, k)
6080 a4(3, i, k) = a4(1, i, k)
6084 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
6089 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
6091 IF (a4(4, i, k) .GE. 0.)
THEN 6096 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 6097 abs11 = a4(2, i, k) - a4(3, i, k)
6099 abs11 = -(a4(2, i, k)-a4(3, i, k))
6102 IF (abs5 .GT. abs11)
THEN 6103 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
6104 lac_1 = pmp_1 + 1.5*gam(i, k+2)
6105 IF (a4(1, i, k) .GT. pmp_1)
THEN 6106 IF (pmp_1 .GT. lac_1)
THEN 6111 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 6116 IF (a4(2, i, k) .LT. y23)
THEN 6121 IF (a4(1, i, k) .LT. pmp_1)
THEN 6122 IF (pmp_1 .LT. lac_1)
THEN 6127 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 6132 IF (x5 .GT. y13)
THEN 6137 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
6138 lac_2 = pmp_2 - 1.5*gam(i, k-1)
6139 IF (a4(1, i, k) .GT. pmp_2)
THEN 6140 IF (pmp_2 .GT. lac_2)
THEN 6145 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 6150 IF (a4(3, i, k) .LT. y24)
THEN 6155 IF (a4(1, i, k) .LT. pmp_2)
THEN 6156 IF (pmp_2 .LT. lac_2)
THEN 6161 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 6166 IF (x6 .GT. y14)
THEN 6171 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
6177 IF (kord .GE. 0.)
THEN 6182 IF (abs6 .EQ. 12)
THEN 6184 IF (extm(i, k))
THEN 6186 a4(2, i, k) = a4(1, i, k)
6187 a4(3, i, k) = a4(1, i, k)
6191 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
6193 IF (a4(4, i, k) .GE. 0.)
THEN 6198 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 6199 abs12 = a4(2, i, k) - a4(3, i, k)
6201 abs12 = -(a4(2, i, k)-a4(3, i, k))
6204 IF (abs7 .GT. abs12)
THEN 6205 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
6206 lac_1 = pmp_1 + 1.5*gam(i, k+2)
6207 IF (a4(1, i, k) .GT. pmp_1)
THEN 6208 IF (pmp_1 .GT. lac_1)
THEN 6213 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 6218 IF (a4(2, i, k) .LT. y25)
THEN 6223 IF (a4(1, i, k) .LT. pmp_1)
THEN 6224 IF (pmp_1 .LT. lac_1)
THEN 6229 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 6234 IF (x7 .GT. y15)
THEN 6239 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
6240 lac_2 = pmp_2 - 1.5*gam(i, k-1)
6241 IF (a4(1, i, k) .GT. pmp_2)
THEN 6242 IF (pmp_2 .GT. lac_2)
THEN 6247 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 6252 IF (a4(3, i, k) .LT. y26)
THEN 6257 IF (a4(1, i, k) .LT. pmp_2)
THEN 6258 IF (pmp_2 .LT. lac_2)
THEN 6263 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 6268 IF (x8 .GT. y16)
THEN 6273 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
6279 IF (kord .GE. 0.)
THEN 6284 IF (abs8 .EQ. 13)
THEN 6286 IF (extm(i, k))
THEN 6287 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 6289 a4(2, i, k) = a4(1, i, k)
6290 a4(3, i, k) = a4(1, i, k)
6294 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
6295 lac_1 = pmp_1 + 1.5*gam(i, k+2)
6296 IF (a4(1, i, k) .GT. pmp_1)
THEN 6297 IF (pmp_1 .GT. lac_1)
THEN 6302 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 6307 IF (a4(2, i, k) .LT. y27)
THEN 6312 IF (a4(1, i, k) .LT. pmp_1)
THEN 6313 IF (pmp_1 .LT. lac_1)
THEN 6318 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 6323 IF (x9 .GT. y17)
THEN 6329 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
6330 lac_2 = pmp_2 - 1.5*gam(i, k-1)
6331 IF (a4(1, i, k) .GT. pmp_2)
THEN 6332 IF (pmp_2 .GT. lac_2)
THEN 6337 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 6342 IF (a4(3, i, k) .LT. y28)
THEN 6347 IF (a4(1, i, k) .LT. pmp_2)
THEN 6348 IF (pmp_2 .LT. lac_2)
THEN 6353 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 6358 IF (x10 .GT. y18)
THEN 6363 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
6367 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
6372 IF (kord .GE. 0.)
THEN 6377 IF (abs9 .EQ. 14)
THEN 6379 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
6385 IF (extm(i, k) .AND. (extm(i, k-1) .OR. extm(i, k+&
6388 a4(2, i, k) = a4(1, i, k)
6389 a4(3, i, k) = a4(1, i, k)
6392 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
6403 IF (iv .EQ. 0)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 0&
6412 IF (0. .LT. a4(3, i, km))
THEN 6413 a4(3, i, km) = a4(3, i, km)
6418 ELSE IF (iv .EQ. -1)
THEN 6420 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.) a4(3, i, km) = 0.
6425 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
6427 IF (k .EQ. km - 1)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k&
6429 IF (k .EQ. km)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 1&
6436 INTEGER,
INTENT(IN) :: im
6437 INTEGER,
INTENT(IN) :: iv
6438 LOGICAL,
INTENT(IN) :: extm(im)
6440 REAL,
INTENT(INOUT) :: a4(4, im)
6442 REAL :: da1, da2, a6da
6449 IF (a4(1, i) .LE. 0.)
THEN 6454 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 6455 abs0 = a4(3, i) - a4(2, i)
6457 abs0 = -(a4(3, i)-a4(2, i))
6459 IF (abs0 .LT. -a4(4, i))
THEN 6460 IF (a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4, &
6461 & i)*
r12 .LT. 0.)
THEN 6463 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
6468 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 6469 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
6470 a4(3, i) = a4(2, i) - a4(4, i)
6472 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
6473 a4(2, i) = a4(3, i) - a4(4, i)
6479 ELSE IF (iv .EQ. 1)
THEN 6481 IF ((a4(1, i)-a4(2, i))*(a4(1, i)-a4(3, i)) .GE. 0.)
THEN 6486 da1 = a4(3, i) - a4(2, i)
6489 IF (a6da .LT. -da2)
THEN 6490 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
6491 a4(3, i) = a4(2, i) - a4(4, i)
6492 ELSE IF (a6da .GT. da2)
THEN 6493 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
6494 a4(2, i) = a4(3, i) - a4(4, i)
6506 da1 = a4(3, i) - a4(2, i)
6509 IF (a6da .LT. -da2)
THEN 6510 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
6511 a4(3, i) = a4(2, i) - a4(4, i)
6512 ELSE IF (a6da .GT. da2)
THEN 6513 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
6514 a4(2, i) = a4(3, i) - a4(4, i)
6520 SUBROUTINE ppm_profile(a4, delp, km, i1, i2, iv, kord)
6524 INTEGER,
INTENT(IN) :: iv
6529 INTEGER,
INTENT(IN) :: i1
6531 INTEGER,
INTENT(IN) :: i2
6533 INTEGER,
INTENT(IN) :: km
6535 INTEGER,
INTENT(IN) :: kord
6538 REAL,
INTENT(IN) :: delp(i1:i2, km)
6541 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
6550 REAL :: dc(i1:i2, km)
6551 REAL :: h2(i1:i2, km)
6552 REAL :: delq(i1:i2, km)
6553 REAL :: df2(i1:i2, km)
6554 REAL :: d4(i1:i2, km)
6556 INTEGER :: i, k, km1, lmt, it
6558 REAL :: a1, a2, c1, c2, c3, d1, d2
6559 REAL :: qm, dq, lac, qmp, pmp
6585 delq(i, k-1) = a4(1, i, k) - a4(1, i, k-1)
6586 d4(i, k) = delp(i, k-1) + delp(i, k)
6591 c1 = (delp(i, k-1)+0.5*delp(i, k))/d4(i, k+1)
6592 c2 = (delp(i, k+1)+0.5*delp(i, k))/d4(i, k)
6593 df2(i, k) = delp(i, k)*(c1*delq(i, k)+c2*delq(i, k-1))/(d4(i, k)&
6595 IF (df2(i, k) .GE. 0.)
THEN 6600 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 6601 IF (a4(1, i, k) .LT. a4(1, i, k+1))
THEN 6602 max1 = a4(1, i, k+1)
6606 ELSE IF (a4(1, i, k-1) .LT. a4(1, i, k+1))
THEN 6607 max1 = a4(1, i, k+1)
6609 max1 = a4(1, i, k-1)
6611 y1 = max1 - a4(1, i, k)
6612 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 6613 IF (a4(1, i, k) .GT. a4(1, i, k+1))
THEN 6614 min2 = a4(1, i, k+1)
6618 ELSE IF (a4(1, i, k-1) .GT. a4(1, i, k+1))
THEN 6619 min2 = a4(1, i, k+1)
6621 min2 = a4(1, i, k-1)
6623 z1 = a4(1, i, k) - min2
6624 IF (x1 .GT. y1)
THEN 6625 IF (y1 .GT. z1)
THEN 6630 ELSE IF (x1 .GT. z1)
THEN 6635 dc(i, k) = sign(min1, df2(i, k))
6643 c1 = delq(i, k-1)*delp(i, k-1)/d4(i, k)
6644 a1 = d4(i, k-1)/(d4(i, k)+delp(i, k-1))
6645 a2 = d4(i, k+1)/(d4(i, k)+delp(i, k))
6646 a4(2, i, k) = a4(1, i, k-1) + c1 + 2./(d4(i, k-1)+d4(i, k+1))*(&
6647 & delp(i, k)*(c1*(a1-a2)+a2*dc(i, k-1))-delp(i, k-1)*a1*dc(i, k)&
6657 qm = (d2*a4(1, i, 1)+d1*a4(1, i, 2))/(d1+d2)
6658 dq = 2.*(a4(1, i, 2)-a4(1, i, 1))/(d1+d2)
6659 c1 = 4.*(a4(2, i, 3)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
6660 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
6661 a4(2, i, 2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
6664 a4(2, i, 1) = d1*(2.*c1*d1**2-c3) + a4(2, i, 2)
6665 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 6670 IF (a4(2, i, 2) .LT. y2)
THEN 6673 a4(2, i, 2) = a4(2, i, 2)
6675 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 6680 IF (a4(2, i, 2) .GT. y3)
THEN 6683 a4(2, i, 2) = a4(2, i, 2)
6685 dc(i, 1) = 0.5*(a4(2, i, 2)-a4(1, i, 1))
6690 IF (0. .LT. a4(2, i, 1))
THEN 6691 a4(2, i, 1) = a4(2, i, 1)
6695 IF (0. .LT. a4(2, i, 2))
THEN 6696 a4(2, i, 2) = a4(2, i, 2)
6701 ELSE IF (iv .EQ. -1)
THEN 6703 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
6706 IF (iv .GE. 0.)
THEN 6711 IF (abs0 .EQ. 2)
THEN 6713 a4(2, i, 1) = a4(1, i, 1)
6714 a4(3, i, 1) = a4(1, i, 1)
6723 qm = (d2*a4(1, i, km)+d1*a4(1, i, km1))/(d1+d2)
6724 dq = 2.*(a4(1, i, km1)-a4(1, i, km))/(d1+d2)
6725 c1 = (a4(2, i, km1)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
6726 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
6727 a4(2, i, km) = qm - c1*d1*d2*(d2+3.*d1)
6730 a4(3, i, km) = d1*(8.*c1*d1**2-c3) + a4(2, i, km)
6731 IF (a4(1, i, km) .GT. a4(1, i, km1))
THEN 6736 IF (a4(2, i, km) .LT. y4)
THEN 6739 a4(2, i, km) = a4(2, i, km)
6741 IF (a4(1, i, km) .LT. a4(1, i, km1))
THEN 6746 IF (a4(2, i, km) .GT. y5)
THEN 6749 a4(2, i, km) = a4(2, i, km)
6751 dc(i, km) = 0.5*(a4(1, i, km)-a4(2, i, km))
6756 IF (0. .LT. a4(2, i, km))
THEN 6757 a4(2, i, km) = a4(2, i, km)
6761 IF (0. .LT. a4(3, i, km))
THEN 6762 a4(3, i, km) = a4(3, i, km)
6767 ELSE IF (iv .LT. 0)
THEN 6769 IF (a4(1, i, km)*a4(3, i, km) .LE. 0.) a4(3, i, km) = 0.
6774 a4(3, i, k) = a4(2, i, k+1)
6783 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
6787 IF (kord .GE. 7)
THEN 6796 h2(i, k) = 2.*(dc(i, k+1)/delp(i, k+1)-dc(i, k-1)/delp(i, k-1)&
6797 & )/(delp(i, k)+0.5*(delp(i, k-1)+delp(i, k+1)))*delp(i, k)**2
6811 qmp = a4(1, i, k) + pmp
6812 lac = a4(1, i, k) + fac*h2(i, k-1) + dc(i, k)
6813 IF (a4(1, i, k) .GT. qmp)
THEN 6814 IF (qmp .GT. lac)
THEN 6819 ELSE IF (a4(1, i, k) .GT. lac)
THEN 6824 IF (a4(3, i, k) .LT. y8)
THEN 6829 IF (a4(1, i, k) .LT. qmp)
THEN 6830 IF (qmp .LT. lac)
THEN 6835 ELSE IF (a4(1, i, k) .LT. lac)
THEN 6840 IF (x2 .GT. y6)
THEN 6849 qmp = a4(1, i, k) - pmp
6850 lac = a4(1, i, k) + fac*h2(i, k+1) - dc(i, k)
6851 IF (a4(1, i, k) .GT. qmp)
THEN 6852 IF (qmp .GT. lac)
THEN 6857 ELSE IF (a4(1, i, k) .GT. lac)
THEN 6862 IF (a4(2, i, k) .LT. y9)
THEN 6867 IF (a4(1, i, k) .LT. qmp)
THEN 6868 IF (qmp .LT. lac)
THEN 6873 ELSE IF (a4(1, i, k) .LT. lac)
THEN 6878 IF (x3 .GT. y7)
THEN 6886 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
6889 IF (iv .EQ. 0 .AND. kord .GE. 6)
CALL ppm_limiters(dc(i1, k), a4&
6890 & (1, i1, k), it, 2)
6894 IF (0 .LT. lmt)
THEN 6900 IF (2 .GT. lmt)
THEN 6907 IF (kord .NE. 4)
THEN 6909 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
6912 IF (kord .NE. 6)
CALL ppm_limiters(dc(i1, k), a4(1, i1, k), it, &
6918 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
6927 REAL,
INTENT(IN) :: dm(*)
6929 INTEGER,
INTENT(IN) :: itot
6931 INTEGER,
INTENT(IN) :: lmt
6937 REAL,
INTENT(INOUT) :: a4(4, *)
6944 REAL :: da1, da2, a6da
6958 IF (lmt .EQ. 3)
THEN 6960 ELSE IF (lmt .EQ. 0)
THEN 6963 IF (dm(i) .EQ. 0.)
THEN 6968 da1 = a4(3, i) - a4(2, i)
6971 IF (a6da .LT. -da2)
THEN 6972 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
6973 a4(3, i) = a4(2, i) - a4(4, i)
6974 ELSE IF (a6da .GT. da2)
THEN 6975 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
6976 a4(2, i) = a4(3, i) - a4(4, i)
6980 ELSE IF (lmt .EQ. 1)
THEN 6985 IF (qmp .GE. 0.)
THEN 6990 IF (a4(2, i) - a4(1, i) .GE. 0.)
THEN 6991 y1 = a4(2, i) - a4(1, i)
6993 y1 = -(a4(2, i)-a4(1, i))
6995 IF (x1 .GT. y1)
THEN 7000 a4(2, i) = a4(1, i) - sign(min1, qmp)
7001 IF (qmp .GE. 0.)
THEN 7006 IF (a4(3, i) - a4(1, i) .GE. 0.)
THEN 7007 y2 = a4(3, i) - a4(1, i)
7009 y2 = -(a4(3, i)-a4(1, i))
7011 IF (x2 .GT. y2)
THEN 7016 a4(3, i) = a4(1, i) + sign(min2, qmp)
7017 a4(4, i) = 3.*(2.*a4(1, i)-(a4(2, i)+a4(3, i)))
7019 ELSE IF (lmt .EQ. 2)
THEN 7022 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 7023 abs0 = a4(3, i) - a4(2, i)
7025 abs0 = -(a4(3, i)-a4(2, i))
7027 IF (abs0 .LT. -a4(4, i))
THEN 7028 fmin = a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4&
7030 IF (fmin .LT. 0.)
THEN 7031 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
7036 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 7037 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
7038 a4(3, i) = a4(2, i) - a4(4, i)
7040 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
7041 a4(2, i) = a4(3, i) - a4(4, i)
7048 SUBROUTINE moist_cv(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum&
7049 & , liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cvm, t1)
7051 INTEGER,
INTENT(IN) :: is, ie, isd, ied, jsd, jed, km, nwat, j, k
7052 INTEGER,
INTENT(IN) :: sphum, liq_wat, rainwat, ice_wat, snowwat, &
7054 REAL,
DIMENSION(isd:ied, jsd:jed, km, nwat),
INTENT(IN) :: q
7055 REAL,
DIMENSION(is:ie),
INTENT(OUT) :: cvm, qd
7056 REAL,
INTENT(IN),
OPTIONAL :: t1(is:ie)
7058 REAL,
PARAMETER :: t_i0=15.
7059 REAL,
DIMENSION(is:ie) :: qv, ql, qs
7065 IF (
PRESENT(t1))
THEN 7068 IF (0. .LT. q(i, j, k, liq_wat))
THEN 7069 qd(i) = q(i, j, k, liq_wat)
7073 IF (t1(i) .GT.
tice)
THEN 7075 ELSE IF (t1(i) .LT.
tice - t_i0)
THEN 7078 qs(i) = qd(i)*(
tice-t1(i))/t_i0
7080 ql(i) = qd(i) - qs(i)
7081 IF (0. .LT. q(i, j, k, sphum))
THEN 7082 qv(i) = q(i, j, k, sphum)
7086 cvm(i) = (1.-(qv(i)+qd(i)))*
cv_air + qv(i)*
cv_vap + ql(i)*&
7091 IF (0. .LT. q(i, j, k, sphum))
THEN 7092 qv(i) = q(i, j, k, sphum)
7096 IF (0. .LT. q(i, j, k, liq_wat))
THEN 7097 qs(i) = q(i, j, k, liq_wat)
7107 qv(i) = q(i, j, k, sphum)
7108 ql(i) = q(i, j, k, liq_wat)
7109 qs(i) = q(i, j, k, ice_wat)
7110 qd(i) = ql(i) + qs(i)
7117 qv(i) = q(i, j, k, sphum)
7118 qd(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
7123 qv(i) = q(i, j, k, sphum)
7124 ql(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
7125 qs(i) = q(i, j, k, ice_wat) + q(i, j, k, snowwat) + q(i, j, k, &
7127 qd(i) = ql(i) + qs(i)
7138 SUBROUTINE moist_cp(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum&
7139 & , liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cpm, t1)
7141 INTEGER,
INTENT(IN) :: is, ie, isd, ied, jsd, jed, km, nwat, j, k
7142 INTEGER,
INTENT(IN) :: sphum, liq_wat, rainwat, ice_wat, snowwat, &
7144 REAL,
DIMENSION(isd:ied, jsd:jed, km, nwat),
INTENT(IN) :: q
7145 REAL,
DIMENSION(is:ie),
INTENT(OUT) :: cpm, qd
7146 REAL,
INTENT(IN),
OPTIONAL :: t1(is:ie)
7148 REAL,
PARAMETER :: t_i0=15.
7149 REAL,
DIMENSION(is:ie) :: qv, ql, qs
7155 IF (
PRESENT(t1))
THEN 7158 IF (0. .LT. q(i, j, k, liq_wat))
THEN 7159 qd(i) = q(i, j, k, liq_wat)
7163 IF (t1(i) .GT.
tice)
THEN 7165 ELSE IF (t1(i) .LT.
tice - t_i0)
THEN 7168 qs(i) = qd(i)*(
tice-t1(i))/t_i0
7170 ql(i) = qd(i) - qs(i)
7171 IF (0. .LT. q(i, j, k, sphum))
THEN 7172 qv(i) = q(i, j, k, sphum)
7181 IF (0. .LT. q(i, j, k, sphum))
THEN 7182 qv(i) = q(i, j, k, sphum)
7186 IF (0. .LT. q(i, j, k, liq_wat))
THEN 7187 qs(i) = q(i, j, k, liq_wat)
7197 qv(i) = q(i, j, k, sphum)
7198 ql(i) = q(i, j, k, liq_wat)
7199 qs(i) = q(i, j, k, ice_wat)
7200 qd(i) = ql(i) + qs(i)
7207 qv(i) = q(i, j, k, sphum)
7208 qd(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
7214 qv(i) = q(i, j, k, sphum)
7215 ql(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
7216 qs(i) = q(i, j, k, ice_wat) + q(i, j, k, snowwat) + q(i, j, k, &
7218 qd(i) = ql(i) + qs(i)
7237 SUBROUTINE map1_cubic_tlm(km, pe1, pe1_tl, kn, pe2, pe2_tl, q2, q2_tl&
7238 & , i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
7243 INTEGER,
INTENT(IN) :: i1
7245 INTEGER,
INTENT(IN) :: i2
7246 REAL,
INTENT(IN) :: akap
7248 INTEGER,
INTENT(IN) :: t_var
7250 LOGICAL,
INTENT(IN) :: conserv
7252 INTEGER,
INTENT(IN) :: j
7253 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
7255 INTEGER,
INTENT(IN) :: km
7257 INTEGER,
INTENT(IN) :: kn
7259 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
7260 REAL,
INTENT(IN) :: pe1_tl(i1:i2, km+1)
7264 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
7265 REAL,
INTENT(IN) :: pe2_tl(i1:i2, kn+1)
7271 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
7272 REAL,
INTENT(INOUT) :: q2_tl(ibeg:iend, jbeg:jend, kn)
7290 REAL :: qx(i1:i2, km)
7291 REAL :: qx_tl(i1:i2, km)
7292 REAL :: logpl1(i1:i2, km)
7293 REAL :: logpl1_tl(i1:i2, km)
7294 REAL :: logpl2(i1:i2, kn)
7295 REAL :: logpl2_tl(i1:i2, kn)
7296 REAL :: dlogp1(i1:i2, km)
7297 REAL :: dlogp1_tl(i1:i2, km)
7298 REAL :: vsum1(i1:i2)
7299 REAL :: vsum1_tl(i1:i2)
7300 REAL :: vsum2(i1:i2)
7301 REAL :: vsum2_tl(i1:i2)
7302 REAL :: am2, am1, ap0, ap1, p, plp1, plp0, plm1, plm2, dlp0, dlm1, &
7304 REAL :: am2_tl, am1_tl, ap0_tl, ap1_tl, p_tl, plp1_tl, plp0_tl, &
7305 & plm1_tl, plm2_tl, dlp0_tl, dlm1_tl, dlm2_tl
7306 INTEGER :: i, k, lm2, lm1, lp0, lp1
7311 REAL,
DIMENSION(i2-i1+1) :: arg1
7312 REAL,
DIMENSION(i2-i1+1) :: arg1_tl
7313 REAL,
DIMENSION(i1:i2) :: arg2
7314 REAL,
DIMENSION(i1:i2) :: arg2_tl
7323 qx_tl(:, k) = q2_tl(i1:i2, j, k)
7324 qx(:, k) = q2(i1:i2, j, k)
7325 logpl1_tl(:, k) = (pe1_tl(:, k)+pe1_tl(:, k+1))/(pe1(:, k)+pe1(:&
7327 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
7331 logpl2_tl(:, k) = (pe2_tl(:, k)+pe2_tl(:, k+1))/(pe2(:, k)+pe2(:&
7333 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
7337 dlogp1_tl(:, k) = logpl1_tl(:, k+1) - logpl1_tl(:, k)
7338 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7345 qx_tl(:, k) = q2_tl(i1:i2, j, k)
7346 qx(:, k) = q2(i1:i2, j, k)
7347 logpl1_tl(:, k) = (pe1_tl(:, k)+pe1_tl(:, k+1))/(pe1(:, k)+pe1(:&
7349 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
7353 logpl2_tl(:, k) = (pe2_tl(:, k)+pe2_tl(:, k+1))/(pe2(:, k)+pe2(:&
7355 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
7359 dlogp1_tl(:, k) = logpl1_tl(:, k+1) - logpl1_tl(:, k)
7360 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7367 qx_tl(:, k) = q2_tl(i1:i2, j, k)
7368 qx(:, k) = q2(i1:i2, j, k)
7369 arg1_tl(:) =
r2*(pe1_tl(:, k)+pe1_tl(:, k+1))
7370 arg1(:) =
r2*(pe1(:, k)+pe1(:, k+1))
7371 arg2_tl(:) = akap*arg1_tl(:)/arg1(:)
7372 arg2(:) = akap*log(arg1(:))
7373 logpl1_tl(:, k) = arg2_tl(:)*exp(arg2(:))
7374 logpl1(:, k) = exp(arg2(:))
7378 arg1_tl(:) =
r2*(pe2_tl(:, k)+pe2_tl(:, k+1))
7379 arg1(:) =
r2*(pe2(:, k)+pe2(:, k+1))
7380 arg2_tl(:) = akap*arg1_tl(:)/arg1(:)
7381 arg2(:) = akap*log(arg1(:))
7382 logpl2_tl(:, k) = arg2_tl(:)*exp(arg2(:))
7383 logpl2(:, k) = exp(arg2(:))
7387 dlogp1_tl(:, k) = logpl1_tl(:, k+1) - logpl1_tl(:, k)
7388 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7403 vsum1_tl(i) = vsum1_tl(i) + qx_tl(i, k)*(pe1(i, k+1)-pe1(i, k)&
7404 & ) + qx(i, k)*(pe1_tl(i, k+1)-pe1_tl(i, k))
7405 vsum1(i) = vsum1(i) + qx(i, k)*(pe1(i, k+1)-pe1(i, k))
7407 vsum1_tl(i) = (vsum1_tl(i)*(pe1(i, km+1)-pe1(i, 1))-vsum1(i)*(&
7408 & pe1_tl(i, km+1)-pe1_tl(i, 1)))/(pe1(i, km+1)-pe1(i, 1))**2
7409 vsum1(i) = vsum1(i)/(pe1(i, km+1)-pe1(i, 1))
7420 DO WHILE (lp0 .LE. km)
7421 IF (logpl1(i, lp0) .LT. logpl2(i, k))
THEN 7427 IF (lp0 - 1 .LT. 1)
THEN 7432 IF (lp0 .GT. km)
THEN 7439 IF (lm1 .EQ. 1 .AND. lp0 .EQ. 1)
THEN 7440 q2_tl(i, j, k) = qx_tl(i, 1) + (((qx_tl(i, 2)-qx_tl(i, 1))*(&
7441 & logpl2(i, k)-logpl1(i, 1))+(qx(i, 2)-qx(i, 1))*(logpl2_tl(i&
7442 & , k)-logpl1_tl(i, 1)))*(logpl1(i, 2)-logpl1(i, 1))-(qx(i, 2)&
7443 & -qx(i, 1))*(logpl2(i, k)-logpl1(i, 1))*(logpl1_tl(i, 2)-&
7444 & logpl1_tl(i, 1)))/(logpl1(i, 2)-logpl1(i, 1))**2
7445 q2(i, j, k) = qx(i, 1) + (qx(i, 2)-qx(i, 1))*(logpl2(i, k)-&
7446 & logpl1(i, 1))/(logpl1(i, 2)-logpl1(i, 1))
7449 ELSE IF (lm1 .EQ. km .AND. lp0 .EQ. km)
THEN 7450 q2_tl(i, j, k) = qx_tl(i, km) + (((qx_tl(i, km)-qx_tl(i, km-1)&
7451 & )*(logpl2(i, k)-logpl1(i, km))+(qx(i, km)-qx(i, km-1))*(&
7452 & logpl2_tl(i, k)-logpl1_tl(i, km)))*(logpl1(i, km)-logpl1(i, &
7453 & km-1))-(qx(i, km)-qx(i, km-1))*(logpl2(i, k)-logpl1(i, km))*&
7454 & (logpl1_tl(i, km)-logpl1_tl(i, km-1)))/(logpl1(i, km)-logpl1&
7456 q2(i, j, k) = qx(i, km) + (qx(i, km)-qx(i, km-1))*(logpl2(i, k&
7457 & )-logpl1(i, km))/(logpl1(i, km)-logpl1(i, km-1))
7460 ELSE IF (lm1 .EQ. 1 .OR. lp0 .EQ. km)
THEN 7461 q2_tl(i, j, k) = qx_tl(i, lp0) + (((qx_tl(i, lm1)-qx_tl(i, lp0&
7462 & ))*(logpl2(i, k)-logpl1(i, lp0))+(qx(i, lm1)-qx(i, lp0))*(&
7463 & logpl2_tl(i, k)-logpl1_tl(i, lp0)))*(logpl1(i, lm1)-logpl1(i&
7464 & , lp0))-(qx(i, lm1)-qx(i, lp0))*(logpl2(i, k)-logpl1(i, lp0)&
7465 & )*(logpl1_tl(i, lm1)-logpl1_tl(i, lp0)))/(logpl1(i, lm1)-&
7466 & logpl1(i, lp0))**2
7467 q2(i, j, k) = qx(i, lp0) + (qx(i, lm1)-qx(i, lp0))*(logpl2(i, &
7468 & k)-logpl1(i, lp0))/(logpl1(i, lm1)-logpl1(i, lp0))
7474 p_tl = logpl2_tl(i, k)
7476 plp1_tl = logpl1_tl(i, lp1)
7477 plp1 = logpl1(i, lp1)
7478 plp0_tl = logpl1_tl(i, lp0)
7479 plp0 = logpl1(i, lp0)
7480 plm1_tl = logpl1_tl(i, lm1)
7481 plm1 = logpl1(i, lm1)
7482 plm2_tl = logpl1_tl(i, lm2)
7483 plm2 = logpl1(i, lm2)
7484 dlp0_tl = dlogp1_tl(i, lp0)
7485 dlp0 = dlogp1(i, lp0)
7486 dlm1_tl = dlogp1_tl(i, lm1)
7487 dlm1 = dlogp1(i, lm1)
7488 dlm2_tl = dlogp1_tl(i, lm2)
7489 dlm2 = dlogp1(i, lm2)
7490 ap1_tl = ((((p_tl-plp0_tl)*(p-plm1)+(p-plp0)*(p_tl-plm1_tl))*(&
7491 & p-plm2)+(p-plp0)*(p-plm1)*(p_tl-plm2_tl))*dlp0*(dlp0+dlm1)*(&
7492 & dlp0+dlm1+dlm2)-(p-plp0)*(p-plm1)*(p-plm2)*((dlp0_tl*(dlp0+&
7493 & dlm1)+dlp0*(dlp0_tl+dlm1_tl))*(dlp0+dlm1+dlm2)+dlp0*(dlp0+&
7494 & dlm1)*(dlp0_tl+dlm1_tl+dlm2_tl)))/(dlp0*(dlp0+dlm1)*(dlp0+&
7496 ap1 = (p-plp0)*(p-plm1)*(p-plm2)/(dlp0*(dlp0+dlm1)*(dlp0+dlm1+&
7498 ap0_tl = ((((plp1_tl-p_tl)*(p-plm1)+(plp1-p)*(p_tl-plm1_tl))*(&
7499 & p-plm2)+(plp1-p)*(p-plm1)*(p_tl-plm2_tl))*dlp0*dlm1*(dlm1+&
7500 & dlm2)-(plp1-p)*(p-plm1)*(p-plm2)*((dlp0_tl*dlm1+dlp0*dlm1_tl&
7501 & )*(dlm1+dlm2)+dlp0*dlm1*(dlm1_tl+dlm2_tl)))/(dlp0*dlm1*(dlm1&
7503 ap0 = (plp1-p)*(p-plm1)*(p-plm2)/(dlp0*dlm1*(dlm1+dlm2))
7504 am1_tl = ((((plp1_tl-p_tl)*(plp0-p)+(plp1-p)*(plp0_tl-p_tl))*(&
7505 & p-plm2)+(plp1-p)*(plp0-p)*(p_tl-plm2_tl))*dlm1*dlm2*(dlp0+&
7506 & dlm1)-(plp1-p)*(plp0-p)*(p-plm2)*((dlm1_tl*dlm2+dlm1*dlm2_tl&
7507 & )*(dlp0+dlm1)+dlm1*dlm2*(dlp0_tl+dlm1_tl)))/(dlm1*dlm2*(dlp0&
7509 am1 = (plp1-p)*(plp0-p)*(p-plm2)/(dlm1*dlm2*(dlp0+dlm1))
7510 am2_tl = ((((plp1_tl-p_tl)*(plp0-p)+(plp1-p)*(plp0_tl-p_tl))*(&
7511 & plm1-p)+(plp1-p)*(plp0-p)*(plm1_tl-p_tl))*dlm2*(dlm1+dlm2)*(&
7512 & dlp0+dlm1+dlm2)-(plp1-p)*(plp0-p)*(plm1-p)*((dlm2_tl*(dlm1+&
7513 & dlm2)+dlm2*(dlm1_tl+dlm2_tl))*(dlp0+dlm1+dlm2)+dlm2*(dlm1+&
7514 & dlm2)*(dlp0_tl+dlm1_tl+dlm2_tl)))/(dlm2*(dlm1+dlm2)*(dlp0+&
7516 am2 = (plp1-p)*(plp0-p)*(plm1-p)/(dlm2*(dlm1+dlm2)*(dlp0+dlm1+&
7518 q2_tl(i, j, k) = ap1_tl*qx(i, lp1) + ap1*qx_tl(i, lp1) + &
7519 & ap0_tl*qx(i, lp0) + ap0*qx_tl(i, lp0) + am1_tl*qx(i, lm1) + &
7520 & am1*qx_tl(i, lm1) + am2_tl*qx(i, lm2) + am2*qx_tl(i, lm2)
7521 q2(i, j, k) = ap1*qx(i, lp1) + ap0*qx(i, lp0) + am1*qx(i, lm1)&
7533 vsum2_tl(i) = vsum2_tl(i) + q2_tl(i, j, k)*(pe2(i, k+1)-pe2(i&
7534 & , k)) + q2(i, j, k)*(pe2_tl(i, k+1)-pe2_tl(i, k))
7535 vsum2(i) = vsum2(i) + q2(i, j, k)*(pe2(i, k+1)-pe2(i, k))
7537 vsum2_tl(i) = (vsum2_tl(i)*(pe2(i, kn+1)-pe2(i, 1))-vsum2(i)*(&
7538 & pe2_tl(i, kn+1)-pe2_tl(i, 1)))/(pe2(i, kn+1)-pe2(i, 1))**2
7539 vsum2(i) = vsum2(i)/(pe2(i, kn+1)-pe2(i, 1))
7545 q2_tl(i, j, k) = q2_tl(i, j, k) + vsum1_tl(i) - vsum2_tl(i)
7546 q2(i, j, k) = q2(i, j, k) + vsum1(i) - vsum2(i)
7558 SUBROUTINE map1_cubic(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend, &
7559 & jbeg, jend, akap, t_var, conserv)
7564 INTEGER,
INTENT(IN) :: i1
7566 INTEGER,
INTENT(IN) :: i2
7567 REAL,
INTENT(IN) :: akap
7569 INTEGER,
INTENT(IN) :: t_var
7571 LOGICAL,
INTENT(IN) :: conserv
7573 INTEGER,
INTENT(IN) :: j
7574 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
7576 INTEGER,
INTENT(IN) :: km
7578 INTEGER,
INTENT(IN) :: kn
7580 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
7584 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
7590 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
7608 REAL :: qx(i1:i2, km)
7609 REAL :: logpl1(i1:i2, km)
7610 REAL :: logpl2(i1:i2, kn)
7611 REAL :: dlogp1(i1:i2, km)
7612 REAL :: vsum1(i1:i2)
7613 REAL :: vsum2(i1:i2)
7614 REAL :: am2, am1, ap0, ap1, p, plp1, plp0, plm1, plm2, dlp0, dlm1, &
7616 INTEGER :: i, k, lm2, lm1, lp0, lp1
7621 REAL,
DIMENSION(i2-i1+1) :: arg1
7622 REAL,
DIMENSION(i1:i2) :: arg2
7629 qx(:, k) = q2(i1:i2, j, k)
7630 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
7633 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
7636 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7641 qx(:, k) = q2(i1:i2, j, k)
7642 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
7645 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
7648 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7653 qx(:, k) = q2(i1:i2, j, k)
7654 arg1(:) =
r2*(pe1(:, k)+pe1(:, k+1))
7655 arg2(:) = akap*log(arg1(:))
7656 logpl1(:, k) = exp(arg2(:))
7659 arg1(:) =
r2*(pe2(:, k)+pe2(:, k+1))
7660 arg2(:) = akap*log(arg1(:))
7661 logpl2(:, k) = exp(arg2(:))
7664 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
7673 vsum1(i) = vsum1(i) + qx(i, k)*(pe1(i, k+1)-pe1(i, k))
7675 vsum1(i) = vsum1(i)/(pe1(i, km+1)-pe1(i, 1))
7684 DO WHILE (lp0 .LE. km)
7685 IF (logpl1(i, lp0) .LT. logpl2(i, k))
THEN 7691 100
IF (lp0 - 1 .LT. 1)
THEN 7696 IF (lp0 .GT. km)
THEN 7703 IF (lm1 .EQ. 1 .AND. lp0 .EQ. 1)
THEN 7704 q2(i, j, k) = qx(i, 1) + (qx(i, 2)-qx(i, 1))*(logpl2(i, k)-&
7705 & logpl1(i, 1))/(logpl1(i, 2)-logpl1(i, 1))
7708 ELSE IF (lm1 .EQ. km .AND. lp0 .EQ. km)
THEN 7709 q2(i, j, k) = qx(i, km) + (qx(i, km)-qx(i, km-1))*(logpl2(i, k&
7710 & )-logpl1(i, km))/(logpl1(i, km)-logpl1(i, km-1))
7713 ELSE IF (lm1 .EQ. 1 .OR. lp0 .EQ. km)
THEN 7714 q2(i, j, k) = qx(i, lp0) + (qx(i, lm1)-qx(i, lp0))*(logpl2(i, &
7715 & k)-logpl1(i, lp0))/(logpl1(i, lm1)-logpl1(i, lp0))
7722 plp1 = logpl1(i, lp1)
7723 plp0 = logpl1(i, lp0)
7724 plm1 = logpl1(i, lm1)
7725 plm2 = logpl1(i, lm2)
7726 dlp0 = dlogp1(i, lp0)
7727 dlm1 = dlogp1(i, lm1)
7728 dlm2 = dlogp1(i, lm2)
7729 ap1 = (p-plp0)*(p-plm1)*(p-plm2)/(dlp0*(dlp0+dlm1)*(dlp0+dlm1+&
7731 ap0 = (plp1-p)*(p-plm1)*(p-plm2)/(dlp0*dlm1*(dlm1+dlm2))
7732 am1 = (plp1-p)*(plp0-p)*(p-plm2)/(dlm1*dlm2*(dlp0+dlm1))
7733 am2 = (plp1-p)*(plp0-p)*(plm1-p)/(dlm2*(dlm1+dlm2)*(dlp0+dlm1+&
7735 q2(i, j, k) = ap1*qx(i, lp1) + ap0*qx(i, lp0) + am1*qx(i, lm1)&
7746 vsum2(i) = vsum2(i) + q2(i, j, k)*(pe2(i, k+1)-pe2(i, k))
7748 vsum2(i) = vsum2(i)/(pe2(i, kn+1)-pe2(i, 1))
7754 q2(i, j, k) = q2(i, j, k) + vsum1(i) - vsum2(i)
7765 SUBROUTINE map_scalar_tlm(km, pe1, pe1_tl, qs, kn, pe2, pe2_tl, q2&
7766 & , q2_tl, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
7770 INTEGER,
INTENT(IN) :: i1
7772 INTEGER,
INTENT(IN) :: i2
7774 INTEGER,
INTENT(IN) :: iv
7777 INTEGER,
INTENT(IN) :: kord
7779 INTEGER,
INTENT(IN) :: j
7780 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
7782 INTEGER,
INTENT(IN) :: km
7784 INTEGER,
INTENT(IN) :: kn
7786 REAL,
INTENT(IN) :: qs(i1:i2)
7788 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
7789 REAL,
INTENT(IN) :: pe1_tl(i1:i2, km+1)
7793 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
7794 REAL,
INTENT(IN) :: pe2_tl(i1:i2, kn+1)
7800 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
7801 REAL,
INTENT(INOUT) :: q2_tl(ibeg:iend, jbeg:jend, kn)
7802 REAL,
INTENT(IN) :: q_min
7810 REAL :: dp1(i1:i2, km)
7811 REAL :: dp1_tl(i1:i2, km)
7812 REAL :: q4(4, i1:i2, km)
7813 REAL :: q4_tl(4, i1:i2, km)
7814 REAL :: pl, pr, qsum, dp, esl
7815 REAL :: pl_tl, pr_tl, qsum_tl, dp_tl, esl_tl
7816 INTEGER :: i, k, l, m, k0
7821 dp1_tl(i, k) = pe1_tl(i, k+1) - pe1_tl(i, k)
7822 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
7823 q4_tl(1, i, k) = q2_tl(i, j, k)
7824 q4(1, i, k) = q2(i, j, k)
7828 IF (kord .GT. 7)
THEN 7830 & , iv, kord, q_min)
7842 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
7846 100 pl_tl = ((pe2_tl(i, k)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k)-pe1(i&
7847 & , l))*dp1_tl(i, l))/dp1(i, l)**2
7848 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
7849 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 7851 pr_tl = ((pe2_tl(i, k+1)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k+1)-&
7852 & pe1(i, l))*dp1_tl(i, l))/dp1(i, l)**2
7853 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
7854 q2_tl(i, j, k) = q4_tl(2, i, l) + 0.5*((q4_tl(4, i, l)+q4_tl(3&
7855 & , i, l)-q4_tl(2, i, l))*(pr+pl)+(q4(4, i, l)+q4(3, i, l)-q4(&
7856 & 2, i, l))*(pr_tl+pl_tl)) -
r3*(q4_tl(4, i, l)*(pr*(pr+pl)+pl&
7857 & **2)+q4(4, i, l)*(pr_tl*(pr+pl)+pr*(pr_tl+pl_tl)+2*pl*pl_tl)&
7859 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
7860 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
7865 qsum_tl = (pe1_tl(i, l+1)-pe2_tl(i, k))*(q4(2, i, l)+0.5*(q4(4&
7866 & , i, l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.&
7867 & +pl*(1.+pl)))) + (pe1(i, l+1)-pe2(i, k))*(q4_tl(2, i, l)+0.5&
7868 & *((q4_tl(4, i, l)+q4_tl(3, i, l)-q4_tl(2, i, l))*(1.+pl)+(q4&
7869 & (4, i, l)+q4(3, i, l)-q4(2, i, l))*pl_tl)-
r3*(q4_tl(4, i, l)&
7870 & *(1.+pl*(1.+pl))+q4(4, i, l)*(pl_tl*(1.+pl)+pl*pl_tl)))
7871 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
7872 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
7876 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 7878 qsum_tl = qsum_tl + dp1_tl(i, m)*q4(1, i, m) + dp1(i, m)*&
7880 qsum = qsum + dp1(i, m)*q4(1, i, m)
7886 110 dp_tl = pe2_tl(i, k+1) - pe1_tl(i, m)
7887 dp = pe2(i, k+1) - pe1(i, m)
7888 esl_tl = (dp_tl*dp1(i, m)-dp*dp1_tl(i, m))/dp1(i, m)**2
7890 qsum_tl = qsum_tl + dp_tl*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4&
7891 & (2, i, m)+q4(4, i, m)*(1.-
r23*esl))) + dp*(q4_tl(2, i, m)+&
7892 & 0.5*(esl_tl*(q4(3, i, m)-q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl&
7893 & ))+esl*(q4_tl(3, i, m)-q4_tl(2, i, m)+q4_tl(4, i, m)*(1.-
r23&
7894 & *esl)-q4(4, i, m)*
r23*esl_tl)))
7895 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
7896 & +q4(4, i, m)*(1.-
r23*esl)))
7899 123 q2_tl(i, j, k) = (qsum_tl*(pe2(i, k+1)-pe2(i, k))-qsum*(pe2_tl(i&
7900 & , k+1)-pe2_tl(i, k)))/(pe2(i, k+1)-pe2(i, k))**2
7901 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
7909 SUBROUTINE map1_ppm_tlm(km, pe1, pe1_tl, qs, qs_tl, kn, pe2, pe2_tl&
7910 & , q2, q2_tl, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
7913 INTEGER,
INTENT(IN) :: i1
7915 INTEGER,
INTENT(IN) :: i2
7917 INTEGER,
INTENT(IN) :: iv
7920 INTEGER,
INTENT(IN) :: kord
7922 INTEGER,
INTENT(IN) :: j
7923 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
7925 INTEGER,
INTENT(IN) :: km
7927 INTEGER,
INTENT(IN) :: kn
7929 REAL,
INTENT(IN) :: qs(i1:i2)
7930 REAL,
INTENT(IN) :: qs_tl(i1:i2)
7932 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
7933 REAL,
INTENT(IN) :: pe1_tl(i1:i2, km+1)
7937 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
7938 REAL,
INTENT(IN) :: pe2_tl(i1:i2, kn+1)
7944 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
7945 REAL,
INTENT(INOUT) :: q2_tl(ibeg:iend, jbeg:jend, kn)
7953 REAL :: dp1(i1:i2, km)
7954 REAL :: dp1_tl(i1:i2, km)
7955 REAL :: q4(4, i1:i2, km)
7956 REAL :: q4_tl(4, i1:i2, km)
7957 REAL :: pl, pr, qsum, dp, esl
7958 REAL :: pl_tl, pr_tl, qsum_tl, dp_tl, esl_tl
7959 INTEGER :: i, k, l, m, k0
7964 dp1_tl(i, k) = pe1_tl(i, k+1) - pe1_tl(i, k)
7965 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
7966 q4_tl(1, i, k) = q2_tl(i, j, k)
7967 q4(1, i, k) = q2(i, j, k)
7971 IF (kord .GT. 7)
THEN 7985 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
7989 100 pl_tl = ((pe2_tl(i, k)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k)-pe1(i&
7990 & , l))*dp1_tl(i, l))/dp1(i, l)**2
7991 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
7992 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 7994 pr_tl = ((pe2_tl(i, k+1)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k+1)-&
7995 & pe1(i, l))*dp1_tl(i, l))/dp1(i, l)**2
7996 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
7997 q2_tl(i, j, k) = q4_tl(2, i, l) + 0.5*((q4_tl(4, i, l)+q4_tl(3&
7998 & , i, l)-q4_tl(2, i, l))*(pr+pl)+(q4(4, i, l)+q4(3, i, l)-q4(&
7999 & 2, i, l))*(pr_tl+pl_tl)) -
r3*(q4_tl(4, i, l)*(pr*(pr+pl)+pl&
8000 & **2)+q4(4, i, l)*(pr_tl*(pr+pl)+pr*(pr_tl+pl_tl)+2*pl*pl_tl)&
8002 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
8003 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
8008 qsum_tl = (pe1_tl(i, l+1)-pe2_tl(i, k))*(q4(2, i, l)+0.5*(q4(4&
8009 & , i, l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.&
8010 & +pl*(1.+pl)))) + (pe1(i, l+1)-pe2(i, k))*(q4_tl(2, i, l)+0.5&
8011 & *((q4_tl(4, i, l)+q4_tl(3, i, l)-q4_tl(2, i, l))*(1.+pl)+(q4&
8012 & (4, i, l)+q4(3, i, l)-q4(2, i, l))*pl_tl)-
r3*(q4_tl(4, i, l)&
8013 & *(1.+pl*(1.+pl))+q4(4, i, l)*(pl_tl*(1.+pl)+pl*pl_tl)))
8014 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
8015 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
8019 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 8021 qsum_tl = qsum_tl + dp1_tl(i, m)*q4(1, i, m) + dp1(i, m)*&
8023 qsum = qsum + dp1(i, m)*q4(1, i, m)
8029 110 dp_tl = pe2_tl(i, k+1) - pe1_tl(i, m)
8030 dp = pe2(i, k+1) - pe1(i, m)
8031 esl_tl = (dp_tl*dp1(i, m)-dp*dp1_tl(i, m))/dp1(i, m)**2
8033 qsum_tl = qsum_tl + dp_tl*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4&
8034 & (2, i, m)+q4(4, i, m)*(1.-
r23*esl))) + dp*(q4_tl(2, i, m)+&
8035 & 0.5*(esl_tl*(q4(3, i, m)-q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl&
8036 & ))+esl*(q4_tl(3, i, m)-q4_tl(2, i, m)+q4_tl(4, i, m)*(1.-
r23&
8037 & *esl)-q4(4, i, m)*
r23*esl_tl)))
8038 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
8039 & +q4(4, i, m)*(1.-
r23*esl)))
8042 123 q2_tl(i, j, k) = (qsum_tl*(pe2(i, k+1)-pe2(i, k))-qsum*(pe2_tl(i&
8043 & , k+1)-pe2_tl(i, k)))/(pe2(i, k+1)-pe2(i, k))**2
8044 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
8052 & q1_tl, dp2, dp2_tl, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill&
8057 INTEGER,
INTENT(IN) :: km
8058 INTEGER,
INTENT(IN) :: j, nq, i1, i2
8059 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
8060 INTEGER,
INTENT(IN) :: kord(nq)
8062 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
8063 REAL,
INTENT(IN) :: pe1_tl(i1:i2, km+1)
8067 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
8068 REAL,
INTENT(IN) :: pe2_tl(i1:i2, km+1)
8071 REAL,
INTENT(IN) :: dp2(i1:i2, km)
8072 REAL,
INTENT(IN) :: dp2_tl(i1:i2, km)
8073 REAL,
INTENT(IN) :: q_min
8074 LOGICAL,
INTENT(IN) :: fill
8076 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
8077 REAL,
INTENT(INOUT) :: q1_tl(isd:ied, jsd:jed, km, nq)
8079 REAL :: q4(4, i1:i2, km, nq)
8080 REAL :: q4_tl(4, i1:i2, km, nq)
8082 REAL :: q2(i1:i2, km, nq)
8083 REAL :: q2_tl(i1:i2, km, nq)
8086 REAL :: dp1(i1:i2, km)
8087 REAL :: dp1_tl(i1:i2, km)
8089 REAL :: pl, pr, dp, esl, fac1, fac2
8090 REAL :: pl_tl, pr_tl, dp_tl, esl_tl, fac1_tl, fac2_tl
8091 INTEGER :: i, k, l, m, k0, iq
8095 dp1_tl(i, k) = pe1_tl(i, k+1) - pe1_tl(i, k)
8096 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
8103 q4_tl(1, i, k, iq) = q1_tl(i, j, k, iq)
8104 q4(1, i, k, iq) = q1(i, j, k, iq)
8108 & , i1:i2, 1:km, iq), dp1, dp1_tl, km, i1, i2, &
8109 & 0, kord(iq), q_min)
8119 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
8123 110 pl_tl = ((pe2_tl(i, k)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k)-pe1(i&
8124 & , l))*dp1_tl(i, l))/dp1(i, l)**2
8125 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
8126 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 8128 pr_tl = ((pe2_tl(i, k+1)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k+1)-&
8129 & pe1(i, l))*dp1_tl(i, l))/dp1(i, l)**2
8130 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
8131 fac1_tl = pr_tl + pl_tl
8133 fac2_tl =
r3*(pr_tl*fac1+pr*fac1_tl+pl_tl*pl+pl*pl_tl)
8134 fac2 =
r3*(pr*fac1+pl*pl)
8135 fac1_tl = 0.5*fac1_tl
8138 q2_tl(i, k, iq) = q4_tl(2, i, l, iq) + (q4_tl(4, i, l, iq)+&
8139 & q4_tl(3, i, l, iq)-q4_tl(2, i, l, iq))*fac1 + (q4(4, i, l&
8140 & , iq)+q4(3, i, l, iq)-q4(2, i, l, iq))*fac1_tl - q4_tl(4, &
8141 & i, l, iq)*fac2 - q4(4, i, l, iq)*fac2_tl
8142 q2(i, k, iq) = q4(2, i, l, iq) + (q4(4, i, l, iq)+q4(3, i, l&
8143 & , iq)-q4(2, i, l, iq))*fac1 - q4(4, i, l, iq)*fac2
8149 dp_tl = pe1_tl(i, l+1) - pe2_tl(i, k)
8150 dp = pe1(i, l+1) - pe2(i, k)
8153 fac2_tl =
r3*(pl_tl*fac1+pl*fac1_tl)
8154 fac2 =
r3*(1.+pl*fac1)
8155 fac1_tl = 0.5*fac1_tl
8158 qsum_tl(iq) = dp_tl*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, &
8159 & i, l, iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2) + dp&
8160 & *(q4_tl(2, i, l, iq)+(q4_tl(4, i, l, iq)+q4_tl(3, i, l, iq&
8161 & )-q4_tl(2, i, l, iq))*fac1+(q4(4, i, l, iq)+q4(3, i, l, iq&
8162 & )-q4(2, i, l, iq))*fac1_tl-q4_tl(4, i, l, iq)*fac2-q4(4, i&
8164 qsum(iq) = dp*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, i, l, &
8165 & iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2)
8169 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 8172 qsum_tl(iq) = qsum_tl(iq) + dp1_tl(i, m)*q4(1, i, m, iq)&
8173 & + dp1(i, m)*q4_tl(1, i, m, iq)
8174 qsum(iq) = qsum(iq) + dp1(i, m)*q4(1, i, m, iq)
8181 120 dp_tl = pe2_tl(i, k+1) - pe1_tl(i, m)
8182 dp = pe2(i, k+1) - pe1(i, m)
8183 esl_tl = (dp_tl*dp1(i, m)-dp*dp1_tl(i, m))/dp1(i, m)**2
8185 fac1_tl = 0.5*esl_tl
8187 fac2_tl = -(
r23*esl_tl)
8190 qsum_tl(iq) = qsum_tl(iq) + dp_tl*(q4(2, i, m, iq)+fac1*(q4(&
8191 & 3, i, m, iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2)) + dp*(&
8192 & q4_tl(2, i, m, iq)+fac1_tl*(q4(3, i, m, iq)-q4(2, i, m, iq&
8193 & )+q4(4, i, m, iq)*fac2)+fac1*(q4_tl(3, i, m, iq)-q4_tl(2, &
8194 & i, m, iq)+q4_tl(4, i, m, iq)*fac2+q4(4, i, m, iq)*fac2_tl)&
8196 qsum(iq) = qsum(iq) + dp*(q4(2, i, m, iq)+fac1*(q4(3, i, m, &
8197 & iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2))
8202 q2_tl(i, k, iq) = (qsum_tl(iq)*dp2(i, k)-qsum(iq)*dp2_tl(i, k)&
8204 q2(i, k, iq) = qsum(iq)/dp2(i, k)
8208 IF (fill)
CALL fillz(i2 - i1 + 1, km, nq, q2, dp2)
8213 q1_tl(i, j, k, iq) = q2_tl(i, k, iq)
8214 q1(i, j, k, iq) = q2(i, k, iq)
8222 SUBROUTINE map1_q2_tlm(km, pe1, pe1_tl, q1, q1_tl, kn, pe2, pe2_tl&
8223 & , q2, q2_tl, dp2, dp2_tl, i1, i2, iv, kord, j, ibeg, iend, jbeg, &
8227 INTEGER,
INTENT(IN) :: j
8228 INTEGER,
INTENT(IN) :: i1, i2
8229 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
8231 INTEGER,
INTENT(IN) :: iv
8232 INTEGER,
INTENT(IN) :: kord
8234 INTEGER,
INTENT(IN) :: km
8236 INTEGER,
INTENT(IN) :: kn
8238 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
8239 REAL,
INTENT(IN) :: pe1_tl(i1:i2, km+1)
8243 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
8244 REAL,
INTENT(IN) :: pe2_tl(i1:i2, kn+1)
8248 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
8249 REAL,
INTENT(IN) :: q1_tl(ibeg:iend, jbeg:jend, km)
8250 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
8251 REAL,
INTENT(IN) :: dp2_tl(i1:i2, kn)
8252 REAL,
INTENT(IN) :: q_min
8255 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
8256 REAL,
INTENT(INOUT) :: q2_tl(i1:i2, kn)
8259 REAL :: dp1(i1:i2, km)
8260 REAL :: dp1_tl(i1:i2, km)
8261 REAL :: q4(4, i1:i2, km)
8262 REAL :: q4_tl(4, i1:i2, km)
8263 REAL :: pl, pr, qsum, dp, esl
8264 REAL :: pl_tl, pr_tl, qsum_tl, dp_tl, esl_tl
8265 INTEGER :: i, k, l, m, k0
8270 dp1_tl(i, k) = pe1_tl(i, k+1) - pe1_tl(i, k)
8271 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
8272 q4_tl(1, i, k) = q1_tl(i, j, k)
8273 q4(1, i, k) = q1(i, j, k)
8277 IF (kord .GT. 7)
THEN 8279 & , iv, kord, q_min)
8292 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
8296 110 pl_tl = ((pe2_tl(i, k)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k)-pe1(i&
8297 & , l))*dp1_tl(i, l))/dp1(i, l)**2
8298 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
8299 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 8301 pr_tl = ((pe2_tl(i, k+1)-pe1_tl(i, l))*dp1(i, l)-(pe2(i, k+1)-&
8302 & pe1(i, l))*dp1_tl(i, l))/dp1(i, l)**2
8303 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
8304 q2_tl(i, k) = q4_tl(2, i, l) + 0.5*((q4_tl(4, i, l)+q4_tl(3, i&
8305 & , l)-q4_tl(2, i, l))*(pr+pl)+(q4(4, i, l)+q4(3, i, l)-q4(2, &
8306 & i, l))*(pr_tl+pl_tl)) -
r3*(q4_tl(4, i, l)*(pr*(pr+pl)+pl**2&
8307 & )+q4(4, i, l)*(pr_tl*(pr+pl)+pr*(pr_tl+pl_tl)+2*pl*pl_tl))
8308 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i&
8309 & , l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
8314 qsum_tl = (pe1_tl(i, l+1)-pe2_tl(i, k))*(q4(2, i, l)+0.5*(q4(4&
8315 & , i, l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.&
8316 & +pl*(1.+pl)))) + (pe1(i, l+1)-pe2(i, k))*(q4_tl(2, i, l)+0.5&
8317 & *((q4_tl(4, i, l)+q4_tl(3, i, l)-q4_tl(2, i, l))*(1.+pl)+(q4&
8318 & (4, i, l)+q4(3, i, l)-q4(2, i, l))*pl_tl)-
r3*(q4_tl(4, i, l)&
8319 & *(1.+pl*(1.+pl))+q4(4, i, l)*(pl_tl*(1.+pl)+pl*pl_tl)))
8320 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
8321 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
8325 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 8327 qsum_tl = qsum_tl + dp1_tl(i, m)*q4(1, i, m) + dp1(i, m)*&
8329 qsum = qsum + dp1(i, m)*q4(1, i, m)
8335 120 dp_tl = pe2_tl(i, k+1) - pe1_tl(i, m)
8336 dp = pe2(i, k+1) - pe1(i, m)
8337 esl_tl = (dp_tl*dp1(i, m)-dp*dp1_tl(i, m))/dp1(i, m)**2
8339 qsum_tl = qsum_tl + dp_tl*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4&
8340 & (2, i, m)+q4(4, i, m)*(1.-
r23*esl))) + dp*(q4_tl(2, i, m)+&
8341 & 0.5*(esl_tl*(q4(3, i, m)-q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl&
8342 & ))+esl*(q4_tl(3, i, m)-q4_tl(2, i, m)+q4_tl(4, i, m)*(1.-
r23&
8343 & *esl)-q4(4, i, m)*
r23*esl_tl)))
8344 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
8345 & +q4(4, i, m)*(1.-
r23*esl)))
8348 123 q2_tl(i, k) = (qsum_tl*dp2(i, k)-qsum*dp2_tl(i, k))/dp2(i, k)**2
8349 q2(i, k) = qsum/dp2(i, k)
8357 & , i2, iv, kord, qmin)
8361 INTEGER,
INTENT(IN) :: i1, i2
8363 INTEGER,
INTENT(IN) :: km
8365 INTEGER,
INTENT(IN) :: iv
8368 INTEGER,
INTENT(IN) :: kord
8369 REAL,
INTENT(IN) :: qs(i1:i2)
8371 REAL,
INTENT(IN) :: delp(i1:i2, km)
8372 REAL,
INTENT(IN) :: delp_tl(i1:i2, km)
8374 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
8375 REAL,
INTENT(INOUT) :: a4_tl(4, i1:i2, km)
8376 REAL,
INTENT(IN) :: qmin
8378 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
8379 REAL :: gam(i1:i2, km)
8380 REAL :: gam_tl(i1:i2, km)
8381 REAL :: q(i1:i2, km+1)
8382 REAL :: q_tl(i1:i2, km+1)
8384 REAL :: d4_tl(i1:i2)
8385 REAL :: bet, a_bot, grat
8386 REAL :: bet_tl, a_bot_tl, grat_tl
8387 REAL :: pmp_1, lac_1, pmp_2, lac_2
8391 IF (iv .EQ. -2)
THEN 8395 q_tl(i, 1) = 1.5*a4_tl(1, i, 1)
8396 q(i, 1) = 1.5*a4(1, i, 1)
8401 grat_tl = (delp_tl(i, k-1)*delp(i, k)-delp(i, k-1)*delp_tl(i, &
8403 grat = delp(i, k-1)/delp(i, k)
8404 bet_tl = 2*grat_tl - gam_tl(i, k)
8405 bet = 2. + grat + grat - gam(i, k)
8406 q_tl(i, k) = ((3.*(a4_tl(1, i, k-1)+a4_tl(1, i, k))-q_tl(i, k-&
8407 & 1))*bet-(3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*bet_tl)/&
8409 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
8410 gam_tl(i, k+1) = (grat_tl*bet-grat*bet_tl)/bet**2
8411 gam(i, k+1) = grat/bet
8415 grat_tl = (delp_tl(i, km-1)*delp(i, km)-delp(i, km-1)*delp_tl(i&
8416 & , km))/delp(i, km)**2
8417 grat = delp(i, km-1)/delp(i, km)
8418 q_tl(i, km) = ((3.*(a4_tl(1, i, km-1)+a4_tl(1, i, km))-qs(i)*&
8419 & grat_tl-q_tl(i, km-1))*(2.+grat+grat-gam(i, km))-(3.*(a4(1, i&
8420 & , km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-1))*(2*grat_tl-gam_tl&
8421 & (i, km)))/(2.+grat+grat-gam(i, km))**2
8422 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
8423 & 1))/(2.+grat+grat-gam(i, km))
8429 q_tl(i, k) = q_tl(i, k) - gam_tl(i, k+1)*q(i, k+1) - gam(i, k+&
8431 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
8439 grat_tl = (delp_tl(i, 2)*delp(i, 1)-delp(i, 2)*delp_tl(i, 1))/&
8441 grat = delp(i, 2)/delp(i, 1)
8442 bet_tl = grat_tl*(grat+0.5) + grat*grat_tl
8443 bet = grat*(grat+0.5)
8444 q_tl(i, 1) = (((2*grat_tl*(grat+1.)+(grat+grat)*grat_tl)*a4(1, i&
8445 & , 1)+(grat+grat)*(grat+1.)*a4_tl(1, i, 1)+a4_tl(1, i, 2))*bet-&
8446 & ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))*bet_tl)/bet**2
8447 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
8448 gam_tl(i, 1) = ((grat_tl*(grat+1.5)+grat*grat_tl)*bet-(1.+grat*(&
8449 & grat+1.5))*bet_tl)/bet**2
8450 gam(i, 1) = (1.+grat*(grat+1.5))/bet
8455 d4_tl(i) = (delp_tl(i, k-1)*delp(i, k)-delp(i, k-1)*delp_tl(i&
8456 & , k))/delp(i, k)**2
8457 d4(i) = delp(i, k-1)/delp(i, k)
8458 bet_tl = 2*d4_tl(i) - gam_tl(i, k-1)
8459 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
8460 q_tl(i, k) = ((3.*(a4_tl(1, i, k-1)+d4_tl(i)*a4(1, i, k)+d4(i)&
8461 & *a4_tl(1, i, k))-q_tl(i, k-1))*bet-(3.*(a4(1, i, k-1)+d4(i)*&
8462 & a4(1, i, k))-q(i, k-1))*bet_tl)/bet**2
8463 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
8464 gam_tl(i, k) = (d4_tl(i)*bet-d4(i)*bet_tl)/bet**2
8465 gam(i, k) = d4(i)/bet
8469 a_bot_tl = d4_tl(i)*(d4(i)+1.5) + d4(i)*d4_tl(i)
8470 a_bot = 1. + d4(i)*(d4(i)+1.5)
8471 q_tl(i, km+1) = ((2.*((d4_tl(i)*(d4(i)+1.)+d4(i)*d4_tl(i))*a4(1&
8472 & , i, km)+d4(i)*(d4(i)+1.)*a4_tl(1, i, km))+a4_tl(1, i, km-1)-&
8473 & a_bot_tl*q(i, km)-a_bot*q_tl(i, km))*(d4(i)*(d4(i)+0.5)-a_bot*&
8474 & gam(i, km))-(2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
8475 & a_bot*q(i, km))*(d4_tl(i)*(d4(i)+0.5)+d4(i)*d4_tl(i)-a_bot_tl*&
8476 & gam(i, km)-a_bot*gam_tl(i, km)))/(d4(i)*(d4(i)+0.5)-a_bot*gam(&
8478 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
8479 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
8483 q_tl(i, k) = q_tl(i, k) - gam_tl(i, k)*q(i, k+1) - gam(i, k)*&
8485 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
8489 IF (kord .GE. 0.)
THEN 8495 IF (abs0 .GT. 16)
THEN 8498 a4_tl(2, i, k) = q_tl(i, k)
8499 a4(2, i, k) = q(i, k)
8500 a4_tl(3, i, k) = q_tl(i, k+1)
8501 a4(3, i, k) = q(i, k+1)
8502 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(3&
8504 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
8513 SUBROUTINE cs_profile_tlm(qs, qs_tl, a4, a4_tl, delp, delp_tl, km, &
8519 INTEGER,
INTENT(IN) :: i1, i2
8521 INTEGER,
INTENT(IN) :: km
8523 INTEGER,
INTENT(IN) :: iv
8526 INTEGER,
INTENT(IN) :: kord
8527 REAL,
INTENT(IN) :: qs(i1:i2)
8528 REAL,
INTENT(IN) :: qs_tl(i1:i2)
8530 REAL,
INTENT(IN) :: delp(i1:i2, km)
8531 REAL,
INTENT(IN) :: delp_tl(i1:i2, km)
8533 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
8534 REAL,
INTENT(INOUT) :: a4_tl(4, i1:i2, km)
8536 LOGICAL :: extm(i1:i2, km)
8537 REAL :: gam(i1:i2, km)
8538 REAL :: gam_tl(i1:i2, km)
8539 REAL :: q(i1:i2, km+1)
8540 REAL :: q_tl(i1:i2, km+1)
8542 REAL :: d4_tl(i1:i2)
8543 REAL :: bet, a_bot, grat
8544 REAL :: bet_tl, a_bot_tl, grat_tl
8545 REAL :: pmp_1, lac_1, pmp_2, lac_2
8549 IF (iv .EQ. -2)
THEN 8553 q_tl(i, 1) = 1.5*a4_tl(1, i, 1)
8554 q(i, 1) = 1.5*a4(1, i, 1)
8559 grat_tl = (delp_tl(i, k-1)*delp(i, k)-delp(i, k-1)*delp_tl(i, &
8561 grat = delp(i, k-1)/delp(i, k)
8562 bet_tl = 2*grat_tl - gam_tl(i, k)
8563 bet = 2. + grat + grat - gam(i, k)
8564 q_tl(i, k) = ((3.*(a4_tl(1, i, k-1)+a4_tl(1, i, k))-q_tl(i, k-&
8565 & 1))*bet-(3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*bet_tl)/&
8567 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
8568 gam_tl(i, k+1) = (grat_tl*bet-grat*bet_tl)/bet**2
8569 gam(i, k+1) = grat/bet
8573 grat_tl = (delp_tl(i, km-1)*delp(i, km)-delp(i, km-1)*delp_tl(i&
8574 & , km))/delp(i, km)**2
8575 grat = delp(i, km-1)/delp(i, km)
8576 q_tl(i, km) = ((3.*(a4_tl(1, i, km-1)+a4_tl(1, i, km))-grat_tl*&
8577 & qs(i)-grat*qs_tl(i)-q_tl(i, km-1))*(2.+grat+grat-gam(i, km))-(&
8578 & 3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-1))*(2*&
8579 & grat_tl-gam_tl(i, km)))/(2.+grat+grat-gam(i, km))**2
8580 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
8581 & 1))/(2.+grat+grat-gam(i, km))
8582 q_tl(i, km+1) = qs_tl(i)
8587 q_tl(i, k) = q_tl(i, k) - gam_tl(i, k+1)*q(i, k+1) - gam(i, k+&
8589 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
8597 grat_tl = (delp_tl(i, 2)*delp(i, 1)-delp(i, 2)*delp_tl(i, 1))/&
8599 grat = delp(i, 2)/delp(i, 1)
8600 bet_tl = grat_tl*(grat+0.5) + grat*grat_tl
8601 bet = grat*(grat+0.5)
8602 q_tl(i, 1) = (((2*grat_tl*(grat+1.)+(grat+grat)*grat_tl)*a4(1, i&
8603 & , 1)+(grat+grat)*(grat+1.)*a4_tl(1, i, 1)+a4_tl(1, i, 2))*bet-&
8604 & ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))*bet_tl)/bet**2
8605 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
8606 gam_tl(i, 1) = ((grat_tl*(grat+1.5)+grat*grat_tl)*bet-(1.+grat*(&
8607 & grat+1.5))*bet_tl)/bet**2
8608 gam(i, 1) = (1.+grat*(grat+1.5))/bet
8613 d4_tl(i) = (delp_tl(i, k-1)*delp(i, k)-delp(i, k-1)*delp_tl(i&
8614 & , k))/delp(i, k)**2
8615 d4(i) = delp(i, k-1)/delp(i, k)
8616 bet_tl = 2*d4_tl(i) - gam_tl(i, k-1)
8617 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
8618 q_tl(i, k) = ((3.*(a4_tl(1, i, k-1)+d4_tl(i)*a4(1, i, k)+d4(i)&
8619 & *a4_tl(1, i, k))-q_tl(i, k-1))*bet-(3.*(a4(1, i, k-1)+d4(i)*&
8620 & a4(1, i, k))-q(i, k-1))*bet_tl)/bet**2
8621 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
8622 gam_tl(i, k) = (d4_tl(i)*bet-d4(i)*bet_tl)/bet**2
8623 gam(i, k) = d4(i)/bet
8627 a_bot_tl = d4_tl(i)*(d4(i)+1.5) + d4(i)*d4_tl(i)
8628 a_bot = 1. + d4(i)*(d4(i)+1.5)
8629 q_tl(i, km+1) = ((2.*((d4_tl(i)*(d4(i)+1.)+d4(i)*d4_tl(i))*a4(1&
8630 & , i, km)+d4(i)*(d4(i)+1.)*a4_tl(1, i, km))+a4_tl(1, i, km-1)-&
8631 & a_bot_tl*q(i, km)-a_bot*q_tl(i, km))*(d4(i)*(d4(i)+0.5)-a_bot*&
8632 & gam(i, km))-(2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
8633 & a_bot*q(i, km))*(d4_tl(i)*(d4(i)+0.5)+d4(i)*d4_tl(i)-a_bot_tl*&
8634 & gam(i, km)-a_bot*gam_tl(i, km)))/(d4(i)*(d4(i)+0.5)-a_bot*gam(&
8636 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
8637 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
8641 q_tl(i, k) = q_tl(i, k) - gam_tl(i, k)*q(i, k+1) - gam(i, k)*&
8643 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
8647 IF (kord .GE. 0.)
THEN 8653 IF (abs0 .GT. 16)
THEN 8656 a4_tl(2, i, k) = q_tl(i, k)
8657 a4(2, i, k) = q(i, k)
8658 a4_tl(3, i, k) = q_tl(i, k+1)
8659 a4(3, i, k) = q(i, k+1)
8660 a4_tl(4, i, k) = 3.*(2.*a4_tl(1, i, k)-a4_tl(2, i, k)-a4_tl(3&
8662 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
subroutine ppm_profile_tlm(a4, a4_tl, delp, delp_tl, km, i1, i2, iv, kord)
subroutine pkez_tlm(km, ifirst, ilast, jfirst, jlast, j, pe, pk, pk_tl, akap, peln, peln_tl, pkz, pkz_tl, ptop)
real, parameter, public radius
Radius of the Earth [m].
integer, parameter, public model_atmos
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
real, parameter, public ptop_min
subroutine, public moist_cp(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cpm, t1)
subroutine, public fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, te0, qv, ql, qi, qr, qs, qg, dpln, delz, pt, dp, q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
subroutine, public map1_q2(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
subroutine map1_ppm_tlm(km, pe1, pe1_tl, qs, qs_tl, kn, pe2, pe2_tl, q2, q2_tl, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
real, parameter, public hlv
Latent heat of evaporation [J/kg].
subroutine scalar_profile_tlm(qs, a4, a4_tl, delp, delp_tl, km, i1, i2, iv, kord, qmin)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
real, parameter consv_min
real, parameter, public cp_vapor
Specific heat capacity of water vapor at constant pressure [J/kg/deg].
subroutine, public fillz(im, km, nq, q, dp)
subroutine, public lagrangian_to_eulerian(last_step, consv, ps, pe, delp, pkz, pk, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, ng, ua, va, omga, te, ws, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
subroutine ppm_limiters_tlm(dm, dm_tl, a4, a4_tl, itot, lmt)
subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
subroutine map_scalar_tlm(km, pe1, pe1_tl, qs, kn, pe2, pe2_tl, q2, q2_tl, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine cs_profile_tlm(qs, qs_tl, a4, a4_tl, delp, delp_tl, km, i1, i2, iv, kord)
subroutine map1_cubic_tlm(km, pe1, pe1_tl, kn, pe2, pe2_tl, q2, q2_tl, i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
subroutine ppm_limiters(dm, a4, itot, lmt)
subroutine remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
subroutine, public lagrangian_to_eulerian_tlm(last_step, consv, ps, ps_tl, pe, pe_tl, delp, delp_tl, pkz, pkz_tl, pk, pk_tl, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, u_tl, v, v_tl, w, w_tl, delz, delz_tl, pt, pt_tl, q, q_tl, hs, r_vir, cp, akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, peln_tl, te0_2d, te0_2d_tl, ng, ua, ua_tl, va, omga, omga_tl, te, te_tl, ws, ws_tl, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
subroutine timing_on(blk_name)
subroutine cs_limiters(im, extm, a4, iv)
subroutine, public compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, u, v, w, delz, pt, delp, q, qc, pe, peln, hs, rsin2_l, cosa_s_l, r_vir, cp, rg, hlv, te_2d, ua, va, teq, moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
subroutine, public qs_init(kmp)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine, public compute_total_energy_tlm(is, ie, js, je, isd, ied, jsd, jed, km, u, u_tl, v, v_tl, w, w_tl, delz, delz_tl, pt, pt_tl, delp, delp_tl, q, q_tl, qc, qc_tl, pe, pe_tl, peln, peln_tl, hs, rsin2_l, cosa_s_l, r_vir, cp, rg, hlv, te_2d, te_2d_tl, ua, va, teq, teq_tl, moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
subroutine map_scalar(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine, public rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, domain, square_domain)
subroutine, public map1_q2_tlm(km, pe1, pe1_tl, q1, q1_tl, kn, pe2, pe2_tl, q2, q2_tl, dp2, dp2_tl, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
real, parameter, public hlf
Latent heat of fusion [J/kg].
subroutine cs_limiters_tlm(im, extm, a4, a4_tl, iv)
subroutine map1_ppm(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
subroutine map1_cubic(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public moist_cv(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cvm, t1)
subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, peln, pkz, ptop)
subroutine, public prt_mxm(qname, q, is, ie, js, je, n_g, km, fac, area, domain)
subroutine mapn_tracer_tlm(nq, km, pe1, pe1_tl, pe2, pe2_tl, q1, q1_tl, dp2, dp2_tl, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
subroutine steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
real function, public g_sum_tlm(domain, p, p_tl, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce, g_sum)
subroutine ppm_profile(a4, delp, km, i1, i2, iv, kord)
real(fp), parameter, public pi
subroutine timing_off(blk_name)