47 real,
parameter::
r2=1./2.,
r0=0.0
48 real,
parameter::
r3 = 1./3.,
r23 = 2./3.,
r12 = 1./12.
53 real,
parameter::
c_liq = 4.1855e+3
56 real,
parameter::
tice = 273.16
92 & pkz, pk, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat&
93 & , sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, akap, cappa, &
94 & kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, ng, ua, va, omga, &
95 & te, ws, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, &
96 & flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, &
97 & do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, &
98 & kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
101 LOGICAL,
INTENT(IN) :: last_step
103 REAL,
INTENT(IN) :: mdt
105 REAL,
INTENT(IN) :: pdt
106 INTEGER,
INTENT(IN) :: km
108 INTEGER,
INTENT(IN) :: nq
109 INTEGER,
INTENT(IN) :: nwat
111 INTEGER,
INTENT(IN) :: sphum
112 INTEGER,
INTENT(IN) :: ng
114 INTEGER,
INTENT(IN) :: is, ie, isd, ied
116 INTEGER,
INTENT(IN) :: js, je, jsd, jed
118 INTEGER,
INTENT(IN) :: kord_mt
120 INTEGER,
INTENT(IN) :: kord_wz
122 INTEGER,
INTENT(IN) :: kord_tr(nq)
124 INTEGER,
INTENT(IN) :: kord_tm
126 INTEGER,
INTENT(IN) :: kord_mt_pert
128 INTEGER,
INTENT(IN) :: kord_wz_pert
130 INTEGER,
INTENT(IN) :: kord_tr_pert(nq)
132 INTEGER,
INTENT(IN) :: kord_tm_pert
134 REAL,
INTENT(IN) :: consv
135 REAL,
INTENT(IN) :: r_vir
136 REAL,
INTENT(IN) :: cp
137 REAL,
INTENT(IN) :: akap
139 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
140 REAL,
INTENT(INOUT) :: te0_2d(is:ie, js:je)
141 REAL,
INTENT(IN) :: ws(is:ie, js:je)
142 LOGICAL,
INTENT(IN) :: do_sat_adj
144 LOGICAL,
INTENT(IN) :: fill
145 LOGICAL,
INTENT(IN) :: reproduce_sum
146 LOGICAL,
INTENT(IN) :: do_omega, adiabatic, do_adiabatic_init
147 REAL,
INTENT(IN) :: ptop
148 REAL,
INTENT(IN) :: ak(km+1)
149 REAL,
INTENT(IN) :: bk(km+1)
150 REAL,
INTENT(IN) :: pfull(km)
153 TYPE(
domain2d),
INTENT(INOUT) :: domain
156 REAL,
INTENT(INOUT) :: pk(is:ie, js:je, km+1)
157 REAL,
INTENT(INOUT) :: q(isd:ied, jsd:jed, km, nq)
159 REAL,
INTENT(INOUT) :: delp(isd:ied, jsd:jed, km)
161 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
163 REAL,
INTENT(INOUT) :: ps(isd:ied, jsd:jed)
166 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
168 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
170 REAL,
INTENT(INOUT) :: w(isd:ied, jsd:jed, km)
172 REAL,
INTENT(INOUT) :: pt(isd:ied, jsd:jed, km)
174 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz
175 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: q_con, cappa
176 LOGICAL,
INTENT(IN) :: hydrostatic
177 LOGICAL,
INTENT(IN) :: hybrid_z
178 LOGICAL,
INTENT(IN) :: out_dt
180 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
182 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
184 REAL,
INTENT(INOUT) :: omga(isd:ied, jsd:jed, km)
186 REAL,
INTENT(INOUT) :: peln(is:ie, km+1, js:je)
187 REAL,
INTENT(INOUT) :: dtdt(is:ie, js:je, km)
189 REAL :: pkz(is:ie, js:je, km)
190 REAL :: te(isd:ied, jsd:jed, km)
193 REAL,
OPTIONAL,
INTENT(INOUT) :: mfx(is:ie+1, js:je, km)
195 REAL,
OPTIONAL,
INTENT(INOUT) :: mfy(is:ie, js:je+1, km)
197 INTEGER,
INTENT(IN) :: remap_option
206 REAL,
DIMENSION(is:ie, js:je) :: te_2d, zsum0, zsum1, dpln
207 REAL,
DIMENSION(is:ie, km) :: q2, dp2
208 REAL,
DIMENSION(is:ie, km+1) :: pe1, pe2, pk1, pk2, pn2, phis
209 REAL,
DIMENSION(is:ie+1, km+1) :: pe0, pe3
210 REAL,
DIMENSION(is:ie) :: gz, cvm, qv
211 REAL :: rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
212 LOGICAL :: fast_mp_consv
214 INTEGER :: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel&
215 & , iq, n, kmp, kp, k_next
216 LOGICAL :: remap_t, remap_pt, remap_te
217 INTEGER :: abs_kord_tm, abs_kord_tm_pert
218 INTEGER :: iep1, jep1, iedp1, jedp1
353 IF (kord_tm .GE. 0.)
THEN 354 abs_kord_tm = kord_tm
356 abs_kord_tm = -kord_tm
358 IF (kord_tm_pert .GE. 0.)
THEN 359 abs_kord_tm_pert = kord_tm_pert
361 abs_kord_tm_pert = -kord_tm_pert
369 SELECT CASE (remap_option)
380 IF (res .AND. flagstruct%fv_debug)
THEN 382 SELECT CASE (remap_option)
385 print*,
' REMAPPING T in logP ' 388 print*,
' REMAPPING PT in P' 391 print*,
' REMAPPING TE in logP with GMAO cubic' 395 print*,
' REMAPPING CONSV: ', consv
396 print*,
' REMAPPING CONSV_MIN: ',
consv_min 406 fast_mp_consv = .NOT.do_adiabatic_init .AND. consv .GT.
consv_min 410 IF (pfull(k) .GT. 10.e2)
THEN 413 ad_count = ad_count + 1
441 pe1(i, k) = pe(i, k, j)
452 pe2(i, km+1) = pe(i, km+1, j)
457 IF (j .NE. je + 1)
THEN 462 IF (hydrostatic)
THEN 468 pt(i, j, k) = pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k))/(&
469 & akap*(peln(i, k+1, j)-peln(i, k, j)))
482 pt(i, j, k) = pt(i, j, k)*exp(k1k*log(rrg*delp(i, j, k)/&
483 & delz(i, j, k)*pt(i, j, k)))
491 ELSE IF (remap_pt)
THEN 496 ELSE IF (remap_te)
THEN 501 CALL pkez_fwd(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, &
508 te(i, j, k) = 0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2+u&
509 & (i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, k)&
510 & +u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*gridstruct%&
511 & cosa_s(i, j)) +
cp_air*pt(i, j, k)*pkz(i, j, k)
521 IF (.NOT.hydrostatic)
THEN 527 delz(i, j, k) = -(delz(i, j, k)/delp(i, j, k))
540 ps(i, j) = pe1(i, km+1)
551 pe2(i, k) = ak(k) + bk(k)*pe(i, km+1, j)
561 dp2(i, k) = pe2(i, k+1) - pe2(i, k)
574 delp(i, j, k) = dp2(i, k)
587 pk1(i, k) = pk(i, j, k)
596 pn2(i, 1) = peln(i, 1, j)
598 pn2(i, km+1) = peln(i, km+1, j)
600 pk2(i, 1) = pk1(i, 1)
602 pk2(i, km+1) = pk1(i, km+1)
610 pn2(i, k) = log(pe2(i, k))
612 pk2(i, k) = exp(akap*pn2(i, k))
622 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 624 & pn2, pt, is, ie, j, isd, ied, jsd, jed, 1, &
625 & abs_kord_tm,
t_min)
629 CALL map_scalar(km, peln(is:ie, 1:km+1, j), gz, km, pn2, pt&
630 & , is, ie, j, isd, ied, jsd, jed, 1, &
631 & abs_kord_tm,
t_min)
634 ELSE IF (remap_pt)
THEN 638 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 639 CALL map1_ppm_fwd(km, pe1, gz, km, pe2, pt, is, ie, j, &
640 & isd, ied, jsd, jed, 1, abs_kord_tm)
644 CALL map1_ppm(km, pe1, gz, km, pe2, pt, is, ie, j, isd, ied&
645 & , jsd, jed, 1, abs_kord_tm)
648 ELSE IF (remap_te)
THEN 655 phis(i, km+1) = hs(i, j)
664 phis(i, k) = phis(i, k+1) +
cp_air*pt(i, j, k)*(pk1(i, k+1&
675 phis(i, k) = phis(i, k)*pe1(i, k)
685 te(i, j, k) = te(i, j, k) + (phis(i, k+1)-phis(i, k))/(pe1&
686 & (i, k+1)-pe1(i, k))
694 & , jsd, jed, akap, t_var=1, conserv=.true.)
703 IF (kord_tr(1) .EQ. kord_tr_pert(1))
THEN 705 & , is, ie, isd, ied, jsd, jed, 0., fill)
709 CALL mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, &
710 & is, ie, isd, ied, jsd, jed, 0., fill)
713 ELSE IF (nq .GT. 0)
THEN 716 IF (kord_tr(iq) .EQ. kord_tr_pert(iq))
THEN 717 CALL map1_q2_fwd(km, pe1, q(isd:ied, jsd:jed, 1:km, iq)&
718 & , km, pe2, q2, dp2, is, ie, 0, kord_tr(iq), &
719 & j, isd, ied, jsd, jed, 0.)
722 CALL map1_q2(km, pe1, q(isd:ied, jsd:jed, 1:km, iq), km, &
723 & pe2, q2, dp2, is, ie, 0, kord_tr(iq), j, isd, &
731 q(i, j, k, iq) = q2(i, k)
743 IF (.NOT.hydrostatic)
THEN 745 IF (kord_wz .EQ. kord_wz_pert)
THEN 746 CALL map1_ppm_fwd(km, pe1, ws(is:ie, j), km, pe2, w, is, &
747 & ie, j, isd, ied, jsd, jed, -2, kord_wz)
751 CALL map1_ppm(km, pe1, ws(is:ie, j), km, pe2, w, is, ie, j, &
752 & isd, ied, jsd, jed, -2, kord_wz)
756 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 757 CALL map1_ppm_fwd(km, pe1, gz, km, pe2, delz, is, ie, j, &
758 & isd, ied, jsd, jed, 1, abs_kord_tm)
762 CALL map1_ppm(km, pe1, gz, km, pe2, delz, is, ie, j, isd, &
763 & ied, jsd, jed, 1, abs_kord_tm)
770 delz(i, j, k) = -(delz(i, j, k)*dp2(i, k))
787 pk(i, j, k) = pk2(i, k)
808 pe3(i, k) = omga(i, j, k-1)
822 pe0(i, k) = peln(i, k, j)
824 peln(i, k, j) = pn2(i, k)
833 IF (hydrostatic)
THEN 838 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1&
839 & , j)-peln(i, k, j)))
846 ELSE IF (remap_te)
THEN 849 ELSE IF (remap_t)
THEN 855 pkz(i, j, k) = exp(akap*log(rrg*delp(i, j, k)/delz(i, j, k&
871 pkz(i, j, k) = exp(k1k*log(rrg*delp(i, j, k)/delz(i, j, k)&
887 dp2(i, k) = 0.5*(peln(i, k, j)+peln(i, k+1, j))
901 IF (dp2(i, n) .LE. pe0(i, k+1) .AND. dp2(i, n) .GE. pe0(&
906 ad_count0 = ad_count0 + 1
916 omga(i, j, n) = pe3(i, k) + (pe3(i, k+1)-pe3(i, k))*(dp2(i&
917 & , n)-pe0(i, k))/(pe0(i, k+1)-pe0(i, k))
935 pe0(i, 1) = pe(i, 1, j)
947 pe0(i, k) = 0.5*(pe(i, k, j-1)+pe1(i, k))
959 pe3(i, k) = ak(k) + bkh*(pe(i, km+1, j-1)+pe1(i, km+1))
965 IF (kord_mt .EQ. kord_mt_pert)
THEN 966 CALL map1_ppm_fwd(km, pe0(is:ie, :), gz, km, pe3(is:ie, :), u&
967 & , is, ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
971 CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:ie, :), u, is, &
972 & ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
976 IF (j .LT. je + 1)
THEN 993 pe0(i, k) = 0.5*(pe(i-1, k, j)+pe(i, k, j))
995 pe3(i, k) = ak(k) + bkh*(pe(i-1, km+1, j)+pe(i, km+1, j))
1001 IF (kord_mt .EQ. kord_mt_pert)
THEN 1002 CALL map1_ppm_fwd(km, pe0, gz, km, pe3, v, is, iep1, j, isd&
1003 & , iedp1, jsd, jed, -1, kord_mt)
1007 CALL map1_ppm(km, pe0, gz, km, pe3, v, is, iep1, j, isd, iedp1&
1008 & , jsd, jed, -1, kord_mt)
1018 ua(i, j, k) = pe2(i, k+1)
1025 ad_count1 = ad_count1 + 1
1043 pe(i, k, j) = ua(i, j, k-1)
1049 IF (last_step .AND. (.NOT.do_adiabatic_init))
THEN 1056 IF (hydrostatic)
THEN 1061 gz(i) = gz(i) + rg*pt(i, j, k)*(peln(i, k+1, j)-peln(i&
1066 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
1071 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*pt(i, j&
1072 & , k)+0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i&
1073 & , j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, &
1074 & k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1075 & gridstruct%cosa_s(i, j)))
1083 phis(i, km+1) = hs(i, j)
1088 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
1093 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
1094 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
1095 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
1096 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
1097 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
1098 & i+1, j, k))*gridstruct%cosa_s(i, j))))
1103 ELSE IF (remap_pt)
THEN 1105 IF (hydrostatic)
THEN 1110 gz(i) = gz(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i&
1115 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
1120 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cp_air*pt(i&
1121 & , j, k)*pkz(i, j, k)+0.25*gridstruct%rsin2(i, j)*(u(&
1122 & i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, &
1123 & k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j&
1124 & , k))*gridstruct%cosa_s(i, j)))
1134 phis(i, km+1) = hs(i, j)
1137 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
1145 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
1146 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
1147 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
1148 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
1149 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
1150 & i+1, j, k))*gridstruct%cosa_s(i, j))))
1155 ELSE IF (remap_te)
THEN 1157 te_2d(i, j) = te(i, j, 1)*delp(i, j, 1)
1161 te_2d(i, j) = te_2d(i, j) + te(i, j, k)*delp(i, j, k)
1169 te_2d(i, j) = te0_2d(i, j) - te_2d(i, j)
1170 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
1174 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
1177 IF (hydrostatic)
THEN 1179 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
1189 result1 = g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%&
1190 & area_64, 0, reproduce=.true.)
1194 IF (hydrostatic)
THEN 1195 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
1196 & area_64, 0, reproduce=.true.)
1197 dtmp = tpe/(cp*result1)
1200 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
1201 & area_64, 0, reproduce=.true.)
1202 dtmp = tpe/(
cv_air*result1)
1210 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
1214 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
1217 IF (hydrostatic)
THEN 1219 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
1230 IF (hydrostatic)
THEN 1231 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
1232 & area_64, 0, reproduce=.true.)
1236 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
1237 & area_64, 0, reproduce=.true.)
1250 IF (remap_t .AND. (.NOT.do_adiabatic_init) .AND. do_sat_adj)
THEN 1253 IF (.NOT.hydrostatic)
THEN 1257 pkz(i, j, k) = exp(akap*log(rrg*delp(i, j, k)/delz(i, j, k&
1267 IF (fast_mp_consv)
THEN 1272 te0_2d(i, j) = te0_2d(i, j) + te(i, j, k)
1290 IF (.NOT.adiabatic)
THEN 1293 pt(i, j, k) = (pt(i, j, k)+dtmp*pkz(i, j, k))/(1.+r_vir*&
1294 & q(i, j, k, sphum))
1332 ELSE IF (remap_pt)
THEN 1340 pt(i, j, k) = (pt(i, j, k)+dtmp)*pkz(i, j, k)/(1.+r_vir*q(&
1375 ELSE IF (remap_te)
THEN 1385 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
1386 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
1387 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1388 & gridstruct%cosa_s(i, j))
1389 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
1391 tmp = tpe/((cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+r_vir*q&
1392 & (i, j, k, sphum)))
1394 pt(i, j, k) = tmp + dtmp*pkz(i, j, k)/(1.+r_vir*q(i, j, k&
1397 gz(i) = gz(i) + dlnp*tmp*(1.+r_vir*q(i, j, k, sphum))
1463 ELSE IF (remap_t)
THEN 1470 pt(i, j, k) = pt(i, j, k)/pkz(i, j, k)
1503 ELSE IF (remap_te)
THEN 1513 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u(i&
1514 & , j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(&
1515 & u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
1516 & gridstruct%cosa_s(i, j))
1517 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
1518 tmp = tpe/(cp-pe(i, k, j)*dlnp/delp(i, j, k))
1520 pt(i, j, k) = tmp/pkz(i, j, k) + dtmp
1522 gz(i) = gz(i) + dlnp*tmp
1615 & , pe_ad, delp, delp_ad, pkz, pkz_ad, pk, pk_ad, mdt, pdt, km, is, ie&
1616 & , js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, u_ad, v, &
1617 & v_ad, w, w_ad, delz, delz_ad, pt, pt_ad, q, q_ad, hs, r_vir, cp, &
1618 & akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, peln_ad, &
1619 & te0_2d, te0_2d_ad, ng, ua, ua_ad, va, omga, omga_ad, te, te_ad, ws, &
1620 & ws_ad, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, &
1621 & flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, &
1622 & do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, &
1623 & kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
1626 LOGICAL,
INTENT(IN) :: last_step
1627 REAL,
INTENT(IN) :: mdt
1628 REAL,
INTENT(IN) :: pdt
1629 INTEGER,
INTENT(IN) :: km
1630 INTEGER,
INTENT(IN) :: nq
1631 INTEGER,
INTENT(IN) :: nwat
1632 INTEGER,
INTENT(IN) :: sphum
1633 INTEGER,
INTENT(IN) :: ng
1634 INTEGER,
INTENT(IN) :: is, ie, isd, ied
1635 INTEGER,
INTENT(IN) :: js, je, jsd, jed
1636 INTEGER,
INTENT(IN) :: kord_mt
1637 INTEGER,
INTENT(IN) :: kord_wz
1638 INTEGER,
INTENT(IN) :: kord_tr(nq)
1639 INTEGER,
INTENT(IN) :: kord_tm
1640 INTEGER,
INTENT(IN) :: kord_mt_pert
1641 INTEGER,
INTENT(IN) :: kord_wz_pert
1642 INTEGER,
INTENT(IN) :: kord_tr_pert(nq)
1643 INTEGER,
INTENT(IN) :: kord_tm_pert
1644 REAL,
INTENT(IN) :: consv
1645 REAL,
INTENT(IN) :: r_vir
1646 REAL,
INTENT(IN) :: cp
1647 REAL,
INTENT(IN) :: akap
1648 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
1649 REAL,
INTENT(INOUT) :: te0_2d(is:ie, js:je)
1650 REAL,
INTENT(INOUT) :: te0_2d_ad(is:ie, js:je)
1651 REAL,
INTENT(IN) :: ws(is:ie, js:je)
1652 REAL :: ws_ad(is:ie, js:je)
1653 LOGICAL,
INTENT(IN) :: do_sat_adj
1654 LOGICAL,
INTENT(IN) :: fill
1655 LOGICAL,
INTENT(IN) :: reproduce_sum
1656 LOGICAL,
INTENT(IN) :: do_omega, adiabatic, do_adiabatic_init
1657 REAL,
INTENT(IN) :: ptop
1658 REAL,
INTENT(IN) :: ak(km+1)
1659 REAL,
INTENT(IN) :: bk(km+1)
1660 REAL,
INTENT(IN) :: pfull(km)
1663 TYPE(
domain2d),
INTENT(INOUT) :: domain
1664 REAL,
INTENT(INOUT) :: pk(is:ie, js:je, km+1)
1665 REAL,
INTENT(INOUT) :: pk_ad(is:ie, js:je, km+1)
1666 REAL,
INTENT(INOUT) :: q(isd:ied, jsd:jed, km, nq)
1667 REAL,
INTENT(INOUT) :: q_ad(isd:ied, jsd:jed, km, nq)
1668 REAL,
INTENT(INOUT) :: delp(isd:ied, jsd:jed, km)
1669 REAL,
INTENT(INOUT) :: delp_ad(isd:ied, jsd:jed, km)
1670 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
1671 REAL,
INTENT(INOUT) :: pe_ad(is-1:ie+1, km+1, js-1:je+1)
1672 REAL,
INTENT(INOUT) :: ps(isd:ied, jsd:jed)
1673 REAL,
INTENT(INOUT) :: ps_ad(isd:ied, jsd:jed)
1674 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
1675 REAL,
INTENT(INOUT) :: u_ad(isd:ied, jsd:jed+1, km)
1676 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
1677 REAL,
INTENT(INOUT) :: v_ad(isd:ied+1, jsd:jed, km)
1678 REAL,
INTENT(INOUT) :: w(isd:ied, jsd:jed, km)
1679 REAL,
INTENT(INOUT) :: w_ad(isd:ied, jsd:jed, km)
1680 REAL,
INTENT(INOUT) :: pt(isd:ied, jsd:jed, km)
1681 REAL,
INTENT(INOUT) :: pt_ad(isd:ied, jsd:jed, km)
1682 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz
1683 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz_ad
1684 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: q_con, cappa
1685 LOGICAL,
INTENT(IN) :: hydrostatic
1686 LOGICAL,
INTENT(IN) :: hybrid_z
1687 LOGICAL,
INTENT(IN) :: out_dt
1688 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
1689 REAL,
INTENT(INOUT) :: ua_ad(isd:ied, jsd:jed, km)
1690 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
1691 REAL,
INTENT(INOUT) :: omga(isd:ied, jsd:jed, km)
1692 REAL,
INTENT(INOUT) :: omga_ad(isd:ied, jsd:jed, km)
1693 REAL,
INTENT(INOUT) :: peln(is:ie, km+1, js:je)
1694 REAL,
INTENT(INOUT) :: peln_ad(is:ie, km+1, js:je)
1695 REAL,
INTENT(INOUT) :: dtdt(is:ie, js:je, km)
1696 REAL :: pkz(is:ie, js:je, km)
1697 REAL :: pkz_ad(is:ie, js:je, km)
1698 REAL :: te(isd:ied, jsd:jed, km)
1699 REAL :: te_ad(isd:ied, jsd:jed, km)
1700 REAL,
OPTIONAL,
INTENT(INOUT) :: mfx(is:ie+1, js:je, km)
1701 REAL,
OPTIONAL,
INTENT(INOUT) :: mfy(is:ie, js:je+1, km)
1702 INTEGER,
INTENT(IN) :: remap_option
1703 REAL,
DIMENSION(is:ie, js:je) :: te_2d, zsum0, zsum1, dpln
1704 REAL,
DIMENSION(is:ie, js:je) :: te_2d_ad, zsum0_ad, zsum1_ad
1705 REAL,
DIMENSION(is:ie, km) :: q2, dp2
1706 REAL,
DIMENSION(is:ie, km) :: q2_ad, dp2_ad
1707 REAL,
DIMENSION(is:ie, km+1) :: pe1, pe2, pk1, pk2, pn2, phis
1708 REAL,
DIMENSION(is:ie, km+1) :: pe1_ad, pe2_ad, pk1_ad, pk2_ad, &
1710 REAL,
DIMENSION(is:ie+1, km+1) :: pe0, pe3
1711 REAL,
DIMENSION(is:ie+1, km+1) :: pe0_ad, pe3_ad
1712 REAL,
DIMENSION(is:ie) :: gz, cvm, qv
1713 REAL,
DIMENSION(is:ie) :: gz_ad
1714 REAL :: rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
1715 REAL :: tmp_ad, tpe_ad, dtmp_ad, dlnp_ad
1716 LOGICAL :: fast_mp_consv
1718 INTEGER :: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel&
1719 & , iq, n, kmp, kp, k_next
1720 LOGICAL :: remap_t, remap_pt, remap_te
1721 INTEGER :: abs_kord_tm, abs_kord_tm_pert
1722 INTEGER :: iep1, jep1, iedp1, jedp1
1872 INTEGER :: ad_from10
1874 INTEGER :: ad_from11
1877 INTEGER :: ad_from12
1879 INTEGER :: ad_from13
1881 INTEGER :: ad_from14
1882 INTEGER :: ad_from15
1885 INTEGER :: ad_from16
1888 INTEGER :: ad_from17
1892 INTEGER :: ad_from18
1895 INTEGER :: ad_from19
1898 INTEGER :: ad_from20
1900 INTEGER :: ad_from21
1903 INTEGER :: ad_from22
1906 INTEGER :: ad_from23
1909 INTEGER :: ad_from24
1912 INTEGER :: ad_from25
1915 INTEGER :: ad_from26
1918 INTEGER :: ad_count0
1921 INTEGER :: ad_from27
1923 INTEGER :: ad_from28
1925 INTEGER :: ad_from29
1928 INTEGER :: ad_from30
1931 INTEGER :: ad_from31
1933 INTEGER :: ad_from32
1936 INTEGER :: ad_from33
1939 INTEGER :: ad_count1
1983 abs_kord_tm_pert = 0
2068 IF (branch .LT. 3)
THEN 2069 IF (branch .EQ. 0)
THEN 2103 IF (branch .NE. 0)
THEN 2106 temp36 = r_vir*q(i, j, k, sphum) + 1.
2107 temp_ad37 = pt_ad(i, j, k)/temp36
2108 dtmp_ad = dtmp_ad + pkz(i, j, k)*temp_ad37
2109 pkz_ad(i, j, k) = pkz_ad(i, j, k) + dtmp*temp_ad37
2110 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) - (pt(i, j, &
2111 & k)+dtmp*pkz(i, j, k))*r_vir*temp_ad37/temp36
2112 pt_ad(i, j, k) = temp_ad37
2118 ELSE IF (branch .EQ. 1)
THEN 2153 temp39 = r_vir*q(i, j, k, sphum) + 1.
2154 temp_ad38 = pt_ad(i, j, k)/temp39
2155 temp38 = pkz(i, j, k)
2156 temp37 = pt(i, j, k) + dtmp
2157 dtmp_ad = dtmp_ad + temp38*temp_ad38
2158 pkz_ad(i, j, k) = pkz_ad(i, j, k) + temp37*temp_ad38
2159 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) - temp37*&
2160 & temp38*r_vir*temp_ad38/temp39
2161 pt_ad(i, j, k) = temp38*temp_ad38
2202 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
2204 temp_ad39 = (r_vir*q(i, j, k, sphum)+1.)*gz_ad(i)
2205 tmp_ad = pt_ad(i, j, k) + dlnp*temp_ad39
2207 temp45 = r_vir*q(i, j, k, sphum) + 1.
2208 temp_ad41 = pt_ad(i, j, k)/temp45
2209 dtmp_ad = dtmp_ad + pkz(i, j, k)*temp_ad41
2210 pkz_ad(i, j, k) = pkz_ad(i, j, k) + dtmp*temp_ad41
2211 pt_ad(i, j, k) = 0.0
2212 temp44 = r_vir*q(i, j, k, sphum) + 1.
2213 temp43 = delp(i, j, k)
2214 temp42 = pe(i, k, j)
2215 temp41 = temp42*dlnp/temp43
2216 temp40 = (cp-temp41)*temp44
2217 temp_ad42 = -(tpe*tmp_ad/temp40**2)
2218 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) + (cp-temp41)*&
2219 & r_vir*temp_ad42 - dtmp*pkz(i, j, k)*r_vir*temp_ad41/&
2220 & temp45 + dlnp*tmp*r_vir*gz_ad(i)
2221 temp_ad40 = -(temp44*temp_ad42/temp43)
2222 dlnp_ad = temp42*temp_ad40 + tmp*temp_ad39
2224 tpe_ad = tmp_ad/temp40
2225 pe_ad(i, k, j) = pe_ad(i, k, j) + dlnp*temp_ad40
2226 delp_ad(i, j, k) = delp_ad(i, j, k) - temp41*temp_ad40
2227 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + rg*dlnp_ad
2228 peln_ad(i, k, j) = peln_ad(i, k, j) - rg*dlnp_ad
2230 temp_ad43 = -(gridstruct%rsin2(i, j)*0.25*tpe_ad)
2231 temp_ad44 = -(gridstruct%cosa_s(i, j)*temp_ad43)
2232 temp_ad45 = (v(i, j, k)+v(i+1, j, k))*temp_ad44
2233 temp_ad46 = (u(i, j, k)+u(i, j+1, k))*temp_ad44
2234 te_ad(i, j, k) = te_ad(i, j, k) + tpe_ad
2235 gz_ad(i) = gz_ad(i) - tpe_ad
2236 u_ad(i, j, k) = u_ad(i, j, k) + temp_ad45 + 2*u(i, j, k)*&
2238 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp_ad45 + 2*u(i, j+1&
2240 v_ad(i, j, k) = v_ad(i, j, k) + temp_ad46 + 2*v(i, j, k)*&
2242 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp_ad46 + 2*v(i+1, j&
2252 ELSE IF (branch .LT. 5)
THEN 2253 IF (branch .EQ. 3)
THEN 2317 temp_ad47 = pt_ad(i, j, k)/pkz(i, j, k)
2318 pkz_ad(i, j, k) = pkz_ad(i, j, k) - pt(i, j, k)*temp_ad47/&
2320 pt_ad(i, j, k) = temp_ad47
2327 ELSE IF (branch .EQ. 5)
THEN 2361 temp_ad49 = pt_ad(i, j, k)/pkz(i, j, k)
2362 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
2363 tmp = tpe/(cp-pe(i, k, j)*dlnp/delp(i, j, k))
2365 tmp_ad = temp_ad49 + dlnp*gz_ad(i)
2367 pkz_ad(i, j, k) = pkz_ad(i, j, k) - tmp*temp_ad49/pkz(i, j, &
2369 dtmp_ad = dtmp_ad + pt_ad(i, j, k)
2370 pt_ad(i, j, k) = 0.0
2371 temp48 = delp(i, j, k)
2372 temp47 = pe(i, k, j)
2373 temp46 = temp47*dlnp/temp48
2374 temp_ad50 = tmp_ad/(cp-temp46)
2375 temp_ad48 = tpe*temp_ad50/((cp-temp46)*temp48)
2376 dlnp_ad = temp47*temp_ad48 + tmp*gz_ad(i)
2378 pe_ad(i, k, j) = pe_ad(i, k, j) + dlnp*temp_ad48
2379 delp_ad(i, j, k) = delp_ad(i, j, k) - temp46*temp_ad48
2380 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + rg*dlnp_ad
2381 peln_ad(i, k, j) = peln_ad(i, k, j) - rg*dlnp_ad
2383 temp_ad51 = -(gridstruct%rsin2(i, j)*0.25*tpe_ad)
2384 temp_ad52 = -(gridstruct%cosa_s(i, j)*temp_ad51)
2385 temp_ad53 = (v(i, j, k)+v(i+1, j, k))*temp_ad52
2386 temp_ad54 = (u(i, j, k)+u(i, j+1, k))*temp_ad52
2387 te_ad(i, j, k) = te_ad(i, j, k) + tpe_ad
2388 gz_ad(i) = gz_ad(i) - tpe_ad
2389 u_ad(i, j, k) = u_ad(i, j, k) + temp_ad53 + 2*u(i, j, k)*&
2391 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp_ad53 + 2*u(i, j+1, &
2393 v_ad(i, j, k) = v_ad(i, j, k) + temp_ad54 + 2*v(i, j, k)*&
2395 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp_ad54 + 2*v(i+1, j, &
2437 IF (branch .EQ. 0)
THEN 2441 te_ad(i, j, k) = te_ad(i, j, k) + te0_2d_ad(i, j)
2445 ELSE IF (branch .NE. 1)
THEN 2451 IF (branch .NE. 0)
THEN 2455 temp35 = delz(i, j, k)
2456 temp34 = delp(i, j, k)*pt(i, j, k)
2457 temp33 = temp34/temp35
2458 temp_ad36 = akap*exp(akap*log(rrg*temp33))*pkz_ad(i, j, k)/(&
2460 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*temp_ad36
2461 pt_ad(i, j, k) = pt_ad(i, j, k) + delp(i, j, k)*temp_ad36
2462 delz_ad(i, j, k) = delz_ad(i, j, k) - temp33*temp_ad36
2463 pkz_ad(i, j, k) = 0.0
2469 IF (branch .LT. 3)
THEN 2470 IF (branch .EQ. 0)
THEN 2471 temp_ad34 = dtmp_ad/(cp*result1)
2473 result1_ad = -(tpe*temp_ad34/result1)
2474 CALL g_sum_adm(domain, zsum0, zsum0_ad, is, ie, js, je, ng, &
2475 & gridstruct%area_64, 0, reproduce=.true., g_sum_ad=&
2478 ELSE IF (branch .EQ. 1)
THEN 2479 temp_ad35 = dtmp_ad/(
cv_air*result1)
2481 result1_ad = -(tpe*temp_ad35/result1)
2482 CALL g_sum_adm(domain, zsum1, zsum1_ad, is, ie, js, je, ng, &
2483 & gridstruct%area_64, 0, reproduce=.true., g_sum_ad=&
2489 CALL g_sum_adm(domain, zsum0, zsum0_ad, is, ie, js, je, ng, &
2490 & gridstruct%area_64, 0, reproduce=.true., g_sum_ad=&
2495 result1_ad = consv*tpe_ad
2496 CALL g_sum_adm(domain, te_2d, te_2d_ad, is, ie, js, je, ng, &
2497 & gridstruct%area_64, 0, reproduce=.true., g_sum_ad=&
2502 IF (branch .NE. 0)
THEN 2504 pk_ad(i, j, 1) = pk_ad(i, j, 1) + ptop*zsum0_ad(i, j)
2505 pk_ad(i, j, km+1) = pk_ad(i, j, km+1) - ptop*zsum0_ad(i, j)
2506 zsum1_ad(i, j) = zsum1_ad(i, j) + zsum0_ad(i, j)
2507 zsum0_ad(i, j) = 0.0
2512 pkz_ad(i, j, k) = pkz_ad(i, j, k) + delp(i, j, k)*zsum1_ad(i&
2514 delp_ad(i, j, k) = delp_ad(i, j, k) + pkz(i, j, k)*zsum1_ad(&
2519 pkz_ad(i, j, 1) = pkz_ad(i, j, 1) + delp(i, j, 1)*zsum1_ad(i, &
2521 delp_ad(i, j, 1) = delp_ad(i, j, 1) + pkz(i, j, 1)*zsum1_ad(i&
2523 zsum1_ad(i, j) = 0.0
2524 te0_2d_ad(i, j) = te0_2d_ad(i, j) + te_2d_ad(i, j)
2525 te_2d_ad(i, j) = -te_2d_ad(i, j)
2528 IF (branch .LT. 3)
THEN 2529 IF (branch .NE. 0)
THEN 2530 IF (branch .EQ. 1)
THEN 2533 te_ad(i, j, k) = te_ad(i, j, k) + delp(i, j, k)*&
2535 delp_ad(i, j, k) = delp_ad(i, j, k) + te(i, j, k)*&
2540 te_ad(i, j, 1) = te_ad(i, j, 1) + delp(i, j, 1)*te_2d_ad&
2542 delp_ad(i, j, 1) = delp_ad(i, j, 1) + te(i, j, 1)*&
2544 te_2d_ad(i, j) = 0.0
2549 temp32 = v(i, j, k) + v(i+1, j, k)
2550 temp31 = u(i, j, k) + u(i, j+1, k)
2551 temp30 = 0.5*gridstruct%rsin2(i, j)
2552 temp29 = r_vir*q(i, j, k, sphum) + 1.
2553 temp28 = pt(i, j, k)/temp29
2554 temp_ad29 = delp(i, j, k)*te_2d_ad(i, j)
2555 temp_ad30 =
cv_air*temp_ad29/temp29
2556 temp_ad31 = 0.5*temp_ad29
2557 temp_ad32 = temp30*temp_ad31
2558 temp_ad33 = -(gridstruct%cosa_s(i, j)*temp_ad32)
2559 delp_ad(i, j, k) = delp_ad(i, j, k) + (
cv_air*temp28+&
2560 & 0.5*(phis(i, k)+phis(i, k+1)+w(i, j, k)**2+temp30*(u&
2561 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j&
2562 & , k)**2-gridstruct%cosa_s(i, j)*(temp31*temp32))))*&
2564 pt_ad(i, j, k) = pt_ad(i, j, k) + temp_ad30
2565 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) - temp28*&
2567 phis_ad(i, k) = phis_ad(i, k) + temp_ad31
2568 phis_ad(i, k+1) = phis_ad(i, k+1) + temp_ad31
2569 w_ad(i, j, k) = w_ad(i, j, k) + 2*w(i, j, k)*temp_ad31
2570 u_ad(i, j, k) = u_ad(i, j, k) + temp32*temp_ad33 + 2*u&
2571 & (i, j, k)*temp_ad32
2572 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp32*temp_ad33 +&
2573 & 2*u(i, j+1, k)*temp_ad32
2574 v_ad(i, j, k) = v_ad(i, j, k) + temp31*temp_ad33 + 2*v&
2575 & (i, j, k)*temp_ad32
2576 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp31*temp_ad33 +&
2577 & 2*v(i+1, j, k)*temp_ad32
2581 te_2d_ad(i, j) = 0.0
2586 phis_ad(i, k+1) = phis_ad(i, k+1) + phis_ad(i, k)
2587 delz_ad(i, j, k) = delz_ad(i, j, k) -
grav*phis_ad(i, &
2592 phis_ad(i, km+1) = 0.0
2596 ELSE IF (branch .EQ. 3)
THEN 2599 temp27 = v(i, j, k) + v(i+1, j, k)
2600 temp26 = u(i, j, k) + u(i, j+1, k)
2601 temp25 = 0.25*gridstruct%rsin2(i, j)
2602 temp_ad26 = delp(i, j, k)*te_2d_ad(i, j)
2603 temp_ad27 = temp25*temp_ad26
2604 temp_ad28 = -(gridstruct%cosa_s(i, j)*temp_ad27)
2605 delp_ad(i, j, k) = delp_ad(i, j, k) + (
cp_air*(pt(i, j, k)&
2606 & *pkz(i, j, k))+temp25*(u(i, j, k)**2+u(i, j+1, k)**2+v(i&
2607 & , j, k)**2+v(i+1, j, k)**2-gridstruct%cosa_s(i, j)*(&
2608 & temp26*temp27)))*te_2d_ad(i, j)
2609 pt_ad(i, j, k) = pt_ad(i, j, k) +
cp_air*pkz(i, j, k)*&
2611 pkz_ad(i, j, k) = pkz_ad(i, j, k) +
cp_air*pt(i, j, k)*&
2613 u_ad(i, j, k) = u_ad(i, j, k) + temp27*temp_ad28 + 2*u(i, &
2615 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp27*temp_ad28 + 2*u&
2616 & (i, j+1, k)*temp_ad27
2617 v_ad(i, j, k) = v_ad(i, j, k) + temp26*temp_ad28 + 2*v(i, &
2619 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp26*temp_ad28 + 2*v&
2620 & (i+1, j, k)*temp_ad27
2624 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + hs(i, j)*te_2d_ad(i&
2626 pe_ad(i, 1, j) = pe_ad(i, 1, j) - gz(i)*te_2d_ad(i, j)
2627 gz_ad(i) = gz_ad(i) - pe(i, 1, j)*te_2d_ad(i, j)
2628 te_2d_ad(i, j) = 0.0
2632 temp_ad25 =
cp_air*pt(i, j, k)*gz_ad(i)
2633 pt_ad(i, j, k) = pt_ad(i, j, k) +
cp_air*(pk(i, j, k+1)-pk&
2634 & (i, j, k))*gz_ad(i)
2635 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp_ad25
2636 pk_ad(i, j, k) = pk_ad(i, j, k) - temp_ad25
2641 ELSE IF (branch .EQ. 4)
THEN 2644 temp24 = v(i, j, k) + v(i+1, j, k)
2645 temp23 = u(i, j, k) + u(i, j+1, k)
2646 temp22 = 0.5*gridstruct%rsin2(i, j)
2647 temp21 = r_vir*q(i, j, k, sphum) + 1.
2648 temp20 = pt(i, j, k)/temp21
2649 temp_ad20 = delp(i, j, k)*te_2d_ad(i, j)
2650 temp_ad21 =
cv_air*temp_ad20/temp21
2651 temp_ad22 = 0.5*temp_ad20
2652 temp_ad23 = temp22*temp_ad22
2653 temp_ad24 = -(gridstruct%cosa_s(i, j)*temp_ad23)
2654 delp_ad(i, j, k) = delp_ad(i, j, k) + (
cv_air*temp20+0.5*(&
2655 & phis(i, k)+phis(i, k+1)+w(i, j, k)**2+temp22*(u(i, j, k)&
2656 & **2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-&
2657 & gridstruct%cosa_s(i, j)*(temp23*temp24))))*te_2d_ad(i, j&
2659 pt_ad(i, j, k) = pt_ad(i, j, k) + temp_ad21
2660 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) - temp20*r_vir&
2662 phis_ad(i, k) = phis_ad(i, k) + temp_ad22
2663 phis_ad(i, k+1) = phis_ad(i, k+1) + temp_ad22
2664 w_ad(i, j, k) = w_ad(i, j, k) + 2*w(i, j, k)*temp_ad22
2665 u_ad(i, j, k) = u_ad(i, j, k) + temp24*temp_ad24 + 2*u(i, &
2667 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp24*temp_ad24 + 2*u&
2668 & (i, j+1, k)*temp_ad23
2669 v_ad(i, j, k) = v_ad(i, j, k) + temp23*temp_ad24 + 2*v(i, &
2671 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp23*temp_ad24 + 2*v&
2672 & (i+1, j, k)*temp_ad23
2678 phis_ad(i, k+1) = phis_ad(i, k+1) + phis_ad(i, k)
2679 delz_ad(i, j, k) = delz_ad(i, j, k) -
grav*phis_ad(i, k)
2685 phis_ad(i, km+1) = 0.0
2686 te_2d_ad(i, j) = 0.0
2691 temp19 = v(i, j, k) + v(i+1, j, k)
2692 temp18 = u(i, j, k) + u(i, j+1, k)
2693 temp17 = 0.25*gridstruct%rsin2(i, j)
2694 temp_ad17 = delp(i, j, k)*te_2d_ad(i, j)
2695 temp_ad18 = temp17*temp_ad17
2696 temp_ad19 = -(gridstruct%cosa_s(i, j)*temp_ad18)
2697 delp_ad(i, j, k) = delp_ad(i, j, k) + (cp*pt(i, j, k)+&
2698 & temp17*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
2699 & 1, j, k)**2-gridstruct%cosa_s(i, j)*(temp18*temp19)))*&
2701 pt_ad(i, j, k) = pt_ad(i, j, k) + cp*temp_ad17
2702 u_ad(i, j, k) = u_ad(i, j, k) + temp19*temp_ad19 + 2*u(i, &
2704 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp19*temp_ad19 + 2*u&
2705 & (i, j+1, k)*temp_ad18
2706 v_ad(i, j, k) = v_ad(i, j, k) + temp18*temp_ad19 + 2*v(i, &
2708 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp18*temp_ad19 + 2*v&
2709 & (i+1, j, k)*temp_ad18
2713 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + hs(i, j)*te_2d_ad(i&
2715 pe_ad(i, 1, j) = pe_ad(i, 1, j) - gz(i)*te_2d_ad(i, j)
2716 gz_ad(i) = gz_ad(i) - pe(i, 1, j)*te_2d_ad(i, j)
2717 te_2d_ad(i, j) = 0.0
2721 temp_ad16 = rg*pt(i, j, k)*gz_ad(i)
2722 pt_ad(i, j, k) = pt_ad(i, j, k) + rg*(peln(i, k+1, j)-peln&
2723 & (i, k, j))*gz_ad(i)
2724 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad16
2725 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad16
2733 ELSE IF (branch .EQ. 3)
THEN 2736 CALL g_sum_adm(domain, zsum1, zsum1_ad, is, ie, js, je, ng, &
2737 & gridstruct%area_64, 0, reproduce=.true., g_sum_ad=&
2740 ELSE IF (branch .EQ. 4)
THEN 2749 IF (branch .NE. 0)
THEN 2751 pk_ad(i, j, 1) = pk_ad(i, j, 1) + ptop*zsum0_ad(i, j)
2752 pk_ad(i, j, km+1) = pk_ad(i, j, km+1) - ptop*zsum0_ad(i, j)
2753 zsum1_ad(i, j) = zsum1_ad(i, j) + zsum0_ad(i, j)
2754 zsum0_ad(i, j) = 0.0
2759 pkz_ad(i, j, k) = pkz_ad(i, j, k) + delp(i, j, k)*zsum1_ad(i, &
2761 delp_ad(i, j, k) = delp_ad(i, j, k) + pkz(i, j, k)*zsum1_ad(i&
2766 pkz_ad(i, j, 1) = pkz_ad(i, j, 1) + delp(i, j, 1)*zsum1_ad(i, j)
2767 delp_ad(i, j, 1) = delp_ad(i, j, 1) + pkz(i, j, 1)*zsum1_ad(i, j&
2769 zsum1_ad(i, j) = 0.0
2777 ua_ad(i, j, k-1) = ua_ad(i, j, k-1) + pe_ad(i, k, j)
2778 pe_ad(i, k, j) = 0.0
2786 IF (branch .EQ. 0)
THEN 2831 DO i=ad_to58,ad_from33,-1
2833 pe2_ad(i, k+1) = pe2_ad(i, k+1) + ua_ad(i, j, k)
2834 ua_ad(i, j, k) = 0.0
2838 IF (branch .NE. 0)
THEN 2839 IF (branch .EQ. 1)
THEN 2841 CALL map1_ppm_bwd(km, pe0, pe0_ad, gz, gz_ad, km, pe3, &
2842 & pe3_ad, v, v_ad, is, iep1, j, isd, iedp1, jsd&
2843 & , jed, -1, kord_mt)
2847 CALL map1_ppm_adm(km, pe0, pe0_ad, gz, gz_ad, km, pe3, &
2848 & pe3_ad, v, v_ad, is, iep1, j, isd, iedp1, jsd, &
2849 & jed, -1, kord_mt_pert)
2855 DO i=ad_to56,ad_from32,-1
2857 pe_ad(i-1, km+1, j) = pe_ad(i-1, km+1, j) + bkh*pe3_ad(i, &
2859 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + bkh*pe3_ad(i, k)
2862 pe_ad(i-1, k, j) = pe_ad(i-1, k, j) + 0.5*pe0_ad(i, k)
2863 pe_ad(i, k, j) = pe_ad(i, k, j) + 0.5*pe0_ad(i, k)
2870 DO i=ad_to55,ad_from31,-1
2876 IF (branch .EQ. 0)
THEN 2878 CALL map1_ppm_bwd(km, pe0(is:ie, :), pe0_ad(is:ie, :), gz, &
2879 & gz_ad, km, pe3(is:ie, :), pe3_ad(is:ie, :), u, &
2880 & u_ad, is, ie, j, isd, ied, jsd, jedp1, -1, &
2885 CALL map1_ppm_adm(km, pe0(is:ie, :), pe0_ad(is:ie, :), gz, &
2886 & gz_ad, km, pe3(is:ie, :), pe3_ad(is:ie, :), u, &
2887 & u_ad, is, ie, j, isd, ied, jsd, jedp1, -1, &
2894 DO i=ad_to53,ad_from30,-1
2896 pe_ad(i, km+1, j-1) = pe_ad(i, km+1, j-1) + bkh*pe3_ad(i, k)
2897 pe1_ad(i, km+1) = pe1_ad(i, km+1) + bkh*pe3_ad(i, k)
2906 DO i=ad_to51,ad_from29,-1
2908 pe_ad(i, k, j-1) = pe_ad(i, k, j-1) + 0.5*pe0_ad(i, k)
2909 pe1_ad(i, k) = pe1_ad(i, k) + 0.5*pe0_ad(i, k)
2916 DO i=ad_to50,ad_from28,-1
2918 pe_ad(i, 1, j) = pe_ad(i, 1, j) + pe0_ad(i, 1)
2922 IF (branch .EQ. 0)
THEN 2925 IF (branch .NE. 1)
THEN 2928 DO i=ad_to49,ad_from27,-1
2932 IF (branch .EQ. 0)
THEN 2934 temp14 = pe0(i, k+1) - pe0(i, k)
2935 temp_ad14 = omga_ad(i, j, n)/temp14
2936 temp16 = dp2(i, n) - pe0(i, k)
2937 temp15 = pe3(i, k+1) - pe3(i, k)
2938 temp_ad15 = -(temp15*temp16*temp_ad14/temp14)
2939 pe3_ad(i, k) = pe3_ad(i, k) + omga_ad(i, j, n) - &
2941 pe3_ad(i, k+1) = pe3_ad(i, k+1) + temp16*temp_ad14
2942 dp2_ad(i, n) = dp2_ad(i, n) + temp15*temp_ad14
2943 pe0_ad(i, k) = pe0_ad(i, k) - temp_ad15 - temp15*&
2945 pe0_ad(i, k+1) = pe0_ad(i, k+1) + temp_ad15
2946 omga_ad(i, j, n) = 0.0
2959 DO i=ad_to46,ad_from26,-1
2961 peln_ad(i, k, j) = peln_ad(i, k, j) + 0.5*dp2_ad(i, k)
2962 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + 0.5*dp2_ad(i, &
2969 IF (branch .EQ. 0)
THEN 2974 DO i=ad_to40,ad_from23,-1
2976 temp7 = akap*(peln(i, k+1, j)-peln(i, k, j))
2977 temp_ad10 = pkz_ad(i, j, k)/temp7
2978 temp_ad11 = -((pk2(i, k+1)-pk2(i, k))*akap*temp_ad10/&
2980 pk2_ad(i, k+1) = pk2_ad(i, k+1) + temp_ad10
2981 pk2_ad(i, k) = pk2_ad(i, k) - temp_ad10
2982 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad11
2983 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad11
2984 pkz_ad(i, j, k) = 0.0
2987 ELSE IF (branch .EQ. 1)
THEN 2992 DO i=ad_to42,ad_from24,-1
2994 temp10 = delz(i, j, k)
2995 temp9 = delp(i, j, k)*pt(i, j, k)
2996 temp8 = temp9/temp10
2997 temp_ad12 = akap*exp(akap*log(rrg*temp8))*pkz_ad(i, j, k&
2999 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*&
3001 pt_ad(i, j, k) = pt_ad(i, j, k) + delp(i, j, k)*&
3003 delz_ad(i, j, k) = delz_ad(i, j, k) - temp8*temp_ad12
3004 pkz_ad(i, j, k) = 0.0
3012 DO i=ad_to44,ad_from25,-1
3014 temp13 = delz(i, j, k)
3015 temp12 = delp(i, j, k)*pt(i, j, k)
3016 temp11 = temp12/temp13
3017 temp_ad13 = k1k*exp(k1k*log(rrg*temp11))*pkz_ad(i, j, k)&
3019 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*&
3021 pt_ad(i, j, k) = pt_ad(i, j, k) + delp(i, j, k)*&
3023 delz_ad(i, j, k) = delz_ad(i, j, k) - temp11*temp_ad13
3024 pkz_ad(i, j, k) = 0.0
3034 DO i=ad_to38,ad_from22,-1
3036 pn2_ad(i, k) = pn2_ad(i, k) + peln_ad(i, k, j)
3037 peln_ad(i, k, j) = pe0_ad(i, k)
3043 IF (branch .NE. 0)
THEN 3048 DO i=ad_to36,ad_from21,-1
3050 omga_ad(i, j, k-1) = omga_ad(i, j, k-1) + pe3_ad(i, k)
3056 DO i=ad_to35,ad_from20,-1
3065 DO i=ad_to33,ad_from19,-1
3067 pk2_ad(i, k) = pk2_ad(i, k) + pk_ad(i, j, k)
3068 pk_ad(i, j, k) = 0.0
3072 IF (branch .NE. 0)
THEN 3077 DO i=ad_to31,ad_from18,-1
3079 dp2_ad(i, k) = dp2_ad(i, k) - delz(i, j, k)*delz_ad(i, j, k)
3080 delz_ad(i, j, k) = -(dp2(i, k)*delz_ad(i, j, k))
3084 IF (branch .EQ. 0)
THEN 3087 CALL map1_ppm_adm(km, pe1, pe1_ad, gz, gz_ad, km, pe2, pe2_ad&
3088 & , delz, delz_ad, is, ie, j, isd, ied, jsd, jed, 1&
3089 & , abs_kord_tm_pert)
3092 CALL map1_ppm_bwd(km, pe1, pe1_ad, gz, gz_ad, km, pe2, &
3093 & pe2_ad, delz, delz_ad, is, ie, j, isd, ied, jsd&
3094 & , jed, 1, abs_kord_tm)
3097 IF (branch .EQ. 0)
THEN 3098 CALL map1_ppm_bwd(km, pe1, pe1_ad, ws(is:ie, j), ws_ad(is:&
3099 & ie, j), km, pe2, pe2_ad, w, w_ad, is, ie, j, &
3100 & isd, ied, jsd, jed, -2, kord_wz)
3103 CALL map1_ppm_adm(km, pe1, pe1_ad, ws(is:ie, j), ws_ad(is:ie, &
3104 & j), km, pe2, pe2_ad, w, w_ad, is, ie, j, isd, ied&
3105 & , jsd, jed, -2, kord_wz_pert)
3109 IF (branch .LT. 2)
THEN 3110 IF (branch .EQ. 0)
THEN 3112 & q_ad, dp2, dp2_ad, kord_tr, j, is, ie, isd, &
3113 & ied, jsd, jed, 0., fill)
3117 & , dp2, dp2_ad, kord_tr_pert, j, is, ie, isd, &
3118 & ied, jsd, jed, 0., fill)
3120 ELSE IF (branch .EQ. 2)
THEN 3127 DO i=ad_to28,ad_from17,-1
3129 q2_ad(i, k) = q2_ad(i, k) + q_ad(i, j, k, iq)
3130 q_ad(i, j, k, iq) = 0.0
3134 IF (branch .EQ. 0)
THEN 3135 CALL map1_q2_bwd(km, pe1, pe1_ad, q(isd:ied, jsd:jed, 1:&
3136 & km, iq), q_ad(isd:ied, jsd:jed, 1:km, iq), km&
3137 & , pe2, pe2_ad, q2, q2_ad, dp2, dp2_ad, is, ie&
3138 & , 0, kord_tr(iq), j, isd, ied, jsd, jed, 0.)
3140 CALL map1_q2_adm(km, pe1, pe1_ad, q(isd:ied, jsd:jed, 1:km, &
3141 & iq), q_ad(isd:ied, jsd:jed, 1:km, iq), km, pe2, &
3142 & pe2_ad, q2, q2_ad, dp2, dp2_ad, is, ie, 0, &
3143 & kord_tr_pert(iq), j, isd, ied, jsd, jed, 0.)
3148 IF (branch .LT. 3)
THEN 3149 IF (branch .EQ. 0)
THEN 3151 & ie, 1:km+1, j), gz, km, pn2, pn2_ad, pt, &
3152 & pt_ad, is, ie, j, isd, ied, jsd, jed, 1, &
3153 & abs_kord_tm,
t_min)
3154 ELSE IF (branch .EQ. 1)
THEN 3157 & , 1:km+1, j), gz, km, pn2, pn2_ad, pt, pt_ad, is&
3158 & , ie, j, isd, ied, jsd, jed, 1, abs_kord_tm_pert&
3162 CALL map1_ppm_bwd(km, pe1, pe1_ad, gz, gz_ad, km, pe2, &
3163 & pe2_ad, pt, pt_ad, is, ie, j, isd, ied, jsd, &
3164 & jed, 1, abs_kord_tm)
3166 ELSE IF (branch .EQ. 3)
THEN 3169 CALL map1_ppm_adm(km, pe1, pe1_ad, gz, gz_ad, km, pe2, pe2_ad, &
3170 & pt, pt_ad, is, ie, j, isd, ied, jsd, jed, 1, &
3172 ELSE IF (branch .EQ. 4)
THEN 3174 & , is, ie, j, isd, ied, jsd, jed, akap, t_var=1, &
3180 DO i=ad_to26,ad_from16,-1
3182 temp6 = pe1(i, k+1) - pe1(i, k)
3183 temp_ad8 = te_ad(i, j, k)/temp6
3184 temp_ad9 = -((phis(i, k+1)-phis(i, k))*temp_ad8/temp6)
3185 phis_ad(i, k+1) = phis_ad(i, k+1) + temp_ad8
3186 phis_ad(i, k) = phis_ad(i, k) - temp_ad8
3187 pe1_ad(i, k+1) = pe1_ad(i, k+1) + temp_ad9
3188 pe1_ad(i, k) = pe1_ad(i, k) - temp_ad9
3195 DO i=ad_to24,ad_from15,-1
3197 pe1_ad(i, k) = pe1_ad(i, k) + phis(i, k)*phis_ad(i, k)
3198 phis_ad(i, k) = pe1(i, k)*phis_ad(i, k)
3205 DO i=ad_to23,ad_from13,-1
3207 temp_ad7 =
cp_air*pt(i, j, k)*phis_ad(i, k)
3208 phis_ad(i, k+1) = phis_ad(i, k+1) + phis_ad(i, k)
3209 pt_ad(i, j, k) = pt_ad(i, j, k) +
cp_air*(pk1(i, k+1)-pk1(i&
3210 & , k))*phis_ad(i, k)
3211 pk1_ad(i, k+1) = pk1_ad(i, k+1) + temp_ad7
3212 pk1_ad(i, k) = pk1_ad(i, k) - temp_ad7
3218 DO i=ad_to22,ad_from12,-1
3220 phis_ad(i, km+1) = 0.0
3227 DO i=ad_to20,ad_from11,-1
3229 pn2_ad(i, k) = pn2_ad(i, k) + exp(akap*pn2(i, k))*akap*pk2_ad(&
3233 pe2_ad(i, k) = pe2_ad(i, k) + pn2_ad(i, k)/pe2(i, k)
3239 DO i=ad_to19,ad_from10,-1
3241 pk1_ad(i, km+1) = pk1_ad(i, km+1) + pk2_ad(i, km+1)
3242 pk2_ad(i, km+1) = 0.0
3244 pk1_ad(i, 1) = pk1_ad(i, 1) + pk2_ad(i, 1)
3247 peln_ad(i, km+1, j) = peln_ad(i, km+1, j) + pn2_ad(i, km+1)
3248 pn2_ad(i, km+1) = 0.0
3250 peln_ad(i, 1, j) = peln_ad(i, 1, j) + pn2_ad(i, 1)
3257 DO i=ad_to17,ad_from9,-1
3259 pk_ad(i, j, k) = pk_ad(i, j, k) + pk1_ad(i, k)
3267 DO i=ad_to15,ad_from8,-1
3269 dp2_ad(i, k) = dp2_ad(i, k) + delp_ad(i, j, k)
3270 delp_ad(i, j, k) = 0.0
3277 DO i=ad_to13,ad_from7,-1
3279 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp2_ad(i, k)
3280 pe2_ad(i, k) = pe2_ad(i, k) - dp2_ad(i, k)
3288 DO i=ad_to11,ad_from6,-1
3290 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + bk(k)*pe2_ad(i, k)
3296 DO i=ad_to10,ad_from5,-1
3297 pe1_ad(i, km+1) = pe1_ad(i, km+1) + ps_ad(i, j)
3301 IF (branch .NE. 0)
THEN 3306 DO i=ad_to8,ad_from4,-1
3308 temp_ad6 = -(delz_ad(i, j, k)/delp(i, j, k))
3309 delp_ad(i, j, k) = delp_ad(i, j, k) - delz(i, j, k)*temp_ad6&
3311 delz_ad(i, j, k) = temp_ad6
3316 IF (branch .LT. 2)
THEN 3317 IF (branch .EQ. 0)
THEN 3322 DO i=ad_to2,ad_from1,-1
3324 temp1 = akap*(peln(i, k+1, j)-peln(i, k, j))
3325 temp_ad = pt_ad(i, j, k)/temp1
3326 temp0 = pk(i, j, k+1) - pk(i, j, k)
3328 temp_ad0 = -(temp*temp0*akap*temp_ad/temp1)
3329 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp*temp_ad
3330 pk_ad(i, j, k) = pk_ad(i, j, k) - temp*temp_ad
3331 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad0
3332 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad0
3333 pt_ad(i, j, k) = temp0*temp_ad
3341 DO i=ad_to4,ad_from2,-1
3343 temp5 = delz(i, j, k)
3344 temp4 = delp(i, j, k)*pt(i, j, k)
3346 temp3 = k1k*log(rrg*temp2)
3347 temp_ad1 = k1k*exp(temp3)*pt(i, j, k)*pt_ad(i, j, k)/(&
3349 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*temp_ad1
3350 delz_ad(i, j, k) = delz_ad(i, j, k) - temp2*temp_ad1
3351 pt_ad(i, j, k) = delp(i, j, k)*temp_ad1 + exp(temp3)*pt_ad&
3356 ELSE IF (branch .NE. 2)
THEN 3357 IF (branch .EQ. 3)
THEN 3362 DO i=ad_to6,ad_from3,-1
3364 temp_ad2 = gridstruct%rsin2(i, j)*0.25*te_ad(i, j, k)
3365 temp_ad3 = -(gridstruct%cosa_s(i, j)*temp_ad2)
3366 temp_ad4 = (v(i, j, k)+v(i+1, j, k))*temp_ad3
3367 temp_ad5 = (u(i, j, k)+u(i, j+1, k))*temp_ad3
3368 u_ad(i, j, k) = u_ad(i, j, k) + temp_ad4 + 2*u(i, j, k)*&
3370 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp_ad4 + 2*u(i, j+1&
3372 v_ad(i, j, k) = v_ad(i, j, k) + temp_ad5 + 2*v(i, j, k)*&
3374 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp_ad5 + 2*v(i+1, j&
3376 pt_ad(i, j, k) = pt_ad(i, j, k) +
cp_air*pkz(i, j, k)*&
3378 pkz_ad(i, j, k) = pkz_ad(i, j, k) +
cp_air*pt(i, j, k)*&
3380 te_ad(i, j, k) = 0.0
3383 CALL pkez_bwd(km, is, ie, js, je, j, pe, pk, pk_ad, akap, peln&
3384 & , peln_ad, pkz, pkz_ad, ptop)
3389 DO i=ad_to1,ad_from0,-1
3391 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + pe2_ad(i, km+1)
3392 pe2_ad(i, km+1) = 0.0
3400 DO i=ad_to,ad_from,-1
3402 pe_ad(i, k, j) = pe_ad(i, k, j) + pe1_ad(i, k)
3409 IF (branch .NE. 0)
THEN 3418 & , pk, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, &
3419 & sphum, q_con, u, v, w, delz, pt, q, hs, r_vir, cp, akap, cappa, &
3420 & kord_mt, kord_wz, kord_tr, kord_tm, peln, te0_2d, ng, ua, va, omga, &
3421 & te, ws, fill, reproduce_sum, out_dt, dtdt, ptop, ak, bk, pfull, &
3422 & flagstruct, gridstruct, domain, do_sat_adj, hydrostatic, hybrid_z, &
3423 & do_omega, adiabatic, do_adiabatic_init, mfx, mfy, remap_option, &
3424 & kord_mt_pert, kord_wz_pert, kord_tr_pert, kord_tm_pert)
3427 LOGICAL,
INTENT(IN) :: last_step
3429 REAL,
INTENT(IN) :: mdt
3431 REAL,
INTENT(IN) :: pdt
3432 INTEGER,
INTENT(IN) :: km
3434 INTEGER,
INTENT(IN) :: nq
3435 INTEGER,
INTENT(IN) :: nwat
3437 INTEGER,
INTENT(IN) :: sphum
3438 INTEGER,
INTENT(IN) :: ng
3440 INTEGER,
INTENT(IN) :: is, ie, isd, ied
3442 INTEGER,
INTENT(IN) :: js, je, jsd, jed
3444 INTEGER,
INTENT(IN) :: kord_mt
3446 INTEGER,
INTENT(IN) :: kord_wz
3448 INTEGER,
INTENT(IN) :: kord_tr(nq)
3450 INTEGER,
INTENT(IN) :: kord_tm
3452 INTEGER,
INTENT(IN) :: kord_mt_pert
3454 INTEGER,
INTENT(IN) :: kord_wz_pert
3456 INTEGER,
INTENT(IN) :: kord_tr_pert(nq)
3458 INTEGER,
INTENT(IN) :: kord_tm_pert
3460 REAL,
INTENT(IN) :: consv
3461 REAL,
INTENT(IN) :: r_vir
3462 REAL,
INTENT(IN) :: cp
3463 REAL,
INTENT(IN) :: akap
3465 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
3466 REAL,
INTENT(INOUT) :: te0_2d(is:ie, js:je)
3467 REAL,
INTENT(IN) :: ws(is:ie, js:je)
3468 LOGICAL,
INTENT(IN) :: do_sat_adj
3470 LOGICAL,
INTENT(IN) :: fill
3471 LOGICAL,
INTENT(IN) :: reproduce_sum
3472 LOGICAL,
INTENT(IN) :: do_omega, adiabatic, do_adiabatic_init
3473 REAL,
INTENT(IN) :: ptop
3474 REAL,
INTENT(IN) :: ak(km+1)
3475 REAL,
INTENT(IN) :: bk(km+1)
3476 REAL,
INTENT(IN) :: pfull(km)
3479 TYPE(
domain2d),
INTENT(INOUT) :: domain
3482 REAL,
INTENT(INOUT) :: pk(is:ie, js:je, km+1)
3483 REAL,
INTENT(INOUT) :: q(isd:ied, jsd:jed, km, nq)
3485 REAL,
INTENT(INOUT) :: delp(isd:ied, jsd:jed, km)
3487 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
3489 REAL,
INTENT(INOUT) :: ps(isd:ied, jsd:jed)
3492 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
3494 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
3496 REAL,
INTENT(INOUT) :: w(isd:ied, jsd:jed, km)
3498 REAL,
INTENT(INOUT) :: pt(isd:ied, jsd:jed, km)
3500 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: delz
3501 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: q_con, cappa
3502 LOGICAL,
INTENT(IN) :: hydrostatic
3503 LOGICAL,
INTENT(IN) :: hybrid_z
3504 LOGICAL,
INTENT(IN) :: out_dt
3506 REAL,
INTENT(INOUT) :: ua(isd:ied, jsd:jed, km)
3508 REAL,
INTENT(INOUT) :: va(isd:ied, jsd:jed, km)
3510 REAL,
INTENT(INOUT) :: omga(isd:ied, jsd:jed, km)
3512 REAL,
INTENT(INOUT) :: peln(is:ie, km+1, js:je)
3513 REAL,
INTENT(INOUT) :: dtdt(is:ie, js:je, km)
3515 REAL,
INTENT(OUT) :: pkz(is:ie, js:je, km)
3516 REAL,
INTENT(OUT) :: te(isd:ied, jsd:jed, km)
3519 REAL,
OPTIONAL,
INTENT(INOUT) :: mfx(is:ie+1, js:je, km)
3521 REAL,
OPTIONAL,
INTENT(INOUT) :: mfy(is:ie, js:je+1, km)
3523 INTEGER,
INTENT(IN) :: remap_option
3532 REAL,
DIMENSION(is:ie, js:je) :: te_2d, zsum0, zsum1, dpln
3533 REAL,
DIMENSION(is:ie, km) :: q2, dp2
3534 REAL,
DIMENSION(is:ie, km+1) :: pe1, pe2, pk1, pk2, pn2, phis
3535 REAL,
DIMENSION(is:ie+1, km+1) :: pe0, pe3
3536 REAL,
DIMENSION(is:ie) :: gz, cvm, qv
3537 REAL :: rcp, rg, tmp, tpe, rrg, bkh, dtmp, k1k, dlnp
3538 LOGICAL :: fast_mp_consv
3540 INTEGER :: nt, liq_wat, ice_wat, rainwat, snowwat, cld_amt, graupel&
3541 & , iq, n, kmp, kp, k_next
3542 LOGICAL :: remap_t, remap_pt, remap_te
3543 INTEGER :: abs_kord_tm, abs_kord_tm_pert
3544 INTEGER :: iep1, jep1, iedp1, jedp1
3553 IF (kord_tm .GE. 0.)
THEN 3554 abs_kord_tm = kord_tm
3556 abs_kord_tm = -kord_tm
3558 IF (kord_tm_pert .GE. 0.)
THEN 3559 abs_kord_tm_pert = kord_tm_pert
3561 abs_kord_tm_pert = -kord_tm_pert
3570 SELECT CASE (remap_option)
3578 print*,
' INVALID REMAPPING OPTION ' 3581 IF (is_master() .AND. flagstruct%fv_debug)
THEN 3583 SELECT CASE (remap_option)
3585 print*,
' REMAPPING T in logP ' 3587 print*,
' REMAPPING PT in P' 3589 print*,
' REMAPPING TE in logP with GMAO cubic' 3591 print*,
' REMAPPING CONSV: ', consv
3592 print*,
' REMAPPING CONSV_MIN: ',
consv_min 3595 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-0 PT', pt, is, ie, js&
3596 & , je, ng, km, 1., gridstruct%area_64&
3603 IF (
fpp%fpp_mapl_mode)
THEN 3618 IF (do_sat_adj)
THEN 3619 fast_mp_consv = .NOT.do_adiabatic_init .AND. consv .GT.
consv_min 3622 IF (pfull(k) .GT. 10.e2)
GOTO 100
3637 pe1(i, k) = pe(i, k, j)
3642 pe2(i, km+1) = pe(i, km+1, j)
3645 IF (j .NE. je + 1)
THEN 3650 IF (hydrostatic)
THEN 3654 pt(i, j, k) = pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k))/(&
3655 & akap*(peln(i, k+1, j)-peln(i, k, j)))
3662 pt(i, j, k) = pt(i, j, k)*exp(k1k*log(rrg*delp(i, j, k)/&
3663 & delz(i, j, k)*pt(i, j, k)))
3667 ELSE IF (.NOT.remap_pt)
THEN 3676 CALL pkez(km, is, ie, js, je, j, pe, pk, akap, peln, pkz, &
3681 te(i, j, k) = 0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2&
3682 & +u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j&
3683 & , k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
3684 & gridstruct%cosa_s(i, j)) +
cp_air*pt(i, j, k)*pkz(i, j&
3690 IF (.NOT.hydrostatic)
THEN 3694 delz(i, j, k) = -(delz(i, j, k)/delp(i, j, k))
3700 ps(i, j) = pe1(i, km+1)
3707 pe2(i, k) = ak(k) + bk(k)*pe(i, km+1, j)
3712 dp2(i, k) = pe2(i, k+1) - pe2(i, k)
3720 delp(i, j, k) = dp2(i, k)
3728 pk1(i, k) = pk(i, j, k)
3732 pn2(i, 1) = peln(i, 1, j)
3733 pn2(i, km+1) = peln(i, km+1, j)
3734 pk2(i, 1) = pk1(i, 1)
3735 pk2(i, km+1) = pk1(i, km+1)
3739 pn2(i, k) = log(pe2(i, k))
3740 pk2(i, k) = exp(akap*pn2(i, k))
3747 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 3748 CALL map_scalar(km, peln(is:ie, 1:km+1, j), gz, km, pn2, &
3749 & pt, is, ie, j, isd, ied, jsd, jed, 1, &
3750 & abs_kord_tm,
t_min)
3752 CALL map_scalar(km, peln(is:ie, 1:km+1, j), gz, km, pn2, pt&
3753 & , is, ie, j, isd, ied, jsd, jed, 1, &
3754 & abs_kord_tm_pert,
t_min)
3756 ELSE IF (remap_pt)
THEN 3760 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 3761 CALL map1_ppm(km, pe1, gz, km, pe2, pt, is, ie, j, isd, &
3762 & ied, jsd, jed, 1, abs_kord_tm)
3764 CALL map1_ppm(km, pe1, gz, km, pe2, pt, is, ie, j, isd, ied&
3765 & , jsd, jed, 1, abs_kord_tm_pert)
3767 ELSE IF (remap_te)
THEN 3772 phis(i, km+1) = hs(i, j)
3776 phis(i, k) = phis(i, k+1) +
cp_air*pt(i, j, k)*(pk1(i, k+1&
3782 phis(i, k) = phis(i, k)*pe1(i, k)
3787 te(i, j, k) = te(i, j, k) + (phis(i, k+1)-phis(i, k))/(pe1&
3788 & (i, k+1)-pe1(i, k))
3792 CALL map1_cubic(km, pe1, km, pe2, te, is, ie, j, isd, ied, jsd&
3793 & , jed, akap, 1, .true.)
3799 IF (kord_tr(1) .EQ. kord_tr_pert(1))
THEN 3800 CALL mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr, j, is&
3801 & , ie, isd, ied, jsd, jed, 0., fill)
3803 CALL mapn_tracer(nq, km, pe1, pe2, q, dp2, kord_tr_pert, j, &
3804 & is, ie, isd, ied, jsd, jed, 0., fill)
3806 ELSE IF (nq .GT. 0)
THEN 3809 IF (kord_tr(iq) .EQ. kord_tr_pert(iq))
THEN 3810 CALL map1_q2(km, pe1, q(isd:ied, jsd:jed, 1:km, iq), km&
3811 & , pe2, q2, dp2, is, ie, 0, kord_tr(iq), j, isd, &
3812 & ied, jsd, jed, 0.)
3814 CALL map1_q2(km, pe1, q(isd:ied, jsd:jed, 1:km, iq), km, &
3815 & pe2, q2, dp2, is, ie, 0, kord_tr_pert(iq), j, isd, &
3816 & ied, jsd, jed, 0.)
3820 CALL fillz(arg1, km, 1, q2, dp2)
3824 q(i, j, k, iq) = q2(i, k)
3829 IF (.NOT.hydrostatic)
THEN 3831 IF (kord_wz .EQ. kord_wz_pert)
THEN 3832 CALL map1_ppm(km, pe1, ws(is:ie, j), km, pe2, w, is, ie, &
3833 & j, isd, ied, jsd, jed, -2, kord_wz)
3835 CALL map1_ppm(km, pe1, ws(is:ie, j), km, pe2, w, is, ie, j, &
3836 & isd, ied, jsd, jed, -2, kord_wz_pert)
3839 IF (abs_kord_tm .EQ. abs_kord_tm_pert)
THEN 3840 CALL map1_ppm(km, pe1, gz, km, pe2, delz, is, ie, j, isd&
3841 & , ied, jsd, jed, 1, abs_kord_tm)
3843 CALL map1_ppm(km, pe1, gz, km, pe2, delz, is, ie, j, isd, &
3844 & ied, jsd, jed, 1, abs_kord_tm_pert)
3848 delz(i, j, k) = -(delz(i, j, k)*dp2(i, k))
3857 pk(i, j, k) = pk2(i, k)
3869 pe3(i, k) = omga(i, j, k-1)
3875 pe0(i, k) = peln(i, k, j)
3876 peln(i, k, j) = pn2(i, k)
3882 IF (hydrostatic)
THEN 3885 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1&
3886 & , j)-peln(i, k, j)))
3889 ELSE IF (remap_te)
THEN 3892 &
'TE remapping non-hydrostatic is invalid and cannot be run' 3894 ELSE IF (remap_t)
THEN 3898 pkz(i, j, k) = exp(akap*log(rrg*delp(i, j, k)/delz(i, j, k&
3908 pkz(i, j, k) = exp(k1k*log(rrg*delp(i, j, k)/delz(i, j, k)&
3918 dp2(i, k) = 0.5*(peln(i, k, j)+peln(i, k+1, j))
3926 IF (dp2(i, n) .LE. pe0(i, k+1) .AND. dp2(i, n) .GE. pe0(&
3928 omga(i, j, n) = pe3(i, k) + (pe3(i, k+1)-pe3(i, k))*(&
3929 & dp2(i, n)-pe0(i, k))/(pe0(i, k+1)-pe0(i, k))
3939 pe0(i, 1) = pe(i, 1, j)
3946 pe0(i, k) = 0.5*(pe(i, k, j-1)+pe1(i, k))
3952 pe3(i, k) = ak(k) + bkh*(pe(i, km+1, j-1)+pe1(i, km+1))
3955 IF (kord_mt .EQ. kord_mt_pert)
THEN 3956 CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:ie, :), u, is&
3957 & , ie, j, isd, ied, jsd, jedp1, -1, kord_mt)
3959 CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:ie, :), u, is, &
3960 & ie, j, isd, ied, jsd, jedp1, -1, kord_mt_pert)
3962 IF (
PRESENT(mfy))
CALL map1_ppm(km, pe0(is:ie, :), gz, km, pe3(is:&
3963 & ie, :), mfy, is, ie, j, is, ie, js, jep1&
3966 IF (j .LT. je + 1)
THEN 3976 pe0(i, k) = 0.5*(pe(i-1, k, j)+pe(i, k, j))
3977 pe3(i, k) = ak(k) + bkh*(pe(i-1, km+1, j)+pe(i, km+1, j))
3980 IF (kord_mt .EQ. kord_mt_pert)
THEN 3981 CALL map1_ppm(km, pe0, gz, km, pe3, v, is, iep1, j, isd, &
3982 & iedp1, jsd, jed, -1, kord_mt)
3984 CALL map1_ppm(km, pe0, gz, km, pe3, v, is, iep1, j, isd, iedp1&
3985 & , jsd, jed, -1, kord_mt_pert)
3987 IF (
PRESENT(mfx))
CALL map1_ppm(km, pe0, gz, km, pe3, mfx, is, &
3988 & iep1, j, is, iep1, js, je, -1, kord_mt&
3993 ua(i, j, k) = pe2(i, k+1)
4010 pe(i, k, j) = ua(i, j, k-1)
4014 IF (flagstruct%fv_debug)
THEN 4015 IF (kord_tm .LT. 0)
THEN 4016 CALL prt_mxm(
'remap-1 TV', pt, is, ie, js, je, ng, km, 1., &
4017 & gridstruct%area_64, domain)
4019 CALL prt_mxm(
'remap-1 PT', pt, is, ie, js, je, ng, km, 1., &
4020 & gridstruct%area_64, domain)
4025 IF (last_step .AND. (.NOT.do_adiabatic_init))
THEN 4032 IF (hydrostatic)
THEN 4036 gz(i) = gz(i) + rg*pt(i, j, k)*(peln(i, k+1, j)-peln(i&
4041 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
4046 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*pt(i, j&
4047 & , k)+0.25*gridstruct%rsin2(i, j)*(u(i, j, k)**2+u(i&
4048 & , j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-(u(i, j, &
4049 & k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
4050 & gridstruct%cosa_s(i, j)))
4056 phis(i, km+1) = hs(i, j)
4060 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
4065 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
4066 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
4067 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
4068 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
4069 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
4070 & i+1, j, k))*gridstruct%cosa_s(i, j))))
4074 ELSE IF (remap_pt)
THEN 4076 IF (hydrostatic)
THEN 4080 gz(i) = gz(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i&
4085 te_2d(i, j) = pe(i, km+1, j)*hs(i, j) - pe(i, 1, j)*gz(i&
4090 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cp_air*pt(i&
4091 & , j, k)*pkz(i, j, k)+0.25*gridstruct%rsin2(i, j)*(u(&
4092 & i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, &
4093 & k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j&
4094 & , k))*gridstruct%cosa_s(i, j)))
4102 phis(i, km+1) = hs(i, j)
4104 phis(i, k) = phis(i, k+1) -
grav*delz(i, j, k)
4112 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i&
4113 & , j, k)/(1.+r_vir*q(i, j, k, sphum))+0.5*(phis(i, k)&
4114 & +phis(i, k+1)+w(i, j, k)**2+0.5*gridstruct%rsin2(i, &
4115 & j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+&
4116 & 1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(&
4117 & i+1, j, k))*gridstruct%cosa_s(i, j))))
4121 ELSE IF (remap_te)
THEN 4123 te_2d(i, j) = te(i, j, 1)*delp(i, j, 1)
4127 te_2d(i, j) = te_2d(i, j) + te(i, j, k)*delp(i, j, k)
4132 te_2d(i, j) = te0_2d(i, j) - te_2d(i, j)
4133 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
4137 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
4140 IF (hydrostatic)
THEN 4142 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
4149 result1 = g_sum(domain, te_2d, is, ie, js, je, ng, gridstruct%&
4150 & area_64, 0, .true.)
4155 IF (hydrostatic)
THEN 4156 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
4157 & area_64, 0, .true.)
4158 dtmp = tpe/(cp*result1)
4160 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
4161 & area_64, 0, .true.)
4162 dtmp = tpe/(
cv_air*result1)
4169 zsum1(i, j) = pkz(i, j, 1)*delp(i, j, 1)
4173 zsum1(i, j) = zsum1(i, j) + pkz(i, j, k)*delp(i, j, k)
4176 IF (hydrostatic)
THEN 4178 zsum0(i, j) = ptop*(pk(i, j, 1)-pk(i, j, km+1)) + zsum1(i&
4185 IF (hydrostatic)
THEN 4186 result1 = g_sum(domain, zsum0, is, ie, js, je, ng, gridstruct%&
4187 & area_64, 0, .true.)
4190 result1 = g_sum(domain, zsum1, is, ie, js, je, ng, gridstruct%&
4191 & area_64, 0, .true.)
4199 IF (remap_t .AND. (.NOT.do_adiabatic_init) .AND. do_sat_adj)
THEN 4206 dpln(i, j) = peln(i, k+1, j) - peln(i, k, j)
4209 IF (mdt .GE. 0.)
THEN 4214 arg10 = cld_amt .GT. 0
4215 CALL fv_sat_adj(abs0, r_vir, is, ie, js, je, ng, hydrostatic, &
4216 & fast_mp_consv, te(isd:ied, jsd:jed, k), q(isd:ied, jsd&
4217 & :jed, k, sphum), q(isd:ied, jsd:jed, k, liq_wat), q(&
4218 & isd:ied, jsd:jed, k, ice_wat), q(isd:ied, jsd:jed, k, &
4219 & rainwat), q(isd:ied, jsd:jed, k, snowwat), q(isd:ied, &
4220 & jsd:jed, k, graupel), dpln, delz(isd:ied, jsd:jed, k)&
4221 & , pt(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k), &
4222 & q_con(isd:ied, jsd:jed, k), cappa(isd:ied, jsd:jed, k)&
4223 & , gridstruct%area_64, dtdt(is:ie, js:je, k), out_dt, &
4224 & last_step, arg10, q(isd:ied, jsd:jed, k, cld_amt))
4225 IF (.NOT.hydrostatic)
THEN 4228 pkz(i, j, k) = exp(akap*log(rrg*delp(i, j, k)/delz(i, j, k&
4235 IF (fast_mp_consv)
THEN 4240 te0_2d(i, j) = te0_2d(i, j) + te(i, j, k)
4254 IF (.NOT.adiabatic)
THEN 4256 pt(i, j, k) = (pt(i, j, k)+dtmp*pkz(i, j, k))/(1.+r_vir*&
4257 & q(i, j, k, sphum))
4262 ELSE IF (remap_pt)
THEN 4269 pt(i, j, k) = (pt(i, j, k)+dtmp)*pkz(i, j, k)/(1.+r_vir*q(&
4274 ELSE IF (remap_te)
THEN 4282 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
4283 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
4284 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
4285 & gridstruct%cosa_s(i, j))
4286 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
4287 tmp = tpe/((cp-pe(i, k, j)*dlnp/delp(i, j, k))*(1.+r_vir*q&
4288 & (i, j, k, sphum)))
4289 pt(i, j, k) = tmp + dtmp*pkz(i, j, k)/(1.+r_vir*q(i, j, k&
4291 gz(i) = gz(i) + dlnp*tmp*(1.+r_vir*q(i, j, k, sphum))
4297 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 TA', pt, is, ie, &
4298 & js, je, ng, km, 1., gridstruct%&
4307 pt(i, j, k) = pt(i, j, k)/pkz(i, j, k)
4311 ELSE IF (remap_te)
THEN 4319 tpe = te(i, j, k) - gz(i) - 0.25*gridstruct%rsin2(i, j)*(u&
4320 & (i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)&
4321 & **2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i+1, j, k))*&
4322 & gridstruct%cosa_s(i, j))
4323 dlnp = rg*(peln(i, k+1, j)-peln(i, k, j))
4324 tmp = tpe/(cp-pe(i, k, j)*dlnp/delp(i, j, k))
4325 pt(i, j, k) = tmp/pkz(i, j, k) + dtmp
4326 gz(i) = gz(i) + dlnp*tmp
4332 IF (flagstruct%fv_debug)
CALL prt_mxm(
'remap-3 PT', pt, is, ie, &
4333 & js, je, ng, km, 1., gridstruct%&
4360 & , km, u, v, w, delz, pt, delp, q, qc, pe, peln, hs, rsin2_l, &
4361 & cosa_s_l, r_vir, cp, rg, hlv, te_2d, ua, va, teq, moist_phys, nwat, &
4362 & sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, &
4369 INTEGER,
INTENT(IN) :: km, is, ie, js, je, isd, ied, jsd, jed, id_te
4370 INTEGER,
INTENT(IN) :: sphum, liq_wat, ice_wat, rainwat, snowwat, &
4372 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: ua, va
4373 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt, delp
4374 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q
4375 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc
4376 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
4377 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
4379 REAL,
INTENT(IN) :: w(isd:ied, jsd:jed, km)
4380 REAL,
INTENT(IN) :: delz(isd:ied, jsd:jed, km)
4382 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
4384 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
4386 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
4387 REAL,
INTENT(IN) :: cp, rg, r_vir,
hlv 4388 REAL,
INTENT(IN) :: rsin2_l(isd:ied, jsd:jed)
4389 REAL,
INTENT(IN) :: cosa_s_l(isd:ied, jsd:jed)
4390 LOGICAL,
INTENT(IN) :: moist_phys, hydrostatic
4393 REAL :: te_2d(is:ie, js:je)
4395 REAL :: teq(is:ie, js:je)
4397 REAL,
DIMENSION(is:ie, km) :: tv
4398 REAL :: phiz(is:ie, km+1)
4399 REAL :: cvm(is:ie), qd(is:ie)
4416 IF (hydrostatic)
THEN 4419 phiz(i, km+1) = hs(i, j)
4424 tv(i, k) = pt(i, j, k)*(1.+qc(i, j, k))
4426 phiz(i, k) = phiz(i, k+1) + rg*tv(i, k)*(peln(i, k+1, j)-&
4431 te_2d(i, j) = pe(i, km+1, j)*phiz(i, km+1) - pe(i, 1, j)*phiz(&
4436 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*tv(i, k)+0.25*&
4437 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2&
4438 & +v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i&
4439 & +1, j, k))*cosa_s_l(i, j)))
4449 phiz(i, km+1) = hs(i, j)
4452 phiz(i, k) = phiz(i, k+1) -
grav*delz(i, j, k)
4458 IF (moist_phys)
THEN 4461 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
4462 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
4463 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
4464 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
4465 & )+v(i+1, j, k))*cosa_s_l(i, j))))
4472 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
4473 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
4474 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
4475 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
4476 & )+v(i+1, j, k))*cosa_s_l(i, j))))
4486 IF (id_te .GT. 0)
THEN 4490 teq(i, j) = te_2d(i, j)
4492 IF (moist_phys)
THEN 4495 teq(i, j) = teq(i, j) +
hlv*q(i, j, k, sphum)*delp(i, j, k&
4536 & , km, u, u_ad, v, v_ad, w, w_ad, delz, delz_ad, pt, pt_ad, delp, &
4537 & delp_ad, q, q_ad, qc, qc_ad, pe, pe_ad, peln, peln_ad, hs, rsin2_l, &
4538 & cosa_s_l, r_vir, cp, rg, hlv, te_2d, te_2d_ad, ua, va, teq, teq_ad, &
4539 & moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel&
4540 & , hydrostatic, id_te)
4542 INTEGER,
INTENT(IN) :: km, is, ie, js, je, isd, ied, jsd, jed, id_te
4543 INTEGER,
INTENT(IN) :: sphum, liq_wat, ice_wat, rainwat, snowwat, &
4545 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: ua, va
4546 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt, delp
4547 REAL,
DIMENSION(isd:ied, jsd:jed, km) :: pt_ad, delp_ad
4548 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q
4549 REAL,
DIMENSION(isd:ied, jsd:jed, km, *) :: q_ad
4550 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc
4551 REAL,
DIMENSION(isd:ied, jsd:jed, km) :: qc_ad
4552 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
4553 REAL,
INTENT(INOUT) :: u_ad(isd:ied, jsd:jed+1, km)
4554 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
4555 REAL,
INTENT(INOUT) :: v_ad(isd:ied+1, jsd:jed, km)
4556 REAL,
INTENT(IN) :: w(isd:ied, jsd:jed, km)
4557 REAL :: w_ad(isd:ied, jsd:jed, km)
4558 REAL,
INTENT(IN) :: delz(isd:ied, jsd:jed, km)
4559 REAL :: delz_ad(isd:ied, jsd:jed, km)
4560 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
4561 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
4562 REAL :: pe_ad(is-1:ie+1, km+1, js-1:je+1)
4563 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
4564 REAL :: peln_ad(is:ie, km+1, js:je)
4565 REAL,
INTENT(IN) :: cp, rg, r_vir,
hlv 4566 REAL,
INTENT(IN) :: rsin2_l(isd:ied, jsd:jed)
4567 REAL,
INTENT(IN) :: cosa_s_l(isd:ied, jsd:jed)
4568 LOGICAL,
INTENT(IN) :: moist_phys, hydrostatic
4569 REAL :: te_2d(is:ie, js:je)
4570 REAL :: te_2d_ad(is:ie, js:je)
4571 REAL :: teq(is:ie, js:je)
4572 REAL :: teq_ad(is:ie, js:je)
4573 REAL,
DIMENSION(is:ie, km) :: tv
4574 REAL,
DIMENSION(is:ie, km) :: tv_ad
4575 REAL :: phiz(is:ie, km+1)
4576 REAL :: phiz_ad(is:ie, km+1)
4577 REAL :: cvm(is:ie), qd(is:ie)
4609 IF (branch .EQ. 0)
THEN 4617 IF (branch .NE. 0)
THEN 4620 q_ad(i, j, k, sphum) = q_ad(i, j, k, sphum) +
hlv*delp(i, &
4621 & j, k)*teq_ad(i, j)
4622 delp_ad(i, j, k) = delp_ad(i, j, k) +
hlv*q(i, j, k, sphum&
4628 te_2d_ad(i, j) = te_2d_ad(i, j) + teq_ad(i, j)
4637 IF (branch .EQ. 0)
THEN 4640 temp7 = v(i, j, k) + v(i+1, j, k)
4641 temp6 = u(i, j, k) + u(i, j+1, k)
4642 temp5 = 0.5*rsin2_l(i, j)
4643 temp_ad7 = delp(i, j, k)*te_2d_ad(i, j)
4644 temp_ad8 = 0.5*temp_ad7
4645 temp_ad9 = temp5*temp_ad8
4646 temp_ad10 = -(cosa_s_l(i, j)*temp_ad9)
4647 delp_ad(i, j, k) = delp_ad(i, j, k) + (
cv_air*pt(i, j, k)+&
4648 & 0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+temp5*(u(i, j, &
4649 & k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-&
4650 & cosa_s_l(i, j)*(temp6*temp7))))*te_2d_ad(i, j)
4651 pt_ad(i, j, k) = pt_ad(i, j, k) +
cv_air*temp_ad7
4652 phiz_ad(i, k) = phiz_ad(i, k) + temp_ad8
4653 phiz_ad(i, k+1) = phiz_ad(i, k+1) + temp_ad8
4654 w_ad(i, j, k) = w_ad(i, j, k) + 2*w(i, j, k)*temp_ad8
4655 u_ad(i, j, k) = u_ad(i, j, k) + temp7*temp_ad10 + 2*u(i, j, &
4657 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp7*temp_ad10 + 2*u(i&
4658 & , j+1, k)*temp_ad9
4659 v_ad(i, j, k) = v_ad(i, j, k) + temp6*temp_ad10 + 2*v(i, j, &
4661 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp6*temp_ad10 + 2*v(i+&
4665 ELSE IF (branch .EQ. 1)
THEN 4668 temp4 = v(i, j, k) + v(i+1, j, k)
4669 temp3 = u(i, j, k) + u(i, j+1, k)
4670 temp2 = 0.5*rsin2_l(i, j)
4671 temp_ad3 = delp(i, j, k)*te_2d_ad(i, j)
4672 temp_ad4 = 0.5*temp_ad3
4673 temp_ad5 = temp2*temp_ad4
4674 temp_ad6 = -(cosa_s_l(i, j)*temp_ad5)
4675 delp_ad(i, j, k) = delp_ad(i, j, k) + (
cv_air*pt(i, j, k)+&
4676 & 0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+temp2*(u(i, j, &
4677 & k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-&
4678 & cosa_s_l(i, j)*(temp3*temp4))))*te_2d_ad(i, j)
4679 pt_ad(i, j, k) = pt_ad(i, j, k) +
cv_air*temp_ad3
4680 phiz_ad(i, k) = phiz_ad(i, k) + temp_ad4
4681 phiz_ad(i, k+1) = phiz_ad(i, k+1) + temp_ad4
4682 w_ad(i, j, k) = w_ad(i, j, k) + 2*w(i, j, k)*temp_ad4
4683 u_ad(i, j, k) = u_ad(i, j, k) + temp4*temp_ad6 + 2*u(i, j, k&
4685 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp4*temp_ad6 + 2*u(i, &
4687 v_ad(i, j, k) = v_ad(i, j, k) + temp3*temp_ad6 + 2*v(i, j, k&
4689 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp3*temp_ad6 + 2*v(i+1&
4696 temp1 = v(i, j, k) + v(i+1, j, k)
4697 temp0 = u(i, j, k) + u(i, j+1, k)
4698 temp = 0.25*rsin2_l(i, j)
4699 temp_ad0 = delp(i, j, k)*te_2d_ad(i, j)
4700 temp_ad1 = temp*temp_ad0
4701 temp_ad2 = -(cosa_s_l(i, j)*temp_ad1)
4702 delp_ad(i, j, k) = delp_ad(i, j, k) + (cp*tv(i, k)+temp*(u(i&
4703 & , j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2+v(i+1, j, k)**2-&
4704 & cosa_s_l(i, j)*(temp0*temp1)))*te_2d_ad(i, j)
4705 tv_ad(i, k) = tv_ad(i, k) + cp*temp_ad0
4706 u_ad(i, j, k) = u_ad(i, j, k) + temp1*temp_ad2 + 2*u(i, j, k&
4708 u_ad(i, j+1, k) = u_ad(i, j+1, k) + temp1*temp_ad2 + 2*u(i, &
4710 v_ad(i, j, k) = v_ad(i, j, k) + temp0*temp_ad2 + 2*v(i, j, k&
4712 v_ad(i+1, j, k) = v_ad(i+1, j, k) + temp0*temp_ad2 + 2*v(i+1&
4717 pe_ad(i, km+1, j) = pe_ad(i, km+1, j) + phiz(i, km+1)*te_2d_ad&
4719 phiz_ad(i, km+1) = phiz_ad(i, km+1) + pe(i, km+1, j)*te_2d_ad(&
4721 pe_ad(i, 1, j) = pe_ad(i, 1, j) - phiz(i, 1)*te_2d_ad(i, j)
4722 phiz_ad(i, 1) = phiz_ad(i, 1) - pe(i, 1, j)*te_2d_ad(i, j)
4723 te_2d_ad(i, j) = 0.0
4728 temp_ad = rg*tv(i, k)*phiz_ad(i, k)
4729 phiz_ad(i, k+1) = phiz_ad(i, k+1) + phiz_ad(i, k)
4730 tv_ad(i, k) = tv_ad(i, k) + rg*(peln(i, k+1, j)-peln(i, k, j&
4732 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad
4733 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad
4736 pt_ad(i, j, k) = pt_ad(i, j, k) + (qc(i, j, k)+1.)*tv_ad(i, &
4738 qc_ad(i, j, k) = qc_ad(i, j, k) + pt(i, j, k)*tv_ad(i, k)
4744 phiz_ad(i, km+1) = 0.0
4749 te_2d_ad(i, j) = 0.0
4754 phiz_ad(i, k+1) = phiz_ad(i, k+1) + phiz_ad(i, k)
4755 delz_ad(i, j, k) = delz_ad(i, j, k) -
grav*phiz_ad(i, k)
4759 phiz_ad(i, km+1) = 0.0
4764 & , u, v, w, delz, pt, delp, q, qc, pe, peln, hs, rsin2_l, cosa_s_l, &
4765 & r_vir, cp, rg, hlv, te_2d, ua, va, teq, moist_phys, nwat, sphum, &
4766 & liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
4772 INTEGER,
INTENT(IN) :: km, is, ie, js, je, isd, ied, jsd, jed, id_te
4773 INTEGER,
INTENT(IN) :: sphum, liq_wat, ice_wat, rainwat, snowwat, &
4775 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: ua, va
4776 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: pt, delp
4777 REAL,
DIMENSION(isd:ied, jsd:jed, km, *),
INTENT(IN) :: q
4778 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: qc
4779 REAL,
INTENT(INOUT) :: u(isd:ied, jsd:jed+1, km)
4780 REAL,
INTENT(INOUT) :: v(isd:ied+1, jsd:jed, km)
4782 REAL,
INTENT(IN) :: w(isd:ied, jsd:jed, km)
4783 REAL,
INTENT(IN) :: delz(isd:ied, jsd:jed, km)
4785 REAL,
INTENT(IN) :: hs(isd:ied, jsd:jed)
4787 REAL,
INTENT(IN) :: pe(is-1:ie+1, km+1, js-1:je+1)
4789 REAL,
INTENT(IN) :: peln(is:ie, km+1, js:je)
4790 REAL,
INTENT(IN) :: cp, rg, r_vir,
hlv 4791 REAL,
INTENT(IN) :: rsin2_l(isd:ied, jsd:jed)
4792 REAL,
INTENT(IN) :: cosa_s_l(isd:ied, jsd:jed)
4793 LOGICAL,
INTENT(IN) :: moist_phys, hydrostatic
4796 REAL,
INTENT(OUT) :: te_2d(is:ie, js:je)
4798 REAL,
INTENT(OUT) :: teq(is:ie, js:je)
4800 REAL,
DIMENSION(is:ie, km) :: tv
4801 REAL :: phiz(is:ie, km+1)
4802 REAL :: cvm(is:ie), qd(is:ie)
4813 IF (hydrostatic)
THEN 4815 phiz(i, km+1) = hs(i, j)
4819 tv(i, k) = pt(i, j, k)*(1.+qc(i, j, k))
4820 phiz(i, k) = phiz(i, k+1) + rg*tv(i, k)*(peln(i, k+1, j)-&
4825 te_2d(i, j) = pe(i, km+1, j)*phiz(i, km+1) - pe(i, 1, j)*phiz(&
4830 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(cp*tv(i, k)+0.25*&
4831 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)**2&
4832 & +v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k)+v(i&
4833 & +1, j, k))*cosa_s_l(i, j)))
4841 phiz(i, km+1) = hs(i, j)
4843 phiz(i, k) = phiz(i, k+1) -
grav*delz(i, j, k)
4849 IF (moist_phys)
THEN 4852 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
4853 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
4854 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
4855 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
4856 & )+v(i+1, j, k))*cosa_s_l(i, j))))
4862 te_2d(i, j) = te_2d(i, j) + delp(i, j, k)*(
cv_air*pt(i, j&
4863 & , k)+0.5*(phiz(i, k)+phiz(i, k+1)+w(i, j, k)**2+0.5*&
4864 & rsin2_l(i, j)*(u(i, j, k)**2+u(i, j+1, k)**2+v(i, j, k)&
4865 & **2+v(i+1, j, k)**2-(u(i, j, k)+u(i, j+1, k))*(v(i, j, k&
4866 & )+v(i+1, j, k))*cosa_s_l(i, j))))
4875 IF (id_te .GT. 0)
THEN 4879 teq(i, j) = te_2d(i, j)
4881 IF (moist_phys)
THEN 4884 teq(i, j) = teq(i, j) +
hlv*q(i, j, k, sphum)*delp(i, j, k&
4912 SUBROUTINE pkez_fwd(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap&
4913 & , peln, pkz, ptop)
4916 INTEGER,
INTENT(IN) :: km, j
4918 INTEGER,
INTENT(IN) :: ifirst, ilast
4920 INTEGER,
INTENT(IN) :: jfirst, jlast
4921 REAL,
INTENT(IN) :: akap
4922 REAL,
INTENT(IN) :: pe(ifirst-1:ilast+1, km+1, jfirst-1:jlast+1)
4923 REAL,
INTENT(IN) :: pk(ifirst:ilast, jfirst:jlast, km+1)
4924 REAL,
INTENT(IN) :: ptop
4926 REAL :: pkz(ifirst:ilast, jfirst:jlast, km)
4928 REAL,
INTENT(INOUT) :: peln(ifirst:ilast, km+1, jfirst:jlast)
4930 REAL :: pk2(ifirst:ilast, km+1)
4942 ak1 = (akap+1.)/akap
4943 pek = pk(ifirst, j, 1)
4950 pk2(i, k) = pk(i, j, k)
4957 peln(i, 1, j) = peln(i, 2, j) - ak1
4972 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1, j)-&
4998 SUBROUTINE pkez_bwd(km, ifirst, ilast, jfirst, jlast, j, pe, pk, pk_ad&
4999 & , akap, peln, peln_ad, pkz, pkz_ad, ptop)
5001 INTEGER,
INTENT(IN) :: km, j
5002 INTEGER,
INTENT(IN) :: ifirst, ilast
5003 INTEGER,
INTENT(IN) :: jfirst, jlast
5004 REAL,
INTENT(IN) :: akap
5005 REAL,
INTENT(IN) :: pe(ifirst-1:ilast+1, km+1, jfirst-1:jlast+1)
5006 REAL,
INTENT(IN) :: pk(ifirst:ilast, jfirst:jlast, km+1)
5007 REAL :: pk_ad(ifirst:ilast, jfirst:jlast, km+1)
5008 REAL,
INTENT(IN) :: ptop
5009 REAL :: pkz(ifirst:ilast, jfirst:jlast, km)
5010 REAL :: pkz_ad(ifirst:ilast, jfirst:jlast, km)
5011 REAL,
INTENT(INOUT) :: peln(ifirst:ilast, km+1, jfirst:jlast)
5012 REAL,
INTENT(INOUT) :: peln_ad(ifirst:ilast, km+1, jfirst:jlast)
5013 REAL :: pk2(ifirst:ilast, km+1)
5014 REAL :: pk2_ad(ifirst:ilast, km+1)
5035 DO i=ilast,ifirst,-1
5037 temp = akap*(peln(i, k+1, j)-peln(i, k, j))
5038 temp_ad = pkz_ad(i, j, k)/temp
5039 temp_ad0 = -((pk2(i, k+1)-pk2(i, k))*akap*temp_ad/temp)
5040 pk2_ad(i, k+1) = pk2_ad(i, k+1) + temp_ad
5041 pk2_ad(i, k) = pk2_ad(i, k) - temp_ad
5042 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad0
5043 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad0
5044 pkz_ad(i, j, k) = 0.0
5048 IF (branch .EQ. 0)
THEN 5049 DO i=ilast,ifirst,-1
5051 peln_ad(i, 1, j) = 0.0
5054 DO i=ilast,ifirst,-1
5056 peln_ad(i, 2, j) = peln_ad(i, 2, j) + peln_ad(i, 1, j)
5057 peln_ad(i, 1, j) = 0.0
5061 DO i=ilast,ifirst,-1
5062 pk_ad(i, j, k) = pk_ad(i, j, k) + pk2_ad(i, k)
5067 DO i=ilast,ifirst,-1
5068 pek_ad = pek_ad + pk2_ad(i, 1)
5071 pk_ad(ifirst, j, 1) = pk_ad(ifirst, j, 1) + pek_ad
5073 SUBROUTINE pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, &
5077 INTEGER,
INTENT(IN) :: km, j
5079 INTEGER,
INTENT(IN) :: ifirst, ilast
5081 INTEGER,
INTENT(IN) :: jfirst, jlast
5082 REAL,
INTENT(IN) :: akap
5083 REAL,
INTENT(IN) :: pe(ifirst-1:ilast+1, km+1, jfirst-1:jlast+1)
5084 REAL,
INTENT(IN) :: pk(ifirst:ilast, jfirst:jlast, km+1)
5085 REAL,
INTENT(IN) :: ptop
5087 REAL,
INTENT(OUT) :: pkz(ifirst:ilast, jfirst:jlast, km)
5089 REAL,
INTENT(INOUT) :: peln(ifirst:ilast, km+1, jfirst:jlast)
5091 REAL :: pk2(ifirst:ilast, km+1)
5097 ak1 = (akap+1.)/akap
5098 pek = pk(ifirst, j, 1)
5105 pk2(i, k) = pk(i, j, k)
5111 peln(i, 1, j) = peln(i, 2, j) - ak1
5122 pkz(i, j, k) = (pk2(i, k+1)-pk2(i, k))/(akap*(peln(i, k+1, j)-&
5127 SUBROUTINE remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
5131 INTEGER,
INTENT(IN) :: i1
5133 INTEGER,
INTENT(IN) :: i2
5135 INTEGER,
INTENT(IN) :: kord
5137 INTEGER,
INTENT(IN) :: km
5139 INTEGER,
INTENT(IN) :: kn
5140 INTEGER,
INTENT(IN) :: iv
5142 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5145 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5148 REAL,
INTENT(IN) :: q1(i1:i2, km)
5151 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
5154 REAL :: dp1(i1:i2, km)
5155 REAL :: q4(4, i1:i2, km)
5156 REAL :: pl, pr, qsum, delp, esl
5157 INTEGER :: i, k, l, m, k0
5161 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5162 q4(1, i, k) = q1(i, k)
5166 IF (kord .GT. 7)
THEN 5167 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
5177 IF (pe2(i, k) .LE. pe1(i, l) .AND. pe2(i, k) .GE. pe1(i, l+1)&
5179 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5180 IF (pe2(i, k+1) .GE. pe1(i, l+1))
THEN 5182 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5183 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
5184 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
5189 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
5190 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
5194 IF (pe2(i, k+1) .LT. pe1(i, m+1))
THEN 5196 qsum = qsum + dp1(i, m)*q4(1, i, m)
5198 delp = pe2(i, k+1) - pe1(i, m)
5199 esl = delp/dp1(i, m)
5200 qsum = qsum + delp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-&
5201 & q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
5210 123 q2(i, k) = qsum/(pe2(i, k+1)-pe2(i, k))
5235 SUBROUTINE map_scalar_adm(km, pe1, pe1_ad, qs, kn, pe2, pe2_ad, q2, &
5236 & q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
5240 INTEGER,
INTENT(IN) :: i1
5242 INTEGER,
INTENT(IN) :: i2
5244 INTEGER,
INTENT(IN) :: iv
5247 INTEGER,
INTENT(IN) :: kord
5249 INTEGER,
INTENT(IN) :: j
5250 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
5252 INTEGER,
INTENT(IN) :: km
5254 INTEGER,
INTENT(IN) :: kn
5256 REAL,
INTENT(IN) :: qs(i1:i2)
5258 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5259 REAL :: pe1_ad(i1:i2, km+1)
5263 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5264 REAL :: pe2_ad(i1:i2, kn+1)
5270 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
5271 REAL,
INTENT(INOUT) :: q2_ad(ibeg:iend, jbeg:jend, kn)
5272 REAL,
INTENT(IN) :: q_min
5280 REAL :: dp1(i1:i2, km)
5281 REAL :: dp1_ad(i1:i2, km)
5282 REAL :: q4(4, i1:i2, km)
5283 REAL :: q4_ad(4, i1:i2, km)
5284 REAL :: pl, pr, qsum, dp, esl
5285 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
5286 INTEGER :: i, k, l, m, k0
5306 INTEGER :: ad_count0
5310 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5311 q4(1, i, k) = q2(i, j, k)
5315 IF (kord .GT. 7)
THEN 5330 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
5335 ad_count = ad_count + 1
5344 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5345 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5353 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
5354 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
5360 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 5362 qsum = qsum + dp1(i, m)*q4(1, i, m)
5364 ad_count0 = ad_count0 + 1
5375 dp = pe2(i, k+1) - pe1(i, m)
5377 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
5378 & +q4(4, i, m)*(1.-
r23*esl)))
5391 IF (branch .EQ. 0)
THEN 5392 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5393 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5394 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, j, k)
5395 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
5397 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, j, k))
5398 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, j, k) - temp_ad0
5399 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
5400 & **2)*q2_ad(i, j, k)
5401 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
5402 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
5403 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
5404 q2_ad(i, j, k) = 0.0
5405 temp_ad3 = pr_ad/dp1(i, l)
5406 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
5407 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
5408 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
5411 temp1 = pe2(i, k+1) - pe2(i, k)
5412 temp_ad11 = -(qsum*q2_ad(i, j, k)/temp1**2)
5413 qsum_ad = qsum_ad + q2_ad(i, j, k)/temp1
5414 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad11
5415 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad11
5416 q2_ad(i, j, k) = 0.0
5418 IF (branch .EQ. 0)
THEN 5419 dp = pe2(i, k+1) - pe1(i, m)
5421 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
5423 temp_ad8 = dp*qsum_ad
5424 temp_ad9 = 0.5*esl*temp_ad8
5425 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
5426 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
5427 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
5428 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
5429 temp_ad10 = esl_ad/dp1(i, m)
5430 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
5431 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
5432 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
5433 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
5434 ELSE IF (branch .NE. 1)
THEN 5442 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
5443 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
5447 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5449 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
5450 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
5451 & *(pl+1.)+1.)))*qsum_ad
5452 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
5453 temp_ad6 = 0.5*(pl+1.)*temp_ad5
5454 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
5455 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
5456 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
5457 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
5458 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
5460 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
5461 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
5464 temp_ad = pl_ad/dp1(i, l)
5465 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
5466 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
5467 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
5477 IF (branch .EQ. 0)
THEN 5486 q2_ad(i, j, k) = q2_ad(i, j, k) + q4_ad(1, i, k)
5487 q4_ad(1, i, k) = 0.0
5488 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
5489 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
5494 SUBROUTINE map_scalar(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend&
5495 & , jbeg, jend, iv, kord, q_min)
5499 INTEGER,
INTENT(IN) :: i1
5501 INTEGER,
INTENT(IN) :: i2
5503 INTEGER,
INTENT(IN) :: iv
5506 INTEGER,
INTENT(IN) :: kord
5508 INTEGER,
INTENT(IN) :: j
5509 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
5511 INTEGER,
INTENT(IN) :: km
5513 INTEGER,
INTENT(IN) :: kn
5515 REAL,
INTENT(IN) :: qs(i1:i2)
5517 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5521 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5527 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
5528 REAL,
INTENT(IN) :: q_min
5536 REAL :: dp1(i1:i2, km)
5537 REAL :: q4(4, i1:i2, km)
5538 REAL :: pl, pr, qsum, dp, esl
5539 INTEGER :: i, k, l, m, k0
5542 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5543 q4(1, i, k) = q2(i, j, k)
5547 IF (kord .GT. 7)
THEN 5557 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
5559 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5560 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5562 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5563 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-&
5564 & q4(2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
5569 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
5570 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
5574 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 5576 qsum = qsum + dp1(i, m)*q4(1, i, m)
5578 dp = pe2(i, k+1) - pe1(i, m)
5580 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
5581 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
5590 123 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
5615 SUBROUTINE map1_ppm_adm(km, pe1, pe1_ad, qs, qs_ad, kn, pe2, pe2_ad, &
5616 & q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
5619 INTEGER,
INTENT(IN) :: i1
5621 INTEGER,
INTENT(IN) :: i2
5623 INTEGER,
INTENT(IN) :: iv
5626 INTEGER,
INTENT(IN) :: kord
5628 INTEGER,
INTENT(IN) :: j
5629 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
5631 INTEGER,
INTENT(IN) :: km
5633 INTEGER,
INTENT(IN) :: kn
5635 REAL,
INTENT(IN) :: qs(i1:i2)
5636 REAL :: qs_ad(i1:i2)
5638 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5639 REAL :: pe1_ad(i1:i2, km+1)
5643 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5644 REAL :: pe2_ad(i1:i2, kn+1)
5650 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
5651 REAL,
INTENT(INOUT) :: q2_ad(ibeg:iend, jbeg:jend, kn)
5659 REAL :: dp1(i1:i2, km)
5660 REAL :: dp1_ad(i1:i2, km)
5661 REAL :: q4(4, i1:i2, km)
5662 REAL :: q4_ad(4, i1:i2, km)
5663 REAL :: pl, pr, qsum, dp, esl
5664 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
5665 INTEGER :: i, k, l, m, k0
5685 INTEGER :: ad_count0
5689 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5690 q4(1, i, k) = q2(i, j, k)
5694 IF (kord .GT. 7)
THEN 5696 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
5709 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
5714 ad_count = ad_count + 1
5723 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5724 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5732 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
5733 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
5739 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 5741 qsum = qsum + dp1(i, m)*q4(1, i, m)
5743 ad_count0 = ad_count0 + 1
5754 dp = pe2(i, k+1) - pe1(i, m)
5756 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
5757 & +q4(4, i, m)*(1.-
r23*esl)))
5770 IF (branch .EQ. 0)
THEN 5771 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5772 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5773 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, j, k)
5774 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
5776 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, j, k))
5777 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, j, k) - temp_ad0
5778 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
5779 & **2)*q2_ad(i, j, k)
5780 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
5781 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
5782 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
5783 q2_ad(i, j, k) = 0.0
5784 temp_ad3 = pr_ad/dp1(i, l)
5785 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
5786 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
5787 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
5790 temp1 = pe2(i, k+1) - pe2(i, k)
5791 temp_ad11 = -(qsum*q2_ad(i, j, k)/temp1**2)
5792 qsum_ad = qsum_ad + q2_ad(i, j, k)/temp1
5793 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad11
5794 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad11
5795 q2_ad(i, j, k) = 0.0
5797 IF (branch .EQ. 0)
THEN 5798 dp = pe2(i, k+1) - pe1(i, m)
5800 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
5802 temp_ad8 = dp*qsum_ad
5803 temp_ad9 = 0.5*esl*temp_ad8
5804 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
5805 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
5806 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
5807 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
5808 temp_ad10 = esl_ad/dp1(i, m)
5809 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
5810 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
5811 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
5812 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
5813 ELSE IF (branch .NE. 1)
THEN 5821 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
5822 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
5826 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5828 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
5829 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
5830 & *(pl+1.)+1.)))*qsum_ad
5831 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
5832 temp_ad6 = 0.5*(pl+1.)*temp_ad5
5833 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
5834 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
5835 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
5836 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
5837 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
5839 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
5840 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
5843 temp_ad = pl_ad/dp1(i, l)
5844 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
5845 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
5846 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
5856 IF (branch .EQ. 0)
THEN 5860 CALL cs_profile_adm(qs, qs_ad, q4, q4_ad, dp1, dp1_ad, km, i1, i2&
5865 q2_ad(i, j, k) = q2_ad(i, j, k) + q4_ad(1, i, k)
5866 q4_ad(1, i, k) = 0.0
5867 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
5868 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
5873 SUBROUTINE map1_ppm(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, &
5874 & jbeg, jend, iv, kord)
5877 INTEGER,
INTENT(IN) :: i1
5879 INTEGER,
INTENT(IN) :: i2
5881 INTEGER,
INTENT(IN) :: iv
5884 INTEGER,
INTENT(IN) :: kord
5886 INTEGER,
INTENT(IN) :: j
5887 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
5889 INTEGER,
INTENT(IN) :: km
5891 INTEGER,
INTENT(IN) :: kn
5893 REAL,
INTENT(IN) :: qs(i1:i2)
5895 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
5899 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
5905 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
5913 REAL :: dp1(i1:i2, km)
5914 REAL :: q4(4, i1:i2, km)
5915 REAL :: pl, pr, qsum, dp, esl
5916 INTEGER :: i, k, l, m, k0
5919 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
5920 q4(1, i, k) = q2(i, j, k)
5924 IF (kord .GT. 7)
THEN 5925 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
5934 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
5936 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
5937 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 5939 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
5940 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-&
5941 & q4(2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
5946 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
5947 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
5951 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 5953 qsum = qsum + dp1(i, m)*q4(1, i, m)
5955 dp = pe2(i, k+1) - pe1(i, m)
5957 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
5958 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
5967 123 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
5992 SUBROUTINE mapn_tracer_adm(nq, km, pe1, pe1_ad, pe2, pe2_ad, q1, q1_ad&
5993 & , dp2, dp2_ad, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
5997 INTEGER,
INTENT(IN) :: km
5998 INTEGER,
INTENT(IN) :: j, nq, i1, i2
5999 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
6000 INTEGER,
INTENT(IN) :: kord(nq)
6002 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
6003 REAL :: pe1_ad(i1:i2, km+1)
6007 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
6008 REAL :: pe2_ad(i1:i2, km+1)
6011 REAL,
INTENT(IN) :: dp2(i1:i2, km)
6012 REAL :: dp2_ad(i1:i2, km)
6013 REAL,
INTENT(IN) :: q_min
6014 LOGICAL,
INTENT(IN) :: fill
6016 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
6017 REAL,
INTENT(INOUT) :: q1_ad(isd:ied, jsd:jed, km, nq)
6019 REAL :: q4(4, i1:i2, km, nq)
6020 REAL :: q4_ad(4, i1:i2, km, nq)
6022 REAL :: q2(i1:i2, km, nq)
6023 REAL :: q2_ad(i1:i2, km, nq)
6026 REAL :: dp1(i1:i2, km)
6027 REAL :: dp1_ad(i1:i2, km)
6029 REAL :: pl, pr, dp, esl, fac1, fac2
6030 REAL :: pl_ad, pr_ad, dp_ad, esl_ad, fac1_ad, fac2_ad
6031 INTEGER :: i, k, l, m, k0, iq
6048 INTEGER :: ad_count0
6052 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
6058 q4(1, i, k, iq) = q1(i, j, k, iq)
6062 CALL scalar_profile(qs, q4(1:4, i1:i2, 1:km, iq), dp1, km, i1, i2&
6063 & , 0, kord(iq), q_min)
6073 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
6078 ad_count = ad_count + 1
6087 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6088 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 6090 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
6094 fac2 =
r3*(pr*fac1+pl*pl)
6103 dp = pe1(i, l+1) - pe2(i, k)
6107 fac2 =
r3*(1.+pl*fac1)
6112 qsum(iq) = dp*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, i, l, &
6113 & iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2)
6119 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 6123 qsum(iq) = qsum(iq) + dp1(i, m)*q4(1, i, m, iq)
6126 ad_count0 = ad_count0 + 1
6138 dp = pe2(i, k+1) - pe1(i, m)
6146 qsum(iq) = qsum(iq) + dp*(q4(2, i, m, iq)+fac1*(q4(3, i, m, &
6147 & iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2))
6159 q2_ad(i, k, iq) = q2_ad(i, k, iq) + q1_ad(i, j, k, iq)
6160 q1_ad(i, j, k, iq) = 0.0
6170 IF (branch .EQ. 0)
THEN 6174 temp_ad2 = fac1*q2_ad(i, k, iq)
6175 q4_ad(2, i, l, iq) = q4_ad(2, i, l, iq) + q2_ad(i, k, iq) - &
6177 q4_ad(4, i, l, iq) = q4_ad(4, i, l, iq) + temp_ad2 - fac2*&
6179 q4_ad(3, i, l, iq) = q4_ad(3, i, l, iq) + temp_ad2
6180 fac1_ad = fac1_ad + (q4(4, i, l, iq)+q4(3, i, l, iq)-q4(2, i&
6181 & , l, iq))*q2_ad(i, k, iq)
6182 fac2_ad = fac2_ad - q4(4, i, l, iq)*q2_ad(i, k, iq)
6183 q2_ad(i, k, iq) = 0.0
6185 temp_ad0 =
r3*fac2_ad
6186 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6187 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
6189 fac1_ad = pr*temp_ad0 + 0.5*fac1_ad
6191 pr_ad = fac1_ad + fac1*temp_ad0
6192 pl_ad = fac1_ad + 2*pl*temp_ad0
6194 temp_ad1 = pr_ad/dp1(i, l)
6195 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad1
6196 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad1
6197 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad1&
6201 temp_ad8 = q2_ad(i, k, iq)/dp2(i, k)
6202 qsum_ad(iq) = qsum_ad(iq) + temp_ad8
6203 dp2_ad(i, k) = dp2_ad(i, k) - qsum(iq)*temp_ad8/dp2(i, k)
6204 q2_ad(i, k, iq) = 0.0
6207 IF (branch .EQ. 0)
THEN 6208 dp = pe2(i, k+1) - pe1(i, m)
6217 temp0 = q4(3, i, m, iq) - q4(2, i, m, iq) + q4(4, i, m, iq&
6219 temp_ad6 = dp*qsum_ad(iq)
6220 temp_ad7 = fac1*temp_ad6
6221 dp_ad = dp_ad + (q4(2, i, m, iq)+fac1*temp0)*qsum_ad(iq)
6222 q4_ad(2, i, m, iq) = q4_ad(2, i, m, iq) + temp_ad6 - &
6224 fac1_ad = fac1_ad + temp0*temp_ad6
6225 q4_ad(3, i, m, iq) = q4_ad(3, i, m, iq) + temp_ad7
6226 q4_ad(4, i, m, iq) = q4_ad(4, i, m, iq) + fac2*temp_ad7
6227 fac2_ad = fac2_ad + q4(4, i, m, iq)*temp_ad7
6230 esl_ad = 0.5*fac1_ad -
r23*fac2_ad
6232 temp_ad5 = esl_ad/dp1(i, m)
6233 dp_ad = dp_ad + temp_ad5
6234 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad5/dp1(i, m)
6236 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
6237 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
6238 ELSE IF (branch .NE. 1)
THEN 6248 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m, iq)*qsum_ad(iq&
6250 q4_ad(1, i, m, iq) = q4_ad(1, i, m, iq) + dp1(i, m)*&
6261 temp = q4(4, i, l, iq) + q4(3, i, l, iq) - q4(2, i, l, iq)
6262 temp_ad3 = dp*qsum_ad(iq)
6263 temp_ad4 = fac1*temp_ad3
6264 dp_ad = dp_ad + (q4(2, i, l, iq)+temp*fac1-q4(4, i, l, iq)*&
6266 q4_ad(2, i, l, iq) = q4_ad(2, i, l, iq) + temp_ad3 - &
6268 q4_ad(4, i, l, iq) = q4_ad(4, i, l, iq) + temp_ad4 - fac2*&
6270 q4_ad(3, i, l, iq) = q4_ad(3, i, l, iq) + temp_ad4
6271 fac1_ad = fac1_ad + temp*temp_ad3
6272 fac2_ad = fac2_ad - q4(4, i, l, iq)*temp_ad3
6275 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6277 fac1_ad =
r3*pl*fac2_ad + 0.5*fac1_ad
6279 pl_ad = fac1_ad +
r3*fac1*fac2_ad
6282 pe1_ad(i, l+1) = pe1_ad(i, l+1) + dp_ad
6283 pe2_ad(i, k) = pe2_ad(i, k) - dp_ad
6285 temp_ad = pl_ad/dp1(i, l)
6286 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
6287 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
6288 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
6300 & i1:i2, 1:km, iq), dp1, dp1_ad, km, i1, i2, 0, &
6304 q1_ad(i, j, k, iq) = q1_ad(i, j, k, iq) + q4_ad(1, i, k, iq)
6305 q4_ad(1, i, k, iq) = 0.0
6311 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
6312 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
6317 SUBROUTINE mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd&
6318 & , ied, jsd, jed, q_min, fill)
6322 INTEGER,
INTENT(IN) :: km
6323 INTEGER,
INTENT(IN) :: j, nq, i1, i2
6324 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
6325 INTEGER,
INTENT(IN) :: kord(nq)
6327 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
6331 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
6334 REAL,
INTENT(IN) :: dp2(i1:i2, km)
6335 REAL,
INTENT(IN) :: q_min
6336 LOGICAL,
INTENT(IN) :: fill
6338 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
6340 REAL :: q4(4, i1:i2, km, nq)
6342 REAL :: q2(i1:i2, km, nq)
6344 REAL :: dp1(i1:i2, km)
6346 REAL :: pl, pr, dp, esl, fac1, fac2
6347 INTEGER :: i, k, l, m, k0, iq
6351 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
6357 q4(1, i, k, iq) = q1(i, j, k, iq)
6360 CALL scalar_profile(qs, q4(1:4, i1:i2, 1:km, iq), dp1, km, i1, i2&
6361 & , 0, kord(iq), q_min)
6369 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
6371 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6372 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 6374 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
6376 fac2 =
r3*(pr*fac1+pl*pl)
6379 q2(i, k, iq) = q4(2, i, l, iq) + (q4(4, i, l, iq)+q4(3, &
6380 & i, l, iq)-q4(2, i, l, iq))*fac1 - q4(4, i, l, iq)*fac2
6386 dp = pe1(i, l+1) - pe2(i, k)
6388 fac2 =
r3*(1.+pl*fac1)
6391 qsum(iq) = dp*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, i&
6392 & , l, iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2)
6396 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 6399 qsum(iq) = qsum(iq) + dp1(i, m)*q4(1, i, m, iq)
6402 dp = pe2(i, k+1) - pe1(i, m)
6407 qsum(iq) = qsum(iq) + dp*(q4(2, i, m, iq)+fac1*(q4(3&
6408 & , i, m, iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2))
6420 q2(i, k, iq) = qsum(iq)/dp2(i, k)
6427 CALL fillz(arg1, km, nq, q2, dp2)
6433 q1(i, j, k, iq) = q2(i, k, iq)
6458 SUBROUTINE map1_q2_adm(km, pe1, pe1_ad, q1, q1_ad, kn, pe2, pe2_ad, q2&
6459 & , q2_ad, dp2, dp2_ad, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, &
6463 INTEGER,
INTENT(IN) :: j
6464 INTEGER,
INTENT(IN) :: i1, i2
6465 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
6467 INTEGER,
INTENT(IN) :: iv
6468 INTEGER,
INTENT(IN) :: kord
6470 INTEGER,
INTENT(IN) :: km
6472 INTEGER,
INTENT(IN) :: kn
6474 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
6475 REAL :: pe1_ad(i1:i2, km+1)
6479 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
6480 REAL :: pe2_ad(i1:i2, kn+1)
6484 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
6485 REAL :: q1_ad(ibeg:iend, jbeg:jend, km)
6486 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
6487 REAL :: dp2_ad(i1:i2, kn)
6488 REAL,
INTENT(IN) :: q_min
6491 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
6492 REAL,
INTENT(INOUT) :: q2_ad(i1:i2, kn)
6495 REAL :: dp1(i1:i2, km)
6496 REAL :: dp1_ad(i1:i2, km)
6497 REAL :: q4(4, i1:i2, km)
6498 REAL :: q4_ad(4, i1:i2, km)
6499 REAL :: pl, pr, qsum, dp, esl
6500 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
6501 INTEGER :: i, k, l, m, k0
6520 INTEGER :: ad_count0
6524 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
6525 q4(1, i, k) = q1(i, j, k)
6529 IF (kord .GT. 7)
THEN 6545 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
6550 ad_count = ad_count + 1
6559 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6560 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 6568 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
6569 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
6575 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 6577 qsum = qsum + dp1(i, m)*q4(1, i, m)
6579 ad_count0 = ad_count0 + 1
6590 dp = pe2(i, k+1) - pe1(i, m)
6592 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
6593 & +q4(4, i, m)*(1.-
r23*esl)))
6606 IF (branch .EQ. 0)
THEN 6607 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6608 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
6609 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, k)
6610 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
6612 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, k))
6613 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, k) - temp_ad0
6614 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
6616 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
6617 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
6618 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
6620 temp_ad3 = pr_ad/dp1(i, l)
6621 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
6622 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
6623 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
6626 temp_ad11 = q2_ad(i, k)/dp2(i, k)
6627 qsum_ad = qsum_ad + temp_ad11
6628 dp2_ad(i, k) = dp2_ad(i, k) - qsum*temp_ad11/dp2(i, k)
6631 IF (branch .EQ. 0)
THEN 6632 dp = pe2(i, k+1) - pe1(i, m)
6634 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
6636 temp_ad8 = dp*qsum_ad
6637 temp_ad9 = 0.5*esl*temp_ad8
6638 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
6639 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
6640 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
6641 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
6642 temp_ad10 = esl_ad/dp1(i, m)
6643 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
6644 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
6645 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
6646 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
6647 ELSE IF (branch .NE. 1)
THEN 6655 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
6656 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
6660 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6662 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
6663 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
6664 & *(pl+1.)+1.)))*qsum_ad
6665 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
6666 temp_ad6 = 0.5*(pl+1.)*temp_ad5
6667 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
6668 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
6669 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
6670 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
6671 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
6673 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
6674 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
6677 temp_ad = pl_ad/dp1(i, l)
6678 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
6679 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
6680 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
6690 IF (branch .EQ. 0)
THEN 6699 q1_ad(i, j, k) = q1_ad(i, j, k) + q4_ad(1, i, k)
6700 q4_ad(1, i, k) = 0.0
6701 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
6702 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
6707 SUBROUTINE map1_q2(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j&
6708 & , ibeg, iend, jbeg, jend, q_min)
6711 INTEGER,
INTENT(IN) :: j
6712 INTEGER,
INTENT(IN) :: i1, i2
6713 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
6715 INTEGER,
INTENT(IN) :: iv
6716 INTEGER,
INTENT(IN) :: kord
6718 INTEGER,
INTENT(IN) :: km
6720 INTEGER,
INTENT(IN) :: kn
6722 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
6726 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
6730 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
6731 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
6732 REAL,
INTENT(IN) :: q_min
6735 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
6738 REAL :: dp1(i1:i2, km)
6739 REAL :: q4(4, i1:i2, km)
6740 REAL :: pl, pr, qsum, dp, esl
6741 INTEGER :: i, k, l, m, k0
6744 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
6745 q4(1, i, k) = q1(i, j, k)
6749 IF (kord .GT. 7)
THEN 6760 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
6762 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
6763 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 6765 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
6766 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
6767 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
6772 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, &
6773 & l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+&
6777 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 6779 qsum = qsum + dp1(i, m)*q4(1, i, m)
6781 dp = pe2(i, k+1) - pe1(i, m)
6783 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(&
6784 & 2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
6793 123 q2(i, k) = qsum/dp2(i, k)
6823 INTEGER,
INTENT(IN) :: i1, i2
6825 INTEGER,
INTENT(IN) :: km
6827 INTEGER,
INTENT(IN) :: iv
6830 INTEGER,
INTENT(IN) :: kord
6831 REAL,
INTENT(IN) :: qs(i1:i2)
6833 REAL,
INTENT(IN) :: delp(i1:i2, km)
6834 REAL :: delp_ad(i1:i2, km)
6836 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
6837 REAL,
INTENT(INOUT) :: a4_ad(4, i1:i2, km)
6838 REAL,
INTENT(IN) :: qmin
6840 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
6841 REAL :: gam(i1:i2, km)
6842 REAL :: gam_ad(i1:i2, km)
6843 REAL :: q(i1:i2, km+1)
6844 REAL :: q_ad(i1:i2, km+1)
6846 REAL :: d4_ad(i1:i2)
6847 REAL :: bet, a_bot, grat
6848 REAL :: bet_ad, a_bot_ad, grat_ad
6849 REAL :: pmp_1, lac_1, pmp_2, lac_2
6850 REAL :: pmp_1_ad, lac_1_ad, pmp_2_ad, lac_2_ad
6993 IF (iv .EQ. -2)
THEN 6996 q(i, 1) = 1.5*a4(1, i, 1)
7000 grat = delp(i, k-1)/delp(i, k)
7002 bet = 2. + grat + grat - gam(i, k)
7004 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
7005 gam(i, k+1) = grat/bet
7009 grat = delp(i, km-1)/delp(i, km)
7011 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
7012 & 1))/(2.+grat+grat-gam(i, km))
7019 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
7026 grat = delp(i, 2)/delp(i, 1)
7027 bet = grat*(grat+0.5)
7028 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
7029 gam(i, 1) = (1.+grat*(grat+1.5))/bet
7034 d4(i) = delp(i, k-1)/delp(i, k)
7036 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
7038 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
7039 gam(i, k) = d4(i)/bet
7043 a_bot = 1. + d4(i)*(d4(i)+1.5)
7045 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
7046 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
7051 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
7056 IF (kord .GE. 0.)
THEN 7062 IF (abs0 .GT. 16)
THEN 7066 temp_ad14 = 3.*a4_ad(4, i, k)
7067 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad14
7068 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad14
7069 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad14
7070 a4_ad(4, i, k) = 0.0
7071 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
7072 a4_ad(3, i, k) = 0.0
7073 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
7074 a4_ad(2, i, k) = 0.0
7086 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 7093 IF (q(i, 2) .GT. y1)
THEN 7102 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 7109 IF (q(i, 2) .LT. y2)
THEN 7120 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
7126 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 7127 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 7134 IF (q(i, k) .GT. y3)
THEN 7143 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 7150 IF (q(i, k) .LT. y4)
THEN 7157 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 7158 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 7165 IF (q(i, k) .LT. y5)
THEN 7175 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 7182 IF (q(i, k) .GT. y6)
THEN 7192 IF (0. .LT. q(i, k))
THEN 7207 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 7214 IF (q(i, km) .GT. y7)
THEN 7223 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 7230 IF (q(i, km) .LT. y8)
THEN 7241 a4(2, i, k) = q(i, k)
7243 a4(3, i, k) = q(i, k+1)
7247 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 7249 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
7254 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
7257 IF (kord .GE. 0.)
THEN 7262 IF (abs1 .EQ. 16)
THEN 7265 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
7266 IF (a4(4, i, k) .GE. 0.)
THEN 7271 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 7272 abs13 = a4(2, i, k) - a4(3, i, k)
7274 abs13 = -(a4(2, i, k)-a4(3, i, k))
7276 ext6(i, k) = abs2 .GT. abs13
7290 IF (0. .LT. a4(2, i, 1))
THEN 7292 a4(2, i, 1) = a4(2, i, 1)
7301 ELSE IF (iv .EQ. -1)
THEN 7303 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.)
THEN 7312 ELSE IF (iv .EQ. 2)
THEN 7315 a4(2, i, 1) = a4(1, i, 1)
7317 a4(3, i, 1) = a4(1, i, 1)
7328 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
7338 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
7345 IF (kord .GE. 0.)
THEN 7350 IF (abs3 .LT. 9)
THEN 7353 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
7354 lac_1 = pmp_1 + 1.5*gam(i, k+2)
7355 IF (a4(1, i, k) .GT. pmp_1)
THEN 7356 IF (pmp_1 .GT. lac_1)
THEN 7363 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 7370 IF (a4(2, i, k) .LT. y21)
THEN 7377 IF (a4(1, i, k) .LT. pmp_1)
THEN 7378 IF (pmp_1 .LT. lac_1)
THEN 7385 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 7392 IF (x1 .GT. y9)
THEN 7402 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
7403 lac_2 = pmp_2 - 1.5*gam(i, k-1)
7404 IF (a4(1, i, k) .GT. pmp_2)
THEN 7405 IF (pmp_2 .GT. lac_2)
THEN 7412 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 7419 IF (a4(3, i, k) .LT. y22)
THEN 7426 IF (a4(1, i, k) .LT. pmp_2)
THEN 7427 IF (pmp_2 .LT. lac_2)
THEN 7434 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 7441 IF (x2 .GT. y10)
THEN 7451 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
7455 IF (kord .GE. 0.)
THEN 7460 IF (abs4 .EQ. 9)
THEN 7462 IF (extm(i, k) .AND. extm(i, k-1))
THEN 7465 a4(2, i, k) = a4(1, i, k)
7467 a4(3, i, k) = a4(1, i, k)
7471 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 7474 a4(2, i, k) = a4(1, i, k)
7476 a4(3, i, k) = a4(1, i, k)
7480 ELSE IF (extm(i, k) .AND. a4(1, i, k) .LT. qmin)
THEN 7483 a4(2, i, k) = a4(1, i, k)
7485 a4(3, i, k) = a4(1, i, k)
7491 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k&
7493 IF (a4(4, i, k) .GE. 0.)
THEN 7498 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 7499 abs14 = a4(2, i, k) - a4(3, i, k)
7501 abs14 = -(a4(2, i, k)-a4(3, i, k))
7504 IF (abs5 .GT. abs14)
THEN 7505 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
7506 lac_1 = pmp_1 + 1.5*gam(i, k+2)
7507 IF (a4(1, i, k) .GT. pmp_1)
THEN 7508 IF (pmp_1 .GT. lac_1)
THEN 7515 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 7522 IF (a4(2, i, k) .LT. y23)
THEN 7529 IF (a4(1, i, k) .LT. pmp_1)
THEN 7530 IF (pmp_1 .LT. lac_1)
THEN 7537 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 7544 IF (x3 .GT. y11)
THEN 7553 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
7554 lac_2 = pmp_2 - 1.5*gam(i, k-1)
7555 IF (a4(1, i, k) .GT. pmp_2)
THEN 7556 IF (pmp_2 .GT. lac_2)
THEN 7563 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 7570 IF (a4(3, i, k) .LT. y24)
THEN 7577 IF (a4(1, i, k) .LT. pmp_2)
THEN 7578 IF (pmp_2 .LT. lac_2)
THEN 7585 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 7592 IF (x4 .GT. y12)
THEN 7602 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i&
7612 IF (kord .GE. 0.)
THEN 7617 IF (abs6 .EQ. 10)
THEN 7619 IF (extm(i, k))
THEN 7620 IF ((a4(1, i, k) .LT. qmin .OR. extm(i, k-1)) .OR. &
7621 & extm(i, k+1))
THEN 7624 a4(2, i, k) = a4(1, i, k)
7626 a4(3, i, k) = a4(1, i, k)
7633 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
7640 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
7642 IF (a4(4, i, k) .GE. 0.)
THEN 7647 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 7648 abs15 = a4(2, i, k) - a4(3, i, k)
7650 abs15 = -(a4(2, i, k)-a4(3, i, k))
7653 IF (abs7 .GT. abs15)
THEN 7654 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
7655 lac_1 = pmp_1 + 1.5*gam(i, k+2)
7656 IF (a4(1, i, k) .GT. pmp_1)
THEN 7657 IF (pmp_1 .GT. lac_1)
THEN 7664 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 7671 IF (a4(2, i, k) .LT. y25)
THEN 7678 IF (a4(1, i, k) .LT. pmp_1)
THEN 7679 IF (pmp_1 .LT. lac_1)
THEN 7686 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 7693 IF (x5 .GT. y13)
THEN 7702 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
7703 lac_2 = pmp_2 - 1.5*gam(i, k-1)
7704 IF (a4(1, i, k) .GT. pmp_2)
THEN 7705 IF (pmp_2 .GT. lac_2)
THEN 7712 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 7719 IF (a4(3, i, k) .LT. y26)
THEN 7726 IF (a4(1, i, k) .LT. pmp_2)
THEN 7727 IF (pmp_2 .LT. lac_2)
THEN 7734 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 7741 IF (x6 .GT. y14)
THEN 7751 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
7761 IF (kord .GE. 0.)
THEN 7766 IF (abs8 .EQ. 12)
THEN 7768 IF (extm(i, k))
THEN 7770 a4(2, i, k) = a4(1, i, k)
7772 a4(3, i, k) = a4(1, i, k)
7779 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
7781 IF (a4(4, i, k) .GE. 0.)
THEN 7786 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 7787 abs16 = a4(2, i, k) - a4(3, i, k)
7789 abs16 = -(a4(2, i, k)-a4(3, i, k))
7792 IF (abs9 .GT. abs16)
THEN 7793 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
7794 lac_1 = pmp_1 + 1.5*gam(i, k+2)
7795 IF (a4(1, i, k) .GT. pmp_1)
THEN 7796 IF (pmp_1 .GT. lac_1)
THEN 7803 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 7810 IF (a4(2, i, k) .LT. y27)
THEN 7817 IF (a4(1, i, k) .LT. pmp_1)
THEN 7818 IF (pmp_1 .LT. lac_1)
THEN 7825 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 7832 IF (x7 .GT. y15)
THEN 7841 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
7842 lac_2 = pmp_2 - 1.5*gam(i, k-1)
7843 IF (a4(1, i, k) .GT. pmp_2)
THEN 7844 IF (pmp_2 .GT. lac_2)
THEN 7851 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 7858 IF (a4(3, i, k) .LT. y28)
THEN 7865 IF (a4(1, i, k) .LT. pmp_2)
THEN 7866 IF (pmp_2 .LT. lac_2)
THEN 7873 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 7880 IF (x8 .GT. y16)
THEN 7890 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
7900 IF (kord .GE. 0.)
THEN 7905 IF (abs10 .EQ. 13)
THEN 7907 IF (extm(i, k))
THEN 7908 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 7911 a4(2, i, k) = a4(1, i, k)
7913 a4(3, i, k) = a4(1, i, k)
7919 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
7920 lac_1 = pmp_1 + 1.5*gam(i, k+2)
7921 IF (a4(1, i, k) .GT. pmp_1)
THEN 7922 IF (pmp_1 .GT. lac_1)
THEN 7929 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 7936 IF (a4(2, i, k) .LT. y29)
THEN 7943 IF (a4(1, i, k) .LT. pmp_1)
THEN 7944 IF (pmp_1 .LT. lac_1)
THEN 7951 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 7958 IF (x9 .GT. y17)
THEN 7968 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
7969 lac_2 = pmp_2 - 1.5*gam(i, k-1)
7970 IF (a4(1, i, k) .GT. pmp_2)
THEN 7971 IF (pmp_2 .GT. lac_2)
THEN 7978 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 7985 IF (a4(3, i, k) .LT. y30)
THEN 7992 IF (a4(1, i, k) .LT. pmp_2)
THEN 7993 IF (pmp_2 .LT. lac_2)
THEN 8000 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 8007 IF (x10 .GT. y18)
THEN 8017 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
8023 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
8030 IF (kord .GE. 0.)
THEN 8035 IF (abs11 .EQ. 14)
THEN 8038 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
8043 IF (kord .GE. 0.)
THEN 8048 IF (abs12 .EQ. 16)
THEN 8050 IF (ext6(i, k))
THEN 8051 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 8053 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
8054 lac_1 = pmp_1 + 1.5*gam(i, k+2)
8055 IF (a4(1, i, k) .GT. pmp_1)
THEN 8056 IF (pmp_1 .GT. lac_1)
THEN 8063 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 8070 IF (a4(2, i, k) .LT. y31)
THEN 8077 IF (a4(1, i, k) .LT. pmp_1)
THEN 8078 IF (pmp_1 .LT. lac_1)
THEN 8085 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 8092 IF (x11 .GT. y19)
THEN 8102 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
8103 lac_2 = pmp_2 - 1.5*gam(i, k-1)
8104 IF (a4(1, i, k) .GT. pmp_2)
THEN 8105 IF (pmp_2 .GT. lac_2)
THEN 8112 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 8119 IF (a4(3, i, k) .LT. y32)
THEN 8126 IF (a4(1, i, k) .LT. pmp_2)
THEN 8127 IF (pmp_2 .LT. lac_2)
THEN 8134 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 8141 IF (x12 .GT. y20)
THEN 8151 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k&
8165 IF (extm(i, k) .AND. ((extm(i, k-1) .OR. extm(i&
8166 & , k+1)) .OR. a4(1, i, k) .LT. qmin))
THEN 8169 a4(2, i, k) = a4(1, i, k)
8171 a4(3, i, k) = a4(1, i, k)
8177 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+&
8204 IF (0. .LT. a4(3, i, km))
THEN 8206 a4(3, i, km) = a4(3, i, km)
8215 ELSE IF (iv .EQ. -1)
THEN 8217 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.)
THEN 8232 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
8234 IF (k .EQ. km - 1)
THEN 8250 & i1, k), a4_ad(1, i1, k), 1)
8253 & i1, k), a4_ad(1, i1, k), 2)
8256 temp_ad26 = 3.*a4_ad(4, i, k)
8257 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad26
8258 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad26
8259 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad26
8260 a4_ad(4, i, k) = 0.0
8264 IF (branch .NE. 0)
THEN 8265 IF (branch .EQ. 1)
THEN 8268 IF (branch .NE. 0)
THEN 8270 a4_ad(3, i, km) = 0.0
8276 IF (branch .EQ. 0)
THEN 8280 a4_ad(3, i, km) = 0.0
8289 & i1, k), a4_ad(1, i1, k), 0)
8291 IF (branch .LT. 4)
THEN 8292 IF (branch .LT. 2)
THEN 8293 IF (branch .EQ. 0)
THEN 8296 temp_ad18 = 3.*a4_ad(4, i, k)
8297 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad18
8298 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad18
8299 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad18
8300 a4_ad(4, i, k) = 0.0
8302 IF (branch .EQ. 0)
THEN 8304 y10_ad = a4_ad(3, i, k)
8305 a4_ad(3, i, k) = 0.0
8309 x2_ad = a4_ad(3, i, k)
8310 a4_ad(3, i, k) = 0.0
8314 IF (branch .LT. 2)
THEN 8315 IF (branch .EQ. 0)
THEN 8323 IF (branch .EQ. 2)
THEN 8326 a4_ad(1, i, k) = a4_ad(1, i, k) + y10_ad
8332 IF (branch .EQ. 0)
THEN 8335 a4_ad(3, i, k) = a4_ad(3, i, k) + x2_ad
8339 IF (branch .LT. 2)
THEN 8340 IF (branch .EQ. 0)
THEN 8341 lac_2_ad = lac_2_ad + y22_ad
8343 pmp_2_ad = pmp_2_ad + y22_ad
8345 ELSE IF (branch .EQ. 2)
THEN 8346 lac_2_ad = lac_2_ad + y22_ad
8348 a4_ad(1, i, k) = a4_ad(1, i, k) + y22_ad
8350 pmp_2_ad = pmp_2_ad + lac_2_ad
8351 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
8352 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
8353 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
8355 IF (branch .EQ. 0)
THEN 8357 y9_ad = a4_ad(2, i, k)
8358 a4_ad(2, i, k) = 0.0
8362 x1_ad = a4_ad(2, i, k)
8363 a4_ad(2, i, k) = 0.0
8367 IF (branch .LT. 2)
THEN 8368 IF (branch .EQ. 0)
THEN 8376 IF (branch .EQ. 2)
THEN 8379 a4_ad(1, i, k) = a4_ad(1, i, k) + y9_ad
8385 IF (branch .EQ. 0)
THEN 8388 a4_ad(2, i, k) = a4_ad(2, i, k) + x1_ad
8392 IF (branch .LT. 2)
THEN 8393 IF (branch .EQ. 0)
THEN 8394 lac_1_ad = lac_1_ad + y21_ad
8396 pmp_1_ad = pmp_1_ad + y21_ad
8398 ELSE IF (branch .EQ. 2)
THEN 8399 lac_1_ad = lac_1_ad + y21_ad
8401 a4_ad(1, i, k) = a4_ad(1, i, k) + y21_ad
8403 pmp_1_ad = pmp_1_ad + lac_1_ad
8404 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
8405 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
8406 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
8411 IF (branch .LT. 2)
THEN 8412 IF (branch .NE. 0)
THEN 8414 temp_ad20 = 3.*a4_ad(4, i, k)
8415 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad20
8416 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad20
8417 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad20
8418 a4_ad(4, i, k) = 0.0
8420 IF (branch .EQ. 0)
THEN 8422 y12_ad = a4_ad(3, i, k)
8423 a4_ad(3, i, k) = 0.0
8427 x4_ad = a4_ad(3, i, k)
8428 a4_ad(3, i, k) = 0.0
8432 IF (branch .LT. 2)
THEN 8433 IF (branch .EQ. 0)
THEN 8441 IF (branch .EQ. 2)
THEN 8444 a4_ad(1, i, k) = a4_ad(1, i, k) + y12_ad
8450 IF (branch .EQ. 0)
THEN 8453 a4_ad(3, i, k) = a4_ad(3, i, k) + x4_ad
8457 IF (branch .LT. 2)
THEN 8458 IF (branch .EQ. 0)
THEN 8459 lac_2_ad = lac_2_ad + y24_ad
8461 pmp_2_ad = pmp_2_ad + y24_ad
8463 ELSE IF (branch .EQ. 2)
THEN 8464 lac_2_ad = lac_2_ad + y24_ad
8466 a4_ad(1, i, k) = a4_ad(1, i, k) + y24_ad
8468 pmp_2_ad = pmp_2_ad + lac_2_ad
8469 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
8470 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
8471 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
8473 IF (branch .EQ. 0)
THEN 8475 y11_ad = a4_ad(2, i, k)
8476 a4_ad(2, i, k) = 0.0
8480 x3_ad = a4_ad(2, i, k)
8481 a4_ad(2, i, k) = 0.0
8485 IF (branch .LT. 2)
THEN 8486 IF (branch .EQ. 0)
THEN 8494 IF (branch .EQ. 2)
THEN 8497 a4_ad(1, i, k) = a4_ad(1, i, k) + y11_ad
8503 IF (branch .EQ. 0)
THEN 8506 a4_ad(2, i, k) = a4_ad(2, i, k) + x3_ad
8510 IF (branch .LT. 2)
THEN 8511 IF (branch .EQ. 0)
THEN 8512 lac_1_ad = lac_1_ad + y23_ad
8514 pmp_1_ad = pmp_1_ad + y23_ad
8516 ELSE IF (branch .EQ. 2)
THEN 8517 lac_1_ad = lac_1_ad + y23_ad
8519 a4_ad(1, i, k) = a4_ad(1, i, k) + y23_ad
8521 pmp_1_ad = pmp_1_ad + lac_1_ad
8522 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
8523 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
8524 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
8527 temp_ad19 = 3.*a4_ad(4, i, k)
8528 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad19
8529 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad19
8530 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad19
8531 a4_ad(4, i, k) = 0.0
8532 ELSE IF (branch .EQ. 2)
THEN 8534 a4_ad(4, i, k) = 0.0
8536 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8537 a4_ad(3, i, k) = 0.0
8539 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8540 a4_ad(2, i, k) = 0.0
8541 ELSE IF (branch .EQ. 3)
THEN 8543 a4_ad(4, i, k) = 0.0
8545 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8546 a4_ad(3, i, k) = 0.0
8548 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8549 a4_ad(2, i, k) = 0.0
8552 a4_ad(4, i, k) = 0.0
8554 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8555 a4_ad(3, i, k) = 0.0
8557 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8558 a4_ad(2, i, k) = 0.0
8562 ELSE IF (branch .EQ. 2)
THEN 8565 IF (branch .LT. 2)
THEN 8566 IF (branch .NE. 0)
THEN 8568 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
8569 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
8570 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
8571 a4_ad(4, i, k) = 0.0
8573 IF (branch .EQ. 0)
THEN 8575 y14_ad = a4_ad(3, i, k)
8576 a4_ad(3, i, k) = 0.0
8580 x6_ad = a4_ad(3, i, k)
8581 a4_ad(3, i, k) = 0.0
8585 IF (branch .LT. 2)
THEN 8586 IF (branch .EQ. 0)
THEN 8594 IF (branch .EQ. 2)
THEN 8597 a4_ad(1, i, k) = a4_ad(1, i, k) + y14_ad
8603 IF (branch .EQ. 0)
THEN 8606 a4_ad(3, i, k) = a4_ad(3, i, k) + x6_ad
8610 IF (branch .LT. 2)
THEN 8611 IF (branch .EQ. 0)
THEN 8612 lac_2_ad = lac_2_ad + y26_ad
8614 pmp_2_ad = pmp_2_ad + y26_ad
8616 ELSE IF (branch .EQ. 2)
THEN 8617 lac_2_ad = lac_2_ad + y26_ad
8619 a4_ad(1, i, k) = a4_ad(1, i, k) + y26_ad
8621 pmp_2_ad = pmp_2_ad + lac_2_ad
8622 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
8623 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
8624 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
8626 IF (branch .EQ. 0)
THEN 8628 y13_ad = a4_ad(2, i, k)
8629 a4_ad(2, i, k) = 0.0
8633 x5_ad = a4_ad(2, i, k)
8634 a4_ad(2, i, k) = 0.0
8638 IF (branch .LT. 2)
THEN 8639 IF (branch .EQ. 0)
THEN 8647 IF (branch .EQ. 2)
THEN 8650 a4_ad(1, i, k) = a4_ad(1, i, k) + y13_ad
8656 IF (branch .EQ. 0)
THEN 8659 a4_ad(2, i, k) = a4_ad(2, i, k) + x5_ad
8663 IF (branch .LT. 2)
THEN 8664 IF (branch .EQ. 0)
THEN 8665 lac_1_ad = lac_1_ad + y25_ad
8667 pmp_1_ad = pmp_1_ad + y25_ad
8669 ELSE IF (branch .EQ. 2)
THEN 8670 lac_1_ad = lac_1_ad + y25_ad
8672 a4_ad(1, i, k) = a4_ad(1, i, k) + y25_ad
8674 pmp_1_ad = pmp_1_ad + lac_1_ad
8675 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
8676 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
8677 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
8680 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
8681 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
8682 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
8683 a4_ad(4, i, k) = 0.0
8684 ELSE IF (branch .EQ. 2)
THEN 8686 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
8687 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
8688 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
8689 a4_ad(4, i, k) = 0.0
8692 a4_ad(4, i, k) = 0.0
8694 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8695 a4_ad(3, i, k) = 0.0
8697 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8698 a4_ad(2, i, k) = 0.0
8704 IF (branch .NE. 0)
THEN 8705 IF (branch .EQ. 1)
THEN 8707 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
8708 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
8709 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
8710 a4_ad(4, i, k) = 0.0
8712 IF (branch .EQ. 0)
THEN 8714 y16_ad = a4_ad(3, i, k)
8715 a4_ad(3, i, k) = 0.0
8719 x8_ad = a4_ad(3, i, k)
8720 a4_ad(3, i, k) = 0.0
8724 IF (branch .LT. 2)
THEN 8725 IF (branch .EQ. 0)
THEN 8733 IF (branch .EQ. 2)
THEN 8736 a4_ad(1, i, k) = a4_ad(1, i, k) + y16_ad
8742 IF (branch .EQ. 0)
THEN 8745 a4_ad(3, i, k) = a4_ad(3, i, k) + x8_ad
8749 IF (branch .LT. 2)
THEN 8750 IF (branch .EQ. 0)
THEN 8751 lac_2_ad = lac_2_ad + y28_ad
8753 pmp_2_ad = pmp_2_ad + y28_ad
8755 ELSE IF (branch .EQ. 2)
THEN 8756 lac_2_ad = lac_2_ad + y28_ad
8758 a4_ad(1, i, k) = a4_ad(1, i, k) + y28_ad
8760 pmp_2_ad = pmp_2_ad + lac_2_ad
8761 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
8762 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
8763 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
8765 IF (branch .EQ. 0)
THEN 8767 y15_ad = a4_ad(2, i, k)
8768 a4_ad(2, i, k) = 0.0
8772 x7_ad = a4_ad(2, i, k)
8773 a4_ad(2, i, k) = 0.0
8777 IF (branch .LT. 2)
THEN 8778 IF (branch .EQ. 0)
THEN 8786 IF (branch .EQ. 2)
THEN 8789 a4_ad(1, i, k) = a4_ad(1, i, k) + y15_ad
8795 IF (branch .EQ. 0)
THEN 8798 a4_ad(2, i, k) = a4_ad(2, i, k) + x7_ad
8802 IF (branch .LT. 2)
THEN 8803 IF (branch .EQ. 0)
THEN 8804 lac_1_ad = lac_1_ad + y27_ad
8806 pmp_1_ad = pmp_1_ad + y27_ad
8808 ELSE IF (branch .EQ. 2)
THEN 8809 lac_1_ad = lac_1_ad + y27_ad
8811 a4_ad(1, i, k) = a4_ad(1, i, k) + y27_ad
8813 pmp_1_ad = pmp_1_ad + lac_1_ad
8814 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
8815 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
8816 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
8819 a4_ad(4, i, k) = 0.0
8821 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8822 a4_ad(3, i, k) = 0.0
8824 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8825 a4_ad(2, i, k) = 0.0
8830 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
8831 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
8832 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
8833 a4_ad(4, i, k) = 0.0
8836 ELSE IF (branch .LT. 6)
THEN 8837 IF (branch .EQ. 4)
THEN 8840 IF (branch .EQ. 0)
THEN 8842 temp_ad22 = 3.*a4_ad(4, i, k)
8843 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad22
8844 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad22
8845 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad22
8846 a4_ad(4, i, k) = 0.0
8847 ELSE IF (branch .EQ. 1)
THEN 8849 temp_ad21 = 3.*a4_ad(4, i, k)
8850 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad21
8851 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad21
8852 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad21
8853 a4_ad(4, i, k) = 0.0
8855 IF (branch .EQ. 0)
THEN 8857 y18_ad = a4_ad(3, i, k)
8858 a4_ad(3, i, k) = 0.0
8862 x10_ad = a4_ad(3, i, k)
8863 a4_ad(3, i, k) = 0.0
8867 IF (branch .LT. 2)
THEN 8868 IF (branch .EQ. 0)
THEN 8876 IF (branch .EQ. 2)
THEN 8879 a4_ad(1, i, k) = a4_ad(1, i, k) + y18_ad
8885 IF (branch .EQ. 0)
THEN 8888 a4_ad(3, i, k) = a4_ad(3, i, k) + x10_ad
8892 IF (branch .LT. 2)
THEN 8893 IF (branch .EQ. 0)
THEN 8894 lac_2_ad = lac_2_ad + y30_ad
8896 pmp_2_ad = pmp_2_ad + y30_ad
8898 ELSE IF (branch .EQ. 2)
THEN 8899 lac_2_ad = lac_2_ad + y30_ad
8901 a4_ad(1, i, k) = a4_ad(1, i, k) + y30_ad
8903 pmp_2_ad = pmp_2_ad + lac_2_ad
8904 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
8905 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
8906 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
8908 IF (branch .EQ. 0)
THEN 8910 y17_ad = a4_ad(2, i, k)
8911 a4_ad(2, i, k) = 0.0
8915 x9_ad = a4_ad(2, i, k)
8916 a4_ad(2, i, k) = 0.0
8920 IF (branch .LT. 2)
THEN 8921 IF (branch .EQ. 0)
THEN 8929 IF (branch .EQ. 2)
THEN 8932 a4_ad(1, i, k) = a4_ad(1, i, k) + y17_ad
8938 IF (branch .EQ. 0)
THEN 8941 a4_ad(2, i, k) = a4_ad(2, i, k) + x9_ad
8945 IF (branch .LT. 2)
THEN 8946 IF (branch .EQ. 0)
THEN 8947 lac_1_ad = lac_1_ad + y29_ad
8949 pmp_1_ad = pmp_1_ad + y29_ad
8951 ELSE IF (branch .EQ. 2)
THEN 8952 lac_1_ad = lac_1_ad + y29_ad
8954 a4_ad(1, i, k) = a4_ad(1, i, k) + y29_ad
8956 pmp_1_ad = pmp_1_ad + lac_1_ad
8957 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
8958 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
8959 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
8962 a4_ad(4, i, k) = 0.0
8964 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
8965 a4_ad(3, i, k) = 0.0
8967 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
8968 a4_ad(2, i, k) = 0.0
8974 temp_ad23 = 3.*a4_ad(4, i, k)
8975 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad23
8976 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad23
8977 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad23
8978 a4_ad(4, i, k) = 0.0
8981 ELSE IF (branch .EQ. 6)
THEN 8984 IF (branch .NE. 0)
THEN 8985 IF (branch .NE. 1)
THEN 8987 temp_ad24 = 3.*a4_ad(4, i, k)
8988 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad24
8989 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad24
8990 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad24
8991 a4_ad(4, i, k) = 0.0
8993 IF (branch .EQ. 0)
THEN 8995 y20_ad = a4_ad(3, i, k)
8996 a4_ad(3, i, k) = 0.0
9000 x12_ad = a4_ad(3, i, k)
9001 a4_ad(3, i, k) = 0.0
9005 IF (branch .LT. 2)
THEN 9006 IF (branch .EQ. 0)
THEN 9014 IF (branch .EQ. 2)
THEN 9017 a4_ad(1, i, k) = a4_ad(1, i, k) + y20_ad
9023 IF (branch .EQ. 0)
THEN 9026 a4_ad(3, i, k) = a4_ad(3, i, k) + x12_ad
9030 IF (branch .LT. 2)
THEN 9031 IF (branch .EQ. 0)
THEN 9032 lac_2_ad = lac_2_ad + y32_ad
9034 pmp_2_ad = pmp_2_ad + y32_ad
9036 ELSE IF (branch .EQ. 2)
THEN 9037 lac_2_ad = lac_2_ad + y32_ad
9039 a4_ad(1, i, k) = a4_ad(1, i, k) + y32_ad
9041 pmp_2_ad = pmp_2_ad + lac_2_ad
9042 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
9043 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
9044 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
9046 IF (branch .EQ. 0)
THEN 9048 y19_ad = a4_ad(2, i, k)
9049 a4_ad(2, i, k) = 0.0
9053 x11_ad = a4_ad(2, i, k)
9054 a4_ad(2, i, k) = 0.0
9058 IF (branch .LT. 2)
THEN 9059 IF (branch .EQ. 0)
THEN 9067 IF (branch .EQ. 2)
THEN 9070 a4_ad(1, i, k) = a4_ad(1, i, k) + y19_ad
9076 IF (branch .EQ. 0)
THEN 9079 a4_ad(2, i, k) = a4_ad(2, i, k) + x11_ad
9083 IF (branch .LT. 2)
THEN 9084 IF (branch .EQ. 0)
THEN 9085 lac_1_ad = lac_1_ad + y31_ad
9087 pmp_1_ad = pmp_1_ad + y31_ad
9089 ELSE IF (branch .EQ. 2)
THEN 9090 lac_1_ad = lac_1_ad + y31_ad
9092 a4_ad(1, i, k) = a4_ad(1, i, k) + y31_ad
9094 pmp_1_ad = pmp_1_ad + lac_1_ad
9095 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
9096 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
9097 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
9104 IF (branch .EQ. 0)
THEN 9106 temp_ad25 = 3.*a4_ad(4, i, k)
9107 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad25
9108 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad25
9109 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad25
9110 a4_ad(4, i, k) = 0.0
9113 a4_ad(4, i, k) = 0.0
9115 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
9116 a4_ad(3, i, k) = 0.0
9118 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
9119 a4_ad(2, i, k) = 0.0
9128 temp_ad17 = 3.*a4_ad(4, i, 2)
9129 a4_ad(1, i, 2) = a4_ad(1, i, 2) + 2.*temp_ad17
9130 a4_ad(2, i, 2) = a4_ad(2, i, 2) - temp_ad17
9131 a4_ad(3, i, 2) = a4_ad(3, i, 2) - temp_ad17
9132 a4_ad(4, i, 2) = 0.0
9135 IF (branch .NE. 0)
THEN 9140 temp_ad16 = 3.*a4_ad(4, i, 1)
9141 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 2.*temp_ad16
9142 a4_ad(2, i, 1) = a4_ad(2, i, 1) - temp_ad16
9143 a4_ad(3, i, 1) = a4_ad(3, i, 1) - temp_ad16
9144 a4_ad(4, i, 1) = 0.0
9148 IF (branch .LT. 2)
THEN 9149 IF (branch .EQ. 0)
THEN 9152 IF (branch .EQ. 0)
THEN 9156 a4_ad(2, i, 1) = 0.0
9162 IF (branch .NE. 0)
THEN 9164 a4_ad(2, i, 1) = 0.0
9168 ELSE IF (branch .EQ. 2)
THEN 9171 a4_ad(4, i, 1) = 0.0
9173 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(3, i, 1)
9174 a4_ad(3, i, 1) = 0.0
9176 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(2, i, 1)
9177 a4_ad(2, i, 1) = 0.0
9182 IF (branch .NE. 0)
THEN 9185 temp_ad15 = 3.*a4_ad(4, i, k)
9186 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad15
9187 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad15
9188 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad15
9189 a4_ad(4, i, k) = 0.0
9197 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
9198 a4_ad(3, i, k) = 0.0
9200 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
9201 a4_ad(2, i, k) = 0.0
9206 IF (branch .EQ. 0)
THEN 9213 IF (branch .EQ. 0)
THEN 9214 a4_ad(1, i, km) = a4_ad(1, i, km) + y8_ad
9216 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + y8_ad
9219 IF (branch .EQ. 0)
THEN 9228 IF (branch .EQ. 0)
THEN 9229 a4_ad(1, i, km) = a4_ad(1, i, km) + y7_ad
9231 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + y7_ad
9237 IF (branch .NE. 0)
THEN 9238 IF (branch .LT. 4)
THEN 9239 IF (branch .EQ. 1)
THEN 9241 ELSE IF (branch .EQ. 2)
THEN 9249 ELSE IF (branch .EQ. 4)
THEN 9253 IF (branch .EQ. 5)
THEN 9260 IF (branch .EQ. 0)
THEN 9261 a4_ad(1, i, k) = a4_ad(1, i, k) + y4_ad
9263 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y4_ad
9266 IF (branch .EQ. 0)
THEN 9275 IF (branch .EQ. 0)
THEN 9276 a4_ad(1, i, k) = a4_ad(1, i, k) + y3_ad
9278 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y3_ad
9283 IF (branch .EQ. 0)
THEN 9284 a4_ad(1, i, k) = a4_ad(1, i, k) + y5_ad
9286 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y5_ad
9291 IF (branch .EQ. 0)
THEN 9300 IF (branch .EQ. 0)
THEN 9301 a4_ad(1, i, k) = a4_ad(1, i, k) + y6_ad
9303 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y6_ad
9310 a4_ad(1, i, k) = a4_ad(1, i, k) + gam_ad(i, k)
9311 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) - gam_ad(i, k)
9317 IF (branch .EQ. 0)
THEN 9324 IF (branch .EQ. 0)
THEN 9325 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y2_ad
9327 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y2_ad
9330 IF (branch .EQ. 0)
THEN 9339 IF (branch .EQ. 0)
THEN 9340 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y1_ad
9342 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y1_ad
9347 IF (branch .EQ. 0)
THEN 9351 gam_ad(i, k) = gam_ad(i, k) - q(i, k+1)*q_ad(i, k)
9352 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k)*q_ad(i, k)
9357 a_bot = 1. + d4(i)*(d4(i)+1.5)
9359 temp2 = d4(i)*(d4(i)+0.5) - a_bot*gam(i, km)
9360 temp_ad11 = q_ad(i, km+1)/temp2
9361 temp1 = d4(i)*(d4(i)+1.)
9362 temp_ad12 = 2.*a4(1, i, km)*temp_ad11
9363 temp_ad13 = -((2.*(temp1*a4(1, i, km))+a4(1, i, km-1)-a_bot*q(i&
9364 & , km))*temp_ad11/temp2)
9365 a4_ad(1, i, km) = a4_ad(1, i, km) + 2.*temp1*temp_ad11
9366 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + temp_ad11
9367 a_bot_ad = -(gam(i, km)*temp_ad13) - q(i, km)*temp_ad11
9368 d4_ad(i) = d4_ad(i) + (2*d4(i)+1.5)*a_bot_ad + (2*d4(i)+0.5)*&
9369 & temp_ad13 + (2*d4(i)+1.)*temp_ad12
9370 q_ad(i, km) = q_ad(i, km) - a_bot*temp_ad11
9371 gam_ad(i, km) = gam_ad(i, km) - a_bot*temp_ad13
9376 temp_ad9 = q_ad(i, k)/bet
9377 temp_ad8 = 3.*temp_ad9
9379 bet_ad = -((3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))*&
9380 & temp_ad9/bet) - d4(i)*gam_ad(i, k)/bet**2
9381 d4_ad(i) = d4_ad(i) + a4(1, i, k)*temp_ad8 + 2*bet_ad + gam_ad&
9384 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + temp_ad8
9385 a4_ad(1, i, k) = a4_ad(1, i, k) + d4(i)*temp_ad8
9386 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad9
9389 gam_ad(i, k-1) = gam_ad(i, k-1) - bet_ad
9391 temp_ad10 = d4_ad(i)/delp(i, k)
9392 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad10
9393 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad10/delp(i&
9399 grat = delp(i, 2)/delp(i, 1)
9400 bet = grat*(grat+0.5)
9401 temp_ad4 = gam_ad(i, 1)/bet
9403 temp_ad6 = q_ad(i, 1)/bet
9404 temp_ad5 = a4(1, i, 1)*temp_ad6
9405 temp0 = 2*grat*(grat+1.)
9406 bet_ad = -((temp0*a4(1, i, 1)+a4(1, i, 2))*temp_ad6/bet) - (grat&
9407 & *(grat+1.5)+1.)*temp_ad4/bet
9408 grat_ad = (4*grat+2*1.)*temp_ad5 + (2*grat+0.5)*bet_ad + (2*grat&
9410 a4_ad(1, i, 1) = a4_ad(1, i, 1) + temp0*temp_ad6
9411 a4_ad(1, i, 2) = a4_ad(1, i, 2) + temp_ad6
9413 temp_ad7 = grat_ad/delp(i, 1)
9414 delp_ad(i, 2) = delp_ad(i, 2) + temp_ad7
9415 delp_ad(i, 1) = delp_ad(i, 1) - delp(i, 2)*temp_ad7/delp(i, 1)
9421 gam_ad(i, k+1) = gam_ad(i, k+1) - q(i, k+1)*q_ad(i, k)
9422 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k+1)*q_ad(i, k)
9428 grat = delp(i, km-1)/delp(i, km)
9430 temp = 2*grat - gam(i, km) + 2.
9431 temp_ad1 = q_ad(i, km)/temp
9432 temp_ad2 = -((3.*(a4(1, i, km-1)+a4(1, i, km))-qs(i)*grat-q(i, &
9433 & km-1))*temp_ad1/temp)
9434 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + 3.*temp_ad1
9435 a4_ad(1, i, km) = a4_ad(1, i, km) + 3.*temp_ad1
9436 grat_ad = 2*temp_ad2 - qs(i)*temp_ad1
9437 q_ad(i, km-1) = q_ad(i, km-1) - temp_ad1
9438 gam_ad(i, km) = gam_ad(i, km) - temp_ad2
9440 temp_ad3 = grat_ad/delp(i, km)
9441 delp_ad(i, km-1) = delp_ad(i, km-1) + temp_ad3
9442 delp_ad(i, km) = delp_ad(i, km) - delp(i, km-1)*temp_ad3/delp(i&
9447 temp_ad = q_ad(i, k)/bet
9449 grat = delp(i, k-1)/delp(i, k)
9450 bet_ad = -((3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*temp_ad/&
9451 & bet) - grat*gam_ad(i, k+1)/bet**2
9452 grat_ad = 2*bet_ad + gam_ad(i, k+1)/bet
9453 gam_ad(i, k+1) = 0.0
9454 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + 3.*temp_ad
9455 a4_ad(1, i, k) = a4_ad(1, i, k) + 3.*temp_ad
9456 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad
9459 gam_ad(i, k) = gam_ad(i, k) - bet_ad
9460 temp_ad0 = grat_ad/delp(i, k)
9461 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad0
9462 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad0/delp(i, &
9467 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 1.5*q_ad(i, 1)
9472 SUBROUTINE scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
9476 INTEGER,
INTENT(IN) :: i1, i2
9478 INTEGER,
INTENT(IN) :: km
9480 INTEGER,
INTENT(IN) :: iv
9483 INTEGER,
INTENT(IN) :: kord
9484 REAL,
INTENT(IN) :: qs(i1:i2)
9486 REAL,
INTENT(IN) :: delp(i1:i2, km)
9488 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
9489 REAL,
INTENT(IN) :: qmin
9491 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
9492 REAL :: gam(i1:i2, km)
9493 REAL :: q(i1:i2, km+1)
9495 REAL :: bet, a_bot, grat
9496 REAL :: pmp_1, lac_1, pmp_2, lac_2
9562 IF (iv .EQ. -2)
THEN 9565 q(i, 1) = 1.5*a4(1, i, 1)
9569 grat = delp(i, k-1)/delp(i, k)
9570 bet = 2. + grat + grat - gam(i, k)
9571 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
9572 gam(i, k+1) = grat/bet
9576 grat = delp(i, km-1)/delp(i, km)
9577 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
9578 & 1))/(2.+grat+grat-gam(i, km))
9583 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
9589 grat = delp(i, 2)/delp(i, 1)
9590 bet = grat*(grat+0.5)
9591 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
9592 gam(i, 1) = (1.+grat*(grat+1.5))/bet
9596 d4(i) = delp(i, k-1)/delp(i, k)
9597 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
9598 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
9599 gam(i, k) = d4(i)/bet
9603 a_bot = 1. + d4(i)*(d4(i)+1.5)
9604 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
9605 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
9609 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
9613 IF (kord .GE. 0.)
THEN 9619 IF (abs0 .GT. 16)
THEN 9622 a4(2, i, k) = q(i, k)
9623 a4(3, i, k) = q(i, k+1)
9624 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
9636 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 9641 IF (q(i, 2) .GT. y1)
THEN 9646 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 9651 IF (q(i, 2) .LT. y2)
THEN 9659 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
9665 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 9666 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 9671 IF (q(i, k) .GT. y3)
THEN 9676 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 9681 IF (q(i, k) .LT. y4)
THEN 9686 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 9687 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 9692 IF (q(i, k) .LT. y5)
THEN 9698 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 9703 IF (q(i, k) .GT. y6)
THEN 9709 IF (0. .LT. q(i, k))
THEN 9720 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 9725 IF (q(i, km) .GT. y7)
THEN 9730 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 9735 IF (q(i, km) .LT. y8)
THEN 9743 a4(2, i, k) = q(i, k)
9744 a4(3, i, k) = q(i, k+1)
9748 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 9750 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
9755 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
9758 IF (kord .GE. 0.)
THEN 9763 IF (abs1 .EQ. 16)
THEN 9765 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
9766 IF (a4(4, i, k) .GE. 0.)
THEN 9771 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 9772 abs13 = a4(2, i, k) - a4(3, i, k)
9774 abs13 = -(a4(2, i, k)-a4(3, i, k))
9776 ext6(i, k) = abs2 .GT. abs13
9787 IF (0. .LT. a4(2, i, 1))
THEN 9788 a4(2, i, 1) = a4(2, i, 1)
9793 ELSE IF (iv .EQ. -1)
THEN 9795 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
9797 ELSE IF (iv .EQ. 2)
THEN 9799 a4(2, i, 1) = a4(1, i, 1)
9800 a4(3, i, 1) = a4(1, i, 1)
9806 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
9808 CALL cs_limiters(im, extm(i1, 1), a4(1, i1, 1), 1)
9812 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
9814 CALL cs_limiters(im, extm(i1, 2), a4(1, i1, 2), 2)
9819 IF (kord .GE. 0.)
THEN 9824 IF (abs3 .LT. 9)
THEN 9827 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
9828 lac_1 = pmp_1 + 1.5*gam(i, k+2)
9829 IF (a4(1, i, k) .GT. pmp_1)
THEN 9830 IF (pmp_1 .GT. lac_1)
THEN 9835 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 9840 IF (a4(2, i, k) .LT. y21)
THEN 9845 IF (a4(1, i, k) .LT. pmp_1)
THEN 9846 IF (pmp_1 .LT. lac_1)
THEN 9851 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 9856 IF (x1 .GT. y9)
THEN 9862 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
9863 lac_2 = pmp_2 - 1.5*gam(i, k-1)
9864 IF (a4(1, i, k) .GT. pmp_2)
THEN 9865 IF (pmp_2 .GT. lac_2)
THEN 9870 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 9875 IF (a4(3, i, k) .LT. y22)
THEN 9880 IF (a4(1, i, k) .LT. pmp_2)
THEN 9881 IF (pmp_2 .LT. lac_2)
THEN 9886 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 9891 IF (x2 .GT. y10)
THEN 9896 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
9899 IF (kord .GE. 0.)
THEN 9904 IF (abs4 .EQ. 9)
THEN 9906 IF (extm(i, k) .AND. extm(i, k-1))
THEN 9908 a4(2, i, k) = a4(1, i, k)
9909 a4(3, i, k) = a4(1, i, k)
9911 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 9913 a4(2, i, k) = a4(1, i, k)
9914 a4(3, i, k) = a4(1, i, k)
9916 ELSE IF (extm(i, k) .AND. a4(1, i, k) .LT. qmin)
THEN 9918 a4(2, i, k) = a4(1, i, k)
9919 a4(3, i, k) = a4(1, i, k)
9922 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k&
9924 IF (a4(4, i, k) .GE. 0.)
THEN 9929 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 9930 abs14 = a4(2, i, k) - a4(3, i, k)
9932 abs14 = -(a4(2, i, k)-a4(3, i, k))
9935 IF (abs5 .GT. abs14)
THEN 9936 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
9937 lac_1 = pmp_1 + 1.5*gam(i, k+2)
9938 IF (a4(1, i, k) .GT. pmp_1)
THEN 9939 IF (pmp_1 .GT. lac_1)
THEN 9944 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 9949 IF (a4(2, i, k) .LT. y23)
THEN 9954 IF (a4(1, i, k) .LT. pmp_1)
THEN 9955 IF (pmp_1 .LT. lac_1)
THEN 9960 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 9965 IF (x3 .GT. y11)
THEN 9970 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
9971 lac_2 = pmp_2 - 1.5*gam(i, k-1)
9972 IF (a4(1, i, k) .GT. pmp_2)
THEN 9973 IF (pmp_2 .GT. lac_2)
THEN 9978 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 9983 IF (a4(3, i, k) .LT. y24)
THEN 9988 IF (a4(1, i, k) .LT. pmp_2)
THEN 9989 IF (pmp_2 .LT. lac_2)
THEN 9994 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 9999 IF (x4 .GT. y12)
THEN 10004 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i&
10010 IF (kord .GE. 0.)
THEN 10015 IF (abs6 .EQ. 10)
THEN 10017 IF (extm(i, k))
THEN 10018 IF ((a4(1, i, k) .LT. qmin .OR. extm(i, k-1)) .OR. &
10019 & extm(i, k+1))
THEN 10021 a4(2, i, k) = a4(1, i, k)
10022 a4(3, i, k) = a4(1, i, k)
10026 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
10031 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
10033 IF (a4(4, i, k) .GE. 0.)
THEN 10036 abs7 = -a4(4, i, k)
10038 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 10039 abs15 = a4(2, i, k) - a4(3, i, k)
10041 abs15 = -(a4(2, i, k)-a4(3, i, k))
10044 IF (abs7 .GT. abs15)
THEN 10045 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
10046 lac_1 = pmp_1 + 1.5*gam(i, k+2)
10047 IF (a4(1, i, k) .GT. pmp_1)
THEN 10048 IF (pmp_1 .GT. lac_1)
THEN 10053 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 10058 IF (a4(2, i, k) .LT. y25)
THEN 10063 IF (a4(1, i, k) .LT. pmp_1)
THEN 10064 IF (pmp_1 .LT. lac_1)
THEN 10069 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 10074 IF (x5 .GT. y13)
THEN 10079 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
10080 lac_2 = pmp_2 - 1.5*gam(i, k-1)
10081 IF (a4(1, i, k) .GT. pmp_2)
THEN 10082 IF (pmp_2 .GT. lac_2)
THEN 10087 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 10092 IF (a4(3, i, k) .LT. y26)
THEN 10097 IF (a4(1, i, k) .LT. pmp_2)
THEN 10098 IF (pmp_2 .LT. lac_2)
THEN 10103 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 10108 IF (x6 .GT. y14)
THEN 10113 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
10119 IF (kord .GE. 0.)
THEN 10124 IF (abs8 .EQ. 12)
THEN 10126 IF (extm(i, k))
THEN 10127 a4(2, i, k) = a4(1, i, k)
10128 a4(3, i, k) = a4(1, i, k)
10132 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
10134 IF (a4(4, i, k) .GE. 0.)
THEN 10137 abs9 = -a4(4, i, k)
10139 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 10140 abs16 = a4(2, i, k) - a4(3, i, k)
10142 abs16 = -(a4(2, i, k)-a4(3, i, k))
10145 IF (abs9 .GT. abs16)
THEN 10146 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
10147 lac_1 = pmp_1 + 1.5*gam(i, k+2)
10148 IF (a4(1, i, k) .GT. pmp_1)
THEN 10149 IF (pmp_1 .GT. lac_1)
THEN 10154 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 10159 IF (a4(2, i, k) .LT. y27)
THEN 10164 IF (a4(1, i, k) .LT. pmp_1)
THEN 10165 IF (pmp_1 .LT. lac_1)
THEN 10170 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 10175 IF (x7 .GT. y15)
THEN 10180 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
10181 lac_2 = pmp_2 - 1.5*gam(i, k-1)
10182 IF (a4(1, i, k) .GT. pmp_2)
THEN 10183 IF (pmp_2 .GT. lac_2)
THEN 10188 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 10193 IF (a4(3, i, k) .LT. y28)
THEN 10198 IF (a4(1, i, k) .LT. pmp_2)
THEN 10199 IF (pmp_2 .LT. lac_2)
THEN 10204 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 10209 IF (x8 .GT. y16)
THEN 10214 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
10220 IF (kord .GE. 0.)
THEN 10225 IF (abs10 .EQ. 13)
THEN 10227 IF (extm(i, k))
THEN 10228 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 10230 a4(2, i, k) = a4(1, i, k)
10231 a4(3, i, k) = a4(1, i, k)
10235 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
10236 lac_1 = pmp_1 + 1.5*gam(i, k+2)
10237 IF (a4(1, i, k) .GT. pmp_1)
THEN 10238 IF (pmp_1 .GT. lac_1)
THEN 10243 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 10248 IF (a4(2, i, k) .LT. y29)
THEN 10253 IF (a4(1, i, k) .LT. pmp_1)
THEN 10254 IF (pmp_1 .LT. lac_1)
THEN 10259 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 10264 IF (x9 .GT. y17)
THEN 10270 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
10271 lac_2 = pmp_2 - 1.5*gam(i, k-1)
10272 IF (a4(1, i, k) .GT. pmp_2)
THEN 10273 IF (pmp_2 .GT. lac_2)
THEN 10278 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 10283 IF (a4(3, i, k) .LT. y30)
THEN 10288 IF (a4(1, i, k) .LT. pmp_2)
THEN 10289 IF (pmp_2 .LT. lac_2)
THEN 10294 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 10299 IF (x10 .GT. y18)
THEN 10304 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
10308 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
10313 IF (kord .GE. 0.)
THEN 10318 IF (abs11 .EQ. 14)
THEN 10320 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
10324 IF (kord .GE. 0.)
THEN 10329 IF (abs12 .EQ. 16)
THEN 10331 IF (ext6(i, k))
THEN 10332 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 10334 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
10335 lac_1 = pmp_1 + 1.5*gam(i, k+2)
10336 IF (a4(1, i, k) .GT. pmp_1)
THEN 10337 IF (pmp_1 .GT. lac_1)
THEN 10342 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 10347 IF (a4(2, i, k) .LT. y31)
THEN 10352 IF (a4(1, i, k) .LT. pmp_1)
THEN 10353 IF (pmp_1 .LT. lac_1)
THEN 10358 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 10363 IF (x11 .GT. y19)
THEN 10369 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
10370 lac_2 = pmp_2 - 1.5*gam(i, k-1)
10371 IF (a4(1, i, k) .GT. pmp_2)
THEN 10372 IF (pmp_2 .GT. lac_2)
THEN 10377 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 10382 IF (a4(3, i, k) .LT. y32)
THEN 10387 IF (a4(1, i, k) .LT. pmp_2)
THEN 10388 IF (pmp_2 .LT. lac_2)
THEN 10393 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 10398 IF (x12 .GT. y20)
THEN 10403 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k&
10411 IF (extm(i, k) .AND. ((extm(i, k-1) .OR. extm(i&
10412 & , k+1)) .OR. a4(1, i, k) .LT. qmin))
THEN 10414 a4(2, i, k) = a4(1, i, k)
10415 a4(3, i, k) = a4(1, i, k)
10418 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+&
10430 IF (iv .EQ. 0)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 0&
10437 IF (iv .EQ. 0)
THEN 10439 IF (0. .LT. a4(3, i, km))
THEN 10440 a4(3, i, km) = a4(3, i, km)
10445 ELSE IF (iv .EQ. -1)
THEN 10447 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.) a4(3, i, km) = 0.
10452 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
10454 IF (k .EQ. km - 1)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k&
10456 IF (k .EQ. km)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 1&
10481 SUBROUTINE cs_profile_adm(qs, qs_ad, a4, a4_ad, delp, delp_ad, km, i1&
10486 INTEGER,
INTENT(IN) :: i1, i2
10488 INTEGER,
INTENT(IN) :: km
10490 INTEGER,
INTENT(IN) :: iv
10493 INTEGER,
INTENT(IN) :: kord
10494 REAL,
INTENT(IN) :: qs(i1:i2)
10495 REAL :: qs_ad(i1:i2)
10497 REAL,
INTENT(IN) :: delp(i1:i2, km)
10498 REAL :: delp_ad(i1:i2, km)
10500 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
10501 REAL,
INTENT(INOUT) :: a4_ad(4, i1:i2, km)
10503 LOGICAL :: extm(i1:i2, km)
10504 REAL :: gam(i1:i2, km)
10505 REAL :: gam_ad(i1:i2, km)
10506 REAL :: q(i1:i2, km+1)
10507 REAL :: q_ad(i1:i2, km+1)
10509 REAL :: d4_ad(i1:i2)
10510 REAL :: bet, a_bot, grat
10511 REAL :: bet_ad, a_bot_ad, grat_ad
10512 REAL :: pmp_1, lac_1, pmp_2, lac_2
10513 REAL :: pmp_1_ad, lac_1_ad, pmp_2_ad, lac_2_ad
10514 INTEGER :: i, k, im
10636 IF (iv .EQ. -2)
THEN 10639 q(i, 1) = 1.5*a4(1, i, 1)
10643 grat = delp(i, k-1)/delp(i, k)
10645 bet = 2. + grat + grat - gam(i, k)
10647 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
10648 gam(i, k+1) = grat/bet
10652 grat = delp(i, km-1)/delp(i, km)
10654 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
10655 & 1))/(2.+grat+grat-gam(i, km))
10662 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
10669 grat = delp(i, 2)/delp(i, 1)
10670 bet = grat*(grat+0.5)
10671 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
10672 gam(i, 1) = (1.+grat*(grat+1.5))/bet
10677 d4(i) = delp(i, k-1)/delp(i, k)
10679 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
10681 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
10682 gam(i, k) = d4(i)/bet
10686 a_bot = 1. + d4(i)*(d4(i)+1.5)
10688 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
10689 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
10694 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
10699 IF (kord .GE. 0.)
THEN 10705 IF (abs0 .GT. 16)
THEN 10709 temp_ad14 = 3.*a4_ad(4, i, k)
10710 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad14
10711 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad14
10712 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad14
10713 a4_ad(4, i, k) = 0.0
10714 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
10715 a4_ad(3, i, k) = 0.0
10716 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
10717 a4_ad(2, i, k) = 0.0
10729 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 10736 IF (q(i, 2) .GT. y1)
THEN 10745 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 10752 IF (q(i, 2) .LT. y2)
THEN 10763 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
10769 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 10770 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 10777 IF (q(i, k) .GT. y3)
THEN 10786 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 10793 IF (q(i, k) .LT. y4)
THEN 10800 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 10801 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 10808 IF (q(i, k) .LT. y5)
THEN 10818 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 10825 IF (q(i, k) .GT. y6)
THEN 10834 IF (iv .EQ. 0)
THEN 10835 IF (0. .LT. q(i, k))
THEN 10850 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 10854 y7 = a4(1, i, km-1)
10857 IF (q(i, km) .GT. y7)
THEN 10863 q(i, km) = q(i, km)
10866 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 10870 y8 = a4(1, i, km-1)
10873 IF (q(i, km) .LT. y8)
THEN 10877 q(i, km) = q(i, km)
10884 a4(2, i, k) = q(i, k)
10886 a4(3, i, k) = q(i, k+1)
10890 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 10893 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
10899 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
10908 IF (iv .EQ. 0)
THEN 10910 IF (0. .LT. a4(2, i, 1))
THEN 10912 a4(2, i, 1) = a4(2, i, 1)
10921 ELSE IF (iv .EQ. -1)
THEN 10923 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.)
THEN 10932 ELSE IF (iv .EQ. 2)
THEN 10935 a4(2, i, 1) = a4(1, i, 1)
10937 a4(3, i, 1) = a4(1, i, 1)
10945 IF (iv .NE. 2)
THEN 10948 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
10958 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
10965 IF (kord .GE. 0.)
THEN 10970 IF (abs1 .LT. 9)
THEN 10973 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
10974 lac_1 = pmp_1 + 1.5*gam(i, k+2)
10975 IF (a4(1, i, k) .GT. pmp_1)
THEN 10976 IF (pmp_1 .GT. lac_1)
THEN 10983 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 10990 IF (a4(2, i, k) .LT. y19)
THEN 10997 IF (a4(1, i, k) .LT. pmp_1)
THEN 10998 IF (pmp_1 .LT. lac_1)
THEN 11005 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 11012 IF (x1 .GT. y9)
THEN 11022 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
11023 lac_2 = pmp_2 - 1.5*gam(i, k-1)
11024 IF (a4(1, i, k) .GT. pmp_2)
THEN 11025 IF (pmp_2 .GT. lac_2)
THEN 11032 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 11039 IF (a4(3, i, k) .LT. y20)
THEN 11046 IF (a4(1, i, k) .LT. pmp_2)
THEN 11047 IF (pmp_2 .LT. lac_2)
THEN 11054 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 11061 IF (x2 .GT. y10)
THEN 11071 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
11075 IF (kord .GE. 0.)
THEN 11080 IF (abs2 .EQ. 9)
THEN 11082 IF (extm(i, k) .AND. extm(i, k-1))
THEN 11086 a4(2, i, k) = a4(1, i, k)
11088 a4(3, i, k) = a4(1, i, k)
11092 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 11096 a4(2, i, k) = a4(1, i, k)
11098 a4(3, i, k) = a4(1, i, k)
11104 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i, &
11106 IF (a4(4, i, k) .GE. 0.)
THEN 11109 abs3 = -a4(4, i, k)
11111 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 11112 abs10 = a4(2, i, k) - a4(3, i, k)
11114 abs10 = -(a4(2, i, k)-a4(3, i, k))
11117 IF (abs3 .GT. abs10)
THEN 11118 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
11119 lac_1 = pmp_1 + 1.5*gam(i, k+2)
11120 IF (a4(1, i, k) .GT. pmp_1)
THEN 11121 IF (pmp_1 .GT. lac_1)
THEN 11128 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 11135 IF (a4(2, i, k) .LT. y21)
THEN 11142 IF (a4(1, i, k) .LT. pmp_1)
THEN 11143 IF (pmp_1 .LT. lac_1)
THEN 11150 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 11157 IF (x3 .GT. y11)
THEN 11166 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
11167 lac_2 = pmp_2 - 1.5*gam(i, k-1)
11168 IF (a4(1, i, k) .GT. pmp_2)
THEN 11169 IF (pmp_2 .GT. lac_2)
THEN 11176 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 11183 IF (a4(3, i, k) .LT. y22)
THEN 11190 IF (a4(1, i, k) .LT. pmp_2)
THEN 11191 IF (pmp_2 .LT. lac_2)
THEN 11198 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 11205 IF (x4 .GT. y12)
THEN 11215 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
11225 IF (kord .GE. 0.)
THEN 11230 IF (abs4 .EQ. 10)
THEN 11232 IF (extm(i, k))
THEN 11233 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 11236 a4(2, i, k) = a4(1, i, k)
11238 a4(3, i, k) = a4(1, i, k)
11245 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
11252 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
11254 IF (a4(4, i, k) .GE. 0.)
THEN 11257 abs5 = -a4(4, i, k)
11259 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 11260 abs11 = a4(2, i, k) - a4(3, i, k)
11262 abs11 = -(a4(2, i, k)-a4(3, i, k))
11265 IF (abs5 .GT. abs11)
THEN 11266 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
11267 lac_1 = pmp_1 + 1.5*gam(i, k+2)
11268 IF (a4(1, i, k) .GT. pmp_1)
THEN 11269 IF (pmp_1 .GT. lac_1)
THEN 11276 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 11283 IF (a4(2, i, k) .LT. y23)
THEN 11290 IF (a4(1, i, k) .LT. pmp_1)
THEN 11291 IF (pmp_1 .LT. lac_1)
THEN 11298 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 11305 IF (x5 .GT. y13)
THEN 11314 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
11315 lac_2 = pmp_2 - 1.5*gam(i, k-1)
11316 IF (a4(1, i, k) .GT. pmp_2)
THEN 11317 IF (pmp_2 .GT. lac_2)
THEN 11324 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 11331 IF (a4(3, i, k) .LT. y24)
THEN 11338 IF (a4(1, i, k) .LT. pmp_2)
THEN 11339 IF (pmp_2 .LT. lac_2)
THEN 11346 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 11353 IF (x6 .GT. y14)
THEN 11363 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
11373 IF (kord .GE. 0.)
THEN 11378 IF (abs6 .EQ. 12)
THEN 11380 IF (extm(i, k))
THEN 11383 a4(2, i, k) = a4(1, i, k)
11385 a4(3, i, k) = a4(1, i, k)
11392 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
11394 IF (a4(4, i, k) .GE. 0.)
THEN 11397 abs7 = -a4(4, i, k)
11399 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 11400 abs12 = a4(2, i, k) - a4(3, i, k)
11402 abs12 = -(a4(2, i, k)-a4(3, i, k))
11405 IF (abs7 .GT. abs12)
THEN 11406 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
11407 lac_1 = pmp_1 + 1.5*gam(i, k+2)
11408 IF (a4(1, i, k) .GT. pmp_1)
THEN 11409 IF (pmp_1 .GT. lac_1)
THEN 11416 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 11423 IF (a4(2, i, k) .LT. y25)
THEN 11430 IF (a4(1, i, k) .LT. pmp_1)
THEN 11431 IF (pmp_1 .LT. lac_1)
THEN 11438 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 11445 IF (x7 .GT. y15)
THEN 11454 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
11455 lac_2 = pmp_2 - 1.5*gam(i, k-1)
11456 IF (a4(1, i, k) .GT. pmp_2)
THEN 11457 IF (pmp_2 .GT. lac_2)
THEN 11464 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 11471 IF (a4(3, i, k) .LT. y26)
THEN 11478 IF (a4(1, i, k) .LT. pmp_2)
THEN 11479 IF (pmp_2 .LT. lac_2)
THEN 11486 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 11493 IF (x8 .GT. y16)
THEN 11503 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
11513 IF (kord .GE. 0.)
THEN 11518 IF (abs8 .EQ. 13)
THEN 11520 IF (extm(i, k))
THEN 11521 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 11524 a4(2, i, k) = a4(1, i, k)
11526 a4(3, i, k) = a4(1, i, k)
11532 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
11533 lac_1 = pmp_1 + 1.5*gam(i, k+2)
11534 IF (a4(1, i, k) .GT. pmp_1)
THEN 11535 IF (pmp_1 .GT. lac_1)
THEN 11542 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 11549 IF (a4(2, i, k) .LT. y27)
THEN 11556 IF (a4(1, i, k) .LT. pmp_1)
THEN 11557 IF (pmp_1 .LT. lac_1)
THEN 11564 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 11571 IF (x9 .GT. y17)
THEN 11581 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
11582 lac_2 = pmp_2 - 1.5*gam(i, k-1)
11583 IF (a4(1, i, k) .GT. pmp_2)
THEN 11584 IF (pmp_2 .GT. lac_2)
THEN 11591 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 11598 IF (a4(3, i, k) .LT. y28)
THEN 11605 IF (a4(1, i, k) .LT. pmp_2)
THEN 11606 IF (pmp_2 .LT. lac_2)
THEN 11613 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 11620 IF (x10 .GT. y18)
THEN 11630 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
11636 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
11643 IF (kord .GE. 0.)
THEN 11648 IF (abs9 .EQ. 14)
THEN 11651 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
11658 IF (extm(i, k) .AND. (extm(i, k-1) .OR. extm(i, k+&
11662 a4(2, i, k) = a4(1, i, k)
11664 a4(3, i, k) = a4(1, i, k)
11670 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
11683 IF (iv .EQ. 0)
THEN 11694 IF (iv .EQ. 0)
THEN 11696 IF (0. .LT. a4(3, i, km))
THEN 11698 a4(3, i, km) = a4(3, i, km)
11707 ELSE IF (iv .EQ. -1)
THEN 11709 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.)
THEN 11724 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
11726 IF (k .EQ. km - 1)
THEN 11732 IF (k .EQ. km)
THEN 11742 & i1, k), a4_ad(1, i1, k), 1)
11745 & i1, k), a4_ad(1, i1, k), 2)
11748 temp_ad22 = 3.*a4_ad(4, i, k)
11749 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad22
11750 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad22
11751 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad22
11752 a4_ad(4, i, k) = 0.0
11756 IF (branch .NE. 0)
THEN 11757 IF (branch .EQ. 1)
THEN 11760 IF (branch .NE. 0)
THEN 11762 a4_ad(3, i, km) = 0.0
11768 IF (branch .EQ. 0)
THEN 11772 a4_ad(3, i, km) = 0.0
11781 & i1, k), a4_ad(1, i1, k), 0)
11783 IF (branch .LT. 3)
THEN 11784 IF (branch .EQ. 0)
THEN 11787 temp_ad17 = 3.*a4_ad(4, i, k)
11788 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad17
11789 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad17
11790 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad17
11791 a4_ad(4, i, k) = 0.0
11793 IF (branch .EQ. 0)
THEN 11795 y10_ad = a4_ad(3, i, k)
11796 a4_ad(3, i, k) = 0.0
11800 x2_ad = a4_ad(3, i, k)
11801 a4_ad(3, i, k) = 0.0
11805 IF (branch .LT. 2)
THEN 11806 IF (branch .EQ. 0)
THEN 11814 IF (branch .EQ. 2)
THEN 11817 a4_ad(1, i, k) = a4_ad(1, i, k) + y10_ad
11823 IF (branch .EQ. 0)
THEN 11826 a4_ad(3, i, k) = a4_ad(3, i, k) + x2_ad
11830 IF (branch .LT. 2)
THEN 11831 IF (branch .EQ. 0)
THEN 11832 lac_2_ad = lac_2_ad + y20_ad
11834 pmp_2_ad = pmp_2_ad + y20_ad
11836 ELSE IF (branch .EQ. 2)
THEN 11837 lac_2_ad = lac_2_ad + y20_ad
11839 a4_ad(1, i, k) = a4_ad(1, i, k) + y20_ad
11841 pmp_2_ad = pmp_2_ad + lac_2_ad
11842 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
11843 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
11844 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
11846 IF (branch .EQ. 0)
THEN 11848 y9_ad = a4_ad(2, i, k)
11849 a4_ad(2, i, k) = 0.0
11853 x1_ad = a4_ad(2, i, k)
11854 a4_ad(2, i, k) = 0.0
11858 IF (branch .LT. 2)
THEN 11859 IF (branch .EQ. 0)
THEN 11867 IF (branch .EQ. 2)
THEN 11870 a4_ad(1, i, k) = a4_ad(1, i, k) + y9_ad
11876 IF (branch .EQ. 0)
THEN 11879 a4_ad(2, i, k) = a4_ad(2, i, k) + x1_ad
11883 IF (branch .LT. 2)
THEN 11884 IF (branch .EQ. 0)
THEN 11885 lac_1_ad = lac_1_ad + y19_ad
11887 pmp_1_ad = pmp_1_ad + y19_ad
11889 ELSE IF (branch .EQ. 2)
THEN 11890 lac_1_ad = lac_1_ad + y19_ad
11892 a4_ad(1, i, k) = a4_ad(1, i, k) + y19_ad
11894 pmp_1_ad = pmp_1_ad + lac_1_ad
11895 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
11896 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
11897 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
11899 ELSE IF (branch .EQ. 1)
THEN 11902 IF (branch .LT. 2)
THEN 11903 IF (branch .NE. 0)
THEN 11905 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
11906 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
11907 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
11908 a4_ad(4, i, k) = 0.0
11910 IF (branch .EQ. 0)
THEN 11912 y12_ad = a4_ad(3, i, k)
11913 a4_ad(3, i, k) = 0.0
11917 x4_ad = a4_ad(3, i, k)
11918 a4_ad(3, i, k) = 0.0
11922 IF (branch .LT. 2)
THEN 11923 IF (branch .EQ. 0)
THEN 11931 IF (branch .EQ. 2)
THEN 11934 a4_ad(1, i, k) = a4_ad(1, i, k) + y12_ad
11940 IF (branch .EQ. 0)
THEN 11943 a4_ad(3, i, k) = a4_ad(3, i, k) + x4_ad
11947 IF (branch .LT. 2)
THEN 11948 IF (branch .EQ. 0)
THEN 11949 lac_2_ad = lac_2_ad + y22_ad
11951 pmp_2_ad = pmp_2_ad + y22_ad
11953 ELSE IF (branch .EQ. 2)
THEN 11954 lac_2_ad = lac_2_ad + y22_ad
11956 a4_ad(1, i, k) = a4_ad(1, i, k) + y22_ad
11958 pmp_2_ad = pmp_2_ad + lac_2_ad
11959 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
11960 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
11961 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
11963 IF (branch .EQ. 0)
THEN 11965 y11_ad = a4_ad(2, i, k)
11966 a4_ad(2, i, k) = 0.0
11970 x3_ad = a4_ad(2, i, k)
11971 a4_ad(2, i, k) = 0.0
11975 IF (branch .LT. 2)
THEN 11976 IF (branch .EQ. 0)
THEN 11984 IF (branch .EQ. 2)
THEN 11987 a4_ad(1, i, k) = a4_ad(1, i, k) + y11_ad
11993 IF (branch .EQ. 0)
THEN 11996 a4_ad(2, i, k) = a4_ad(2, i, k) + x3_ad
12000 IF (branch .LT. 2)
THEN 12001 IF (branch .EQ. 0)
THEN 12002 lac_1_ad = lac_1_ad + y21_ad
12004 pmp_1_ad = pmp_1_ad + y21_ad
12006 ELSE IF (branch .EQ. 2)
THEN 12007 lac_1_ad = lac_1_ad + y21_ad
12009 a4_ad(1, i, k) = a4_ad(1, i, k) + y21_ad
12011 pmp_1_ad = pmp_1_ad + lac_1_ad
12012 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
12013 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
12014 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
12017 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12018 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12019 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12020 a4_ad(4, i, k) = 0.0
12021 ELSE IF (branch .EQ. 2)
THEN 12023 a4_ad(4, i, k) = 0.0
12025 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12026 a4_ad(3, i, k) = 0.0
12028 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12029 a4_ad(2, i, k) = 0.0
12032 a4_ad(4, i, k) = 0.0
12034 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12035 a4_ad(3, i, k) = 0.0
12037 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12038 a4_ad(2, i, k) = 0.0
12044 IF (branch .LT. 2)
THEN 12045 IF (branch .NE. 0)
THEN 12047 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12048 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12049 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12050 a4_ad(4, i, k) = 0.0
12052 IF (branch .EQ. 0)
THEN 12054 y14_ad = a4_ad(3, i, k)
12055 a4_ad(3, i, k) = 0.0
12059 x6_ad = a4_ad(3, i, k)
12060 a4_ad(3, i, k) = 0.0
12064 IF (branch .LT. 2)
THEN 12065 IF (branch .EQ. 0)
THEN 12073 IF (branch .EQ. 2)
THEN 12076 a4_ad(1, i, k) = a4_ad(1, i, k) + y14_ad
12082 IF (branch .EQ. 0)
THEN 12085 a4_ad(3, i, k) = a4_ad(3, i, k) + x6_ad
12089 IF (branch .LT. 2)
THEN 12090 IF (branch .EQ. 0)
THEN 12091 lac_2_ad = lac_2_ad + y24_ad
12093 pmp_2_ad = pmp_2_ad + y24_ad
12095 ELSE IF (branch .EQ. 2)
THEN 12096 lac_2_ad = lac_2_ad + y24_ad
12098 a4_ad(1, i, k) = a4_ad(1, i, k) + y24_ad
12100 pmp_2_ad = pmp_2_ad + lac_2_ad
12101 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
12102 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
12103 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
12105 IF (branch .EQ. 0)
THEN 12107 y13_ad = a4_ad(2, i, k)
12108 a4_ad(2, i, k) = 0.0
12112 x5_ad = a4_ad(2, i, k)
12113 a4_ad(2, i, k) = 0.0
12117 IF (branch .LT. 2)
THEN 12118 IF (branch .EQ. 0)
THEN 12126 IF (branch .EQ. 2)
THEN 12129 a4_ad(1, i, k) = a4_ad(1, i, k) + y13_ad
12135 IF (branch .EQ. 0)
THEN 12138 a4_ad(2, i, k) = a4_ad(2, i, k) + x5_ad
12142 IF (branch .LT. 2)
THEN 12143 IF (branch .EQ. 0)
THEN 12144 lac_1_ad = lac_1_ad + y23_ad
12146 pmp_1_ad = pmp_1_ad + y23_ad
12148 ELSE IF (branch .EQ. 2)
THEN 12149 lac_1_ad = lac_1_ad + y23_ad
12151 a4_ad(1, i, k) = a4_ad(1, i, k) + y23_ad
12153 pmp_1_ad = pmp_1_ad + lac_1_ad
12154 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
12155 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
12156 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
12159 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12160 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12161 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12162 a4_ad(4, i, k) = 0.0
12163 ELSE IF (branch .EQ. 2)
THEN 12165 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12166 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12167 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12168 a4_ad(4, i, k) = 0.0
12171 a4_ad(4, i, k) = 0.0
12173 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12174 a4_ad(3, i, k) = 0.0
12176 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12177 a4_ad(2, i, k) = 0.0
12181 ELSE IF (branch .LT. 5)
THEN 12182 IF (branch .EQ. 3)
THEN 12185 IF (branch .NE. 0)
THEN 12186 IF (branch .EQ. 1)
THEN 12188 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12189 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12190 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12191 a4_ad(4, i, k) = 0.0
12193 IF (branch .EQ. 0)
THEN 12195 y16_ad = a4_ad(3, i, k)
12196 a4_ad(3, i, k) = 0.0
12200 x8_ad = a4_ad(3, i, k)
12201 a4_ad(3, i, k) = 0.0
12205 IF (branch .LT. 2)
THEN 12206 IF (branch .EQ. 0)
THEN 12214 IF (branch .EQ. 2)
THEN 12217 a4_ad(1, i, k) = a4_ad(1, i, k) + y16_ad
12223 IF (branch .EQ. 0)
THEN 12226 a4_ad(3, i, k) = a4_ad(3, i, k) + x8_ad
12230 IF (branch .LT. 2)
THEN 12231 IF (branch .EQ. 0)
THEN 12232 lac_2_ad = lac_2_ad + y26_ad
12234 pmp_2_ad = pmp_2_ad + y26_ad
12236 ELSE IF (branch .EQ. 2)
THEN 12237 lac_2_ad = lac_2_ad + y26_ad
12239 a4_ad(1, i, k) = a4_ad(1, i, k) + y26_ad
12241 pmp_2_ad = pmp_2_ad + lac_2_ad
12242 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
12243 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
12244 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
12246 IF (branch .EQ. 0)
THEN 12248 y15_ad = a4_ad(2, i, k)
12249 a4_ad(2, i, k) = 0.0
12253 x7_ad = a4_ad(2, i, k)
12254 a4_ad(2, i, k) = 0.0
12258 IF (branch .LT. 2)
THEN 12259 IF (branch .EQ. 0)
THEN 12267 IF (branch .EQ. 2)
THEN 12270 a4_ad(1, i, k) = a4_ad(1, i, k) + y15_ad
12276 IF (branch .EQ. 0)
THEN 12279 a4_ad(2, i, k) = a4_ad(2, i, k) + x7_ad
12283 IF (branch .LT. 2)
THEN 12284 IF (branch .EQ. 0)
THEN 12285 lac_1_ad = lac_1_ad + y25_ad
12287 pmp_1_ad = pmp_1_ad + y25_ad
12289 ELSE IF (branch .EQ. 2)
THEN 12290 lac_1_ad = lac_1_ad + y25_ad
12292 a4_ad(1, i, k) = a4_ad(1, i, k) + y25_ad
12294 pmp_1_ad = pmp_1_ad + lac_1_ad
12295 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
12296 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
12297 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
12300 a4_ad(4, i, k) = 0.0
12302 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12303 a4_ad(3, i, k) = 0.0
12305 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12306 a4_ad(2, i, k) = 0.0
12311 a4_ad(1, i, k) = a4_ad(1, i, k) + 6.*a4_ad(4, i, k)
12312 a4_ad(2, i, k) = a4_ad(2, i, k) - 3.*a4_ad(4, i, k)
12313 a4_ad(3, i, k) = a4_ad(3, i, k) - 3.*a4_ad(4, i, k)
12314 a4_ad(4, i, k) = 0.0
12319 IF (branch .EQ. 0)
THEN 12321 temp_ad19 = 3.*a4_ad(4, i, k)
12322 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad19
12323 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad19
12324 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad19
12325 a4_ad(4, i, k) = 0.0
12326 ELSE IF (branch .EQ. 1)
THEN 12328 temp_ad18 = 3.*a4_ad(4, i, k)
12329 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad18
12330 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad18
12331 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad18
12332 a4_ad(4, i, k) = 0.0
12334 IF (branch .EQ. 0)
THEN 12336 y18_ad = a4_ad(3, i, k)
12337 a4_ad(3, i, k) = 0.0
12341 x10_ad = a4_ad(3, i, k)
12342 a4_ad(3, i, k) = 0.0
12346 IF (branch .LT. 2)
THEN 12347 IF (branch .EQ. 0)
THEN 12355 IF (branch .EQ. 2)
THEN 12358 a4_ad(1, i, k) = a4_ad(1, i, k) + y18_ad
12364 IF (branch .EQ. 0)
THEN 12367 a4_ad(3, i, k) = a4_ad(3, i, k) + x10_ad
12371 IF (branch .LT. 2)
THEN 12372 IF (branch .EQ. 0)
THEN 12373 lac_2_ad = lac_2_ad + y28_ad
12375 pmp_2_ad = pmp_2_ad + y28_ad
12377 ELSE IF (branch .EQ. 2)
THEN 12378 lac_2_ad = lac_2_ad + y28_ad
12380 a4_ad(1, i, k) = a4_ad(1, i, k) + y28_ad
12382 pmp_2_ad = pmp_2_ad + lac_2_ad
12383 gam_ad(i, k-1) = gam_ad(i, k-1) - 1.5*lac_2_ad
12384 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_2_ad
12385 gam_ad(i, k) = gam_ad(i, k) + 2.*pmp_2_ad
12387 IF (branch .EQ. 0)
THEN 12389 y17_ad = a4_ad(2, i, k)
12390 a4_ad(2, i, k) = 0.0
12394 x9_ad = a4_ad(2, i, k)
12395 a4_ad(2, i, k) = 0.0
12399 IF (branch .LT. 2)
THEN 12400 IF (branch .EQ. 0)
THEN 12408 IF (branch .EQ. 2)
THEN 12411 a4_ad(1, i, k) = a4_ad(1, i, k) + y17_ad
12417 IF (branch .EQ. 0)
THEN 12420 a4_ad(2, i, k) = a4_ad(2, i, k) + x9_ad
12424 IF (branch .LT. 2)
THEN 12425 IF (branch .EQ. 0)
THEN 12426 lac_1_ad = lac_1_ad + y27_ad
12428 pmp_1_ad = pmp_1_ad + y27_ad
12430 ELSE IF (branch .EQ. 2)
THEN 12431 lac_1_ad = lac_1_ad + y27_ad
12433 a4_ad(1, i, k) = a4_ad(1, i, k) + y27_ad
12435 pmp_1_ad = pmp_1_ad + lac_1_ad
12436 gam_ad(i, k+2) = gam_ad(i, k+2) + 1.5*lac_1_ad
12437 a4_ad(1, i, k) = a4_ad(1, i, k) + pmp_1_ad
12438 gam_ad(i, k+1) = gam_ad(i, k+1) - 2.*pmp_1_ad
12441 a4_ad(4, i, k) = 0.0
12443 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12444 a4_ad(3, i, k) = 0.0
12446 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12447 a4_ad(2, i, k) = 0.0
12451 ELSE IF (branch .EQ. 5)
THEN 12454 temp_ad20 = 3.*a4_ad(4, i, k)
12455 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad20
12456 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad20
12457 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad20
12458 a4_ad(4, i, k) = 0.0
12463 IF (branch .EQ. 0)
THEN 12465 temp_ad21 = 3.*a4_ad(4, i, k)
12466 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad21
12467 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad21
12468 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad21
12469 a4_ad(4, i, k) = 0.0
12472 a4_ad(4, i, k) = 0.0
12474 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(3, i, k)
12475 a4_ad(3, i, k) = 0.0
12477 a4_ad(1, i, k) = a4_ad(1, i, k) + a4_ad(2, i, k)
12478 a4_ad(2, i, k) = 0.0
12487 temp_ad16 = 3.*a4_ad(4, i, 2)
12488 a4_ad(1, i, 2) = a4_ad(1, i, 2) + 2.*temp_ad16
12489 a4_ad(2, i, 2) = a4_ad(2, i, 2) - temp_ad16
12490 a4_ad(3, i, 2) = a4_ad(3, i, 2) - temp_ad16
12491 a4_ad(4, i, 2) = 0.0
12494 IF (branch .NE. 0)
THEN 12499 temp_ad15 = 3.*a4_ad(4, i, 1)
12500 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 2.*temp_ad15
12501 a4_ad(2, i, 1) = a4_ad(2, i, 1) - temp_ad15
12502 a4_ad(3, i, 1) = a4_ad(3, i, 1) - temp_ad15
12503 a4_ad(4, i, 1) = 0.0
12507 IF (branch .LT. 2)
THEN 12508 IF (branch .EQ. 0)
THEN 12511 IF (branch .EQ. 0)
THEN 12515 a4_ad(2, i, 1) = 0.0
12521 IF (branch .NE. 0)
THEN 12523 a4_ad(2, i, 1) = 0.0
12527 ELSE IF (branch .EQ. 2)
THEN 12530 a4_ad(4, i, 1) = 0.0
12532 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(3, i, 1)
12533 a4_ad(3, i, 1) = 0.0
12535 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(2, i, 1)
12536 a4_ad(2, i, 1) = 0.0
12546 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
12547 a4_ad(3, i, k) = 0.0
12549 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
12550 a4_ad(2, i, k) = 0.0
12555 IF (branch .EQ. 0)
THEN 12556 y8_ad = q_ad(i, km)
12562 IF (branch .EQ. 0)
THEN 12563 a4_ad(1, i, km) = a4_ad(1, i, km) + y8_ad
12565 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + y8_ad
12568 IF (branch .EQ. 0)
THEN 12570 y7_ad = q_ad(i, km)
12577 IF (branch .EQ. 0)
THEN 12578 a4_ad(1, i, km) = a4_ad(1, i, km) + y7_ad
12580 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + y7_ad
12586 IF (branch .NE. 0)
THEN 12587 IF (branch .LT. 4)
THEN 12588 IF (branch .EQ. 1)
THEN 12590 ELSE IF (branch .EQ. 2)
THEN 12598 ELSE IF (branch .EQ. 4)
THEN 12602 IF (branch .EQ. 5)
THEN 12609 IF (branch .EQ. 0)
THEN 12610 a4_ad(1, i, k) = a4_ad(1, i, k) + y4_ad
12612 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y4_ad
12615 IF (branch .EQ. 0)
THEN 12624 IF (branch .EQ. 0)
THEN 12625 a4_ad(1, i, k) = a4_ad(1, i, k) + y3_ad
12627 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y3_ad
12632 IF (branch .EQ. 0)
THEN 12633 a4_ad(1, i, k) = a4_ad(1, i, k) + y5_ad
12635 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y5_ad
12640 IF (branch .EQ. 0)
THEN 12649 IF (branch .EQ. 0)
THEN 12650 a4_ad(1, i, k) = a4_ad(1, i, k) + y6_ad
12652 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + y6_ad
12659 a4_ad(1, i, k) = a4_ad(1, i, k) + gam_ad(i, k)
12660 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) - gam_ad(i, k)
12666 IF (branch .EQ. 0)
THEN 12673 IF (branch .EQ. 0)
THEN 12674 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y2_ad
12676 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y2_ad
12679 IF (branch .EQ. 0)
THEN 12688 IF (branch .EQ. 0)
THEN 12689 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y1_ad
12691 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y1_ad
12696 IF (branch .EQ. 0)
THEN 12700 gam_ad(i, k) = gam_ad(i, k) - q(i, k+1)*q_ad(i, k)
12701 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k)*q_ad(i, k)
12706 a_bot = 1. + d4(i)*(d4(i)+1.5)
12708 temp2 = d4(i)*(d4(i)+0.5) - a_bot*gam(i, km)
12709 temp_ad11 = q_ad(i, km+1)/temp2
12710 temp1 = d4(i)*(d4(i)+1.)
12711 temp_ad12 = 2.*a4(1, i, km)*temp_ad11
12712 temp_ad13 = -((2.*(temp1*a4(1, i, km))+a4(1, i, km-1)-a_bot*q(i&
12713 & , km))*temp_ad11/temp2)
12714 a4_ad(1, i, km) = a4_ad(1, i, km) + 2.*temp1*temp_ad11
12715 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + temp_ad11
12716 a_bot_ad = -(gam(i, km)*temp_ad13) - q(i, km)*temp_ad11
12717 d4_ad(i) = d4_ad(i) + (2*d4(i)+1.5)*a_bot_ad + (2*d4(i)+0.5)*&
12718 & temp_ad13 + (2*d4(i)+1.)*temp_ad12
12719 q_ad(i, km) = q_ad(i, km) - a_bot*temp_ad11
12720 gam_ad(i, km) = gam_ad(i, km) - a_bot*temp_ad13
12721 q_ad(i, km+1) = 0.0
12725 temp_ad9 = q_ad(i, k)/bet
12726 temp_ad8 = 3.*temp_ad9
12728 bet_ad = -((3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))*&
12729 & temp_ad9/bet) - d4(i)*gam_ad(i, k)/bet**2
12730 d4_ad(i) = d4_ad(i) + a4(1, i, k)*temp_ad8 + 2*bet_ad + gam_ad&
12733 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + temp_ad8
12734 a4_ad(1, i, k) = a4_ad(1, i, k) + d4(i)*temp_ad8
12735 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad9
12738 gam_ad(i, k-1) = gam_ad(i, k-1) - bet_ad
12740 temp_ad10 = d4_ad(i)/delp(i, k)
12741 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad10
12742 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad10/delp(i&
12748 grat = delp(i, 2)/delp(i, 1)
12749 bet = grat*(grat+0.5)
12750 temp_ad4 = gam_ad(i, 1)/bet
12752 temp_ad6 = q_ad(i, 1)/bet
12753 temp_ad5 = a4(1, i, 1)*temp_ad6
12754 temp0 = 2*grat*(grat+1.)
12755 bet_ad = -((temp0*a4(1, i, 1)+a4(1, i, 2))*temp_ad6/bet) - (grat&
12756 & *(grat+1.5)+1.)*temp_ad4/bet
12757 grat_ad = (4*grat+2*1.)*temp_ad5 + (2*grat+0.5)*bet_ad + (2*grat&
12759 a4_ad(1, i, 1) = a4_ad(1, i, 1) + temp0*temp_ad6
12760 a4_ad(1, i, 2) = a4_ad(1, i, 2) + temp_ad6
12762 temp_ad7 = grat_ad/delp(i, 1)
12763 delp_ad(i, 2) = delp_ad(i, 2) + temp_ad7
12764 delp_ad(i, 1) = delp_ad(i, 1) - delp(i, 2)*temp_ad7/delp(i, 1)
12770 gam_ad(i, k+1) = gam_ad(i, k+1) - q(i, k+1)*q_ad(i, k)
12771 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k+1)*q_ad(i, k)
12776 qs_ad(i) = qs_ad(i) + q_ad(i, km+1)
12777 q_ad(i, km+1) = 0.0
12778 grat = delp(i, km-1)/delp(i, km)
12780 temp = 2*grat - gam(i, km) + 2.
12781 temp_ad1 = q_ad(i, km)/temp
12782 temp_ad2 = -((3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, &
12783 & km-1))*temp_ad1/temp)
12784 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + 3.*temp_ad1
12785 a4_ad(1, i, km) = a4_ad(1, i, km) + 3.*temp_ad1
12786 grat_ad = 2*temp_ad2 - qs(i)*temp_ad1
12787 qs_ad(i) = qs_ad(i) - grat*temp_ad1
12788 q_ad(i, km-1) = q_ad(i, km-1) - temp_ad1
12789 gam_ad(i, km) = gam_ad(i, km) - temp_ad2
12791 temp_ad3 = grat_ad/delp(i, km)
12792 delp_ad(i, km-1) = delp_ad(i, km-1) + temp_ad3
12793 delp_ad(i, km) = delp_ad(i, km) - delp(i, km-1)*temp_ad3/delp(i&
12798 temp_ad = q_ad(i, k)/bet
12800 grat = delp(i, k-1)/delp(i, k)
12801 bet_ad = -((3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*temp_ad/&
12802 & bet) - grat*gam_ad(i, k+1)/bet**2
12803 grat_ad = 2*bet_ad + gam_ad(i, k+1)/bet
12804 gam_ad(i, k+1) = 0.0
12805 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + 3.*temp_ad
12806 a4_ad(1, i, k) = a4_ad(1, i, k) + 3.*temp_ad
12807 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad
12810 gam_ad(i, k) = gam_ad(i, k) - bet_ad
12811 temp_ad0 = grat_ad/delp(i, k)
12812 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad0
12813 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad0/delp(i, &
12818 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 1.5*q_ad(i, 1)
12823 SUBROUTINE cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
12827 INTEGER,
INTENT(IN) :: i1, i2
12829 INTEGER,
INTENT(IN) :: km
12831 INTEGER,
INTENT(IN) :: iv
12834 INTEGER,
INTENT(IN) :: kord
12835 REAL,
INTENT(IN) :: qs(i1:i2)
12837 REAL,
INTENT(IN) :: delp(i1:i2, km)
12839 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
12841 LOGICAL :: extm(i1:i2, km)
12842 REAL :: gam(i1:i2, km)
12843 REAL :: q(i1:i2, km+1)
12845 REAL :: bet, a_bot, grat
12846 REAL :: pmp_1, lac_1, pmp_2, lac_2
12847 INTEGER :: i, k, im
12902 IF (iv .EQ. -2)
THEN 12905 q(i, 1) = 1.5*a4(1, i, 1)
12909 grat = delp(i, k-1)/delp(i, k)
12910 bet = 2. + grat + grat - gam(i, k)
12911 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
12912 gam(i, k+1) = grat/bet
12916 grat = delp(i, km-1)/delp(i, km)
12917 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
12918 & 1))/(2.+grat+grat-gam(i, km))
12923 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
12929 grat = delp(i, 2)/delp(i, 1)
12930 bet = grat*(grat+0.5)
12931 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
12932 gam(i, 1) = (1.+grat*(grat+1.5))/bet
12936 d4(i) = delp(i, k-1)/delp(i, k)
12937 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
12938 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
12939 gam(i, k) = d4(i)/bet
12943 a_bot = 1. + d4(i)*(d4(i)+1.5)
12944 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
12945 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
12949 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
12953 IF (kord .GE. 0.)
THEN 12959 IF (abs0 .GT. 16)
THEN 12962 a4(2, i, k) = q(i, k)
12963 a4(3, i, k) = q(i, k+1)
12964 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
12976 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 12981 IF (q(i, 2) .GT. y1)
THEN 12986 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 12991 IF (q(i, 2) .LT. y2)
THEN 12999 gam(i, k) = a4(1, i, k) - a4(1, i, k-1)
13005 IF (gam(i, k-1)*gam(i, k+1) .GT. 0.)
THEN 13006 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 13011 IF (q(i, k) .GT. y3)
THEN 13016 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 13021 IF (q(i, k) .LT. y4)
THEN 13026 ELSE IF (gam(i, k-1) .GT. 0.)
THEN 13027 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 13032 IF (q(i, k) .LT. y5)
THEN 13038 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 13043 IF (q(i, k) .GT. y6)
THEN 13048 IF (iv .EQ. 0)
THEN 13049 IF (0. .LT. q(i, k))
THEN 13060 IF (a4(1, i, km-1) .LT. a4(1, i, km))
THEN 13063 y7 = a4(1, i, km-1)
13065 IF (q(i, km) .GT. y7)
THEN 13068 q(i, km) = q(i, km)
13070 IF (a4(1, i, km-1) .GT. a4(1, i, km))
THEN 13073 y8 = a4(1, i, km-1)
13075 IF (q(i, km) .LT. y8)
THEN 13078 q(i, km) = q(i, km)
13083 a4(2, i, k) = q(i, k)
13084 a4(3, i, k) = q(i, k+1)
13088 IF (k .EQ. 1 .OR. k .EQ. km)
THEN 13090 extm(i, k) = (a4(2, i, k)-a4(1, i, k))*(a4(3, i, k)-a4(1, i&
13095 extm(i, k) = gam(i, k)*gam(i, k+1) .LT. 0.
13104 IF (iv .EQ. 0)
THEN 13106 IF (0. .LT. a4(2, i, 1))
THEN 13107 a4(2, i, 1) = a4(2, i, 1)
13112 ELSE IF (iv .EQ. -1)
THEN 13114 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
13116 ELSE IF (iv .EQ. 2)
THEN 13118 a4(2, i, 1) = a4(1, i, 1)
13119 a4(3, i, 1) = a4(1, i, 1)
13123 IF (iv .NE. 2)
THEN 13125 a4(4, i, 1) = 3.*(2.*a4(1, i, 1)-(a4(2, i, 1)+a4(3, i, 1)))
13127 CALL cs_limiters(im, extm(i1, 1), a4(1, i1, 1), 1)
13131 a4(4, i, 2) = 3.*(2.*a4(1, i, 2)-(a4(2, i, 2)+a4(3, i, 2)))
13133 CALL cs_limiters(im, extm(i1, 2), a4(1, i1, 2), 2)
13138 IF (kord .GE. 0.)
THEN 13143 IF (abs1 .LT. 9)
THEN 13146 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
13147 lac_1 = pmp_1 + 1.5*gam(i, k+2)
13148 IF (a4(1, i, k) .GT. pmp_1)
THEN 13149 IF (pmp_1 .GT. lac_1)
THEN 13154 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 13159 IF (a4(2, i, k) .LT. y19)
THEN 13164 IF (a4(1, i, k) .LT. pmp_1)
THEN 13165 IF (pmp_1 .LT. lac_1)
THEN 13170 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 13175 IF (x1 .GT. y9)
THEN 13181 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
13182 lac_2 = pmp_2 - 1.5*gam(i, k-1)
13183 IF (a4(1, i, k) .GT. pmp_2)
THEN 13184 IF (pmp_2 .GT. lac_2)
THEN 13189 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 13194 IF (a4(3, i, k) .LT. y20)
THEN 13199 IF (a4(1, i, k) .LT. pmp_2)
THEN 13200 IF (pmp_2 .LT. lac_2)
THEN 13205 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 13210 IF (x2 .GT. y10)
THEN 13215 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
13218 IF (kord .GE. 0.)
THEN 13223 IF (abs2 .EQ. 9)
THEN 13225 IF (extm(i, k) .AND. extm(i, k-1))
THEN 13228 a4(2, i, k) = a4(1, i, k)
13229 a4(3, i, k) = a4(1, i, k)
13231 ELSE IF (extm(i, k) .AND. extm(i, k+1))
THEN 13234 a4(2, i, k) = a4(1, i, k)
13235 a4(3, i, k) = a4(1, i, k)
13238 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i, &
13240 IF (a4(4, i, k) .GE. 0.)
THEN 13243 abs3 = -a4(4, i, k)
13245 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 13246 abs10 = a4(2, i, k) - a4(3, i, k)
13248 abs10 = -(a4(2, i, k)-a4(3, i, k))
13251 IF (abs3 .GT. abs10)
THEN 13252 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
13253 lac_1 = pmp_1 + 1.5*gam(i, k+2)
13254 IF (a4(1, i, k) .GT. pmp_1)
THEN 13255 IF (pmp_1 .GT. lac_1)
THEN 13260 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 13265 IF (a4(2, i, k) .LT. y21)
THEN 13270 IF (a4(1, i, k) .LT. pmp_1)
THEN 13271 IF (pmp_1 .LT. lac_1)
THEN 13276 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 13281 IF (x3 .GT. y11)
THEN 13286 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
13287 lac_2 = pmp_2 - 1.5*gam(i, k-1)
13288 IF (a4(1, i, k) .GT. pmp_2)
THEN 13289 IF (pmp_2 .GT. lac_2)
THEN 13294 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 13299 IF (a4(3, i, k) .LT. y22)
THEN 13304 IF (a4(1, i, k) .LT. pmp_2)
THEN 13305 IF (pmp_2 .LT. lac_2)
THEN 13310 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 13315 IF (x4 .GT. y12)
THEN 13320 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
13326 IF (kord .GE. 0.)
THEN 13331 IF (abs4 .EQ. 10)
THEN 13333 IF (extm(i, k))
THEN 13334 IF (extm(i, k-1) .OR. extm(i, k+1))
THEN 13336 a4(2, i, k) = a4(1, i, k)
13337 a4(3, i, k) = a4(1, i, k)
13341 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
13346 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3, i&
13348 IF (a4(4, i, k) .GE. 0.)
THEN 13351 abs5 = -a4(4, i, k)
13353 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 13354 abs11 = a4(2, i, k) - a4(3, i, k)
13356 abs11 = -(a4(2, i, k)-a4(3, i, k))
13359 IF (abs5 .GT. abs11)
THEN 13360 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
13361 lac_1 = pmp_1 + 1.5*gam(i, k+2)
13362 IF (a4(1, i, k) .GT. pmp_1)
THEN 13363 IF (pmp_1 .GT. lac_1)
THEN 13368 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 13373 IF (a4(2, i, k) .LT. y23)
THEN 13378 IF (a4(1, i, k) .LT. pmp_1)
THEN 13379 IF (pmp_1 .LT. lac_1)
THEN 13384 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 13389 IF (x5 .GT. y13)
THEN 13394 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
13395 lac_2 = pmp_2 - 1.5*gam(i, k-1)
13396 IF (a4(1, i, k) .GT. pmp_2)
THEN 13397 IF (pmp_2 .GT. lac_2)
THEN 13402 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 13407 IF (a4(3, i, k) .LT. y24)
THEN 13412 IF (a4(1, i, k) .LT. pmp_2)
THEN 13413 IF (pmp_2 .LT. lac_2)
THEN 13418 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 13423 IF (x6 .GT. y14)
THEN 13428 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
13434 IF (kord .GE. 0.)
THEN 13439 IF (abs6 .EQ. 12)
THEN 13441 IF (extm(i, k))
THEN 13443 a4(2, i, k) = a4(1, i, k)
13444 a4(3, i, k) = a4(1, i, k)
13448 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(3&
13450 IF (a4(4, i, k) .GE. 0.)
THEN 13453 abs7 = -a4(4, i, k)
13455 IF (a4(2, i, k) - a4(3, i, k) .GE. 0.)
THEN 13456 abs12 = a4(2, i, k) - a4(3, i, k)
13458 abs12 = -(a4(2, i, k)-a4(3, i, k))
13461 IF (abs7 .GT. abs12)
THEN 13462 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
13463 lac_1 = pmp_1 + 1.5*gam(i, k+2)
13464 IF (a4(1, i, k) .GT. pmp_1)
THEN 13465 IF (pmp_1 .GT. lac_1)
THEN 13470 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 13475 IF (a4(2, i, k) .LT. y25)
THEN 13480 IF (a4(1, i, k) .LT. pmp_1)
THEN 13481 IF (pmp_1 .LT. lac_1)
THEN 13486 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 13491 IF (x7 .GT. y15)
THEN 13496 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
13497 lac_2 = pmp_2 - 1.5*gam(i, k-1)
13498 IF (a4(1, i, k) .GT. pmp_2)
THEN 13499 IF (pmp_2 .GT. lac_2)
THEN 13504 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 13509 IF (a4(3, i, k) .LT. y26)
THEN 13514 IF (a4(1, i, k) .LT. pmp_2)
THEN 13515 IF (pmp_2 .LT. lac_2)
THEN 13520 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 13525 IF (x8 .GT. y16)
THEN 13530 a4(4, i, k) = 6.*a4(1, i, k) - 3.*(a4(2, i, k)+a4(&
13536 IF (kord .GE. 0.)
THEN 13541 IF (abs8 .EQ. 13)
THEN 13543 IF (extm(i, k))
THEN 13544 IF (extm(i, k-1) .AND. extm(i, k+1))
THEN 13546 a4(2, i, k) = a4(1, i, k)
13547 a4(3, i, k) = a4(1, i, k)
13551 pmp_1 = a4(1, i, k) - 2.*gam(i, k+1)
13552 lac_1 = pmp_1 + 1.5*gam(i, k+2)
13553 IF (a4(1, i, k) .GT. pmp_1)
THEN 13554 IF (pmp_1 .GT. lac_1)
THEN 13559 ELSE IF (a4(1, i, k) .GT. lac_1)
THEN 13564 IF (a4(2, i, k) .LT. y27)
THEN 13569 IF (a4(1, i, k) .LT. pmp_1)
THEN 13570 IF (pmp_1 .LT. lac_1)
THEN 13575 ELSE IF (a4(1, i, k) .LT. lac_1)
THEN 13580 IF (x9 .GT. y17)
THEN 13586 pmp_2 = a4(1, i, k) + 2.*gam(i, k)
13587 lac_2 = pmp_2 - 1.5*gam(i, k-1)
13588 IF (a4(1, i, k) .GT. pmp_2)
THEN 13589 IF (pmp_2 .GT. lac_2)
THEN 13594 ELSE IF (a4(1, i, k) .GT. lac_2)
THEN 13599 IF (a4(3, i, k) .LT. y28)
THEN 13604 IF (a4(1, i, k) .LT. pmp_2)
THEN 13605 IF (pmp_2 .LT. lac_2)
THEN 13610 ELSE IF (a4(1, i, k) .LT. lac_2)
THEN 13615 IF (x10 .GT. y18)
THEN 13620 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
13624 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
13629 IF (kord .GE. 0.)
THEN 13634 IF (abs9 .EQ. 14)
THEN 13636 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3&
13642 IF (extm(i, k) .AND. (extm(i, k-1) .OR. extm(i, k+&
13645 a4(2, i, k) = a4(1, i, k)
13646 a4(3, i, k) = a4(1, i, k)
13649 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4&
13660 IF (iv .EQ. 0)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 0&
13667 IF (iv .EQ. 0)
THEN 13669 IF (0. .LT. a4(3, i, km))
THEN 13670 a4(3, i, km) = a4(3, i, km)
13675 ELSE IF (iv .EQ. -1)
THEN 13677 IF (a4(3, i, km)*a4(1, i, km) .LE. 0.) a4(3, i, km) = 0.
13682 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
13684 IF (k .EQ. km - 1)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k&
13686 IF (k .EQ. km)
CALL cs_limiters(im, extm(i1, k), a4(1, i1, k), 1&
13713 INTEGER,
INTENT(IN) :: im
13714 INTEGER,
INTENT(IN) :: iv
13715 LOGICAL,
INTENT(IN) :: extm(im)
13717 REAL,
INTENT(INOUT) :: a4(4, im)
13719 REAL :: da1, da2, a6da
13723 IF (iv .EQ. 0)
THEN 13726 IF (a4(1, i) .LE. 0.)
THEN 13728 a4(2, i) = a4(1, i)
13730 a4(3, i) = a4(1, i)
13735 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 13736 abs0 = a4(3, i) - a4(2, i)
13738 abs0 = -(a4(3, i)-a4(2, i))
13740 IF (abs0 .LT. -a4(4, i))
THEN 13741 IF (a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4, &
13742 & i)*
r12 .LT. 0.)
THEN 13744 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
13747 a4(3, i) = a4(1, i)
13749 a4(2, i) = a4(1, i)
13753 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 13755 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
13757 a4(3, i) = a4(2, i) - a4(4, i)
13761 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
13763 a4(2, i) = a4(3, i) - a4(4, i)
13775 ELSE IF (iv .EQ. 1)
THEN 13777 IF ((a4(1, i)-a4(2, i))*(a4(1, i)-a4(3, i)) .GE. 0.)
THEN 13779 a4(2, i) = a4(1, i)
13781 a4(3, i) = a4(1, i)
13786 da1 = a4(3, i) - a4(2, i)
13788 a6da = a4(4, i)*da1
13789 IF (a6da .LT. -da2)
THEN 13791 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
13793 a4(3, i) = a4(2, i) - a4(4, i)
13795 ELSE IF (a6da .GT. da2)
THEN 13797 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
13799 a4(2, i) = a4(3, i) - a4(4, i)
13812 a4(2, i) = a4(1, i)
13814 a4(3, i) = a4(1, i)
13819 da1 = a4(3, i) - a4(2, i)
13821 a6da = a4(4, i)*da1
13822 IF (a6da .LT. -da2)
THEN 13824 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
13826 a4(3, i) = a4(2, i) - a4(4, i)
13828 ELSE IF (a6da .GT. da2)
THEN 13830 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
13832 a4(2, i) = a4(3, i) - a4(4, i)
13864 INTEGER,
INTENT(IN) :: im
13865 INTEGER,
INTENT(IN) :: iv
13866 LOGICAL,
INTENT(IN) :: extm(im)
13867 REAL,
INTENT(INOUT) :: a4(4, im)
13868 REAL,
INTENT(INOUT) :: a4_ad(4, im)
13869 REAL :: da1, da2, a6da
13875 IF (branch .EQ. 0)
THEN 13878 IF (branch .LT. 3)
THEN 13879 IF (branch .NE. 0)
THEN 13880 IF (branch .NE. 1)
THEN 13882 a4_ad(3, i) = a4_ad(3, i) + a4_ad(2, i)
13883 a4_ad(4, i) = a4_ad(4, i) - a4_ad(2, i)
13886 a4_ad(3, i) = a4_ad(3, i) + 3.*a4_ad(4, i)
13887 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13891 ELSE IF (branch .EQ. 3)
THEN 13893 a4_ad(2, i) = a4_ad(2, i) + a4_ad(3, i)
13894 a4_ad(4, i) = a4_ad(4, i) - a4_ad(3, i)
13897 a4_ad(2, i) = a4_ad(2, i) + 3.*a4_ad(4, i)
13898 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13900 ELSE IF (branch .EQ. 4)
THEN 13904 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
13907 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
13913 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
13916 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
13920 ELSE IF (branch .EQ. 1)
THEN 13923 IF (branch .LT. 2)
THEN 13924 IF (branch .NE. 0)
THEN 13926 a4_ad(3, i) = a4_ad(3, i) + a4_ad(2, i)
13927 a4_ad(4, i) = a4_ad(4, i) - a4_ad(2, i)
13930 a4_ad(3, i) = a4_ad(3, i) + 3.*a4_ad(4, i)
13931 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13934 ELSE IF (branch .EQ. 2)
THEN 13936 a4_ad(2, i) = a4_ad(2, i) + a4_ad(3, i)
13937 a4_ad(4, i) = a4_ad(4, i) - a4_ad(3, i)
13940 a4_ad(2, i) = a4_ad(2, i) + 3.*a4_ad(4, i)
13941 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13947 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
13950 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
13957 IF (branch .LT. 2)
THEN 13958 IF (branch .NE. 0)
THEN 13960 a4_ad(3, i) = a4_ad(3, i) + a4_ad(2, i)
13961 a4_ad(4, i) = a4_ad(4, i) - a4_ad(2, i)
13964 a4_ad(3, i) = a4_ad(3, i) + 3.*a4_ad(4, i)
13965 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13968 ELSE IF (branch .EQ. 2)
THEN 13970 a4_ad(2, i) = a4_ad(2, i) + a4_ad(3, i)
13971 a4_ad(4, i) = a4_ad(4, i) - a4_ad(3, i)
13974 a4_ad(2, i) = a4_ad(2, i) + 3.*a4_ad(4, i)
13975 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
13981 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
13984 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
13992 INTEGER,
INTENT(IN) :: im
13993 INTEGER,
INTENT(IN) :: iv
13994 LOGICAL,
INTENT(IN) :: extm(im)
13996 REAL,
INTENT(INOUT) :: a4(4, im)
13998 REAL :: da1, da2, a6da
14002 IF (iv .EQ. 0)
THEN 14005 IF (a4(1, i) .LE. 0.)
THEN 14006 a4(2, i) = a4(1, i)
14007 a4(3, i) = a4(1, i)
14010 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 14011 abs0 = a4(3, i) - a4(2, i)
14013 abs0 = -(a4(3, i)-a4(2, i))
14015 IF (abs0 .LT. -a4(4, i))
THEN 14016 IF (a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4, &
14017 & i)*
r12 .LT. 0.)
THEN 14019 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
14021 a4(3, i) = a4(1, i)
14022 a4(2, i) = a4(1, i)
14024 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 14025 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
14026 a4(3, i) = a4(2, i) - a4(4, i)
14028 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
14029 a4(2, i) = a4(3, i) - a4(4, i)
14035 ELSE IF (iv .EQ. 1)
THEN 14037 IF ((a4(1, i)-a4(2, i))*(a4(1, i)-a4(3, i)) .GE. 0.)
THEN 14038 a4(2, i) = a4(1, i)
14039 a4(3, i) = a4(1, i)
14042 da1 = a4(3, i) - a4(2, i)
14044 a6da = a4(4, i)*da1
14045 IF (a6da .LT. -da2)
THEN 14046 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
14047 a4(3, i) = a4(2, i) - a4(4, i)
14048 ELSE IF (a6da .GT. da2)
THEN 14049 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
14050 a4(2, i) = a4(3, i) - a4(4, i)
14058 a4(2, i) = a4(1, i)
14059 a4(3, i) = a4(1, i)
14062 da1 = a4(3, i) - a4(2, i)
14064 a6da = a4(4, i)*da1
14065 IF (a6da .LT. -da2)
THEN 14066 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
14067 a4(3, i) = a4(2, i) - a4(4, i)
14068 ELSE IF (a6da .GT. da2)
THEN 14069 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
14070 a4(2, i) = a4(3, i) - a4(4, i)
14100 INTEGER,
INTENT(IN) :: iv
14105 INTEGER,
INTENT(IN) :: i1
14107 INTEGER,
INTENT(IN) :: i2
14109 INTEGER,
INTENT(IN) :: km
14111 INTEGER,
INTENT(IN) :: kord
14114 REAL,
INTENT(IN) :: delp(i1:i2, km)
14117 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
14126 REAL :: dc(i1:i2, km)
14127 REAL :: h2(i1:i2, km)
14128 REAL :: delq(i1:i2, km)
14129 REAL :: df2(i1:i2, km)
14130 REAL :: d4(i1:i2, km)
14132 INTEGER :: i, k, km1, lmt, it
14134 REAL :: a1, a2, c1, c2, c3, d1, d2
14135 REAL :: qm, dq, lac, qmp, pmp
14161 delq(i, k-1) = a4(1, i, k) - a4(1, i, k-1)
14162 d4(i, k) = delp(i, k-1) + delp(i, k)
14167 c1 = (delp(i, k-1)+0.5*delp(i, k))/d4(i, k+1)
14168 c2 = (delp(i, k+1)+0.5*delp(i, k))/d4(i, k)
14169 df2(i, k) = delp(i, k)*(c1*delq(i, k)+c2*delq(i, k-1))/(d4(i, k)&
14171 IF (df2(i, k) .GE. 0.)
THEN 14178 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 14179 IF (a4(1, i, k) .LT. a4(1, i, k+1))
THEN 14180 max1 = a4(1, i, k+1)
14186 ELSE IF (a4(1, i, k-1) .LT. a4(1, i, k+1))
THEN 14187 max1 = a4(1, i, k+1)
14190 max1 = a4(1, i, k-1)
14193 y1 = max1 - a4(1, i, k)
14194 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 14195 IF (a4(1, i, k) .GT. a4(1, i, k+1))
THEN 14196 min2 = a4(1, i, k+1)
14202 ELSE IF (a4(1, i, k-1) .GT. a4(1, i, k+1))
THEN 14203 min2 = a4(1, i, k+1)
14206 min2 = a4(1, i, k-1)
14209 z1 = a4(1, i, k) - min2
14210 IF (x1 .GT. y1)
THEN 14211 IF (y1 .GT. z1)
THEN 14220 ELSE IF (x1 .GT. z1)
THEN 14229 dc(i, k) = sign(min1, df2(i, k))
14237 c1 = delq(i, k-1)*delp(i, k-1)/d4(i, k)
14238 a1 = d4(i, k-1)/(d4(i, k)+delp(i, k-1))
14239 a2 = d4(i, k+1)/(d4(i, k)+delp(i, k))
14240 a4(2, i, k) = a4(1, i, k-1) + c1 + 2./(d4(i, k-1)+d4(i, k+1))*(&
14241 & delp(i, k)*(c1*(a1-a2)+a2*dc(i, k-1))-delp(i, k-1)*a1*dc(i, k)&
14252 qm = (d2*a4(1, i, 1)+d1*a4(1, i, 2))/(d1+d2)
14254 dq = 2.*(a4(1, i, 2)-a4(1, i, 1))/(d1+d2)
14256 c1 = 4.*(a4(2, i, 3)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
14257 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
14259 a4(2, i, 2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
14263 a4(2, i, 1) = d1*(2.*c1*d1**2-c3) + a4(2, i, 2)
14264 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 14271 IF (a4(2, i, 2) .LT. y2)
THEN 14277 a4(2, i, 2) = a4(2, i, 2)
14280 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 14287 IF (a4(2, i, 2) .GT. y3)
THEN 14293 a4(2, i, 2) = a4(2, i, 2)
14297 dc(i, 1) = 0.5*(a4(2, i, 2)-a4(1, i, 1))
14300 IF (iv .EQ. 0)
THEN 14302 IF (0. .LT. a4(2, i, 1))
THEN 14304 a4(2, i, 1) = a4(2, i, 1)
14311 IF (0. .LT. a4(2, i, 2))
THEN 14313 a4(2, i, 2) = a4(2, i, 2)
14322 ELSE IF (iv .EQ. -1)
THEN 14324 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.)
THEN 14334 IF (iv .GE. 0.)
THEN 14339 IF (abs0 .EQ. 2)
THEN 14342 a4(2, i, 1) = a4(1, i, 1)
14344 a4(3, i, 1) = a4(1, i, 1)
14357 qm = (d2*a4(1, i, km)+d1*a4(1, i, km1))/(d1+d2)
14359 dq = 2.*(a4(1, i, km1)-a4(1, i, km))/(d1+d2)
14361 c1 = (a4(2, i, km1)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
14362 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
14364 a4(2, i, km) = qm - c1*d1*d2*(d2+3.*d1)
14368 a4(3, i, km) = d1*(8.*c1*d1**2-c3) + a4(2, i, km)
14369 IF (a4(1, i, km) .GT. a4(1, i, km1))
THEN 14376 IF (a4(2, i, km) .LT. y4)
THEN 14382 a4(2, i, km) = a4(2, i, km)
14385 IF (a4(1, i, km) .LT. a4(1, i, km1))
THEN 14392 IF (a4(2, i, km) .GT. y5)
THEN 14398 a4(2, i, km) = a4(2, i, km)
14402 dc(i, km) = 0.5*(a4(1, i, km)-a4(2, i, km))
14405 IF (iv .EQ. 0)
THEN 14407 IF (0. .LT. a4(2, i, km))
THEN 14409 a4(2, i, km) = a4(2, i, km)
14416 IF (0. .LT. a4(3, i, km))
THEN 14418 a4(3, i, km) = a4(3, i, km)
14427 ELSE IF (iv .LT. 0)
THEN 14429 IF (a4(1, i, km)*a4(3, i, km) .LE. 0.)
THEN 14444 a4(3, i, k) = a4(2, i, k+1)
14454 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
14458 IF (kord .GE. 7)
THEN 14467 h2(i, k) = 2.*(dc(i, k+1)/delp(i, k+1)-dc(i, k-1)/delp(i, k-1)&
14468 & )/(delp(i, k)+0.5*(delp(i, k-1)+delp(i, k+1)))*delp(i, k)**2
14482 qmp = a4(1, i, k) + pmp
14483 lac = a4(1, i, k) + fac*h2(i, k-1) + dc(i, k)
14484 IF (a4(1, i, k) .GT. qmp)
THEN 14485 IF (qmp .GT. lac)
THEN 14492 ELSE IF (a4(1, i, k) .GT. lac)
THEN 14499 IF (a4(3, i, k) .LT. y8)
THEN 14506 IF (a4(1, i, k) .LT. qmp)
THEN 14507 IF (qmp .LT. lac)
THEN 14514 ELSE IF (a4(1, i, k) .LT. lac)
THEN 14521 IF (x2 .GT. y6)
THEN 14534 qmp = a4(1, i, k) - pmp
14535 lac = a4(1, i, k) + fac*h2(i, k+1) - dc(i, k)
14536 IF (a4(1, i, k) .GT. qmp)
THEN 14537 IF (qmp .GT. lac)
THEN 14544 ELSE IF (a4(1, i, k) .GT. lac)
THEN 14551 IF (a4(2, i, k) .LT. y9)
THEN 14558 IF (a4(1, i, k) .LT. qmp)
THEN 14559 IF (qmp .LT. lac)
THEN 14566 ELSE IF (a4(1, i, k) .LT. lac)
THEN 14573 IF (x3 .GT. y7)
THEN 14586 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
14589 IF (iv .EQ. 0 .AND. kord .GE. 6)
THEN 14599 IF (0 .LT. lmt)
THEN 14604 IF (iv .EQ. 0)
THEN 14605 IF (2 .GT. lmt)
THEN 14616 IF (kord .NE. 4)
THEN 14619 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
14625 IF (kord .NE. 6)
THEN 14637 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
14673 SUBROUTINE ppm_profile_bwd(a4, a4_ad, delp, delp_ad, km, i1, i2, iv, &
14676 INTEGER,
INTENT(IN) :: iv
14677 INTEGER,
INTENT(IN) :: i1
14678 INTEGER,
INTENT(IN) :: i2
14679 INTEGER,
INTENT(IN) :: km
14680 INTEGER,
INTENT(IN) :: kord
14681 REAL,
INTENT(IN) :: delp(i1:i2, km)
14682 REAL :: delp_ad(i1:i2, km)
14683 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
14684 REAL,
INTENT(INOUT) :: a4_ad(4, i1:i2, km)
14685 REAL :: dc(i1:i2, km)
14686 REAL :: dc_ad(i1:i2, km)
14687 REAL :: h2(i1:i2, km)
14688 REAL :: h2_ad(i1:i2, km)
14689 REAL :: delq(i1:i2, km)
14690 REAL :: delq_ad(i1:i2, km)
14691 REAL :: df2(i1:i2, km)
14692 REAL :: df2_ad(i1:i2, km)
14693 REAL :: d4(i1:i2, km)
14694 REAL :: d4_ad(i1:i2, km)
14695 INTEGER :: i, k, km1, lmt, it
14697 REAL :: a1, a2, c1, c2, c3, d1, d2
14698 REAL :: a1_ad, a2_ad, c1_ad, c2_ad, c3_ad, d1_ad, d2_ad
14699 REAL :: qm, dq, lac, qmp, pmp
14700 REAL :: qm_ad, dq_ad, lac_ad, qmp_ad, pmp_ad
14812 & (1, i1, k), it, 0)
14815 temp_ad39 = 3.*a4_ad(4, i, k)
14816 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad39
14817 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad39
14818 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad39
14819 a4_ad(4, i, k) = 0.0
14823 IF (branch .EQ. 0)
THEN 14827 & , a4(1, i1, k), a4_ad(1, i1, &
14830 IF (branch .EQ. 0)
THEN 14833 temp_ad38 = 3.*a4_ad(4, i, k)
14834 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad38
14835 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad38
14836 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad38
14837 a4_ad(4, i, k) = 0.0
14847 & , a4(1, i1, k), a4_ad(1, i1, &
14851 temp_ad37 = 3.*a4_ad(4, i, k)
14852 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad37
14853 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad37
14854 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad37
14855 a4_ad(4, i, k) = 0.0
14857 IF (branch .EQ. 0)
THEN 14859 y7_ad = a4_ad(2, i, k)
14860 a4_ad(2, i, k) = 0.0
14864 x3_ad = a4_ad(2, i, k)
14865 a4_ad(2, i, k) = 0.0
14869 IF (branch .LT. 2)
THEN 14870 IF (branch .EQ. 0)
THEN 14878 IF (branch .EQ. 2)
THEN 14881 a4_ad(1, i, k) = a4_ad(1, i, k) + y7_ad
14887 IF (branch .EQ. 0)
THEN 14890 a4_ad(2, i, k) = a4_ad(2, i, k) + x3_ad
14894 IF (branch .LT. 2)
THEN 14895 IF (branch .EQ. 0)
THEN 14896 lac_ad = lac_ad + y9_ad
14898 qmp_ad = qmp_ad + y9_ad
14900 ELSE IF (branch .EQ. 2)
THEN 14901 lac_ad = lac_ad + y9_ad
14903 a4_ad(1, i, k) = a4_ad(1, i, k) + y9_ad
14905 a4_ad(1, i, k) = a4_ad(1, i, k) + qmp_ad + lac_ad
14906 h2_ad(i, k+1) = h2_ad(i, k+1) + fac*lac_ad
14907 dc_ad(i, k) = dc_ad(i, k) - lac_ad
14910 IF (branch .EQ. 0)
THEN 14912 y6_ad = a4_ad(3, i, k)
14913 a4_ad(3, i, k) = 0.0
14917 x2_ad = a4_ad(3, i, k)
14918 a4_ad(3, i, k) = 0.0
14922 IF (branch .LT. 2)
THEN 14923 IF (branch .EQ. 0)
THEN 14931 IF (branch .EQ. 2)
THEN 14934 a4_ad(1, i, k) = a4_ad(1, i, k) + y6_ad
14940 IF (branch .EQ. 0)
THEN 14943 a4_ad(3, i, k) = a4_ad(3, i, k) + x2_ad
14947 IF (branch .LT. 2)
THEN 14948 IF (branch .EQ. 0)
THEN 14949 lac_ad = lac_ad + y8_ad
14951 qmp_ad = qmp_ad + y8_ad
14953 ELSE IF (branch .EQ. 2)
THEN 14954 lac_ad = lac_ad + y8_ad
14956 a4_ad(1, i, k) = a4_ad(1, i, k) + y8_ad
14958 pmp_ad = pmp_ad + qmp_ad
14959 a4_ad(1, i, k) = a4_ad(1, i, k) + qmp_ad + lac_ad
14960 h2_ad(i, k-1) = h2_ad(i, k-1) + fac*lac_ad
14961 dc_ad(i, k) = dc_ad(i, k) + 2.*pmp_ad + lac_ad
14966 temp11 = delp(i, k) + 0.5*(delp(i, k-1)+delp(i, k+1))
14967 temp16 = delp(i, k)**2
14968 temp10 = temp16/temp11
14969 temp15 = delp(i, k-1)
14970 temp14 = dc(i, k-1)/temp15
14971 temp13 = delp(i, k+1)
14972 temp12 = dc(i, k+1)/temp13
14973 temp_ad34 = 2.*temp10*h2_ad(i, k)
14974 temp_ad35 = (temp12-temp14)*2.*h2_ad(i, k)/temp11
14975 temp_ad36 = -(temp10*temp_ad35)
14976 dc_ad(i, k+1) = dc_ad(i, k+1) + temp_ad34/temp13
14977 delp_ad(i, k+1) = delp_ad(i, k+1) + 0.5*temp_ad36 - temp12*&
14979 dc_ad(i, k-1) = dc_ad(i, k-1) - temp_ad34/temp15
14980 delp_ad(i, k-1) = delp_ad(i, k-1) + 0.5*temp_ad36 + temp14*&
14982 delp_ad(i, k) = delp_ad(i, k) + temp_ad36 + 2*delp(i, k)*&
14990 & (1, i1, k), it, 0)
14993 temp_ad33 = 3.*a4_ad(4, i, k)
14994 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad33
14995 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad33
14996 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad33
14997 a4_ad(4, i, k) = 0.0
15003 a4_ad(2, i, k+1) = a4_ad(2, i, k+1) + a4_ad(3, i, k)
15004 a4_ad(3, i, k) = 0.0
15008 IF (branch .NE. 0)
THEN 15009 IF (branch .EQ. 1)
THEN 15012 IF (branch .NE. 0)
THEN 15014 a4_ad(3, i, km) = 0.0
15020 IF (branch .EQ. 0)
THEN 15024 a4_ad(3, i, km) = 0.0
15027 IF (branch .EQ. 0)
THEN 15031 a4_ad(2, i, km) = 0.0
15038 a4_ad(1, i, km) = a4_ad(1, i, km) + 0.5*dc_ad(i, km)
15039 a4_ad(2, i, km) = a4_ad(2, i, km) - 0.5*dc_ad(i, km)
15042 IF (branch .EQ. 0)
THEN 15044 y5_ad = a4_ad(2, i, km)
15045 a4_ad(2, i, km) = 0.0
15051 IF (branch .EQ. 0)
THEN 15052 a4_ad(1, i, km1) = a4_ad(1, i, km1) + y5_ad
15054 a4_ad(1, i, km) = a4_ad(1, i, km) + y5_ad
15057 IF (branch .EQ. 0)
THEN 15059 y4_ad = a4_ad(2, i, km)
15060 a4_ad(2, i, km) = 0.0
15066 IF (branch .EQ. 0)
THEN 15067 a4_ad(1, i, km1) = a4_ad(1, i, km1) + y4_ad
15069 a4_ad(1, i, km) = a4_ad(1, i, km) + y4_ad
15073 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
15075 temp_ad22 = d1*a4_ad(3, i, km)
15076 d1_ad = c1*8.*2*d1*temp_ad22 + (8.*(c1*d1**2)-c3)*a4_ad(3, i, km)
15078 a4_ad(2, i, km) = a4_ad(2, i, km) + a4_ad(3, i, km)
15079 a4_ad(3, i, km) = 0.0
15081 temp_ad23 = -((d2+3.*d1)*a4_ad(2, i, km))
15082 c1_ad = d2*d1*temp_ad23 - 2.0*(d2*(5.*d1+d2)-3.*d1**2)*c3_ad + 8.*&
15084 temp_ad24 = -(c1*d1*d2*a4_ad(2, i, km))
15085 temp_ad26 = -(2.0*c1*c3_ad)
15086 temp9 = 2.*d2**2 + d1*(d2+3.*d1)
15087 temp_ad25 = c1_ad/(d2*temp9)
15088 qm_ad = a4_ad(2, i, km) - temp_ad25
15089 a4_ad(2, i, km) = 0.0
15090 dq_ad = c3_ad - d2*temp_ad25
15091 temp_ad31 = -((a4(2, i, km1)-qm-d2*dq)*temp_ad25/(d2*temp9))
15092 temp_ad30 = d2*temp_ad31
15093 a4_ad(2, i, km1) = a4_ad(2, i, km1) + temp_ad25
15094 temp_ad32 = 2.*dq_ad/(d1+d2)
15095 temp_ad27 = -((a4(1, i, km1)-a4(1, i, km))*temp_ad32/(d1+d2))
15096 a4_ad(1, i, km1) = a4_ad(1, i, km1) + temp_ad32
15097 temp_ad29 = qm_ad/(d1+d2)
15098 a4_ad(1, i, km) = a4_ad(1, i, km) + d2*temp_ad29 - temp_ad32
15099 temp_ad28 = -((d2*a4(1, i, km)+d1*a4(1, i, km1))*temp_ad29/(d1+d2)&
15101 d1_ad = d1_ad + (d2*5.-3.*2*d1)*temp_ad26 + temp_ad27 + temp_ad28 &
15102 & + a4(1, i, km1)*temp_ad29 + (d1*3.+d2+3.*d1)*temp_ad30 + 3.*&
15103 & temp_ad24 + d2*c1*temp_ad23
15104 d2_ad = (2*d2+5.*d1)*temp_ad26 + temp_ad27 + temp_ad28 + a4(1, i, &
15105 & km)*temp_ad29 + (d1+2.*2*d2)*temp_ad30 + temp9*temp_ad31 - dq*&
15106 & temp_ad25 + temp_ad24 + c1*d1*temp_ad23
15110 a4_ad(1, i, km1) = a4_ad(1, i, km1) + d1*temp_ad29
15111 delp_ad(i, km1) = delp_ad(i, km1) + d2_ad
15112 delp_ad(i, km) = delp_ad(i, km) + d1_ad
15115 IF (branch .LT. 2)
THEN 15116 IF (branch .NE. 0)
THEN 15119 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(3, i, 1)
15120 a4_ad(3, i, 1) = 0.0
15122 a4_ad(1, i, 1) = a4_ad(1, i, 1) + a4_ad(2, i, 1)
15123 a4_ad(2, i, 1) = 0.0
15126 ELSE IF (branch .EQ. 2)
THEN 15129 IF (branch .NE. 0)
THEN 15131 a4_ad(2, i, 1) = 0.0
15137 IF (branch .EQ. 0)
THEN 15141 a4_ad(2, i, 2) = 0.0
15144 IF (branch .EQ. 0)
THEN 15148 a4_ad(2, i, 1) = 0.0
15154 a4_ad(2, i, 2) = a4_ad(2, i, 2) + 0.5*dc_ad(i, 1)
15155 a4_ad(1, i, 1) = a4_ad(1, i, 1) - 0.5*dc_ad(i, 1)
15158 IF (branch .EQ. 0)
THEN 15160 y3_ad = a4_ad(2, i, 2)
15161 a4_ad(2, i, 2) = 0.0
15167 IF (branch .EQ. 0)
THEN 15168 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y3_ad
15170 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y3_ad
15173 IF (branch .EQ. 0)
THEN 15175 y2_ad = a4_ad(2, i, 2)
15176 a4_ad(2, i, 2) = 0.0
15182 IF (branch .EQ. 0)
THEN 15183 a4_ad(1, i, 2) = a4_ad(1, i, 2) + y2_ad
15185 a4_ad(1, i, 1) = a4_ad(1, i, 1) + y2_ad
15189 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
15191 temp_ad11 = d1*a4_ad(2, i, 1)
15192 d1_ad = c1*2.*2*d1*temp_ad11 + (2.*(c1*d1**2)-c3)*a4_ad(2, i, 1)
15194 a4_ad(2, i, 2) = a4_ad(2, i, 2) + a4_ad(2, i, 1)
15195 a4_ad(2, i, 1) = 0.0
15197 temp_ad12 = -(0.25*(d2+3.*d1)*a4_ad(2, i, 2))
15198 c1_ad = d2*d1*temp_ad12 - 0.5*(d2*(5.*d1+d2)-3.*d1**2)*c3_ad + 2.*&
15200 temp_ad13 = -(0.25*c1*d1*d2*a4_ad(2, i, 2))
15201 temp_ad15 = -(0.5*c1*c3_ad)
15202 temp8 = 2.*d2**2 + d1*(d2+3.*d1)
15203 temp_ad14 = 4.*c1_ad/(d2*temp8)
15204 qm_ad = a4_ad(2, i, 2) - temp_ad14
15205 a4_ad(2, i, 2) = 0.0
15206 dq_ad = c3_ad - d2*temp_ad14
15207 temp_ad20 = -((a4(2, i, 3)-qm-d2*dq)*temp_ad14/(d2*temp8))
15208 temp_ad19 = d2*temp_ad20
15209 a4_ad(2, i, 3) = a4_ad(2, i, 3) + temp_ad14
15210 temp_ad21 = 2.*dq_ad/(d1+d2)
15211 temp_ad16 = -((a4(1, i, 2)-a4(1, i, 1))*temp_ad21/(d1+d2))
15212 a4_ad(1, i, 2) = a4_ad(1, i, 2) + temp_ad21
15213 temp_ad18 = qm_ad/(d1+d2)
15214 a4_ad(1, i, 1) = a4_ad(1, i, 1) + d2*temp_ad18 - temp_ad21
15215 temp_ad17 = -((d2*a4(1, i, 1)+d1*a4(1, i, 2))*temp_ad18/(d1+d2))
15216 d1_ad = d1_ad + (d2*5.-3.*2*d1)*temp_ad15 + temp_ad16 + temp_ad17 &
15217 & + a4(1, i, 2)*temp_ad18 + (d1*3.+d2+3.*d1)*temp_ad19 + 3.*&
15218 & temp_ad13 + d2*c1*temp_ad12
15219 d2_ad = (2*d2+5.*d1)*temp_ad15 + temp_ad16 + temp_ad17 + a4(1, i, &
15220 & 1)*temp_ad18 + (d1+2.*2*d2)*temp_ad19 + temp8*temp_ad20 - dq*&
15221 & temp_ad14 + temp_ad13 + c1*d1*temp_ad12
15225 a4_ad(1, i, 2) = a4_ad(1, i, 2) + d1*temp_ad18
15226 delp_ad(i, 2) = delp_ad(i, 2) + d2_ad
15227 delp_ad(i, 1) = delp_ad(i, 1) + d1_ad
15234 temp1 = delq(i, k-1)/temp2
15235 temp4 = d4(i, k) + delp(i, k)
15236 c1 = delq(i, k-1)*delp(i, k-1)/d4(i, k)
15237 a1 = d4(i, k-1)/(d4(i, k)+delp(i, k-1))
15238 a2 = d4(i, k+1)/(d4(i, k)+delp(i, k))
15239 temp7 = d4(i, k-1) + d4(i, k+1)
15240 temp6 = a1*dc(i, k)
15241 temp5 = c1*(a1-a2) + a2*dc(i, k-1)
15242 temp_ad4 = 2.*a4_ad(2, i, k)/temp7
15243 temp_ad5 = delp(i, k)*temp_ad4
15244 temp_ad6 = -(delp(i, k-1)*temp_ad4)
15245 temp_ad7 = -((delp(i, k)*temp5-delp(i, k-1)*temp6)*temp_ad4/&
15247 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + a4_ad(2, i, k)
15248 c1_ad = (a1-a2)*temp_ad5 + a4_ad(2, i, k)
15249 delp_ad(i, k) = delp_ad(i, k) + temp5*temp_ad4
15250 a1_ad = dc(i, k)*temp_ad6 + c1*temp_ad5
15251 a2_ad = (dc(i, k-1)-c1)*temp_ad5
15252 dc_ad(i, k-1) = dc_ad(i, k-1) + a2*temp_ad5
15253 delp_ad(i, k-1) = delp_ad(i, k-1) - temp6*temp_ad4
15254 dc_ad(i, k) = dc_ad(i, k) + a1*temp_ad6
15255 d4_ad(i, k-1) = d4_ad(i, k-1) + temp_ad7
15256 d4_ad(i, k+1) = d4_ad(i, k+1) + a2_ad/temp4 + temp_ad7
15257 a4_ad(2, i, k) = 0.0
15258 temp_ad8 = -(d4(i, k+1)*a2_ad/temp4**2)
15259 d4_ad(i, k) = d4_ad(i, k) + temp_ad8
15260 delp_ad(i, k) = delp_ad(i, k) + temp_ad8
15261 temp3 = d4(i, k) + delp(i, k-1)
15262 temp_ad9 = -(d4(i, k-1)*a1_ad/temp3**2)
15263 d4_ad(i, k-1) = d4_ad(i, k-1) + a1_ad/temp3
15264 delp_ad(i, k-1) = delp_ad(i, k-1) + temp1*c1_ad + temp_ad9
15265 temp_ad10 = delp(i, k-1)*c1_ad/temp2
15266 d4_ad(i, k) = d4_ad(i, k) + temp_ad9 - temp1*temp_ad10
15267 delq_ad(i, k-1) = delq_ad(i, k-1) + temp_ad10
15273 min1_ad = sign(1.d0, min1*df2(i, k))*dc_ad(i, k)
15276 IF (branch .LT. 2)
THEN 15277 IF (branch .EQ. 0)
THEN 15288 IF (branch .EQ. 2)
THEN 15299 a4_ad(1, i, k) = a4_ad(1, i, k) + z1_ad
15302 IF (branch .LT. 2)
THEN 15303 IF (branch .EQ. 0)
THEN 15304 a4_ad(1, i, k+1) = a4_ad(1, i, k+1) + min2_ad
15306 a4_ad(1, i, k) = a4_ad(1, i, k) + min2_ad
15308 ELSE IF (branch .EQ. 2)
THEN 15309 a4_ad(1, i, k+1) = a4_ad(1, i, k+1) + min2_ad
15311 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + min2_ad
15314 a4_ad(1, i, k) = a4_ad(1, i, k) - y1_ad
15316 IF (branch .LT. 2)
THEN 15317 IF (branch .EQ. 0)
THEN 15318 a4_ad(1, i, k+1) = a4_ad(1, i, k+1) + max1_ad
15320 a4_ad(1, i, k) = a4_ad(1, i, k) + max1_ad
15322 ELSE IF (branch .EQ. 2)
THEN 15323 a4_ad(1, i, k+1) = a4_ad(1, i, k+1) + max1_ad
15325 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + max1_ad
15328 IF (branch .EQ. 0)
THEN 15329 df2_ad(i, k) = df2_ad(i, k) + x1_ad
15331 df2_ad(i, k) = df2_ad(i, k) - x1_ad
15333 c1 = (delp(i, k-1)+0.5*delp(i, k))/d4(i, k+1)
15334 c2 = (delp(i, k+1)+0.5*delp(i, k))/d4(i, k)
15335 temp0 = d4(i, k) + delp(i, k+1)
15336 temp = delp(i, k)/temp0
15337 temp_ad = temp*df2_ad(i, k)
15338 temp_ad0 = (c1*delq(i, k)+c2*delq(i, k-1))*df2_ad(i, k)/temp0
15339 temp_ad1 = -(temp*temp_ad0)
15340 c1_ad = delq(i, k)*temp_ad
15341 delq_ad(i, k) = delq_ad(i, k) + c1*temp_ad
15342 c2_ad = delq(i, k-1)*temp_ad
15343 delq_ad(i, k-1) = delq_ad(i, k-1) + c2*temp_ad
15344 delp_ad(i, k) = delp_ad(i, k) + temp_ad0
15346 temp_ad2 = c2_ad/d4(i, k)
15347 d4_ad(i, k) = d4_ad(i, k) + temp_ad1 - (delp(i, k+1)+0.5*delp(i&
15348 & , k))*temp_ad2/d4(i, k)
15349 delp_ad(i, k+1) = delp_ad(i, k+1) + temp_ad2 + temp_ad1
15350 delp_ad(i, k) = delp_ad(i, k) + 0.5*temp_ad2
15351 temp_ad3 = c1_ad/d4(i, k+1)
15352 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad3
15353 delp_ad(i, k) = delp_ad(i, k) + 0.5*temp_ad3
15354 d4_ad(i, k+1) = d4_ad(i, k+1) - (delp(i, k-1)+0.5*delp(i, k))*&
15355 & temp_ad3/d4(i, k+1)
15360 delp_ad(i, k-1) = delp_ad(i, k-1) + d4_ad(i, k)
15361 delp_ad(i, k) = delp_ad(i, k) + d4_ad(i, k)
15363 a4_ad(1, i, k) = a4_ad(1, i, k) + delq_ad(i, k-1)
15364 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) - delq_ad(i, k-1)
15365 delq_ad(i, k-1) = 0.0
15393 REAL,
INTENT(IN) :: dm(*)
15395 INTEGER,
INTENT(IN) :: itot
15397 INTEGER,
INTENT(IN) :: lmt
15403 REAL,
INTENT(INOUT) :: a4(4, *)
15410 REAL :: da1, da2, a6da
15424 IF (lmt .EQ. 3)
THEN 15426 ELSE IF (lmt .EQ. 0)
THEN 15429 IF (dm(i) .EQ. 0.)
THEN 15431 a4(2, i) = a4(1, i)
15433 a4(3, i) = a4(1, i)
15438 da1 = a4(3, i) - a4(2, i)
15440 a6da = a4(4, i)*da1
15441 IF (a6da .LT. -da2)
THEN 15443 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
15445 a4(3, i) = a4(2, i) - a4(4, i)
15447 ELSE IF (a6da .GT. da2)
THEN 15449 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
15451 a4(2, i) = a4(3, i) - a4(4, i)
15459 ELSE IF (lmt .EQ. 1)
THEN 15464 IF (qmp .GE. 0.)
THEN 15471 IF (a4(2, i) - a4(1, i) .GE. 0.)
THEN 15472 y1 = a4(2, i) - a4(1, i)
15475 y1 = -(a4(2, i)-a4(1, i))
15478 IF (x1 .GT. y1)
THEN 15488 a4(2, i) = a4(1, i) - sign(min1, qmp)
15489 IF (qmp .GE. 0.)
THEN 15496 IF (a4(3, i) - a4(1, i) .GE. 0.)
THEN 15497 y2 = a4(3, i) - a4(1, i)
15500 y2 = -(a4(3, i)-a4(1, i))
15503 IF (x2 .GT. y2)
THEN 15513 a4(3, i) = a4(1, i) + sign(min2, qmp)
15515 a4(4, i) = 3.*(2.*a4(1, i)-(a4(2, i)+a4(3, i)))
15520 ELSE IF (lmt .EQ. 2)
THEN 15523 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 15524 abs0 = a4(3, i) - a4(2, i)
15526 abs0 = -(a4(3, i)-a4(2, i))
15528 IF (abs0 .LT. -a4(4, i))
THEN 15529 fmin = a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4&
15531 IF (fmin .LT. 0.)
THEN 15532 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
15535 a4(3, i) = a4(1, i)
15537 a4(2, i) = a4(1, i)
15541 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 15543 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
15545 a4(3, i) = a4(2, i) - a4(4, i)
15549 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
15551 a4(2, i) = a4(3, i) - a4(4, i)
15588 REAL,
INTENT(IN) :: dm(*)
15590 INTEGER,
INTENT(IN) :: itot
15591 INTEGER,
INTENT(IN) :: lmt
15592 REAL,
INTENT(INOUT) :: a4(4, *)
15593 REAL,
INTENT(INOUT) :: a4_ad(4, *)
15596 REAL :: da1, da2, a6da
15618 IF (branch .LT. 2)
THEN 15619 IF (branch .NE. 0)
THEN 15622 IF (branch .LT. 2)
THEN 15623 IF (branch .NE. 0)
THEN 15625 a4_ad(3, i) = a4_ad(3, i) + a4_ad(2, i)
15626 a4_ad(4, i) = a4_ad(4, i) - a4_ad(2, i)
15629 a4_ad(3, i) = a4_ad(3, i) + 3.*a4_ad(4, i)
15630 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
15633 ELSE IF (branch .EQ. 2)
THEN 15635 a4_ad(2, i) = a4_ad(2, i) + a4_ad(3, i)
15636 a4_ad(4, i) = a4_ad(4, i) - a4_ad(3, i)
15639 a4_ad(2, i) = a4_ad(2, i) + 3.*a4_ad(4, i)
15640 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
15646 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
15649 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
15654 ELSE IF (branch .EQ. 2)
THEN 15659 temp_ad = 3.*a4_ad(4, i)
15660 a4_ad(1, i) = a4_ad(1, i) + 2.*temp_ad
15661 a4_ad(2, i) = a4_ad(2, i) - temp_ad
15662 a4_ad(3, i) = a4_ad(3, i) - temp_ad
15666 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
15667 min2_ad = sign(1.d0, min2*qmp)*a4_ad(3, i)
15670 IF (branch .EQ. 0)
THEN 15680 IF (branch .EQ. 0)
THEN 15681 a4_ad(3, i) = a4_ad(3, i) + y2_ad
15682 a4_ad(1, i) = a4_ad(1, i) - y2_ad
15684 a4_ad(1, i) = a4_ad(1, i) + y2_ad
15685 a4_ad(3, i) = a4_ad(3, i) - y2_ad
15688 IF (branch .EQ. 0)
THEN 15694 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
15695 min1_ad = -(sign(1.d0, min1*qmp)*a4_ad(2, i))
15698 IF (branch .EQ. 0)
THEN 15708 IF (branch .EQ. 0)
THEN 15709 a4_ad(2, i) = a4_ad(2, i) + y1_ad
15710 a4_ad(1, i) = a4_ad(1, i) - y1_ad
15712 a4_ad(1, i) = a4_ad(1, i) + y1_ad
15713 a4_ad(2, i) = a4_ad(2, i) - y1_ad
15716 IF (branch .EQ. 0)
THEN 15717 qmp_ad = qmp_ad + x1_ad
15719 qmp_ad = qmp_ad - x1_ad
15721 dm_ad(i) = dm_ad(i) + 2.*qmp_ad
15723 ELSE IF (branch .NE. 3)
THEN 15726 IF (branch .GE. 2)
THEN 15727 IF (branch .EQ. 2)
THEN 15729 a4_ad(3, i) = a4_ad(3, i) + a4_ad(2, i)
15730 a4_ad(4, i) = a4_ad(4, i) - a4_ad(2, i)
15733 a4_ad(3, i) = a4_ad(3, i) + 3.*a4_ad(4, i)
15734 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
15736 ELSE IF (branch .EQ. 3)
THEN 15738 a4_ad(2, i) = a4_ad(2, i) + a4_ad(3, i)
15739 a4_ad(4, i) = a4_ad(4, i) - a4_ad(3, i)
15742 a4_ad(2, i) = a4_ad(2, i) + 3.*a4_ad(4, i)
15743 a4_ad(1, i) = a4_ad(1, i) - 3.*a4_ad(4, i)
15749 a4_ad(1, i) = a4_ad(1, i) + a4_ad(2, i)
15752 a4_ad(1, i) = a4_ad(1, i) + a4_ad(3, i)
15759 SUBROUTINE steepz(i1, i2, km, a4, df2, dm, dq, dp, d4)
15761 INTEGER,
INTENT(IN) :: km, i1, i2
15763 REAL,
INTENT(IN) :: dp(i1:i2, km)
15765 REAL,
INTENT(IN) :: dq(i1:i2, km)
15767 REAL,
INTENT(IN) :: d4(i1:i2, km)
15769 REAL,
INTENT(IN) :: df2(i1:i2, km)
15771 REAL,
INTENT(IN) :: dm(i1:i2, km)
15774 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
15777 REAL :: alfa(i1:i2, km)
15778 REAL :: f(i1:i2, km)
15779 REAL :: rat(i1:i2, km)
15787 rat(i, k) = dq(i, k-1)/d4(i, k)
15793 f(i, k) = (rat(i, k+1)-rat(i, k))/(dp(i, k-1)+dp(i, k)+dp(i, k+1&
15799 IF (f(i, k+1)*f(i, k-1) .LT. 0. .AND. df2(i, k) .NE. 0.)
THEN 15800 dg2 = (f(i, k+1)-f(i, k-1))*((dp(i, k+1)-dp(i, k-1))**2+d4(i, &
15802 IF (0.5 .GT. -(0.1875*dg2/df2(i, k)))
THEN 15803 y1 = -(0.1875*dg2/df2(i, k))
15807 IF (0. .LT. y1)
THEN 15819 a4(2, i, k) = (1.-alfa(i, k-1)-alfa(i, k))*a4(2, i, k) + alfa(i&
15820 & , k-1)*(a4(1, i, k)-dm(i, k)) + alfa(i, k)*(a4(1, i, k-1)+dm(i&
15825 SUBROUTINE rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, &
15826 & ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, &
15827 & w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, &
15828 & make_nh, domain, square_domain)
15835 INTEGER,
INTENT(IN) :: km
15837 INTEGER,
INTENT(IN) :: kn
15839 INTEGER,
INTENT(IN) :: nq, ntp
15841 INTEGER,
INTENT(IN) :: is, ie, isd, ied
15843 INTEGER,
INTENT(IN) :: js, je, jsd, jed
15844 LOGICAL,
INTENT(IN) :: hydrostatic, make_nh, square_domain
15845 REAL,
INTENT(IN) :: ptop
15846 REAL,
INTENT(IN) :: ak_r(km+1)
15847 REAL,
INTENT(IN) :: bk_r(km+1)
15848 REAL,
INTENT(IN) :: ak(kn+1)
15849 REAL,
INTENT(IN) :: bk(kn+1)
15851 REAL,
INTENT(IN) :: delp_r(is:ie, js:je, km)
15853 REAL,
INTENT(IN) :: u_r(is:ie, js:je+1, km)
15855 REAL,
INTENT(IN) :: v_r(is:ie+1, js:je, km)
15856 REAL,
INTENT(INOUT) :: pt_r(is:ie, js:je, km)
15857 REAL,
INTENT(IN) :: w_r(is:ie, js:je, km)
15858 REAL,
INTENT(IN) :: q_r(is:ie, js:je, km, ntp)
15859 REAL,
INTENT(IN) :: qdiag_r(is:ie, js:je, km, ntp+1:nq)
15860 REAL,
INTENT(INOUT) :: delz_r(is:ie, js:je, km)
15861 TYPE(
domain2d),
INTENT(INOUT) :: domain
15864 REAL,
INTENT(OUT) :: delp(isd:ied, jsd:jed, kn)
15866 REAL,
INTENT(OUT) :: u(isd:ied, jsd:jed+1, kn)
15868 REAL,
INTENT(OUT) :: v(isd:ied+1, jsd:jed, kn)
15870 REAL,
INTENT(OUT) :: w(isd:, jsd:, :)
15872 REAL,
INTENT(OUT) :: pt(isd:ied, jsd:jed, kn)
15873 REAL,
INTENT(OUT) :: q(isd:ied, jsd:jed, kn, ntp)
15874 REAL,
INTENT(OUT) :: qdiag(isd:ied, jsd:jed, kn, ntp+1:nq)
15876 REAL,
INTENT(OUT) :: delz(isd:, jsd:, :)
15878 REAL :: r_vir, rgrav
15880 REAL :: ps(isd:ied, jsd:jed)
15881 REAL :: pe1(is:ie, km+1)
15882 REAL :: pe2(is:ie, kn+1)
15883 REAL :: pv1(is:ie+1, km+1)
15884 REAL :: pv2(is:ie+1, kn+1)
15885 INTEGER :: i, j, k, iq
15886 INTEGER,
PARAMETER :: kord=4
15902 ps(i, j) = ps(i, j) + delp_r(i, j, k)
15907 IF (square_domain)
THEN 15909 & ehalo=1, shalo=1, nhalo=1)
15918 pt_r(i, j, k) = pt_r(i, j, k)*(1.+r_vir*q_r(i, j, k, 1))
15932 pe1(i, k) = ak_r(k) + 0.5*bk_r(k)*(ps(i, j-1)+ps(i, j))
15937 pe2(i, k) = ak(k) + 0.5*bk(k)*(ps(i, j-1)+ps(i, j))
15940 CALL remap_2d(km, pe1, u_r(is:ie, j:j, 1:km), kn, pe2, u(is:ie, j:&
15941 & j, 1:kn), is, ie, -1, kord)
15943 IF (j .NE. je + 1)
THEN 15949 pe1(i, k) = ak_r(k) + bk_r(k)*ps(i, j)
15954 pe2(i, k) = ak(k) + bk(k)*ps(i, j)
15962 delp(i, j, k) = pe2(i, k+1) - pe2(i, k)
15968 IF (nq .NE. 0)
THEN 15970 CALL remap_2d(km, pe1, q_r(is:ie, j:j, 1:km, iq:iq), kn, pe2&
15971 & , q(is:ie, j:j, 1:kn, iq:iq), is, ie, 0, kord)
15974 CALL remap_2d(km, pe1, qdiag_r(is:ie, j:j, 1:km, iq:iq), kn&
15975 & , pe2, qdiag(is:ie, j:j, 1:kn, iq:iq), is, ie, 0, &
15979 IF (.NOT.hydrostatic .AND. (.NOT.make_nh))
THEN 15981 CALL remap_2d(km, pe1, w_r(is:ie, j:j, 1:km), kn, pe2, w(is:ie&
15982 & , j:j, 1:kn), is, ie, -1, kord)
15987 delz_r(i, j, k) = -(delz_r(i, j, k)/delp_r(i, j, k))
15990 CALL remap_2d(km, pe1, delz_r(is:ie, j:j, 1:km), kn, pe2, delz&
15991 & (is:ie, j:j, 1:kn), is, ie, 1, kord)
15994 delz(i, j, k) = -(delz(i, j, k)*delp(i, j, k))
16001 pe1(i, k) = log(pe1(i, k))
16006 pe2(i, k) = log(pe2(i, k))
16009 CALL remap_2d(km, pe1, pt_r(is:ie, j:j, 1:km), kn, pe2, pt(is:ie&
16010 & , j:j, 1:kn), is, ie, 1, kord)
16016 pv1(i, k) = ak_r(k) + 0.5*bk_r(k)*(ps(i-1, j)+ps(i, j))
16021 pv2(i, k) = ak(k) + 0.5*bk(k)*(ps(i-1, j)+ps(i, j))
16025 CALL remap_2d(km, pv1, v_r(is:ie+1, j:j, 1:km), kn, pv2, v(is:ie&
16026 & +1, j:j, 1:kn), is, arg1, -1, kord)
16033 pt(i, j, k) = pt(i, j, k)/(1.+r_vir*q(i, j, k, 1))
16038 SUBROUTINE remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
16040 INTEGER,
INTENT(IN) :: i1, i2
16042 INTEGER,
INTENT(IN) :: iv
16043 INTEGER,
INTENT(IN) :: kord
16045 INTEGER,
INTENT(IN) :: km
16047 INTEGER,
INTENT(IN) :: kn
16049 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
16053 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
16057 REAL,
INTENT(IN) :: q1(i1:i2, km)
16059 REAL,
INTENT(OUT) :: q2(i1:i2, kn)
16062 REAL :: dp1(i1:i2, km)
16063 REAL :: q4(4, i1:i2, km)
16064 REAL :: pl, pr, qsum, dp, esl
16065 INTEGER :: i, k, l, m, k0
16068 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
16069 q4(1, i, k) = q1(i, k)
16073 IF (kord .GT. 7)
THEN 16074 CALL cs_profile(qs, q4, dp1, km, i1, i2, iv, kord)
16081 IF (pe2(i, k) .LE. pe1(i, 1))
THEN 16083 q2(i, k) = q1(i, 1)
16087 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1&
16089 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
16090 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 16092 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
16093 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4&
16094 & (2, i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
16099 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i&
16100 & , l)+q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*&
16101 & (1.+pl*(1.+pl))))
16104 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 16106 qsum = qsum + dp1(i, m)*q4(1, i, m)
16108 dp = pe2(i, k+1) - pe1(i, m)
16110 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-&
16111 & q4(2, i, m)+q4(4, i, m)*(1.-
r23*esl)))
16120 123 q2(i, k) = qsum/(pe2(i, k+1)-pe2(i, k))
16126 SUBROUTINE mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
16136 INTEGER,
INTENT(IN) :: i1, i2, km, kn, kord, iv
16137 REAL,
INTENT(IN) :: pe1(i1:i2, km+1), pe2(i1:i2, kn+1)
16138 REAL,
INTENT(IN) :: q1(i1:i2, km)
16139 REAL,
INTENT(OUT) :: q2(i1:i2, kn)
16140 REAL,
INTENT(IN) :: ptop
16143 REAL :: dp1(i1:i2, km)
16144 REAL :: a4(4, i1:i2, km)
16147 REAL :: pl, pr, tt, delp, qsum, dpsum, esl
16150 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
16151 a4(1, i, k) = q1(i, k)
16154 IF (kord .GT. 7)
THEN 16155 CALL cs_profile(qs, a4, dp1, km, i1, i2, iv, kord)
16165 IF (pe2(i, k) .LE. pe1(i, 1))
THEN 16167 q2(i, k) = q1(i, 1)
16168 ELSE IF (pe2(i, k) .GE. pe1(i, km+1))
THEN 16170 q2(i, k) = q1(i, km)
16174 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1&
16177 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
16178 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 16180 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
16181 tt =
r3*(pr*(pr+pl)+pl**2)
16182 q2(i, k) = a4(2, i, l) + 0.5*(a4(4, i, l)+a4(3, i, l)-a4&
16183 & (2, i, l))*(pr+pl) - a4(4, i, l)*tt
16187 delp = pe1(i, l+1) - pe2(i, k)
16188 tt =
r3*(1.+pl*(1.+pl))
16189 qsum = delp*(a4(2, i, l)+0.5*(a4(4, i, l)+a4(3, i, l)-a4&
16190 & (2, i, l))*(1.+pl)-a4(4, i, l)*tt)
16199 IF (pe2(i, k+1) .GT. pe1(i, l+1))
THEN 16201 qsum = qsum + dp1(i, l)*q1(i, l)
16202 dpsum = dpsum + dp1(i, l)
16204 delp = pe2(i, k+1) - pe1(i, l)
16205 esl = delp/dp1(i, l)
16206 qsum = qsum + delp*(a4(2, i, l)+0.5*esl*(a4(3, i, l)-a4(2&
16207 & , i, l)+a4(4, i, l)*(1.-
r23*esl)))
16208 dpsum = dpsum + delp
16213 delp = pe2(i, k+1) - pe1(i, km+1)
16214 IF (delp .GT. 0.)
THEN 16216 qsum = qsum + delp*q1(i, km)
16217 dpsum = dpsum + delp
16219 123 q2(i, k) = qsum/dpsum
16224 END SUBROUTINE mappm 16225 SUBROUTINE ppm_profile(a4, delp, km, i1, i2, iv, kord)
16229 INTEGER,
INTENT(IN) :: iv
16234 INTEGER,
INTENT(IN) :: i1
16236 INTEGER,
INTENT(IN) :: i2
16238 INTEGER,
INTENT(IN) :: km
16240 INTEGER,
INTENT(IN) :: kord
16243 REAL,
INTENT(IN) :: delp(i1:i2, km)
16246 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
16255 REAL :: dc(i1:i2, km)
16256 REAL :: h2(i1:i2, km)
16257 REAL :: delq(i1:i2, km)
16258 REAL :: df2(i1:i2, km)
16259 REAL :: d4(i1:i2, km)
16261 INTEGER :: i, k, km1, lmt, it
16263 REAL :: a1, a2, c1, c2, c3, d1, d2
16264 REAL :: qm, dq, lac, qmp, pmp
16290 delq(i, k-1) = a4(1, i, k) - a4(1, i, k-1)
16291 d4(i, k) = delp(i, k-1) + delp(i, k)
16296 c1 = (delp(i, k-1)+0.5*delp(i, k))/d4(i, k+1)
16297 c2 = (delp(i, k+1)+0.5*delp(i, k))/d4(i, k)
16298 df2(i, k) = delp(i, k)*(c1*delq(i, k)+c2*delq(i, k-1))/(d4(i, k)&
16300 IF (df2(i, k) .GE. 0.)
THEN 16305 IF (a4(1, i, k-1) .LT. a4(1, i, k))
THEN 16306 IF (a4(1, i, k) .LT. a4(1, i, k+1))
THEN 16307 max1 = a4(1, i, k+1)
16311 ELSE IF (a4(1, i, k-1) .LT. a4(1, i, k+1))
THEN 16312 max1 = a4(1, i, k+1)
16314 max1 = a4(1, i, k-1)
16316 y1 = max1 - a4(1, i, k)
16317 IF (a4(1, i, k-1) .GT. a4(1, i, k))
THEN 16318 IF (a4(1, i, k) .GT. a4(1, i, k+1))
THEN 16319 min2 = a4(1, i, k+1)
16323 ELSE IF (a4(1, i, k-1) .GT. a4(1, i, k+1))
THEN 16324 min2 = a4(1, i, k+1)
16326 min2 = a4(1, i, k-1)
16328 z1 = a4(1, i, k) - min2
16329 IF (x1 .GT. y1)
THEN 16330 IF (y1 .GT. z1)
THEN 16335 ELSE IF (x1 .GT. z1)
THEN 16340 dc(i, k) = sign(min1, df2(i, k))
16348 c1 = delq(i, k-1)*delp(i, k-1)/d4(i, k)
16349 a1 = d4(i, k-1)/(d4(i, k)+delp(i, k-1))
16350 a2 = d4(i, k+1)/(d4(i, k)+delp(i, k))
16351 a4(2, i, k) = a4(1, i, k-1) + c1 + 2./(d4(i, k-1)+d4(i, k+1))*(&
16352 & delp(i, k)*(c1*(a1-a2)+a2*dc(i, k-1))-delp(i, k-1)*a1*dc(i, k)&
16362 qm = (d2*a4(1, i, 1)+d1*a4(1, i, 2))/(d1+d2)
16363 dq = 2.*(a4(1, i, 2)-a4(1, i, 1))/(d1+d2)
16364 c1 = 4.*(a4(2, i, 3)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
16365 c3 = dq - 0.5*c1*(d2*(5.*d1+d2)-3.*d1*d1)
16366 a4(2, i, 2) = qm - 0.25*c1*d1*d2*(d2+3.*d1)
16369 a4(2, i, 1) = d1*(2.*c1*d1**2-c3) + a4(2, i, 2)
16370 IF (a4(1, i, 1) .GT. a4(1, i, 2))
THEN 16375 IF (a4(2, i, 2) .LT. y2)
THEN 16378 a4(2, i, 2) = a4(2, i, 2)
16380 IF (a4(1, i, 1) .LT. a4(1, i, 2))
THEN 16385 IF (a4(2, i, 2) .GT. y3)
THEN 16388 a4(2, i, 2) = a4(2, i, 2)
16390 dc(i, 1) = 0.5*(a4(2, i, 2)-a4(1, i, 1))
16393 IF (iv .EQ. 0)
THEN 16395 IF (0. .LT. a4(2, i, 1))
THEN 16396 a4(2, i, 1) = a4(2, i, 1)
16400 IF (0. .LT. a4(2, i, 2))
THEN 16401 a4(2, i, 2) = a4(2, i, 2)
16406 ELSE IF (iv .EQ. -1)
THEN 16408 IF (a4(2, i, 1)*a4(1, i, 1) .LE. 0.) a4(2, i, 1) = 0.
16411 IF (iv .GE. 0.)
THEN 16416 IF (abs0 .EQ. 2)
THEN 16418 a4(2, i, 1) = a4(1, i, 1)
16419 a4(3, i, 1) = a4(1, i, 1)
16428 qm = (d2*a4(1, i, km)+d1*a4(1, i, km1))/(d1+d2)
16429 dq = 2.*(a4(1, i, km1)-a4(1, i, km))/(d1+d2)
16430 c1 = (a4(2, i, km1)-qm-d2*dq)/(d2*(2.*d2*d2+d1*(d2+3.*d1)))
16431 c3 = dq - 2.0*c1*(d2*(5.*d1+d2)-3.*d1*d1)
16432 a4(2, i, km) = qm - c1*d1*d2*(d2+3.*d1)
16435 a4(3, i, km) = d1*(8.*c1*d1**2-c3) + a4(2, i, km)
16436 IF (a4(1, i, km) .GT. a4(1, i, km1))
THEN 16441 IF (a4(2, i, km) .LT. y4)
THEN 16444 a4(2, i, km) = a4(2, i, km)
16446 IF (a4(1, i, km) .LT. a4(1, i, km1))
THEN 16451 IF (a4(2, i, km) .GT. y5)
THEN 16454 a4(2, i, km) = a4(2, i, km)
16456 dc(i, km) = 0.5*(a4(1, i, km)-a4(2, i, km))
16459 IF (iv .EQ. 0)
THEN 16461 IF (0. .LT. a4(2, i, km))
THEN 16462 a4(2, i, km) = a4(2, i, km)
16466 IF (0. .LT. a4(3, i, km))
THEN 16467 a4(3, i, km) = a4(3, i, km)
16472 ELSE IF (iv .LT. 0)
THEN 16474 IF (a4(1, i, km)*a4(3, i, km) .LE. 0.) a4(3, i, km) = 0.
16479 a4(3, i, k) = a4(2, i, k+1)
16488 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
16492 IF (kord .GE. 7)
THEN 16501 h2(i, k) = 2.*(dc(i, k+1)/delp(i, k+1)-dc(i, k-1)/delp(i, k-1)&
16502 & )/(delp(i, k)+0.5*(delp(i, k-1)+delp(i, k+1)))*delp(i, k)**2
16516 qmp = a4(1, i, k) + pmp
16517 lac = a4(1, i, k) + fac*h2(i, k-1) + dc(i, k)
16518 IF (a4(1, i, k) .GT. qmp)
THEN 16519 IF (qmp .GT. lac)
THEN 16524 ELSE IF (a4(1, i, k) .GT. lac)
THEN 16529 IF (a4(3, i, k) .LT. y8)
THEN 16534 IF (a4(1, i, k) .LT. qmp)
THEN 16535 IF (qmp .LT. lac)
THEN 16540 ELSE IF (a4(1, i, k) .LT. lac)
THEN 16545 IF (x2 .GT. y6)
THEN 16554 qmp = a4(1, i, k) - pmp
16555 lac = a4(1, i, k) + fac*h2(i, k+1) - dc(i, k)
16556 IF (a4(1, i, k) .GT. qmp)
THEN 16557 IF (qmp .GT. lac)
THEN 16562 ELSE IF (a4(1, i, k) .GT. lac)
THEN 16567 IF (a4(2, i, k) .LT. y9)
THEN 16572 IF (a4(1, i, k) .LT. qmp)
THEN 16573 IF (qmp .LT. lac)
THEN 16578 ELSE IF (a4(1, i, k) .LT. lac)
THEN 16583 IF (x3 .GT. y7)
THEN 16591 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
16594 IF (iv .EQ. 0 .AND. kord .GE. 6)
CALL ppm_limiters(dc(i1, k), a4&
16595 & (1, i1, k), it, 2)
16599 IF (0 .LT. lmt)
THEN 16604 IF (iv .EQ. 0)
THEN 16605 IF (2 .GT. lmt)
THEN 16612 IF (kord .NE. 4)
THEN 16614 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
16617 IF (kord .NE. 6)
CALL ppm_limiters(dc(i1, k), a4(1, i1, k), it, &
16623 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
16632 REAL,
INTENT(IN) :: dm(*)
16634 INTEGER,
INTENT(IN) :: itot
16636 INTEGER,
INTENT(IN) :: lmt
16642 REAL,
INTENT(INOUT) :: a4(4, *)
16649 REAL :: da1, da2, a6da
16663 IF (lmt .EQ. 3)
THEN 16665 ELSE IF (lmt .EQ. 0)
THEN 16668 IF (dm(i) .EQ. 0.)
THEN 16669 a4(2, i) = a4(1, i)
16670 a4(3, i) = a4(1, i)
16673 da1 = a4(3, i) - a4(2, i)
16675 a6da = a4(4, i)*da1
16676 IF (a6da .LT. -da2)
THEN 16677 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
16678 a4(3, i) = a4(2, i) - a4(4, i)
16679 ELSE IF (a6da .GT. da2)
THEN 16680 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
16681 a4(2, i) = a4(3, i) - a4(4, i)
16685 ELSE IF (lmt .EQ. 1)
THEN 16690 IF (qmp .GE. 0.)
THEN 16695 IF (a4(2, i) - a4(1, i) .GE. 0.)
THEN 16696 y1 = a4(2, i) - a4(1, i)
16698 y1 = -(a4(2, i)-a4(1, i))
16700 IF (x1 .GT. y1)
THEN 16705 a4(2, i) = a4(1, i) - sign(min1, qmp)
16706 IF (qmp .GE. 0.)
THEN 16711 IF (a4(3, i) - a4(1, i) .GE. 0.)
THEN 16712 y2 = a4(3, i) - a4(1, i)
16714 y2 = -(a4(3, i)-a4(1, i))
16716 IF (x2 .GT. y2)
THEN 16721 a4(3, i) = a4(1, i) + sign(min2, qmp)
16722 a4(4, i) = 3.*(2.*a4(1, i)-(a4(2, i)+a4(3, i)))
16724 ELSE IF (lmt .EQ. 2)
THEN 16727 IF (a4(3, i) - a4(2, i) .GE. 0.)
THEN 16728 abs0 = a4(3, i) - a4(2, i)
16730 abs0 = -(a4(3, i)-a4(2, i))
16732 IF (abs0 .LT. -a4(4, i))
THEN 16733 fmin = a4(1, i) + 0.25*(a4(3, i)-a4(2, i))**2/a4(4, i) + a4(4&
16735 IF (fmin .LT. 0.)
THEN 16736 IF (a4(1, i) .LT. a4(3, i) .AND. a4(1, i) .LT. a4(2, i)) &
16738 a4(3, i) = a4(1, i)
16739 a4(2, i) = a4(1, i)
16741 ELSE IF (a4(3, i) .GT. a4(2, i))
THEN 16742 a4(4, i) = 3.*(a4(2, i)-a4(1, i))
16743 a4(3, i) = a4(2, i) - a4(4, i)
16745 a4(4, i) = 3.*(a4(3, i)-a4(1, i))
16746 a4(2, i) = a4(3, i) - a4(4, i)
16753 SUBROUTINE moist_cv(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum&
16754 & , liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cvm, t1)
16756 INTEGER,
INTENT(IN) :: is, ie, isd, ied, jsd, jed, km, nwat, j, k
16757 INTEGER,
INTENT(IN) :: sphum, liq_wat, rainwat, ice_wat, snowwat, &
16759 REAL,
DIMENSION(isd:ied, jsd:jed, km, nwat),
INTENT(IN) :: q
16760 REAL,
DIMENSION(is:ie),
INTENT(OUT) :: cvm, qd
16761 REAL,
INTENT(IN),
OPTIONAL :: t1(is:ie)
16763 REAL,
PARAMETER :: t_i0=15.
16764 REAL,
DIMENSION(is:ie) :: qv, ql, qs
16770 IF (
PRESENT(t1))
THEN 16773 IF (0. .LT. q(i, j, k, liq_wat))
THEN 16774 qd(i) = q(i, j, k, liq_wat)
16778 IF (t1(i) .GT.
tice)
THEN 16780 ELSE IF (t1(i) .LT.
tice - t_i0)
THEN 16783 qs(i) = qd(i)*(
tice-t1(i))/t_i0
16785 ql(i) = qd(i) - qs(i)
16786 IF (0. .LT. q(i, j, k, sphum))
THEN 16787 qv(i) = q(i, j, k, sphum)
16791 cvm(i) = (1.-(qv(i)+qd(i)))*
cv_air + qv(i)*
cv_vap + ql(i)*&
16796 IF (0. .LT. q(i, j, k, sphum))
THEN 16797 qv(i) = q(i, j, k, sphum)
16801 IF (0. .LT. q(i, j, k, liq_wat))
THEN 16802 qs(i) = q(i, j, k, liq_wat)
16812 qv(i) = q(i, j, k, sphum)
16813 ql(i) = q(i, j, k, liq_wat)
16814 qs(i) = q(i, j, k, ice_wat)
16815 qd(i) = ql(i) + qs(i)
16822 qv(i) = q(i, j, k, sphum)
16823 qd(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
16828 qv(i) = q(i, j, k, sphum)
16829 ql(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
16830 qs(i) = q(i, j, k, ice_wat) + q(i, j, k, snowwat) + q(i, j, k, &
16832 qd(i) = ql(i) + qs(i)
16843 SUBROUTINE moist_cp(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum&
16844 & , liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cpm, t1)
16846 INTEGER,
INTENT(IN) :: is, ie, isd, ied, jsd, jed, km, nwat, j, k
16847 INTEGER,
INTENT(IN) :: sphum, liq_wat, rainwat, ice_wat, snowwat, &
16849 REAL,
DIMENSION(isd:ied, jsd:jed, km, nwat),
INTENT(IN) :: q
16850 REAL,
DIMENSION(is:ie),
INTENT(OUT) :: cpm, qd
16851 REAL,
INTENT(IN),
OPTIONAL :: t1(is:ie)
16853 REAL,
PARAMETER :: t_i0=15.
16854 REAL,
DIMENSION(is:ie) :: qv, ql, qs
16860 IF (
PRESENT(t1))
THEN 16863 IF (0. .LT. q(i, j, k, liq_wat))
THEN 16864 qd(i) = q(i, j, k, liq_wat)
16868 IF (t1(i) .GT.
tice)
THEN 16870 ELSE IF (t1(i) .LT.
tice - t_i0)
THEN 16873 qs(i) = qd(i)*(
tice-t1(i))/t_i0
16875 ql(i) = qd(i) - qs(i)
16876 IF (0. .LT. q(i, j, k, sphum))
THEN 16877 qv(i) = q(i, j, k, sphum)
16886 IF (0. .LT. q(i, j, k, sphum))
THEN 16887 qv(i) = q(i, j, k, sphum)
16891 IF (0. .LT. q(i, j, k, liq_wat))
THEN 16892 qs(i) = q(i, j, k, liq_wat)
16902 qv(i) = q(i, j, k, sphum)
16903 ql(i) = q(i, j, k, liq_wat)
16904 qs(i) = q(i, j, k, ice_wat)
16905 qd(i) = ql(i) + qs(i)
16912 qv(i) = q(i, j, k, sphum)
16913 qd(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
16919 qv(i) = q(i, j, k, sphum)
16920 ql(i) = q(i, j, k, liq_wat) + q(i, j, k, rainwat)
16921 qs(i) = q(i, j, k, ice_wat) + q(i, j, k, snowwat) + q(i, j, k, &
16923 qd(i) = ql(i) + qs(i)
16959 SUBROUTINE map1_cubic_fwd(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend&
16960 & , jbeg, jend, akap, t_var, conserv)
16965 INTEGER,
INTENT(IN) :: i1
16967 INTEGER,
INTENT(IN) :: i2
16968 REAL,
INTENT(IN) :: akap
16970 INTEGER,
INTENT(IN) :: t_var
16972 LOGICAL,
INTENT(IN) :: conserv
16974 INTEGER,
INTENT(IN) :: j
16975 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
16977 INTEGER,
INTENT(IN) :: km
16979 INTEGER,
INTENT(IN) :: kn
16981 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
16985 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
16991 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
17009 REAL :: qx(i1:i2, km)
17010 REAL :: logpl1(i1:i2, km)
17011 REAL :: logpl2(i1:i2, kn)
17012 REAL :: dlogp1(i1:i2, km)
17013 REAL :: vsum1(i1:i2)
17014 REAL :: vsum2(i1:i2)
17015 REAL :: am2, am1, ap0, ap1, p, plp1, plp0, plm1, plm2, dlp0, dlm1, &
17017 INTEGER :: i, k, lm2, lm1, lp0, lp1
17022 INTEGER :: ad_count
17052 SELECT CASE (t_var)
17056 qx(:, k) = q2(i1:i2, j, k)
17057 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
17060 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
17063 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17069 qx(:, k) = q2(i1:i2, j, k)
17070 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
17073 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
17076 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17082 qx(:, k) = q2(i1:i2, j, k)
17083 logpl1(:, k) = exp(akap*log(
r2*(pe1(:, k)+pe1(:, k+1))))
17086 logpl2(:, k) = exp(akap*log(
r2*(pe2(:, k)+pe2(:, k+1))))
17089 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17101 vsum1(i) = vsum1(i) + qx(i, k)*(pe1(i, k+1)-pe1(i, k))
17104 vsum1(i) = vsum1(i)/(pe1(i, km+1)-pe1(i, 1))
17117 DO WHILE (lp0 .LE. km)
17118 IF (logpl1(i, lp0) .LT. logpl2(i, k))
THEN 17120 ad_count = ad_count + 1
17130 110
IF (lp0 - 1 .LT. 1)
THEN 17139 IF (lp0 .GT. km)
THEN 17146 IF (lm1 .EQ. 1 .AND. lp0 .EQ. 1)
THEN 17148 q2(i, j, k) = qx(i, 1) + (qx(i, 2)-qx(i, 1))*(logpl2(i, k)-&
17149 & logpl1(i, 1))/(logpl1(i, 2)-logpl1(i, 1))
17153 ELSE IF (lm1 .EQ. km .AND. lp0 .EQ. km)
THEN 17155 q2(i, j, k) = qx(i, km) + (qx(i, km)-qx(i, km-1))*(logpl2(i, k&
17156 & )-logpl1(i, km))/(logpl1(i, km)-logpl1(i, km-1))
17160 ELSE IF (lm1 .EQ. 1 .OR. lp0 .EQ. km)
THEN 17162 q2(i, j, k) = qx(i, lp0) + (qx(i, lm1)-qx(i, lp0))*(logpl2(i, &
17163 & k)-logpl1(i, lp0))/(logpl1(i, lm1)-logpl1(i, lp0))
17174 plp1 = logpl1(i, lp1)
17175 plp0 = logpl1(i, lp0)
17176 plm1 = logpl1(i, lm1)
17177 plm2 = logpl1(i, lm2)
17179 dlp0 = dlogp1(i, lp0)
17181 dlm1 = dlogp1(i, lm1)
17183 dlm2 = dlogp1(i, lm2)
17185 ap1 = (p-plp0)*(p-plm1)*(p-plm2)/(dlp0*(dlp0+dlm1)*(dlp0+dlm1+&
17188 ap0 = (plp1-p)*(p-plm1)*(p-plm2)/(dlp0*dlm1*(dlm1+dlm2))
17190 am1 = (plp1-p)*(plp0-p)*(p-plm2)/(dlm1*dlm2*(dlp0+dlm1))
17192 am2 = (plp1-p)*(plp0-p)*(plm1-p)/(dlm2*(dlm1+dlm2)*(dlp0+dlm1+&
17195 q2(i, j, k) = ap1*qx(i, lp1) + ap0*qx(i, lp0) + am1*qx(i, lm1)&
17207 vsum2(i) = vsum2(i) + q2(i, j, k)*(pe2(i, k+1)-pe2(i, k))
17210 vsum2(i) = vsum2(i)/(pe2(i, kn+1)-pe2(i, 1))
17217 q2(i, j, k) = q2(i, j, k) + vsum1(i) - vsum2(i)
17280 SUBROUTINE map1_cubic_bwd(km, pe1, pe1_ad, kn, pe2, pe2_ad, q2, q2_ad&
17281 & , i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
17284 INTEGER,
INTENT(IN) :: i1
17285 INTEGER,
INTENT(IN) :: i2
17286 REAL,
INTENT(IN) :: akap
17287 INTEGER,
INTENT(IN) :: t_var
17288 LOGICAL,
INTENT(IN) :: conserv
17289 INTEGER,
INTENT(IN) :: j
17290 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
17291 INTEGER,
INTENT(IN) :: km
17292 INTEGER,
INTENT(IN) :: kn
17293 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
17294 REAL :: pe1_ad(i1:i2, km+1)
17295 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
17296 REAL :: pe2_ad(i1:i2, kn+1)
17297 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
17298 REAL,
INTENT(INOUT) :: q2_ad(ibeg:iend, jbeg:jend, kn)
17299 REAL :: qx(i1:i2, km)
17300 REAL :: qx_ad(i1:i2, km)
17301 REAL :: logpl1(i1:i2, km)
17302 REAL :: logpl1_ad(i1:i2, km)
17303 REAL :: logpl2(i1:i2, kn)
17304 REAL :: logpl2_ad(i1:i2, kn)
17305 REAL :: dlogp1(i1:i2, km)
17306 REAL :: dlogp1_ad(i1:i2, km)
17307 REAL :: vsum1(i1:i2)
17308 REAL :: vsum1_ad(i1:i2)
17309 REAL :: vsum2(i1:i2)
17310 REAL :: vsum2_ad(i1:i2)
17311 REAL :: am2, am1, ap0, ap1, p, plp1, plp0, plm1, plm2, dlp0, dlm1, &
17313 REAL :: am2_ad, am1_ad, ap0_ad, ap1_ad, p_ad, plp1_ad, plp0_ad, &
17314 & plm1_ad, plm2_ad, dlp0_ad, dlm1_ad, dlm2_ad
17315 INTEGER :: i, k, lm2, lm1, lp0, lp1
17320 REAL,
DIMENSION(i2-i1+1) :: temp_ad
17321 REAL,
DIMENSION(i2-i1+1) :: temp_ad0
17322 REAL,
DIMENSION(i2-i1+1) :: temp_ad1
17323 REAL,
DIMENSION(i2-i1+1) :: temp_ad2
17324 REAL,
DIMENSION(i2-i1+1) :: temp
17325 REAL,
DIMENSION(i2-i1+1) :: temp_ad3
17326 REAL,
DIMENSION(i2-i1+1) :: temp0
17327 REAL,
DIMENSION(i2-i1+1) :: temp_ad4
17375 INTEGER :: ad_count
17407 IF (branch .EQ. 0)
THEN 17428 vsum1_ad(i) = vsum1_ad(i) + q2_ad(i, j, k)
17429 vsum2_ad(i) = vsum2_ad(i) - q2_ad(i, j, k)
17434 temp21 = pe2(i, kn+1) - pe2(i, 1)
17435 temp_ad30 = -(vsum2(i)*vsum2_ad(i)/temp21**2)
17436 pe2_ad(i, kn+1) = pe2_ad(i, kn+1) + temp_ad30
17437 pe2_ad(i, 1) = pe2_ad(i, 1) - temp_ad30
17438 vsum2_ad(i) = vsum2_ad(i)/temp21
17440 temp_ad29 = q2(i, j, k)*vsum2_ad(i)
17441 q2_ad(i, j, k) = q2_ad(i, j, k) + (pe2(i, k+1)-pe2(i, k))*&
17443 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad29
17444 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad29
17472 IF (branch .LT. 2)
THEN 17473 IF (branch .EQ. 0)
THEN 17475 ap1_ad = qx(i, lp1)*q2_ad(i, j, k)
17476 qx_ad(i, lp1) = qx_ad(i, lp1) + ap1*q2_ad(i, j, k)
17477 ap0_ad = qx(i, lp0)*q2_ad(i, j, k)
17478 qx_ad(i, lp0) = qx_ad(i, lp0) + ap0*q2_ad(i, j, k)
17479 am1_ad = qx(i, lm1)*q2_ad(i, j, k)
17480 qx_ad(i, lm1) = qx_ad(i, lm1) + am1*q2_ad(i, j, k)
17481 am2_ad = qx(i, lm2)*q2_ad(i, j, k)
17482 qx_ad(i, lm2) = qx_ad(i, lm2) + am2*q2_ad(i, j, k)
17483 q2_ad(i, j, k) = 0.0
17484 plp0 = logpl1(i, lp0)
17485 plp1 = logpl1(i, lp1)
17486 plm1 = logpl1(i, lm1)
17488 temp20 = dlm2*(dlm1+dlm2)
17489 temp19 = temp20*(dlp0+dlm1+dlm2)
17490 temp_ad13 = am2_ad/temp19
17491 temp_ad14 = (plm1-p)*temp_ad13
17492 temp18 = (plp1-p)*(plp0-p)
17493 temp_ad15 = -(temp18*(plm1-p)*temp_ad13/temp19)
17494 temp_ad16 = (dlp0+dlm1+dlm2)*temp_ad15
17495 temp_ad17 = temp20*temp_ad15
17496 plm2 = logpl1(i, lm2)
17499 temp_ad20 = am1_ad/(temp17*(dlp0+dlm1))
17500 temp_ad18 = (p-plm2)*temp_ad20
17501 temp16 = (plp1-p)*(plp0-p)
17502 temp_ad24 = -(temp16*(p-plm2)*temp_ad20/(temp17*(dlp0+dlm1))&
17506 temp_ad23 = ap0_ad/(temp15*(dlm1+dlm2))
17507 temp_ad19 = (p-plm2)*temp_ad23
17508 plp1_ad = (plp0-p)*temp_ad18 + (p-plm1)*temp_ad19 + (plp0-p)&
17510 temp14 = (plp1-p)*(p-plm1)
17511 temp_ad26 = -(temp14*(p-plm2)*temp_ad23/(temp15*(dlm1+dlm2))&
17514 temp13 = dlp0*(dlp0+dlm1)
17515 temp12 = temp13*(dlp0+dlm1+dlm2)
17516 temp_ad22 = ap1_ad/temp12
17517 temp_ad21 = (p-plm2)*temp_ad22
17518 plp0_ad = (plp1-p)*temp_ad18 - (p-plm1)*temp_ad21 + (plp1-p)&
17520 plm1_ad = temp18*temp_ad13 - (p-plp0)*temp_ad21 - (plp1-p)*&
17522 temp11 = (p-plp0)*(p-plm1)
17523 p_ad = (2*p-plp1-plp0)*temp_ad18 + temp16*temp_ad20 + (2*p-&
17524 & plp0-plm1)*temp_ad21 + temp11*temp_ad22 + temp14*temp_ad23&
17525 & + (plp1-2*p+plm1)*temp_ad19 - temp18*temp_ad13 + (2*p-plp1&
17527 plm2_ad = -(temp14*temp_ad23) - temp11*temp_ad22 - temp16*&
17529 temp_ad28 = -(temp11*(p-plm2)*temp_ad22/temp12)
17530 temp_ad27 = (dlp0+dlm1+dlm2)*temp_ad28
17531 temp_ad25 = temp13*temp_ad28
17532 dlm2_ad = (dlp0+dlm1)*dlm1*temp_ad24 + temp_ad25 + temp15*&
17533 & temp_ad26 + temp_ad17 + (2*dlm2+dlm1)*temp_ad16
17534 dlm1_ad = (temp17+(dlp0+dlm1)*dlm2)*temp_ad24 + dlp0*&
17535 & temp_ad27 + temp_ad25 + (temp15+(dlm1+dlm2)*dlp0)*&
17536 & temp_ad26 + temp_ad17 + dlm2*temp_ad16
17537 dlp0_ad = temp17*temp_ad24 + (2*dlp0+dlm1)*temp_ad27 + &
17538 & temp_ad25 + (dlm1+dlm2)*dlm1*temp_ad26 + temp_ad17
17540 dlogp1_ad(i, lm2) = dlogp1_ad(i, lm2) + dlm2_ad
17542 dlogp1_ad(i, lm1) = dlogp1_ad(i, lm1) + dlm1_ad
17544 dlogp1_ad(i, lp0) = dlogp1_ad(i, lp0) + dlp0_ad
17545 logpl1_ad(i, lm2) = logpl1_ad(i, lm2) + plm2_ad
17546 logpl1_ad(i, lm1) = logpl1_ad(i, lm1) + plm1_ad
17547 logpl1_ad(i, lp0) = logpl1_ad(i, lp0) + plp0_ad
17548 logpl1_ad(i, lp1) = logpl1_ad(i, lp1) + plp1_ad
17550 logpl2_ad(i, k) = logpl2_ad(i, k) + p_ad
17555 temp8 = logpl1(i, lm1) - logpl1(i, lp0)
17556 temp_ad11 = q2_ad(i, j, k)/temp8
17557 temp10 = logpl2(i, k) - logpl1(i, lp0)
17558 temp9 = qx(i, lm1) - qx(i, lp0)
17559 temp_ad12 = -(temp9*temp10*temp_ad11/temp8)
17560 qx_ad(i, lp0) = qx_ad(i, lp0) + q2_ad(i, j, k) - temp10*&
17562 qx_ad(i, lm1) = qx_ad(i, lm1) + temp10*temp_ad11
17563 logpl2_ad(i, k) = logpl2_ad(i, k) + temp9*temp_ad11
17564 logpl1_ad(i, lp0) = logpl1_ad(i, lp0) - temp_ad12 - temp9*&
17566 logpl1_ad(i, lm1) = logpl1_ad(i, lm1) + temp_ad12
17567 q2_ad(i, j, k) = 0.0
17569 ELSE IF (branch .EQ. 2)
THEN 17571 temp5 = logpl1(i, km) - logpl1(i, km-1)
17572 temp_ad9 = q2_ad(i, j, k)/temp5
17573 temp7 = logpl2(i, k) - logpl1(i, km)
17574 temp6 = qx(i, km) - qx(i, km-1)
17575 temp_ad10 = -(temp6*temp7*temp_ad9/temp5)
17576 qx_ad(i, km) = qx_ad(i, km) + temp7*temp_ad9 + q2_ad(i, j, k)
17577 qx_ad(i, km-1) = qx_ad(i, km-1) - temp7*temp_ad9
17578 logpl2_ad(i, k) = logpl2_ad(i, k) + temp6*temp_ad9
17579 logpl1_ad(i, km) = logpl1_ad(i, km) + temp_ad10 - temp6*&
17581 logpl1_ad(i, km-1) = logpl1_ad(i, km-1) - temp_ad10
17582 q2_ad(i, j, k) = 0.0
17585 temp3 = logpl1(i, 2) - logpl1(i, 1)
17586 temp4 = qx(i, 2) - qx(i, 1)
17587 temp2 = temp4/temp3
17588 temp_ad7 = (logpl2(i, k)-logpl1(i, 1))*q2_ad(i, j, k)/temp3
17589 temp_ad8 = -(temp2*temp_ad7)
17590 qx_ad(i, 1) = qx_ad(i, 1) + q2_ad(i, j, k) - temp_ad7
17591 logpl2_ad(i, k) = logpl2_ad(i, k) + temp2*q2_ad(i, j, k)
17592 logpl1_ad(i, 1) = logpl1_ad(i, 1) - temp_ad8 - temp2*q2_ad(i, &
17594 qx_ad(i, 2) = qx_ad(i, 2) + temp_ad7
17595 logpl1_ad(i, 2) = logpl1_ad(i, 2) + temp_ad8
17596 q2_ad(i, j, k) = 0.0
17599 IF (branch .EQ. 0)
THEN 17612 IF (branch .NE. 0)
THEN 17615 temp1 = pe1(i, km+1) - pe1(i, 1)
17616 temp_ad6 = -(vsum1(i)*vsum1_ad(i)/temp1**2)
17617 pe1_ad(i, km+1) = pe1_ad(i, km+1) + temp_ad6
17618 pe1_ad(i, 1) = pe1_ad(i, 1) - temp_ad6
17619 vsum1_ad(i) = vsum1_ad(i)/temp1
17621 temp_ad5 = qx(i, k)*vsum1_ad(i)
17622 qx_ad(i, k) = qx_ad(i, k) + (pe1(i, k+1)-pe1(i, k))*vsum1_ad(i&
17624 pe1_ad(i, k+1) = pe1_ad(i, k+1) + temp_ad5
17625 pe1_ad(i, k) = pe1_ad(i, k) - temp_ad5
17630 IF (branch .LT. 2)
THEN 17631 IF (branch .NE. 0)
THEN 17633 logpl1_ad(:, k+1) = logpl1_ad(:, k+1) + dlogp1_ad(:, k)
17634 logpl1_ad(:, k) = logpl1_ad(:, k) - dlogp1_ad(:, k)
17635 dlogp1_ad(:, k) = 0.0
17638 temp_ad0 = logpl2_ad(:, k)/(pe2(:, k)+pe2(:, k+1))
17639 pe2_ad(:, k) = pe2_ad(:, k) + temp_ad0
17640 pe2_ad(:, k+1) = pe2_ad(:, k+1) + temp_ad0
17641 logpl2_ad(:, k) = 0.0
17644 temp_ad = logpl1_ad(:, k)/(pe1(:, k)+pe1(:, k+1))
17645 pe1_ad(:, k) = pe1_ad(:, k) + temp_ad
17646 pe1_ad(:, k+1) = pe1_ad(:, k+1) + temp_ad
17647 logpl1_ad(:, k) = 0.0
17648 q2_ad(i1:i2, j, k) = q2_ad(i1:i2, j, k) + qx_ad(:, k)
17652 ELSE IF (branch .EQ. 2)
THEN 17654 logpl1_ad(:, k+1) = logpl1_ad(:, k+1) + dlogp1_ad(:, k)
17655 logpl1_ad(:, k) = logpl1_ad(:, k) - dlogp1_ad(:, k)
17656 dlogp1_ad(:, k) = 0.0
17659 temp_ad2 = logpl2_ad(:, k)/(pe2(:, k)+pe2(:, k+1))
17660 pe2_ad(:, k) = pe2_ad(:, k) + temp_ad2
17661 pe2_ad(:, k+1) = pe2_ad(:, k+1) + temp_ad2
17662 logpl2_ad(:, k) = 0.0
17665 temp_ad1 = logpl1_ad(:, k)/(pe1(:, k)+pe1(:, k+1))
17666 pe1_ad(:, k) = pe1_ad(:, k) + temp_ad1
17667 pe1_ad(:, k+1) = pe1_ad(:, k+1) + temp_ad1
17668 logpl1_ad(:, k) = 0.0
17669 q2_ad(i1:i2, j, k) = q2_ad(i1:i2, j, k) + qx_ad(:, k)
17674 logpl1_ad(:, k+1) = logpl1_ad(:, k+1) + dlogp1_ad(:, k)
17675 logpl1_ad(:, k) = logpl1_ad(:, k) - dlogp1_ad(:, k)
17676 dlogp1_ad(:, k) = 0.0
17679 temp0 =
r2*(pe2(:, k)+pe2(:, k+1))
17680 temp_ad4 = akap*exp(akap*log(temp0))*
r2*logpl2_ad(:, k)/temp0
17681 pe2_ad(:, k) = pe2_ad(:, k) + temp_ad4
17682 pe2_ad(:, k+1) = pe2_ad(:, k+1) + temp_ad4
17683 logpl2_ad(:, k) = 0.0
17686 temp =
r2*(pe1(:, k)+pe1(:, k+1))
17687 temp_ad3 = akap*exp(akap*log(temp))*
r2*logpl1_ad(:, k)/temp
17688 pe1_ad(:, k) = pe1_ad(:, k) + temp_ad3
17689 pe1_ad(:, k+1) = pe1_ad(:, k+1) + temp_ad3
17690 logpl1_ad(:, k) = 0.0
17691 q2_ad(i1:i2, j, k) = q2_ad(i1:i2, j, k) + qx_ad(:, k)
17701 SUBROUTINE map1_cubic(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend, &
17702 & jbeg, jend, akap, t_var, conserv)
17707 INTEGER,
INTENT(IN) :: i1
17709 INTEGER,
INTENT(IN) :: i2
17710 REAL,
INTENT(IN) :: akap
17712 INTEGER,
INTENT(IN) :: t_var
17714 LOGICAL,
INTENT(IN) :: conserv
17716 INTEGER,
INTENT(IN) :: j
17717 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
17719 INTEGER,
INTENT(IN) :: km
17721 INTEGER,
INTENT(IN) :: kn
17723 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
17727 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
17733 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
17751 REAL :: qx(i1:i2, km)
17752 REAL :: logpl1(i1:i2, km)
17753 REAL :: logpl2(i1:i2, kn)
17754 REAL :: dlogp1(i1:i2, km)
17755 REAL :: vsum1(i1:i2)
17756 REAL :: vsum2(i1:i2)
17757 REAL :: am2, am1, ap0, ap1, p, plp1, plp0, plm1, plm2, dlp0, dlm1, &
17759 INTEGER :: i, k, lm2, lm1, lp0, lp1
17766 SELECT CASE (t_var)
17770 qx(:, k) = q2(i1:i2, j, k)
17771 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
17774 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
17777 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17782 qx(:, k) = q2(i1:i2, j, k)
17783 logpl1(:, k) = log(
r2*(pe1(:, k)+pe1(:, k+1)))
17786 logpl2(:, k) = log(
r2*(pe2(:, k)+pe2(:, k+1)))
17789 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17794 qx(:, k) = q2(i1:i2, j, k)
17795 logpl1(:, k) = exp(akap*log(
r2*(pe1(:, k)+pe1(:, k+1))))
17798 logpl2(:, k) = exp(akap*log(
r2*(pe2(:, k)+pe2(:, k+1))))
17801 dlogp1(:, k) = logpl1(:, k+1) - logpl1(:, k)
17810 vsum1(i) = vsum1(i) + qx(i, k)*(pe1(i, k+1)-pe1(i, k))
17812 vsum1(i) = vsum1(i)/(pe1(i, km+1)-pe1(i, 1))
17821 DO WHILE (lp0 .LE. km)
17822 IF (logpl1(i, lp0) .LT. logpl2(i, k))
THEN 17828 100
IF (lp0 - 1 .LT. 1)
THEN 17833 IF (lp0 .GT. km)
THEN 17840 IF (lm1 .EQ. 1 .AND. lp0 .EQ. 1)
THEN 17841 q2(i, j, k) = qx(i, 1) + (qx(i, 2)-qx(i, 1))*(logpl2(i, k)-&
17842 & logpl1(i, 1))/(logpl1(i, 2)-logpl1(i, 1))
17845 ELSE IF (lm1 .EQ. km .AND. lp0 .EQ. km)
THEN 17846 q2(i, j, k) = qx(i, km) + (qx(i, km)-qx(i, km-1))*(logpl2(i, k&
17847 & )-logpl1(i, km))/(logpl1(i, km)-logpl1(i, km-1))
17850 ELSE IF (lm1 .EQ. 1 .OR. lp0 .EQ. km)
THEN 17851 q2(i, j, k) = qx(i, lp0) + (qx(i, lm1)-qx(i, lp0))*(logpl2(i, &
17852 & k)-logpl1(i, lp0))/(logpl1(i, lm1)-logpl1(i, lp0))
17859 plp1 = logpl1(i, lp1)
17860 plp0 = logpl1(i, lp0)
17861 plm1 = logpl1(i, lm1)
17862 plm2 = logpl1(i, lm2)
17863 dlp0 = dlogp1(i, lp0)
17864 dlm1 = dlogp1(i, lm1)
17865 dlm2 = dlogp1(i, lm2)
17866 ap1 = (p-plp0)*(p-plm1)*(p-plm2)/(dlp0*(dlp0+dlm1)*(dlp0+dlm1+&
17868 ap0 = (plp1-p)*(p-plm1)*(p-plm2)/(dlp0*dlm1*(dlm1+dlm2))
17869 am1 = (plp1-p)*(plp0-p)*(p-plm2)/(dlm1*dlm2*(dlp0+dlm1))
17870 am2 = (plp1-p)*(plp0-p)*(plm1-p)/(dlm2*(dlm1+dlm2)*(dlp0+dlm1+&
17872 q2(i, j, k) = ap1*qx(i, lp1) + ap0*qx(i, lp0) + am1*qx(i, lm1)&
17883 vsum2(i) = vsum2(i) + q2(i, j, k)*(pe2(i, k+1)-pe2(i, k))
17885 vsum2(i) = vsum2(i)/(pe2(i, kn+1)-pe2(i, 1))
17891 q2(i, j, k) = q2(i, j, k) + vsum1(i) - vsum2(i)
17919 SUBROUTINE map_scalar_fwd(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg&
17920 & , iend, jbeg, jend, iv, kord, q_min)
17924 INTEGER,
INTENT(IN) :: i1
17926 INTEGER,
INTENT(IN) :: i2
17928 INTEGER,
INTENT(IN) :: iv
17931 INTEGER,
INTENT(IN) :: kord
17933 INTEGER,
INTENT(IN) :: j
17934 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
17936 INTEGER,
INTENT(IN) :: km
17938 INTEGER,
INTENT(IN) :: kn
17940 REAL,
INTENT(IN) :: qs(i1:i2)
17942 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
17946 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
17952 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
17953 REAL,
INTENT(IN) :: q_min
17961 REAL :: dp1(i1:i2, km)
17962 REAL :: q4(4, i1:i2, km)
17963 REAL :: pl, pr, qsum, dp, esl
17964 INTEGER :: i, k, l, m, k0
17965 INTEGER :: ad_count
17966 INTEGER :: ad_count0
17985 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
17986 q4(1, i, k) = q2(i, j, k)
17990 IF (kord .GT. 7)
THEN 18006 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
18011 ad_count = ad_count + 1
18020 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18021 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 18023 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18025 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
18026 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
18033 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
18034 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
18040 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 18042 qsum = qsum + dp1(i, m)*q4(1, i, m)
18044 ad_count0 = ad_count0 + 1
18055 dp = pe2(i, k+1) - pe1(i, m)
18057 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
18058 & +q4(4, i, m)*(1.-
r23*esl)))
18063 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
18094 SUBROUTINE map_scalar_bwd(km, pe1, pe1_ad, qs, kn, pe2, pe2_ad, q2&
18095 & , q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
18097 INTEGER,
INTENT(IN) :: i1
18098 INTEGER,
INTENT(IN) :: i2
18099 INTEGER,
INTENT(IN) :: iv
18100 INTEGER,
INTENT(IN) :: kord
18101 INTEGER,
INTENT(IN) :: j
18102 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
18103 INTEGER,
INTENT(IN) :: km
18104 INTEGER,
INTENT(IN) :: kn
18105 REAL,
INTENT(IN) :: qs(i1:i2)
18106 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
18107 REAL :: pe1_ad(i1:i2, km+1)
18108 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
18109 REAL :: pe2_ad(i1:i2, kn+1)
18110 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
18111 REAL,
INTENT(INOUT) :: q2_ad(ibeg:iend, jbeg:jend, kn)
18112 REAL,
INTENT(IN) :: q_min
18113 REAL :: dp1(i1:i2, km)
18114 REAL :: dp1_ad(i1:i2, km)
18115 REAL :: q4(4, i1:i2, km)
18116 REAL :: q4_ad(4, i1:i2, km)
18117 REAL :: pl, pr, qsum, dp, esl
18118 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
18119 INTEGER :: i, k, l, m, k0
18136 INTEGER :: ad_count
18139 INTEGER :: ad_count0
18169 IF (branch .EQ. 0)
THEN 18170 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18171 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18173 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, j, k)
18174 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
18176 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, j, k))
18177 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, j, k) - temp_ad0
18178 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
18179 & **2)*q2_ad(i, j, k)
18180 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
18181 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
18182 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
18183 q2_ad(i, j, k) = 0.0
18184 temp_ad3 = pr_ad/dp1(i, l)
18185 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
18186 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
18187 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
18191 temp1 = pe2(i, k+1) - pe2(i, k)
18192 temp_ad11 = -(qsum*q2_ad(i, j, k)/temp1**2)
18193 qsum_ad = qsum_ad + q2_ad(i, j, k)/temp1
18194 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad11
18195 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad11
18196 q2_ad(i, j, k) = 0.0
18198 IF (branch .EQ. 0)
THEN 18199 dp = pe2(i, k+1) - pe1(i, m)
18201 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
18203 temp_ad8 = dp*qsum_ad
18204 temp_ad9 = 0.5*esl*temp_ad8
18205 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
18206 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
18207 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
18208 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
18209 temp_ad10 = esl_ad/dp1(i, m)
18210 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
18211 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
18212 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
18213 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
18214 ELSE IF (branch .NE. 1)
THEN 18219 IF (i3 .EQ. 1)
THEN 18222 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
18223 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
18227 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18229 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
18230 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
18231 & *(pl+1.)+1.)))*qsum_ad
18232 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
18233 temp_ad6 = 0.5*(pl+1.)*temp_ad5
18234 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
18235 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
18236 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
18237 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
18238 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
18240 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
18241 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
18244 temp_ad = pl_ad/dp1(i, l)
18245 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
18246 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
18247 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
18258 & dp1_ad, km, i1, i2, iv, kord&
18262 q2_ad(i, j, k) = q2_ad(i, j, k) + q4_ad(1, i, k)
18263 q4_ad(1, i, k) = 0.0
18264 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
18265 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
18291 SUBROUTINE map1_ppm_fwd(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, &
18292 & iend, jbeg, jend, iv, kord)
18295 INTEGER,
INTENT(IN) :: i1
18297 INTEGER,
INTENT(IN) :: i2
18299 INTEGER,
INTENT(IN) :: iv
18302 INTEGER,
INTENT(IN) :: kord
18304 INTEGER,
INTENT(IN) :: j
18305 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
18307 INTEGER,
INTENT(IN) :: km
18309 INTEGER,
INTENT(IN) :: kn
18311 REAL,
INTENT(IN) :: qs(i1:i2)
18313 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
18317 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
18323 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
18331 REAL :: dp1(i1:i2, km)
18332 REAL :: q4(4, i1:i2, km)
18333 REAL :: pl, pr, qsum, dp, esl
18334 INTEGER :: i, k, l, m, k0
18335 INTEGER :: ad_count
18336 INTEGER :: ad_count0
18355 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
18356 q4(1, i, k) = q2(i, j, k)
18360 IF (kord .GT. 7)
THEN 18375 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
18380 ad_count = ad_count + 1
18389 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18390 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 18392 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18394 q2(i, j, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2&
18395 & , i, l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
18402 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
18403 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
18409 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 18411 qsum = qsum + dp1(i, m)*q4(1, i, m)
18413 ad_count0 = ad_count0 + 1
18424 dp = pe2(i, k+1) - pe1(i, m)
18426 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
18427 & +q4(4, i, m)*(1.-
r23*esl)))
18432 q2(i, j, k) = qsum/(pe2(i, k+1)-pe2(i, k))
18462 SUBROUTINE map1_ppm_bwd(km, pe1, pe1_ad, qs, qs_ad, kn, pe2, pe2_ad&
18463 & , q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
18465 INTEGER,
INTENT(IN) :: i1
18466 INTEGER,
INTENT(IN) :: i2
18467 INTEGER,
INTENT(IN) :: iv
18468 INTEGER,
INTENT(IN) :: kord
18469 INTEGER,
INTENT(IN) :: j
18470 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
18471 INTEGER,
INTENT(IN) :: km
18472 INTEGER,
INTENT(IN) :: kn
18473 REAL,
INTENT(IN) :: qs(i1:i2)
18474 REAL :: qs_ad(i1:i2)
18475 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
18476 REAL :: pe1_ad(i1:i2, km+1)
18477 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
18478 REAL :: pe2_ad(i1:i2, kn+1)
18479 REAL,
INTENT(INOUT) :: q2(ibeg:iend, jbeg:jend, kn)
18480 REAL,
INTENT(INOUT) :: q2_ad(ibeg:iend, jbeg:jend, kn)
18481 REAL :: dp1(i1:i2, km)
18482 REAL :: dp1_ad(i1:i2, km)
18483 REAL :: q4(4, i1:i2, km)
18484 REAL :: q4_ad(4, i1:i2, km)
18485 REAL :: pl, pr, qsum, dp, esl
18486 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
18487 INTEGER :: i, k, l, m, k0
18504 INTEGER :: ad_count
18507 INTEGER :: ad_count0
18537 IF (branch .EQ. 0)
THEN 18538 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18539 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18541 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, j, k)
18542 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
18544 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, j, k))
18545 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, j, k) - temp_ad0
18546 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
18547 & **2)*q2_ad(i, j, k)
18548 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
18549 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
18550 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
18551 q2_ad(i, j, k) = 0.0
18552 temp_ad3 = pr_ad/dp1(i, l)
18553 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
18554 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
18555 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
18559 temp1 = pe2(i, k+1) - pe2(i, k)
18560 temp_ad11 = -(qsum*q2_ad(i, j, k)/temp1**2)
18561 qsum_ad = qsum_ad + q2_ad(i, j, k)/temp1
18562 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad11
18563 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad11
18564 q2_ad(i, j, k) = 0.0
18566 IF (branch .EQ. 0)
THEN 18567 dp = pe2(i, k+1) - pe1(i, m)
18569 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
18571 temp_ad8 = dp*qsum_ad
18572 temp_ad9 = 0.5*esl*temp_ad8
18573 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
18574 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
18575 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
18576 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
18577 temp_ad10 = esl_ad/dp1(i, m)
18578 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
18579 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
18580 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
18581 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
18582 ELSE IF (branch .NE. 1)
THEN 18587 IF (i3 .EQ. 1)
THEN 18590 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
18591 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
18595 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18597 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
18598 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
18599 & *(pl+1.)+1.)))*qsum_ad
18600 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
18601 temp_ad6 = 0.5*(pl+1.)*temp_ad5
18602 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
18603 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
18604 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
18605 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
18606 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
18608 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
18609 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
18612 temp_ad = pl_ad/dp1(i, l)
18613 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
18614 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
18615 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
18625 IF (branch .NE. 0)
CALL cs_profile_bwd(qs, qs_ad, q4, q4_ad, dp1&
18626 & , dp1_ad, km, i1, i2, iv, kord)
18629 q2_ad(i, j, k) = q2_ad(i, j, k) + q4_ad(1, i, k)
18630 q4_ad(1, i, k) = 0.0
18631 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
18632 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
18658 & i2, isd, ied, jsd, jed, q_min, fill)
18662 INTEGER,
INTENT(IN) :: km
18663 INTEGER,
INTENT(IN) :: j, nq, i1, i2
18664 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
18665 INTEGER,
INTENT(IN) :: kord(nq)
18667 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
18671 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
18674 REAL,
INTENT(IN) :: dp2(i1:i2, km)
18675 REAL,
INTENT(IN) :: q_min
18676 LOGICAL,
INTENT(IN) :: fill
18678 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
18680 REAL :: q4(4, i1:i2, km, nq)
18682 REAL :: q2(i1:i2, km, nq)
18684 REAL :: dp1(i1:i2, km)
18686 REAL :: pl, pr, dp, esl, fac1, fac2
18687 INTEGER :: i, k, l, m, k0, iq
18689 INTEGER :: ad_count
18690 INTEGER :: ad_count0
18715 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
18721 q4(1, i, k, iq) = q1(i, j, k, iq)
18725 & i1, i2, 0, kord(iq), q_min)
18735 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
18740 ad_count = ad_count + 1
18749 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18750 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 18752 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18756 fac2 =
r3*(pr*fac1+pl*pl)
18760 q2(i, k, iq) = q4(2, i, l, iq) + (q4(4, i, l, iq)+q4(3, i, l&
18761 & , iq)-q4(2, i, l, iq))*fac1 - q4(4, i, l, iq)*fac2
18769 dp = pe1(i, l+1) - pe2(i, k)
18773 fac2 =
r3*(1.+pl*fac1)
18778 qsum(iq) = dp*(q4(2, i, l, iq)+(q4(4, i, l, iq)+q4(3, i, l, &
18779 & iq)-q4(2, i, l, iq))*fac1-q4(4, i, l, iq)*fac2)
18785 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 18789 qsum(iq) = qsum(iq) + dp1(i, m)*q4(1, i, m, iq)
18792 ad_count0 = ad_count0 + 1
18804 dp = pe2(i, k+1) - pe1(i, m)
18809 fac2 = 1. -
r23*esl
18812 qsum(iq) = qsum(iq) + dp*(q4(2, i, m, iq)+fac1*(q4(3, i, m, &
18813 & iq)-q4(2, i, m, iq)+q4(4, i, m, iq)*fac2))
18819 q2(i, k, iq) = qsum(iq)/dp2(i, k)
18829 q1(i, j, k, iq) = q2(i, k, iq)
18864 & q1_ad, dp2, dp2_ad, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill&
18867 INTEGER,
INTENT(IN) :: km
18868 INTEGER,
INTENT(IN) :: j, nq, i1, i2
18869 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
18870 INTEGER,
INTENT(IN) :: kord(nq)
18871 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
18872 REAL :: pe1_ad(i1:i2, km+1)
18873 REAL,
INTENT(IN) :: pe2(i1:i2, km+1)
18874 REAL :: pe2_ad(i1:i2, km+1)
18875 REAL,
INTENT(IN) :: dp2(i1:i2, km)
18876 REAL :: dp2_ad(i1:i2, km)
18877 REAL,
INTENT(IN) :: q_min
18878 LOGICAL,
INTENT(IN) :: fill
18879 REAL,
INTENT(INOUT) :: q1(isd:ied, jsd:jed, km, nq)
18880 REAL,
INTENT(INOUT) :: q1_ad(isd:ied, jsd:jed, km, nq)
18881 REAL :: q4(4, i1:i2, km, nq)
18882 REAL :: q4_ad(4, i1:i2, km, nq)
18883 REAL :: q2(i1:i2, km, nq)
18884 REAL :: q2_ad(i1:i2, km, nq)
18886 REAL :: qsum_ad(nq)
18887 REAL :: dp1(i1:i2, km)
18888 REAL :: dp1_ad(i1:i2, km)
18890 REAL :: pl, pr, dp, esl, fac1, fac2
18891 REAL :: pl_ad, pr_ad, dp_ad, esl_ad, fac1_ad, fac2_ad
18892 INTEGER :: i, k, l, m, k0, iq
18906 INTEGER :: ad_count
18909 INTEGER :: ad_count0
18948 q2_ad(i, k, iq) = q2_ad(i, k, iq) + q1_ad(i, j, k, iq)
18949 q1_ad(i, j, k, iq) = 0.0
18959 IF (branch .EQ. 0)
THEN 18963 temp_ad2 = fac1*q2_ad(i, k, iq)
18964 q4_ad(2, i, l, iq) = q4_ad(2, i, l, iq) + q2_ad(i, k, iq) - &
18966 q4_ad(4, i, l, iq) = q4_ad(4, i, l, iq) + temp_ad2 - fac2*&
18968 q4_ad(3, i, l, iq) = q4_ad(3, i, l, iq) + temp_ad2
18969 fac1_ad = fac1_ad + (q4(4, i, l, iq)+q4(3, i, l, iq)-q4(2, i&
18970 & , l, iq))*q2_ad(i, k, iq)
18971 fac2_ad = fac2_ad - q4(4, i, l, iq)*q2_ad(i, k, iq)
18972 q2_ad(i, k, iq) = 0.0
18974 temp_ad0 =
r3*fac2_ad
18975 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
18976 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
18978 fac1_ad = pr*temp_ad0 + 0.5*fac1_ad
18980 pr_ad = fac1_ad + fac1*temp_ad0
18981 pl_ad = fac1_ad + 2*pl*temp_ad0
18983 temp_ad1 = pr_ad/dp1(i, l)
18984 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad1
18985 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad1
18986 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad1&
18990 temp_ad8 = q2_ad(i, k, iq)/dp2(i, k)
18991 qsum_ad(iq) = qsum_ad(iq) + temp_ad8
18992 dp2_ad(i, k) = dp2_ad(i, k) - qsum(iq)*temp_ad8/dp2(i, k)
18993 q2_ad(i, k, iq) = 0.0
18996 IF (branch .EQ. 0)
THEN 18997 dp = pe2(i, k+1) - pe1(i, m)
19000 fac2 = 1. -
r23*esl
19006 temp0 = q4(3, i, m, iq) - q4(2, i, m, iq) + q4(4, i, m, iq&
19008 temp_ad6 = dp*qsum_ad(iq)
19009 temp_ad7 = fac1*temp_ad6
19010 dp_ad = dp_ad + (q4(2, i, m, iq)+fac1*temp0)*qsum_ad(iq)
19011 q4_ad(2, i, m, iq) = q4_ad(2, i, m, iq) + temp_ad6 - &
19013 fac1_ad = fac1_ad + temp0*temp_ad6
19014 q4_ad(3, i, m, iq) = q4_ad(3, i, m, iq) + temp_ad7
19015 q4_ad(4, i, m, iq) = q4_ad(4, i, m, iq) + fac2*temp_ad7
19016 fac2_ad = fac2_ad + q4(4, i, m, iq)*temp_ad7
19019 esl_ad = 0.5*fac1_ad -
r23*fac2_ad
19021 temp_ad5 = esl_ad/dp1(i, m)
19022 dp_ad = dp_ad + temp_ad5
19023 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad5/dp1(i, m)
19025 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
19026 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
19027 ELSE IF (branch .NE. 1)
THEN 19032 IF (i3 .EQ. 1)
THEN 19037 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m, iq)*qsum_ad(iq&
19039 q4_ad(1, i, m, iq) = q4_ad(1, i, m, iq) + dp1(i, m)*&
19050 temp = q4(4, i, l, iq) + q4(3, i, l, iq) - q4(2, i, l, iq)
19051 temp_ad3 = dp*qsum_ad(iq)
19052 temp_ad4 = fac1*temp_ad3
19053 dp_ad = dp_ad + (q4(2, i, l, iq)+temp*fac1-q4(4, i, l, iq)*&
19054 & fac2)*qsum_ad(iq)
19055 q4_ad(2, i, l, iq) = q4_ad(2, i, l, iq) + temp_ad3 - &
19057 q4_ad(4, i, l, iq) = q4_ad(4, i, l, iq) + temp_ad4 - fac2*&
19059 q4_ad(3, i, l, iq) = q4_ad(3, i, l, iq) + temp_ad4
19060 fac1_ad = fac1_ad + temp*temp_ad3
19061 fac2_ad = fac2_ad - q4(4, i, l, iq)*temp_ad3
19064 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
19066 fac1_ad =
r3*pl*fac2_ad + 0.5*fac1_ad
19068 pl_ad = fac1_ad +
r3*fac1*fac2_ad
19071 pe1_ad(i, l+1) = pe1_ad(i, l+1) + dp_ad
19072 pe2_ad(i, k) = pe2_ad(i, k) - dp_ad
19074 temp_ad = pl_ad/dp1(i, l)
19075 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
19076 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
19077 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
19088 & , i1:i2, 1:km, iq), dp1, dp1_ad, km, i1, i2, &
19089 & 0, kord(iq), q_min)
19092 q1_ad(i, j, k, iq) = q1_ad(i, j, k, iq) + q4_ad(1, i, k, iq)
19093 q4_ad(1, i, k, iq) = 0.0
19099 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
19100 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
19125 SUBROUTINE map1_q2_fwd(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, &
19126 & kord, j, ibeg, iend, jbeg, jend, q_min)
19129 INTEGER,
INTENT(IN) :: j
19130 INTEGER,
INTENT(IN) :: i1, i2
19131 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
19133 INTEGER,
INTENT(IN) :: iv
19134 INTEGER,
INTENT(IN) :: kord
19136 INTEGER,
INTENT(IN) :: km
19138 INTEGER,
INTENT(IN) :: kn
19140 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
19144 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
19148 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
19149 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
19150 REAL,
INTENT(IN) :: q_min
19153 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
19156 REAL :: dp1(i1:i2, km)
19157 REAL :: q4(4, i1:i2, km)
19158 REAL :: pl, pr, qsum, dp, esl
19159 INTEGER :: i, k, l, m, k0
19160 INTEGER :: ad_count
19161 INTEGER :: ad_count0
19181 dp1(i, k) = pe1(i, k+1) - pe1(i, k)
19182 q4(1, i, k) = q1(i, j, k)
19186 IF (kord .GT. 7)
THEN 19203 IF (pe2(i, k) .GE. pe1(i, l) .AND. pe2(i, k) .LE. pe1(i, l+1)&
19208 ad_count = ad_count + 1
19217 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
19218 IF (pe2(i, k+1) .LE. pe1(i, l+1))
THEN 19220 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
19221 q2(i, k) = q4(2, i, l) + 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i&
19222 & , l))*(pr+pl) - q4(4, i, l)*
r3*(pr*(pr+pl)+pl**2)
19229 qsum = (pe1(i, l+1)-pe2(i, k))*(q4(2, i, l)+0.5*(q4(4, i, l)+&
19230 & q4(3, i, l)-q4(2, i, l))*(1.+pl)-q4(4, i, l)*(
r3*(1.+pl*(1.+&
19236 IF (pe2(i, k+1) .GT. pe1(i, m+1))
THEN 19238 qsum = qsum + dp1(i, m)*q4(1, i, m)
19240 ad_count0 = ad_count0 + 1
19251 dp = pe2(i, k+1) - pe1(i, m)
19253 qsum = qsum + dp*(q4(2, i, m)+0.5*esl*(q4(3, i, m)-q4(2, i, m)&
19254 & +q4(4, i, m)*(1.-
r23*esl)))
19258 123 q2(i, k) = qsum/dp2(i, k)
19289 SUBROUTINE map1_q2_bwd(km, pe1, pe1_ad, q1, q1_ad, kn, pe2, pe2_ad&
19290 & , q2, q2_ad, dp2, dp2_ad, i1, i2, iv, kord, j, ibeg, iend, jbeg, &
19293 INTEGER,
INTENT(IN) :: j
19294 INTEGER,
INTENT(IN) :: i1, i2
19295 INTEGER,
INTENT(IN) :: ibeg, iend, jbeg, jend
19296 INTEGER,
INTENT(IN) :: iv
19297 INTEGER,
INTENT(IN) :: kord
19298 INTEGER,
INTENT(IN) :: km
19299 INTEGER,
INTENT(IN) :: kn
19300 REAL,
INTENT(IN) :: pe1(i1:i2, km+1)
19301 REAL :: pe1_ad(i1:i2, km+1)
19302 REAL,
INTENT(IN) :: pe2(i1:i2, kn+1)
19303 REAL :: pe2_ad(i1:i2, kn+1)
19304 REAL,
INTENT(IN) :: q1(ibeg:iend, jbeg:jend, km)
19305 REAL :: q1_ad(ibeg:iend, jbeg:jend, km)
19306 REAL,
INTENT(IN) :: dp2(i1:i2, kn)
19307 REAL :: dp2_ad(i1:i2, kn)
19308 REAL,
INTENT(IN) :: q_min
19309 REAL,
INTENT(INOUT) :: q2(i1:i2, kn)
19310 REAL,
INTENT(INOUT) :: q2_ad(i1:i2, kn)
19312 REAL :: dp1(i1:i2, km)
19313 REAL :: dp1_ad(i1:i2, km)
19314 REAL :: q4(4, i1:i2, km)
19315 REAL :: q4_ad(4, i1:i2, km)
19316 REAL :: pl, pr, qsum, dp, esl
19317 REAL :: pl_ad, pr_ad, qsum_ad, dp_ad, esl_ad
19318 INTEGER :: i, k, l, m, k0
19334 INTEGER :: ad_count
19337 INTEGER :: ad_count0
19369 IF (branch .EQ. 0)
THEN 19370 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
19371 pr = (pe2(i, k+1)-pe1(i, l))/dp1(i, l)
19372 temp_ad0 = 0.5*(pr+pl)*q2_ad(i, k)
19373 temp_ad1 = 0.5*(q4(4, i, l)+q4(3, i, l)-q4(2, i, l))*q2_ad(i, &
19375 temp_ad2 = -(
r3*q4(4, i, l)*q2_ad(i, k))
19376 q4_ad(2, i, l) = q4_ad(2, i, l) + q2_ad(i, k) - temp_ad0
19377 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad0 -
r3*(pr*(pr+pl)+pl&
19379 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad0
19380 pr_ad = (2*pr+pl)*temp_ad2 + temp_ad1
19381 pl_ad = (2*pl+pr)*temp_ad2 + temp_ad1
19383 temp_ad3 = pr_ad/dp1(i, l)
19384 pe2_ad(i, k+1) = pe2_ad(i, k+1) + temp_ad3
19385 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad3
19386 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k+1)-pe1(i, l))*temp_ad3&
19389 temp_ad11 = q2_ad(i, k)/dp2(i, k)
19390 qsum_ad = qsum_ad + temp_ad11
19391 dp2_ad(i, k) = dp2_ad(i, k) - qsum*temp_ad11/dp2(i, k)
19394 IF (branch .EQ. 0)
THEN 19395 dp = pe2(i, k+1) - pe1(i, m)
19397 temp0 = q4(3, i, m) - q4(2, i, m) + q4(4, i, m)*(-(
r23*esl)+&
19399 temp_ad8 = dp*qsum_ad
19400 temp_ad9 = 0.5*esl*temp_ad8
19401 q4_ad(2, i, m) = q4_ad(2, i, m) + temp_ad8 - temp_ad9
19402 esl_ad = 0.5*temp0*temp_ad8 - q4(4, i, m)*
r23*temp_ad9
19403 q4_ad(3, i, m) = q4_ad(3, i, m) + temp_ad9
19404 q4_ad(4, i, m) = q4_ad(4, i, m) + (1.-
r23*esl)*temp_ad9
19405 temp_ad10 = esl_ad/dp1(i, m)
19406 dp_ad = temp_ad10 + (q4(2, i, m)+0.5*(esl*temp0))*qsum_ad
19407 dp1_ad(i, m) = dp1_ad(i, m) - dp*temp_ad10/dp1(i, m)
19408 pe2_ad(i, k+1) = pe2_ad(i, k+1) + dp_ad
19409 pe1_ad(i, m) = pe1_ad(i, m) - dp_ad
19410 ELSE IF (branch .NE. 1)
THEN 19415 IF (i3 .EQ. 1)
THEN 19418 dp1_ad(i, m) = dp1_ad(i, m) + q4(1, i, m)*qsum_ad
19419 q4_ad(1, i, m) = q4_ad(1, i, m) + dp1(i, m)*qsum_ad
19423 pl = (pe2(i, k)-pe1(i, l))/dp1(i, l)
19425 temp = q4(4, i, l) + q4(3, i, l) - q4(2, i, l)
19426 temp_ad4 = (q4(2, i, l)+0.5*(temp*(pl+1.))-
r3*(q4(4, i, l)*(pl&
19427 & *(pl+1.)+1.)))*qsum_ad
19428 temp_ad5 = (pe1(i, l+1)-pe2(i, k))*qsum_ad
19429 temp_ad6 = 0.5*(pl+1.)*temp_ad5
19430 temp_ad7 = -(
r3*q4(4, i, l)*temp_ad5)
19431 pe1_ad(i, l+1) = pe1_ad(i, l+1) + temp_ad4
19432 pe2_ad(i, k) = pe2_ad(i, k) - temp_ad4
19433 q4_ad(2, i, l) = q4_ad(2, i, l) + temp_ad5 - temp_ad6
19434 q4_ad(4, i, l) = q4_ad(4, i, l) + temp_ad6 -
r3*(pl*(pl+1.)+1.&
19436 q4_ad(3, i, l) = q4_ad(3, i, l) + temp_ad6
19437 pl_ad = (2*pl+1.)*temp_ad7 + 0.5*temp*temp_ad5
19440 temp_ad = pl_ad/dp1(i, l)
19441 pe2_ad(i, k) = pe2_ad(i, k) + temp_ad
19442 pe1_ad(i, l) = pe1_ad(i, l) - temp_ad
19443 dp1_ad(i, l) = dp1_ad(i, l) - (pe2(i, k)-pe1(i, l))*temp_ad/dp1(&
19454 & dp1_ad, km, i1, i2, iv, kord&
19458 q1_ad(i, j, k) = q1_ad(i, j, k) + q4_ad(1, i, k)
19459 q4_ad(1, i, k) = 0.0
19460 pe1_ad(i, k+1) = pe1_ad(i, k+1) + dp1_ad(i, k)
19461 pe1_ad(i, k) = pe1_ad(i, k) - dp1_ad(i, k)
19491 INTEGER,
INTENT(IN) :: i1, i2
19493 INTEGER,
INTENT(IN) :: km
19495 INTEGER,
INTENT(IN) :: iv
19498 INTEGER,
INTENT(IN) :: kord
19499 REAL,
INTENT(IN) :: qs(i1:i2)
19501 REAL,
INTENT(IN) :: delp(i1:i2, km)
19503 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
19504 REAL,
INTENT(IN) :: qmin
19506 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
19507 REAL :: gam(i1:i2, km)
19508 REAL :: q(i1:i2, km+1)
19510 REAL :: bet, a_bot, grat
19511 REAL :: pmp_1, lac_1, pmp_2, lac_2
19512 INTEGER :: i, k, im
19531 IF (iv .EQ. -2)
THEN 19534 q(i, 1) = 1.5*a4(1, i, 1)
19538 grat = delp(i, k-1)/delp(i, k)
19540 bet = 2. + grat + grat - gam(i, k)
19542 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
19543 gam(i, k+1) = grat/bet
19547 grat = delp(i, km-1)/delp(i, km)
19549 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
19550 & 1))/(2.+grat+grat-gam(i, km))
19557 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
19564 grat = delp(i, 2)/delp(i, 1)
19565 bet = grat*(grat+0.5)
19566 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
19567 gam(i, 1) = (1.+grat*(grat+1.5))/bet
19572 d4(i) = delp(i, k-1)/delp(i, k)
19574 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
19576 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
19577 gam(i, k) = d4(i)/bet
19581 a_bot = 1. + d4(i)*(d4(i)+1.5)
19583 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
19584 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
19589 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
19594 IF (kord .GE. 0.)
THEN 19600 IF (abs0 .GT. 16)
THEN 19604 a4(2, i, k) = q(i, k)
19606 a4(3, i, k) = q(i, k+1)
19608 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
19645 & , i2, iv, kord, qmin)
19647 INTEGER,
INTENT(IN) :: i1, i2
19648 INTEGER,
INTENT(IN) :: km
19649 INTEGER,
INTENT(IN) :: iv
19650 INTEGER,
INTENT(IN) :: kord
19651 REAL,
INTENT(IN) :: qs(i1:i2)
19652 REAL,
INTENT(IN) :: delp(i1:i2, km)
19653 REAL :: delp_ad(i1:i2, km)
19654 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
19655 REAL,
INTENT(INOUT) :: a4_ad(4, i1:i2, km)
19656 REAL,
INTENT(IN) :: qmin
19657 LOGICAL,
DIMENSION(i1:i2, km) :: extm, ext6
19658 REAL :: gam(i1:i2, km)
19659 REAL :: gam_ad(i1:i2, km)
19660 REAL :: q(i1:i2, km+1)
19661 REAL :: q_ad(i1:i2, km+1)
19663 REAL :: d4_ad(i1:i2)
19664 REAL :: bet, a_bot, grat
19665 REAL :: bet_ad, a_bot_ad, grat_ad
19666 REAL :: pmp_1, lac_1, pmp_2, lac_2
19667 INTEGER :: i, k, im
19709 IF (branch .EQ. 0)
THEN 19724 temp_ad14 = 3.*a4_ad(4, i, k)
19725 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad14
19726 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad14
19727 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad14
19728 a4_ad(4, i, k) = 0.0
19730 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
19731 a4_ad(3, i, k) = 0.0
19733 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
19734 a4_ad(2, i, k) = 0.0
19739 IF (branch .EQ. 0)
THEN 19744 gam_ad(i, k) = gam_ad(i, k) - q(i, k+1)*q_ad(i, k)
19745 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k)*q_ad(i, k)
19750 a_bot = 1. + d4(i)*(d4(i)+1.5)
19752 temp2 = d4(i)*(d4(i)+0.5) - a_bot*gam(i, km)
19753 temp_ad11 = q_ad(i, km+1)/temp2
19754 temp1 = d4(i)*(d4(i)+1.)
19755 temp_ad12 = 2.*a4(1, i, km)*temp_ad11
19756 temp_ad13 = -((2.*(temp1*a4(1, i, km))+a4(1, i, km-1)-a_bot*q(i&
19757 & , km))*temp_ad11/temp2)
19758 a4_ad(1, i, km) = a4_ad(1, i, km) + 2.*temp1*temp_ad11
19759 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + temp_ad11
19760 a_bot_ad = -(gam(i, km)*temp_ad13) - q(i, km)*temp_ad11
19761 d4_ad(i) = d4_ad(i) + (2*d4(i)+1.5)*a_bot_ad + (2*d4(i)+0.5)*&
19762 & temp_ad13 + (2*d4(i)+1.)*temp_ad12
19763 q_ad(i, km) = q_ad(i, km) - a_bot*temp_ad11
19764 gam_ad(i, km) = gam_ad(i, km) - a_bot*temp_ad13
19765 q_ad(i, km+1) = 0.0
19769 temp_ad9 = q_ad(i, k)/bet
19770 temp_ad8 = 3.*temp_ad9
19772 bet_ad = -((3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))*&
19773 & temp_ad9/bet) - d4(i)*gam_ad(i, k)/bet**2
19774 d4_ad(i) = d4_ad(i) + a4(1, i, k)*temp_ad8 + 2*bet_ad + gam_ad&
19777 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + temp_ad8
19778 a4_ad(1, i, k) = a4_ad(1, i, k) + d4(i)*temp_ad8
19779 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad9
19782 gam_ad(i, k-1) = gam_ad(i, k-1) - bet_ad
19784 temp_ad10 = d4_ad(i)/delp(i, k)
19785 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad10
19786 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad10/delp(i&
19792 grat = delp(i, 2)/delp(i, 1)
19793 bet = grat*(grat+0.5)
19794 temp_ad4 = gam_ad(i, 1)/bet
19796 temp_ad6 = q_ad(i, 1)/bet
19797 temp_ad5 = a4(1, i, 1)*temp_ad6
19798 temp0 = 2*grat*(grat+1.)
19799 bet_ad = -((temp0*a4(1, i, 1)+a4(1, i, 2))*temp_ad6/bet) - (grat&
19800 & *(grat+1.5)+1.)*temp_ad4/bet
19801 grat_ad = (4*grat+2*1.)*temp_ad5 + (2*grat+0.5)*bet_ad + (2*grat&
19803 a4_ad(1, i, 1) = a4_ad(1, i, 1) + temp0*temp_ad6
19804 a4_ad(1, i, 2) = a4_ad(1, i, 2) + temp_ad6
19806 temp_ad7 = grat_ad/delp(i, 1)
19807 delp_ad(i, 2) = delp_ad(i, 2) + temp_ad7
19808 delp_ad(i, 1) = delp_ad(i, 1) - delp(i, 2)*temp_ad7/delp(i, 1)
19815 gam_ad(i, k+1) = gam_ad(i, k+1) - q(i, k+1)*q_ad(i, k)
19816 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k+1)*q_ad(i, k)
19821 q_ad(i, km+1) = 0.0
19822 grat = delp(i, km-1)/delp(i, km)
19824 temp = 2*grat - gam(i, km) + 2.
19825 temp_ad1 = q_ad(i, km)/temp
19826 temp_ad2 = -((3.*(a4(1, i, km-1)+a4(1, i, km))-qs(i)*grat-q(i, &
19827 & km-1))*temp_ad1/temp)
19828 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + 3.*temp_ad1
19829 a4_ad(1, i, km) = a4_ad(1, i, km) + 3.*temp_ad1
19830 grat_ad = 2*temp_ad2 - qs(i)*temp_ad1
19831 q_ad(i, km-1) = q_ad(i, km-1) - temp_ad1
19832 gam_ad(i, km) = gam_ad(i, km) - temp_ad2
19834 temp_ad3 = grat_ad/delp(i, km)
19835 delp_ad(i, km-1) = delp_ad(i, km-1) + temp_ad3
19836 delp_ad(i, km) = delp_ad(i, km) - delp(i, km-1)*temp_ad3/delp(i&
19841 temp_ad = q_ad(i, k)/bet
19843 grat = delp(i, k-1)/delp(i, k)
19844 bet_ad = -((3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*temp_ad/&
19845 & bet) - grat*gam_ad(i, k+1)/bet**2
19846 grat_ad = 2*bet_ad + gam_ad(i, k+1)/bet
19847 gam_ad(i, k+1) = 0.0
19848 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + 3.*temp_ad
19849 a4_ad(1, i, k) = a4_ad(1, i, k) + 3.*temp_ad
19850 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad
19853 gam_ad(i, k) = gam_ad(i, k) - bet_ad
19854 temp_ad0 = grat_ad/delp(i, k)
19855 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad0
19856 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad0/delp(i, &
19861 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 1.5*q_ad(i, 1)
19891 INTEGER,
INTENT(IN) :: i1, i2
19893 INTEGER,
INTENT(IN) :: km
19895 INTEGER,
INTENT(IN) :: iv
19898 INTEGER,
INTENT(IN) :: kord
19899 REAL,
INTENT(IN) :: qs(i1:i2)
19901 REAL,
INTENT(IN) :: delp(i1:i2, km)
19903 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
19905 LOGICAL :: extm(i1:i2, km)
19906 REAL :: gam(i1:i2, km)
19907 REAL :: q(i1:i2, km+1)
19909 REAL :: bet, a_bot, grat
19910 REAL :: pmp_1, lac_1, pmp_2, lac_2
19911 INTEGER :: i, k, im
19930 IF (iv .EQ. -2)
THEN 19933 q(i, 1) = 1.5*a4(1, i, 1)
19937 grat = delp(i, k-1)/delp(i, k)
19939 bet = 2. + grat + grat - gam(i, k)
19941 q(i, k) = (3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))/bet
19942 gam(i, k+1) = grat/bet
19946 grat = delp(i, km-1)/delp(i, km)
19948 q(i, km) = (3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, km-&
19949 & 1))/(2.+grat+grat-gam(i, km))
19956 q(i, k) = q(i, k) - gam(i, k+1)*q(i, k+1)
19963 grat = delp(i, 2)/delp(i, 1)
19964 bet = grat*(grat+0.5)
19965 q(i, 1) = ((grat+grat)*(grat+1.)*a4(1, i, 1)+a4(1, i, 2))/bet
19966 gam(i, 1) = (1.+grat*(grat+1.5))/bet
19971 d4(i) = delp(i, k-1)/delp(i, k)
19973 bet = 2. + d4(i) + d4(i) - gam(i, k-1)
19975 q(i, k) = (3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))/bet
19976 gam(i, k) = d4(i)/bet
19980 a_bot = 1. + d4(i)*(d4(i)+1.5)
19982 q(i, km+1) = (2.*d4(i)*(d4(i)+1.)*a4(1, i, km)+a4(1, i, km-1)-&
19983 & a_bot*q(i, km))/(d4(i)*(d4(i)+0.5)-a_bot*gam(i, km))
19988 q(i, k) = q(i, k) - gam(i, k)*q(i, k+1)
19993 IF (kord .GE. 0.)
THEN 19999 IF (abs0 .GT. 16)
THEN 20003 a4(2, i, k) = q(i, k)
20005 a4(3, i, k) = q(i, k+1)
20007 a4(4, i, k) = 3.*(2.*a4(1, i, k)-(a4(2, i, k)+a4(3, i, k)))
20043 SUBROUTINE cs_profile_bwd(qs, qs_ad, a4, a4_ad, delp, delp_ad, km, &
20044 & i1, i2, iv, kord)
20047 INTEGER,
INTENT(IN) :: i1, i2
20048 INTEGER,
INTENT(IN) :: km
20049 INTEGER,
INTENT(IN) :: iv
20050 INTEGER,
INTENT(IN) :: kord
20051 REAL,
INTENT(IN) :: qs(i1:i2)
20052 REAL :: qs_ad(i1:i2)
20053 REAL,
INTENT(IN) :: delp(i1:i2, km)
20054 REAL :: delp_ad(i1:i2, km)
20055 REAL,
INTENT(INOUT) :: a4(4, i1:i2, km)
20056 REAL,
INTENT(INOUT) :: a4_ad(4, i1:i2, km)
20057 LOGICAL :: extm(i1:i2, km)
20058 REAL :: gam(i1:i2, km)
20059 REAL :: gam_ad(i1:i2, km)
20060 REAL :: q(i1:i2, km+1)
20061 REAL :: q_ad(i1:i2, km+1)
20063 REAL :: d4_ad(i1:i2)
20064 REAL :: bet, a_bot, grat
20065 REAL :: bet_ad, a_bot_ad, grat_ad
20066 REAL :: pmp_1, lac_1, pmp_2, lac_2
20067 INTEGER :: i, k, im
20109 IF (branch .EQ. 0)
THEN 20124 temp_ad14 = 3.*a4_ad(4, i, k)
20125 a4_ad(1, i, k) = a4_ad(1, i, k) + 2.*temp_ad14
20126 a4_ad(2, i, k) = a4_ad(2, i, k) - temp_ad14
20127 a4_ad(3, i, k) = a4_ad(3, i, k) - temp_ad14
20128 a4_ad(4, i, k) = 0.0
20130 q_ad(i, k+1) = q_ad(i, k+1) + a4_ad(3, i, k)
20131 a4_ad(3, i, k) = 0.0
20133 q_ad(i, k) = q_ad(i, k) + a4_ad(2, i, k)
20134 a4_ad(2, i, k) = 0.0
20139 IF (branch .EQ. 0)
THEN 20144 gam_ad(i, k) = gam_ad(i, k) - q(i, k+1)*q_ad(i, k)
20145 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k)*q_ad(i, k)
20150 a_bot = 1. + d4(i)*(d4(i)+1.5)
20152 temp2 = d4(i)*(d4(i)+0.5) - a_bot*gam(i, km)
20153 temp_ad11 = q_ad(i, km+1)/temp2
20154 temp1 = d4(i)*(d4(i)+1.)
20155 temp_ad12 = 2.*a4(1, i, km)*temp_ad11
20156 temp_ad13 = -((2.*(temp1*a4(1, i, km))+a4(1, i, km-1)-a_bot*q(i&
20157 & , km))*temp_ad11/temp2)
20158 a4_ad(1, i, km) = a4_ad(1, i, km) + 2.*temp1*temp_ad11
20159 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + temp_ad11
20160 a_bot_ad = -(gam(i, km)*temp_ad13) - q(i, km)*temp_ad11
20161 d4_ad(i) = d4_ad(i) + (2*d4(i)+1.5)*a_bot_ad + (2*d4(i)+0.5)*&
20162 & temp_ad13 + (2*d4(i)+1.)*temp_ad12
20163 q_ad(i, km) = q_ad(i, km) - a_bot*temp_ad11
20164 gam_ad(i, km) = gam_ad(i, km) - a_bot*temp_ad13
20165 q_ad(i, km+1) = 0.0
20169 temp_ad9 = q_ad(i, k)/bet
20170 temp_ad8 = 3.*temp_ad9
20172 bet_ad = -((3.*(a4(1, i, k-1)+d4(i)*a4(1, i, k))-q(i, k-1))*&
20173 & temp_ad9/bet) - d4(i)*gam_ad(i, k)/bet**2
20174 d4_ad(i) = d4_ad(i) + a4(1, i, k)*temp_ad8 + 2*bet_ad + gam_ad&
20177 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + temp_ad8
20178 a4_ad(1, i, k) = a4_ad(1, i, k) + d4(i)*temp_ad8
20179 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad9
20182 gam_ad(i, k-1) = gam_ad(i, k-1) - bet_ad
20184 temp_ad10 = d4_ad(i)/delp(i, k)
20185 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad10
20186 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad10/delp(i&
20192 grat = delp(i, 2)/delp(i, 1)
20193 bet = grat*(grat+0.5)
20194 temp_ad4 = gam_ad(i, 1)/bet
20196 temp_ad6 = q_ad(i, 1)/bet
20197 temp_ad5 = a4(1, i, 1)*temp_ad6
20198 temp0 = 2*grat*(grat+1.)
20199 bet_ad = -((temp0*a4(1, i, 1)+a4(1, i, 2))*temp_ad6/bet) - (grat&
20200 & *(grat+1.5)+1.)*temp_ad4/bet
20201 grat_ad = (4*grat+2*1.)*temp_ad5 + (2*grat+0.5)*bet_ad + (2*grat&
20203 a4_ad(1, i, 1) = a4_ad(1, i, 1) + temp0*temp_ad6
20204 a4_ad(1, i, 2) = a4_ad(1, i, 2) + temp_ad6
20206 temp_ad7 = grat_ad/delp(i, 1)
20207 delp_ad(i, 2) = delp_ad(i, 2) + temp_ad7
20208 delp_ad(i, 1) = delp_ad(i, 1) - delp(i, 2)*temp_ad7/delp(i, 1)
20215 gam_ad(i, k+1) = gam_ad(i, k+1) - q(i, k+1)*q_ad(i, k)
20216 q_ad(i, k+1) = q_ad(i, k+1) - gam(i, k+1)*q_ad(i, k)
20221 qs_ad(i) = qs_ad(i) + q_ad(i, km+1)
20222 q_ad(i, km+1) = 0.0
20223 grat = delp(i, km-1)/delp(i, km)
20225 temp = 2*grat - gam(i, km) + 2.
20226 temp_ad1 = q_ad(i, km)/temp
20227 temp_ad2 = -((3.*(a4(1, i, km-1)+a4(1, i, km))-grat*qs(i)-q(i, &
20228 & km-1))*temp_ad1/temp)
20229 a4_ad(1, i, km-1) = a4_ad(1, i, km-1) + 3.*temp_ad1
20230 a4_ad(1, i, km) = a4_ad(1, i, km) + 3.*temp_ad1
20231 grat_ad = 2*temp_ad2 - qs(i)*temp_ad1
20232 qs_ad(i) = qs_ad(i) - grat*temp_ad1
20233 q_ad(i, km-1) = q_ad(i, km-1) - temp_ad1
20234 gam_ad(i, km) = gam_ad(i, km) - temp_ad2
20236 temp_ad3 = grat_ad/delp(i, km)
20237 delp_ad(i, km-1) = delp_ad(i, km-1) + temp_ad3
20238 delp_ad(i, km) = delp_ad(i, km) - delp(i, km-1)*temp_ad3/delp(i&
20243 temp_ad = q_ad(i, k)/bet
20245 grat = delp(i, k-1)/delp(i, k)
20246 bet_ad = -((3.*(a4(1, i, k-1)+a4(1, i, k))-q(i, k-1))*temp_ad/&
20247 & bet) - grat*gam_ad(i, k+1)/bet**2
20248 grat_ad = 2*bet_ad + gam_ad(i, k+1)/bet
20249 gam_ad(i, k+1) = 0.0
20250 a4_ad(1, i, k-1) = a4_ad(1, i, k-1) + 3.*temp_ad
20251 a4_ad(1, i, k) = a4_ad(1, i, k) + 3.*temp_ad
20252 q_ad(i, k-1) = q_ad(i, k-1) - temp_ad
20255 gam_ad(i, k) = gam_ad(i, k) - bet_ad
20256 temp_ad0 = grat_ad/delp(i, k)
20257 delp_ad(i, k-1) = delp_ad(i, k-1) + temp_ad0
20258 delp_ad(i, k) = delp_ad(i, k) - delp(i, k-1)*temp_ad0/delp(i, &
20263 a4_ad(1, i, 1) = a4_ad(1, i, 1) + 1.5*q_ad(i, 1)
real, parameter, public radius
Radius of the Earth [m].
subroutine map1_ppm_fwd(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
integer, parameter, public model_atmos
subroutine map1_q2_adm(km, pe1, pe1_ad, q1, q1_ad, kn, pe2, pe2_ad, q2, q2_ad, dp2, dp2_ad, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
subroutine popinteger4(x)
subroutine cs_limiters_bwd(im, extm, a4, a4_ad, iv)
subroutine popcontrol2b(cc)
real, parameter, public ptop_min
subroutine, public fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, te0, qv, ql, qi, qr, qs, qg, dpln, delz, pt, dp, q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
subroutine ppm_profile_fwd(a4, delp, km, i1, i2, iv, kord)
subroutine, public compute_total_energy_bwd(is, ie, js, je, isd, ied, jsd, jed, km, u, u_ad, v, v_ad, w, w_ad, delz, delz_ad, pt, pt_ad, delp, delp_ad, q, q_ad, qc, qc_ad, pe, pe_ad, peln, peln_ad, hs, rsin2_l, cosa_s_l, r_vir, cp, rg, hlv, te_2d, te_2d_ad, ua, va, teq, teq_ad, moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
subroutine cs_profile(qs, a4, delp, km, i1, i2, iv, kord)
subroutine cs_limiters_fwd(im, extm, a4, iv)
subroutine map1_ppm_bwd(km, pe1, pe1_ad, qs, qs_ad, kn, pe2, pe2_ad, q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
subroutine scalar_profile(qs, a4, delp, km, i1, i2, iv, kord, qmin)
real, parameter, public hlv
Latent heat of evaporation [J/kg].
subroutine mapn_tracer_fwd(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)
subroutine map_scalar_adm(km, pe1, pe1_ad, qs, kn, pe2, pe2_ad, q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine, public pushcontrol(ctype, field)
subroutine map1_cubic_bwd(km, pe1, pe1_ad, kn, pe2, pe2_ad, q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
subroutine, public g_sum_adm(domain, p, p_ad, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce, g_sum_ad)
subroutine, public map1_q2_fwd(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
subroutine mapn_tracer(nq, km, pe1, pe2, q1, dp2, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
subroutine scalar_profile_fwd(qs, a4, delp, km, i1, i2, iv, kord, qmin)
subroutine map_scalar(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
real, parameter, public cp_vapor
Specific heat capacity of water vapor at constant pressure [J/kg/deg].
subroutine map1_ppm(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
subroutine pushcontrol1b(cc)
subroutine, public fillz(im, km, nq, q, dp)
subroutine map1_cubic_fwd(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
subroutine ppm_profile_bwd(a4, a4_ad, delp, delp_ad, km, i1, i2, iv, kord)
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 pushcontrol2b(cc)
subroutine ppm_limiters_bwd(dm, dm_ad, a4, a4_ad, itot, lmt)
subroutine cs_profile_bwd(qs, qs_ad, a4, a4_ad, delp, delp_ad, km, i1, i2, iv, kord)
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 pkez_bwd(km, ifirst, ilast, jfirst, jlast, j, pe, pk, pk_ad, akap, peln, peln_ad, pkz, pkz_ad, ptop)
subroutine map_scalar_fwd(km, pe1, qs, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine, public map1_q2_bwd(km, pe1, pe1_ad, q1, q1_ad, kn, pe2, pe2_ad, q2, q2_ad, dp2, dp2_ad, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
subroutine map1_ppm_adm(km, pe1, pe1_ad, qs, qs_ad, kn, pe2, pe2_ad, q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord)
subroutine, public lagrangian_to_eulerian_bwd(last_step, consv, ps, ps_ad, pe, pe_ad, delp, delp_ad, pkz, pkz_ad, pk, pk_ad, mdt, pdt, km, is, ie, js, je, isd, ied, jsd, jed, nq, nwat, sphum, q_con, u, u_ad, v, v_ad, w, w_ad, delz, delz_ad, pt, pt_ad, q, q_ad, hs, r_vir, cp, akap, cappa, kord_mt, kord_wz, kord_tr, kord_tm, peln, peln_ad, te0_2d, te0_2d_ad, ng, ua, ua_ad, va, omga, omga_ad, te, te_ad, ws, ws_ad, 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 timing_on(blk_name)
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 map_scalar_bwd(km, pe1, pe1_ad, qs, kn, pe2, pe2_ad, q2, q2_ad, i1, i2, j, ibeg, iend, jbeg, jend, iv, kord, q_min)
subroutine cs_limiters(im, extm, a4, iv)
subroutine, public qs_init(kmp)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine remap_z(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
subroutine pkez_fwd(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, peln, pkz, ptop)
subroutine, public lagrangian_to_eulerian_fwd(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(dm, a4, itot, lmt)
real, parameter, public hlf
Latent heat of fusion [J/kg].
subroutine popcontrol3b(cc)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine popcontrol1b(cc)
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
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_profile(a4, delp, km, i1, i2, iv, kord)
subroutine remap_2d(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord)
subroutine cs_profile_fwd(qs, a4, delp, km, i1, i2, iv, kord)
subroutine, public prt_mxm(qname, q, is, ie, js, je, n_g, km, fac, area, domain)
subroutine mapn_tracer_adm(nq, km, pe1, pe1_ad, pe2, pe2_ad, q1, q1_ad, dp2, dp2_ad, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)
subroutine, public rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, domain, square_domain)
subroutine cs_profile_adm(qs, qs_ad, a4, a4_ad, delp, delp_ad, km, i1, i2, iv, kord)
subroutine map1_cubic(km, pe1, kn, pe2, q2, i1, i2, j, ibeg, iend, jbeg, jend, akap, t_var, conserv)
real, parameter consv_min
subroutine pushcontrol3b(cc)
subroutine, public map1_q2(km, pe1, q1, kn, pe2, q2, dp2, i1, i2, iv, kord, j, ibeg, iend, jbeg, jend, q_min)
subroutine, public compute_total_energy_fwd(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 scalar_profile_bwd(qs, a4, a4_ad, delp, delp_ad, km, i1, i2, iv, kord, qmin)
subroutine ppm_limiters_fwd(dm, a4, itot, lmt)
subroutine scalar_profile_adm(qs, a4, a4_ad, delp, delp_ad, km, i1, i2, iv, kord, qmin)
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
subroutine, public popcontrol(ctype, field)
subroutine pkez(km, ifirst, ilast, jfirst, jlast, j, pe, pk, akap, peln, pkz, ptop)
subroutine pushinteger4(x)
real(fp), parameter, public pi
subroutine timing_off(blk_name)
subroutine mapn_tracer_bwd(nq, km, pe1, pe1_ad, pe2, pe2_ad, q1, q1_ad, dp2, dp2_ad, kord, j, i1, i2, isd, ied, jsd, jed, q_min, fill)