1 ! Generated by TAPENADE (INRIA, Ecuador team)
2 ! Tapenade 3.16 (master) - 9 Oct 2020 17:47
4 MODULE A_MODULE_MP_WSM6R
8 REAL, PARAMETER :: dtcldcr=120.
9 REAL, PARAMETER :: n0r=8.e6
10 REAL, PARAMETER :: n0g=4.e6
11 REAL, PARAMETER :: avtr=841.9
12 REAL, PARAMETER :: bvtr=0.8
13 ! 8 microm in contrast to 10 micro m
14 REAL, PARAMETER :: r0=.8e-5
15 ! collection efficiency
16 REAL, PARAMETER :: peaut=.55
17 ! maritime cloud in contrast to 3.e8 in tc80
18 REAL, PARAMETER :: xncr=3.e8
19 ! the dynamic viscosity kgm-1s-1
20 REAL, PARAMETER :: xmyu=1.718e-5
21 REAL, PARAMETER :: avts=11.72
22 REAL, PARAMETER :: bvts=.41
23 REAL, PARAMETER :: avtg=330.
24 REAL, PARAMETER :: bvtg=0.8
25 REAL, PARAMETER :: deng=500.
27 REAL, PARAMETER :: n0smax=1.e11
28 ! REAL, PARAMETER :: betai = .6
29 ! REAL, PARAMETER :: xn0 = 1.e-2
30 ! REAL, PARAMETER :: dicon = 11.9
31 ! REAL, PARAMETER :: di0 = 12.9e-6
32 REAL, PARAMETER :: dimax=500.e-6
33 ! temperature dependent n0s
34 REAL, PARAMETER :: n0s=2.e6
35 ! .122 exponen factor for n0s
36 REAL, PARAMETER :: alpha=.12
37 REAL, PARAMETER :: pfrz1=100.
38 REAL, PARAMETER :: pfrz2=0.66
39 REAL, PARAMETER :: t40c=233.16
41 REAL, PARAMETER :: eacrc=1.0
43 REAL, PARAMETER :: eacrr=1.0
44 REAL, PARAMETER :: dens=100.0
46 REAL, PARAMETER :: qs0=6.e-4
48 REAL, PARAMETER :: g=9.81
49 ! gas constant for dry air (J/kg/K) = 287
50 REAL, PARAMETER :: rd=287.
51 ! gas constant for water vapor (J/kg/K)
52 REAL, PARAMETER :: rv=461.6
54 REAL, PARAMETER :: t0c=273.15
55 ! density of 0 degree air (kg/m^3)
56 REAL, PARAMETER :: den0=1.28
57 ! heat capacity at constant pressure for dry air (J/kg/K) = 7.*rd/2.
58 REAL, PARAMETER :: cpd=1004.5
59 ! heat capacity at constant pressure for vapor (J/kg/K) = 4.*r_v
60 REAL, PARAMETER :: cpv=1846.4
61 ! REAL, PARAMETER :: ep1 = 0.6083624 ! = rv/rd-1.
63 REAL, PARAMETER :: ep2=0.6217504
64 REAL, PARAMETER :: qcrmin=1.e-9
66 REAL, PARAMETER :: qmin=1.e-15
67 ! latent heat of sublimation (J/kg) = 2.85E6
68 REAL, PARAMETER :: xls=2.85e6
69 ! latent heat of vaporization (J/kg) = 3.15E6
70 REAL, PARAMETER :: xlv0=2.5e6
71 ! latent heat of melting (J/kg) = 3.50E5
72 REAL, PARAMETER :: xlf0=3.50e5
74 REAL, PARAMETER :: cliq=4190.
76 REAL, PARAMETER :: cice=2106.
78 REAL, PARAMETER :: psat=610.78
79 ! water density = 1000 (kg/m^3)
80 REAL, PARAMETER :: denr=1000.
81 REAL, SAVE :: pi, qc0, qck1, bvtr1, bvtr2, bvtr3, bvtr4, bvtr6, g1pbr&
82 & , g3pbr, g4pbr, g5pbro2, g6pbr, pvtr, bvts1, bvts2, bvts3, bvts4, &
83 & g1pbs, g3pbs, g4pbs, g5pbso2, pvts, bvtg1, bvtg2, bvtg3, bvtg4, g1pbg&
84 & , g3pbg, g4pbg, g5pbgo2, pvtg, roqimax, pidn0r, pidn0s, pidn0g, xlv1, &
85 & vt2i, vt2r, vt2s, vt2g, egs, egi, vt2r_a, vt2s_a, vt2g_a, vt2i_a, &
86 & fallr_a, falls_a, fallg_a, falli_a, pgfrz_a, diffac_a, diffac_b, &
87 & pidep_a, pgacs_a, pgacs_b, pgacs_c, pgacs_d, pgacr_a, pgacr_b, pgacr_c&
88 & , pgacr_d, psacr_a, psacr_b, psacr_c, psacr_d, pracs_a, pracs_b, &
89 & pracs_c, pracs_d, pgaci_a, pgaci_b, pgaci_c, pgaci_d, psevp_a, psevp_b&
91 REAL, SAVE :: pgevp_b, psmlt_a, psmlt_b, pgmlt_a, pgmlt_b, prevp_a, &
92 & prevp_b, psdep_a, psdep_b, pgdep_a, pgdep_b, praci_a, praci_b, praci_c&
93 & , praci_d, psaci_a, psaci_b, psaci_c, psaci_d, pracw_a, piacr_a, &
95 REAL, SAVE :: a_vt2i, a_vt2r, a_vt2s, a_vt2g
98 ! Differentiation of wsm6r in reverse (adjoint) mode (with options r8):
99 ! gradient of useful results: th qc qg qi q qr qs rain rainncv
100 ! with respect to varying inputs: th qc qg qi p q qr qs delz
101 ! den rain rainncv pii
102 ! RW status of diff variables: vt2g:(loc) vt2i:(loc) vt2r:(loc)
103 ! vt2s:(loc) th:in-out qc:in-out qg:in-out qi:in-out
104 ! p:out q:in-out qr:in-out qs:in-out delz:out den:out
105 ! rain:in-out rainncv:in-out pii:out
106 !=======================================================================
108 !=======================================================================
109 SUBROUTINE A_WSM6R(th, a_th, q, a_q, qc, a_qc, qr, a_qr, qi, a_qi, qs&
110 & , a_qs, qg, a_qg, den, a_den, pii, a_pii, p, a_p, delz, a_delz, delt&
111 & , rain, a_rain, rainncv, a_rainncv, ids, ide, jds, jde, kds, kde, &
112 & ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
114 !-------------------------------------------------------------------
115 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde, ims, ime, jms, &
116 & jme, kms, kme, its, ite, jts, jte, kts, kte
117 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: th, q, &
119 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: a_th, &
120 & a_q, a_qc, a_qi, a_qr, a_qs, a_qg
121 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: den, pii, &
123 REAL, DIMENSION(ims:ime, kms:kme, jms:jme) :: a_den, a_pii, a_p, &
125 REAL, INTENT(IN) :: delt
126 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: rain, rainncv
127 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: a_rain, &
130 REAL, DIMENSION(its:ite, kts:kte) :: t
131 REAL, DIMENSION(its:ite, kts:kte) :: a_t
132 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
133 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
134 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
135 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs
136 REAL, DIMENSION(ims:ime, kms:kme) :: q2d, den2d, p2d, delz2d
137 REAL, DIMENSION(ims:ime, kms:kme) :: a_q2d, a_den2d, a_p2d, a_delz2d
138 REAL, DIMENSION(ims:ime) :: r1d, rcv1d
139 REAL, DIMENSION(ims:ime) :: a_r1d, a_rcv1d
141 INTEGER :: i, j, k, ierr
148 CALL PUSHREAL8(t(i, k))
149 t(i, k) = th(i, k, j)*pii(i, k, j)
150 qci(i, k, 1) = qc(i, k, j)
151 qci(i, k, 2) = qi(i, k, j)
152 qrs(i, k, 1) = qr(i, k, j)
153 qrs(i, k, 2) = qs(i, k, j)
154 qrs(i, k, 3) = qg(i, k, j)
155 q2d(i, k) = q(i, k, j)
156 CALL PUSHREAL8(den2d(i, k))
157 den2d(i, k) = den(i, k, j)
158 CALL PUSHREAL8(p2d(i, k))
159 p2d(i, k) = p(i, k, j)
160 CALL PUSHREAL8(delz2d(i, k))
161 delz2d(i, k) = delz(i, k, j)
164 ! Sending array starting locations of optional variables may cause
165 ! troubles, so we explicitly change the call.
166 CALL PUSHREAL8ARRAY(r1d, ime - ims + 1)
167 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
168 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
169 CALL PUSHREAL8ARRAY(q2d, (ime-ims+1)*(kme-kms+1))
170 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
171 CALL WSM62D(t, q2d, qci, qrs, den2d, p2d, delz2d, delt1, r1d, &
172 & rcv1d, ims, ime, kms, kme, its, ite, kts, kte)
190 a_q2d(i, k) = a_q2d(i, k) + a_q(i, k, j)
192 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_qg(i, k, j)
193 a_qg(i, k, j) = 0.0_8
194 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_qs(i, k, j)
195 a_qs(i, k, j) = 0.0_8
196 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_qr(i, k, j)
197 a_qr(i, k, j) = 0.0_8
198 a_qci(i, k, 2) = a_qci(i, k, 2) + a_qi(i, k, j)
199 a_qi(i, k, j) = 0.0_8
200 a_qci(i, k, 1) = a_qci(i, k, 1) + a_qc(i, k, j)
201 a_qc(i, k, j) = 0.0_8
202 a_temp = a_th(i, k, j)/pii(i, k, j)
203 a_th(i, k, j) = 0.0_8
204 a_t(i, k) = a_t(i, k) + a_temp
205 a_pii(i, k, j) = a_pii(i, k, j) - t(i, k)*a_temp/pii(i, k, j)
207 a_rcv1d(i) = a_rcv1d(i) + a_rainncv(i, j)
208 a_rainncv(i, j) = 0.0_8
209 a_r1d(i) = a_r1d(i) + a_rain(i, j)
212 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
213 CALL POPREAL8ARRAY(q2d, (ime-ims+1)*(kme-kms+1))
214 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
215 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
216 CALL POPREAL8ARRAY(r1d, ime - ims + 1)
217 CALL A_WSM62D(t, a_t, q2d, a_q2d, qci, a_qci, qrs, a_qrs, den2d, &
218 & a_den2d, p2d, a_p2d, delz2d, a_delz2d, delt1, r1d, a_r1d, &
219 & rcv1d, a_rcv1d, ims, ime, kms, kme, its, ite, kts, kte)
222 CALL POPREAL8(delz2d(i, k))
223 a_delz(i, k, j) = a_delz(i, k, j) + a_delz2d(i, k)
224 a_delz2d(i, k) = 0.0_8
225 CALL POPREAL8(p2d(i, k))
226 a_p(i, k, j) = a_p(i, k, j) + a_p2d(i, k)
228 CALL POPREAL8(den2d(i, k))
229 a_den(i, k, j) = a_den(i, k, j) + a_den2d(i, k)
230 a_den2d(i, k) = 0.0_8
231 a_q(i, k, j) = a_q(i, k, j) + a_q2d(i, k)
233 a_qg(i, k, j) = a_qg(i, k, j) + a_qrs(i, k, 3)
234 a_qrs(i, k, 3) = 0.0_8
235 a_qs(i, k, j) = a_qs(i, k, j) + a_qrs(i, k, 2)
236 a_qrs(i, k, 2) = 0.0_8
237 a_qr(i, k, j) = a_qr(i, k, j) + a_qrs(i, k, 1)
238 a_qrs(i, k, 1) = 0.0_8
239 a_qi(i, k, j) = a_qi(i, k, j) + a_qci(i, k, 2)
240 a_qci(i, k, 2) = 0.0_8
241 a_qc(i, k, j) = a_qc(i, k, j) + a_qci(i, k, 1)
242 a_qci(i, k, 1) = 0.0_8
243 CALL POPREAL8(t(i, k))
244 a_th(i, k, j) = a_th(i, k, j) + pii(i, k, j)*a_t(i, k)
245 a_pii(i, k, j) = a_pii(i, k, j) + th(i, k, j)*a_t(i, k)
248 a_rainncv(i, j) = a_rainncv(i, j) + a_rcv1d(i)
250 a_rain(i, j) = a_rain(i, j) + a_r1d(i)
254 END SUBROUTINE A_WSM6R
256 !=======================================================================
258 !=======================================================================
259 SUBROUTINE WSM6R(th, q, qc, qr, qi, qs, qg, den, pii, p, delz, delt, &
260 & rain, rainncv, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms&
261 & , kme, its, ite, jts, jte, kts, kte)
263 !-------------------------------------------------------------------
264 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde, ims, ime, jms, &
265 & jme, kms, kme, its, ite, jts, jte, kts, kte
266 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: th, q, &
268 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: den, pii, &
270 REAL, INTENT(IN) :: delt
271 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: rain, rainncv
273 REAL, DIMENSION(its:ite, kts:kte) :: t
274 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
275 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
276 REAL, DIMENSION(ims:ime, kms:kme) :: q2d, den2d, p2d, delz2d
277 REAL, DIMENSION(ims:ime) :: r1d, rcv1d
279 INTEGER :: i, j, k, ierr
284 rcv1d(i) = rainncv(i, j)
286 t(i, k) = th(i, k, j)*pii(i, k, j)
287 qci(i, k, 1) = qc(i, k, j)
288 qci(i, k, 2) = qi(i, k, j)
289 qrs(i, k, 1) = qr(i, k, j)
290 qrs(i, k, 2) = qs(i, k, j)
291 qrs(i, k, 3) = qg(i, k, j)
292 q2d(i, k) = q(i, k, j)
293 den2d(i, k) = den(i, k, j)
294 p2d(i, k) = p(i, k, j)
295 delz2d(i, k) = delz(i, k, j)
298 ! Sending array starting locations of optional variables may cause
299 ! troubles, so we explicitly change the call.
300 CALL WSM62D(t, q2d, qci, qrs, den2d, p2d, delz2d, delt1, r1d, &
301 & rcv1d, ims, ime, kms, kme, its, ite, kts, kte)
304 rainncv(i, j) = rcv1d(i)
306 th(i, k, j) = t(i, k)/pii(i, k, j)
307 qc(i, k, j) = qci(i, k, 1)
308 qi(i, k, j) = qci(i, k, 2)
309 qr(i, k, j) = qrs(i, k, 1)
310 qs(i, k, j) = qrs(i, k, 2)
311 qg(i, k, j) = qrs(i, k, 3)
312 q(i, k, j) = q2d(i, k)
318 ! Differentiation of wsm62d in reverse (adjoint) mode (with options r8):
319 ! gradient of useful results: p q t delz den qrs rain qci
321 ! with respect to varying inputs: p q t delz den qrs rain qci
323 !=======================================================================
325 !=======================================================================
326 SUBROUTINE A_WSM62D(t, a_t, q, a_q, qci, a_qci, qrs, a_qrs, den, a_den&
327 & , p, a_p, delz, a_delz, delt, rain, a_rain, rainncv, a_rainncv, ims&
328 & , ime, kms, kme, its, ite, kts, kte)
332 !-------------------------------------------------------------------
333 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
334 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: t
335 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: a_t
336 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: qci
337 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: a_qci
338 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: qrs
339 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: a_qrs
340 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: q
341 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: a_q
342 REAL, DIMENSION(ims:ime, kms:kme), INTENT(IN) :: den, p, delz
343 REAL, DIMENSION(ims:ime, kms:kme) :: a_den, a_p, a_delz
344 REAL, INTENT(IN) :: delt
345 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: rain, rainncv
346 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: a_rain, a_rainncv
348 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, rslope, rslope2, &
349 & rslope3, rslopeb, falk, fall, work1
350 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_rh, a_qs, a_falk, a_fall
351 REAL, DIMENSION(its:ite, kts:kte) :: pracw, psacw, pgacw, pgacr, &
352 & pgacs, psaci, praci, piacr, pracs, psacr, pgaci, pseml, pgeml, fallc&
353 & , praut, psaut, pgaut, prevp, psdep, pgdep
354 REAL, DIMENSION(its:ite, kts:kte) :: a_pracw, a_psacw, a_pgacw, &
355 & a_pgacr, a_pgacs, a_psaci, a_praci, a_piacr, a_pracs, a_psacr, &
356 & a_pgaci, a_pseml, a_pgeml, a_fallc, a_praut, a_psaut, a_pgaut, &
357 & a_prevp, a_psdep, a_pgdep
358 REAL, DIMENSION(its:ite, kts:kte) :: pigen, pidep, pcond, xl, cpm, &
359 & psevp, xni, pgevp, n0sfac, work2
360 REAL, DIMENSION(its:ite, kts:kte) :: a_pigen, a_pidep, a_xl, a_cpm, &
362 ! LOGICAL, DIMENSION( its:ite ) :: flgcld
363 REAL :: dtcld, temp, temp0, supcol, supsat, satdt, eacrs, xmi, &
364 & diameter, delta2, delta3
365 INTEGER :: i, k, loop, loops
366 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
367 & qs10, qs11, qs20, qs21
368 REAL :: fq, fqc, fqi, fqr, fqs, fqg, fallsum
373 !=================================================================
376 !----------------------------------------------------------------
377 ! paddint 0 for negative values generated by dynamics
381 IF (q(i, k) .LT. 0.) THEN
383 CALL PUSHCONTROL1B(0)
385 CALL PUSHCONTROL1B(1)
388 IF (qci(i, k, 1) .LT. 0.) THEN
390 CALL PUSHCONTROL1B(0)
392 CALL PUSHCONTROL1B(1)
393 qci(i, k, 1) = qci(i, k, 1)
395 IF (qrs(i, k, 1) .LT. 0.) THEN
397 CALL PUSHCONTROL1B(0)
399 CALL PUSHCONTROL1B(1)
400 qrs(i, k, 1) = qrs(i, k, 1)
402 IF (qci(i, k, 2) .LT. 0.) THEN
404 CALL PUSHCONTROL1B(0)
406 CALL PUSHCONTROL1B(1)
407 qci(i, k, 2) = qci(i, k, 2)
409 IF (qrs(i, k, 2) .LT. 0.) THEN
411 CALL PUSHCONTROL1B(0)
413 CALL PUSHCONTROL1B(1)
414 qrs(i, k, 2) = qrs(i, k, 2)
416 IF (qrs(i, k, 3) .LT. 0.) THEN
418 CALL PUSHCONTROL1B(0)
420 CALL PUSHCONTROL1B(1)
421 qrs(i, k, 3) = qrs(i, k, 3)
425 x1 = NINT(delt/dtcldcr)
432 IF (delt .LE. dtcldcr) dtcld = delt
436 !----------------------------------------------------------------
437 ! initialize the variables for microphysical physics
438 CALL PUSHREAL8ARRAY(fallc, (ite-its+1)*(kte-kts+1))
439 CALL PUSHREAL8ARRAY(fall, (ite-its+1)*(kte-kts+1)*3)
440 CALL INIMP(prevp, psdep, pgdep, praut, psaut, pgaut, pracw, praci&
441 & , piacr, psaci, psacw, pracs, psacr, pgacw, pgaci, pgacr, &
442 & pgacs, pigen, pidep, pcond, pseml, pgeml, psevp, pgevp, falk&
443 & , fall, fallc, xni, kts, kte, its, ite)
444 !----------------------------------------------------------------
445 ! compute the fallout term:
446 ! first, vertical terminal velosity for minor loops
447 CALL PUSHREAL8ARRAY(falk, (ite-its+1)*(kte-kts+1)*3)
448 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
449 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
450 CALL PUSHREAL8ARRAY(cpm, (ite-its+1)*(kte-kts+1))
451 CALL FALLK(cpm, t, p, q, den, qrs, delz, dtcld, falk, fall, kte, &
452 & kts, its, ite, kme, kms, ims, ime)
453 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
454 CALL FALLKC(qci, fallc, den, delz, dtcld, kte, kts, its, ite, kme&
456 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
457 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
458 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
459 CALL RAINSC(fall, fallc, xl, t, q, qci, cpm, den, qrs, delz, rain&
460 & , rainncv, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
461 CALL PUSHREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
462 CALL PUSHREAL8ARRAY(rh, (ite-its+1)*(kte-kts+1)*3)
463 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
464 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
465 CALL PUSHREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
466 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
467 CALL WARMR(t, q, qci, qrs, den, p, dtcld, xl, rh, qs, praut, pracw&
468 & , prevp, ims, ime, kms, kme, its, ite, kts, kte)
470 ! cold rain processes
473 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
474 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
475 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
476 CALL ACCRET1(qci, den, qrs, t, q, dtcld, praci, piacr, psaci, &
477 & pgaci, psacw, pgacw, ims, ime, kms, kme, its, ite, kts, kte&
479 CALL PUSHREAL8ARRAY(pgacw, (ite-its+1)*(kte-kts+1))
480 CALL PUSHREAL8ARRAY(psacw, (ite-its+1)*(kte-kts+1))
481 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
482 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
483 CALL ACCRET2(qrs, t, q, den, dtcld, psacw, pgacw, pracs, psacr, &
484 & pgacr, pgacs, pseml, pgeml, ims, ime, kms, kme, its, ite, &
486 CALL PUSHREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
487 CALL PUSHREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
488 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
489 CALL PUSHREAL8ARRAY(rh, (ite-its+1)*(kte-kts+1)*3)
490 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
491 CALL PUSHREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
492 CALL ACCRET3(qrs, qci, rh, t, p, den, dtcld, q, qs, psdep, pgdep, &
493 & pigen, psaut, pgaut, psevp, pgevp, pidep, ims, ime, kms, &
494 & kme, its, ite, kts, kte)
495 CALL PUSHREAL8ARRAY(cpm, (ite-its+1)*(kte-kts+1))
496 CALL PUSHREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
497 CALL PUSHREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
498 CALL PUSHREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
499 CALL PUSHREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
500 CALL PCONADD(t, p, q, qci, qs, xl, cpm, dtcld, kte, kts, its, ite&
501 & , kme, kms, ims, ime)
534 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
535 CALL POPREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
536 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
537 CALL POPREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
538 CALL POPREAL8ARRAY(cpm, (ite-its+1)*(kte-kts+1))
539 CALL A_PCONADD(t, a_t, p, a_p, q, a_q, qci, a_qci, qs, a_qs, xl, &
540 & a_xl, cpm, a_cpm, dtcld, kte, kts, its, ite, kme, kms, &
542 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
543 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
544 CALL POPREAL8ARRAY(rh, (ite-its+1)*(kte-kts+1)*3)
545 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
546 CALL POPREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
547 CALL POPREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
548 CALL A_ACCRET3(qrs, a_qrs, qci, a_qci, rh, a_rh, t, a_t, p, a_p, &
549 & den, a_den, dtcld, q, a_q, qs, a_qs, psdep, a_psdep, &
550 & pgdep, a_pgdep, pigen, a_pigen, psaut, a_psaut, pgaut, &
551 & a_pgaut, psevp, a_psevp, pgevp, a_pgevp, pidep, a_pidep, &
552 & ims, ime, kms, kme, its, ite, kts, kte)
553 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
554 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
555 CALL POPREAL8ARRAY(psacw, (ite-its+1)*(kte-kts+1))
556 CALL POPREAL8ARRAY(pgacw, (ite-its+1)*(kte-kts+1))
557 CALL A_ACCRET2(qrs, a_qrs, t, a_t, q, a_q, den, a_den, dtcld, &
558 & psacw, a_psacw, pgacw, a_pgacw, pracs, a_pracs, psacr, &
559 & a_psacr, pgacr, a_pgacr, pgacs, a_pgacs, pseml, a_pseml, &
560 & pgeml, a_pgeml, ims, ime, kms, kme, its, ite, kts, kte)
561 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
562 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
563 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
564 CALL A_ACCRET1(qci, a_qci, den, a_den, qrs, a_qrs, t, a_t, q, a_q&
565 & , dtcld, praci, a_praci, piacr, a_piacr, psaci, a_psaci, &
566 & pgaci, a_pgaci, psacw, a_psacw, pgacw, a_pgacw, ims, ime&
567 & , kms, kme, its, ite, kts, kte)
568 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
569 CALL POPREAL8ARRAY(q, (ime-ims+1)*(kme-kms+1))
570 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
571 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
572 CALL POPREAL8ARRAY(rh, (ite-its+1)*(kte-kts+1)*3)
573 CALL POPREAL8ARRAY(qs, (ite-its+1)*(kte-kts+1)*3)
574 CALL A_WARMR(t, a_t, q, a_q, qci, a_qci, qrs, a_qrs, den, a_den, p&
575 & , a_p, dtcld, xl, a_xl, rh, a_rh, qs, a_qs, praut, a_praut&
576 & , pracw, a_pracw, prevp, a_prevp, ims, ime, kms, kme, its, &
578 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
579 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
580 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
581 CALL A_RAINSC(fall, a_fall, fallc, a_fallc, xl, a_xl, t, a_t, q, &
582 & qci, a_qci, cpm, a_cpm, den, a_den, qrs, a_qrs, delz, &
583 & a_delz, rain, a_rain, rainncv, a_rainncv, dtcld, kte, kts&
584 & , its, ite, kme, kms, ims, ime)
585 CALL POPREAL8ARRAY(qci, (ite-its+1)*(kte-kts+1)*2)
586 CALL A_FALLKC(qci, a_qci, fallc, a_fallc, den, a_den, delz, a_delz&
587 & , dtcld, kte, kts, its, ite, kme, kms, ims, ime)
588 CALL POPREAL8ARRAY(cpm, (ite-its+1)*(kte-kts+1))
589 CALL POPREAL8ARRAY(t, (ite-its+1)*(kte-kts+1))
590 CALL POPREAL8ARRAY(qrs, (ite-its+1)*(kte-kts+1)*3)
591 CALL POPREAL8ARRAY(falk, (ite-its+1)*(kte-kts+1)*3)
592 CALL A_FALLK(cpm, a_cpm, t, a_t, p, a_p, q, a_q, den, a_den, qrs, &
593 & a_qrs, delz, a_delz, dtcld, falk, a_falk, fall, a_fall, kte&
594 & , kts, its, ite, kme, kms, ims, ime)
595 CALL POPREAL8ARRAY(fall, (ite-its+1)*(kte-kts+1)*3)
596 CALL POPREAL8ARRAY(fallc, (ite-its+1)*(kte-kts+1))
597 CALL A_INIMP(prevp, a_prevp, psdep, a_psdep, pgdep, a_pgdep, praut&
598 & , a_praut, psaut, a_psaut, pgaut, a_pgaut, pracw, a_pracw, &
599 & praci, a_praci, piacr, a_piacr, psaci, a_psaci, psacw, &
600 & a_psacw, pracs, a_pracs, psacr, a_psacr, pgacw, a_pgacw, &
601 & pgaci, a_pgaci, pgacr, a_pgacr, pgacs, a_pgacs, pigen, &
602 & a_pigen, pidep, a_pidep, pcond, pseml, a_pseml, pgeml, &
603 & a_pgeml, psevp, a_psevp, pgevp, a_pgevp, falk, a_falk, fall&
604 & , a_fall, fallc, a_fallc, xni, kts, kte, its, ite)
608 CALL POPCONTROL1B(branch)
609 IF (branch .EQ. 0) a_qrs(i, k, 3) = 0.0_8
610 CALL POPCONTROL1B(branch)
611 IF (branch .EQ. 0) a_qrs(i, k, 2) = 0.0_8
612 CALL POPCONTROL1B(branch)
613 IF (branch .EQ. 0) a_qci(i, k, 2) = 0.0_8
614 CALL POPCONTROL1B(branch)
615 IF (branch .EQ. 0) a_qrs(i, k, 1) = 0.0_8
616 CALL POPCONTROL1B(branch)
617 IF (branch .EQ. 0) a_qci(i, k, 1) = 0.0_8
618 CALL POPCONTROL1B(branch)
619 IF (branch .EQ. 0) a_q(i, k) = 0.0_8
622 END SUBROUTINE A_WSM62D
624 !=======================================================================
626 !=======================================================================
627 SUBROUTINE WSM62D(t, q, qci, qrs, den, p, delz, delt, rain, rainncv, &
628 & ims, ime, kms, kme, its, ite, kts, kte)
632 !-------------------------------------------------------------------
633 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
634 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: t
635 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: qci
636 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: qrs
637 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: q
638 REAL, DIMENSION(ims:ime, kms:kme), INTENT(IN) :: den, p, delz
639 REAL, INTENT(IN) :: delt
640 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: rain, rainncv
642 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, rslope, rslope2, &
643 & rslope3, rslopeb, falk, fall, work1
644 REAL, DIMENSION(its:ite, kts:kte) :: pracw, psacw, pgacw, pgacr, &
645 & pgacs, psaci, praci, piacr, pracs, psacr, pgaci, pseml, pgeml, fallc&
646 & , praut, psaut, pgaut, prevp, psdep, pgdep
647 REAL, DIMENSION(its:ite, kts:kte) :: pigen, pidep, pcond, xl, cpm, &
648 & psevp, xni, pgevp, n0sfac, work2
649 ! LOGICAL, DIMENSION( its:ite ) :: flgcld
650 REAL :: dtcld, temp, temp0, supcol, supsat, satdt, eacrs, xmi, &
651 & diameter, delta2, delta3
652 INTEGER :: i, k, loop, loops
653 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
654 & qs10, qs11, qs20, qs21
655 REAL :: fq, fqc, fqi, fqr, fqs, fqg, fallsum
659 !=================================================================
662 !----------------------------------------------------------------
663 ! paddint 0 for negative values generated by dynamics
667 IF (q(i, k) .LT. 0.) THEN
672 IF (qci(i, k, 1) .LT. 0.) THEN
675 qci(i, k, 1) = qci(i, k, 1)
677 IF (qrs(i, k, 1) .LT. 0.) THEN
680 qrs(i, k, 1) = qrs(i, k, 1)
682 IF (qci(i, k, 2) .LT. 0.) THEN
685 qci(i, k, 2) = qci(i, k, 2)
687 IF (qrs(i, k, 2) .LT. 0.) THEN
690 qrs(i, k, 2) = qrs(i, k, 2)
692 IF (qrs(i, k, 3) .LT. 0.) THEN
695 qrs(i, k, 3) = qrs(i, k, 3)
699 x1 = NINT(delt/dtcldcr)
706 IF (delt .LE. dtcldcr) dtcld = delt
710 !----------------------------------------------------------------
711 ! initialize the variables for microphysical physics
712 CALL INIMP(prevp, psdep, pgdep, praut, psaut, pgaut, pracw, praci&
713 & , piacr, psaci, psacw, pracs, psacr, pgacw, pgaci, pgacr, &
714 & pgacs, pigen, pidep, pcond, pseml, pgeml, psevp, pgevp, falk&
715 & , fall, fallc, xni, kts, kte, its, ite)
716 !----------------------------------------------------------------
717 ! compute the fallout term:
718 ! first, vertical terminal velosity for minor loops
719 CALL FALLK(cpm, t, p, q, den, qrs, delz, dtcld, falk, fall, kte, &
720 & kts, its, ite, kme, kms, ims, ime)
721 CALL FALLKC(qci, fallc, den, delz, dtcld, kte, kts, its, ite, kme&
723 CALL RAINSC(fall, fallc, xl, t, q, qci, cpm, den, qrs, delz, rain&
724 & , rainncv, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
725 CALL WARMR(t, q, qci, qrs, den, p, dtcld, xl, rh, qs, praut, pracw&
726 & , prevp, ims, ime, kms, kme, its, ite, kts, kte)
728 ! cold rain processes
731 CALL ACCRET1(qci, den, qrs, t, q, dtcld, praci, piacr, psaci, &
732 & pgaci, psacw, pgacw, ims, ime, kms, kme, its, ite, kts, kte&
734 CALL ACCRET2(qrs, t, q, den, dtcld, psacw, pgacw, pracs, psacr, &
735 & pgacr, pgacs, pseml, pgeml, ims, ime, kms, kme, its, ite, &
737 CALL ACCRET3(qrs, qci, rh, t, p, den, dtcld, q, qs, psdep, pgdep, &
738 & pigen, psaut, pgaut, psevp, pgevp, pidep, ims, ime, kms, &
739 & kme, its, ite, kts, kte)
740 CALL PCONADD(t, p, q, qci, qs, xl, cpm, dtcld, kte, kts, its, ite&
741 & , kme, kms, ims, ime)
743 END SUBROUTINE WSM62D
745 ! Differentiation of calcrh in reverse (adjoint) mode (with options r8):
746 ! gradient of useful results: p q t qs rh
747 ! with respect to varying inputs: p q t qs rh
748 !=======================================================================
750 !=======================================================================
751 SUBROUTINE A_CALCRH(t, a_t, p, a_p, q, a_q, rh, a_rh, qs, a_qs)
753 REAL, INTENT(IN) :: t, q, p
754 REAL :: a_t, a_q, a_p
755 REAL, DIMENSION(3) :: rh, qs
756 REAL, DIMENSION(3) :: a_rh, a_qs
757 REAL :: tr, qs10, qs11, qs20, qs21
758 REAL :: a_tr, a_qs10, a_qs11, a_qs20, a_qs21
759 REAL, PARAMETER :: hsub=xls
760 REAL, PARAMETER :: hvap=xlv0
761 REAL, PARAMETER :: cvap=cpv
762 REAL, PARAMETER :: ttp=t0c+0.01
763 REAL, PARAMETER :: dldt=cvap-cliq
764 REAL, PARAMETER :: xa=-(dldt/rv)
765 REAL, PARAMETER :: xb=xa+hvap/(rv*ttp)
766 REAL, PARAMETER :: dldti=cvap-cice
767 REAL, PARAMETER :: xai=-(dldti/rv)
768 REAL, PARAMETER :: xbi=xai+hsub/(rv*ttp)
782 qs10 = psat*EXP(LOG(tr)*xa)*EXP(xb*(1.-tr))
783 qs11 = ep2*qs10/(p-qs10)
784 CALL PUSHREAL8(qs(1))
786 IF (qs(1) .LT. qmin) THEN
787 CALL PUSHCONTROL1B(0)
791 CALL PUSHCONTROL1B(1)
793 qs20 = psat*EXP(LOG(tr)*xai)*EXP(xbi*(1.-tr))
794 qs21 = ep2*qs20/(p-qs20)
795 CALL PUSHREAL8(qs(2))
797 IF (qs(2) .LT. qmin) THEN
798 CALL PUSHCONTROL1B(0)
802 CALL PUSHCONTROL1B(1)
804 a_q = a_q + a_rh(2)/max2
805 a_max2 = -(q*a_rh(2)/max2**2)
807 CALL POPCONTROL1B(branch)
808 IF (branch .NE. 0) a_qs(2) = a_qs(2) + a_max2
812 a_temp0 = ep2*a_qs21/(p-qs20)
813 a_temp = -(qs20*a_temp0/(p-qs20))
814 a_qs20 = a_temp0 - a_temp
817 a_tr = (xai*EXP(temp0)*EXP(xbi*(1.-tr))*psat/tr-xbi*EXP(xbi*(1.-tr))&
818 & *EXP(temp0)*psat)*a_qs20
819 a_q = a_q + a_rh(1)/max1
820 a_max1 = -(q*a_rh(1)/max1**2)
822 CALL POPCONTROL1B(branch)
823 IF (branch .NE. 0) a_qs(1) = a_qs(1) + a_max1
827 a_temp = ep2*a_qs11/(p-qs10)
828 a_temp0 = -(qs10*a_temp/(p-qs10))
829 a_qs10 = a_temp - a_temp0
832 a_tr = a_tr + (xa*EXP(temp)*EXP(xb*(1.-tr))*psat/tr-xb*EXP(xb*(1.-tr&
833 & ))*EXP(temp)*psat)*a_qs10
834 a_t = a_t - ttp*a_tr/t**2
835 END SUBROUTINE A_CALCRH
837 !=======================================================================
839 !=======================================================================
840 SUBROUTINE CALCRH(t, p, q, rh, qs)
842 REAL, INTENT(IN) :: t, q, p
843 REAL, DIMENSION(3), INTENT(OUT) :: rh, qs
844 REAL :: tr, qs10, qs11, qs20, qs21
845 REAL, PARAMETER :: hsub=xls
846 REAL, PARAMETER :: hvap=xlv0
847 REAL, PARAMETER :: cvap=cpv
848 REAL, PARAMETER :: ttp=t0c+0.01
849 REAL, PARAMETER :: dldt=cvap-cliq
850 REAL, PARAMETER :: xa=-(dldt/rv)
851 REAL, PARAMETER :: xb=xa+hvap/(rv*ttp)
852 REAL, PARAMETER :: dldti=cvap-cice
853 REAL, PARAMETER :: xai=-(dldti/rv)
854 REAL, PARAMETER :: xbi=xai+hsub/(rv*ttp)
861 qs10 = psat*EXP(LOG(tr)*xa)*EXP(xb*(1.-tr))
862 qs11 = ep2*qs10/(p-qs10)
864 IF (qs(1) .LT. qmin) THEN
870 qs20 = psat*EXP(LOG(tr)*xai)*EXP(xbi*(1.-tr))
871 qs21 = ep2*qs20/(p-qs20)
873 IF (qs(2) .LT. qmin) THEN
879 END SUBROUTINE CALCRH
882 !=======================================================================
884 !=======================================================================
885 SUBROUTINE WSM6RINIT()
889 !-------------------------------------------------------------------
890 !.... constants which may not be tunable
894 qc0 = 4./3.*pi*denr*r0**3*xncr/den0
896 qck1 = .104*9.8*peaut/(xncr*denr)**(1./3.)/xmyu*den0**(4./3.)
898 bvtr2 = 2.5 + .5*bvtr
908 g5pbro2 = RGMMA(bvtr2)
910 roqimax = 2.08e22*dimax**8
913 bvts2 = 2.5 + .5*bvts
921 g5pbso2 = RGMMA(bvts2)
926 bvtg2 = 2.5 + .5*bvtg
932 g5pbgo2 = RGMMA(bvtg2)
935 vt2r_a = pvtr*pidn0r**(-(bvtr/4.))*SQRT(den0)
936 vt2s_a = pvts*pidn0s**(-(bvts/4.))*SQRT(den0)
937 vt2g_a = pvtg*pidn0g**(-(bvtg/4.))*SQRT(den0)
943 prevp_a = 1.56*pi*n0r/SQRT(pidn0r)
944 prevp_b = 130.37*pi*SQRT(avtr)*n0r*pidn0r**(-((5.+bvtr)/8.))*SQRT(&
945 & SQRT(den0))*g5pbro2
946 psdep_a = 2.6*n0s/SQRT(pidn0s)
947 psdep_b = 370.08*SQRT(avts)*n0s*pidn0s**(-((5.+bvts)/8.))*SQRT(SQRT(&
951 pgdep_a = 1.56*pi*n0g/SQRT(pidn0g)
952 pgdep_b = 130.37*pi*SQRT(avtg)*n0g*pidn0g**(-((5.+bvtg)/8.))*SQRT(&
953 & SQRT(den0))*g5pbgo2
956 psmlt_a = 2.75e-3*pi*n0s/SQRT(pidn0s)/xlf0
957 psmlt_b = 0.391*pi*n0s*SQRT(SQRT(den0))*SQRT(avts)*pidn0s**(-((5.+&
958 & bvts)/8.))*g5pbso2/xlf0
959 pgmlt_a = 3.3e-3*pi*n0g/SQRT(pidn0g)/xlf0
960 pgmlt_b = 0.276*pi*n0g*SQRT(SQRT(den0))*SQRT(avtg)*pidn0g**(-((5.+&
961 & bvtg)/8.))*g5pbgo2/xlf0
963 praci_b = 2./pidn0r**(3./4.)
964 praci_c = 3.245e-3/SQRT(pidn0r)
965 praci_d = 2.633e-6/SQRT(SQRT(pidn0r))
967 psaci_b = 2./pidn0s**(3./4.)
968 psaci_c = 3.245e-3/SQRT(pidn0s)
969 psaci_d = 2.633e-6/SQRT(SQRT(pidn0s))
971 pgaci_b = 2./pidn0g**(3./4.)
972 pgaci_c = 3.245e-3/SQRT(pidn0g)
973 pgaci_d = 2.633e-6/SQRT(SQRT(pidn0g))
974 pracs_a = pi*n0r*pidn0s
975 pracs_b = 5./pidn0s**(3./2.)/SQRT(SQRT(pidn0r))
976 pracs_c = 2./pidn0s**(5./4.)/SQRT(pidn0r)
977 pracs_d = .5/pidn0s/pidn0r**(3./4.)
978 psacr_a = pi*n0s*pidn0r
979 psacr_b = 5./pidn0r**(3./2.)/SQRT(SQRT(pidn0s))
980 psacr_c = 2./pidn0r**(5./4.)/SQRT(pidn0s)
981 psacr_d = .5/pidn0r/pidn0s**(3./4.)
982 pgacr_a = pi*n0g*pidn0r
983 pgacr_b = 5./pidn0r**(3./2.)/SQRT(SQRT(pidn0g))
984 pgacr_c = 2./pidn0r**(5./4.)/SQRT(pidn0g)
985 pgacr_d = .5/pidn0r/pidn0g**(3./4.)
986 pgacs_a = pi*n0g*pidn0s
987 pgacs_b = 5./pidn0s**(3./2.)/SQRT(SQRT(pidn0g))
988 pgacs_c = 2./pidn0s**(5./4.)/SQRT(pidn0g)
989 pgacs_d = .5/pidn0s/pidn0g**(3./4.)
993 pgfrz_a = 20.*pi*pfrz1/pidn0r**(3./4.)
994 piacr_a = 5.38e7*pi*avtr*pidn0r*g6pbr*SQRT(den0)*pidn0r**(-((6.+bvtr&
996 pracw_a = .25*pi*avtr*n0r*g3pbr*SQRT(den0)*pidn0r**(-((3.+bvtr)/4.))
997 psacw_a = .25*pi*avts*n0s*g3pbs*SQRT(den0)*pidn0s**(-((3.+bvts)/4.))
998 pgacw_a = .25*pi*avtg*n0g*g3pbg*SQRT(den0)*pidn0g**(-((3.+bvtg)/4.))
999 END SUBROUTINE WSM6RINIT
1001 ! Differentiation of inimp in reverse (adjoint) mode (with options r8):
1002 ! gradient of useful results: fallc piacr psaci pgaci psacr
1003 ! praci psacw pgacr pgacs pracs pgacw pigen pracw
1004 ! psevp pidep falk fall pgevp prevp psdep pseml
1005 ! pgdep pgeml psaut pgaut praut
1006 ! with respect to varying inputs: fallc piacr psaci pgaci psacr
1007 ! praci psacw pgacr pgacs pracs pgacw pigen pracw
1008 ! psevp pidep falk fall pgevp prevp psdep pseml
1009 ! pgdep pgeml psaut pgaut praut
1010 !=======================================================================
1012 !=======================================================================
1013 SUBROUTINE A_INIMP(prevp, a_prevp, psdep, a_psdep, pgdep, a_pgdep, &
1014 & praut, a_praut, psaut, a_psaut, pgaut, a_pgaut, pracw, a_pracw, &
1015 & praci, a_praci, piacr, a_piacr, psaci, a_psaci, psacw, a_psacw, &
1016 & pracs, a_pracs, psacr, a_psacr, pgacw, a_pgacw, pgaci, a_pgaci, &
1017 & pgacr, a_pgacr, pgacs, a_pgacs, pigen, a_pigen, pidep, a_pidep, &
1018 & pcond, pseml, a_pseml, pgeml, a_pgeml, psevp, a_psevp, pgevp, &
1019 & a_pgevp, falk, a_falk, fall, a_fall, fallc, a_fallc, xni, kts, kte, &
1022 INTEGER :: kts, kte, its, ite, k, i
1023 REAL, DIMENSION(its:ite, kts:kte, 3) :: falk, fall
1024 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_falk, a_fall
1025 REAL, DIMENSION(its:ite, kts:kte) :: xni, pgevp, pigen, pidep, pcond&
1026 & , fallc, pracw, psacw, pgacw, pgacr, pgacs, psaci, praci, piacr, &
1027 & pracs, psacr, pgaci, pseml, pgeml, psevp, praut, psaut, pgaut, prevp&
1029 REAL, DIMENSION(its:ite, kts:kte) :: a_pgevp, a_pigen, a_pidep, &
1030 & a_fallc, a_pracw, a_psacw, a_pgacw, a_pgacr, a_pgacs, a_psaci, &
1031 & a_praci, a_piacr, a_pracs, a_psacr, a_pgaci, a_pseml, a_pgeml, &
1032 & a_psevp, a_praut, a_psaut, a_pgaut, a_prevp, a_psdep, a_pgdep
1035 a_fallc(i, k) = 0.0_8
1036 a_fall(i, k, 3) = 0.0_8
1037 a_fall(i, k, 2) = 0.0_8
1038 a_fall(i, k, 1) = 0.0_8
1039 a_falk(i, k, 3) = 0.0_8
1040 a_falk(i, k, 2) = 0.0_8
1041 a_falk(i, k, 1) = 0.0_8
1042 a_pgevp(i, k) = 0.0_8
1043 a_psevp(i, k) = 0.0_8
1044 a_pgeml(i, k) = 0.0_8
1045 a_pseml(i, k) = 0.0_8
1046 a_pidep(i, k) = 0.0_8
1047 a_pigen(i, k) = 0.0_8
1048 a_pgacs(i, k) = 0.0_8
1049 a_pgacr(i, k) = 0.0_8
1050 a_pgaci(i, k) = 0.0_8
1051 a_pgacw(i, k) = 0.0_8
1052 a_psacr(i, k) = 0.0_8
1053 a_pracs(i, k) = 0.0_8
1054 a_psacw(i, k) = 0.0_8
1055 a_psaci(i, k) = 0.0_8
1056 a_piacr(i, k) = 0.0_8
1057 a_praci(i, k) = 0.0_8
1058 a_pracw(i, k) = 0.0_8
1059 a_pgaut(i, k) = 0.0_8
1060 a_psaut(i, k) = 0.0_8
1061 a_praut(i, k) = 0.0_8
1062 a_pgdep(i, k) = 0.0_8
1063 a_psdep(i, k) = 0.0_8
1064 a_prevp(i, k) = 0.0_8
1067 END SUBROUTINE A_INIMP
1069 !=======================================================================
1071 !=======================================================================
1072 SUBROUTINE INIMP(prevp, psdep, pgdep, praut, psaut, pgaut, pracw, &
1073 & praci, piacr, psaci, psacw, pracs, psacr, pgacw, pgaci, pgacr, pgacs&
1074 & , pigen, pidep, pcond, pseml, pgeml, psevp, pgevp, falk, fall, fallc&
1075 & , xni, kts, kte, its, ite)
1077 INTEGER :: kts, kte, its, ite, k, i
1078 REAL, DIMENSION(its:ite, kts:kte, 3) :: falk, fall
1079 REAL, DIMENSION(its:ite, kts:kte) :: xni, pgevp, pigen, pidep, pcond&
1080 & , fallc, pracw, psacw, pgacw, pgacr, pgacs, psaci, praci, piacr, &
1081 & pracs, psacr, pgaci, pseml, pgeml, psevp, praut, psaut, pgaut, prevp&
1119 END SUBROUTINE INIMP
1121 ! Differentiation of fallk in reverse (adjoint) mode (with options r8):
1122 ! gradient of useful results: p q t cpm delz den qrs falk
1124 ! with respect to varying inputs: p q t cpm delz den qrs falk
1126 !=======================================================================
1128 !=======================================================================
1129 SUBROUTINE A_FALLK(cpm, a_cpm, t, a_t, p, a_p, q, a_q, den, a_den, qrs&
1130 & , a_qrs, delz, a_delz, dtcld, falk, a_falk, fall, a_fall, kte, kts, &
1131 & its, ite, kme, kms, ims, ime)
1133 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
1134 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, falk, fall, work1
1135 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs, a_falk, a_fall, &
1137 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, p, q
1138 REAL, DIMENSION(ims:ime, kms:kme) :: a_delz, a_den, a_p, a_q
1139 REAL, DIMENSION(its:ite, kts:kte) :: psmlt, pgmlt, t, work2, cpm
1140 REAL, DIMENSION(its:ite, kts:kte) :: a_psmlt, a_pgmlt, a_t, a_cpm
1141 INTEGER, DIMENSION(its:ite) :: mstep, numdt
1142 REAL :: dtcld, coeres1, coeres2, coeresi, coeresh, xlf, psmlt0, &
1143 & pgmlt0, help_i, help_h, w1
1144 REAL :: a_psmlt0, a_pgmlt0
1145 REAL :: tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8
1146 REAL :: a_tmp1, a_tmp2, a_tmp3, a_tmp4, a_tmp5, a_tmp6, a_tmp7, &
1148 INTEGER :: mstepmax, k, i, n, nw, jj
1149 REAL :: fqs, fqg, supcol, a, b, c, d
1150 REAL :: a_a, a_b, a_c, a_d
1212 IF (qcrmin .LT. qrs(i, k, 1)) THEN
1213 CALL PUSHREAL8(max1)
1215 CALL PUSHCONTROL1B(0)
1217 CALL PUSHREAL8(max1)
1219 CALL PUSHCONTROL1B(1)
1221 work1(i, k, 1) = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.&
1223 IF (qcrmin .LT. qrs(i, k, 2)) THEN
1224 CALL PUSHREAL8(max2)
1226 CALL PUSHCONTROL1B(0)
1228 CALL PUSHREAL8(max2)
1230 CALL PUSHCONTROL1B(1)
1232 IF (90. .GT. t0c - t(i, k)) THEN
1234 CALL PUSHCONTROL1B(0)
1236 CALL PUSHCONTROL1B(1)
1239 IF (0. .LT. y3) THEN
1240 CALL PUSHREAL8(max8)
1242 CALL PUSHCONTROL1B(0)
1244 CALL PUSHREAL8(max8)
1246 CALL PUSHCONTROL1B(1)
1248 work1(i, k, 2) = vt2s_a*den(i, k)**((bvts-2.)/4.)*max2**(bvts/4.&
1249 & )/delz(i, k)*EXP(-(bvts*alpha*max8/4.))
1250 IF (qcrmin .LT. qrs(i, k, 3)) THEN
1251 CALL PUSHREAL8(max3)
1253 CALL PUSHCONTROL1B(0)
1255 CALL PUSHREAL8(max3)
1257 CALL PUSHCONTROL1B(1)
1259 work1(i, k, 3) = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max3**(bvtg/4.&
1261 IF (work1(i, k, 1) .GE. work1(i, k, 2) .AND. work1(i, k, 1) .GE.&
1262 & work1(i, k, 3)) THEN
1263 CALL PUSHCONTROL1B(0)
1265 ELSE IF (work1(i, k, 2) .GE. work1(i, k, 1) .AND. work1(i, k, 2)&
1266 & .GE. work1(i, k, 3)) THEN
1267 CALL PUSHCONTROL1B(1)
1270 CALL PUSHCONTROL1B(1)
1273 nw = NINT(w1*dtcld + .5)
1279 IF (numdt(i) .GE. mstep(i)) THEN
1280 CALL PUSHCONTROL1B(1)
1283 CALL PUSHCONTROL1B(0)
1288 IF (mstepmax .LE. mstep(i)) THEN
1289 CALL PUSHCONTROL1B(1)
1292 CALL PUSHCONTROL1B(0)
1297 IF (n .LE. mstep(i)) THEN
1298 CALL PUSHINTEGER4(k)
1300 CALL PUSHREAL8(falk(i, k, 1))
1301 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(i)
1302 CALL PUSHREAL8(falk(i, k, 2))
1303 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(i)
1304 CALL PUSHREAL8(falk(i, k, 3))
1305 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(i)
1307 x1 = falk(i, k, jj)*dtcld/den(i, k)
1308 IF (x1 .GT. qrs(i, k, jj)) THEN
1309 tmp1 = qrs(i, k, jj)
1310 CALL PUSHCONTROL1B(0)
1313 CALL PUSHCONTROL1B(1)
1315 IF (tmp1 .GE. 0.) THEN
1320 IF (abs0 .LT. qmin) THEN
1322 CALL PUSHCONTROL1B(0)
1324 CALL PUSHCONTROL1B(1)
1326 CALL PUSHREAL8(qrs(i, k, jj))
1327 qrs(i, k, jj) = qrs(i, k, jj) - tmp1
1329 CALL PUSHCONTROL1B(1)
1331 CALL PUSHCONTROL1B(0)
1334 CALL PUSHINTEGER4(k)
1337 IF (n .LE. mstep(i)) THEN
1338 CALL PUSHREAL8(falk(i, k, 1))
1339 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(&
1341 CALL PUSHREAL8(falk(i, k, 2))
1342 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(&
1344 CALL PUSHREAL8(falk(i, k, 3))
1345 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(&
1348 IF ((falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/delz(i, &
1349 & k))*dtcld/den(i, k) .GT. qrs(i, k, jj)) THEN
1350 tmp2 = qrs(i, k, jj)
1351 CALL PUSHCONTROL1B(0)
1353 tmp2 = (falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/&
1354 & delz(i, k))*dtcld/den(i, k)
1355 CALL PUSHCONTROL1B(1)
1357 IF (tmp2 .GE. 0.) THEN
1362 IF (abs1 .LT. qmin) THEN
1364 CALL PUSHCONTROL1B(0)
1366 CALL PUSHCONTROL1B(1)
1368 CALL PUSHREAL8(qrs(i, k, jj))
1369 qrs(i, k, jj) = qrs(i, k, jj) - tmp2
1371 CALL PUSHCONTROL1B(1)
1373 CALL PUSHCONTROL1B(0)
1379 IF (n .LE. mstep(i)) THEN
1381 !---------------------------------------------------------------
1382 ! psmlt: melting of snow [RH83 A25]
1383 ! (T>T0: S->R) psmlt<0: min=-qrs(i,k,2), max=0
1384 !---------------------------------------------------------------
1386 CALL PUSHREAL8(cpm(i, k))
1387 cpm(i, k) = CPMCAL(q(i, k))
1389 IF (90. .GT. t0c - t(i, k)) THEN
1391 CALL PUSHCONTROL1B(0)
1393 CALL PUSHCONTROL1B(1)
1396 IF (0. .LT. y1) THEN
1397 CALL PUSHREAL8(max4)
1399 CALL PUSHCONTROL1B(0)
1401 CALL PUSHREAL8(max4)
1403 CALL PUSHCONTROL1B(1)
1406 a = EXP(alpha*max4/2.)
1407 IF (90. .GT. t0c - t(i, k)) THEN
1409 CALL PUSHCONTROL1B(0)
1411 CALL PUSHCONTROL1B(1)
1414 IF (0. .LT. y2) THEN
1415 CALL PUSHREAL8(max5)
1417 CALL PUSHCONTROL1B(0)
1419 CALL PUSHREAL8(max5)
1421 CALL PUSHCONTROL1B(1)
1424 b = EXP(alpha*max5*(3-bvts)/8.)
1425 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
1427 d = t(i, k)**(3.88/6.)*(t0c-t(i, k))/(t(i, k)+120.)**(5./6.)
1428 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1429 CALL PUSHREAL8(max6)
1431 CALL PUSHCONTROL1B(1)
1433 CALL PUSHREAL8(max6)
1435 CALL PUSHCONTROL1B(0)
1437 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1438 CALL PUSHREAL8(max9)
1440 CALL PUSHCONTROL1B(0)
1442 CALL PUSHREAL8(max9)
1444 CALL PUSHCONTROL1B(1)
1446 psmlt0 = psmlt_a*a*c*SQRT(den(i, k)*max6) + psmlt_b*b*d*p(i&
1447 & , k)**(1./3.)*den(i, k)**((13.+3*bvts)/24.)*max9**((5.+&
1449 tmp3 = psmlt0*dtcld/mstep(i)
1450 tmp4 = -(qrs(i, k, 2)/mstep(i))
1451 IF (tmp3 .GT. tmp4) THEN
1453 CALL PUSHCONTROL1B(0)
1456 CALL PUSHCONTROL1B(1)
1458 IF (tmp5 .LT. 0.) THEN
1459 CALL PUSHREAL8(psmlt(i, k))
1461 CALL PUSHCONTROL1B(1)
1463 CALL PUSHREAL8(psmlt(i, k))
1465 CALL PUSHCONTROL1B(0)
1467 IF (psmlt(i, k) .GE. 0.) THEN
1472 IF (abs2 .LT. qmin) THEN
1474 CALL PUSHCONTROL1B(1)
1476 CALL PUSHCONTROL1B(0)
1478 IF (qrs(i, k, 2) + psmlt(i, k) .LT. 0.) THEN
1479 CALL PUSHREAL8(qrs(i, k, 2))
1481 CALL PUSHCONTROL1B(0)
1483 CALL PUSHREAL8(qrs(i, k, 2))
1484 qrs(i, k, 2) = qrs(i, k, 2) + psmlt(i, k)
1485 CALL PUSHCONTROL1B(1)
1487 IF (qrs(i, k, 1) - psmlt(i, k) .LT. 0.) THEN
1488 CALL PUSHREAL8(qrs(i, k, 1))
1490 CALL PUSHCONTROL1B(0)
1492 CALL PUSHREAL8(qrs(i, k, 1))
1493 qrs(i, k, 1) = qrs(i, k, 1) - psmlt(i, k)
1494 CALL PUSHCONTROL1B(1)
1496 CALL PUSHREAL8(t(i, k))
1497 t(i, k) = t(i, k) + xlf/cpm(i, k)*psmlt(i, k)
1498 CALL PUSHCONTROL1B(1)
1500 CALL PUSHCONTROL1B(0)
1504 !---------------------------------------------------------------
1505 ! pgmlt: melting of graupel [LFO 47]
1506 ! (T>T0: G->R) pgmlt<0: min=-qrs(i,k,3), max=0
1507 !---------------------------------------------------------------
1510 IF (n .LE. mstep(i)) THEN
1513 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
1514 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
1516 d = t(i, k)**(3.88/6.)*(t0c-t(i, k))/(t(i, k)+120.)**(5./6.)
1517 IF (qrs(i, k, 3) .LT. qcrmin) THEN
1518 CALL PUSHREAL8(max7)
1520 CALL PUSHCONTROL1B(1)
1522 CALL PUSHREAL8(max7)
1524 CALL PUSHCONTROL1B(0)
1526 IF (qrs(i, k, 3) .LT. qcrmin) THEN
1527 CALL PUSHREAL8(max10)
1529 CALL PUSHCONTROL1B(0)
1531 CALL PUSHREAL8(max10)
1532 max10 = qrs(i, k, 3)
1533 CALL PUSHCONTROL1B(1)
1535 pgmlt0 = pgmlt_a*c*SQRT(den(i, k)*max7) + pgmlt_b*d*p(i, k)&
1536 & **(1./3.)*den(i, k)**((13.+3*bvtg)/24.)*max10**((5.+bvtg)/&
1538 tmp6 = pgmlt0*dtcld/mstep(i)
1539 tmp7 = -(qrs(i, k, 3)/mstep(i))
1540 IF (tmp6 .GT. tmp7) THEN
1542 CALL PUSHCONTROL1B(0)
1545 CALL PUSHCONTROL1B(1)
1547 IF (tmp8 .LT. 0.) THEN
1548 CALL PUSHREAL8(pgmlt(i, k))
1550 CALL PUSHCONTROL1B(1)
1552 CALL PUSHREAL8(pgmlt(i, k))
1554 CALL PUSHCONTROL1B(0)
1556 IF (pgmlt(i, k) .GE. 0.) THEN
1561 IF (abs3 .LT. qmin) THEN
1563 CALL PUSHCONTROL1B(1)
1565 CALL PUSHCONTROL1B(0)
1567 IF (qrs(i, k, 3) + pgmlt(i, k) .LT. 0.) THEN
1568 CALL PUSHREAL8(qrs(i, k, 3))
1570 CALL PUSHCONTROL1B(0)
1572 CALL PUSHREAL8(qrs(i, k, 3))
1573 qrs(i, k, 3) = qrs(i, k, 3) + pgmlt(i, k)
1574 CALL PUSHCONTROL1B(1)
1576 IF (qrs(i, k, 1) - pgmlt(i, k) .LT. 0.) THEN
1577 CALL PUSHREAL8(qrs(i, k, 1))
1579 CALL PUSHCONTROL1B(0)
1581 CALL PUSHREAL8(qrs(i, k, 1))
1582 qrs(i, k, 1) = qrs(i, k, 1) - pgmlt(i, k)
1583 CALL PUSHCONTROL1B(1)
1585 CALL PUSHREAL8(t(i, k))
1586 t(i, k) = t(i, k) + xlf/cpm(i, k)*pgmlt(i, k)
1587 CALL PUSHCONTROL1B(1)
1589 CALL PUSHCONTROL1B(0)
1600 CALL POPCONTROL1B(branch)
1601 IF (branch .NE. 0) THEN
1603 CALL POPREAL8(t(i, k))
1604 a_temp4 = xlf*a_t(i, k)/cpm(i, k)
1605 a_pgmlt(i, k) = a_pgmlt(i, k) + a_temp4
1606 a_cpm(i, k) = a_cpm(i, k) - pgmlt(i, k)*a_temp4/cpm(i, k)
1607 CALL POPCONTROL1B(branch)
1608 IF (branch .EQ. 0) THEN
1609 CALL POPREAL8(qrs(i, k, 1))
1610 a_qrs(i, k, 1) = 0.0_8
1612 CALL POPREAL8(qrs(i, k, 1))
1613 a_pgmlt(i, k) = a_pgmlt(i, k) - a_qrs(i, k, 1)
1615 CALL POPCONTROL1B(branch)
1616 IF (branch .EQ. 0) THEN
1617 CALL POPREAL8(qrs(i, k, 3))
1618 a_qrs(i, k, 3) = 0.0_8
1620 CALL POPREAL8(qrs(i, k, 3))
1621 a_pgmlt(i, k) = a_pgmlt(i, k) + a_qrs(i, k, 3)
1623 CALL POPCONTROL1B(branch)
1624 IF (branch .NE. 0) a_pgmlt(i, k) = 0.0_8
1625 CALL POPCONTROL1B(branch)
1626 IF (branch .EQ. 0) THEN
1627 CALL POPREAL8(pgmlt(i, k))
1628 a_pgmlt(i, k) = 0.0_8
1631 CALL POPREAL8(pgmlt(i, k))
1632 a_tmp8 = a_pgmlt(i, k)
1633 a_pgmlt(i, k) = 0.0_8
1635 CALL POPCONTROL1B(branch)
1636 IF (branch .EQ. 0) THEN
1643 a_qrs(i, k, 3) = a_qrs(i, k, 3) - a_tmp7/mstep(i)
1644 a_pgmlt0 = dtcld*a_tmp6/mstep(i)
1645 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
1646 temp9 = den(i, k)*max7
1648 temp7 = (bvtg+5.)/8.
1649 temp6 = max10**temp7
1651 temp4 = p(i, k)**temp5
1652 temp3 = (3*bvtg+13.)/24.
1653 a_c = temp8*pgmlt_a*a_pgmlt0
1654 IF (temp9 .EQ. 0.0_8) THEN
1657 a_temp4 = c*pgmlt_a*a_pgmlt0/(2.0*temp8)
1659 IF (den(i, k) .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. temp3 &
1660 & .NE. INT(temp3))) THEN
1661 a_den(i, k) = a_den(i, k) + max7*a_temp4
1663 a_den(i, k) = a_den(i, k) + temp3*den(i, k)**(temp3-1)*&
1664 & temp4*d*temp6*pgmlt_b*a_pgmlt0 + max7*a_temp4
1666 a_temp0 = den(i, k)**temp3*pgmlt_b*a_pgmlt0
1667 IF (.NOT.(p(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
1668 & temp5 .NE. INT(temp5)))) a_p(i, k) = a_p(i, k) + temp5*p&
1669 & (i, k)**(temp5-1)*d*temp6*a_temp0
1670 a_d = temp6*temp4*a_temp0
1671 IF (max10 .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 .NE.&
1675 a_max10 = temp7*max10**(temp7-1)*d*temp4*a_temp0
1677 a_max7 = den(i, k)*a_temp4
1678 CALL POPCONTROL1B(branch)
1679 IF (branch .EQ. 0) THEN
1680 CALL POPREAL8(max10)
1682 CALL POPREAL8(max10)
1683 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max10
1685 CALL POPCONTROL1B(branch)
1686 IF (branch .EQ. 0) THEN
1688 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max7
1692 a_temp4 = t(i, k)**1.5*a_c/(t(i, k)+120.)
1695 temp8 = (t(i, k)+120.)**temp9
1697 temp5 = t(i, k)**temp6
1699 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
1700 & temp6 .NE. INT(temp6)))) a_t(i, k) = a_t(i, k) + temp6*t&
1701 & (i, k)**(temp6-1)*(t0c-t(i, k))*a_temp5
1702 IF (t(i, k) + 120. .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. &
1703 & temp9 .NE. INT(temp9))) THEN
1704 a_t(i, k) = a_t(i, k) - temp5*a_temp5
1706 a_t(i, k) = a_t(i, k) - (temp5+temp9*(t(i, k)+120.)**(&
1707 & temp9-1)*temp5*(t0c-t(i, k))/temp8)*a_temp5
1709 temp9 = (t0c-t(i, k))/(t(i, k)+120.)
1710 a_t(i, k) = a_t(i, k) + 1.5*t(i, k)**0.5*temp9*a_c - (temp9+&
1717 CALL POPCONTROL1B(branch)
1718 IF (branch .NE. 0) THEN
1720 CALL POPREAL8(t(i, k))
1721 a_temp4 = xlf*a_t(i, k)/cpm(i, k)
1722 a_psmlt(i, k) = a_psmlt(i, k) + a_temp4
1723 a_cpm(i, k) = a_cpm(i, k) - psmlt(i, k)*a_temp4/cpm(i, k)
1724 CALL POPCONTROL1B(branch)
1725 IF (branch .EQ. 0) THEN
1726 CALL POPREAL8(qrs(i, k, 1))
1727 a_qrs(i, k, 1) = 0.0_8
1729 CALL POPREAL8(qrs(i, k, 1))
1730 a_psmlt(i, k) = a_psmlt(i, k) - a_qrs(i, k, 1)
1732 CALL POPCONTROL1B(branch)
1733 IF (branch .EQ. 0) THEN
1734 CALL POPREAL8(qrs(i, k, 2))
1735 a_qrs(i, k, 2) = 0.0_8
1737 CALL POPREAL8(qrs(i, k, 2))
1738 a_psmlt(i, k) = a_psmlt(i, k) + a_qrs(i, k, 2)
1740 CALL POPCONTROL1B(branch)
1741 IF (branch .NE. 0) a_psmlt(i, k) = 0.0_8
1742 CALL POPCONTROL1B(branch)
1743 IF (branch .EQ. 0) THEN
1744 CALL POPREAL8(psmlt(i, k))
1745 a_psmlt(i, k) = 0.0_8
1748 CALL POPREAL8(psmlt(i, k))
1749 a_tmp5 = a_psmlt(i, k)
1750 a_psmlt(i, k) = 0.0_8
1752 CALL POPCONTROL1B(branch)
1753 IF (branch .EQ. 0) THEN
1760 a_qrs(i, k, 2) = a_qrs(i, k, 2) - a_tmp4/mstep(i)
1761 a_psmlt0 = dtcld*a_tmp3/mstep(i)
1762 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
1763 temp3 = den(i, k)*max6
1765 temp1 = (bvts+5.)/8.
1767 temp5 = (3*bvts+13.)/24.
1768 temp6 = den(i, k)**temp5
1770 temp8 = p(i, k)**temp7
1771 a_temp2 = psmlt_a*a_psmlt0
1772 a_temp3 = b*d*temp0*psmlt_b*a_psmlt0
1773 a_temp4 = temp8*temp6*psmlt_b*a_psmlt0
1774 a_b = d*temp0*a_temp4
1775 a_d = b*temp0*a_temp4
1776 IF (max9 .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. temp1 .NE. &
1780 a_max9 = temp1*max9**(temp1-1)*b*d*a_temp4
1782 IF (.NOT.(p(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. &
1783 & temp7 .NE. INT(temp7)))) a_p(i, k) = a_p(i, k) + temp7*p&
1784 & (i, k)**(temp7-1)*temp6*a_temp3
1785 a_a = c*temp2*a_temp2
1786 a_c = a*temp2*a_temp2
1787 IF (temp3 .EQ. 0.0_8) THEN
1790 a_temp1 = a*c*a_temp2/(2.0*temp2)
1792 IF (den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. temp5 &
1793 & .NE. INT(temp5))) THEN
1794 a_den(i, k) = a_den(i, k) + max6*a_temp1
1796 a_den(i, k) = a_den(i, k) + temp5*den(i, k)**(temp5-1)*&
1797 & temp8*a_temp3 + max6*a_temp1
1799 a_max6 = den(i, k)*a_temp1
1800 CALL POPCONTROL1B(branch)
1801 IF (branch .EQ. 0) THEN
1805 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max9
1807 CALL POPCONTROL1B(branch)
1808 IF (branch .EQ. 0) THEN
1810 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max6
1814 a_temp2 = t(i, k)**1.5*a_c/(t(i, k)+120.)
1817 temp3 = (t(i, k)+120.)**temp4
1819 temp0 = t(i, k)**temp1
1821 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. &
1822 & temp1 .NE. INT(temp1)))) a_t(i, k) = a_t(i, k) + temp1*t&
1823 & (i, k)**(temp1-1)*(t0c-t(i, k))*a_temp0
1824 IF (t(i, k) + 120. .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. &
1825 & temp4 .NE. INT(temp4))) THEN
1826 a_t(i, k) = a_t(i, k) - temp0*a_temp0
1828 a_t(i, k) = a_t(i, k) - (temp0+temp4*(t(i, k)+120.)**(&
1829 & temp4-1)*temp0*(t0c-t(i, k))/temp3)*a_temp0
1831 temp4 = (t0c-t(i, k))/(t(i, k)+120.)
1832 a_t(i, k) = a_t(i, k) + 1.5*t(i, k)**0.5*temp4*a_c - (temp4+&
1835 a_max5 = alpha*(3-bvts)*EXP(alpha*(3-bvts)*(max5/8.))*a_b/8.
1836 CALL POPCONTROL1B(branch)
1837 IF (branch .EQ. 0) THEN
1844 CALL POPCONTROL1B(branch)
1845 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y2
1847 a_max4 = alpha*EXP(alpha*(max4/2.))*a_a/2.
1848 CALL POPCONTROL1B(branch)
1849 IF (branch .EQ. 0) THEN
1856 CALL POPCONTROL1B(branch)
1857 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y1
1858 CALL POPREAL8(cpm(i, k))
1859 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
1866 CALL POPCONTROL1B(branch)
1867 IF (branch .NE. 0) THEN
1869 CALL POPREAL8(qrs(i, k, jj))
1870 a_tmp2 = -a_qrs(i, k, jj)
1871 CALL POPCONTROL1B(branch)
1872 IF (branch .EQ. 0) a_tmp2 = 0.0_8
1873 CALL POPCONTROL1B(branch)
1874 IF (branch .EQ. 0) THEN
1875 a_qrs(i, k, jj) = a_qrs(i, k, jj) + a_tmp2
1877 temp3 = delz(i, k+1)/delz(i, k)
1878 a_temp2 = dtcld*a_tmp2/den(i, k)
1879 a_falk(i, k, jj) = a_falk(i, k, jj) + a_temp2
1880 a_falk(i, k+1, jj) = a_falk(i, k+1, jj) - temp3*a_temp2
1881 a_temp1 = -(falk(i, k+1, jj)*a_temp2/delz(i, k))
1882 a_den(i, k) = a_den(i, k) - (falk(i, k, jj)-falk(i, k+1&
1883 & , jj)*temp3)*a_temp2/den(i, k)
1884 a_delz(i, k+1) = a_delz(i, k+1) + a_temp1
1885 a_delz(i, k) = a_delz(i, k) - temp3*a_temp1
1888 a_falk(i, k, 3) = a_falk(i, k, 3) + a_fall(i, k, 3)
1889 a_falk(i, k, 2) = a_falk(i, k, 2) + a_fall(i, k, 2)
1890 a_falk(i, k, 1) = a_falk(i, k, 1) + a_fall(i, k, 1)
1891 CALL POPREAL8(falk(i, k, 3))
1892 a_den(i, k) = a_den(i, k) + qrs(i, k, 3)*work1(i, k, 3)*&
1893 & a_falk(i, k, 3)/mstep(i) + qrs(i, k, 2)*work1(i, k, 2)*&
1894 & a_falk(i, k, 2)/mstep(i) + qrs(i, k, 1)*work1(i, k, 1)*&
1895 & a_falk(i, k, 1)/mstep(i)
1896 a_temp2 = den(i, k)*a_falk(i, k, 3)/mstep(i)
1897 a_falk(i, k, 3) = 0.0_8
1898 a_qrs(i, k, 3) = a_qrs(i, k, 3) + work1(i, k, 3)*a_temp2
1899 a_work1(i, k, 3) = a_work1(i, k, 3) + qrs(i, k, 3)*a_temp2
1900 CALL POPREAL8(falk(i, k, 2))
1901 a_temp2 = den(i, k)*a_falk(i, k, 2)/mstep(i)
1902 a_falk(i, k, 2) = 0.0_8
1903 a_qrs(i, k, 2) = a_qrs(i, k, 2) + work1(i, k, 2)*a_temp2
1904 a_work1(i, k, 2) = a_work1(i, k, 2) + qrs(i, k, 2)*a_temp2
1905 CALL POPREAL8(falk(i, k, 1))
1906 a_temp2 = den(i, k)*a_falk(i, k, 1)/mstep(i)
1907 a_falk(i, k, 1) = 0.0_8
1908 a_qrs(i, k, 1) = a_qrs(i, k, 1) + work1(i, k, 1)*a_temp2
1909 a_work1(i, k, 1) = a_work1(i, k, 1) + qrs(i, k, 1)*a_temp2
1915 CALL POPCONTROL1B(branch)
1916 IF (branch .NE. 0) THEN
1918 CALL POPREAL8(qrs(i, k, jj))
1919 a_tmp1 = -a_qrs(i, k, jj)
1920 CALL POPCONTROL1B(branch)
1921 IF (branch .EQ. 0) a_tmp1 = 0.0_8
1922 CALL POPCONTROL1B(branch)
1923 IF (branch .EQ. 0) THEN
1924 a_qrs(i, k, jj) = a_qrs(i, k, jj) + a_tmp1
1929 a_temp2 = dtcld*a_x1/den(i, k)
1930 a_falk(i, k, jj) = a_falk(i, k, jj) + a_temp2
1931 a_den(i, k) = a_den(i, k) - falk(i, k, jj)*a_temp2/den(i, k)
1933 a_falk(i, k, 3) = a_falk(i, k, 3) + a_fall(i, k, 3)
1934 a_falk(i, k, 2) = a_falk(i, k, 2) + a_fall(i, k, 2)
1935 a_falk(i, k, 1) = a_falk(i, k, 1) + a_fall(i, k, 1)
1936 CALL POPREAL8(falk(i, k, 3))
1937 a_den(i, k) = a_den(i, k) + qrs(i, k, 3)*work1(i, k, 3)*a_falk&
1938 & (i, k, 3)/mstep(i) + qrs(i, k, 2)*work1(i, k, 2)*a_falk(i, k&
1939 & , 2)/mstep(i) + qrs(i, k, 1)*work1(i, k, 1)*a_falk(i, k, 1)/&
1941 a_temp2 = den(i, k)*a_falk(i, k, 3)/mstep(i)
1942 a_falk(i, k, 3) = 0.0_8
1943 a_qrs(i, k, 3) = a_qrs(i, k, 3) + work1(i, k, 3)*a_temp2
1944 a_work1(i, k, 3) = a_work1(i, k, 3) + qrs(i, k, 3)*a_temp2
1945 CALL POPREAL8(falk(i, k, 2))
1946 a_temp2 = den(i, k)*a_falk(i, k, 2)/mstep(i)
1947 a_falk(i, k, 2) = 0.0_8
1948 a_qrs(i, k, 2) = a_qrs(i, k, 2) + work1(i, k, 2)*a_temp2
1949 a_work1(i, k, 2) = a_work1(i, k, 2) + qrs(i, k, 2)*a_temp2
1950 CALL POPREAL8(falk(i, k, 1))
1951 a_temp2 = den(i, k)*a_falk(i, k, 1)/mstep(i)
1952 a_falk(i, k, 1) = 0.0_8
1953 a_qrs(i, k, 1) = a_qrs(i, k, 1) + work1(i, k, 1)*a_temp2
1954 a_work1(i, k, 1) = a_work1(i, k, 1) + qrs(i, k, 1)*a_temp2
1960 CALL POPCONTROL1B(branch)
1964 CALL POPCONTROL1B(branch)
1965 CALL POPCONTROL1B(branch)
1967 temp3 = max3**temp4/delz(i, k)
1968 temp2 = (bvtg-2.)/4.
1969 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
1970 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2*&
1971 & den(i, k)**(temp2-1)*temp3*vt2g_a*a_work1(i, k, 3)
1972 a_temp1 = den(i, k)**temp2*vt2g_a*a_work1(i, k, 3)/delz(i, k)
1973 a_work1(i, k, 3) = 0.0_8
1974 IF (max3 .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. temp4 .NE. INT(&
1978 a_max3 = temp4*max3**(temp4-1)*a_temp1
1980 a_delz(i, k) = a_delz(i, k) - temp3*a_temp1
1981 CALL POPCONTROL1B(branch)
1982 IF (branch .EQ. 0) THEN
1984 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max3
1988 temp1 = -(bvts*alpha*max8/4.)
1990 temp2 = max2**temp/delz(i, k)
1991 temp3 = (bvts-2.)/4.
1992 temp4 = den(i, k)**temp3
1993 a_temp = EXP(temp1)*vt2s_a*a_work1(i, k, 2)
1994 a_max8 = -(bvts*alpha*EXP(temp1)*temp4*temp2*vt2s_a*a_work1(i, k&
1996 a_work1(i, k, 2) = 0.0_8
1997 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. &
1998 & temp3 .NE. INT(temp3)))) a_den(i, k) = a_den(i, k) + temp3*&
1999 & den(i, k)**(temp3-1)*temp2*a_temp
2000 a_temp0 = temp4*a_temp/delz(i, k)
2001 IF (max2 .LE. 0.0_8 .AND. (temp .EQ. 0.0_8 .OR. temp .NE. INT(&
2005 a_max2 = temp*max2**(temp-1)*a_temp0
2007 a_delz(i, k) = a_delz(i, k) - temp2*a_temp0
2008 CALL POPCONTROL1B(branch)
2009 IF (branch .EQ. 0) THEN
2016 CALL POPCONTROL1B(branch)
2017 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y3
2018 CALL POPCONTROL1B(branch)
2019 IF (branch .EQ. 0) THEN
2021 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max2
2026 temp0 = max1**temp/delz(i, k)
2027 temp1 = (bvtr-2.)/4.
2028 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. &
2029 & temp1 .NE. INT(temp1)))) a_den(i, k) = a_den(i, k) + temp1*&
2030 & den(i, k)**(temp1-1)*temp0*vt2r_a*a_work1(i, k, 1)
2031 a_temp = den(i, k)**temp1*vt2r_a*a_work1(i, k, 1)/delz(i, k)
2032 a_work1(i, k, 1) = 0.0_8
2033 IF (max1 .LE. 0.0_8 .AND. (temp .EQ. 0.0_8 .OR. temp .NE. INT(&
2037 a_max1 = temp*max1**(temp-1)*a_temp
2039 a_delz(i, k) = a_delz(i, k) - temp0*a_temp
2040 CALL POPCONTROL1B(branch)
2041 IF (branch .EQ. 0) THEN
2043 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max1
2049 END SUBROUTINE A_FALLK
2051 !=======================================================================
2053 !=======================================================================
2054 SUBROUTINE FALLK(cpm, t, p, q, den, qrs, delz, dtcld, falk, fall, kte&
2055 & , kts, its, ite, kme, kms, ims, ime)
2057 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2058 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, falk, fall, work1
2059 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, p, q
2060 REAL, DIMENSION(its:ite, kts:kte) :: psmlt, pgmlt, t, work2, cpm
2061 INTEGER, DIMENSION(its:ite) :: mstep, numdt
2062 REAL :: dtcld, coeres1, coeres2, coeresi, coeresh, xlf, psmlt0, &
2063 & pgmlt0, help_i, help_h, w1
2064 REAL :: tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8
2065 INTEGER :: mstepmax, k, i, n, nw, jj
2066 REAL :: fqs, fqg, supcol, a, b, c, d
2096 IF (qcrmin .LT. qrs(i, k, 1)) THEN
2101 work1(i, k, 1) = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.&
2103 IF (qcrmin .LT. qrs(i, k, 2)) THEN
2108 IF (90. .GT. t0c - t(i, k)) THEN
2113 IF (0. .LT. y3) THEN
2118 work1(i, k, 2) = vt2s_a*den(i, k)**((bvts-2.)/4.)*max2**(bvts/4.&
2119 & )/delz(i, k)*EXP(-(bvts*alpha*max8/4.))
2120 IF (qcrmin .LT. qrs(i, k, 3)) THEN
2125 work1(i, k, 3) = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max3**(bvtg/4.&
2127 IF (work1(i, k, 1) .GE. work1(i, k, 2) .AND. work1(i, k, 1) .GE.&
2128 & work1(i, k, 3)) THEN
2130 ELSE IF (work1(i, k, 2) .GE. work1(i, k, 1) .AND. work1(i, k, 2)&
2131 & .GE. work1(i, k, 3)) THEN
2136 nw = NINT(w1*dtcld + .5)
2142 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
2146 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
2150 IF (n .LE. mstep(i)) THEN
2152 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(i)
2153 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(i)
2154 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(i)
2155 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
2156 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
2157 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
2159 x1 = falk(i, k, jj)*dtcld/den(i, k)
2160 IF (x1 .GT. qrs(i, k, jj)) THEN
2161 tmp1 = qrs(i, k, jj)
2165 IF (tmp1 .GE. 0.) THEN
2170 IF (abs0 .LT. qmin) tmp1 = 0.
2171 qrs(i, k, jj) = qrs(i, k, jj) - tmp1
2177 IF (n .LE. mstep(i)) THEN
2178 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(&
2180 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(&
2182 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(&
2184 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
2185 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
2186 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
2188 IF ((falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/delz(i, &
2189 & k))*dtcld/den(i, k) .GT. qrs(i, k, jj)) THEN
2190 tmp2 = qrs(i, k, jj)
2192 tmp2 = (falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/&
2193 & delz(i, k))*dtcld/den(i, k)
2195 IF (tmp2 .GE. 0.) THEN
2200 IF (abs1 .LT. qmin) tmp2 = 0.
2201 qrs(i, k, jj) = qrs(i, k, jj) - tmp2
2208 IF (n .LE. mstep(i)) THEN
2210 !---------------------------------------------------------------
2211 ! psmlt: melting of snow [RH83 A25]
2212 ! (T>T0: S->R) psmlt<0: min=-qrs(i,k,2), max=0
2213 !---------------------------------------------------------------
2215 cpm(i, k) = CPMCAL(q(i, k))
2217 IF (90. .GT. t0c - t(i, k)) THEN
2222 IF (0. .LT. y1) THEN
2227 a = EXP(alpha*max4/2.)
2228 IF (90. .GT. t0c - t(i, k)) THEN
2233 IF (0. .LT. y2) THEN
2238 b = EXP(alpha*max5*(3-bvts)/8.)
2239 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
2240 d = t(i, k)**(3.88/6.)*(t0c-t(i, k))/(t(i, k)+120.)**(5./6.)
2241 IF (qrs(i, k, 2) .LT. qcrmin) THEN
2246 IF (qrs(i, k, 2) .LT. qcrmin) THEN
2251 psmlt0 = psmlt_a*a*c*SQRT(den(i, k)*max6) + psmlt_b*b*d*p(i&
2252 & , k)**(1./3.)*den(i, k)**((13.+3*bvts)/24.)*max9**((5.+&
2254 tmp3 = psmlt0*dtcld/mstep(i)
2255 tmp4 = -(qrs(i, k, 2)/mstep(i))
2256 IF (tmp3 .GT. tmp4) THEN
2261 IF (tmp5 .LT. 0.) THEN
2266 IF (psmlt(i, k) .GE. 0.) THEN
2271 IF (abs2 .LT. qmin) psmlt(i, k) = 0.
2272 IF (qrs(i, k, 2) + psmlt(i, k) .LT. 0.) THEN
2275 qrs(i, k, 2) = qrs(i, k, 2) + psmlt(i, k)
2277 IF (qrs(i, k, 1) - psmlt(i, k) .LT. 0.) THEN
2280 qrs(i, k, 1) = qrs(i, k, 1) - psmlt(i, k)
2282 t(i, k) = t(i, k) + xlf/cpm(i, k)*psmlt(i, k)
2286 !---------------------------------------------------------------
2287 ! pgmlt: melting of graupel [LFO 47]
2288 ! (T>T0: G->R) pgmlt<0: min=-qrs(i,k,3), max=0
2289 !---------------------------------------------------------------
2292 IF (n .LE. mstep(i)) THEN
2295 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
2296 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
2297 d = t(i, k)**(3.88/6.)*(t0c-t(i, k))/(t(i, k)+120.)**(5./6.)
2298 IF (qrs(i, k, 3) .LT. qcrmin) THEN
2303 IF (qrs(i, k, 3) .LT. qcrmin) THEN
2306 max10 = qrs(i, k, 3)
2308 pgmlt0 = pgmlt_a*c*SQRT(den(i, k)*max7) + pgmlt_b*d*p(i, k)&
2309 & **(1./3.)*den(i, k)**((13.+3*bvtg)/24.)*max10**((5.+bvtg)/&
2311 tmp6 = pgmlt0*dtcld/mstep(i)
2312 tmp7 = -(qrs(i, k, 3)/mstep(i))
2313 IF (tmp6 .GT. tmp7) THEN
2318 IF (tmp8 .LT. 0.) THEN
2323 IF (pgmlt(i, k) .GE. 0.) THEN
2328 IF (abs3 .LT. qmin) pgmlt(i, k) = 0.
2329 IF (qrs(i, k, 3) + pgmlt(i, k) .LT. 0.) THEN
2332 qrs(i, k, 3) = qrs(i, k, 3) + pgmlt(i, k)
2334 IF (qrs(i, k, 1) - pgmlt(i, k) .LT. 0.) THEN
2337 qrs(i, k, 1) = qrs(i, k, 1) - pgmlt(i, k)
2339 t(i, k) = t(i, k) + xlf/cpm(i, k)*pgmlt(i, k)
2344 END SUBROUTINE FALLK
2346 ! Differentiation of fallkc in reverse (adjoint) mode (with options r8):
2347 ! gradient of useful results: fallc delz den qci
2348 ! with respect to varying inputs: fallc delz den qci
2349 !=======================================================================
2351 !=======================================================================
2352 SUBROUTINE A_FALLKC(qci, a_qci, fallc, a_fallc, den, a_den, delz, &
2353 & a_delz, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
2355 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2356 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2357 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
2358 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den
2359 REAL, DIMENSION(ims:ime, kms:kme) :: a_delz, a_den
2360 REAL, DIMENSION(its:ite, kts:kte) :: falkc, work1c, work2c, xni, &
2362 REAL, DIMENSION(its:ite, kts:kte) :: a_falkc, a_fallc
2363 INTEGER, DIMENSION(its:ite) :: mstep, numdt
2364 REAL :: dtcld, xmi, diameter, temp1, temp2, temp3, temp4, temp5, &
2366 REAL :: a_temp3, a_temp4
2367 INTEGER :: mstepmax, k, i, n
2389 work1c(i, k) = vt2i_a*(den(i, k)*qci(i, k, 2))**(1.31/8.)
2390 work2c(i, k) = work1c(i, k)/delz(i, k)
2391 x1 = NINT(work2c(i, k)*dtcld + .5)
2397 IF (numdt(i) .GE. mstep(i)) THEN
2398 CALL PUSHCONTROL1B(1)
2401 CALL PUSHCONTROL1B(0)
2406 IF (mstepmax .LE. mstep(i)) THEN
2407 CALL PUSHCONTROL1B(1)
2410 CALL PUSHCONTROL1B(0)
2416 IF (n .LE. mstep(i)) THEN
2417 CALL PUSHREAL8(falkc(i, k))
2418 falkc(i, k) = falli_a*(den(i, k)*qci(i, k, 2))**(9.31/8.)/delz&
2420 x2 = falkc(i, k)*dtcld/den(i, k)
2421 IF (x2 .GT. qci(i, k, 2)) THEN
2422 temp3 = qci(i, k, 2)
2423 CALL PUSHCONTROL1B(0)
2426 CALL PUSHCONTROL1B(1)
2428 IF (temp3 .GE. 0.) THEN
2433 IF (abs0 .LT. qmin) THEN
2435 CALL PUSHCONTROL1B(0)
2437 CALL PUSHCONTROL1B(1)
2439 CALL PUSHREAL8(qci(i, k, 2))
2440 qci(i, k, 2) = qci(i, k, 2) - temp3
2441 CALL PUSHCONTROL1B(1)
2443 CALL PUSHCONTROL1B(0)
2446 CALL PUSHINTEGER4(k)
2449 IF (n .LE. mstep(i)) THEN
2450 CALL PUSHREAL8(falkc(i, k))
2451 falkc(i, k) = falli_a*(den(i, k)*qci(i, k, 2))**(9.31/8.)/&
2452 & delz(i, k)/mstep(i)
2453 IF ((falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k))*&
2454 & dtcld/den(i, k) .GT. qci(i, k, 2)) THEN
2455 temp4 = qci(i, k, 2)
2456 CALL PUSHCONTROL1B(0)
2458 temp4 = (falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k)&
2460 CALL PUSHCONTROL1B(1)
2462 IF (temp4 .GE. 0.) THEN
2467 IF (abs1 .LT. qmin) THEN
2469 CALL PUSHCONTROL1B(0)
2471 CALL PUSHCONTROL1B(1)
2473 CALL PUSHREAL8(qci(i, k, 2))
2474 qci(i, k, 2) = qci(i, k, 2) - temp4
2475 CALL PUSHCONTROL1B(1)
2477 CALL PUSHCONTROL1B(0)
2486 CALL POPCONTROL1B(branch)
2487 IF (branch .NE. 0) THEN
2488 CALL POPREAL8(qci(i, k, 2))
2489 a_temp4 = -a_qci(i, k, 2)
2490 CALL POPCONTROL1B(branch)
2491 IF (branch .EQ. 0) a_temp4 = 0.0_8
2492 CALL POPCONTROL1B(branch)
2493 IF (branch .EQ. 0) THEN
2494 a_qci(i, k, 2) = a_qci(i, k, 2) + a_temp4
2496 temp7 = falkc(i, k+1)/delz(i, k)
2497 a_temp1 = dtcld*a_temp4/den(i, k)
2498 a_falkc(i, k) = a_falkc(i, k) + a_temp1
2499 a_temp0 = -(delz(i, k+1)*a_temp1/delz(i, k))
2500 a_delz(i, k+1) = a_delz(i, k+1) - temp7*a_temp1
2501 a_den(i, k) = a_den(i, k) - (falkc(i, k)-temp7*delz(i, k+1&
2502 & ))*a_temp1/den(i, k)
2503 a_falkc(i, k+1) = a_falkc(i, k+1) + a_temp0
2504 a_delz(i, k) = a_delz(i, k) - temp7*a_temp0
2506 a_falkc(i, k) = a_falkc(i, k) + a_fallc(i, k)
2507 CALL POPREAL8(falkc(i, k))
2508 temp8 = mstep(i)*delz(i, k)
2509 temp6 = den(i, k)*qci(i, k, 2)
2511 a_temp0 = falli_a*a_falkc(i, k)/temp8
2512 a_falkc(i, k) = 0.0_8
2513 IF (temp6 .LE. 0.0_8 .AND. (temp .EQ. 0.0_8 .OR. temp .NE. &
2517 a_temp = temp*temp6**(temp-1)*a_temp0
2519 a_delz(i, k) = a_delz(i, k) - mstep(i)*temp6**temp*a_temp0/&
2521 a_den(i, k) = a_den(i, k) + qci(i, k, 2)*a_temp
2522 a_qci(i, k, 2) = a_qci(i, k, 2) + den(i, k)*a_temp
2528 CALL POPCONTROL1B(branch)
2529 IF (branch .NE. 0) THEN
2530 CALL POPREAL8(qci(i, k, 2))
2531 a_temp3 = -a_qci(i, k, 2)
2532 CALL POPCONTROL1B(branch)
2533 IF (branch .EQ. 0) a_temp3 = 0.0_8
2534 CALL POPCONTROL1B(branch)
2535 IF (branch .EQ. 0) THEN
2536 a_qci(i, k, 2) = a_qci(i, k, 2) + a_temp3
2541 a_temp1 = dtcld*a_x2/den(i, k)
2542 a_falkc(i, k) = a_falkc(i, k) + a_temp1 + a_fallc(i, k)
2543 temp = mstep(i)*delz(i, k)
2544 temp7 = den(i, k)*qci(i, k, 2)
2546 a_temp = falli_a*a_falkc(i, k)/temp
2547 a_falkc(i, k) = 0.0_8
2548 IF (temp7 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. &
2552 a_temp0 = temp8*temp7**(temp8-1)*a_temp
2554 a_den(i, k) = a_den(i, k) + qci(i, k, 2)*a_temp0 - falkc(i, k)&
2555 & *a_temp1/den(i, k)
2556 CALL POPREAL8(falkc(i, k))
2557 a_delz(i, k) = a_delz(i, k) - mstep(i)*temp7**temp8*a_temp/&
2559 a_qci(i, k, 2) = a_qci(i, k, 2) + den(i, k)*a_temp0
2564 CALL POPCONTROL1B(branch)
2568 CALL POPCONTROL1B(branch)
2571 END SUBROUTINE A_FALLKC
2573 !=======================================================================
2575 !=======================================================================
2576 SUBROUTINE FALLKC(qci, fallc, den, delz, dtcld, kte, kts, its, ite, &
2577 & kme, kms, ims, ime)
2579 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2580 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2581 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den
2582 REAL, DIMENSION(its:ite, kts:kte) :: falkc, work1c, work2c, xni, &
2584 INTEGER, DIMENSION(its:ite) :: mstep, numdt
2585 REAL :: dtcld, xmi, diameter, temp1, temp2, temp3, temp4, temp5, &
2587 INTEGER :: mstepmax, k, i, n
2601 work1c(i, k) = vt2i_a*(den(i, k)*qci(i, k, 2))**(1.31/8.)
2602 work2c(i, k) = work1c(i, k)/delz(i, k)
2603 x1 = NINT(work2c(i, k)*dtcld + .5)
2609 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
2613 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
2618 IF (n .LE. mstep(i)) THEN
2619 falkc(i, k) = falli_a*(den(i, k)*qci(i, k, 2))**(9.31/8.)/delz&
2621 fallc(i, k) = fallc(i, k) + falkc(i, k)
2622 x2 = falkc(i, k)*dtcld/den(i, k)
2623 IF (x2 .GT. qci(i, k, 2)) THEN
2624 temp3 = qci(i, k, 2)
2628 IF (temp3 .GE. 0.) THEN
2633 IF (abs0 .LT. qmin) temp3 = 0.
2634 qci(i, k, 2) = qci(i, k, 2) - temp3
2639 IF (n .LE. mstep(i)) THEN
2640 falkc(i, k) = falli_a*(den(i, k)*qci(i, k, 2))**(9.31/8.)/&
2641 & delz(i, k)/mstep(i)
2642 fallc(i, k) = fallc(i, k) + falkc(i, k)
2643 IF ((falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k))*&
2644 & dtcld/den(i, k) .GT. qci(i, k, 2)) THEN
2645 temp4 = qci(i, k, 2)
2647 temp4 = (falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k)&
2650 IF (temp4 .GE. 0.) THEN
2655 IF (abs1 .LT. qmin) temp4 = 0.
2656 qci(i, k, 2) = qci(i, k, 2) - temp4
2661 END SUBROUTINE FALLKC
2663 ! Differentiation of rainsc in reverse (adjoint) mode (with options r8):
2664 ! gradient of useful results: fallc t cpm xl delz den qrs
2665 ! fall rain qci rainncv
2666 ! with respect to varying inputs: fallc t cpm xl delz den qrs
2667 ! fall rain qci rainncv
2668 !=======================================================================
2670 !=======================================================================
2671 SUBROUTINE A_RAINSC(fall, a_fall, fallc, a_fallc, xl, a_xl, t, a_t, q&
2672 & , qci, a_qci, cpm, a_cpm, den, a_den, qrs, a_qrs, delz, a_delz, rain&
2673 & , a_rain, rainncv, a_rainncv, dtcld, kte, kts, its, ite, kme, kms, &
2676 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2677 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, fall
2678 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs, a_fall
2679 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2680 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
2681 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, q
2682 REAL, DIMENSION(ims:ime, kms:kme) :: a_delz, a_den
2683 REAL, DIMENSION(its:ite, kts:kte) :: xl, t, cpm, fallc
2684 REAL, DIMENSION(its:ite, kts:kte) :: a_xl, a_t, a_cpm, a_fallc
2685 REAL, DIMENSION(ims:ime) :: rain, rainncv
2686 REAL, DIMENSION(ims:ime) :: a_rain, a_rainncv
2688 REAL :: dtcld, fallsum, supcol, xlf, temp, temp0, pfrzdtr, pfrzdtc
2689 REAL :: a_fallsum, a_supcol, a_xlf, a_temp, a_pfrzdtr, a_pfrzdtc
2690 REAL :: ft0, ft40, fsupcol, fqc, fqi, fqr, qtmp
2691 REAL :: a_ft0, a_ft40, a_qtmp
2717 fallsum = fall(i, kts, 1) + fall(i, kts, 2) + fall(i, kts, 3) + &
2719 IF (fallsum .GT. qmin) THEN
2720 CALL PUSHCONTROL1B(1)
2722 CALL PUSHCONTROL1B(0)
2727 !---------------------------------------------------------------
2728 ! pimlt: instantaneous melting of cloud ice [RH83 A28]
2729 ! (T>T0: I->C) pimlt=qci(i,k,2) t-
2730 !---------------------------------------------------------------
2732 xl(i, k) = XLCAL(t(i, k))
2733 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2735 xlf = xls - xl(i, k)
2736 supcol = t0c - t(i, k)
2737 IF (supcol .LT. 0.) THEN
2739 CALL PUSHCONTROL1B(1)
2741 CALL PUSHCONTROL1B(0)
2744 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
2745 IF (qci(i, k, 2) .LT. 0.) THEN
2746 CALL PUSHREAL8(max1)
2748 CALL PUSHCONTROL1B(0)
2750 CALL PUSHREAL8(max1)
2752 CALL PUSHCONTROL1B(1)
2754 CALL PUSHREAL8(qtmp)
2756 IF (qtmp .GE. 0.) THEN
2761 IF (abs0 .LT. qmin) THEN
2763 CALL PUSHCONTROL1B(1)
2765 CALL PUSHCONTROL1B(0)
2767 IF (qci(i, k, 1) + qtmp .LT. 0.) THEN
2769 CALL PUSHCONTROL1B(0)
2771 qci(i, k, 1) = qci(i, k, 1) + qtmp
2772 CALL PUSHCONTROL1B(1)
2774 IF (qci(i, k, 2) - qtmp .LT. 0.) THEN
2776 CALL PUSHCONTROL1B(0)
2778 qci(i, k, 2) = qci(i, k, 2) - qtmp
2779 CALL PUSHCONTROL1B(1)
2781 CALL PUSHREAL8(t(i, k))
2782 t(i, k) = t(i, k) - xlf/cpm(i, k)*qtmp
2783 !---------------------------------------------------------------
2784 ! pihmf: homogeneous freezing of cloud water below -40c
2785 ! (T<-40C: C->I) min=0,pihmf=qci(i,k,1) t+
2786 !---------------------------------------------------------------
2788 xl(i, k) = XLCAL(t(i, k))
2789 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2791 xlf = xls - xl(i, k)
2792 supcol = t0c - t(i, k)
2793 IF (supcol .LT. 0.) THEN
2795 CALL PUSHCONTROL1B(1)
2797 CALL PUSHCONTROL1B(0)
2799 CALL PUSHREAL8(ft40)
2800 CALL SMOOTHIF(supcol, 40., ft40, 't0')
2801 IF (ft40*qci(i, k, 1) .LT. 0.) THEN
2802 CALL PUSHREAL8(qtmp)
2804 CALL PUSHCONTROL1B(0)
2806 CALL PUSHREAL8(qtmp)
2807 qtmp = ft40*qci(i, k, 1)
2808 CALL PUSHCONTROL1B(1)
2810 IF (qtmp .GE. 0.) THEN
2816 IF (abs1 .LT. qmin) THEN
2818 CALL PUSHCONTROL1B(1)
2820 CALL PUSHCONTROL1B(0)
2822 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2823 CALL PUSHREAL8(qci(i, k, 2))
2825 CALL PUSHCONTROL1B(0)
2827 CALL PUSHREAL8(qci(i, k, 2))
2828 qci(i, k, 2) = qci(i, k, 2) + qtmp
2829 CALL PUSHCONTROL1B(1)
2831 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2832 CALL PUSHREAL8(qci(i, k, 1))
2834 CALL PUSHCONTROL1B(0)
2836 CALL PUSHREAL8(qci(i, k, 1))
2837 qci(i, k, 1) = qci(i, k, 1) - qtmp
2838 CALL PUSHCONTROL1B(1)
2840 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
2841 !---------------------------------------------------------------
2842 ! pihtf: heterogeneous freezing of cloud water
2843 ! (T0>T>-40C: C->I) max=qci(i,k,1),min=0. t+
2844 !---------------------------------------------------------------
2846 xl(i, k) = XLCAL(t(i, k))
2847 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2849 xlf = xls - xl(i, k)
2850 CALL PUSHREAL8(supcol)
2851 supcol = t0c - t(i, k)
2852 IF (supcol .LT. 0.) THEN
2854 CALL PUSHCONTROL1B(1)
2856 CALL PUSHCONTROL1B(0)
2858 !t>-40C=t0c-40,t0c-t<40, supcol<40,-supcol>-40
2860 CALL PUSHREAL8(ft40)
2861 CALL SMOOTHIF(arg0, -40., ft40, 't0')
2862 x1 = pfrz1*(EXP(pfrz2*supcol)-1.)*den(i, k)/denr/xncr*qci(i, k, &
2863 & 1)*qci(i, k, 1)*dtcld
2864 IF (x1 .GT. qci(i, k, 1)) THEN
2865 CALL PUSHREAL8(pfrzdtc)
2866 pfrzdtc = qci(i, k, 1)
2867 CALL PUSHCONTROL1B(0)
2869 CALL PUSHREAL8(pfrzdtc)
2871 CALL PUSHCONTROL1B(1)
2873 IF (ft40*pfrzdtc .LT. 0.) THEN
2874 CALL PUSHREAL8(qtmp)
2876 CALL PUSHCONTROL1B(0)
2878 CALL PUSHREAL8(qtmp)
2880 CALL PUSHCONTROL1B(1)
2882 IF (qtmp .GE. 0.) THEN
2888 IF (abs2 .LT. qmin) THEN
2890 CALL PUSHCONTROL1B(1)
2892 CALL PUSHCONTROL1B(0)
2894 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2895 CALL PUSHREAL8(qci(i, k, 2))
2897 CALL PUSHCONTROL1B(0)
2899 CALL PUSHREAL8(qci(i, k, 2))
2900 qci(i, k, 2) = qci(i, k, 2) + qtmp
2901 CALL PUSHCONTROL1B(1)
2903 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2904 CALL PUSHCONTROL1B(0)
2906 CALL PUSHCONTROL1B(1)
2908 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
2909 !---------------------------------------------------------------
2910 ! pgfrz: freezing of rain water [LFO 45]
2911 ! (T<T0, R->G) max=qrs(i,k,1),min=0. t+
2912 !---------------------------------------------------------------
2914 xl(i, k) = XLCAL(t(i, k))
2915 ! cpm(i,k)=cpmcal(q(i,k))!not change
2917 xlf = xls - xl(i, k)
2918 CALL PUSHREAL8(supcol)
2919 supcol = t0c - t(i, k)
2920 IF (supcol .LT. 0.) THEN
2922 CALL PUSHCONTROL1B(0)
2924 CALL PUSHCONTROL1B(1)
2926 IF (qrs(i, k, 1) .GT. 0.) THEN
2927 temp = pgfrz_a*(EXP(pfrz2*supcol)-1.)*den(i, k)**(3./4.)*qrs(i&
2929 CALL PUSHCONTROL1B(1)
2932 CALL PUSHCONTROL1B(0)
2934 IF (temp*dtcld .GT. qrs(i, k, 1)) THEN
2935 pfrzdtr = qrs(i, k, 1)
2936 CALL PUSHCONTROL1B(0)
2938 pfrzdtr = temp*dtcld
2939 CALL PUSHCONTROL1B(1)
2941 IF (pfrzdtr .LT. 0.) THEN
2942 CALL PUSHREAL8(qtmp)
2944 CALL PUSHCONTROL1B(0)
2946 CALL PUSHREAL8(qtmp)
2948 CALL PUSHCONTROL1B(1)
2950 IF (qtmp .GE. 0.) THEN
2955 IF (abs3 .LT. qmin) THEN
2957 CALL PUSHCONTROL1B(1)
2959 CALL PUSHCONTROL1B(0)
2961 IF (qrs(i, k, 3) + qtmp .LT. 0.) THEN
2962 CALL PUSHREAL8(qrs(i, k, 3))
2964 CALL PUSHCONTROL1B(0)
2966 CALL PUSHREAL8(qrs(i, k, 3))
2967 qrs(i, k, 3) = qrs(i, k, 3) + qtmp
2968 CALL PUSHCONTROL1B(1)
2970 IF (qrs(i, k, 1) - qtmp .LT. 0.) THEN
2971 CALL PUSHCONTROL1B(0)
2973 CALL PUSHCONTROL1B(1)
2979 a_temp3 = a_t(i, k)/cpm(i, k)
2980 a_xlf = qtmp*a_temp3
2981 a_qtmp = xlf*a_temp3
2982 a_cpm(i, k) = a_cpm(i, k) - xlf*qtmp*a_temp3/cpm(i, k)
2983 CALL POPCONTROL1B(branch)
2984 IF (branch .EQ. 0) THEN
2985 a_qrs(i, k, 1) = 0.0_8
2987 a_qtmp = a_qtmp - a_qrs(i, k, 1)
2989 CALL POPCONTROL1B(branch)
2990 IF (branch .EQ. 0) THEN
2991 CALL POPREAL8(qrs(i, k, 3))
2992 a_qrs(i, k, 3) = 0.0_8
2994 CALL POPREAL8(qrs(i, k, 3))
2995 a_qtmp = a_qtmp + a_qrs(i, k, 3)
2997 CALL POPCONTROL1B(branch)
2998 IF (branch .NE. 0) a_qtmp = 0.0_8
2999 CALL POPCONTROL1B(branch)
3000 IF (branch .EQ. 0) THEN
3007 CALL POPCONTROL1B(branch)
3008 IF (branch .EQ. 0) THEN
3009 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_pfrzdtr
3012 a_temp = dtcld*a_pfrzdtr
3014 CALL POPCONTROL1B(branch)
3015 IF (branch .EQ. 0) THEN
3018 supcol = t0c - t(i, k)
3021 temp1 = den(i, k)**temp2
3022 temp5 = EXP(pfrz2*supcol) - 1.
3023 a_temp2 = qrs(i, k, 1)**temp4*pgfrz_a*a_temp
3024 IF (.NOT.(qrs(i, k, 1) .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR.&
3025 & temp4 .NE. INT(temp4)))) a_qrs(i, k, 1) = a_qrs(i, k, 1) +&
3026 & temp4*qrs(i, k, 1)**(temp4-1)*temp5*temp1*pgfrz_a*a_temp
3027 a_supcol = pfrz2*EXP(pfrz2*supcol)*temp1*a_temp2
3028 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
3029 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2&
3030 & *den(i, k)**(temp2-1)*temp5*a_temp2
3032 CALL POPCONTROL1B(branch)
3033 IF (branch .EQ. 0) a_xlf = 0.0_8
3034 CALL POPREAL8(supcol)
3035 a_t(i, k) = a_t(i, k) - a_supcol
3037 a_xl(i, k) = a_xl(i, k) - a_xlf
3038 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
3040 a_temp1 = a_t(i, k)/cpm(i, k)
3041 a_xlf = qtmp*a_temp1
3042 a_qtmp = xlf*a_temp1
3043 a_cpm(i, k) = a_cpm(i, k) - xlf*qtmp*a_temp1/cpm(i, k)
3044 CALL POPCONTROL1B(branch)
3045 IF (branch .EQ. 0) THEN
3046 a_qci(i, k, 1) = 0.0_8
3048 a_qtmp = a_qtmp - a_qci(i, k, 1)
3050 CALL POPCONTROL1B(branch)
3051 IF (branch .EQ. 0) THEN
3052 CALL POPREAL8(qci(i, k, 2))
3053 a_qci(i, k, 2) = 0.0_8
3055 CALL POPREAL8(qci(i, k, 2))
3056 a_qtmp = a_qtmp + a_qci(i, k, 2)
3058 CALL POPCONTROL1B(branch)
3059 IF (branch .NE. 0) a_qtmp = 0.0_8
3060 CALL POPCONTROL1B(branch)
3061 IF (branch .EQ. 0) THEN
3067 a_ft40 = pfrzdtc*a_qtmp
3068 a_pfrzdtc = ft40*a_qtmp
3070 CALL POPCONTROL1B(branch)
3071 IF (branch .EQ. 0) THEN
3072 CALL POPREAL8(pfrzdtc)
3073 a_qci(i, k, 1) = a_qci(i, k, 1) + a_pfrzdtc
3076 CALL POPREAL8(pfrzdtc)
3079 temp2 = den(i, k)/(denr*xncr)
3080 temp3 = qci(i, k, 1)
3081 a_temp0 = pfrz1*dtcld*a_x1
3082 a_supcol = pfrz2*EXP(pfrz2*supcol)*temp3**2*temp2*a_temp0
3083 a_temp1 = (EXP(pfrz2*supcol)-1.)*a_temp0
3084 a_qci(i, k, 1) = a_qci(i, k, 1) + 2*temp3*temp2*a_temp1
3085 a_den(i, k) = a_den(i, k) + temp3**2*a_temp1/(denr*xncr)
3088 CALL A_SMOOTHIF(arg0, a_arg0, -40., ft40, a_ft40, 't0')
3089 a_supcol = a_supcol - a_arg0
3090 CALL POPCONTROL1B(branch)
3091 IF (branch .NE. 0) a_xlf = 0.0_8
3092 CALL POPREAL8(supcol)
3093 a_t(i, k) = a_t(i, k) - a_supcol
3095 a_xl(i, k) = a_xl(i, k) - a_xlf
3096 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
3098 a_temp0 = a_t(i, k)/cpm(i, k)
3099 a_xlf = qtmp*a_temp0
3100 a_qtmp = xlf*a_temp0
3101 a_cpm(i, k) = a_cpm(i, k) - xlf*qtmp*a_temp0/cpm(i, k)
3102 CALL POPCONTROL1B(branch)
3103 IF (branch .EQ. 0) THEN
3104 CALL POPREAL8(qci(i, k, 1))
3105 a_qci(i, k, 1) = 0.0_8
3107 CALL POPREAL8(qci(i, k, 1))
3108 a_qtmp = a_qtmp - a_qci(i, k, 1)
3110 CALL POPCONTROL1B(branch)
3111 IF (branch .EQ. 0) THEN
3112 CALL POPREAL8(qci(i, k, 2))
3113 a_qci(i, k, 2) = 0.0_8
3115 CALL POPREAL8(qci(i, k, 2))
3116 a_qtmp = a_qtmp + a_qci(i, k, 2)
3118 CALL POPCONTROL1B(branch)
3119 IF (branch .NE. 0) a_qtmp = 0.0_8
3120 CALL POPCONTROL1B(branch)
3121 IF (branch .EQ. 0) THEN
3126 a_ft40 = qci(i, k, 1)*a_qtmp
3127 a_qci(i, k, 1) = a_qci(i, k, 1) + ft40*a_qtmp
3131 CALL A_SMOOTHIF(supcol, a_supcol, 40., ft40, a_ft40, 't0')
3132 CALL POPCONTROL1B(branch)
3133 IF (branch .NE. 0) a_xlf = 0.0_8
3134 a_t(i, k) = a_t(i, k) - a_supcol
3136 a_xl(i, k) = a_xl(i, k) - a_xlf
3137 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
3139 CALL POPREAL8(t(i, k))
3140 a_temp0 = -(a_t(i, k)/cpm(i, k))
3141 a_xlf = qtmp*a_temp0
3142 a_qtmp = xlf*a_temp0
3143 a_cpm(i, k) = a_cpm(i, k) - xlf*qtmp*a_temp0/cpm(i, k)
3144 CALL POPCONTROL1B(branch)
3145 IF (branch .EQ. 0) THEN
3146 a_qci(i, k, 2) = 0.0_8
3148 a_qtmp = a_qtmp - a_qci(i, k, 2)
3150 CALL POPCONTROL1B(branch)
3151 IF (branch .EQ. 0) THEN
3152 a_qci(i, k, 1) = 0.0_8
3154 a_qtmp = a_qtmp + a_qci(i, k, 1)
3156 CALL POPCONTROL1B(branch)
3157 IF (branch .NE. 0) a_qtmp = 0.0_8
3161 CALL POPCONTROL1B(branch)
3162 IF (branch .EQ. 0) THEN
3166 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max1
3169 CALL A_SMOOTHIF(t(i, k), a_t(i, k), t0c, ft0, a_ft0, 't0')
3170 CALL POPCONTROL1B(branch)
3171 IF (branch .NE. 0) a_xlf = 0.0_8
3173 a_xl(i, k) = a_xl(i, k) - a_xlf
3174 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
3179 CALL POPCONTROL1B(branch)
3180 IF (branch .EQ. 0) THEN
3183 fallsum = fall(i, kts, 1) + fall(i, kts, 2) + fall(i, kts, 3) + &
3185 a_temp0 = dtcld*1000.*a_rain(i)
3186 a_delz(i, kts) = a_delz(i, kts) + fallsum*a_temp0/denr
3187 a_fallsum = delz(i, kts)*a_temp0/denr
3188 a_temp0 = dtcld*1000.*a_rainncv(i)
3189 a_rainncv(i) = 0.0_8
3190 a_delz(i, kts) = a_delz(i, kts) + fallsum*a_temp0/denr
3191 a_fallsum = a_fallsum + delz(i, kts)*a_temp0/denr
3193 a_fall(i, kts, 1) = a_fall(i, kts, 1) + a_fallsum
3194 a_fall(i, kts, 2) = a_fall(i, kts, 2) + a_fallsum
3195 a_fall(i, kts, 3) = a_fall(i, kts, 3) + a_fallsum
3196 a_fallc(i, kts) = a_fallc(i, kts) + a_fallsum
3198 END SUBROUTINE A_RAINSC
3200 !=======================================================================
3202 !=======================================================================
3203 SUBROUTINE RAINSC(fall, fallc, xl, t, q, qci, cpm, den, qrs, delz, &
3204 & rain, rainncv, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
3206 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
3207 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, fall
3208 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
3209 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, q
3210 REAL, DIMENSION(its:ite, kts:kte) :: xl, t, cpm, fallc
3211 REAL, DIMENSION(ims:ime) :: rain, rainncv
3213 REAL :: dtcld, fallsum, supcol, xlf, temp, temp0, pfrzdtr, pfrzdtc
3214 REAL :: ft0, ft40, fsupcol, fqc, fqi, fqr, qtmp
3226 fallsum = fall(i, kts, 1) + fall(i, kts, 2) + fall(i, kts, 3) + &
3228 IF (fallsum .GT. qmin) THEN
3229 !rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
3230 rainncv(i) = fallsum*delz(i, kts)/denr*dtcld*1000.
3231 rain(i) = fallsum*delz(i, kts)/denr*dtcld*1000. + rain(i)
3236 !---------------------------------------------------------------
3237 ! pimlt: instantaneous melting of cloud ice [RH83 A28]
3238 ! (T>T0: I->C) pimlt=qci(i,k,2) t-
3239 !---------------------------------------------------------------
3241 xl(i, k) = XLCAL(t(i, k))
3242 ! cpm(i,k)=cpmcal(q(i,k)) !not change
3243 xlf = xls - xl(i, k)
3244 supcol = t0c - t(i, k)
3245 IF (supcol .LT. 0.) xlf = xlf0
3246 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
3247 IF (qci(i, k, 2) .LT. 0.) THEN
3253 IF (qtmp .GE. 0.) THEN
3258 IF (abs0 .LT. qmin) qtmp = 0.
3259 IF (qci(i, k, 1) + qtmp .LT. 0.) THEN
3262 qci(i, k, 1) = qci(i, k, 1) + qtmp
3264 IF (qci(i, k, 2) - qtmp .LT. 0.) THEN
3267 qci(i, k, 2) = qci(i, k, 2) - qtmp
3269 t(i, k) = t(i, k) - xlf/cpm(i, k)*qtmp
3270 !---------------------------------------------------------------
3271 ! pihmf: homogeneous freezing of cloud water below -40c
3272 ! (T<-40C: C->I) min=0,pihmf=qci(i,k,1) t+
3273 !---------------------------------------------------------------
3275 xl(i, k) = XLCAL(t(i, k))
3276 ! cpm(i,k)=cpmcal(q(i,k)) !not change
3277 xlf = xls - xl(i, k)
3278 supcol = t0c - t(i, k)
3279 IF (supcol .LT. 0.) xlf = xlf0
3280 CALL SMOOTHIF(supcol, 40., ft40, 't0')
3281 IF (ft40*qci(i, k, 1) .LT. 0.) THEN
3284 qtmp = ft40*qci(i, k, 1)
3286 IF (qtmp .GE. 0.) THEN
3292 IF (abs1 .LT. qmin) qtmp = 0.
3293 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
3296 qci(i, k, 2) = qci(i, k, 2) + qtmp
3298 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
3301 qci(i, k, 1) = qci(i, k, 1) - qtmp
3303 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
3304 !---------------------------------------------------------------
3305 ! pihtf: heterogeneous freezing of cloud water
3306 ! (T0>T>-40C: C->I) max=qci(i,k,1),min=0. t+
3307 !---------------------------------------------------------------
3309 xl(i, k) = XLCAL(t(i, k))
3310 ! cpm(i,k)=cpmcal(q(i,k)) !not change
3311 xlf = xls - xl(i, k)
3312 supcol = t0c - t(i, k)
3313 IF (supcol .LT. 0.) xlf = xlf0
3314 !t>-40C=t0c-40,t0c-t<40, supcol<40,-supcol>-40
3315 CALL SMOOTHIF(-supcol, -40., ft40, 't0')
3316 x1 = pfrz1*(EXP(pfrz2*supcol)-1.)*den(i, k)/denr/xncr*qci(i, k, &
3317 & 1)*qci(i, k, 1)*dtcld
3318 IF (x1 .GT. qci(i, k, 1)) THEN
3319 pfrzdtc = qci(i, k, 1)
3323 IF (ft40*pfrzdtc .LT. 0.) THEN
3328 IF (qtmp .GE. 0.) THEN
3334 IF (abs2 .LT. qmin) qtmp = 0.
3335 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
3338 qci(i, k, 2) = qci(i, k, 2) + qtmp
3340 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
3343 qci(i, k, 1) = qci(i, k, 1) - qtmp
3345 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
3346 !---------------------------------------------------------------
3347 ! pgfrz: freezing of rain water [LFO 45]
3348 ! (T<T0, R->G) max=qrs(i,k,1),min=0. t+
3349 !---------------------------------------------------------------
3351 xl(i, k) = XLCAL(t(i, k))
3352 ! cpm(i,k)=cpmcal(q(i,k))!not change
3353 xlf = xls - xl(i, k)
3354 supcol = t0c - t(i, k)
3355 IF (supcol .LT. 0.) xlf = xlf0
3356 IF (qrs(i, k, 1) .GT. 0.) THEN
3357 temp = pgfrz_a*(EXP(pfrz2*supcol)-1.)*den(i, k)**(3./4.)*qrs(i&
3362 IF (temp*dtcld .GT. qrs(i, k, 1)) THEN
3363 pfrzdtr = qrs(i, k, 1)
3365 pfrzdtr = temp*dtcld
3367 IF (pfrzdtr .LT. 0.) THEN
3372 IF (qtmp .GE. 0.) THEN
3377 IF (abs3 .LT. qmin) qtmp = 0.
3378 IF (qrs(i, k, 3) + qtmp .LT. 0.) THEN
3381 qrs(i, k, 3) = qrs(i, k, 3) + qtmp
3383 IF (qrs(i, k, 1) - qtmp .LT. 0.) THEN
3386 qrs(i, k, 1) = qrs(i, k, 1) - qtmp
3388 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
3391 END SUBROUTINE RAINSC
3393 ! Differentiation of warmr in reverse (adjoint) mode (with options r8):
3394 ! gradient of useful results: p q t qs xl pracw rh den qrs
3396 ! with respect to varying inputs: p q t qs xl pracw rh den qrs
3398 !=======================================================================
3400 !=======================================================================
3401 SUBROUTINE A_WARMR(t, a_t, q, a_q, qci, a_qci, qrs, a_qrs, den, a_den&
3402 & , p, a_p, dtcld, xl, a_xl, rh, a_rh, qs, a_qs, praut, a_praut, pracw&
3403 & , a_pracw, prevp, a_prevp, ims, ime, kms, kme, its, ite, kts, kte)
3405 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
3406 !------------------------------------------------------------------
3407 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
3408 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
3409 REAL, DIMENSION(ims:ime, kms:kme) :: q, den, p
3410 REAL, DIMENSION(ims:ime, kms:kme) :: a_q, a_den, a_p
3411 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, qrs, work1
3412 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_rh, a_qs, a_qrs
3413 REAL, DIMENSION(its:ite, kts:kte) :: praut, prevp, pracw, xl, denfac&
3415 REAL, DIMENSION(its:ite, kts:kte) :: a_praut, a_prevp, a_pracw, a_xl&
3417 REAL :: coeres, supsat, satdt, dtcld, praut1
3418 REAL :: a_supsat, a_satdt, a_praut1
3420 REAL :: fqv, fqc, fqr, fqc0, fprevp, prevp0, prevp1, temp, a, b, c, &
3422 REAL :: a_fqc0, a_a, a_b, a_c, a_d, a_e
3462 !---------------------------------------------------------------
3463 ! praut: auto conversion rate from cloud to rain [HDC 16]
3464 ! (C->R) praut>0 max=qci(i,k,1)/dtcld, min=0.
3465 !---------------------------------------------------------------
3466 CALL PUSHREAL8(fqc0)
3467 CALL SMOOTHIF(qci(i, k, 1), qc0, fqc0, 'q0')
3469 IF (qci(i, k, 1) .GT. 0.) THEN
3471 !(qci(i,k,1)**(7./3.))
3472 praut1 = fqc0*qck1*EXP(LOG(qci(i, k, 1))*(7./3.))
3473 CALL PUSHCONTROL1B(1)
3476 CALL PUSHCONTROL1B(0)
3478 IF (praut1 .GT. qci(i, k, 1)/dtcld) THEN
3479 praut(i, k) = qci(i, k, 1)/dtcld
3480 CALL PUSHCONTROL1B(0)
3482 praut(i, k) = praut1
3483 CALL PUSHCONTROL1B(1)
3485 IF (praut(i, k) .GE. 0.) THEN
3490 IF (abs0 .LT. qmin/dtcld) THEN
3492 CALL PUSHCONTROL1B(1)
3494 CALL PUSHCONTROL1B(0)
3496 IF (qci(i, k, 1) - praut(i, k)*dtcld .LT. 0.) THEN
3497 CALL PUSHREAL8(qci(i, k, 1))
3499 CALL PUSHCONTROL1B(0)
3501 CALL PUSHREAL8(qci(i, k, 1))
3502 qci(i, k, 1) = qci(i, k, 1) - praut(i, k)*dtcld
3503 CALL PUSHCONTROL1B(1)
3505 IF (qrs(i, k, 1) + praut(i, k)*dtcld .LT. 0.) THEN
3507 CALL PUSHCONTROL1B(0)
3509 qrs(i, k, 1) = qrs(i, k, 1) + praut(i, k)*dtcld
3510 CALL PUSHCONTROL1B(1)
3512 !---------------------------------------------------------------
3513 ! pracw: accretion of cloud water by rain [LFO 51]
3514 ! (C->R) max=qci(i,k,1)/dtcld, min=0.
3515 !---------------------------------------------------------------
3516 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
3517 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
3518 IF (qrs(i, k, 1) .GT. 0 .AND. qci(i, k, 1) .GT. 0.) THEN
3519 pracw(i, k) = pracw_a*den(i, k)**((1.+bvtr)/4.)*qrs(i, k, 1)**&
3520 & ((3.+bvtr)/4.)*qci(i, k, 1)
3521 CALL PUSHCONTROL1B(0)
3524 CALL PUSHCONTROL1B(1)
3526 IF (pracw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
3527 x1 = qci(i, k, 1)/dtcld
3528 CALL PUSHCONTROL1B(0)
3531 CALL PUSHCONTROL1B(1)
3533 IF (x1 .LT. 0.) THEN
3535 CALL PUSHCONTROL1B(0)
3538 CALL PUSHCONTROL1B(1)
3540 IF (pracw(i, k) .GE. 0.) THEN
3545 IF (abs1 .LT. qmin/dtcld) THEN
3547 CALL PUSHCONTROL1B(1)
3549 CALL PUSHCONTROL1B(0)
3551 IF (qci(i, k, 1) - pracw(i, k)*dtcld .LT. 0.) THEN
3552 CALL PUSHCONTROL1B(0)
3554 CALL PUSHCONTROL1B(1)
3556 IF (qrs(i, k, 1) + pracw(i, k)*dtcld .LT. 0.) THEN
3557 CALL PUSHREAL8(qrs(i, k, 1))
3559 CALL PUSHCONTROL1B(0)
3561 CALL PUSHREAL8(qrs(i, k, 1))
3562 qrs(i, k, 1) = qrs(i, k, 1) + pracw(i, k)*dtcld
3563 CALL PUSHCONTROL1B(1)
3566 !---------------------------------------------------------------
3567 ! prevp: evaporation/condensation rate of rain [HDC 14]
3568 ! (V->R or R->V) rh(i,k,1)>1., prevp>0, V->R, min=0., max=satdt ;
3569 ! rh(i,k,1)<1., prevp<0, R->V, min=-qrs(i,k,1)/dtcld, max=0.
3570 !---------------------------------------------------------------
3572 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
3573 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
3575 xl(i, k) = XLCAL(t(i, k))
3576 cpm(i, k) = CPMCAL(q(i, k))
3577 supsat = q(i, k) - qs(i, k, 1)
3578 satdt = supsat/dtcld
3579 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3580 CALL PUSHREAL8(max1)
3582 CALL PUSHCONTROL1B(0)
3584 CALL PUSHREAL8(max1)
3586 CALL PUSHCONTROL1B(1)
3589 a = SQRT(den(i, k)*max1)
3590 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3591 CALL PUSHREAL8(max2)
3593 CALL PUSHCONTROL1B(0)
3595 CALL PUSHREAL8(max2)
3597 CALL PUSHCONTROL1B(1)
3600 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
3601 & den(i, k)**((13.+3.*bvtr)/24.)*max2**((5.+bvtr)/8.)
3603 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
3605 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
3606 e = (rh(i, k, 1)-1.)/(c+d)
3607 prevp(i, k) = (prevp_a*a+prevp_b*b)*e
3608 IF (prevp(i, k) .LT. 0.) THEN
3609 IF (prevp(i, k) .LT. -(qrs(i, k, 1)/dtcld)) THEN
3610 x2 = -(qrs(i, k, 1)/dtcld)
3611 CALL PUSHCONTROL1B(0)
3614 CALL PUSHCONTROL1B(1)
3616 IF (x2 .GT. 0.) THEN
3618 CALL PUSHCONTROL2B(1)
3621 CALL PUSHCONTROL2B(0)
3624 IF (prevp(i, k) .GT. satdt) THEN
3626 CALL PUSHCONTROL1B(0)
3629 CALL PUSHCONTROL1B(1)
3631 IF (x3 .LT. 0.) THEN
3633 CALL PUSHCONTROL2B(3)
3636 CALL PUSHCONTROL2B(2)
3639 IF (prevp(i, k) .GE. 0.) THEN
3644 IF (abs2 .LT. qmin/dtcld) THEN
3646 CALL PUSHCONTROL1B(1)
3648 CALL PUSHCONTROL1B(0)
3650 IF (q(i, k) - prevp(i, k)*dtcld .LT. 0.) THEN
3651 CALL PUSHCONTROL1B(0)
3653 CALL PUSHCONTROL1B(1)
3655 IF (qrs(i, k, 1) + prevp(i, k)*dtcld .LT. 0.) THEN
3656 CALL PUSHCONTROL1B(0)
3658 CALL PUSHCONTROL1B(1)
3665 a_temp2 = dtcld*a_t(i, k)/cpm(i, k)
3666 a_prevp(i, k) = xl(i, k)*a_temp2
3667 a_xl(i, k) = a_xl(i, k) + prevp(i, k)*a_temp2
3668 a_cpm(i, k) = a_cpm(i, k) - prevp(i, k)*xl(i, k)*a_temp2/cpm(i, &
3670 CALL POPCONTROL1B(branch)
3671 IF (branch .EQ. 0) THEN
3672 a_qrs(i, k, 1) = 0.0_8
3674 a_prevp(i, k) = a_prevp(i, k) + dtcld*a_qrs(i, k, 1)
3676 CALL POPCONTROL1B(branch)
3677 IF (branch .EQ. 0) THEN
3680 a_prevp(i, k) = a_prevp(i, k) - dtcld*a_q(i, k)
3682 CALL POPCONTROL1B(branch)
3683 IF (branch .NE. 0) a_prevp(i, k) = 0.0_8
3684 CALL POPCONTROL2B(branch)
3685 IF (branch .LT. 2) THEN
3686 IF (branch .EQ. 0) THEN
3687 a_x2 = a_prevp(i, k)
3688 a_prevp(i, k) = 0.0_8
3690 a_prevp(i, k) = 0.0_8
3693 CALL POPCONTROL1B(branch)
3694 IF (branch .EQ. 0) THEN
3695 a_qrs(i, k, 1) = a_qrs(i, k, 1) - a_x2/dtcld
3697 a_prevp(i, k) = a_prevp(i, k) + a_x2
3701 IF (branch .EQ. 2) THEN
3702 a_x3 = a_prevp(i, k)
3703 a_prevp(i, k) = 0.0_8
3705 a_prevp(i, k) = 0.0_8
3708 CALL POPCONTROL1B(branch)
3709 IF (branch .EQ. 0) THEN
3712 a_prevp(i, k) = a_prevp(i, k) + a_x3
3716 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
3717 e = (rh(i, k, 1)-1.)/(c+d)
3718 a_a = prevp_a*e*a_prevp(i, k)
3719 a_b = prevp_b*e*a_prevp(i, k)
3720 a_e = (prevp_a*a+prevp_b*b)*a_prevp(i, k)
3721 a_prevp(i, k) = 0.0_8
3723 a_rh(i, k, 1) = a_rh(i, k, 1) + a_temp2
3724 a_temp3 = -((rh(i, k, 1)-1.)*a_temp2/(c+d))
3727 temp11 = t(i, k)**1.81
3728 temp10 = temp11*qs(i, k, 1)
3729 a_temp1 = diffac_b*a_d/temp10
3730 a_temp3 = -(p(i, k)*a_temp1/temp10)
3731 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 1)*a_temp3
3732 a_qs(i, k, 1) = a_qs(i, k, 1) + temp11*a_temp3
3734 temp11 = rv*t(i, k)**3.5
3735 temp9 = den(i, k)*(t(i, k)+120.)
3736 temp8 = xl(i, k)*xl(i, k)
3737 a_temp3 = diffac_a*a_c/temp11
3738 a_xl(i, k) = a_xl(i, k) + 2*xl(i, k)*temp9*a_temp3
3739 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*temp8*a_temp3
3740 a_t(i, k) = a_t(i, k) + (den(i, k)*temp8-3.5*t(i, k)**2.5*rv*&
3741 & temp8*temp9/temp11)*a_temp3
3743 temp3 = (3.*bvtr+13.)/24.
3744 temp2 = den(i, k)**temp3
3745 temp1 = (bvtr+5.)/8.
3748 temp5 = p(i, k)**temp4
3751 temp8 = t(i, k)**temp7
3753 temp9 = (t(i, k)+120.)**temp10/temp8
3755 IF (p(i, k) .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. temp4 .NE. &
3757 a_p(i, k) = a_p(i, k) + a_temp1
3759 a_p(i, k) = a_p(i, k) + a_temp1 + temp4*p(i, k)**(temp4-1)*&
3760 & temp0*temp2*a_temp2
3762 a_temp1 = temp6*temp2*a_b/temp8
3763 IF (max2 .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. temp1 .NE. INT(&
3767 a_max2 = temp1*max2**(temp1-1)*temp5*temp2*a_temp2
3769 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. &
3770 & temp3 .NE. INT(temp3)))) a_den(i, k) = a_den(i, k) + temp3*&
3771 & den(i, k)**(temp3-1)*temp6*a_temp2
3772 IF (.NOT.(t(i, k) + 120. .LE. 0.0_8 .AND. (temp10 .EQ. 0.0_8 &
3773 & .OR. temp10 .NE. INT(temp10)))) a_t(i, k) = a_t(i, k) + &
3774 & temp10*(t(i, k)+120.)**(temp10-1)*a_temp1
3775 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 &
3776 & .NE. INT(temp7)))) a_t(i, k) = a_t(i, k) - temp7*t(i, k)**(&
3777 & temp7-1)*temp9*a_temp1
3778 CALL POPCONTROL1B(branch)
3779 IF (branch .EQ. 0) THEN
3783 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max2
3786 IF (den(i, k)*max1 .EQ. 0.0_8) THEN
3789 a_temp0 = a_a/(2.0*SQRT(den(i, k)*max1))
3791 a_den(i, k) = a_den(i, k) + max1*a_temp0
3792 a_max1 = den(i, k)*a_temp0
3793 CALL POPCONTROL1B(branch)
3794 IF (branch .EQ. 0) THEN
3798 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max1
3800 a_supsat = a_satdt/dtcld
3801 a_q(i, k) = a_q(i, k) + a_supsat
3802 a_qs(i, k, 1) = a_qs(i, k, 1) - a_supsat
3803 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
3805 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
3807 CALL POPREAL8ARRAY(qs(i, k, :), 3)
3808 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
3809 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
3811 a_pracw(i, k) = 0.0_8
3812 CALL POPCONTROL1B(branch)
3813 IF (branch .EQ. 0) THEN
3814 CALL POPREAL8(qrs(i, k, 1))
3815 a_qrs(i, k, 1) = 0.0_8
3817 CALL POPREAL8(qrs(i, k, 1))
3818 a_pracw(i, k) = a_pracw(i, k) + dtcld*a_qrs(i, k, 1)
3820 CALL POPCONTROL1B(branch)
3821 IF (branch .EQ. 0) THEN
3822 a_qci(i, k, 1) = 0.0_8
3824 a_pracw(i, k) = a_pracw(i, k) - dtcld*a_qci(i, k, 1)
3826 CALL POPCONTROL1B(branch)
3827 IF (branch .NE. 0) a_pracw(i, k) = 0.0_8
3828 CALL POPCONTROL1B(branch)
3829 IF (branch .EQ. 0) THEN
3830 a_pracw(i, k) = 0.0_8
3833 a_x1 = a_pracw(i, k)
3834 a_pracw(i, k) = 0.0_8
3836 CALL POPCONTROL1B(branch)
3837 IF (branch .EQ. 0) THEN
3838 a_qci(i, k, 1) = a_qci(i, k, 1) + a_x1/dtcld
3840 a_pracw(i, k) = a_pracw(i, k) + a_x1
3842 CALL POPCONTROL1B(branch)
3843 IF (branch .EQ. 0) THEN
3844 temp0 = (bvtr+3.)/4.
3845 temp2 = (bvtr+1.)/4.
3846 temp3 = den(i, k)**temp2
3847 a_temp = qrs(i, k, 1)**temp0*pracw_a*a_pracw(i, k)
3848 IF (.NOT.(qrs(i, k, 1) .LE. 0.0_8 .AND. (temp0 .EQ. 0.0_8 .OR.&
3849 & temp0 .NE. INT(temp0)))) a_qrs(i, k, 1) = a_qrs(i, k, 1) +&
3850 & temp0*qrs(i, k, 1)**(temp0-1)*temp3*qci(i, k, 1)*pracw_a*&
3852 a_pracw(i, k) = 0.0_8
3853 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
3854 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2&
3855 & *den(i, k)**(temp2-1)*qci(i, k, 1)*a_temp
3856 a_qci(i, k, 1) = a_qci(i, k, 1) + temp3*a_temp
3858 a_pracw(i, k) = 0.0_8
3860 a_praut(i, k) = 0.0_8
3861 CALL POPCONTROL1B(branch)
3862 IF (branch .EQ. 0) THEN
3863 a_qrs(i, k, 1) = 0.0_8
3865 a_praut(i, k) = a_praut(i, k) + dtcld*a_qrs(i, k, 1)
3867 CALL POPCONTROL1B(branch)
3868 IF (branch .EQ. 0) THEN
3869 CALL POPREAL8(qci(i, k, 1))
3870 a_qci(i, k, 1) = 0.0_8
3872 CALL POPREAL8(qci(i, k, 1))
3873 a_praut(i, k) = a_praut(i, k) - dtcld*a_qci(i, k, 1)
3875 CALL POPCONTROL1B(branch)
3876 IF (branch .NE. 0) a_praut(i, k) = 0.0_8
3877 CALL POPCONTROL1B(branch)
3878 IF (branch .EQ. 0) THEN
3879 a_qci(i, k, 1) = a_qci(i, k, 1) + a_praut(i, k)/dtcld
3880 a_praut(i, k) = 0.0_8
3883 a_praut1 = a_praut(i, k)
3884 a_praut(i, k) = 0.0_8
3886 CALL POPCONTROL1B(branch)
3887 IF (branch .EQ. 0) THEN
3890 temp0 = 7.*LOG(qci(i, k, 1))/3.
3891 a_fqc0 = EXP(temp0)*qck1*a_praut1
3892 a_qci(i, k, 1) = a_qci(i, k, 1) + 7.*EXP(temp0)*fqc0*qck1*&
3893 & a_praut1/(qci(i, k, 1)*3.)
3896 CALL A_SMOOTHIF(qci(i, k, 1), a_qci(i, k, 1), qc0, fqc0, a_fqc0&
3900 END SUBROUTINE A_WARMR
3902 !=======================================================================
3904 !=======================================================================
3905 SUBROUTINE WARMR(t, q, qci, qrs, den, p, dtcld, xl, rh, qs, praut, &
3906 & pracw, prevp, ims, ime, kms, kme, its, ite, kts, kte)
3908 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
3909 !------------------------------------------------------------------
3910 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
3911 REAL, DIMENSION(ims:ime, kms:kme) :: q, den, p
3912 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, qrs, work1
3913 REAL, DIMENSION(its:ite, kts:kte) :: praut, prevp, pracw, xl, denfac&
3915 REAL :: coeres, supsat, satdt, dtcld, praut1
3917 REAL :: fqv, fqc, fqr, fqc0, fprevp, prevp0, prevp1, temp, a, b, c, &
3935 !---------------------------------------------------------------
3936 ! praut: auto conversion rate from cloud to rain [HDC 16]
3937 ! (C->R) praut>0 max=qci(i,k,1)/dtcld, min=0.
3938 !---------------------------------------------------------------
3939 CALL SMOOTHIF(qci(i, k, 1), qc0, fqc0, 'q0')
3941 IF (qci(i, k, 1) .GT. 0.) THEN
3943 !(qci(i,k,1)**(7./3.))
3944 praut1 = fqc0*qck1*EXP(LOG(qci(i, k, 1))*(7./3.))
3948 IF (praut1 .GT. qci(i, k, 1)/dtcld) THEN
3949 praut(i, k) = qci(i, k, 1)/dtcld
3951 praut(i, k) = praut1
3953 IF (praut(i, k) .GE. 0.) THEN
3958 IF (abs0 .LT. qmin/dtcld) praut(i, k) = 0.
3959 IF (qci(i, k, 1) - praut(i, k)*dtcld .LT. 0.) THEN
3962 qci(i, k, 1) = qci(i, k, 1) - praut(i, k)*dtcld
3964 IF (qrs(i, k, 1) + praut(i, k)*dtcld .LT. 0.) THEN
3967 qrs(i, k, 1) = qrs(i, k, 1) + praut(i, k)*dtcld
3970 !---------------------------------------------------------------
3971 ! pracw: accretion of cloud water by rain [LFO 51]
3972 ! (C->R) max=qci(i,k,1)/dtcld, min=0.
3973 !---------------------------------------------------------------
3974 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
3975 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
3976 IF (qrs(i, k, 1) .GT. 0 .AND. qci(i, k, 1) .GT. 0.) THEN
3977 pracw(i, k) = pracw_a*den(i, k)**((1.+bvtr)/4.)*qrs(i, k, 1)**&
3978 & ((3.+bvtr)/4.)*qci(i, k, 1)
3982 IF (pracw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
3983 x1 = qci(i, k, 1)/dtcld
3987 IF (x1 .LT. 0.) THEN
3992 IF (pracw(i, k) .GE. 0.) THEN
3997 IF (abs1 .LT. qmin/dtcld) pracw(i, k) = 0.
3998 IF (qci(i, k, 1) - pracw(i, k)*dtcld .LT. 0.) THEN
4001 qci(i, k, 1) = qci(i, k, 1) - pracw(i, k)*dtcld
4003 IF (qrs(i, k, 1) + pracw(i, k)*dtcld .LT. 0.) THEN
4006 qrs(i, k, 1) = qrs(i, k, 1) + pracw(i, k)*dtcld
4010 !---------------------------------------------------------------
4011 ! prevp: evaporation/condensation rate of rain [HDC 14]
4012 ! (V->R or R->V) rh(i,k,1)>1., prevp>0, V->R, min=0., max=satdt ;
4013 ! rh(i,k,1)<1., prevp<0, R->V, min=-qrs(i,k,1)/dtcld, max=0.
4014 !---------------------------------------------------------------
4016 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
4018 xl(i, k) = XLCAL(t(i, k))
4019 cpm(i, k) = CPMCAL(q(i, k))
4020 supsat = q(i, k) - qs(i, k, 1)
4021 satdt = supsat/dtcld
4022 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4027 a = SQRT(den(i, k)*max1)
4028 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4033 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
4034 & den(i, k)**((13.+3.*bvtr)/24.)*max2**((5.+bvtr)/8.)
4035 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
4037 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
4038 e = (rh(i, k, 1)-1.)/(c+d)
4039 prevp(i, k) = (prevp_a*a+prevp_b*b)*e
4040 IF (prevp(i, k) .LT. 0.) THEN
4041 IF (prevp(i, k) .LT. -(qrs(i, k, 1)/dtcld)) THEN
4042 x2 = -(qrs(i, k, 1)/dtcld)
4046 IF (x2 .GT. 0.) THEN
4052 IF (prevp(i, k) .GT. satdt) THEN
4057 IF (x3 .LT. 0.) THEN
4063 IF (prevp(i, k) .GE. 0.) THEN
4068 IF (abs2 .LT. qmin/dtcld) prevp(i, k) = 0.
4069 IF (q(i, k) - prevp(i, k)*dtcld .LT. 0.) THEN
4072 q(i, k) = q(i, k) - prevp(i, k)*dtcld
4074 IF (qrs(i, k, 1) + prevp(i, k)*dtcld .LT. 0.) THEN
4077 qrs(i, k, 1) = qrs(i, k, 1) + prevp(i, k)*dtcld
4079 t(i, k) = t(i, k) + prevp(i, k)*dtcld*xl(i, k)/cpm(i, k)
4083 END SUBROUTINE WARMR
4085 ! Differentiation of accret1 in reverse (adjoint) mode (with options r8):
4086 ! gradient of useful results: piacr psaci q pgaci t praci
4087 ! psacw pgacw den qrs qci
4088 ! with respect to varying inputs: piacr psaci q pgaci t praci
4089 ! psacw pgacw den qrs qci
4090 !===================================================================
4091 SUBROUTINE A_ACCRET1(qci, a_qci, den, a_den, qrs, a_qrs, t, a_t, q, &
4092 & a_q, dtcld, praci, a_praci, piacr, a_piacr, psaci, a_psaci, pgaci, &
4093 & a_pgaci, psacw, a_psacw, pgacw, a_pgacw, ims, ime, kms, kme, its, &
4096 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
4097 !-------------------------------------------------------------------
4098 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
4099 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
4100 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
4101 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs
4102 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
4103 REAL, DIMENSION(ims:ime, kms:kme) :: a_den, a_q
4104 REAL, DIMENSION(its:ite, kts:kte) :: praci, piacr, psaci, pgaci, &
4105 & psacw, pgacw, t, xl, cpm
4106 REAL, DIMENSION(its:ite, kts:kte) :: a_praci, a_piacr, a_psaci, &
4107 & a_pgaci, a_psacw, a_pgacw, a_t, a_xl, a_cpm
4108 REAL :: supcol, dtcld, eacrs, egi, praci1, piacr1, psaci1, pgaci1, &
4110 REAL :: a_supcol, a_eacrs, a_egi, a_praci1, a_piacr1, a_psaci1, &
4113 REAL :: fsupcol, fqc, fqi, fqr, fqs, fqg, delta3, xlf, a, b, c, d, e
4114 REAL :: a_fsupcol, a_xlf, a_a, a_b, a_c, a_d
4246 !-------------------------------------------------------------
4247 ! praci: Accretion of cloud ice by rain [LFO 25]
4248 ! (T<T0: I->S or I->G) praci: min=0,max=qci(i,k,2)/dtcld
4249 !-------------------------------------------------------------
4250 supcol = t0c - t(i, k)
4251 CALL PUSHREAL8(fsupcol)
4252 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4253 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4254 CALL PUSHREAL8(max1)
4256 CALL PUSHCONTROL1B(0)
4258 CALL PUSHREAL8(max1)
4260 CALL PUSHCONTROL1B(1)
4262 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.)
4263 IF (qci(i, k, 2) .LT. qmin) THEN
4264 CALL PUSHREAL8(max2)
4266 CALL PUSHCONTROL1B(0)
4268 CALL PUSHREAL8(max2)
4270 CALL PUSHCONTROL1B(1)
4272 vt2i = vt2i_a*(den(i, k)*max2)**(1.31/8.)
4273 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4274 CALL PUSHREAL8(max3)
4276 CALL PUSHCONTROL1B(1)
4278 CALL PUSHREAL8(max3)
4280 CALL PUSHCONTROL1B(0)
4282 IF (qci(i, k, 2) .LT. qmin) THEN
4283 CALL PUSHREAL8(max18)
4285 CALL PUSHCONTROL1B(0)
4287 CALL PUSHREAL8(max18)
4288 max18 = qci(i, k, 2)
4289 CALL PUSHCONTROL1B(1)
4292 b = (den(i, k)*max3)**(3./4.)*max18
4293 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4294 CALL PUSHREAL8(max4)
4296 CALL PUSHCONTROL1B(1)
4298 CALL PUSHREAL8(max4)
4300 CALL PUSHCONTROL1B(0)
4302 IF (qci(i, k, 2) .LT. qmin) THEN
4303 CALL PUSHREAL8(max19)
4305 CALL PUSHCONTROL1B(0)
4307 CALL PUSHREAL8(max19)
4308 max19 = qci(i, k, 2)
4309 CALL PUSHCONTROL1B(1)
4312 c = den(i, k)**(5./8.)*SQRT(max4)*max19**(9./8.)
4313 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4314 CALL PUSHREAL8(max5)
4316 CALL PUSHCONTROL1B(1)
4318 CALL PUSHREAL8(max5)
4320 CALL PUSHCONTROL1B(0)
4322 IF (qci(i, k, 2) .LT. qmin) THEN
4323 CALL PUSHREAL8(max20)
4325 CALL PUSHCONTROL1B(0)
4327 CALL PUSHREAL8(max20)
4328 max20 = qci(i, k, 2)
4329 CALL PUSHCONTROL1B(1)
4332 d = SQRT(den(i, k))*SQRT(SQRT(max5))*max20**(5./4.)
4333 IF (vt2r - vt2i .GE. 0.) THEN
4334 CALL PUSHREAL8(abs0)
4336 CALL PUSHCONTROL1B(0)
4338 CALL PUSHREAL8(abs0)
4340 CALL PUSHCONTROL1B(1)
4342 praci1 = praci_a*abs0*(praci_b*b+praci_c*c+praci_d*d)
4343 IF (praci1 .GT. qci(i, k, 2)/dtcld) THEN
4344 praci(i, k) = qci(i, k, 2)/dtcld
4345 CALL PUSHCONTROL1B(0)
4347 praci(i, k) = praci1
4348 CALL PUSHCONTROL1B(1)
4350 CALL PUSHREAL8(praci(i, k))
4351 praci(i, k) = fsupcol*praci(i, k)
4353 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
4354 CALL PUSHREAL8(delta3)
4356 CALL PUSHCONTROL1B(1)
4358 CALL PUSHREAL8(delta3)
4360 CALL PUSHCONTROL1B(0)
4362 IF (praci(i, k) .GE. 0.) THEN
4367 IF (abs1 .LT. qmin/dtcld) THEN
4369 CALL PUSHCONTROL1B(1)
4371 CALL PUSHCONTROL1B(0)
4373 IF (qci(i, k, 2) - praci(i, k)*dtcld .LT. 0.) THEN
4375 CALL PUSHCONTROL1B(0)
4377 qci(i, k, 2) = qci(i, k, 2) - praci(i, k)*dtcld
4378 CALL PUSHCONTROL1B(1)
4380 x1 = qrs(i, k, 2) + praci(i, k)*delta3*dtcld
4381 IF (x1 .LT. 0.) THEN
4383 CALL PUSHCONTROL1B(0)
4386 CALL PUSHCONTROL1B(1)
4388 x2 = qrs(i, k, 3) + praci(i, k)*(1-delta3)*dtcld
4389 IF (x2 .LT. 0.) THEN
4391 CALL PUSHCONTROL1B(0)
4394 CALL PUSHCONTROL1B(1)
4396 !-------------------------------------------------------------
4397 ! piacr: Accretion of rain by cloud ice [LFO 26]
4398 ! (T<T0: R->S or R->G) piacr: min=0,max=qrs(i,k,1)/dtcld
4399 !-------------------------------------------------------------
4400 ! supcol = t0c-t(i,k) !not change
4401 CALL PUSHREAL8(fsupcol)
4402 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4403 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
4404 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
4406 cpm(i, k) = CPMCAL(q(i, k))
4407 xl(i, k) = XLCAL(t(i, k))
4409 xlf = xls - xl(i, k)
4410 IF (supcol .LT. 0.) THEN
4412 CALL PUSHCONTROL1B(0)
4414 CALL PUSHCONTROL1B(1)
4416 IF (qci(i, k, 2) .GT. 0. .AND. qrs(i, k, 1) .GT. 0.) THEN
4418 piacr1 = piacr_a*den(i, k)**((3.+bvtr)/4.)*qci(i, k, 2)**0.75*&
4419 & qrs(i, k, 1)**((6.+bvtr)/4.)
4420 CALL PUSHCONTROL1B(1)
4422 CALL PUSHCONTROL1B(0)
4425 IF (piacr1 .GT. qrs(i, k, 1)/dtcld) THEN
4426 piacr(i, k) = qrs(i, k, 1)/dtcld
4427 CALL PUSHCONTROL1B(0)
4429 piacr(i, k) = piacr1
4430 CALL PUSHCONTROL1B(1)
4432 CALL PUSHREAL8(piacr(i, k))
4433 piacr(i, k) = fsupcol*piacr(i, k)
4435 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
4436 CALL PUSHREAL8(delta3)
4438 CALL PUSHCONTROL1B(1)
4440 CALL PUSHREAL8(delta3)
4442 CALL PUSHCONTROL1B(0)
4444 IF (piacr(i, k) .GE. 0.) THEN
4449 IF (abs2 .LT. qmin/dtcld) THEN
4451 CALL PUSHCONTROL1B(1)
4453 CALL PUSHCONTROL1B(0)
4455 IF (qrs(i, k, 1) - piacr(i, k)*dtcld .LT. 0.) THEN
4456 CALL PUSHREAL8(qrs(i, k, 1))
4458 CALL PUSHCONTROL1B(0)
4460 CALL PUSHREAL8(qrs(i, k, 1))
4461 qrs(i, k, 1) = qrs(i, k, 1) - piacr(i, k)*dtcld
4462 CALL PUSHCONTROL1B(1)
4464 x3 = qrs(i, k, 2) + piacr(i, k)*delta3*dtcld
4465 IF (x3 .LT. 0.) THEN
4466 CALL PUSHREAL8(qrs(i, k, 2))
4468 CALL PUSHCONTROL1B(0)
4470 CALL PUSHREAL8(qrs(i, k, 2))
4472 CALL PUSHCONTROL1B(1)
4474 x4 = qrs(i, k, 3) + piacr(i, k)*(1-delta3)*dtcld
4475 IF (x4 .LT. 0.) THEN
4476 CALL PUSHREAL8(qrs(i, k, 3))
4478 CALL PUSHCONTROL1B(0)
4480 CALL PUSHREAL8(qrs(i, k, 3))
4482 CALL PUSHCONTROL1B(1)
4484 t(i, k) = t(i, k) + piacr(i, k)*dtcld*xlf/cpm(i, k)
4485 !-------------------------------------------------------------
4486 ! psaci: Accretion of cloud ice by snow [HDC 10]
4487 ! (T<T0: I->S) psaci: min=0, max=qci(i,k,2)/dtcld
4488 !-------------------------------------------------------------
4489 CALL PUSHREAL8(supcol)
4490 supcol = t0c - t(i, k)
4491 CALL PUSHREAL8(fsupcol)
4492 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4493 x5 = EXP(0.07*(-supcol))
4494 IF (x5 .GT. 1.) THEN
4495 CALL PUSHREAL8(eacrs)
4497 CALL PUSHCONTROL1B(0)
4499 CALL PUSHREAL8(eacrs)
4501 CALL PUSHCONTROL1B(1)
4503 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4504 CALL PUSHREAL8(max6)
4506 CALL PUSHCONTROL1B(0)
4508 CALL PUSHREAL8(max6)
4510 CALL PUSHCONTROL1B(1)
4512 IF (90. .GT. t0c - t(i, k)) THEN
4514 CALL PUSHCONTROL1B(0)
4516 CALL PUSHCONTROL1B(1)
4519 IF (0. .LT. y6) THEN
4520 CALL PUSHREAL8(max21)
4522 CALL PUSHCONTROL1B(0)
4524 CALL PUSHREAL8(max21)
4526 CALL PUSHCONTROL1B(1)
4528 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max6**(bvts/4.)*EXP(-(&
4529 & alpha*bvts*max21/4.))
4530 IF (qci(i, k, 2) .LT. qmin) THEN
4531 CALL PUSHREAL8(max7)
4533 CALL PUSHCONTROL1B(0)
4535 CALL PUSHREAL8(max7)
4537 CALL PUSHCONTROL1B(1)
4539 vt2i = vt2i_a*(den(i, k)*max7)**(1.31/8.)
4540 IF (90. .GT. t0c - t(i, k)) THEN
4542 CALL PUSHCONTROL1B(0)
4544 CALL PUSHCONTROL1B(1)
4547 IF (0. .LT. y1) THEN
4548 CALL PUSHREAL8(max8)
4550 CALL PUSHCONTROL1B(0)
4552 CALL PUSHREAL8(max8)
4554 CALL PUSHCONTROL1B(1)
4558 IF (90. .GT. t0c - t(i, k)) THEN
4560 CALL PUSHCONTROL1B(0)
4562 CALL PUSHCONTROL1B(1)
4565 IF (0. .LT. y2) THEN
4566 CALL PUSHREAL8(max9)
4568 CALL PUSHCONTROL1B(1)
4570 CALL PUSHREAL8(max9)
4572 CALL PUSHCONTROL1B(0)
4574 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4575 CALL PUSHREAL8(max22)
4577 CALL PUSHCONTROL1B(1)
4579 CALL PUSHREAL8(max22)
4580 max22 = qrs(i, k, 2)
4581 CALL PUSHCONTROL1B(0)
4583 IF (qci(i, k, 2) .LT. qmin) THEN
4584 CALL PUSHREAL8(max28)
4586 CALL PUSHCONTROL1B(0)
4588 CALL PUSHREAL8(max28)
4589 max28 = qci(i, k, 2)
4590 CALL PUSHCONTROL1B(1)
4592 b = EXP(-(3.*alpha*max9/4.))*(den(i, k)*max22)**(3./4.)*max28
4593 IF (90. .GT. t0c - t(i, k)) THEN
4595 CALL PUSHCONTROL1B(0)
4597 CALL PUSHCONTROL1B(1)
4600 IF (0. .LT. y3) THEN
4601 CALL PUSHREAL8(max10)
4603 CALL PUSHCONTROL1B(1)
4605 CALL PUSHREAL8(max10)
4607 CALL PUSHCONTROL1B(0)
4609 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4610 CALL PUSHREAL8(max23)
4612 CALL PUSHCONTROL1B(1)
4614 CALL PUSHREAL8(max23)
4615 max23 = qrs(i, k, 2)
4616 CALL PUSHCONTROL1B(0)
4618 IF (qci(i, k, 2) .LT. qmin) THEN
4619 CALL PUSHREAL8(max29)
4621 CALL PUSHCONTROL1B(0)
4623 CALL PUSHREAL8(max29)
4624 max29 = qci(i, k, 2)
4625 CALL PUSHCONTROL1B(1)
4628 c = EXP(-(alpha*max10/2.))*den(i, k)**(5./8.)*SQRT(max23)*max29&
4630 IF (90. .GT. t0c - t(i, k)) THEN
4632 CALL PUSHCONTROL1B(0)
4634 CALL PUSHCONTROL1B(1)
4637 IF (0. .LT. y4) THEN
4638 CALL PUSHREAL8(max11)
4640 CALL PUSHCONTROL1B(1)
4642 CALL PUSHREAL8(max11)
4644 CALL PUSHCONTROL1B(0)
4646 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4647 CALL PUSHREAL8(max24)
4649 CALL PUSHCONTROL1B(1)
4651 CALL PUSHREAL8(max24)
4652 max24 = qrs(i, k, 2)
4653 CALL PUSHCONTROL1B(0)
4655 IF (qci(i, k, 2) .LT. qmin) THEN
4656 CALL PUSHREAL8(max30)
4658 CALL PUSHCONTROL1B(0)
4660 CALL PUSHREAL8(max30)
4661 max30 = qci(i, k, 2)
4662 CALL PUSHCONTROL1B(1)
4665 d = EXP(-(alpha*max11/4.))*SQRT(den(i, k))*SQRT(SQRT(max24))*&
4667 IF (vt2s - vt2i .GE. 0.) THEN
4668 CALL PUSHREAL8(abs3)
4670 CALL PUSHCONTROL1B(0)
4672 CALL PUSHREAL8(abs3)
4674 CALL PUSHCONTROL1B(1)
4676 psaci1 = psaci_a*a*abs3*(psaci_b*b+psaci_c*c+psaci_d*d)*eacrs
4677 IF (psaci1 .GT. qci(i, k, 2)/dtcld) THEN
4678 psaci(i, k) = qci(i, k, 2)/dtcld
4679 CALL PUSHCONTROL1B(0)
4681 psaci(i, k) = psaci1
4682 CALL PUSHCONTROL1B(1)
4684 CALL PUSHREAL8(psaci(i, k))
4685 psaci(i, k) = fsupcol*psaci(i, k)
4686 IF (psaci(i, k) .GE. 0.) THEN
4691 IF (abs4 .LT. qmin/dtcld) THEN
4693 CALL PUSHCONTROL1B(1)
4695 CALL PUSHCONTROL1B(0)
4697 IF (qci(i, k, 2) - psaci(i, k)*dtcld .LT. 0.) THEN
4698 CALL PUSHREAL8(qci(i, k, 2))
4700 CALL PUSHCONTROL1B(0)
4702 CALL PUSHREAL8(qci(i, k, 2))
4703 qci(i, k, 2) = qci(i, k, 2) - psaci(i, k)*dtcld
4704 CALL PUSHCONTROL1B(1)
4706 IF (qrs(i, k, 2) + psaci(i, k)*dtcld .LT. 0.) THEN
4707 CALL PUSHREAL8(qrs(i, k, 2))
4709 CALL PUSHCONTROL1B(0)
4711 CALL PUSHREAL8(qrs(i, k, 2))
4712 qrs(i, k, 2) = qrs(i, k, 2) + psaci(i, k)*dtcld
4713 CALL PUSHCONTROL1B(1)
4715 !-------------------------------------------------------------
4716 ! pgaci: Accretion of cloud ice by graupel [LFO 41]
4717 ! (T<T0: I->G) pgaci:min=0,max=qci(i,k,2)/dtcld
4718 !-------------------------------------------------------------
4719 ! supcol = t0c-t(i,k) !not change
4720 ! call smoothif(supcol, 0.,fsupcol,'t0')
4721 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
4722 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
4723 !min(exp(0.07*(-supcol)),1.)
4726 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4727 CALL PUSHREAL8(max12)
4729 CALL PUSHCONTROL1B(0)
4731 CALL PUSHREAL8(max12)
4732 max12 = qrs(i, k, 3)
4733 CALL PUSHCONTROL1B(1)
4735 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max12**(bvtg/4.)
4736 IF (qci(i, k, 2) .LT. qmin) THEN
4737 CALL PUSHREAL8(max13)
4739 CALL PUSHCONTROL1B(0)
4741 CALL PUSHREAL8(max13)
4742 max13 = qci(i, k, 2)
4743 CALL PUSHCONTROL1B(1)
4745 vt2i = vt2i_a*(den(i, k)*max13)**(1.31/8.)
4746 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4747 CALL PUSHREAL8(max14)
4749 CALL PUSHCONTROL1B(1)
4751 CALL PUSHREAL8(max14)
4752 max14 = qrs(i, k, 3)
4753 CALL PUSHCONTROL1B(0)
4755 IF (qci(i, k, 2) .LT. qmin) THEN
4756 CALL PUSHREAL8(max25)
4758 CALL PUSHCONTROL1B(0)
4760 CALL PUSHREAL8(max25)
4761 max25 = qci(i, k, 2)
4762 CALL PUSHCONTROL1B(1)
4765 b = (den(i, k)*max14)**(3./4.)*max25
4766 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4767 CALL PUSHREAL8(max15)
4769 CALL PUSHCONTROL1B(1)
4771 CALL PUSHREAL8(max15)
4772 max15 = qrs(i, k, 3)
4773 CALL PUSHCONTROL1B(0)
4775 IF (qci(i, k, 2) .LT. qmin) THEN
4776 CALL PUSHREAL8(max26)
4778 CALL PUSHCONTROL1B(0)
4780 CALL PUSHREAL8(max26)
4781 max26 = qci(i, k, 2)
4782 CALL PUSHCONTROL1B(1)
4785 c = den(i, k)**(5./8.)*SQRT(max15)*max26**(9./8.)
4786 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4787 CALL PUSHREAL8(max16)
4789 CALL PUSHCONTROL1B(1)
4791 CALL PUSHREAL8(max16)
4792 max16 = qrs(i, k, 3)
4793 CALL PUSHCONTROL1B(0)
4795 IF (qci(i, k, 2) .LT. qmin) THEN
4796 CALL PUSHREAL8(max27)
4798 CALL PUSHCONTROL1B(0)
4800 CALL PUSHREAL8(max27)
4801 max27 = qci(i, k, 2)
4802 CALL PUSHCONTROL1B(1)
4805 d = SQRT(den(i, k))*SQRT(SQRT(max16))*max27**(5./4.)
4806 IF (vt2g - vt2i .GE. 0.) THEN
4807 CALL PUSHREAL8(abs5)
4809 CALL PUSHCONTROL1B(0)
4811 CALL PUSHREAL8(abs5)
4813 CALL PUSHCONTROL1B(1)
4815 pgaci1 = pgaci_a*abs5*(pgaci_b*b+pgaci_c*c+pgaci_d*d)*egi
4816 IF (pgaci1 .GT. qci(i, k, 2)/dtcld) THEN
4817 pgaci(i, k) = qci(i, k, 2)/dtcld
4818 CALL PUSHCONTROL1B(0)
4820 pgaci(i, k) = pgaci1
4821 CALL PUSHCONTROL1B(1)
4823 CALL PUSHREAL8(pgaci(i, k))
4824 pgaci(i, k) = fsupcol*pgaci(i, k)
4825 IF (pgaci(i, k) .GE. 0.) THEN
4830 IF (abs6 .LT. qmin/dtcld) THEN
4832 CALL PUSHCONTROL1B(1)
4834 CALL PUSHCONTROL1B(0)
4836 IF (qci(i, k, 2) - pgaci(i, k)*dtcld .LT. 0.) THEN
4837 CALL PUSHREAL8(qci(i, k, 2))
4839 CALL PUSHCONTROL1B(0)
4841 CALL PUSHREAL8(qci(i, k, 2))
4842 qci(i, k, 2) = qci(i, k, 2) - pgaci(i, k)*dtcld
4843 CALL PUSHCONTROL1B(1)
4845 IF (qrs(i, k, 3) + pgaci(i, k)*dtcld .LT. 0.) THEN
4846 CALL PUSHREAL8(qrs(i, k, 3))
4848 CALL PUSHCONTROL1B(0)
4850 CALL PUSHREAL8(qrs(i, k, 3))
4851 qrs(i, k, 3) = qrs(i, k, 3) + pgaci(i, k)*dtcld
4852 CALL PUSHCONTROL1B(1)
4854 !-------------------------------------------------------------
4855 ! psacw: Accretion of cloud water by snow [LFO 24]
4856 ! (T<T0: C->G, and T>=T0: C->R) psacw:min=0,max=qci(i,k,1)/dtcld
4857 !-------------------------------------------------------------
4858 ! supcol = t0c-t(i,k) !not change
4859 ! call smoothif(supcol, 0.,fsupcol,'t0')
4860 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
4861 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
4863 ! cpm(i,k)=cpmcal(q(i,k)) !not change
4864 xl(i, k) = XLCAL(t(i, k))
4866 xlf = xls - xl(i, k)
4867 IF (supcol .LT. 0.) THEN
4869 CALL PUSHCONTROL1B(0)
4871 CALL PUSHCONTROL1B(1)
4873 IF (qrs(i, k, 2) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
4874 IF (90. .GT. t0c - t(i, k)) THEN
4876 CALL PUSHCONTROL1B(0)
4878 CALL PUSHCONTROL1B(1)
4881 IF (0. .LT. y5) THEN
4882 CALL PUSHREAL8(max17)
4884 CALL PUSHCONTROL1B(0)
4886 CALL PUSHREAL8(max17)
4888 CALL PUSHCONTROL1B(1)
4891 a = EXP((1.-bvts)*alpha*max17/4.)
4892 psacw(i, k) = psacw_a*a*den(i, k)**((1.+bvts)/4.)*qrs(i, k, 2)&
4893 & **((3.+bvts)/4.)*qci(i, k, 1)
4894 CALL PUSHCONTROL1B(0)
4897 CALL PUSHCONTROL1B(1)
4899 IF (psacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
4900 x6 = qci(i, k, 1)/dtcld
4901 CALL PUSHCONTROL1B(0)
4904 CALL PUSHCONTROL1B(1)
4906 IF (x6 .LT. 0.) THEN
4908 CALL PUSHCONTROL1B(0)
4911 CALL PUSHCONTROL1B(1)
4913 CALL PUSHREAL8(psacw(i, k))
4914 psacw(i, k) = fsupcol*psacw(i, k)
4915 IF (psacw(i, k) .GE. 0.) THEN
4920 IF (abs7 .LT. qmin/dtcld) THEN
4922 CALL PUSHCONTROL1B(1)
4924 CALL PUSHCONTROL1B(0)
4926 IF (qci(i, k, 1) - psacw(i, k)*dtcld .LT. 0.) THEN
4927 CALL PUSHREAL8(qci(i, k, 1))
4929 CALL PUSHCONTROL1B(0)
4931 CALL PUSHREAL8(qci(i, k, 1))
4932 qci(i, k, 1) = qci(i, k, 1) - psacw(i, k)*dtcld
4933 CALL PUSHCONTROL1B(1)
4935 x7 = qrs(i, k, 1) + (1.-fsupcol)*psacw(i, k)*dtcld
4936 IF (x7 .LT. 0.) THEN
4937 CALL PUSHREAL8(qrs(i, k, 1))
4939 CALL PUSHCONTROL1B(0)
4941 CALL PUSHREAL8(qrs(i, k, 1))
4943 CALL PUSHCONTROL1B(1)
4945 x8 = qrs(i, k, 3) + fsupcol*psacw(i, k)*dtcld
4946 IF (x8 .LT. 0.) THEN
4947 CALL PUSHREAL8(qrs(i, k, 3))
4949 CALL PUSHCONTROL1B(0)
4951 CALL PUSHREAL8(qrs(i, k, 3))
4953 CALL PUSHCONTROL1B(1)
4955 t(i, k) = t(i, k) + fsupcol*psacw(i, k)*dtcld*xlf/cpm(i, k)
4957 !-------------------------------------------------------------
4958 ! pgacw: Accretion of cloud water by graupel [LFO 40]
4959 ! (T<T0: C->G, and T>=T0: C->R) pgacw:min=0.,max=qci(i,k,1)/dtcld
4960 !-------------------------------------------------------------
4961 CALL PUSHREAL8(supcol)
4962 supcol = t0c - t(i, k)
4963 CALL PUSHREAL8(fsupcol)
4964 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4965 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
4966 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
4967 ! cpm(i,k)=cpmcal(q(i,k)) !not change
4968 xl(i, k) = XLCAL(t(i, k))
4970 xlf = xls - xl(i, k)
4971 IF (supcol .LT. 0.) THEN
4973 CALL PUSHCONTROL1B(0)
4975 CALL PUSHCONTROL1B(1)
4977 IF (qrs(i, k, 3) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
4978 pgacw(i, k) = pgacw_a*den(i, k)**((1.+bvtg)/4.)*qrs(i, k, 3)**&
4979 & ((3.+bvtg)/4.)*qci(i, k, 1)
4980 CALL PUSHCONTROL1B(0)
4983 CALL PUSHCONTROL1B(1)
4985 IF (pgacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
4986 x9 = qci(i, k, 1)/dtcld
4987 CALL PUSHCONTROL1B(0)
4990 CALL PUSHCONTROL1B(1)
4992 IF (x9 .LT. 0.) THEN
4994 CALL PUSHCONTROL1B(0)
4997 CALL PUSHCONTROL1B(1)
4999 IF (pgacw(i, k) .GE. 0.) THEN
5004 !pgacw(i,k)=fqg*fqc*pgacw(i,k)
5005 IF (abs8 .LT. qmin/dtcld) THEN
5007 CALL PUSHCONTROL1B(1)
5009 CALL PUSHCONTROL1B(0)
5011 IF (qci(i, k, 1) - pgacw(i, k)*dtcld .LT. 0.) THEN
5012 CALL PUSHCONTROL1B(0)
5014 CALL PUSHCONTROL1B(1)
5016 x10 = qrs(i, k, 1) + (1.-fsupcol)*pgacw(i, k)*dtcld
5017 IF (x10 .LT. 0.) THEN
5018 CALL PUSHREAL8(qrs(i, k, 1))
5020 CALL PUSHCONTROL1B(0)
5022 CALL PUSHREAL8(qrs(i, k, 1))
5024 CALL PUSHCONTROL1B(1)
5026 x11 = qrs(i, k, 3) + fsupcol*pgacw(i, k)*dtcld
5027 IF (x11 .LT. 0.) THEN
5028 CALL PUSHCONTROL1B(0)
5030 CALL PUSHCONTROL1B(1)
5038 a_temp4 = dtcld*a_t(i, k)
5039 a_temp6 = fsupcol*xlf*a_temp4/cpm(i, k)
5040 temp8 = pgacw(i, k)/cpm(i, k)
5041 a_fsupcol = xlf*temp8*a_temp4 - pgacw(i, k)*a_pgacw(i, k)
5042 a_pgacw(i, k) = (1-fsupcol)*a_pgacw(i, k) + a_temp6
5043 a_xlf = fsupcol*temp8*a_temp4
5044 a_cpm(i, k) = a_cpm(i, k) - temp8*a_temp6
5045 CALL POPCONTROL1B(branch)
5046 IF (branch .EQ. 0) THEN
5047 a_qrs(i, k, 3) = 0.0_8
5050 a_x11 = a_qrs(i, k, 3)
5051 a_qrs(i, k, 3) = 0.0_8
5053 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x11
5054 a_fsupcol = a_fsupcol + pgacw(i, k)*dtcld*a_x11
5055 a_pgacw(i, k) = a_pgacw(i, k) + fsupcol*dtcld*a_x11
5056 CALL POPCONTROL1B(branch)
5057 IF (branch .EQ. 0) THEN
5058 CALL POPREAL8(qrs(i, k, 1))
5059 a_qrs(i, k, 1) = 0.0_8
5062 CALL POPREAL8(qrs(i, k, 1))
5063 a_x10 = a_qrs(i, k, 1)
5064 a_qrs(i, k, 1) = 0.0_8
5066 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_x10
5067 a_fsupcol = a_fsupcol - pgacw(i, k)*dtcld*a_x10
5068 a_pgacw(i, k) = a_pgacw(i, k) + (1.-fsupcol)*dtcld*a_x10
5069 CALL POPCONTROL1B(branch)
5070 IF (branch .EQ. 0) THEN
5071 a_qci(i, k, 1) = 0.0_8
5073 a_pgacw(i, k) = a_pgacw(i, k) - dtcld*a_qci(i, k, 1)
5075 CALL POPCONTROL1B(branch)
5076 IF (branch .NE. 0) a_pgacw(i, k) = 0.0_8
5077 CALL POPCONTROL1B(branch)
5078 IF (branch .EQ. 0) THEN
5079 a_pgacw(i, k) = 0.0_8
5082 a_x9 = a_pgacw(i, k)
5083 a_pgacw(i, k) = 0.0_8
5085 CALL POPCONTROL1B(branch)
5086 IF (branch .EQ. 0) THEN
5087 a_qci(i, k, 1) = a_qci(i, k, 1) + a_x9/dtcld
5089 a_pgacw(i, k) = a_pgacw(i, k) + a_x9
5091 CALL POPCONTROL1B(branch)
5092 IF (branch .EQ. 0) THEN
5093 temp9 = (bvtg+3.)/4.
5094 temp7 = (bvtg+1.)/4.
5095 temp6 = den(i, k)**temp7
5096 a_temp6 = qrs(i, k, 3)**temp9*pgacw_a*a_pgacw(i, k)
5097 IF (.NOT.(qrs(i, k, 3) .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR.&
5098 & temp9 .NE. INT(temp9)))) a_qrs(i, k, 3) = a_qrs(i, k, 3) +&
5099 & temp9*qrs(i, k, 3)**(temp9-1)*temp6*qci(i, k, 1)*pgacw_a*&
5101 a_pgacw(i, k) = 0.0_8
5102 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. &
5103 & temp7 .NE. INT(temp7)))) a_den(i, k) = a_den(i, k) + temp7&
5104 & *den(i, k)**(temp7-1)*qci(i, k, 1)*a_temp6
5105 a_qci(i, k, 1) = a_qci(i, k, 1) + temp6*a_temp6
5107 a_pgacw(i, k) = 0.0_8
5109 CALL POPCONTROL1B(branch)
5110 IF (branch .EQ. 0) a_xlf = 0.0_8
5111 supcol = t0c - t(i, k)
5113 a_xl(i, k) = a_xl(i, k) - a_xlf
5114 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
5116 CALL POPREAL8(fsupcol)
5118 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
5119 CALL POPREAL8(supcol)
5120 a_t(i, k) = a_t(i, k) - a_supcol
5121 temp8 = psacw(i, k)/cpm(i, k)
5122 a_temp4 = dtcld*a_t(i, k)
5123 a_fsupcol = xlf*temp8*a_temp4 - psacw(i, k)*a_psacw(i, k)
5124 a_xlf = fsupcol*temp8*a_temp4
5125 a_temp6 = fsupcol*xlf*a_temp4/cpm(i, k)
5126 a_psacw(i, k) = (1-fsupcol)*a_psacw(i, k) + a_temp6
5127 a_cpm(i, k) = a_cpm(i, k) - temp8*a_temp6
5128 CALL POPCONTROL1B(branch)
5129 IF (branch .EQ. 0) THEN
5130 CALL POPREAL8(qrs(i, k, 3))
5131 a_qrs(i, k, 3) = 0.0_8
5134 CALL POPREAL8(qrs(i, k, 3))
5135 a_x8 = a_qrs(i, k, 3)
5136 a_qrs(i, k, 3) = 0.0_8
5138 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x8
5139 a_fsupcol = a_fsupcol + psacw(i, k)*dtcld*a_x8
5140 a_psacw(i, k) = a_psacw(i, k) + fsupcol*dtcld*a_x8
5141 CALL POPCONTROL1B(branch)
5142 IF (branch .EQ. 0) THEN
5143 CALL POPREAL8(qrs(i, k, 1))
5144 a_qrs(i, k, 1) = 0.0_8
5147 CALL POPREAL8(qrs(i, k, 1))
5148 a_x7 = a_qrs(i, k, 1)
5149 a_qrs(i, k, 1) = 0.0_8
5151 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_x7
5152 a_fsupcol = a_fsupcol - psacw(i, k)*dtcld*a_x7
5153 a_psacw(i, k) = a_psacw(i, k) + (1.-fsupcol)*dtcld*a_x7
5154 CALL POPCONTROL1B(branch)
5155 IF (branch .EQ. 0) THEN
5156 CALL POPREAL8(qci(i, k, 1))
5157 a_qci(i, k, 1) = 0.0_8
5159 CALL POPREAL8(qci(i, k, 1))
5160 a_psacw(i, k) = a_psacw(i, k) - dtcld*a_qci(i, k, 1)
5162 CALL POPCONTROL1B(branch)
5163 IF (branch .NE. 0) a_psacw(i, k) = 0.0_8
5164 CALL POPREAL8(psacw(i, k))
5165 a_fsupcol = a_fsupcol + psacw(i, k)*a_psacw(i, k)
5166 a_psacw(i, k) = fsupcol*a_psacw(i, k)
5167 CALL POPCONTROL1B(branch)
5168 IF (branch .EQ. 0) THEN
5169 a_psacw(i, k) = 0.0_8
5172 a_x6 = a_psacw(i, k)
5173 a_psacw(i, k) = 0.0_8
5175 CALL POPCONTROL1B(branch)
5176 IF (branch .EQ. 0) THEN
5177 a_qci(i, k, 1) = a_qci(i, k, 1) + a_x6/dtcld
5179 a_psacw(i, k) = a_psacw(i, k) + a_x6
5181 CALL POPCONTROL1B(branch)
5182 IF (branch .EQ. 0) THEN
5183 temp9 = (bvts+3.)/4.
5184 temp7 = a*qci(i, k, 1)
5185 temp6 = (bvts+1.)/4.
5186 temp5 = den(i, k)**temp6
5187 a_temp6 = qrs(i, k, 2)**temp9*psacw_a*a_psacw(i, k)
5188 IF (.NOT.(qrs(i, k, 2) .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR.&
5189 & temp9 .NE. INT(temp9)))) a_qrs(i, k, 2) = a_qrs(i, k, 2) +&
5190 & temp9*qrs(i, k, 2)**(temp9-1)*temp5*temp7*psacw_a*a_psacw(&
5192 a_psacw(i, k) = 0.0_8
5193 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
5194 & temp6 .NE. INT(temp6)))) a_den(i, k) = a_den(i, k) + temp6&
5195 & *den(i, k)**(temp6-1)*temp7*a_temp6
5196 a_a = qci(i, k, 1)*temp5*a_temp6
5197 a_qci(i, k, 1) = a_qci(i, k, 1) + a*temp5*a_temp6
5199 a_max17 = (1.-bvts)*alpha*EXP((1.-bvts)*alpha*(max17/4.))*a_a/&
5201 CALL POPCONTROL1B(branch)
5202 IF (branch .EQ. 0) THEN
5203 CALL POPREAL8(max17)
5206 CALL POPREAL8(max17)
5209 CALL POPCONTROL1B(branch)
5210 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y5
5212 a_psacw(i, k) = 0.0_8
5214 CALL POPCONTROL1B(branch)
5215 IF (branch .EQ. 0) a_xlf = 0.0_8
5217 a_xl(i, k) = a_xl(i, k) - a_xlf
5218 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
5220 a_pgaci(i, k) = 0.0_8
5221 CALL POPCONTROL1B(branch)
5222 IF (branch .EQ. 0) THEN
5223 CALL POPREAL8(qrs(i, k, 3))
5224 a_qrs(i, k, 3) = 0.0_8
5226 CALL POPREAL8(qrs(i, k, 3))
5227 a_pgaci(i, k) = a_pgaci(i, k) + dtcld*a_qrs(i, k, 3)
5229 CALL POPCONTROL1B(branch)
5230 IF (branch .EQ. 0) THEN
5231 CALL POPREAL8(qci(i, k, 2))
5232 a_qci(i, k, 2) = 0.0_8
5234 CALL POPREAL8(qci(i, k, 2))
5235 a_pgaci(i, k) = a_pgaci(i, k) - dtcld*a_qci(i, k, 2)
5237 CALL POPCONTROL1B(branch)
5238 IF (branch .NE. 0) a_pgaci(i, k) = 0.0_8
5239 CALL POPREAL8(pgaci(i, k))
5240 a_fsupcol = a_fsupcol + pgaci(i, k)*a_pgaci(i, k)
5241 a_pgaci(i, k) = fsupcol*a_pgaci(i, k)
5242 CALL POPCONTROL1B(branch)
5243 IF (branch .EQ. 0) THEN
5244 a_qci(i, k, 2) = a_qci(i, k, 2) + a_pgaci(i, k)/dtcld
5245 a_pgaci(i, k) = 0.0_8
5248 a_pgaci1 = a_pgaci(i, k)
5249 a_pgaci(i, k) = 0.0_8
5251 a_temp4 = abs5*egi*pgaci_a*a_pgaci1
5252 a_temp6 = (pgaci_b*b+pgaci_c*c+pgaci_d*d)*pgaci_a*a_pgaci1
5253 a_abs5 = egi*a_temp6
5254 a_egi = abs5*a_temp6
5255 a_b = pgaci_b*a_temp4
5256 a_c = pgaci_c*a_temp4
5257 a_d = pgaci_d*a_temp4
5258 CALL POPCONTROL1B(branch)
5259 IF (branch .EQ. 0) THEN
5272 temp6 = max27**temp7
5273 temp5 = SQRT(den(i, k))
5274 IF (.NOT.den(i, k) .EQ. 0.0_8) a_den(i, k) = a_den(i, k) + temp6&
5275 & *temp8*a_d/(2.0*temp5)
5276 IF (max27 .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 .NE. INT&
5280 a_max27 = temp7*max27**(temp7-1)*temp5*temp8*a_d
5282 IF (max16 .EQ. 0.0_8 .OR. temp9 .EQ. 0.0_8) THEN
5285 a_max16 = temp5*temp6*a_d/(2.0**2*temp9*temp8)
5287 CALL POPCONTROL1B(branch)
5288 IF (branch .EQ. 0) THEN
5289 CALL POPREAL8(max27)
5291 CALL POPREAL8(max27)
5292 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max27
5294 CALL POPCONTROL1B(branch)
5295 IF (branch .EQ. 0) THEN
5296 CALL POPREAL8(max16)
5297 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max16
5299 CALL POPREAL8(max16)
5303 temp8 = max26**temp9
5306 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
5307 & temp6 .NE. INT(temp6)))) a_den(i, k) = a_den(i, k) + temp6*&
5308 & den(i, k)**(temp6-1)*temp7*temp8*a_c
5309 a_temp0 = den(i, k)**temp6*a_c
5310 IF (max15 .EQ. 0.0_8) THEN
5313 a_max15 = temp8*a_temp0/(2.0*temp7)
5315 IF (max26 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
5319 a_max26 = temp9*max26**(temp9-1)*temp7*a_temp0
5321 CALL POPCONTROL1B(branch)
5322 IF (branch .EQ. 0) THEN
5323 CALL POPREAL8(max26)
5325 CALL POPREAL8(max26)
5326 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max26
5328 CALL POPCONTROL1B(branch)
5329 IF (branch .EQ. 0) THEN
5330 CALL POPREAL8(max15)
5331 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max15
5333 CALL POPREAL8(max15)
5336 temp9 = den(i, k)*max14
5338 IF (temp9 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. INT&
5342 a_temp4 = temp8*temp9**(temp8-1)*max25*a_b
5344 a_max25 = temp9**temp8*a_b
5345 a_den(i, k) = a_den(i, k) + max14*a_temp4
5346 a_max14 = den(i, k)*a_temp4
5347 CALL POPCONTROL1B(branch)
5348 IF (branch .EQ. 0) THEN
5349 CALL POPREAL8(max25)
5351 CALL POPREAL8(max25)
5352 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max25
5354 CALL POPCONTROL1B(branch)
5355 IF (branch .EQ. 0) THEN
5356 CALL POPREAL8(max14)
5357 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max14
5359 CALL POPREAL8(max14)
5361 IF (den(i, k)*max13 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. &
5362 & 1.31/8. .NE. INT(1.31/8.))) THEN
5365 a_temp4 = 1.31*(den(i, k)*max13)**(1.31/8.-1)*vt2i_a*a_vt2i/8.
5367 a_den(i, k) = a_den(i, k) + max13*a_temp4
5368 a_max13 = den(i, k)*a_temp4
5369 CALL POPCONTROL1B(branch)
5370 IF (branch .EQ. 0) THEN
5371 CALL POPREAL8(max13)
5373 CALL POPREAL8(max13)
5374 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max13
5377 temp8 = (bvtg-2.)/4.
5378 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. &
5379 & temp8 .NE. INT(temp8)))) a_den(i, k) = a_den(i, k) + temp8*&
5380 & den(i, k)**(temp8-1)*max12**temp9*vt2g_a*a_vt2g
5381 IF (max12 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
5385 a_max12 = temp9*max12**(temp9-1)*den(i, k)**temp8*vt2g_a*&
5388 CALL POPCONTROL1B(branch)
5389 IF (branch .EQ. 0) THEN
5390 CALL POPREAL8(max12)
5392 CALL POPREAL8(max12)
5393 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max12
5397 a_psaci(i, k) = 0.0_8
5398 CALL POPCONTROL1B(branch)
5399 IF (branch .EQ. 0) THEN
5400 CALL POPREAL8(qrs(i, k, 2))
5401 a_qrs(i, k, 2) = 0.0_8
5403 CALL POPREAL8(qrs(i, k, 2))
5404 a_psaci(i, k) = a_psaci(i, k) + dtcld*a_qrs(i, k, 2)
5406 CALL POPCONTROL1B(branch)
5407 IF (branch .EQ. 0) THEN
5408 CALL POPREAL8(qci(i, k, 2))
5409 a_qci(i, k, 2) = 0.0_8
5411 CALL POPREAL8(qci(i, k, 2))
5412 a_psaci(i, k) = a_psaci(i, k) - dtcld*a_qci(i, k, 2)
5414 CALL POPCONTROL1B(branch)
5415 IF (branch .NE. 0) a_psaci(i, k) = 0.0_8
5416 CALL POPREAL8(psaci(i, k))
5417 a_fsupcol = a_fsupcol + psaci(i, k)*a_psaci(i, k)
5418 a_psaci(i, k) = fsupcol*a_psaci(i, k)
5419 CALL POPCONTROL1B(branch)
5420 IF (branch .EQ. 0) THEN
5421 a_qci(i, k, 2) = a_qci(i, k, 2) + a_psaci(i, k)/dtcld
5422 a_psaci(i, k) = 0.0_8
5425 a_psaci1 = a_psaci(i, k)
5426 a_psaci(i, k) = 0.0_8
5428 a_temp4 = (psaci_b*b+psaci_c*c+psaci_d*d)*psaci_a*a_psaci1
5429 a_temp6 = a*abs3*eacrs*psaci_a*a_psaci1
5430 a_b = psaci_b*a_temp6
5431 a_c = psaci_c*a_temp6
5432 a_d = psaci_d*a_temp6
5433 a_a = abs3*eacrs*a_temp4
5434 a_abs3 = a*eacrs*a_temp4
5435 a_eacrs = a_eacrs + a*abs3*a_temp4
5436 CALL POPCONTROL1B(branch)
5437 IF (branch .EQ. 0) THEN
5449 temp7 = -(alpha*max11/4.)
5452 temp3 = max30**temp4
5453 temp2 = SQRT(den(i, k))
5454 a_temp0 = temp6*temp8*a_d
5455 a_temp5 = temp2*temp3*a_d
5456 a_max11 = -(alpha*EXP(temp7)*temp8*a_temp5/4.)
5457 IF (max24 .EQ. 0.0_8 .OR. temp9 .EQ. 0.0_8) THEN
5460 a_max24 = temp6*a_temp5/(2.0**2*temp9*temp8)
5462 IF (.NOT.den(i, k) .EQ. 0.0_8) a_den(i, k) = a_den(i, k) + temp3&
5463 & *a_temp0/(2.0*temp2)
5464 IF (max30 .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. temp4 .NE. INT&
5468 a_max30 = temp4*max30**(temp4-1)*temp2*a_temp0
5470 CALL POPCONTROL1B(branch)
5471 IF (branch .EQ. 0) THEN
5472 CALL POPREAL8(max30)
5474 CALL POPREAL8(max30)
5475 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max30
5477 CALL POPCONTROL1B(branch)
5478 IF (branch .EQ. 0) THEN
5479 CALL POPREAL8(max24)
5480 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max24
5482 CALL POPREAL8(max24)
5484 CALL POPCONTROL1B(branch)
5485 IF (branch .EQ. 0) THEN
5486 CALL POPREAL8(max11)
5489 CALL POPREAL8(max11)
5492 CALL POPCONTROL1B(branch)
5493 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y4
5496 temp5 = max29**temp6
5499 temp1 = den(i, k)**temp2
5500 temp7 = -(alpha*max10/2.)
5502 a_temp3 = temp4*temp5*a_c
5503 a_temp4 = temp8*temp1*a_c
5504 IF (max23 .EQ. 0.0_8) THEN
5507 a_max23 = temp5*a_temp4/(2.0*temp4)
5509 IF (max29 .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. temp6 .NE. INT&
5513 a_max29 = temp6*max29**(temp6-1)*temp4*a_temp4
5515 a_max10 = -(alpha*EXP(temp7)*temp1*a_temp3/2.)
5516 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
5517 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2*&
5518 & den(i, k)**(temp2-1)*temp8*a_temp3
5519 CALL POPCONTROL1B(branch)
5520 IF (branch .EQ. 0) THEN
5521 CALL POPREAL8(max29)
5523 CALL POPREAL8(max29)
5524 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max29
5526 CALL POPCONTROL1B(branch)
5527 IF (branch .EQ. 0) THEN
5528 CALL POPREAL8(max23)
5529 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max23
5531 CALL POPREAL8(max23)
5533 CALL POPCONTROL1B(branch)
5534 IF (branch .EQ. 0) THEN
5535 CALL POPREAL8(max10)
5538 CALL POPREAL8(max10)
5541 CALL POPCONTROL1B(branch)
5542 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y3
5544 temp5 = den(i, k)*max22
5545 temp4 = temp5**temp6
5546 temp3 = -(3.*alpha*max9/4.)
5547 a_max9 = -(alpha*3.*EXP(temp3)*temp4*max28*a_b/4.)
5548 a_temp = EXP(temp3)*a_b
5549 IF (temp5 .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. temp6 .NE. INT&
5553 a_temp0 = temp6*temp5**(temp6-1)*max28*a_temp
5555 a_max28 = temp4*a_temp
5556 a_den(i, k) = a_den(i, k) + max22*a_temp0
5557 a_max22 = den(i, k)*a_temp0
5558 b = (den(i, k)*max3)**(3./4.)*max18
5559 CALL POPCONTROL1B(branch)
5560 IF (branch .EQ. 0) THEN
5561 CALL POPREAL8(max28)
5563 CALL POPREAL8(max28)
5564 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max28
5566 CALL POPCONTROL1B(branch)
5567 IF (branch .EQ. 0) THEN
5568 CALL POPREAL8(max22)
5569 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max22
5571 CALL POPREAL8(max22)
5573 CALL POPCONTROL1B(branch)
5574 IF (branch .EQ. 0) THEN
5581 CALL POPCONTROL1B(branch)
5582 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y2
5584 a_max8 = alpha*EXP(alpha*max8)*a_a
5585 CALL POPCONTROL1B(branch)
5586 IF (branch .EQ. 0) THEN
5593 CALL POPCONTROL1B(branch)
5594 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y1
5595 IF (den(i, k)*max7 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. &
5596 & 1.31/8. .NE. INT(1.31/8.))) THEN
5599 a_temp2 = 1.31*(den(i, k)*max7)**(1.31/8.-1)*vt2i_a*a_vt2i/8.
5601 a_den(i, k) = a_den(i, k) + max7*a_temp2
5602 a_max7 = den(i, k)*a_temp2
5603 CALL POPCONTROL1B(branch)
5604 IF (branch .EQ. 0) THEN
5608 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max7
5610 temp5 = -(alpha*bvts*max21/4.)
5613 temp1 = (bvts-2.)/4.
5614 temp6 = den(i, k)**temp1
5615 a_temp1 = EXP(temp5)*vt2s_a*a_vt2s
5616 a_max21 = -(alpha*bvts*EXP(temp5)*temp6*temp2*vt2s_a*a_vt2s/4.)
5617 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. &
5618 & temp1 .NE. INT(temp1)))) a_den(i, k) = a_den(i, k) + temp1*&
5619 & den(i, k)**(temp1-1)*temp2*a_temp1
5620 IF (max6 .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. temp3 .NE. INT(&
5624 a_max6 = temp3*max6**(temp3-1)*temp6*a_temp1
5626 CALL POPCONTROL1B(branch)
5627 IF (branch .EQ. 0) THEN
5628 CALL POPREAL8(max21)
5631 CALL POPREAL8(max21)
5634 CALL POPCONTROL1B(branch)
5635 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y6
5636 CALL POPCONTROL1B(branch)
5637 IF (branch .EQ. 0) THEN
5641 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max6
5643 CALL POPCONTROL1B(branch)
5644 IF (branch .EQ. 0) THEN
5645 CALL POPREAL8(eacrs)
5648 CALL POPREAL8(eacrs)
5651 a_supcol = -(0.07*EXP(-(0.07*supcol))*a_x5)
5652 CALL POPREAL8(fsupcol)
5653 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
5654 CALL POPREAL8(supcol)
5655 a_t(i, k) = a_t(i, k) - a_supcol
5656 a_temp0 = dtcld*a_t(i, k)/cpm(i, k)
5657 a_piacr(i, k) = xlf*a_temp0
5658 a_xlf = piacr(i, k)*a_temp0
5659 a_cpm(i, k) = a_cpm(i, k) - piacr(i, k)*xlf*a_temp0/cpm(i, k)
5660 CALL POPCONTROL1B(branch)
5661 IF (branch .EQ. 0) THEN
5662 CALL POPREAL8(qrs(i, k, 3))
5663 a_qrs(i, k, 3) = 0.0_8
5666 CALL POPREAL8(qrs(i, k, 3))
5667 a_x4 = a_qrs(i, k, 3)
5668 a_qrs(i, k, 3) = 0.0_8
5670 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x4
5671 a_piacr(i, k) = a_piacr(i, k) + (1-delta3)*dtcld*a_x4
5672 CALL POPCONTROL1B(branch)
5673 IF (branch .EQ. 0) THEN
5674 CALL POPREAL8(qrs(i, k, 2))
5675 a_qrs(i, k, 2) = 0.0_8
5678 CALL POPREAL8(qrs(i, k, 2))
5679 a_x3 = a_qrs(i, k, 2)
5680 a_qrs(i, k, 2) = 0.0_8
5682 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_x3
5683 a_piacr(i, k) = a_piacr(i, k) + delta3*dtcld*a_x3
5684 CALL POPCONTROL1B(branch)
5685 IF (branch .EQ. 0) THEN
5686 CALL POPREAL8(qrs(i, k, 1))
5687 a_qrs(i, k, 1) = 0.0_8
5689 CALL POPREAL8(qrs(i, k, 1))
5690 a_piacr(i, k) = a_piacr(i, k) - dtcld*a_qrs(i, k, 1)
5692 CALL POPCONTROL1B(branch)
5693 IF (branch .NE. 0) a_piacr(i, k) = 0.0_8
5694 CALL POPCONTROL1B(branch)
5695 IF (branch .EQ. 0) THEN
5696 CALL POPREAL8(delta3)
5698 CALL POPREAL8(delta3)
5700 CALL POPREAL8(piacr(i, k))
5701 a_fsupcol = piacr(i, k)*a_piacr(i, k)
5702 a_piacr(i, k) = fsupcol*a_piacr(i, k)
5703 CALL POPCONTROL1B(branch)
5704 IF (branch .EQ. 0) THEN
5705 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_piacr(i, k)/dtcld
5706 a_piacr(i, k) = 0.0_8
5709 a_piacr1 = a_piacr(i, k)
5710 a_piacr(i, k) = 0.0_8
5712 CALL POPCONTROL1B(branch)
5713 IF (branch .NE. 0) THEN
5714 temp5 = (bvtr+6.)/4.
5715 temp3 = qci(i, k, 2)**0.75
5716 temp2 = (bvtr+3.)/4.
5717 temp1 = den(i, k)**temp2
5718 a_temp1 = qrs(i, k, 1)**temp5*piacr_a*a_piacr1
5719 IF (.NOT.(qrs(i, k, 1) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR.&
5720 & temp5 .NE. INT(temp5)))) a_qrs(i, k, 1) = a_qrs(i, k, 1) +&
5721 & temp5*qrs(i, k, 1)**(temp5-1)*temp1*temp3*piacr_a*a_piacr1
5722 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
5723 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2&
5724 & *den(i, k)**(temp2-1)*temp3*a_temp1
5725 a_qci(i, k, 2) = a_qci(i, k, 2) + 0.75*qci(i, k, 2)**(-0.25)*&
5728 CALL POPCONTROL1B(branch)
5729 IF (branch .EQ. 0) a_xlf = 0.0_8
5731 a_xl(i, k) = a_xl(i, k) - a_xlf
5732 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
5734 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
5736 CALL POPREAL8(fsupcol)
5738 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
5739 a_praci(i, k) = 0.0_8
5740 CALL POPCONTROL1B(branch)
5741 IF (branch .EQ. 0) THEN
5742 a_qrs(i, k, 3) = 0.0_8
5745 a_x2 = a_qrs(i, k, 3)
5746 a_qrs(i, k, 3) = 0.0_8
5748 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x2
5749 a_praci(i, k) = a_praci(i, k) + (1-delta3)*dtcld*a_x2
5750 CALL POPCONTROL1B(branch)
5751 IF (branch .EQ. 0) THEN
5752 a_qrs(i, k, 2) = 0.0_8
5755 a_x1 = a_qrs(i, k, 2)
5756 a_qrs(i, k, 2) = 0.0_8
5758 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_x1
5759 a_praci(i, k) = a_praci(i, k) + delta3*dtcld*a_x1
5760 CALL POPCONTROL1B(branch)
5761 IF (branch .EQ. 0) THEN
5762 a_qci(i, k, 2) = 0.0_8
5764 a_praci(i, k) = a_praci(i, k) - dtcld*a_qci(i, k, 2)
5766 CALL POPCONTROL1B(branch)
5767 IF (branch .NE. 0) a_praci(i, k) = 0.0_8
5768 CALL POPCONTROL1B(branch)
5769 IF (branch .EQ. 0) THEN
5770 CALL POPREAL8(delta3)
5772 CALL POPREAL8(delta3)
5774 CALL POPREAL8(praci(i, k))
5775 a_fsupcol = praci(i, k)*a_praci(i, k)
5776 a_praci(i, k) = fsupcol*a_praci(i, k)
5777 CALL POPCONTROL1B(branch)
5778 IF (branch .EQ. 0) THEN
5779 a_qci(i, k, 2) = a_qci(i, k, 2) + a_praci(i, k)/dtcld
5780 a_praci(i, k) = 0.0_8
5783 a_praci1 = a_praci(i, k)
5784 a_praci(i, k) = 0.0_8
5786 a_abs0 = (praci_b*b+praci_c*c+praci_d*d)*praci_a*a_praci1
5787 a_temp0 = abs0*praci_a*a_praci1
5788 a_b = praci_b*a_temp0
5789 a_c = praci_c*a_temp0
5790 a_d = praci_d*a_temp0
5791 CALL POPCONTROL1B(branch)
5792 IF (branch .EQ. 0) THEN
5805 temp2 = max20**temp3
5806 temp1 = SQRT(den(i, k))
5807 IF (.NOT.den(i, k) .EQ. 0.0_8) a_den(i, k) = a_den(i, k) + temp2&
5808 & *temp4*a_d/(2.0*temp1)
5809 IF (max20 .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. temp3 .NE. INT&
5813 a_max20 = temp3*max20**(temp3-1)*temp1*temp4*a_d
5815 IF (max5 .EQ. 0.0_8 .OR. temp5 .EQ. 0.0_8) THEN
5818 a_max5 = temp1*temp2*a_d/(2.0**2*temp5*temp4)
5820 CALL POPCONTROL1B(branch)
5821 IF (branch .EQ. 0) THEN
5822 CALL POPREAL8(max20)
5824 CALL POPREAL8(max20)
5825 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max20
5827 CALL POPCONTROL1B(branch)
5828 IF (branch .EQ. 0) THEN
5830 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max5
5836 temp1 = max19**temp2
5839 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. &
5840 & temp4 .NE. INT(temp4)))) a_den(i, k) = a_den(i, k) + temp4*&
5841 & den(i, k)**(temp4-1)*temp3*temp1*a_c
5842 a_temp0 = den(i, k)**temp4*a_c
5843 IF (max4 .EQ. 0.0_8) THEN
5846 a_max4 = temp1*a_temp0/(2.0*temp3)
5848 IF (max19 .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. temp2 .NE. INT&
5852 a_max19 = temp2*max19**(temp2-1)*temp3*a_temp0
5854 CALL POPCONTROL1B(branch)
5855 IF (branch .EQ. 0) THEN
5856 CALL POPREAL8(max19)
5858 CALL POPREAL8(max19)
5859 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max19
5861 CALL POPCONTROL1B(branch)
5862 IF (branch .EQ. 0) THEN
5864 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max4
5869 temp2 = den(i, k)*max3
5871 IF (temp2 .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. temp1 .NE. INT&
5875 a_temp = temp1*temp2**(temp1-1)*max18*a_b
5877 a_max18 = temp2**temp1*a_b
5878 a_den(i, k) = a_den(i, k) + max3*a_temp
5879 a_max3 = den(i, k)*a_temp
5880 CALL POPCONTROL1B(branch)
5881 IF (branch .EQ. 0) THEN
5882 CALL POPREAL8(max18)
5884 CALL POPREAL8(max18)
5885 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max18
5887 CALL POPCONTROL1B(branch)
5888 IF (branch .EQ. 0) THEN
5890 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max3
5894 IF (den(i, k)*max2 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. &
5895 & 1.31/8. .NE. INT(1.31/8.))) THEN
5898 a_temp = 1.31*(den(i, k)*max2)**(1.31/8.-1)*vt2i_a*a_vt2i/8.
5900 a_den(i, k) = a_den(i, k) + max2*a_temp
5901 a_max2 = den(i, k)*a_temp
5902 CALL POPCONTROL1B(branch)
5903 IF (branch .EQ. 0) THEN
5907 a_qci(i, k, 2) = a_qci(i, k, 2) + a_max2
5910 temp2 = (bvtr-2.)/4.
5911 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
5912 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2*&
5913 & den(i, k)**(temp2-1)*max1**temp1*vt2r_a*a_vt2r
5914 IF (max1 .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. temp1 .NE. INT(&
5918 a_max1 = temp1*max1**(temp1-1)*den(i, k)**temp2*vt2r_a*a_vt2r
5920 CALL POPCONTROL1B(branch)
5921 IF (branch .EQ. 0) THEN
5925 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max1
5927 CALL POPREAL8(fsupcol)
5928 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
5929 a_t(i, k) = a_t(i, k) - a_supcol
5932 END SUBROUTINE A_ACCRET1
5934 !===================================================================
5935 SUBROUTINE ACCRET1(qci, den, qrs, t, q, dtcld, praci, piacr, psaci, &
5936 & pgaci, psacw, pgacw, ims, ime, kms, kme, its, ite, kts, kte)
5938 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
5939 !-------------------------------------------------------------------
5940 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
5941 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
5942 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
5943 REAL, DIMENSION(its:ite, kts:kte) :: praci, piacr, psaci, pgaci, &
5944 & psacw, pgacw, t, xl, cpm
5945 REAL :: supcol, dtcld, eacrs, egi, praci1, piacr1, psaci1, pgaci1, &
5948 REAL :: fsupcol, fqc, fqi, fqr, fqs, fqg, delta3, xlf, a, b, c, d, e
6012 !-------------------------------------------------------------
6013 ! praci: Accretion of cloud ice by rain [LFO 25]
6014 ! (T<T0: I->S or I->G) praci: min=0,max=qci(i,k,2)/dtcld
6015 !-------------------------------------------------------------
6016 supcol = t0c - t(i, k)
6017 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6018 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6023 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.)
6024 IF (qci(i, k, 2) .LT. qmin) THEN
6029 vt2i = vt2i_a*(den(i, k)*max2)**(1.31/8.)
6030 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6035 IF (qci(i, k, 2) .LT. qmin) THEN
6038 max18 = qci(i, k, 2)
6040 b = (den(i, k)*max3)**(3./4.)*max18
6041 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6046 IF (qci(i, k, 2) .LT. qmin) THEN
6049 max19 = qci(i, k, 2)
6051 c = den(i, k)**(5./8.)*SQRT(max4)*max19**(9./8.)
6052 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6057 IF (qci(i, k, 2) .LT. qmin) THEN
6060 max20 = qci(i, k, 2)
6062 d = SQRT(den(i, k))*SQRT(SQRT(max5))*max20**(5./4.)
6063 IF (vt2r - vt2i .GE. 0.) THEN
6068 praci1 = praci_a*abs0*(praci_b*b+praci_c*c+praci_d*d)
6069 IF (praci1 .GT. qci(i, k, 2)/dtcld) THEN
6070 praci(i, k) = qci(i, k, 2)/dtcld
6072 praci(i, k) = praci1
6074 praci(i, k) = fsupcol*praci(i, k)
6076 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
6081 IF (praci(i, k) .GE. 0.) THEN
6086 IF (abs1 .LT. qmin/dtcld) praci(i, k) = 0.
6087 IF (qci(i, k, 2) - praci(i, k)*dtcld .LT. 0.) THEN
6090 qci(i, k, 2) = qci(i, k, 2) - praci(i, k)*dtcld
6092 x1 = qrs(i, k, 2) + praci(i, k)*delta3*dtcld
6093 IF (x1 .LT. 0.) THEN
6098 x2 = qrs(i, k, 3) + praci(i, k)*(1-delta3)*dtcld
6099 IF (x2 .LT. 0.) THEN
6105 !-------------------------------------------------------------
6106 ! piacr: Accretion of rain by cloud ice [LFO 26]
6107 ! (T<T0: R->S or R->G) piacr: min=0,max=qrs(i,k,1)/dtcld
6108 !-------------------------------------------------------------
6109 ! supcol = t0c-t(i,k) !not change
6110 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6111 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
6112 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
6114 cpm(i, k) = CPMCAL(q(i, k))
6115 xl(i, k) = XLCAL(t(i, k))
6116 xlf = xls - xl(i, k)
6117 IF (supcol .LT. 0.) xlf = xlf0
6118 IF (qci(i, k, 2) .GT. 0. .AND. qrs(i, k, 1) .GT. 0.) THEN
6120 piacr1 = piacr_a*den(i, k)**((3.+bvtr)/4.)*qci(i, k, 2)**0.75*&
6121 & qrs(i, k, 1)**((6.+bvtr)/4.)
6125 IF (piacr1 .GT. qrs(i, k, 1)/dtcld) THEN
6126 piacr(i, k) = qrs(i, k, 1)/dtcld
6128 piacr(i, k) = piacr1
6130 piacr(i, k) = fsupcol*piacr(i, k)
6132 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
6137 IF (piacr(i, k) .GE. 0.) THEN
6142 IF (abs2 .LT. qmin/dtcld) piacr(i, k) = 0.
6143 IF (qrs(i, k, 1) - piacr(i, k)*dtcld .LT. 0.) THEN
6146 qrs(i, k, 1) = qrs(i, k, 1) - piacr(i, k)*dtcld
6148 x3 = qrs(i, k, 2) + piacr(i, k)*delta3*dtcld
6149 IF (x3 .LT. 0.) THEN
6154 x4 = qrs(i, k, 3) + piacr(i, k)*(1-delta3)*dtcld
6155 IF (x4 .LT. 0.) THEN
6160 t(i, k) = t(i, k) + piacr(i, k)*dtcld*xlf/cpm(i, k)
6162 !-------------------------------------------------------------
6163 ! psaci: Accretion of cloud ice by snow [HDC 10]
6164 ! (T<T0: I->S) psaci: min=0, max=qci(i,k,2)/dtcld
6165 !-------------------------------------------------------------
6166 supcol = t0c - t(i, k)
6167 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6168 x5 = EXP(0.07*(-supcol))
6169 IF (x5 .GT. 1.) THEN
6174 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6179 IF (90. .GT. t0c - t(i, k)) THEN
6184 IF (0. .LT. y6) THEN
6189 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max6**(bvts/4.)*EXP(-(&
6190 & alpha*bvts*max21/4.))
6191 IF (qci(i, k, 2) .LT. qmin) THEN
6196 vt2i = vt2i_a*(den(i, k)*max7)**(1.31/8.)
6197 IF (90. .GT. t0c - t(i, k)) THEN
6202 IF (0. .LT. y1) THEN
6208 IF (90. .GT. t0c - t(i, k)) THEN
6213 IF (0. .LT. y2) THEN
6218 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6221 max22 = qrs(i, k, 2)
6223 IF (qci(i, k, 2) .LT. qmin) THEN
6226 max28 = qci(i, k, 2)
6228 b = EXP(-(3.*alpha*max9/4.))*(den(i, k)*max22)**(3./4.)*max28
6229 IF (90. .GT. t0c - t(i, k)) THEN
6234 IF (0. .LT. y3) THEN
6239 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6242 max23 = qrs(i, k, 2)
6244 IF (qci(i, k, 2) .LT. qmin) THEN
6247 max29 = qci(i, k, 2)
6249 c = EXP(-(alpha*max10/2.))*den(i, k)**(5./8.)*SQRT(max23)*max29&
6251 IF (90. .GT. t0c - t(i, k)) THEN
6256 IF (0. .LT. y4) THEN
6261 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6264 max24 = qrs(i, k, 2)
6266 IF (qci(i, k, 2) .LT. qmin) THEN
6269 max30 = qci(i, k, 2)
6271 d = EXP(-(alpha*max11/4.))*SQRT(den(i, k))*SQRT(SQRT(max24))*&
6273 IF (vt2s - vt2i .GE. 0.) THEN
6278 psaci1 = psaci_a*a*abs3*(psaci_b*b+psaci_c*c+psaci_d*d)*eacrs
6279 IF (psaci1 .GT. qci(i, k, 2)/dtcld) THEN
6280 psaci(i, k) = qci(i, k, 2)/dtcld
6282 psaci(i, k) = psaci1
6284 psaci(i, k) = fsupcol*psaci(i, k)
6285 IF (psaci(i, k) .GE. 0.) THEN
6290 IF (abs4 .LT. qmin/dtcld) psaci(i, k) = 0.
6291 IF (qci(i, k, 2) - psaci(i, k)*dtcld .LT. 0.) THEN
6294 qci(i, k, 2) = qci(i, k, 2) - psaci(i, k)*dtcld
6296 IF (qrs(i, k, 2) + psaci(i, k)*dtcld .LT. 0.) THEN
6299 qrs(i, k, 2) = qrs(i, k, 2) + psaci(i, k)*dtcld
6302 !-------------------------------------------------------------
6303 ! pgaci: Accretion of cloud ice by graupel [LFO 41]
6304 ! (T<T0: I->G) pgaci:min=0,max=qci(i,k,2)/dtcld
6305 !-------------------------------------------------------------
6306 ! supcol = t0c-t(i,k) !not change
6307 ! call smoothif(supcol, 0.,fsupcol,'t0')
6308 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
6309 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
6310 !min(exp(0.07*(-supcol)),1.)
6312 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6315 max12 = qrs(i, k, 3)
6317 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max12**(bvtg/4.)
6318 IF (qci(i, k, 2) .LT. qmin) THEN
6321 max13 = qci(i, k, 2)
6323 vt2i = vt2i_a*(den(i, k)*max13)**(1.31/8.)
6324 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6327 max14 = qrs(i, k, 3)
6329 IF (qci(i, k, 2) .LT. qmin) THEN
6332 max25 = qci(i, k, 2)
6334 b = (den(i, k)*max14)**(3./4.)*max25
6335 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6338 max15 = qrs(i, k, 3)
6340 IF (qci(i, k, 2) .LT. qmin) THEN
6343 max26 = qci(i, k, 2)
6345 c = den(i, k)**(5./8.)*SQRT(max15)*max26**(9./8.)
6346 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6349 max16 = qrs(i, k, 3)
6351 IF (qci(i, k, 2) .LT. qmin) THEN
6354 max27 = qci(i, k, 2)
6356 d = SQRT(den(i, k))*SQRT(SQRT(max16))*max27**(5./4.)
6357 IF (vt2g - vt2i .GE. 0.) THEN
6362 pgaci1 = pgaci_a*abs5*(pgaci_b*b+pgaci_c*c+pgaci_d*d)*egi
6363 IF (pgaci1 .GT. qci(i, k, 2)/dtcld) THEN
6364 pgaci(i, k) = qci(i, k, 2)/dtcld
6366 pgaci(i, k) = pgaci1
6368 pgaci(i, k) = fsupcol*pgaci(i, k)
6369 IF (pgaci(i, k) .GE. 0.) THEN
6374 IF (abs6 .LT. qmin/dtcld) pgaci(i, k) = 0.
6375 IF (qci(i, k, 2) - pgaci(i, k)*dtcld .LT. 0.) THEN
6378 qci(i, k, 2) = qci(i, k, 2) - pgaci(i, k)*dtcld
6380 IF (qrs(i, k, 3) + pgaci(i, k)*dtcld .LT. 0.) THEN
6383 qrs(i, k, 3) = qrs(i, k, 3) + pgaci(i, k)*dtcld
6386 !-------------------------------------------------------------
6387 ! psacw: Accretion of cloud water by snow [LFO 24]
6388 ! (T<T0: C->G, and T>=T0: C->R) psacw:min=0,max=qci(i,k,1)/dtcld
6389 !-------------------------------------------------------------
6390 ! supcol = t0c-t(i,k) !not change
6391 ! call smoothif(supcol, 0.,fsupcol,'t0')
6392 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
6393 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
6395 ! cpm(i,k)=cpmcal(q(i,k)) !not change
6396 xl(i, k) = XLCAL(t(i, k))
6397 xlf = xls - xl(i, k)
6398 IF (supcol .LT. 0.) xlf = xlf0
6399 IF (qrs(i, k, 2) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
6400 IF (90. .GT. t0c - t(i, k)) THEN
6405 IF (0. .LT. y5) THEN
6410 a = EXP((1.-bvts)*alpha*max17/4.)
6411 psacw(i, k) = psacw_a*a*den(i, k)**((1.+bvts)/4.)*qrs(i, k, 2)&
6412 & **((3.+bvts)/4.)*qci(i, k, 1)
6416 IF (psacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
6417 x6 = qci(i, k, 1)/dtcld
6421 IF (x6 .LT. 0.) THEN
6426 psacw(i, k) = fsupcol*psacw(i, k)
6427 IF (psacw(i, k) .GE. 0.) THEN
6432 IF (abs7 .LT. qmin/dtcld) psacw(i, k) = 0.
6433 IF (qci(i, k, 1) - psacw(i, k)*dtcld .LT. 0.) THEN
6436 qci(i, k, 1) = qci(i, k, 1) - psacw(i, k)*dtcld
6438 x7 = qrs(i, k, 1) + (1.-fsupcol)*psacw(i, k)*dtcld
6439 IF (x7 .LT. 0.) THEN
6444 x8 = qrs(i, k, 3) + fsupcol*psacw(i, k)*dtcld
6445 IF (x8 .LT. 0.) THEN
6450 t(i, k) = t(i, k) + fsupcol*psacw(i, k)*dtcld*xlf/cpm(i, k)
6452 psacw(i, k) = (1-fsupcol)*psacw(i, k)
6453 !-------------------------------------------------------------
6454 ! pgacw: Accretion of cloud water by graupel [LFO 40]
6455 ! (T<T0: C->G, and T>=T0: C->R) pgacw:min=0.,max=qci(i,k,1)/dtcld
6456 !-------------------------------------------------------------
6457 supcol = t0c - t(i, k)
6458 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6459 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
6460 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
6461 ! cpm(i,k)=cpmcal(q(i,k)) !not change
6462 xl(i, k) = XLCAL(t(i, k))
6463 xlf = xls - xl(i, k)
6464 IF (supcol .LT. 0.) xlf = xlf0
6465 IF (qrs(i, k, 3) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
6466 pgacw(i, k) = pgacw_a*den(i, k)**((1.+bvtg)/4.)*qrs(i, k, 3)**&
6467 & ((3.+bvtg)/4.)*qci(i, k, 1)
6471 IF (pgacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
6472 x9 = qci(i, k, 1)/dtcld
6476 IF (x9 .LT. 0.) THEN
6481 IF (pgacw(i, k) .GE. 0.) THEN
6486 !pgacw(i,k)=fqg*fqc*pgacw(i,k)
6487 IF (abs8 .LT. qmin/dtcld) pgacw(i, k) = 0.
6488 IF (qci(i, k, 1) - pgacw(i, k)*dtcld .LT. 0.) THEN
6491 qci(i, k, 1) = qci(i, k, 1) - pgacw(i, k)*dtcld
6493 x10 = qrs(i, k, 1) + (1.-fsupcol)*pgacw(i, k)*dtcld
6494 IF (x10 .LT. 0.) THEN
6499 x11 = qrs(i, k, 3) + fsupcol*pgacw(i, k)*dtcld
6500 IF (x11 .LT. 0.) THEN
6505 t(i, k) = t(i, k) + fsupcol*pgacw(i, k)*dtcld*xlf/cpm(i, k)
6507 pgacw(i, k) = (1-fsupcol)*pgacw(i, k)
6510 END SUBROUTINE ACCRET1
6512 ! Differentiation of accret2 in reverse (adjoint) mode (with options r8):
6513 ! gradient of useful results: q t psacr psacw pgacr pgacs
6514 ! pracs pgacw den qrs pseml pgeml
6515 ! with respect to varying inputs: q t psacr psacw pgacr pgacs
6516 ! pracs pgacw den qrs pseml pgeml
6517 !=======================================================================
6519 !=======================================================================
6520 SUBROUTINE A_ACCRET2(qrs, a_qrs, t, a_t, q, a_q, den, a_den, dtcld, &
6521 & psacw, a_psacw, pgacw, a_pgacw, pracs, a_pracs, psacr, a_psacr, &
6522 & pgacr, a_pgacr, pgacs, a_pgacs, pseml, a_pseml, pgeml, a_pgeml, ims&
6523 & , ime, kms, kme, its, ite, kts, kte)
6525 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
6526 !-------------------------------------------------------------------
6527 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
6528 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs
6529 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
6530 REAL, DIMENSION(ims:ime, kms:kme) :: a_den, a_q
6531 REAL, DIMENSION(its:ite, kts:kte) :: psacw, pgacw, pracs, psacr, &
6532 & pgacr, pgacs, pseml, pgeml, t, xl, cpm
6533 REAL, DIMENSION(its:ite, kts:kte) :: a_psacw, a_pgacw, a_pracs, &
6534 & a_psacr, a_pgacr, a_pgacs, a_pseml, a_pgeml, a_t, a_xl, a_cpm
6535 REAL :: supcol, vt2r, vt2s, vt2g, dtcld, xlf, egs
6536 REAL :: a_supcol, a_vt2r, a_vt2s, a_vt2g, a_xlf, a_egs
6537 REAL :: acrfac1, acrfac2, acrfac3, acrfac4, pracs1, psacr1, pgacr1, &
6539 REAL :: a_pracs1, a_psacr1, a_pgacr1, a_pgacs1
6541 REAL :: fsupcol, ft0, fqr, fqs, fqg, temp1, delta2, a, b, c, d
6542 REAL :: a_fsupcol, a_ft0, a_fqs, a_fqg, a_a, a_b, a_c, a_d
6724 !-------------------------------------------------------------
6725 ! pracs: Accretion of snow by rain [LFO 27]
6726 ! (T<T0: S->G) pracs: min=0., max=qrs(i,k,2)/dtcld
6727 !-------------------------------------------------------------
6728 CALL PUSHREAL8(supcol)
6729 supcol = t0c - t(i, k)
6730 CALL PUSHREAL8(fsupcol)
6731 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6732 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6733 CALL PUSHREAL8(max1)
6735 CALL PUSHCONTROL1B(0)
6737 CALL PUSHREAL8(max1)
6739 CALL PUSHCONTROL1B(1)
6741 !call smoothif(qrs(i,k,1),1.e-4,fqr,'q0')
6742 !call smoothif(qrs(i,k,2),1.e-4,fqs,'q0')
6743 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.)
6744 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6745 CALL PUSHREAL8(max2)
6747 CALL PUSHCONTROL1B(0)
6749 CALL PUSHREAL8(max2)
6751 CALL PUSHCONTROL1B(1)
6753 IF (90. .GT. t0c - t(i, k)) THEN
6755 CALL PUSHCONTROL1B(0)
6757 CALL PUSHCONTROL1B(1)
6760 IF (0. .LT. y13) THEN
6761 CALL PUSHREAL8(max24)
6763 CALL PUSHCONTROL1B(0)
6765 CALL PUSHREAL8(max24)
6767 CALL PUSHCONTROL1B(1)
6769 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max2**(bvts/4.)*EXP(-(&
6770 & alpha*bvts*max24/4.))
6771 IF (90. .GT. t0c - t(i, k)) THEN
6773 CALL PUSHCONTROL1B(0)
6775 CALL PUSHCONTROL1B(1)
6778 IF (0. .LT. y1) THEN
6779 CALL PUSHREAL8(max3)
6781 CALL PUSHCONTROL1B(0)
6783 CALL PUSHREAL8(max3)
6785 CALL PUSHCONTROL1B(1)
6789 IF (90. .GT. t0c - t(i, k)) THEN
6791 CALL PUSHCONTROL1B(0)
6793 CALL PUSHCONTROL1B(1)
6796 IF (0. .LT. y2) THEN
6797 CALL PUSHREAL8(max4)
6799 CALL PUSHCONTROL1B(1)
6801 CALL PUSHREAL8(max4)
6803 CALL PUSHCONTROL1B(0)
6805 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6806 CALL PUSHREAL8(max25)
6808 CALL PUSHCONTROL1B(1)
6810 CALL PUSHREAL8(max25)
6811 max25 = qrs(i, k, 2)
6812 CALL PUSHCONTROL1B(0)
6814 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6815 CALL PUSHREAL8(max39)
6817 CALL PUSHCONTROL1B(0)
6819 CALL PUSHREAL8(max39)
6820 max39 = qrs(i, k, 1)
6821 CALL PUSHCONTROL1B(1)
6824 b = EXP(-(3.*alpha*max4/2.))*den(i, k)**(3./4.)*max25**(3./2.)*&
6826 IF (90. .GT. t0c - t(i, k)) THEN
6828 CALL PUSHCONTROL1B(0)
6830 CALL PUSHCONTROL1B(1)
6833 IF (0. .LT. y3) THEN
6834 CALL PUSHREAL8(max5)
6836 CALL PUSHCONTROL1B(1)
6838 CALL PUSHREAL8(max5)
6840 CALL PUSHCONTROL1B(0)
6842 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6843 CALL PUSHREAL8(max26)
6845 CALL PUSHCONTROL1B(1)
6847 CALL PUSHREAL8(max26)
6848 max26 = qrs(i, k, 2)
6849 CALL PUSHCONTROL1B(0)
6851 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6852 CALL PUSHREAL8(max40)
6854 CALL PUSHCONTROL1B(0)
6856 CALL PUSHREAL8(max40)
6857 max40 = qrs(i, k, 1)
6858 CALL PUSHCONTROL1B(1)
6861 c = EXP(-(5.*alpha*max5/4.))*den(i, k)**(3./4.)*max26**(5./4.)*&
6863 IF (90. .GT. t0c - t(i, k)) THEN
6865 CALL PUSHCONTROL1B(0)
6867 CALL PUSHCONTROL1B(1)
6870 IF (0. .LT. y4) THEN
6871 CALL PUSHREAL8(max6)
6873 CALL PUSHCONTROL1B(1)
6875 CALL PUSHREAL8(max6)
6877 CALL PUSHCONTROL1B(0)
6879 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6880 CALL PUSHREAL8(max27)
6882 CALL PUSHCONTROL1B(1)
6884 CALL PUSHREAL8(max27)
6885 max27 = qrs(i, k, 2)
6886 CALL PUSHCONTROL1B(0)
6888 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6889 CALL PUSHREAL8(max41)
6891 CALL PUSHCONTROL1B(0)
6893 CALL PUSHREAL8(max41)
6894 max41 = qrs(i, k, 1)
6895 CALL PUSHCONTROL1B(1)
6898 d = EXP(-(alpha*max6))*den(i, k)**(3./4.)*max27*max41**(3./4.)
6899 IF (vt2r - vt2s .GE. 0.) THEN
6900 CALL PUSHREAL8(abs0)
6902 CALL PUSHCONTROL1B(0)
6904 CALL PUSHREAL8(abs0)
6906 CALL PUSHCONTROL1B(1)
6908 pracs1 = pracs_a*a*abs0*(pracs_b*b+pracs_c*c+pracs_d*d)
6909 IF (pracs1 .GT. qrs(i, k, 2)/dtcld) THEN
6910 pracs(i, k) = qrs(i, k, 2)/dtcld
6911 CALL PUSHCONTROL1B(0)
6913 pracs(i, k) = pracs1
6914 CALL PUSHCONTROL1B(1)
6916 CALL PUSHREAL8(pracs(i, k))
6917 pracs(i, k) = fsupcol*pracs(i, k)
6918 IF (pracs(i, k) .GE. 0.) THEN
6923 IF (abs1 .LT. qmin/dtcld) THEN
6925 CALL PUSHCONTROL1B(1)
6927 CALL PUSHCONTROL1B(0)
6929 IF (qrs(i, k, 2) - pracs(i, k)*dtcld .LT. 0.) THEN
6931 CALL PUSHCONTROL1B(0)
6933 qrs(i, k, 2) = qrs(i, k, 2) - pracs(i, k)*dtcld
6934 CALL PUSHCONTROL1B(1)
6936 IF (qrs(i, k, 3) + pracs(i, k)*dtcld .LT. 0.) THEN
6938 CALL PUSHCONTROL1B(0)
6940 qrs(i, k, 3) = qrs(i, k, 3) + pracs(i, k)*dtcld
6941 CALL PUSHCONTROL1B(1)
6943 !-------------------------------------------------------------
6944 ! psacr: Accretion of rain by snow [LFO 28]
6945 ! (T< T0: R->S or R->G) min=0.,max=qrs(i,k,1)/dtcld
6946 ! (T>=T0: S->R enhance melting of snow) min=0.,max=qrs(i,k,2)/dtcld
6947 !-------------------------------------------------------------
6948 ! supcol = t0c-t(i,k) !not change
6949 ! call smoothif(supcol,0.,fsupcol,'t0')
6950 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
6951 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
6953 cpm(i, k) = CPMCAL(q(i, k))
6954 xl(i, k) = XLCAL(t(i, k))
6956 xlf = xls - xl(i, k)
6957 IF (supcol .LT. 0.) THEN
6959 CALL PUSHCONTROL1B(1)
6961 CALL PUSHCONTROL1B(0)
6963 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6964 CALL PUSHREAL8(max7)
6966 CALL PUSHCONTROL1B(0)
6968 CALL PUSHREAL8(max7)
6970 CALL PUSHCONTROL1B(1)
6972 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max7**(bvtr/4.)
6973 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6974 CALL PUSHREAL8(max8)
6976 CALL PUSHCONTROL1B(0)
6978 CALL PUSHREAL8(max8)
6980 CALL PUSHCONTROL1B(1)
6982 IF (90. .GT. t0c - t(i, k)) THEN
6984 CALL PUSHCONTROL1B(0)
6986 CALL PUSHCONTROL1B(1)
6989 IF (0. .LT. y14) THEN
6990 CALL PUSHREAL8(max28)
6992 CALL PUSHCONTROL1B(0)
6994 CALL PUSHREAL8(max28)
6996 CALL PUSHCONTROL1B(1)
6998 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max8**(bvts/4.)*EXP(-(&
6999 & alpha*bvts*max28/4.))
7000 IF (90. .GT. t0c - t(i, k)) THEN
7002 CALL PUSHCONTROL1B(0)
7004 CALL PUSHCONTROL1B(1)
7007 IF (0. .LT. y5) THEN
7008 CALL PUSHREAL8(max9)
7010 CALL PUSHCONTROL1B(0)
7012 CALL PUSHREAL8(max9)
7014 CALL PUSHCONTROL1B(1)
7018 IF (90. .GT. t0c - t(i, k)) THEN
7020 CALL PUSHCONTROL1B(0)
7022 CALL PUSHCONTROL1B(1)
7025 IF (0. .LT. y6) THEN
7026 CALL PUSHREAL8(max10)
7028 CALL PUSHCONTROL1B(1)
7030 CALL PUSHREAL8(max10)
7032 CALL PUSHCONTROL1B(0)
7034 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7035 CALL PUSHREAL8(max29)
7037 CALL PUSHCONTROL1B(1)
7039 CALL PUSHREAL8(max29)
7040 max29 = qrs(i, k, 1)
7041 CALL PUSHCONTROL1B(0)
7043 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7044 CALL PUSHREAL8(max42)
7046 CALL PUSHCONTROL1B(0)
7048 CALL PUSHREAL8(max42)
7049 max42 = qrs(i, k, 2)
7050 CALL PUSHCONTROL1B(1)
7053 b = EXP(-(alpha*max10/4.))*den(i, k)**(3./4.)*max29**(3./2.)*&
7055 IF (90. .GT. t0c - t(i, k)) THEN
7057 CALL PUSHCONTROL1B(0)
7059 CALL PUSHCONTROL1B(1)
7062 IF (0. .LT. y7) THEN
7063 CALL PUSHREAL8(max11)
7065 CALL PUSHCONTROL1B(1)
7067 CALL PUSHREAL8(max11)
7069 CALL PUSHCONTROL1B(0)
7071 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7072 CALL PUSHREAL8(max30)
7074 CALL PUSHCONTROL1B(1)
7076 CALL PUSHREAL8(max30)
7077 max30 = qrs(i, k, 1)
7078 CALL PUSHCONTROL1B(0)
7080 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7081 CALL PUSHREAL8(max43)
7083 CALL PUSHCONTROL1B(0)
7085 CALL PUSHREAL8(max43)
7086 max43 = qrs(i, k, 2)
7087 CALL PUSHCONTROL1B(1)
7090 c = EXP(-(alpha*max11/2.))*den(i, k)**(3./4.)*max30**(5./4.)*&
7092 IF (90. .GT. t0c - t(i, k)) THEN
7094 CALL PUSHCONTROL1B(0)
7096 CALL PUSHCONTROL1B(1)
7099 IF (0. .LT. y8) THEN
7100 CALL PUSHREAL8(max12)
7102 CALL PUSHCONTROL1B(1)
7104 CALL PUSHREAL8(max12)
7106 CALL PUSHCONTROL1B(0)
7108 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7109 CALL PUSHREAL8(max31)
7111 CALL PUSHCONTROL1B(1)
7113 CALL PUSHREAL8(max31)
7114 max31 = qrs(i, k, 1)
7115 CALL PUSHCONTROL1B(0)
7117 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7118 CALL PUSHREAL8(max44)
7120 CALL PUSHCONTROL1B(0)
7122 CALL PUSHREAL8(max44)
7123 max44 = qrs(i, k, 2)
7124 CALL PUSHCONTROL1B(1)
7127 d = EXP(-(3.*alpha*max12/4.))*den(i, k)**(3./4.)*max31*max44**(&
7129 IF (vt2r - vt2s .GE. 0.) THEN
7130 CALL PUSHREAL8(abs2)
7132 CALL PUSHCONTROL1B(0)
7134 CALL PUSHREAL8(abs2)
7136 CALL PUSHCONTROL1B(1)
7138 psacr1 = psacr_a*a*abs2*(psacr_b*b+psacr_c*c+psacr_d*d)
7139 IF (supcol .GT. 0.) THEN
7140 IF (psacr1 .GT. qrs(i, k, 1)/dtcld) THEN
7141 psacr(i, k) = qrs(i, k, 1)/dtcld
7142 CALL PUSHCONTROL2B(1)
7144 psacr(i, k) = psacr1
7145 CALL PUSHCONTROL2B(0)
7147 ELSE IF (psacr1 .GT. qrs(i, k, 2)/dtcld) THEN
7148 psacr(i, k) = qrs(i, k, 2)/dtcld
7149 CALL PUSHCONTROL2B(3)
7151 psacr(i, k) = psacr1
7152 CALL PUSHCONTROL2B(2)
7154 IF (psacr(i, k) .GE. 0.) THEN
7159 !psacr(i,k)=fqr*fqs*psacr(i,k)
7160 IF (abs3 .LT. qmin/dtcld) THEN
7162 CALL PUSHCONTROL1B(0)
7164 CALL PUSHCONTROL1B(1)
7167 IF (qrs(i, k, 1) .LT. 1.e-4 .AND. qrs(i, k, 2) .LT. 1.e-4) THEN
7168 CALL PUSHREAL8(delta2)
7170 CALL PUSHCONTROL1B(1)
7172 CALL PUSHREAL8(delta2)
7174 CALL PUSHCONTROL1B(0)
7176 IF (qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld .LT. 0.) THEN
7178 CALL PUSHCONTROL1B(0)
7180 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld
7181 CALL PUSHCONTROL1B(1)
7183 x1 = qrs(i, k, 2) + fsupcol*delta2*psacr(i, k)*dtcld
7184 IF (x1 .LT. 0.) THEN
7186 CALL PUSHCONTROL1B(0)
7189 CALL PUSHCONTROL1B(1)
7191 x2 = qrs(i, k, 3) + fsupcol*(1-delta2)*psacr(i, k)*dtcld
7192 IF (x2 .LT. 0.) THEN
7194 CALL PUSHCONTROL1B(0)
7197 CALL PUSHCONTROL1B(1)
7199 t(i, k) = t(i, k) + fsupcol*psacr(i, k)*dtcld*xlf/cpm(i, k)
7201 CALL PUSHREAL8(psacr(i, k))
7202 psacr(i, k) = (1-fsupcol)*psacr(i, k)
7203 !-------------------------------------------------------------
7204 ! pgacr: Accretion of rain by graupel [LFO 42]
7205 ! (T< T0: R->G) min=0.,max=qrs(i,k,1)/dtcld
7206 ! (T>=T0: G->R enhance melting of graupel) min=0.,max=qrs(i,k,3)/dtcld
7207 !-------------------------------------------------------------
7208 CALL PUSHREAL8(supcol)
7209 supcol = t0c - t(i, k)
7210 CALL PUSHREAL8(fsupcol)
7211 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
7212 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
7213 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
7215 ! cpm(i,k)=cpmcal(q(i,k)) !not change
7216 xl(i, k) = XLCAL(t(i, k))
7218 xlf = xls - xl(i, k)
7219 IF (supcol .LT. 0.) THEN
7221 CALL PUSHCONTROL1B(1)
7223 CALL PUSHCONTROL1B(0)
7225 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7226 CALL PUSHREAL8(max13)
7228 CALL PUSHCONTROL1B(0)
7230 CALL PUSHREAL8(max13)
7231 max13 = qrs(i, k, 1)
7232 CALL PUSHCONTROL1B(1)
7234 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max13**(bvtr/4.)
7235 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7236 CALL PUSHREAL8(max14)
7238 CALL PUSHCONTROL1B(0)
7240 CALL PUSHREAL8(max14)
7241 max14 = qrs(i, k, 3)
7242 CALL PUSHCONTROL1B(1)
7244 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max14**(bvtg/4.)
7245 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7246 CALL PUSHREAL8(max15)
7248 CALL PUSHCONTROL1B(1)
7250 CALL PUSHREAL8(max15)
7251 max15 = qrs(i, k, 1)
7252 CALL PUSHCONTROL1B(0)
7254 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7255 CALL PUSHREAL8(max32)
7257 CALL PUSHCONTROL1B(0)
7259 CALL PUSHREAL8(max32)
7260 max32 = qrs(i, k, 3)
7261 CALL PUSHCONTROL1B(1)
7264 b = den(i, k)**(3./4.)*max15**(3./2.)*SQRT(SQRT(max32))
7265 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7266 CALL PUSHREAL8(max16)
7268 CALL PUSHCONTROL1B(1)
7270 CALL PUSHREAL8(max16)
7271 max16 = qrs(i, k, 1)
7272 CALL PUSHCONTROL1B(0)
7274 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7275 CALL PUSHREAL8(max33)
7277 CALL PUSHCONTROL1B(0)
7279 CALL PUSHREAL8(max33)
7280 max33 = qrs(i, k, 3)
7281 CALL PUSHCONTROL1B(1)
7284 c = den(i, k)**(3./4.)*max16**(5./4.)*SQRT(max33)
7285 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7286 CALL PUSHREAL8(max17)
7288 CALL PUSHCONTROL1B(1)
7290 CALL PUSHREAL8(max17)
7291 max17 = qrs(i, k, 1)
7292 CALL PUSHCONTROL1B(0)
7294 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7295 CALL PUSHREAL8(max34)
7297 CALL PUSHCONTROL1B(0)
7299 CALL PUSHREAL8(max34)
7300 max34 = qrs(i, k, 3)
7301 CALL PUSHCONTROL1B(1)
7304 d = den(i, k)**(3./4.)*max17*max34**(3./4.)
7305 IF (vt2r - vt2g .GE. 0.) THEN
7306 CALL PUSHREAL8(abs4)
7308 CALL PUSHCONTROL1B(0)
7310 CALL PUSHREAL8(abs4)
7312 CALL PUSHCONTROL1B(1)
7314 pgacr1 = pgacr_a*abs4*(pgacr_b*b+pgacr_c*c+pgacr_d*d)
7315 IF (supcol .GT. 0.) THEN
7316 IF (pgacr1 .GT. qrs(i, k, 1)/dtcld) THEN
7317 pgacr(i, k) = qrs(i, k, 1)/dtcld
7318 CALL PUSHCONTROL2B(1)
7320 pgacr(i, k) = pgacr1
7321 CALL PUSHCONTROL2B(0)
7323 ELSE IF (pgacr1 .GT. qrs(i, k, 3)/dtcld) THEN
7324 pgacr(i, k) = qrs(i, k, 3)/dtcld
7325 CALL PUSHCONTROL2B(3)
7327 pgacr(i, k) = pgacr1
7328 CALL PUSHCONTROL2B(2)
7330 IF (pgacr(i, k) .GE. 0.) THEN
7335 !pgacr(i,k)=fqg*fqr*pgacr(i,k)
7336 IF (abs5 .LT. qmin/dtcld) THEN
7338 CALL PUSHCONTROL1B(1)
7340 CALL PUSHCONTROL1B(0)
7342 IF (qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld .LT. 0.) THEN
7344 CALL PUSHCONTROL1B(0)
7346 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld
7347 CALL PUSHCONTROL1B(1)
7349 x3 = qrs(i, k, 3) + fsupcol*pgacr(i, k)*dtcld
7350 IF (x3 .LT. 0.) THEN
7352 CALL PUSHCONTROL1B(0)
7355 CALL PUSHCONTROL1B(1)
7357 t(i, k) = t(i, k) + fsupcol*pgacr(i, k)*dtcld*xlf/cpm(i, k)
7359 CALL PUSHREAL8(pgacr(i, k))
7360 pgacr(i, k) = (1-fsupcol)*pgacr(i, k)
7361 !-------------------------------------------------------------
7362 ! pgacs: Accretion of snow by graupel [LFO 29]
7363 ! (S->G) min=0,max=qrs(i,k,2)/dtcld
7364 !-------------------------------------------------------------
7365 CALL PUSHREAL8(supcol)
7366 supcol = t0c - t(i, k)
7367 x4 = EXP(-(0.09*supcol))
7368 IF (x4 .GT. 1.) THEN
7371 CALL PUSHCONTROL1B(0)
7375 CALL PUSHCONTROL1B(1)
7377 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7378 CALL PUSHREAL8(max18)
7380 CALL PUSHCONTROL1B(0)
7382 CALL PUSHREAL8(max18)
7383 max18 = qrs(i, k, 3)
7384 CALL PUSHCONTROL1B(1)
7386 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max18**(bvtg/4.)
7387 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7388 CALL PUSHREAL8(max19)
7390 CALL PUSHCONTROL1B(0)
7392 CALL PUSHREAL8(max19)
7393 max19 = qrs(i, k, 2)
7394 CALL PUSHCONTROL1B(1)
7396 IF (90. .GT. t0c - t(i, k)) THEN
7398 CALL PUSHCONTROL1B(0)
7400 CALL PUSHCONTROL1B(1)
7403 IF (0. .LT. y15) THEN
7404 CALL PUSHREAL8(max35)
7406 CALL PUSHCONTROL1B(0)
7408 CALL PUSHREAL8(max35)
7410 CALL PUSHCONTROL1B(1)
7412 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max19**(bvts/4.)*EXP(-(&
7413 & alpha*bvts*max35/4.))
7414 IF (90. .GT. t0c - t(i, k)) THEN
7416 CALL PUSHCONTROL1B(0)
7418 CALL PUSHCONTROL1B(1)
7421 IF (0. .LT. y9) THEN
7422 CALL PUSHREAL8(max20)
7424 CALL PUSHCONTROL1B(0)
7426 CALL PUSHREAL8(max20)
7428 CALL PUSHCONTROL1B(1)
7431 a = EXP(alpha*max20)
7432 IF (90. .GT. t0c - t(i, k)) THEN
7434 CALL PUSHCONTROL1B(0)
7436 CALL PUSHCONTROL1B(1)
7439 IF (0. .LT. y10) THEN
7440 CALL PUSHREAL8(max21)
7442 CALL PUSHCONTROL1B(1)
7444 CALL PUSHREAL8(max21)
7446 CALL PUSHCONTROL1B(0)
7448 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7449 CALL PUSHREAL8(max36)
7451 CALL PUSHCONTROL1B(1)
7453 CALL PUSHREAL8(max36)
7454 max36 = qrs(i, k, 2)
7455 CALL PUSHCONTROL1B(0)
7457 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7458 CALL PUSHREAL8(max45)
7460 CALL PUSHCONTROL1B(0)
7462 CALL PUSHREAL8(max45)
7463 max45 = qrs(i, k, 3)
7464 CALL PUSHCONTROL1B(1)
7467 b = EXP(-(3.*alpha*max21/2.))*den(i, k)**(3./4.)*max36**(3./2.)*&
7469 IF (90. .GT. t0c - t(i, k)) THEN
7471 CALL PUSHCONTROL1B(0)
7473 CALL PUSHCONTROL1B(1)
7476 IF (0. .LT. y11) THEN
7477 CALL PUSHREAL8(max22)
7479 CALL PUSHCONTROL1B(1)
7481 CALL PUSHREAL8(max22)
7483 CALL PUSHCONTROL1B(0)
7485 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7486 CALL PUSHREAL8(max37)
7488 CALL PUSHCONTROL1B(1)
7490 CALL PUSHREAL8(max37)
7491 max37 = qrs(i, k, 2)
7492 CALL PUSHCONTROL1B(0)
7494 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7495 CALL PUSHREAL8(max46)
7497 CALL PUSHCONTROL1B(0)
7499 CALL PUSHREAL8(max46)
7500 max46 = qrs(i, k, 3)
7501 CALL PUSHCONTROL1B(1)
7504 c = EXP(-(5.*alpha*max22/4.))*den(i, k)**(3./4.)*max37**(5./4.)*&
7506 IF (90. .GT. t0c - t(i, k)) THEN
7508 CALL PUSHCONTROL1B(0)
7510 CALL PUSHCONTROL1B(1)
7513 IF (0. .LT. y12) THEN
7514 CALL PUSHREAL8(max23)
7516 CALL PUSHCONTROL1B(1)
7518 CALL PUSHREAL8(max23)
7520 CALL PUSHCONTROL1B(0)
7522 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7523 CALL PUSHREAL8(max38)
7525 CALL PUSHCONTROL1B(1)
7527 CALL PUSHREAL8(max38)
7528 max38 = qrs(i, k, 2)
7529 CALL PUSHCONTROL1B(0)
7531 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7532 CALL PUSHREAL8(max47)
7534 CALL PUSHCONTROL1B(0)
7536 CALL PUSHREAL8(max47)
7537 max47 = qrs(i, k, 3)
7538 CALL PUSHCONTROL1B(1)
7540 d = EXP(-(alpha*max23))*den(i, k)**(3./4.)*max38*max47**(3./4.)
7541 IF (vt2g - vt2s .GE. 0.) THEN
7542 CALL PUSHREAL8(abs6)
7544 CALL PUSHCONTROL1B(0)
7546 CALL PUSHREAL8(abs6)
7548 CALL PUSHCONTROL1B(1)
7550 pgacs1 = pgacs_a*a*abs6*(pgacs_b*b+pgacs_c*c+pgacs_d*d)*egs
7551 IF (pgacs1 .GT. qrs(i, k, 2)/dtcld) THEN
7552 pgacs(i, k) = qrs(i, k, 2)/dtcld
7553 CALL PUSHCONTROL1B(0)
7555 pgacs(i, k) = pgacs1
7556 CALL PUSHCONTROL1B(1)
7558 IF (pgacs(i, k) .GE. 0.) THEN
7563 !pgacs(i,k)=fqg*fqs*pgacs(i,k)
7564 IF (abs7 .LT. qmin/dtcld) THEN
7566 CALL PUSHCONTROL1B(1)
7568 CALL PUSHCONTROL1B(0)
7570 IF (qrs(i, k, 2) - pgacs(i, k)*dtcld .LT. 0.) THEN
7572 CALL PUSHCONTROL1B(0)
7574 qrs(i, k, 2) = qrs(i, k, 2) - pgacs(i, k)*dtcld
7575 CALL PUSHCONTROL1B(1)
7577 IF (qrs(i, k, 3) + pgacs(i, k)*dtcld .LT. 0.) THEN
7579 CALL PUSHCONTROL1B(0)
7581 qrs(i, k, 3) = qrs(i, k, 3) + pgacs(i, k)*dtcld
7582 CALL PUSHCONTROL1B(1)
7584 !-------------------------------------------------------------
7585 ! pseml: Enhanced melting of snow by accretion of water
7586 ! (T>=T0: S->R) pseml<0 max=0,min=-qrs(i,k,2)/dtcld
7587 !-------------------------------------------------------------
7588 ! supcol = t0c-t(i,k) ! not change
7590 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
7591 xl(i, k) = XLCAL(t(i, k))
7593 xlf = xls - xl(i, k)
7594 IF (supcol .LT. 0.) THEN
7596 CALL PUSHCONTROL1B(1)
7598 CALL PUSHCONTROL1B(0)
7601 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
7603 CALL SMOOTHIF(qrs(i, k, 2), 0., fqs, 'q+')
7604 x7 = cliq*supcol*(psacw(i, k)+psacr(i, k))/xlf
7605 IF (x7 .LT. -(qrs(i, k, 2)/dtcld)) THEN
7606 x5 = -(qrs(i, k, 2)/dtcld)
7607 CALL PUSHCONTROL1B(0)
7610 CALL PUSHCONTROL1B(1)
7612 IF (x5 .GT. 0.) THEN
7614 CALL PUSHCONTROL1B(0)
7617 CALL PUSHCONTROL1B(1)
7619 CALL PUSHREAL8(pseml(i, k))
7620 pseml(i, k) = ft0*fqs*pseml(i, k)
7621 IF (pseml(i, k) .GE. 0.) THEN
7626 IF (abs8 .LT. qmin/dtcld) THEN
7628 CALL PUSHCONTROL1B(1)
7630 CALL PUSHCONTROL1B(0)
7632 IF (qrs(i, k, 1) - pseml(i, k)*dtcld .LT. 0.) THEN
7633 CALL PUSHREAL8(qrs(i, k, 1))
7635 CALL PUSHCONTROL1B(0)
7637 CALL PUSHREAL8(qrs(i, k, 1))
7638 qrs(i, k, 1) = qrs(i, k, 1) - pseml(i, k)*dtcld
7639 CALL PUSHCONTROL1B(1)
7641 IF (qrs(i, k, 2) + pseml(i, k)*dtcld .LT. 0.) THEN
7642 CALL PUSHREAL8(qrs(i, k, 2))
7644 CALL PUSHCONTROL1B(0)
7646 CALL PUSHREAL8(qrs(i, k, 2))
7647 qrs(i, k, 2) = qrs(i, k, 2) + pseml(i, k)*dtcld
7648 CALL PUSHCONTROL1B(1)
7650 CALL PUSHREAL8(t(i, k))
7651 t(i, k) = t(i, k) + pseml(i, k)*dtcld*xlf/cpm(i, k)
7652 !-------------------------------------------------------------
7653 ! pgeml: Enhanced melting of graupel by accretion of water [RH84 A21-A22]
7654 ! (T>=T0: G->R) pgeml<0 max=0,min=-qrs(i,k,3)/dtcld
7655 !-------------------------------------------------------------
7656 CALL PUSHREAL8(supcol)
7657 supcol = t0c - t(i, k)
7659 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
7660 xl(i, k) = XLCAL(t(i, k))
7662 xlf = xls - xl(i, k)
7663 IF (supcol .LT. 0.) THEN
7665 CALL PUSHCONTROL1B(1)
7667 CALL PUSHCONTROL1B(0)
7670 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
7672 CALL SMOOTHIF(qrs(i, k, 3), 0., fqg, 'q+')
7673 x8 = cliq*supcol*(pgacw(i, k)+pgacr(i, k))/xlf
7674 IF (x8 .LT. -(qrs(i, k, 3)/dtcld)) THEN
7675 x6 = -(qrs(i, k, 3)/dtcld)
7676 CALL PUSHCONTROL1B(0)
7679 CALL PUSHCONTROL1B(1)
7681 IF (x6 .GT. 0.) THEN
7683 CALL PUSHCONTROL1B(0)
7686 CALL PUSHCONTROL1B(1)
7688 CALL PUSHREAL8(pgeml(i, k))
7689 pgeml(i, k) = ft0*fqg*pgeml(i, k)
7690 IF (pgeml(i, k) .GE. 0.) THEN
7695 IF (abs9 .LT. qmin/dtcld) THEN
7697 CALL PUSHCONTROL1B(1)
7699 CALL PUSHCONTROL1B(0)
7701 IF (qrs(i, k, 1) - pgeml(i, k)*dtcld .LT. 0.) THEN
7702 CALL PUSHREAL8(qrs(i, k, 1))
7704 CALL PUSHCONTROL1B(0)
7706 CALL PUSHREAL8(qrs(i, k, 1))
7707 qrs(i, k, 1) = qrs(i, k, 1) - pgeml(i, k)*dtcld
7708 CALL PUSHCONTROL1B(1)
7710 IF (qrs(i, k, 3) + pgeml(i, k)*dtcld .LT. 0.) THEN
7711 CALL PUSHCONTROL1B(0)
7713 CALL PUSHCONTROL1B(1)
7721 a_temp1 = dtcld*a_t(i, k)/cpm(i, k)
7722 a_pgacr(i, k) = 0.0_8
7723 a_pgacw(i, k) = 0.0_8
7724 a_pgeml(i, k) = xlf*a_temp1
7725 a_xlf = pgeml(i, k)*a_temp1
7726 a_cpm(i, k) = a_cpm(i, k) - pgeml(i, k)*xlf*a_temp1/cpm(i, k)
7727 CALL POPCONTROL1B(branch)
7728 IF (branch .EQ. 0) THEN
7729 a_qrs(i, k, 3) = 0.0_8
7731 a_pgeml(i, k) = a_pgeml(i, k) + dtcld*a_qrs(i, k, 3)
7733 CALL POPCONTROL1B(branch)
7734 IF (branch .EQ. 0) THEN
7735 CALL POPREAL8(qrs(i, k, 1))
7736 a_qrs(i, k, 1) = 0.0_8
7738 CALL POPREAL8(qrs(i, k, 1))
7739 a_pgeml(i, k) = a_pgeml(i, k) - dtcld*a_qrs(i, k, 1)
7741 CALL POPCONTROL1B(branch)
7742 IF (branch .NE. 0) a_pgeml(i, k) = 0.0_8
7743 CALL POPREAL8(pgeml(i, k))
7744 a_temp1 = pgeml(i, k)*a_pgeml(i, k)
7745 a_pgeml(i, k) = ft0*fqg*a_pgeml(i, k)
7748 CALL POPCONTROL1B(branch)
7749 IF (branch .EQ. 0) THEN
7750 a_pgeml(i, k) = 0.0_8
7753 a_x6 = a_pgeml(i, k)
7754 a_pgeml(i, k) = 0.0_8
7756 CALL POPCONTROL1B(branch)
7757 IF (branch .EQ. 0) THEN
7758 a_qrs(i, k, 3) = a_qrs(i, k, 3) - a_x6/dtcld
7763 a_temp1 = supcol*cliq*a_x8/xlf
7764 a_temp5 = (pgacw(i, k)+pgacr(i, k))*cliq*a_x8/xlf
7766 a_xlf = a_xlf - supcol*a_temp5/xlf
7767 a_pgacw(i, k) = a_pgacw(i, k) + a_temp1
7768 a_pgacr(i, k) = a_pgacr(i, k) + a_temp1
7770 CALL A_SMOOTHIF(qrs(i, k, 3), a_qrs(i, k, 3), 0., fqg, a_fqg, &
7773 CALL A_SMOOTHIF(t(i, k), a_t(i, k), t0c, ft0, a_ft0, 't0')
7774 CALL POPCONTROL1B(branch)
7775 IF (branch .NE. 0) a_xlf = 0.0_8
7777 a_xl(i, k) = a_xl(i, k) - a_xlf
7778 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
7780 CALL POPREAL8(supcol)
7781 a_t(i, k) = a_t(i, k) - a_supcol
7782 a_psacr(i, k) = 0.0_8
7783 a_psacw(i, k) = 0.0_8
7784 CALL POPREAL8(t(i, k))
7785 a_temp1 = dtcld*a_t(i, k)/cpm(i, k)
7786 a_pseml(i, k) = xlf*a_temp1
7787 a_xlf = pseml(i, k)*a_temp1
7788 a_cpm(i, k) = a_cpm(i, k) - pseml(i, k)*xlf*a_temp1/cpm(i, k)
7789 CALL POPCONTROL1B(branch)
7790 IF (branch .EQ. 0) THEN
7791 CALL POPREAL8(qrs(i, k, 2))
7792 a_qrs(i, k, 2) = 0.0_8
7794 CALL POPREAL8(qrs(i, k, 2))
7795 a_pseml(i, k) = a_pseml(i, k) + dtcld*a_qrs(i, k, 2)
7797 CALL POPCONTROL1B(branch)
7798 IF (branch .EQ. 0) THEN
7799 CALL POPREAL8(qrs(i, k, 1))
7800 a_qrs(i, k, 1) = 0.0_8
7802 CALL POPREAL8(qrs(i, k, 1))
7803 a_pseml(i, k) = a_pseml(i, k) - dtcld*a_qrs(i, k, 1)
7805 CALL POPCONTROL1B(branch)
7806 IF (branch .NE. 0) a_pseml(i, k) = 0.0_8
7807 CALL POPREAL8(pseml(i, k))
7808 a_temp1 = pseml(i, k)*a_pseml(i, k)
7809 a_pseml(i, k) = ft0*fqs*a_pseml(i, k)
7812 CALL POPCONTROL1B(branch)
7813 IF (branch .EQ. 0) THEN
7814 a_pseml(i, k) = 0.0_8
7817 a_x5 = a_pseml(i, k)
7818 a_pseml(i, k) = 0.0_8
7820 CALL POPCONTROL1B(branch)
7821 IF (branch .EQ. 0) THEN
7822 a_qrs(i, k, 2) = a_qrs(i, k, 2) - a_x5/dtcld
7827 a_temp1 = supcol*cliq*a_x7/xlf
7828 a_temp5 = (psacw(i, k)+psacr(i, k))*cliq*a_x7/xlf
7830 a_xlf = a_xlf - supcol*a_temp5/xlf
7831 a_psacw(i, k) = a_psacw(i, k) + a_temp1
7832 a_psacr(i, k) = a_psacr(i, k) + a_temp1
7834 CALL A_SMOOTHIF(qrs(i, k, 2), a_qrs(i, k, 2), 0., fqs, a_fqs, &
7837 CALL A_SMOOTHIF(t(i, k), a_t(i, k), t0c, ft0, a_ft0, 't0')
7838 CALL POPCONTROL1B(branch)
7839 IF (branch .NE. 0) a_xlf = 0.0_8
7841 a_xl(i, k) = a_xl(i, k) - a_xlf
7842 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
7844 a_pgacs(i, k) = 0.0_8
7845 CALL POPCONTROL1B(branch)
7846 IF (branch .EQ. 0) THEN
7847 a_qrs(i, k, 3) = 0.0_8
7849 a_pgacs(i, k) = a_pgacs(i, k) + dtcld*a_qrs(i, k, 3)
7851 CALL POPCONTROL1B(branch)
7852 IF (branch .EQ. 0) THEN
7853 a_qrs(i, k, 2) = 0.0_8
7855 a_pgacs(i, k) = a_pgacs(i, k) - dtcld*a_qrs(i, k, 2)
7857 CALL POPCONTROL1B(branch)
7858 IF (branch .NE. 0) a_pgacs(i, k) = 0.0_8
7859 CALL POPCONTROL1B(branch)
7860 IF (branch .EQ. 0) THEN
7861 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_pgacs(i, k)/dtcld
7862 a_pgacs(i, k) = 0.0_8
7865 a_pgacs1 = a_pgacs(i, k)
7866 a_pgacs(i, k) = 0.0_8
7868 a_temp1 = (pgacs_b*b+pgacs_c*c+pgacs_d*d)*pgacs_a*a_pgacs1
7869 a_temp5 = a*abs6*egs*pgacs_a*a_pgacs1
7870 a_b = pgacs_b*a_temp5
7871 a_c = pgacs_c*a_temp5
7872 a_d = pgacs_d*a_temp5
7873 a_a = abs6*egs*a_temp1
7874 a_abs6 = a*egs*a_temp1
7875 a_egs = a*abs6*a_temp1
7876 CALL POPCONTROL1B(branch)
7877 IF (branch .EQ. 0) THEN
7887 temp8 = max47**temp9
7889 temp5 = den(i, k)**temp6
7890 temp4 = EXP(-(alpha*max23))
7891 a_temp3 = max38*temp8*a_d
7892 a_temp4 = temp4*temp5*a_d
7893 a_max38 = temp8*a_temp4
7894 IF (max47 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
7898 a_max47 = temp9*max47**(temp9-1)*max38*a_temp4
7900 a_max23 = -(alpha*EXP(-(alpha*max23))*temp5*a_temp3)
7901 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
7902 & temp6 .NE. INT(temp6)))) a_den(i, k) = a_den(i, k) + temp6*&
7903 & den(i, k)**(temp6-1)*temp4*a_temp3
7904 CALL POPCONTROL1B(branch)
7905 IF (branch .EQ. 0) THEN
7906 CALL POPREAL8(max47)
7908 CALL POPREAL8(max47)
7909 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max47
7911 CALL POPCONTROL1B(branch)
7912 IF (branch .EQ. 0) THEN
7913 CALL POPREAL8(max38)
7914 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max38
7916 CALL POPREAL8(max38)
7918 CALL POPCONTROL1B(branch)
7919 IF (branch .EQ. 0) THEN
7920 CALL POPREAL8(max23)
7923 CALL POPREAL8(max23)
7926 CALL POPCONTROL1B(branch)
7927 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y12
7931 temp7 = max37**temp8
7933 temp4 = den(i, k)**temp5
7934 temp3 = -(5.*alpha*max22/4.)
7936 a_temp2 = temp7*temp9*a_c
7937 a_temp0 = temp2*temp4*a_c
7938 IF (max37 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. INT&
7942 a_max37 = temp8*max37**(temp8-1)*temp9*a_temp0
7944 IF (max46 .EQ. 0.0_8) THEN
7947 a_max46 = temp7*a_temp0/(2.0*temp9)
7949 a_max22 = -(alpha*5.*EXP(temp3)*temp4*a_temp2/4.)
7950 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
7951 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
7952 & den(i, k)**(temp5-1)*temp2*a_temp2
7953 CALL POPCONTROL1B(branch)
7954 IF (branch .EQ. 0) THEN
7955 CALL POPREAL8(max46)
7957 CALL POPREAL8(max46)
7958 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max46
7960 CALL POPCONTROL1B(branch)
7961 IF (branch .EQ. 0) THEN
7962 CALL POPREAL8(max37)
7963 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max37
7965 CALL POPREAL8(max37)
7967 CALL POPCONTROL1B(branch)
7968 IF (branch .EQ. 0) THEN
7969 CALL POPREAL8(max22)
7972 CALL POPREAL8(max22)
7975 CALL POPCONTROL1B(branch)
7976 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y11
7977 d = den(i, k)**(3./4.)*max17*max34**(3./4.)
7981 temp7 = -(3.*alpha*max21/2.)
7984 temp3 = max36**temp4
7986 temp0 = den(i, k)**temp2
7987 a_temp6 = temp6*temp8*a_b
7988 a_temp = temp0*temp3*a_b
7989 a_max21 = -(alpha*3.*EXP(temp7)*temp8*a_temp/2.)
7990 IF (max45 .EQ. 0.0_8 .OR. temp9 .EQ. 0.0_8) THEN
7993 a_max45 = temp6*a_temp/(2.0**2*temp9*temp8)
7995 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
7996 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2*&
7997 & den(i, k)**(temp2-1)*temp3*a_temp6
7998 IF (max36 .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. temp4 .NE. INT&
8002 a_max36 = temp4*max36**(temp4-1)*temp0*a_temp6
8004 CALL POPCONTROL1B(branch)
8005 IF (branch .EQ. 0) THEN
8006 CALL POPREAL8(max45)
8008 CALL POPREAL8(max45)
8009 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max45
8011 CALL POPCONTROL1B(branch)
8012 IF (branch .EQ. 0) THEN
8013 CALL POPREAL8(max36)
8014 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max36
8016 CALL POPREAL8(max36)
8018 CALL POPCONTROL1B(branch)
8019 IF (branch .EQ. 0) THEN
8020 CALL POPREAL8(max21)
8023 CALL POPREAL8(max21)
8026 CALL POPCONTROL1B(branch)
8027 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y10
8029 a_max20 = alpha*EXP(alpha*max20)*a_a
8030 CALL POPCONTROL1B(branch)
8031 IF (branch .EQ. 0) THEN
8032 CALL POPREAL8(max20)
8035 CALL POPREAL8(max20)
8038 CALL POPCONTROL1B(branch)
8039 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y9
8040 temp9 = -(alpha*bvts*max35/4.)
8042 temp6 = max19**temp7
8043 temp5 = (bvts-2.)/4.
8044 temp4 = den(i, k)**temp5
8045 a_temp5 = EXP(temp9)*vt2s_a*a_vt2s
8046 a_max35 = -(alpha*bvts*EXP(temp9)*temp4*temp6*vt2s_a*a_vt2s/4.)
8047 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
8048 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
8049 & den(i, k)**(temp5-1)*temp6*a_temp5
8050 IF (max19 .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 .NE. INT&
8054 a_max19 = temp7*max19**(temp7-1)*temp4*a_temp5
8056 CALL POPCONTROL1B(branch)
8057 IF (branch .EQ. 0) THEN
8058 CALL POPREAL8(max35)
8061 CALL POPREAL8(max35)
8064 CALL POPCONTROL1B(branch)
8065 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y15
8066 CALL POPCONTROL1B(branch)
8067 IF (branch .EQ. 0) THEN
8068 CALL POPREAL8(max19)
8070 CALL POPREAL8(max19)
8071 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max19
8074 temp8 = (bvtg-2.)/4.
8075 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. &
8076 & temp8 .NE. INT(temp8)))) a_den(i, k) = a_den(i, k) + temp8*&
8077 & den(i, k)**(temp8-1)*max18**temp9*vt2g_a*a_vt2g
8078 IF (max18 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8082 a_max18 = temp9*max18**(temp9-1)*den(i, k)**temp8*vt2g_a*&
8085 CALL POPCONTROL1B(branch)
8086 IF (branch .EQ. 0) THEN
8087 CALL POPREAL8(max18)
8089 CALL POPREAL8(max18)
8090 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max18
8092 CALL POPCONTROL1B(branch)
8093 IF (branch .EQ. 0) THEN
8100 a_supcol = a_supcol - 0.09*EXP(-(0.09*supcol))*a_x4
8101 CALL POPREAL8(supcol)
8102 a_t(i, k) = a_t(i, k) - a_supcol
8103 CALL POPREAL8(pgacr(i, k))
8104 temp8 = pgacr(i, k)/cpm(i, k)
8105 a_temp1 = dtcld*a_t(i, k)
8106 a_fsupcol = xlf*temp8*a_temp1 - pgacr(i, k)*a_pgacr(i, k)
8107 a_xlf = fsupcol*temp8*a_temp1
8108 a_temp5 = fsupcol*xlf*a_temp1/cpm(i, k)
8109 a_pgacr(i, k) = (1-fsupcol)*a_pgacr(i, k) + a_temp5
8110 a_cpm(i, k) = a_cpm(i, k) - temp8*a_temp5
8111 CALL POPCONTROL1B(branch)
8112 IF (branch .EQ. 0) THEN
8113 a_qrs(i, k, 3) = 0.0_8
8116 a_x3 = a_qrs(i, k, 3)
8117 a_qrs(i, k, 3) = 0.0_8
8119 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x3
8120 a_fsupcol = a_fsupcol + pgacr(i, k)*dtcld*a_x3
8121 a_pgacr(i, k) = a_pgacr(i, k) + fsupcol*dtcld*a_x3
8122 CALL POPCONTROL1B(branch)
8123 IF (branch .EQ. 0) THEN
8124 a_qrs(i, k, 1) = 0.0_8
8126 a_fsupcol = a_fsupcol - pgacr(i, k)*dtcld*a_qrs(i, k, 1)
8127 a_pgacr(i, k) = a_pgacr(i, k) - fsupcol*dtcld*a_qrs(i, k, 1)
8129 CALL POPCONTROL1B(branch)
8130 IF (branch .NE. 0) a_pgacr(i, k) = 0.0_8
8131 CALL POPCONTROL2B(branch)
8132 IF (branch .LT. 2) THEN
8133 IF (branch .EQ. 0) THEN
8134 a_pgacr1 = a_pgacr(i, k)
8135 a_pgacr(i, k) = 0.0_8
8137 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_pgacr(i, k)/dtcld
8138 a_pgacr(i, k) = 0.0_8
8141 ELSE IF (branch .EQ. 2) THEN
8142 a_pgacr1 = a_pgacr(i, k)
8143 a_pgacr(i, k) = 0.0_8
8145 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_pgacr(i, k)/dtcld
8146 a_pgacr(i, k) = 0.0_8
8149 a_abs4 = (pgacr_b*b+pgacr_c*c+pgacr_d*d)*pgacr_a*a_pgacr1
8150 a_temp1 = abs4*pgacr_a*a_pgacr1
8151 a_b = pgacr_b*a_temp1
8152 a_c = pgacr_c*a_temp1
8153 a_d = pgacr_d*a_temp1
8154 CALL POPCONTROL1B(branch)
8155 IF (branch .EQ. 0) THEN
8166 temp8 = max34**temp9
8168 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. &
8169 & temp7 .NE. INT(temp7)))) a_den(i, k) = a_den(i, k) + temp7*&
8170 & den(i, k)**(temp7-1)*max17*temp8*a_d
8171 a_temp2 = den(i, k)**temp7*a_d
8172 a_max17 = temp8*a_temp2
8173 IF (max34 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8177 a_max34 = temp9*max34**(temp9-1)*max17*a_temp2
8179 CALL POPCONTROL1B(branch)
8180 IF (branch .EQ. 0) THEN
8181 CALL POPREAL8(max34)
8183 CALL POPREAL8(max34)
8184 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max34
8186 CALL POPCONTROL1B(branch)
8187 IF (branch .EQ. 0) THEN
8188 CALL POPREAL8(max17)
8189 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max17
8191 CALL POPREAL8(max17)
8196 temp7 = max16**temp8
8198 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
8199 & temp6 .NE. INT(temp6)))) a_den(i, k) = a_den(i, k) + temp6*&
8200 & den(i, k)**(temp6-1)*temp7*temp9*a_c
8201 a_temp6 = den(i, k)**temp6*a_c
8202 IF (max16 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. INT&
8206 a_max16 = temp8*max16**(temp8-1)*temp9*a_temp6
8208 IF (max33 .EQ. 0.0_8) THEN
8211 a_max33 = temp7*a_temp6/(2.0*temp9)
8213 CALL POPCONTROL1B(branch)
8214 IF (branch .EQ. 0) THEN
8215 CALL POPREAL8(max33)
8217 CALL POPREAL8(max33)
8218 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max33
8220 CALL POPCONTROL1B(branch)
8221 IF (branch .EQ. 0) THEN
8222 CALL POPREAL8(max16)
8223 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max16
8225 CALL POPREAL8(max16)
8231 temp6 = max15**temp7
8233 temp4 = den(i, k)**temp5
8234 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
8235 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
8236 & den(i, k)**(temp5-1)*temp6*temp8*a_b
8237 IF (max15 .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 .NE. INT&
8241 a_max15 = temp7*max15**(temp7-1)*temp4*temp8*a_b
8243 IF (max32 .EQ. 0.0_8 .OR. temp9 .EQ. 0.0_8) THEN
8246 a_max32 = temp4*temp6*a_b/(2.0**2*temp9*temp8)
8248 CALL POPCONTROL1B(branch)
8249 IF (branch .EQ. 0) THEN
8250 CALL POPREAL8(max32)
8252 CALL POPREAL8(max32)
8253 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max32
8255 CALL POPCONTROL1B(branch)
8256 IF (branch .EQ. 0) THEN
8257 CALL POPREAL8(max15)
8258 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max15
8260 CALL POPREAL8(max15)
8263 temp8 = (bvtg-2.)/4.
8264 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. &
8265 & temp8 .NE. INT(temp8)))) a_den(i, k) = a_den(i, k) + temp8*&
8266 & den(i, k)**(temp8-1)*max14**temp9*vt2g_a*a_vt2g
8267 IF (max14 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8271 a_max14 = temp9*max14**(temp9-1)*den(i, k)**temp8*vt2g_a*&
8274 CALL POPCONTROL1B(branch)
8275 IF (branch .EQ. 0) THEN
8276 CALL POPREAL8(max14)
8278 CALL POPREAL8(max14)
8279 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max14
8282 temp8 = (bvtr-2.)/4.
8283 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. &
8284 & temp8 .NE. INT(temp8)))) a_den(i, k) = a_den(i, k) + temp8*&
8285 & den(i, k)**(temp8-1)*max13**temp9*vt2r_a*a_vt2r
8286 IF (max13 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8290 a_max13 = temp9*max13**(temp9-1)*den(i, k)**temp8*vt2r_a*&
8293 CALL POPCONTROL1B(branch)
8294 IF (branch .EQ. 0) THEN
8295 CALL POPREAL8(max13)
8297 CALL POPREAL8(max13)
8298 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max13
8300 CALL POPCONTROL1B(branch)
8301 IF (branch .NE. 0) a_xlf = 0.0_8
8303 a_xl(i, k) = a_xl(i, k) - a_xlf
8304 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
8306 CALL POPREAL8(fsupcol)
8308 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
8309 CALL POPREAL8(supcol)
8310 a_t(i, k) = a_t(i, k) - a_supcol
8311 CALL POPREAL8(psacr(i, k))
8312 temp8 = psacr(i, k)/cpm(i, k)
8313 a_temp1 = dtcld*a_t(i, k)
8314 a_fsupcol = xlf*temp8*a_temp1 - psacr(i, k)*a_psacr(i, k)
8315 a_xlf = fsupcol*temp8*a_temp1
8316 a_temp5 = fsupcol*xlf*a_temp1/cpm(i, k)
8317 a_psacr(i, k) = (1-fsupcol)*a_psacr(i, k) + a_temp5
8318 a_cpm(i, k) = a_cpm(i, k) - temp8*a_temp5
8319 CALL POPCONTROL1B(branch)
8320 IF (branch .EQ. 0) THEN
8321 a_qrs(i, k, 3) = 0.0_8
8324 a_x2 = a_qrs(i, k, 3)
8325 a_qrs(i, k, 3) = 0.0_8
8327 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_x2
8328 a_temp1 = (1-delta2)*dtcld*a_x2
8329 a_fsupcol = a_fsupcol + psacr(i, k)*a_temp1
8330 a_psacr(i, k) = a_psacr(i, k) + fsupcol*a_temp1
8331 CALL POPCONTROL1B(branch)
8332 IF (branch .EQ. 0) THEN
8333 a_qrs(i, k, 2) = 0.0_8
8336 a_x1 = a_qrs(i, k, 2)
8337 a_qrs(i, k, 2) = 0.0_8
8339 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_x1
8340 a_temp1 = delta2*dtcld*a_x1
8341 a_fsupcol = a_fsupcol + psacr(i, k)*a_temp1
8342 a_psacr(i, k) = a_psacr(i, k) + fsupcol*a_temp1
8343 CALL POPCONTROL1B(branch)
8344 IF (branch .EQ. 0) THEN
8345 a_qrs(i, k, 1) = 0.0_8
8347 a_fsupcol = a_fsupcol - psacr(i, k)*dtcld*a_qrs(i, k, 1)
8348 a_psacr(i, k) = a_psacr(i, k) - fsupcol*dtcld*a_qrs(i, k, 1)
8350 CALL POPCONTROL1B(branch)
8351 IF (branch .EQ. 0) THEN
8352 CALL POPREAL8(delta2)
8354 CALL POPREAL8(delta2)
8356 CALL POPCONTROL1B(branch)
8357 IF (branch .EQ. 0) a_psacr(i, k) = 0.0_8
8358 CALL POPCONTROL2B(branch)
8359 IF (branch .LT. 2) THEN
8360 IF (branch .EQ. 0) THEN
8361 a_psacr1 = a_psacr(i, k)
8362 a_psacr(i, k) = 0.0_8
8364 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_psacr(i, k)/dtcld
8365 a_psacr(i, k) = 0.0_8
8368 ELSE IF (branch .EQ. 2) THEN
8369 a_psacr1 = a_psacr(i, k)
8370 a_psacr(i, k) = 0.0_8
8372 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_psacr(i, k)/dtcld
8373 a_psacr(i, k) = 0.0_8
8376 a_temp1 = (psacr_b*b+psacr_c*c+psacr_d*d)*psacr_a*a_psacr1
8377 a_temp5 = a*abs2*psacr_a*a_psacr1
8378 a_b = psacr_b*a_temp5
8379 a_c = psacr_c*a_temp5
8380 a_d = psacr_d*a_temp5
8383 CALL POPCONTROL1B(branch)
8384 IF (branch .EQ. 0) THEN
8395 temp8 = max44**temp9
8397 temp6 = den(i, k)**temp7
8398 temp5 = -(3.*alpha*max12/4.)
8399 a_max12 = -(alpha*3.*EXP(temp5)*temp6*max31*temp8*a_d/4.)
8400 a_temp7 = EXP(temp5)*a_d
8401 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. &
8402 & temp7 .NE. INT(temp7)))) a_den(i, k) = a_den(i, k) + temp7*&
8403 & den(i, k)**(temp7-1)*max31*temp8*a_temp7
8404 a_max31 = temp8*temp6*a_temp7
8405 IF (max44 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8409 a_max44 = temp9*max44**(temp9-1)*max31*temp6*a_temp7
8411 CALL POPCONTROL1B(branch)
8412 IF (branch .EQ. 0) THEN
8413 CALL POPREAL8(max44)
8415 CALL POPREAL8(max44)
8416 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max44
8418 CALL POPCONTROL1B(branch)
8419 IF (branch .EQ. 0) THEN
8420 CALL POPREAL8(max31)
8421 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max31
8423 CALL POPREAL8(max31)
8425 CALL POPCONTROL1B(branch)
8426 IF (branch .EQ. 0) THEN
8427 CALL POPREAL8(max12)
8430 CALL POPREAL8(max12)
8433 CALL POPCONTROL1B(branch)
8434 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y8
8438 temp7 = max30**temp8
8440 temp4 = den(i, k)**temp5
8441 temp3 = -(alpha*max11/2.)
8443 a_temp2 = temp7*temp9*a_c
8444 a_temp0 = temp2*temp4*a_c
8445 IF (max30 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. INT&
8449 a_max30 = temp8*max30**(temp8-1)*temp9*a_temp0
8451 IF (max43 .EQ. 0.0_8) THEN
8454 a_max43 = temp7*a_temp0/(2.0*temp9)
8456 a_max11 = -(alpha*EXP(temp3)*temp4*a_temp2/2.)
8457 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
8458 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
8459 & den(i, k)**(temp5-1)*temp2*a_temp2
8460 CALL POPCONTROL1B(branch)
8461 IF (branch .EQ. 0) THEN
8462 CALL POPREAL8(max43)
8464 CALL POPREAL8(max43)
8465 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max43
8467 CALL POPCONTROL1B(branch)
8468 IF (branch .EQ. 0) THEN
8469 CALL POPREAL8(max30)
8470 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max30
8472 CALL POPREAL8(max30)
8474 CALL POPCONTROL1B(branch)
8475 IF (branch .EQ. 0) THEN
8476 CALL POPREAL8(max11)
8479 CALL POPREAL8(max11)
8482 CALL POPCONTROL1B(branch)
8483 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y7
8487 temp7 = -(alpha*max10/4.)
8490 temp3 = max29**temp4
8492 temp0 = den(i, k)**temp2
8493 a_temp6 = temp6*temp8*a_b
8494 a_temp = temp0*temp3*a_b
8495 a_max10 = -(alpha*EXP(temp7)*temp8*a_temp/4.)
8496 IF (max42 .EQ. 0.0_8 .OR. temp9 .EQ. 0.0_8) THEN
8499 a_max42 = temp6*a_temp/(2.0**2*temp9*temp8)
8501 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. &
8502 & temp2 .NE. INT(temp2)))) a_den(i, k) = a_den(i, k) + temp2*&
8503 & den(i, k)**(temp2-1)*temp3*a_temp6
8504 IF (max29 .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. temp4 .NE. INT&
8508 a_max29 = temp4*max29**(temp4-1)*temp0*a_temp6
8510 CALL POPCONTROL1B(branch)
8511 IF (branch .EQ. 0) THEN
8512 CALL POPREAL8(max42)
8514 CALL POPREAL8(max42)
8515 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max42
8517 CALL POPCONTROL1B(branch)
8518 IF (branch .EQ. 0) THEN
8519 CALL POPREAL8(max29)
8520 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max29
8522 CALL POPREAL8(max29)
8524 CALL POPCONTROL1B(branch)
8525 IF (branch .EQ. 0) THEN
8526 CALL POPREAL8(max10)
8529 CALL POPREAL8(max10)
8532 CALL POPCONTROL1B(branch)
8533 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y6
8535 a_max9 = alpha*EXP(alpha*max9)*a_a
8536 CALL POPCONTROL1B(branch)
8537 IF (branch .EQ. 0) THEN
8544 CALL POPCONTROL1B(branch)
8545 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y5
8546 temp9 = -(alpha*bvts*max28/4.)
8549 temp5 = (bvts-2.)/4.
8550 temp4 = den(i, k)**temp5
8551 a_temp5 = EXP(temp9)*vt2s_a*a_vt2s
8552 a_max28 = -(alpha*bvts*EXP(temp9)*temp4*temp6*vt2s_a*a_vt2s/4.)
8553 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
8554 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
8555 & den(i, k)**(temp5-1)*temp6*a_temp5
8556 IF (max8 .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. temp7 .NE. INT(&
8560 a_max8 = temp7*max8**(temp7-1)*temp4*a_temp5
8562 CALL POPCONTROL1B(branch)
8563 IF (branch .EQ. 0) THEN
8564 CALL POPREAL8(max28)
8567 CALL POPREAL8(max28)
8570 CALL POPCONTROL1B(branch)
8571 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y14
8572 CALL POPCONTROL1B(branch)
8573 IF (branch .EQ. 0) THEN
8577 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max8
8580 temp8 = (bvtr-2.)/4.
8581 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. &
8582 & temp8 .NE. INT(temp8)))) a_den(i, k) = a_den(i, k) + temp8*&
8583 & den(i, k)**(temp8-1)*max7**temp9*vt2r_a*a_vt2r
8584 IF (max7 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT(&
8588 a_max7 = temp9*max7**(temp9-1)*den(i, k)**temp8*vt2r_a*a_vt2r
8590 CALL POPCONTROL1B(branch)
8591 IF (branch .EQ. 0) THEN
8595 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max7
8597 CALL POPCONTROL1B(branch)
8598 IF (branch .NE. 0) a_xlf = 0.0_8
8600 a_xl(i, k) = a_xl(i, k) - a_xlf
8601 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
8603 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
8605 a_pracs(i, k) = 0.0_8
8606 CALL POPCONTROL1B(branch)
8607 IF (branch .EQ. 0) THEN
8608 a_qrs(i, k, 3) = 0.0_8
8610 a_pracs(i, k) = a_pracs(i, k) + dtcld*a_qrs(i, k, 3)
8612 CALL POPCONTROL1B(branch)
8613 IF (branch .EQ. 0) THEN
8614 a_qrs(i, k, 2) = 0.0_8
8616 a_pracs(i, k) = a_pracs(i, k) - dtcld*a_qrs(i, k, 2)
8618 CALL POPCONTROL1B(branch)
8619 IF (branch .NE. 0) a_pracs(i, k) = 0.0_8
8620 CALL POPREAL8(pracs(i, k))
8621 a_fsupcol = a_fsupcol + pracs(i, k)*a_pracs(i, k)
8622 a_pracs(i, k) = fsupcol*a_pracs(i, k)
8623 CALL POPCONTROL1B(branch)
8624 IF (branch .EQ. 0) THEN
8625 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_pracs(i, k)/dtcld
8626 a_pracs(i, k) = 0.0_8
8629 a_pracs1 = a_pracs(i, k)
8630 a_pracs(i, k) = 0.0_8
8632 a_temp1 = (pracs_b*b+pracs_c*c+pracs_d*d)*pracs_a*a_pracs1
8633 a_temp5 = a*abs0*pracs_a*a_pracs1
8634 a_b = pracs_b*a_temp5
8635 a_c = pracs_c*a_temp5
8636 a_d = pracs_d*a_temp5
8639 CALL POPCONTROL1B(branch)
8640 IF (branch .EQ. 0) THEN
8651 temp8 = max41**temp9
8653 temp5 = den(i, k)**temp6
8654 temp4 = EXP(-(alpha*max6))
8655 a_temp3 = max27*temp8*a_d
8656 a_temp4 = temp4*temp5*a_d
8657 a_max27 = temp8*a_temp4
8658 IF (max41 .LE. 0.0_8 .AND. (temp9 .EQ. 0.0_8 .OR. temp9 .NE. INT&
8662 a_max41 = temp9*max41**(temp9-1)*max27*a_temp4
8664 a_max6 = -(alpha*EXP(-(alpha*max6))*temp5*a_temp3)
8665 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. &
8666 & temp6 .NE. INT(temp6)))) a_den(i, k) = a_den(i, k) + temp6*&
8667 & den(i, k)**(temp6-1)*temp4*a_temp3
8668 CALL POPCONTROL1B(branch)
8669 IF (branch .EQ. 0) THEN
8670 CALL POPREAL8(max41)
8672 CALL POPREAL8(max41)
8673 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max41
8675 CALL POPCONTROL1B(branch)
8676 IF (branch .EQ. 0) THEN
8677 CALL POPREAL8(max27)
8678 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max27
8680 CALL POPREAL8(max27)
8682 CALL POPCONTROL1B(branch)
8683 IF (branch .EQ. 0) THEN
8690 CALL POPCONTROL1B(branch)
8691 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y4
8695 temp7 = max26**temp8
8697 temp4 = den(i, k)**temp5
8698 temp3 = -(5.*alpha*max5/4.)
8700 a_temp2 = temp7*temp9*a_c
8701 a_temp0 = temp2*temp4*a_c
8702 IF (max26 .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 .NE. INT&
8706 a_max26 = temp8*max26**(temp8-1)*temp9*a_temp0
8708 IF (max40 .EQ. 0.0_8) THEN
8711 a_max40 = temp7*a_temp0/(2.0*temp9)
8713 a_max5 = -(alpha*5.*EXP(temp3)*temp4*a_temp2/4.)
8714 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
8715 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
8716 & den(i, k)**(temp5-1)*temp2*a_temp2
8717 CALL POPCONTROL1B(branch)
8718 IF (branch .EQ. 0) THEN
8719 CALL POPREAL8(max40)
8721 CALL POPREAL8(max40)
8722 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max40
8724 CALL POPCONTROL1B(branch)
8725 IF (branch .EQ. 0) THEN
8726 CALL POPREAL8(max26)
8727 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max26
8729 CALL POPREAL8(max26)
8731 CALL POPCONTROL1B(branch)
8732 IF (branch .EQ. 0) THEN
8739 CALL POPCONTROL1B(branch)
8740 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y3
8744 temp3 = -(3.*alpha*max4/2.)
8749 temp8 = den(i, k)**temp7
8750 a_temp0 = temp2*temp4*a_b
8751 a_temp1 = temp8*temp6*a_b
8752 a_max4 = -(alpha*3.*EXP(temp3)*temp4*a_temp1/2.)
8753 IF (max39 .EQ. 0.0_8 .OR. temp5 .EQ. 0.0_8) THEN
8756 a_max39 = temp2*a_temp1/(2.0**2*temp5*temp4)
8758 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp7 .EQ. 0.0_8 .OR. &
8759 & temp7 .NE. INT(temp7)))) a_den(i, k) = a_den(i, k) + temp7*&
8760 & den(i, k)**(temp7-1)*temp6*a_temp0
8761 IF (max25 .LE. 0.0_8 .AND. (temp .EQ. 0.0_8 .OR. temp .NE. INT(&
8765 a_max25 = temp*max25**(temp-1)*temp8*a_temp0
8767 CALL POPCONTROL1B(branch)
8768 IF (branch .EQ. 0) THEN
8769 CALL POPREAL8(max39)
8771 CALL POPREAL8(max39)
8772 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max39
8774 CALL POPCONTROL1B(branch)
8775 IF (branch .EQ. 0) THEN
8776 CALL POPREAL8(max25)
8777 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max25
8779 CALL POPREAL8(max25)
8781 CALL POPCONTROL1B(branch)
8782 IF (branch .EQ. 0) THEN
8789 CALL POPCONTROL1B(branch)
8790 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y2
8792 a_max3 = alpha*EXP(alpha*max3)*a_a
8793 CALL POPCONTROL1B(branch)
8794 IF (branch .EQ. 0) THEN
8801 CALL POPCONTROL1B(branch)
8802 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y1
8803 temp0 = -(alpha*bvts*max24/4.)
8806 temp4 = (bvts-2.)/4.
8807 temp5 = den(i, k)**temp4
8808 a_temp = EXP(temp0)*vt2s_a*a_vt2s
8809 a_max24 = -(alpha*bvts*EXP(temp0)*temp5*temp3*vt2s_a*a_vt2s/4.)
8810 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp4 .EQ. 0.0_8 .OR. &
8811 & temp4 .NE. INT(temp4)))) a_den(i, k) = a_den(i, k) + temp4*&
8812 & den(i, k)**(temp4-1)*temp3*a_temp
8813 IF (max2 .LE. 0.0_8 .AND. (temp2 .EQ. 0.0_8 .OR. temp2 .NE. INT(&
8817 a_max2 = temp2*max2**(temp2-1)*temp5*a_temp
8819 CALL POPCONTROL1B(branch)
8820 IF (branch .EQ. 0) THEN
8821 CALL POPREAL8(max24)
8824 CALL POPREAL8(max24)
8827 CALL POPCONTROL1B(branch)
8828 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y13
8829 CALL POPCONTROL1B(branch)
8830 IF (branch .EQ. 0) THEN
8834 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max2
8837 temp0 = (bvtr-2.)/4.
8838 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp0 .EQ. 0.0_8 .OR. &
8839 & temp0 .NE. INT(temp0)))) a_den(i, k) = a_den(i, k) + temp0*&
8840 & den(i, k)**(temp0-1)*max1**temp*vt2r_a*a_vt2r
8841 IF (max1 .LE. 0.0_8 .AND. (temp .EQ. 0.0_8 .OR. temp .NE. INT(&
8845 a_max1 = temp*max1**(temp-1)*den(i, k)**temp0*vt2r_a*a_vt2r
8847 CALL POPCONTROL1B(branch)
8848 IF (branch .EQ. 0) THEN
8852 a_qrs(i, k, 1) = a_qrs(i, k, 1) + a_max1
8854 CALL POPREAL8(fsupcol)
8856 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't0')
8857 CALL POPREAL8(supcol)
8858 a_t(i, k) = a_t(i, k) - a_supcol
8861 END SUBROUTINE A_ACCRET2
8863 !=======================================================================
8865 !=======================================================================
8866 SUBROUTINE ACCRET2(qrs, t, q, den, dtcld, psacw, pgacw, pracs, psacr, &
8867 & pgacr, pgacs, pseml, pgeml, ims, ime, kms, kme, its, ite, kts, kte)
8869 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
8870 !-------------------------------------------------------------------
8871 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
8872 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
8873 REAL, DIMENSION(its:ite, kts:kte) :: psacw, pgacw, pracs, psacr, &
8874 & pgacr, pgacs, pseml, pgeml, t, xl, cpm
8875 REAL :: supcol, vt2r, vt2s, vt2g, dtcld, xlf, egs
8876 REAL :: acrfac1, acrfac2, acrfac3, acrfac4, pracs1, psacr1, pgacr1, &
8879 REAL :: fsupcol, ft0, fqr, fqs, fqg, temp1, delta2, a, b, c, d
8967 !-------------------------------------------------------------
8968 ! pracs: Accretion of snow by rain [LFO 27]
8969 ! (T<T0: S->G) pracs: min=0., max=qrs(i,k,2)/dtcld
8970 !-------------------------------------------------------------
8971 supcol = t0c - t(i, k)
8972 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
8973 IF (qrs(i, k, 1) .LT. qcrmin) THEN
8978 !call smoothif(qrs(i,k,1),1.e-4,fqr,'q0')
8979 !call smoothif(qrs(i,k,2),1.e-4,fqs,'q0')
8980 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max1**(bvtr/4.)
8981 IF (qrs(i, k, 2) .LT. qcrmin) THEN
8986 IF (90. .GT. t0c - t(i, k)) THEN
8991 IF (0. .LT. y13) THEN
8996 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max2**(bvts/4.)*EXP(-(&
8997 & alpha*bvts*max24/4.))
8998 IF (90. .GT. t0c - t(i, k)) THEN
9003 IF (0. .LT. y1) THEN
9009 IF (90. .GT. t0c - t(i, k)) THEN
9014 IF (0. .LT. y2) THEN
9019 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9022 max25 = qrs(i, k, 2)
9024 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9027 max39 = qrs(i, k, 1)
9029 b = EXP(-(3.*alpha*max4/2.))*den(i, k)**(3./4.)*max25**(3./2.)*&
9031 IF (90. .GT. t0c - t(i, k)) THEN
9036 IF (0. .LT. y3) THEN
9041 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9044 max26 = qrs(i, k, 2)
9046 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9049 max40 = qrs(i, k, 1)
9051 c = EXP(-(5.*alpha*max5/4.))*den(i, k)**(3./4.)*max26**(5./4.)*&
9053 IF (90. .GT. t0c - t(i, k)) THEN
9058 IF (0. .LT. y4) THEN
9063 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9066 max27 = qrs(i, k, 2)
9068 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9071 max41 = qrs(i, k, 1)
9073 d = EXP(-(alpha*max6))*den(i, k)**(3./4.)*max27*max41**(3./4.)
9074 IF (vt2r - vt2s .GE. 0.) THEN
9079 pracs1 = pracs_a*a*abs0*(pracs_b*b+pracs_c*c+pracs_d*d)
9080 IF (pracs1 .GT. qrs(i, k, 2)/dtcld) THEN
9081 pracs(i, k) = qrs(i, k, 2)/dtcld
9083 pracs(i, k) = pracs1
9085 pracs(i, k) = fsupcol*pracs(i, k)
9086 IF (pracs(i, k) .GE. 0.) THEN
9091 IF (abs1 .LT. qmin/dtcld) pracs(i, k) = 0.
9092 IF (qrs(i, k, 2) - pracs(i, k)*dtcld .LT. 0.) THEN
9095 qrs(i, k, 2) = qrs(i, k, 2) - pracs(i, k)*dtcld
9097 IF (qrs(i, k, 3) + pracs(i, k)*dtcld .LT. 0.) THEN
9100 qrs(i, k, 3) = qrs(i, k, 3) + pracs(i, k)*dtcld
9103 !-------------------------------------------------------------
9104 ! psacr: Accretion of rain by snow [LFO 28]
9105 ! (T< T0: R->S or R->G) min=0.,max=qrs(i,k,1)/dtcld
9106 ! (T>=T0: S->R enhance melting of snow) min=0.,max=qrs(i,k,2)/dtcld
9107 !-------------------------------------------------------------
9108 ! supcol = t0c-t(i,k) !not change
9109 ! call smoothif(supcol,0.,fsupcol,'t0')
9110 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
9111 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
9113 cpm(i, k) = CPMCAL(q(i, k))
9114 xl(i, k) = XLCAL(t(i, k))
9115 xlf = xls - xl(i, k)
9116 IF (supcol .LT. 0.) xlf = xlf0
9117 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9122 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max7**(bvtr/4.)
9123 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9128 IF (90. .GT. t0c - t(i, k)) THEN
9133 IF (0. .LT. y14) THEN
9138 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max8**(bvts/4.)*EXP(-(&
9139 & alpha*bvts*max28/4.))
9140 IF (90. .GT. t0c - t(i, k)) THEN
9145 IF (0. .LT. y5) THEN
9151 IF (90. .GT. t0c - t(i, k)) THEN
9156 IF (0. .LT. y6) THEN
9161 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9164 max29 = qrs(i, k, 1)
9166 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9169 max42 = qrs(i, k, 2)
9171 b = EXP(-(alpha*max10/4.))*den(i, k)**(3./4.)*max29**(3./2.)*&
9173 IF (90. .GT. t0c - t(i, k)) THEN
9178 IF (0. .LT. y7) THEN
9183 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9186 max30 = qrs(i, k, 1)
9188 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9191 max43 = qrs(i, k, 2)
9193 c = EXP(-(alpha*max11/2.))*den(i, k)**(3./4.)*max30**(5./4.)*&
9195 IF (90. .GT. t0c - t(i, k)) THEN
9200 IF (0. .LT. y8) THEN
9205 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9208 max31 = qrs(i, k, 1)
9210 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9213 max44 = qrs(i, k, 2)
9215 d = EXP(-(3.*alpha*max12/4.))*den(i, k)**(3./4.)*max31*max44**(&
9217 IF (vt2r - vt2s .GE. 0.) THEN
9222 psacr1 = psacr_a*a*abs2*(psacr_b*b+psacr_c*c+psacr_d*d)
9223 IF (supcol .GT. 0.) THEN
9224 IF (psacr1 .GT. qrs(i, k, 1)/dtcld) THEN
9225 psacr(i, k) = qrs(i, k, 1)/dtcld
9227 psacr(i, k) = psacr1
9229 ELSE IF (psacr1 .GT. qrs(i, k, 2)/dtcld) THEN
9230 psacr(i, k) = qrs(i, k, 2)/dtcld
9232 psacr(i, k) = psacr1
9234 IF (psacr(i, k) .GE. 0.) THEN
9239 !psacr(i,k)=fqr*fqs*psacr(i,k)
9240 IF (abs3 .LT. qmin/dtcld) psacr(i, k) = 0.
9242 IF (qrs(i, k, 1) .LT. 1.e-4 .AND. qrs(i, k, 2) .LT. 1.e-4) THEN
9247 IF (qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld .LT. 0.) THEN
9250 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld
9252 x1 = qrs(i, k, 2) + fsupcol*delta2*psacr(i, k)*dtcld
9253 IF (x1 .LT. 0.) THEN
9258 x2 = qrs(i, k, 3) + fsupcol*(1-delta2)*psacr(i, k)*dtcld
9259 IF (x2 .LT. 0.) THEN
9264 t(i, k) = t(i, k) + fsupcol*psacr(i, k)*dtcld*xlf/cpm(i, k)
9266 psacr(i, k) = (1-fsupcol)*psacr(i, k)
9267 !-------------------------------------------------------------
9268 ! pgacr: Accretion of rain by graupel [LFO 42]
9269 ! (T< T0: R->G) min=0.,max=qrs(i,k,1)/dtcld
9270 ! (T>=T0: G->R enhance melting of graupel) min=0.,max=qrs(i,k,3)/dtcld
9271 !-------------------------------------------------------------
9272 supcol = t0c - t(i, k)
9273 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
9274 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
9275 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
9277 ! cpm(i,k)=cpmcal(q(i,k)) !not change
9278 xl(i, k) = XLCAL(t(i, k))
9279 xlf = xls - xl(i, k)
9280 IF (supcol .LT. 0.) xlf = xlf0
9281 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9284 max13 = qrs(i, k, 1)
9286 vt2r = vt2r_a*den(i, k)**((bvtr-2.)/4.)*max13**(bvtr/4.)
9287 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9290 max14 = qrs(i, k, 3)
9292 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max14**(bvtg/4.)
9293 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9296 max15 = qrs(i, k, 1)
9298 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9301 max32 = qrs(i, k, 3)
9303 b = den(i, k)**(3./4.)*max15**(3./2.)*SQRT(SQRT(max32))
9304 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9307 max16 = qrs(i, k, 1)
9309 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9312 max33 = qrs(i, k, 3)
9314 c = den(i, k)**(3./4.)*max16**(5./4.)*SQRT(max33)
9315 IF (qrs(i, k, 1) .LT. qcrmin) THEN
9318 max17 = qrs(i, k, 1)
9320 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9323 max34 = qrs(i, k, 3)
9325 d = den(i, k)**(3./4.)*max17*max34**(3./4.)
9326 IF (vt2r - vt2g .GE. 0.) THEN
9331 pgacr1 = pgacr_a*abs4*(pgacr_b*b+pgacr_c*c+pgacr_d*d)
9332 IF (supcol .GT. 0.) THEN
9333 IF (pgacr1 .GT. qrs(i, k, 1)/dtcld) THEN
9334 pgacr(i, k) = qrs(i, k, 1)/dtcld
9336 pgacr(i, k) = pgacr1
9338 ELSE IF (pgacr1 .GT. qrs(i, k, 3)/dtcld) THEN
9339 pgacr(i, k) = qrs(i, k, 3)/dtcld
9341 pgacr(i, k) = pgacr1
9343 IF (pgacr(i, k) .GE. 0.) THEN
9348 !pgacr(i,k)=fqg*fqr*pgacr(i,k)
9349 IF (abs5 .LT. qmin/dtcld) pgacr(i, k) = 0.
9350 IF (qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld .LT. 0.) THEN
9353 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld
9355 x3 = qrs(i, k, 3) + fsupcol*pgacr(i, k)*dtcld
9356 IF (x3 .LT. 0.) THEN
9361 t(i, k) = t(i, k) + fsupcol*pgacr(i, k)*dtcld*xlf/cpm(i, k)
9363 pgacr(i, k) = (1-fsupcol)*pgacr(i, k)
9364 !-------------------------------------------------------------
9365 ! pgacs: Accretion of snow by graupel [LFO 29]
9366 ! (S->G) min=0,max=qrs(i,k,2)/dtcld
9367 !-------------------------------------------------------------
9368 supcol = t0c - t(i, k)
9369 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
9370 x4 = EXP(-(0.09*supcol))
9371 IF (x4 .GT. 1.) THEN
9376 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9379 max18 = qrs(i, k, 3)
9381 vt2g = vt2g_a*den(i, k)**((bvtg-2.)/4.)*max18**(bvtg/4.)
9382 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9385 max19 = qrs(i, k, 2)
9387 IF (90. .GT. t0c - t(i, k)) THEN
9392 IF (0. .LT. y15) THEN
9397 vt2s = vt2s_a*den(i, k)**((bvts-2.)/4.)*max19**(bvts/4.)*EXP(-(&
9398 & alpha*bvts*max35/4.))
9399 IF (90. .GT. t0c - t(i, k)) THEN
9404 IF (0. .LT. y9) THEN
9409 a = EXP(alpha*max20)
9410 IF (90. .GT. t0c - t(i, k)) THEN
9415 IF (0. .LT. y10) THEN
9420 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9423 max36 = qrs(i, k, 2)
9425 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9428 max45 = qrs(i, k, 3)
9430 b = EXP(-(3.*alpha*max21/2.))*den(i, k)**(3./4.)*max36**(3./2.)*&
9432 IF (90. .GT. t0c - t(i, k)) THEN
9437 IF (0. .LT. y11) THEN
9442 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9445 max37 = qrs(i, k, 2)
9447 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9450 max46 = qrs(i, k, 3)
9452 c = EXP(-(5.*alpha*max22/4.))*den(i, k)**(3./4.)*max37**(5./4.)*&
9454 IF (90. .GT. t0c - t(i, k)) THEN
9459 IF (0. .LT. y12) THEN
9464 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9467 max38 = qrs(i, k, 2)
9469 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9472 max47 = qrs(i, k, 3)
9474 d = EXP(-(alpha*max23))*den(i, k)**(3./4.)*max38*max47**(3./4.)
9475 IF (vt2g - vt2s .GE. 0.) THEN
9480 pgacs1 = pgacs_a*a*abs6*(pgacs_b*b+pgacs_c*c+pgacs_d*d)*egs
9481 IF (pgacs1 .GT. qrs(i, k, 2)/dtcld) THEN
9482 pgacs(i, k) = qrs(i, k, 2)/dtcld
9484 pgacs(i, k) = pgacs1
9486 IF (pgacs(i, k) .GE. 0.) THEN
9491 !pgacs(i,k)=fqg*fqs*pgacs(i,k)
9492 IF (abs7 .LT. qmin/dtcld) pgacs(i, k) = 0.
9493 IF (qrs(i, k, 2) - pgacs(i, k)*dtcld .LT. 0.) THEN
9496 qrs(i, k, 2) = qrs(i, k, 2) - pgacs(i, k)*dtcld
9498 IF (qrs(i, k, 3) + pgacs(i, k)*dtcld .LT. 0.) THEN
9501 qrs(i, k, 3) = qrs(i, k, 3) + pgacs(i, k)*dtcld
9504 !-------------------------------------------------------------
9505 ! pseml: Enhanced melting of snow by accretion of water
9506 ! (T>=T0: S->R) pseml<0 max=0,min=-qrs(i,k,2)/dtcld
9507 !-------------------------------------------------------------
9508 ! supcol = t0c-t(i,k) ! not change
9510 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
9511 xl(i, k) = XLCAL(t(i, k))
9512 xlf = xls - xl(i, k)
9513 IF (supcol .LT. 0.) xlf = xlf0
9514 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
9515 CALL SMOOTHIF(qrs(i, k, 2), 0., fqs, 'q+')
9516 x7 = cliq*supcol*(psacw(i, k)+psacr(i, k))/xlf
9517 IF (x7 .LT. -(qrs(i, k, 2)/dtcld)) THEN
9518 x5 = -(qrs(i, k, 2)/dtcld)
9522 IF (x5 .GT. 0.) THEN
9527 pseml(i, k) = ft0*fqs*pseml(i, k)
9528 IF (pseml(i, k) .GE. 0.) THEN
9533 IF (abs8 .LT. qmin/dtcld) pseml(i, k) = 0.
9534 IF (qrs(i, k, 1) - pseml(i, k)*dtcld .LT. 0.) THEN
9537 qrs(i, k, 1) = qrs(i, k, 1) - pseml(i, k)*dtcld
9539 IF (qrs(i, k, 2) + pseml(i, k)*dtcld .LT. 0.) THEN
9542 qrs(i, k, 2) = qrs(i, k, 2) + pseml(i, k)*dtcld
9544 t(i, k) = t(i, k) + pseml(i, k)*dtcld*xlf/cpm(i, k)
9548 !-------------------------------------------------------------
9549 ! pgeml: Enhanced melting of graupel by accretion of water [RH84 A21-A22]
9550 ! (T>=T0: G->R) pgeml<0 max=0,min=-qrs(i,k,3)/dtcld
9551 !-------------------------------------------------------------
9552 supcol = t0c - t(i, k)
9554 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
9555 xl(i, k) = XLCAL(t(i, k))
9556 xlf = xls - xl(i, k)
9557 IF (supcol .LT. 0.) xlf = xlf0
9558 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
9559 CALL SMOOTHIF(qrs(i, k, 3), 0., fqg, 'q+')
9560 x8 = cliq*supcol*(pgacw(i, k)+pgacr(i, k))/xlf
9561 IF (x8 .LT. -(qrs(i, k, 3)/dtcld)) THEN
9562 x6 = -(qrs(i, k, 3)/dtcld)
9566 IF (x6 .GT. 0.) THEN
9571 pgeml(i, k) = ft0*fqg*pgeml(i, k)
9572 IF (pgeml(i, k) .GE. 0.) THEN
9577 IF (abs9 .LT. qmin/dtcld) pgeml(i, k) = 0.
9578 IF (qrs(i, k, 1) - pgeml(i, k)*dtcld .LT. 0.) THEN
9581 qrs(i, k, 1) = qrs(i, k, 1) - pgeml(i, k)*dtcld
9583 IF (qrs(i, k, 3) + pgeml(i, k)*dtcld .LT. 0.) THEN
9586 qrs(i, k, 3) = qrs(i, k, 3) + pgeml(i, k)*dtcld
9588 t(i, k) = t(i, k) + pgeml(i, k)*dtcld*xlf/cpm(i, k)
9594 END SUBROUTINE ACCRET2
9596 ! Differentiation of accret3 in reverse (adjoint) mode (with options r8):
9597 ! gradient of useful results: p q t qs pigen rh den qrs psevp
9598 ! pidep pgevp psdep qci pgdep psaut pgaut
9599 ! with respect to varying inputs: p q t qs pigen rh den qrs psevp
9600 ! pidep pgevp psdep qci pgdep psaut pgaut
9601 !=======================================================================
9603 !=======================================================================
9604 SUBROUTINE A_ACCRET3(qrs, a_qrs, qci, a_qci, rh, a_rh, t, a_t, p, a_p&
9605 & , den, a_den, dtcld, q, a_q, qs, a_qs, psdep, a_psdep, pgdep, &
9606 & a_pgdep, pigen, a_pigen, psaut, a_psaut, pgaut, a_pgaut, psevp, &
9607 & a_psevp, pgevp, a_pgevp, pidep, a_pidep, ims, ime, kms, kme, its, &
9610 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
9611 !-------------------------------------------------------------------
9612 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
9613 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
9614 REAL, DIMENSION(ims:ime, kms:kme) :: den, q, p
9615 REAL, DIMENSION(ims:ime, kms:kme) :: a_den, a_q, a_p
9616 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, rh, qs
9617 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qrs, a_rh, a_qs
9618 REAL, DIMENSION(its:ite, kts:kte) :: pigen, psevp, pgevp, pidep, t, &
9619 & xl, cpm, psdep, pgdep, psaut, pgaut
9620 REAL, DIMENSION(its:ite, kts:kte) :: a_pigen, a_psevp, a_pgevp, &
9621 & a_pidep, a_t, a_xl, a_cpm, a_psdep, a_pgdep, a_psaut, a_pgaut
9622 REAL :: supcol, dtcld, satdt, supsat, qimax, diameter, xni0, roqi0, &
9623 & supice1, supice2, supice3, supice4, alpha2
9624 REAL :: a_supcol, a_satdt, a_supsat, a_qimax, a_xni0, a_roqi0, &
9626 REAL :: pidep0, pidep1, psdep0, pgdep3, pigen0, psevp0, pgevp0, &
9627 & coeres1, coeres2, coeres3, coeres4
9628 REAL :: a_pidep0, a_psdep0, a_pgdep3, a_pigen0, a_psevp0, a_pgevp0
9629 REAL :: temp0, temp, xmi
9631 REAL :: fqi, fqr, fqv, fqs, fqg, frh, ft0, fpidep, fpsdep, fpgdep, &
9632 & fsupcol, fsupsat, pidep2
9633 REAL :: a_ft0, a_fsupcol, a_fsupsat
9634 REAL :: value01, factor01, source01, vice, a, b, c, d, e, f, g
9635 REAL :: a_a, a_b, a_c, a_d, a_e
9733 !-------------------------------------------------------------
9734 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
9735 ! (T<T0: V->I or I->V)
9736 ! rh(i,k,2)>1.,pidep>0: V->I, min=0, max=satdt
9737 ! rh(i,k,2)<1.,pidep<0: I->V, min=-qi/dtcld,max=0,
9738 !-------------------------------------------------------------
9740 CALL PUSHREAL8(supcol)
9741 supcol = t0c - t(i, k)
9743 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
9744 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9746 CALL PUSHREAL8(supsat)
9747 supsat = q(i, k) - qs(i, k, 2)
9748 satdt = supsat/dtcld
9750 cpm(i, k) = CPMCAL(q(i, k))
9751 CALL PUSHREAL8(fsupcol)
9752 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
9753 IF (qci(i, k, 2) .GT. 0.) THEN
9755 b = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
9757 c = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
9759 a = (rh(i, k, 2)-1.)/(b+c)
9760 pidep0 = pidep_a*a*(den(i, k)*qci(i, k, 2))**(7./8.)
9761 CALL PUSHCONTROL1B(0)
9763 CALL PUSHCONTROL1B(1)
9766 IF (pidep0 .LT. 0.) THEN
9767 IF (pidep0 .LT. -(qci(i, k, 2)/dtcld)) THEN
9768 x1 = -(qci(i, k, 2)/dtcld)
9769 CALL PUSHCONTROL1B(0)
9772 CALL PUSHCONTROL1B(1)
9774 IF (x1 .GT. 0.) THEN
9776 CALL PUSHCONTROL2B(1)
9779 CALL PUSHCONTROL2B(0)
9782 IF (pidep0 .GT. satdt) THEN
9784 CALL PUSHCONTROL1B(0)
9787 CALL PUSHCONTROL1B(1)
9789 IF (x2 .LT. 0.) THEN
9791 CALL PUSHCONTROL2B(3)
9794 CALL PUSHCONTROL2B(2)
9797 CALL PUSHREAL8(pidep(i, k))
9798 pidep(i, k) = fsupcol*pidep(i, k)
9799 IF (pidep(i, k) .GE. 0.) THEN
9804 IF (abs0 .LT. qmin/dtcld) THEN
9806 CALL PUSHCONTROL1B(1)
9808 CALL PUSHCONTROL1B(0)
9810 IF (q(i, k) - pidep(i, k)*dtcld .LT. 0.) THEN
9811 CALL PUSHREAL8(q(i, k))
9813 CALL PUSHCONTROL1B(0)
9815 CALL PUSHREAL8(q(i, k))
9816 q(i, k) = q(i, k) - pidep(i, k)*dtcld
9817 CALL PUSHCONTROL1B(1)
9819 IF (qci(i, k, 2) + pidep(i, k)*dtcld .LT. 0.) THEN
9820 CALL PUSHREAL8(qci(i, k, 2))
9822 CALL PUSHCONTROL1B(0)
9824 CALL PUSHREAL8(qci(i, k, 2))
9825 qci(i, k, 2) = qci(i, k, 2) + pidep(i, k)*dtcld
9826 CALL PUSHCONTROL1B(1)
9828 CALL PUSHREAL8(t(i, k))
9829 t(i, k) = t(i, k) + pidep(i, k)*dtcld*xls/cpm(i, k)
9831 !-------------------------------------------------------------
9832 ! psdep: deposition/sublimation rate of snow [HDC 14]
9833 ! (T<T0: V->S or S->V)
9834 ! rh(i,k,2)>1.,psdep>0: V->S, min=0, max=satdt
9835 ! rh(i,k,2)<1.,psdep<0: S->V, min=-qs/dtcld,max=0,
9836 !-------------------------------------------------------------
9838 CALL PUSHREAL8(supcol)
9839 supcol = t0c - t(i, k)
9841 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
9842 CALL PUSHREAL8ARRAY(rh(i, k, :), 3)
9843 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9845 supsat = q(i, k) - qs(i, k, 2)
9846 satdt = supsat/dtcld
9848 CALL PUSHREAL8(cpm(i, k))
9849 cpm(i, k) = CPMCAL(q(i, k))
9850 CALL PUSHREAL8(fsupcol)
9851 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
9852 IF (90. .GT. t0c - t(i, k)) THEN
9854 CALL PUSHCONTROL1B(0)
9856 CALL PUSHCONTROL1B(1)
9859 IF (0. .LT. y1) THEN
9860 CALL PUSHREAL8(max1)
9862 CALL PUSHCONTROL1B(1)
9864 CALL PUSHREAL8(max1)
9866 CALL PUSHCONTROL1B(0)
9868 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9869 CALL PUSHREAL8(max9)
9871 CALL PUSHCONTROL1B(0)
9873 CALL PUSHREAL8(max9)
9875 CALL PUSHCONTROL1B(1)
9877 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
9878 ! call smoothif(q (i,k ),0.,fqv,'q+')
9880 a = EXP(alpha*max1/2.)*SQRT(den(i, k)*max9)
9881 IF (90. .GT. t0c - t(i, k)) THEN
9883 CALL PUSHCONTROL1B(0)
9885 CALL PUSHCONTROL1B(1)
9888 IF (0. .LT. y2) THEN
9889 CALL PUSHREAL8(max2)
9891 CALL PUSHCONTROL1B(1)
9893 CALL PUSHREAL8(max2)
9895 CALL PUSHCONTROL1B(0)
9897 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9898 CALL PUSHREAL8(max10)
9900 CALL PUSHCONTROL1B(0)
9902 CALL PUSHREAL8(max10)
9903 max10 = qrs(i, k, 2)
9904 CALL PUSHCONTROL1B(1)
9907 b = EXP((3.-bvts)*alpha*max2/8.)*(t(i, k)+120.)**(1./6.)/t(i, k)&
9908 & **(5.12/6.)*p(i, k)**(1./3.)*den(i, k)**((13.+3.*bvts)/24.)*&
9909 & max10**((5.+bvts)/8.)
9911 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
9913 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
9915 e = (rh(i, k, 2)-1.)/(c+d)
9916 psdep0 = e*(psdep_a*a+psdep_b*b)
9917 IF (psdep0 .LT. 0.) THEN
9918 IF (psdep0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
9919 x3 = -(qrs(i, k, 2)/dtcld)
9920 CALL PUSHCONTROL1B(0)
9923 CALL PUSHCONTROL1B(1)
9925 IF (x3 .GT. 0.) THEN
9927 CALL PUSHCONTROL2B(1)
9930 CALL PUSHCONTROL2B(0)
9933 IF (psdep0 .GT. satdt) THEN
9935 CALL PUSHCONTROL1B(0)
9938 CALL PUSHCONTROL1B(1)
9940 IF (x4 .LT. 0.) THEN
9942 CALL PUSHCONTROL2B(3)
9945 CALL PUSHCONTROL2B(2)
9948 CALL PUSHREAL8(psdep(i, k))
9949 psdep(i, k) = fsupcol*psdep(i, k)
9950 IF (psdep(i, k) .GE. 0.) THEN
9955 IF (abs1 .LT. qmin/dtcld) THEN
9957 CALL PUSHCONTROL1B(1)
9959 CALL PUSHCONTROL1B(0)
9961 IF (q(i, k) - psdep(i, k)*dtcld .LT. 0.) THEN
9962 CALL PUSHREAL8(q(i, k))
9964 CALL PUSHCONTROL1B(0)
9966 CALL PUSHREAL8(q(i, k))
9967 q(i, k) = q(i, k) - psdep(i, k)*dtcld
9968 CALL PUSHCONTROL1B(1)
9970 IF (qrs(i, k, 2) + psdep(i, k)*dtcld .LT. 0.) THEN
9972 CALL PUSHCONTROL1B(0)
9974 qrs(i, k, 2) = qrs(i, k, 2) + psdep(i, k)*dtcld
9975 CALL PUSHCONTROL1B(1)
9977 CALL PUSHREAL8(t(i, k))
9978 t(i, k) = t(i, k) + psdep(i, k)*dtcld*xls/cpm(i, k)
9980 !------------------------------------------------------------
9981 ! pgdep: deposition/sublimation rate of graupel [LFO 46]
9982 ! (T<T0: V->G or G->V)
9983 ! rh(i,k,2)>1.,pgdep>0: V->G, min=0, max=satdt
9984 ! rh(i,k,2)<1.,pgdep<0: G->V, min=-qg/dtcld,max=0,
9985 !------------------------------------------------------------
9987 CALL PUSHREAL8(supcol)
9988 supcol = t0c - t(i, k)
9990 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
9991 CALL PUSHREAL8ARRAY(rh(i, k, :), 3)
9992 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9994 supsat = q(i, k) - qs(i, k, 2)
9995 satdt = supsat/dtcld
9997 CALL PUSHREAL8(cpm(i, k))
9998 cpm(i, k) = CPMCAL(q(i, k))
9999 CALL PUSHREAL8(fsupcol)
10000 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
10001 IF (qrs(i, k, 3) .LT. qcrmin) THEN
10002 CALL PUSHREAL8(max3)
10004 CALL PUSHCONTROL1B(0)
10006 CALL PUSHREAL8(max3)
10007 max3 = qrs(i, k, 3)
10008 CALL PUSHCONTROL1B(1)
10010 ! call smoothif(qrs(i,k,3),0.,fqg,'q+')
10011 ! call smoothif(q (i,k ),0.,fqv,'q+')
10013 a = SQRT(den(i, k)*max3)
10014 IF (qrs(i, k, 3) .LT. qcrmin) THEN
10015 CALL PUSHREAL8(max4)
10017 CALL PUSHCONTROL1B(0)
10019 CALL PUSHREAL8(max4)
10020 max4 = qrs(i, k, 3)
10021 CALL PUSHCONTROL1B(1)
10024 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
10025 & den(i, k)**((13.+3.*bvtg)/24.)*max4**((5.+bvtg)/8.)
10027 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
10029 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
10031 e = (rh(i, k, 2)-1.)/(c+d)
10032 pgdep3 = e*(pgdep_a*a+pgdep_b*b)
10033 IF (pgdep3 .LT. 0.) THEN
10034 IF (pgdep3 .LT. -(qrs(i, k, 3)/dtcld)) THEN
10035 x5 = -(qrs(i, k, 3)/dtcld)
10036 CALL PUSHCONTROL1B(0)
10039 CALL PUSHCONTROL1B(1)
10041 IF (x5 .GT. 0.) THEN
10043 CALL PUSHCONTROL2B(1)
10046 CALL PUSHCONTROL2B(0)
10049 IF (pgdep3 .GT. satdt) THEN
10051 CALL PUSHCONTROL1B(0)
10054 CALL PUSHCONTROL1B(1)
10056 IF (x6 .LT. 0.) THEN
10058 CALL PUSHCONTROL2B(3)
10061 CALL PUSHCONTROL2B(2)
10064 CALL PUSHREAL8(pgdep(i, k))
10065 pgdep(i, k) = fsupcol*pgdep(i, k)
10066 IF (pgdep(i, k) .GE. 0.) THEN
10069 abs2 = -pgdep(i, k)
10071 IF (abs2 .LT. qmin/dtcld) THEN
10073 CALL PUSHCONTROL1B(1)
10075 CALL PUSHCONTROL1B(0)
10077 IF (q(i, k) - pgdep(i, k)*dtcld .LT. 0.) THEN
10078 CALL PUSHREAL8(q(i, k))
10080 CALL PUSHCONTROL1B(0)
10082 CALL PUSHREAL8(q(i, k))
10083 q(i, k) = q(i, k) - pgdep(i, k)*dtcld
10084 CALL PUSHCONTROL1B(1)
10086 IF (qrs(i, k, 3) + pgdep(i, k)*dtcld .LT. 0.) THEN
10088 CALL PUSHCONTROL1B(0)
10090 qrs(i, k, 3) = qrs(i, k, 3) + pgdep(i, k)*dtcld
10091 CALL PUSHCONTROL1B(1)
10093 CALL PUSHREAL8(t(i, k))
10094 t(i, k) = t(i, k) + pgdep(i, k)*dtcld*xls/cpm(i, k)
10095 !-------------------------------------------------------------
10096 ! pigen: generation(nucleation) of ice from vapor [HDC 7-8]
10097 ! (T<T0: V->I) min=0,max=min(roqi0/den(i,k)-max(qci(i,k,2),0.))/dtcld,satdt)
10098 !-------------------------------------------------------------
10100 CALL PUSHREAL8(supcol)
10101 supcol = t0c - t(i, k)
10102 CALL PUSHREAL8(cpm(i, k))
10103 cpm(i, k) = CPMCAL(q(i, k))
10105 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
10106 CALL PUSHREAL8ARRAY(rh(i, k, :), 3)
10107 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
10109 supsat = q(i, k) - qs(i, k, 2)
10110 satdt = supsat/dtcld
10111 CALL PUSHREAL8(fsupsat)
10112 CALL SMOOTHIF(supsat, 0., fsupsat, 'q+')
10113 CALL PUSHREAL8(fsupcol)
10114 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
10115 CALL PUSHREAL8(xni0)
10116 xni0 = 1.e3*EXP(0.1*supcol)
10117 roqi0 = 4.92e-11*xni0**1.33
10118 IF (qci(i, k, 2) .LT. 0.) THEN
10119 CALL PUSHCONTROL1B(0)
10122 max11 = qci(i, k, 2)
10123 CALL PUSHCONTROL1B(1)
10125 x7 = (roqi0/den(i, k)-max11)/dtcld
10126 IF (x7 .GT. satdt) THEN
10128 CALL PUSHCONTROL1B(0)
10131 CALL PUSHCONTROL1B(1)
10133 IF (pigen0 .LT. 0.) THEN
10135 CALL PUSHCONTROL1B(0)
10137 pigen(i, k) = pigen0
10138 CALL PUSHCONTROL1B(1)
10140 CALL PUSHREAL8(pigen(i, k))
10141 pigen(i, k) = fsupcol*fsupsat*pigen(i, k)
10142 IF (pigen(i, k) .GE. 0.) THEN
10145 abs3 = -pigen(i, k)
10147 IF (abs3 .LT. qmin/dtcld) THEN
10149 CALL PUSHCONTROL1B(1)
10151 CALL PUSHCONTROL1B(0)
10153 IF (q(i, k) - pigen(i, k)*dtcld .LT. 0.) THEN
10154 CALL PUSHREAL8(q(i, k))
10156 CALL PUSHCONTROL1B(0)
10158 CALL PUSHREAL8(q(i, k))
10159 q(i, k) = q(i, k) - pigen(i, k)*dtcld
10160 CALL PUSHCONTROL1B(1)
10162 IF (qci(i, k, 2) + pigen(i, k)*dtcld .LT. 0.) THEN
10164 CALL PUSHCONTROL1B(0)
10166 qci(i, k, 2) = qci(i, k, 2) + pigen(i, k)*dtcld
10167 CALL PUSHCONTROL1B(1)
10169 CALL PUSHREAL8(t(i, k))
10170 t(i, k) = t(i, k) + pigen(i, k)*dtcld*xls/cpm(i, k)
10172 !------------------------------------------------------------
10173 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
10174 ! (T<T0: I->S) psaut>0, min=0,max=(qci(i,k,2)-qimax)/dtcld
10175 !-------------------------------------------------------------
10177 CALL PUSHREAL8(supcol)
10178 supcol = t0c - t(i, k)
10179 CALL PUSHREAL8(fsupcol)
10180 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
10181 ! call smoothif(qci(i,k,2),0.,fqi,'q+')
10182 qimax = roqimax/den(i, k)
10183 IF (0. .LT. (qci(i, k, 2)-qimax)/dtcld) THEN
10184 psaut(i, k) = (qci(i, k, 2)-qimax)/dtcld
10185 CALL PUSHCONTROL1B(0)
10188 CALL PUSHCONTROL1B(1)
10190 CALL PUSHREAL8(psaut(i, k))
10191 psaut(i, k) = fsupcol*psaut(i, k)
10192 IF (psaut(i, k) .GE. 0.) THEN
10195 abs4 = -psaut(i, k)
10197 IF (abs4 .LT. qmin/dtcld) THEN
10199 CALL PUSHCONTROL1B(1)
10201 CALL PUSHCONTROL1B(0)
10203 IF (qci(i, k, 2) - psaut(i, k)*dtcld .LT. 0.) THEN
10204 CALL PUSHCONTROL1B(0)
10206 CALL PUSHCONTROL1B(1)
10208 IF (qrs(i, k, 2) + psaut(i, k)*dtcld .LT. 0.) THEN
10210 CALL PUSHCONTROL1B(0)
10212 qrs(i, k, 2) = qrs(i, k, 2) + psaut(i, k)*dtcld
10213 CALL PUSHCONTROL1B(1)
10216 !-------------------------------------------------------------
10217 ! pgaut: conversion(aggregation) of snow to graupel [LFO 37]
10218 ! (T<T0: S->G) pgaut>0 min=0.,max=qrs(i,k,2)/dtcld
10219 !-------------------------------------------------------------
10221 ! supcol = t0c-t(i,k) ! not change
10222 ! call smoothif(supcol,0.,fsupcol,'t0')
10223 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
10224 CALL PUSHREAL8(alpha2)
10225 alpha2 = 1.e-3*EXP(0.09*(-supcol))
10226 IF (0. .LT. alpha2*(qrs(i, k, 2)-qs0)) THEN
10227 x8 = alpha2*(qrs(i, k, 2)-qs0)
10228 CALL PUSHCONTROL1B(0)
10231 CALL PUSHCONTROL1B(1)
10233 IF (x8 .GT. qrs(i, k, 2)/dtcld) THEN
10234 pgaut(i, k) = qrs(i, k, 2)/dtcld
10235 CALL PUSHCONTROL1B(0)
10238 CALL PUSHCONTROL1B(1)
10240 CALL PUSHREAL8(pgaut(i, k))
10241 pgaut(i, k) = fsupcol*pgaut(i, k)
10242 IF (pgaut(i, k) .GE. 0.) THEN
10245 abs5 = -pgaut(i, k)
10247 IF (abs5 .LT. qmin/dtcld) THEN
10249 CALL PUSHCONTROL1B(1)
10251 CALL PUSHCONTROL1B(0)
10253 IF (qrs(i, k, 2) - pgaut(i, k)*dtcld .LT. 0.) THEN
10254 CALL PUSHREAL8(qrs(i, k, 2))
10256 CALL PUSHCONTROL1B(0)
10258 CALL PUSHREAL8(qrs(i, k, 2))
10259 qrs(i, k, 2) = qrs(i, k, 2) - pgaut(i, k)*dtcld
10260 CALL PUSHCONTROL1B(1)
10262 IF (qrs(i, k, 3) + pgaut(i, k)*dtcld .LT. 0.) THEN
10263 CALL PUSHREAL8(qrs(i, k, 3))
10265 CALL PUSHCONTROL1B(0)
10267 CALL PUSHREAL8(qrs(i, k, 3))
10268 qrs(i, k, 3) = qrs(i, k, 3) + pgaut(i, k)*dtcld
10269 CALL PUSHCONTROL1B(1)
10272 !-------------------------------------------------------------
10273 ! psevp: Evaporation of melting snow [RH83 A27]
10274 ! (T>=T0: S->V) rh<1., psevp<0, min=-qrs(i,k,2)/dtcld, max=0.
10275 !-------------------------------------------------------------
10276 ! supcol = t0c-t(i,k) ! not change
10278 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
10279 CALL PUSHREAL8ARRAY(rh(i, k, :), 3)
10280 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
10282 xl(i, k) = XLCAL(t(i, k))
10283 CALL PUSHREAL8(cpm(i, k))
10284 cpm(i, k) = CPMCAL(q(i, k))
10285 CALL PUSHREAL8(ft0)
10286 CALL SMOOTHIF(t(i, k), t0c, ft0, 't+')
10287 IF (90. .GT. t0c - t(i, k)) THEN
10289 CALL PUSHCONTROL1B(0)
10291 CALL PUSHCONTROL1B(1)
10294 IF (0. .LT. y3) THEN
10295 CALL PUSHREAL8(max5)
10297 CALL PUSHCONTROL1B(1)
10299 CALL PUSHREAL8(max5)
10301 CALL PUSHCONTROL1B(0)
10303 IF (qrs(i, k, 2) .LT. qcrmin) THEN
10304 CALL PUSHREAL8(max12)
10306 CALL PUSHCONTROL1B(0)
10308 CALL PUSHREAL8(max12)
10309 max12 = qrs(i, k, 2)
10310 CALL PUSHCONTROL1B(1)
10313 a = EXP(alpha*max5/2.)*SQRT(den(i, k)*max12)
10314 IF (90. .GT. t0c - t(i, k)) THEN
10316 CALL PUSHCONTROL1B(0)
10318 CALL PUSHCONTROL1B(1)
10321 IF (0. .LT. y4) THEN
10322 CALL PUSHREAL8(max6)
10324 CALL PUSHCONTROL1B(1)
10326 CALL PUSHREAL8(max6)
10328 CALL PUSHCONTROL1B(0)
10330 IF (qrs(i, k, 2) .LT. qcrmin) THEN
10331 CALL PUSHREAL8(max13)
10333 CALL PUSHCONTROL1B(0)
10335 CALL PUSHREAL8(max13)
10336 max13 = qrs(i, k, 2)
10337 CALL PUSHCONTROL1B(1)
10340 b = EXP((3.-bvts)*alpha*max6/8.)*(t(i, k)+120.)**(1./6.)/t(i, k)&
10341 & **(5.12/6.)*p(i, k)**(1./3.)*den(i, k)**((13.+3.*bvts)/24.)*&
10342 & max13**((5.+bvts)/8.)
10344 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
10347 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
10349 e = (rh(i, k, 1)-1.)/(c+d)
10350 psevp0 = e*(psevp_a*a+psevp_b*b)
10351 IF (psevp0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
10352 x9 = -(qrs(i, k, 2)/dtcld)
10353 CALL PUSHCONTROL1B(0)
10356 CALL PUSHCONTROL1B(1)
10358 IF (x9 .GT. 0.) THEN
10360 CALL PUSHCONTROL1B(0)
10363 CALL PUSHCONTROL1B(1)
10365 CALL PUSHREAL8(psevp(i, k))
10366 psevp(i, k) = ft0*psevp(i, k)
10367 IF (psevp(i, k) .GE. 0.) THEN
10370 abs6 = -psevp(i, k)
10372 IF (abs6 .LT. qmin/dtcld) THEN
10374 CALL PUSHCONTROL1B(1)
10376 CALL PUSHCONTROL1B(0)
10378 IF (q(i, k) - psevp(i, k)*dtcld .LT. 0.) THEN
10379 CALL PUSHREAL8(q(i, k))
10381 CALL PUSHCONTROL1B(0)
10383 CALL PUSHREAL8(q(i, k))
10384 q(i, k) = q(i, k) - psevp(i, k)*dtcld
10385 CALL PUSHCONTROL1B(1)
10387 IF (qrs(i, k, 2) + psevp(i, k)*dtcld .LT. 0.) THEN
10388 CALL PUSHREAL8(qrs(i, k, 2))
10390 CALL PUSHCONTROL1B(0)
10392 CALL PUSHREAL8(qrs(i, k, 2))
10393 qrs(i, k, 2) = qrs(i, k, 2) + psevp(i, k)*dtcld
10394 CALL PUSHCONTROL1B(1)
10396 CALL PUSHREAL8(t(i, k))
10397 t(i, k) = t(i, k) + psevp(i, k)*dtcld*xls/cpm(i, k)
10399 !-------------------------------------------------------------
10400 ! pgevp: Evaporation of melting graupel [RH84 A19]
10401 ! (T>=T0: G->V) rh<1., pgevp<0, min=-qrs(i,k,3)/dtcld, max=0.
10402 !-------------------------------------------------------------
10404 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
10405 CALL PUSHREAL8ARRAY(rh(i, k, :), 3)
10406 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
10408 CALL PUSHREAL8(xl(i, k))
10409 xl(i, k) = XLCAL(t(i, k))
10410 CALL PUSHREAL8(cpm(i, k))
10411 cpm(i, k) = CPMCAL(q(i, k))
10412 CALL PUSHREAL8(ft0)
10413 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
10414 IF (qrs(i, k, 3) .LT. qcrmin) THEN
10415 CALL PUSHREAL8(max7)
10417 CALL PUSHCONTROL1B(0)
10419 CALL PUSHREAL8(max7)
10420 max7 = qrs(i, k, 3)
10421 CALL PUSHCONTROL1B(1)
10424 a = SQRT(den(i, k)*max7)
10425 IF (qrs(i, k, 3) .LT. qcrmin) THEN
10426 CALL PUSHREAL8(max8)
10428 CALL PUSHCONTROL1B(0)
10430 CALL PUSHREAL8(max8)
10431 max8 = qrs(i, k, 3)
10432 CALL PUSHCONTROL1B(1)
10435 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
10436 & den(i, k)**((13.+3.*bvtg)/24.)*max8**((5.+bvtg)/8.)
10438 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
10441 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
10443 e = (rh(i, k, 1)-1.)/(c+d)
10444 pgevp0 = e*(pgevp_a*a+pgevp_b*b)
10445 IF (pgevp0 .LT. -(qrs(i, k, 3)/dtcld)) THEN
10446 x10 = -(qrs(i, k, 3)/dtcld)
10447 CALL PUSHCONTROL1B(0)
10450 CALL PUSHCONTROL1B(1)
10452 IF (x10 .GT. 0.) THEN
10454 CALL PUSHCONTROL1B(0)
10457 CALL PUSHCONTROL1B(1)
10459 CALL PUSHREAL8(pgevp(i, k))
10460 pgevp(i, k) = ft0*pgevp(i, k)
10461 IF (pgevp(i, k) .GE. 0.) THEN
10464 abs7 = -pgevp(i, k)
10466 IF (abs7 .LT. qmin/dtcld) THEN
10468 CALL PUSHCONTROL1B(1)
10470 CALL PUSHCONTROL1B(0)
10472 IF (q(i, k) - pgevp(i, k)*dtcld .LT. 0.) THEN
10473 CALL PUSHCONTROL1B(0)
10475 CALL PUSHCONTROL1B(1)
10477 IF (qrs(i, k, 3) + pgevp(i, k)*dtcld .LT. 0.) THEN
10478 CALL PUSHCONTROL1B(0)
10480 CALL PUSHCONTROL1B(1)
10488 a_temp3 = dtcld*xls*a_t(i, k)/cpm(i, k)
10489 a_pgevp(i, k) = a_temp3
10490 a_cpm(i, k) = a_cpm(i, k) - pgevp(i, k)*a_temp3/cpm(i, k)
10491 CALL POPCONTROL1B(branch)
10492 IF (branch .EQ. 0) THEN
10493 a_qrs(i, k, 3) = 0.0_8
10495 a_pgevp(i, k) = a_pgevp(i, k) + dtcld*a_qrs(i, k, 3)
10497 CALL POPCONTROL1B(branch)
10498 IF (branch .EQ. 0) THEN
10501 a_pgevp(i, k) = a_pgevp(i, k) - dtcld*a_q(i, k)
10503 CALL POPCONTROL1B(branch)
10504 IF (branch .NE. 0) a_pgevp(i, k) = 0.0_8
10505 CALL POPREAL8(pgevp(i, k))
10506 a_ft0 = pgevp(i, k)*a_pgevp(i, k)
10507 a_pgevp(i, k) = ft0*a_pgevp(i, k)
10508 CALL POPCONTROL1B(branch)
10509 IF (branch .EQ. 0) THEN
10510 a_pgevp(i, k) = 0.0_8
10513 a_x10 = a_pgevp(i, k)
10514 a_pgevp(i, k) = 0.0_8
10516 CALL POPCONTROL1B(branch)
10517 IF (branch .EQ. 0) THEN
10518 a_qrs(i, k, 3) = a_qrs(i, k, 3) - a_x10/dtcld
10523 a_e = (pgevp_a*a+pgevp_b*b)*a_pgevp0
10524 a_a = pgevp_a*e*a_pgevp0
10525 a_b = pgevp_b*e*a_pgevp0
10527 a_temp3 = a_e/(c+d)
10528 a_rh(i, k, 1) = a_rh(i, k, 1) + a_temp3
10529 a_temp5 = -((rh(i, k, 1)-1.)*a_temp3/(c+d))
10533 temp15 = t(i, k)**1.81
10534 temp14 = temp15*qs(i, k, 1)
10535 a_temp6 = diffac_b*a_d/temp14
10536 a_temp5 = -(p(i, k)*a_temp6/temp14)
10537 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 1)*a_temp5
10538 a_qs(i, k, 1) = a_qs(i, k, 1) + temp15*a_temp5
10540 temp15 = rv*t(i, k)**3.5
10541 temp13 = den(i, k)*(t(i, k)+120.)
10542 temp12 = xl(i, k)*xl(i, k)
10543 a_temp5 = diffac_a*a_c/temp15
10544 a_xl(i, k) = a_xl(i, k) + 2*xl(i, k)*temp13*a_temp5
10545 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*temp12*a_temp5
10546 a_t(i, k) = a_t(i, k) + (den(i, k)*temp12-3.5*t(i, k)**2.5*rv*&
10547 & temp12*temp13/temp15)*a_temp5
10549 temp15 = (3.*bvtg+13.)/24.
10550 temp14 = den(i, k)**temp15
10551 temp13 = (bvtg+5.)/8.
10552 temp12 = max8**temp13
10554 temp10 = p(i, k)**temp11
10555 temp9 = temp10*temp12
10557 temp7 = t(i, k)**temp8
10559 temp6 = (t(i, k)+120.)**temp5/temp7
10560 a_temp7 = temp9*temp14*a_b/temp7
10561 a_temp8 = temp6*a_b
10562 IF (p(i, k) .LE. 0.0_8 .AND. (temp11 .EQ. 0.0_8 .OR. temp11 .NE.&
10563 & INT(temp11))) THEN
10564 a_p(i, k) = a_p(i, k) + a_temp6
10566 a_p(i, k) = a_p(i, k) + a_temp6 + temp11*p(i, k)**(temp11-1)*&
10567 & temp12*temp14*a_temp8
10569 IF (max8 .LE. 0.0_8 .AND. (temp13 .EQ. 0.0_8 .OR. temp13 .NE. &
10570 & INT(temp13))) THEN
10573 a_max8 = temp13*max8**(temp13-1)*temp10*temp14*a_temp8
10575 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp15 .EQ. 0.0_8 .OR. &
10576 & temp15 .NE. INT(temp15)))) a_den(i, k) = a_den(i, k) + &
10577 & temp15*den(i, k)**(temp15-1)*temp9*a_temp8
10578 IF (.NOT.(t(i, k) + 120. .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR.&
10579 & temp5 .NE. INT(temp5)))) a_t(i, k) = a_t(i, k) + temp5*(t(i&
10580 & , k)+120.)**(temp5-1)*a_temp7
10581 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 &
10582 & .NE. INT(temp8)))) a_t(i, k) = a_t(i, k) - temp8*t(i, k)**(&
10583 & temp8-1)*temp6*a_temp7
10584 CALL POPCONTROL1B(branch)
10585 IF (branch .EQ. 0) THEN
10586 CALL POPREAL8(max8)
10588 CALL POPREAL8(max8)
10589 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max8
10592 IF (den(i, k)*max7 .EQ. 0.0_8) THEN
10595 a_temp3 = a_a/(2.0*SQRT(den(i, k)*max7))
10597 a_den(i, k) = a_den(i, k) + max7*a_temp3
10598 a_max7 = den(i, k)*a_temp3
10599 CALL POPCONTROL1B(branch)
10600 IF (branch .EQ. 0) THEN
10601 CALL POPREAL8(max7)
10603 CALL POPREAL8(max7)
10604 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max7
10607 CALL A_SMOOTHIF(t(i, k), a_t(i, k), t0c, ft0, a_ft0, 't0')
10608 CALL POPREAL8(cpm(i, k))
10609 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
10610 a_cpm(i, k) = 0.0_8
10611 CALL POPREAL8(xl(i, k))
10612 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
10614 CALL POPREAL8ARRAY(rh(i, k, :), 3)
10615 CALL POPREAL8ARRAY(qs(i, k, :), 3)
10616 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
10617 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
10619 CALL POPREAL8(t(i, k))
10620 a_temp3 = dtcld*xls*a_t(i, k)/cpm(i, k)
10621 a_psevp(i, k) = a_temp3
10622 a_cpm(i, k) = a_cpm(i, k) - psevp(i, k)*a_temp3/cpm(i, k)
10623 CALL POPCONTROL1B(branch)
10624 IF (branch .EQ. 0) THEN
10625 CALL POPREAL8(qrs(i, k, 2))
10626 a_qrs(i, k, 2) = 0.0_8
10628 CALL POPREAL8(qrs(i, k, 2))
10629 a_psevp(i, k) = a_psevp(i, k) + dtcld*a_qrs(i, k, 2)
10631 CALL POPCONTROL1B(branch)
10632 IF (branch .EQ. 0) THEN
10633 CALL POPREAL8(q(i, k))
10636 CALL POPREAL8(q(i, k))
10637 a_psevp(i, k) = a_psevp(i, k) - dtcld*a_q(i, k)
10639 CALL POPCONTROL1B(branch)
10640 IF (branch .NE. 0) a_psevp(i, k) = 0.0_8
10641 CALL POPREAL8(psevp(i, k))
10642 a_ft0 = psevp(i, k)*a_psevp(i, k)
10643 a_psevp(i, k) = ft0*a_psevp(i, k)
10644 CALL POPCONTROL1B(branch)
10645 IF (branch .EQ. 0) THEN
10646 a_psevp(i, k) = 0.0_8
10649 a_x9 = a_psevp(i, k)
10650 a_psevp(i, k) = 0.0_8
10652 CALL POPCONTROL1B(branch)
10653 IF (branch .EQ. 0) THEN
10654 a_qrs(i, k, 2) = a_qrs(i, k, 2) - a_x9/dtcld
10659 a_e = (psevp_a*a+psevp_b*b)*a_psevp0
10660 a_a = psevp_a*e*a_psevp0
10661 a_b = psevp_b*e*a_psevp0
10663 a_temp3 = a_e/(c+d)
10664 a_rh(i, k, 1) = a_rh(i, k, 1) + a_temp3
10665 a_temp5 = -((rh(i, k, 1)-1.)*a_temp3/(c+d))
10669 temp15 = t(i, k)**1.81
10670 temp14 = temp15*qs(i, k, 1)
10671 a_temp6 = diffac_b*a_d/temp14
10672 a_temp5 = -(p(i, k)*a_temp6/temp14)
10673 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 1)*a_temp5
10674 a_qs(i, k, 1) = a_qs(i, k, 1) + temp15*a_temp5
10676 temp15 = rv*t(i, k)**3.5
10677 temp13 = den(i, k)*(t(i, k)+120.)
10678 temp12 = xl(i, k)*xl(i, k)
10679 a_temp5 = diffac_a*a_c/temp15
10680 a_xl(i, k) = a_xl(i, k) + 2*xl(i, k)*temp13*a_temp5
10681 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*temp12*a_temp5
10682 a_t(i, k) = a_t(i, k) + (den(i, k)*temp12-3.5*t(i, k)**2.5*rv*&
10683 & temp12*temp13/temp15)*a_temp5
10685 temp15 = (bvts+5.)/8.
10686 temp14 = max13**temp15
10688 temp12 = p(i, k)**temp13
10689 temp11 = temp12*temp14
10691 temp9 = t(i, k)**temp10
10693 temp7 = (t(i, k)+120.)**temp8/temp9
10694 temp5 = (3.*bvts+13.)/24.
10695 temp4 = den(i, k)**temp5
10696 temp3 = (-bvts+3.)*alpha*max6/8.
10698 a_temp7 = temp7*temp11*a_b
10699 a_temp1 = temp2*temp4*a_b
10700 IF (p(i, k) .LE. 0.0_8 .AND. (temp13 .EQ. 0.0_8 .OR. temp13 .NE.&
10701 & INT(temp13))) THEN
10702 a_p(i, k) = a_p(i, k) + a_temp6
10704 a_p(i, k) = a_p(i, k) + a_temp6 + temp13*p(i, k)**(temp13-1)*&
10705 & temp14*temp7*a_temp1
10707 a_temp9 = temp11*a_temp1/temp9
10708 IF (max13 .LE. 0.0_8 .AND. (temp15 .EQ. 0.0_8 .OR. temp15 .NE. &
10709 & INT(temp15))) THEN
10712 a_max13 = temp15*max13**(temp15-1)*temp12*temp7*a_temp1
10714 IF (.NOT.(t(i, k) + 120. .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR.&
10715 & temp8 .NE. INT(temp8)))) a_t(i, k) = a_t(i, k) + temp8*(t(i&
10716 & , k)+120.)**(temp8-1)*a_temp9
10717 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp10 .EQ. 0.0_8 .OR. &
10718 & temp10 .NE. INT(temp10)))) a_t(i, k) = a_t(i, k) - temp10*t(&
10719 & i, k)**(temp10-1)*temp7*a_temp9
10720 a_max6 = (3.-bvts)*alpha*EXP(temp3)*temp4*a_temp7/8.
10721 IF (.NOT.(den(i, k) .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR. &
10722 & temp5 .NE. INT(temp5)))) a_den(i, k) = a_den(i, k) + temp5*&
10723 & den(i, k)**(temp5-1)*temp2*a_temp7
10724 CALL POPCONTROL1B(branch)
10725 IF (branch .EQ. 0) THEN
10726 CALL POPREAL8(max13)
10728 CALL POPREAL8(max13)
10729 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max13
10731 CALL POPCONTROL1B(branch)
10732 IF (branch .EQ. 0) THEN
10733 CALL POPREAL8(max6)
10736 CALL POPREAL8(max6)
10739 CALL POPCONTROL1B(branch)
10740 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y4
10742 temp15 = den(i, k)*max12
10743 temp14 = SQRT(temp15)
10744 temp13 = alpha*max5/2.
10745 a_max5 = alpha*EXP(temp13)*temp14*a_a/2.
10746 IF (temp15 .EQ. 0.0_8) THEN
10749 a_temp3 = EXP(temp13)*a_a/(2.0*temp14)
10751 a_den(i, k) = a_den(i, k) + max12*a_temp3
10752 a_max12 = den(i, k)*a_temp3
10753 CALL POPCONTROL1B(branch)
10754 IF (branch .EQ. 0) THEN
10755 CALL POPREAL8(max12)
10757 CALL POPREAL8(max12)
10758 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max12
10760 CALL POPCONTROL1B(branch)
10761 IF (branch .EQ. 0) THEN
10762 CALL POPREAL8(max5)
10765 CALL POPREAL8(max5)
10768 CALL POPCONTROL1B(branch)
10769 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y3
10771 CALL A_SMOOTHIF(t(i, k), a_t(i, k), t0c, ft0, a_ft0, 't+')
10772 CALL POPREAL8(cpm(i, k))
10773 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
10774 a_cpm(i, k) = 0.0_8
10775 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
10777 CALL POPREAL8ARRAY(rh(i, k, :), 3)
10778 CALL POPREAL8ARRAY(qs(i, k, :), 3)
10779 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
10780 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
10782 a_pgaut(i, k) = 0.0_8
10783 CALL POPCONTROL1B(branch)
10784 IF (branch .EQ. 0) THEN
10785 CALL POPREAL8(qrs(i, k, 3))
10786 a_qrs(i, k, 3) = 0.0_8
10788 CALL POPREAL8(qrs(i, k, 3))
10789 a_pgaut(i, k) = a_pgaut(i, k) + dtcld*a_qrs(i, k, 3)
10791 CALL POPCONTROL1B(branch)
10792 IF (branch .EQ. 0) THEN
10793 CALL POPREAL8(qrs(i, k, 2))
10794 a_qrs(i, k, 2) = 0.0_8
10796 CALL POPREAL8(qrs(i, k, 2))
10797 a_pgaut(i, k) = a_pgaut(i, k) - dtcld*a_qrs(i, k, 2)
10799 CALL POPCONTROL1B(branch)
10800 IF (branch .NE. 0) a_pgaut(i, k) = 0.0_8
10801 CALL POPREAL8(pgaut(i, k))
10802 a_fsupcol = pgaut(i, k)*a_pgaut(i, k)
10803 a_pgaut(i, k) = fsupcol*a_pgaut(i, k)
10804 CALL POPCONTROL1B(branch)
10805 IF (branch .EQ. 0) THEN
10806 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_pgaut(i, k)/dtcld
10807 a_pgaut(i, k) = 0.0_8
10810 a_x8 = a_pgaut(i, k)
10811 a_pgaut(i, k) = 0.0_8
10813 CALL POPCONTROL1B(branch)
10814 IF (branch .EQ. 0) THEN
10815 a_alpha2 = (qrs(i, k, 2)-qs0)*a_x8
10816 a_qrs(i, k, 2) = a_qrs(i, k, 2) + alpha2*a_x8
10820 CALL POPREAL8(alpha2)
10821 a_supcol = -(0.09*EXP(-(0.09*supcol))*1.e-3*a_alpha2)
10822 a_psaut(i, k) = 0.0_8
10823 CALL POPCONTROL1B(branch)
10824 IF (branch .EQ. 0) THEN
10825 a_qrs(i, k, 2) = 0.0_8
10827 a_psaut(i, k) = a_psaut(i, k) + dtcld*a_qrs(i, k, 2)
10829 CALL POPCONTROL1B(branch)
10830 IF (branch .EQ. 0) THEN
10831 a_qci(i, k, 2) = 0.0_8
10833 a_psaut(i, k) = a_psaut(i, k) - dtcld*a_qci(i, k, 2)
10835 CALL POPCONTROL1B(branch)
10836 IF (branch .NE. 0) a_psaut(i, k) = 0.0_8
10837 CALL POPREAL8(psaut(i, k))
10838 a_fsupcol = a_fsupcol + psaut(i, k)*a_psaut(i, k)
10839 a_psaut(i, k) = fsupcol*a_psaut(i, k)
10840 CALL POPCONTROL1B(branch)
10841 IF (branch .EQ. 0) THEN
10842 a_qci(i, k, 2) = a_qci(i, k, 2) + a_psaut(i, k)/dtcld
10843 a_qimax = -(a_psaut(i, k)/dtcld)
10844 a_psaut(i, k) = 0.0_8
10846 a_psaut(i, k) = 0.0_8
10849 a_den(i, k) = a_den(i, k) - roqimax*a_qimax/den(i, k)**2
10850 CALL POPREAL8(fsupcol)
10851 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't+')
10852 CALL POPREAL8(supcol)
10853 a_t(i, k) = a_t(i, k) - a_supcol
10854 CALL POPREAL8(t(i, k))
10855 a_temp3 = dtcld*xls*a_t(i, k)/cpm(i, k)
10856 a_pigen(i, k) = a_temp3
10857 a_cpm(i, k) = a_cpm(i, k) - pigen(i, k)*a_temp3/cpm(i, k)
10858 CALL POPCONTROL1B(branch)
10859 IF (branch .EQ. 0) THEN
10860 a_qci(i, k, 2) = 0.0_8
10862 a_pigen(i, k) = a_pigen(i, k) + dtcld*a_qci(i, k, 2)
10864 CALL POPCONTROL1B(branch)
10865 IF (branch .EQ. 0) THEN
10866 CALL POPREAL8(q(i, k))
10869 CALL POPREAL8(q(i, k))
10870 a_pigen(i, k) = a_pigen(i, k) - dtcld*a_q(i, k)
10872 CALL POPCONTROL1B(branch)
10873 IF (branch .NE. 0) a_pigen(i, k) = 0.0_8
10874 CALL POPREAL8(pigen(i, k))
10875 a_temp3 = pigen(i, k)*a_pigen(i, k)
10876 a_pigen(i, k) = fsupcol*fsupsat*a_pigen(i, k)
10877 a_fsupcol = fsupsat*a_temp3
10878 a_fsupsat = fsupcol*a_temp3
10879 CALL POPCONTROL1B(branch)
10880 IF (branch .EQ. 0) THEN
10881 a_pigen(i, k) = 0.0_8
10884 a_pigen0 = a_pigen(i, k)
10885 a_pigen(i, k) = 0.0_8
10887 CALL POPCONTROL1B(branch)
10888 IF (branch .EQ. 0) THEN
10895 roqi0 = 4.92e-11*xni0**1.33
10896 a_temp3 = a_x7/(den(i, k)*dtcld)
10897 a_max11 = -(a_x7/dtcld)
10899 a_den(i, k) = a_den(i, k) - roqi0*a_temp3/den(i, k)
10900 CALL POPCONTROL1B(branch)
10901 IF (branch .NE. 0) a_qci(i, k, 2) = a_qci(i, k, 2) + a_max11
10902 a_xni0 = 1.33*xni0**0.33*4.92e-11*a_roqi0
10903 CALL POPREAL8(xni0)
10904 a_supcol = 0.1*EXP(0.1*supcol)*1.e3*a_xni0
10905 CALL POPREAL8(fsupcol)
10906 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't+')
10907 CALL POPREAL8(fsupsat)
10909 CALL A_SMOOTHIF(supsat, a_supsat, 0., fsupsat, a_fsupsat, 'q+')
10910 a_supsat = a_supsat + a_satdt/dtcld
10911 a_q(i, k) = a_q(i, k) + a_supsat
10912 a_qs(i, k, 2) = a_qs(i, k, 2) - a_supsat
10913 CALL POPREAL8ARRAY(rh(i, k, :), 3)
10914 CALL POPREAL8ARRAY(qs(i, k, :), 3)
10915 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
10916 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
10918 CALL POPREAL8(cpm(i, k))
10919 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
10920 a_cpm(i, k) = 0.0_8
10921 CALL POPREAL8(supcol)
10922 a_t(i, k) = a_t(i, k) - a_supcol
10923 CALL POPREAL8(t(i, k))
10924 a_temp3 = dtcld*xls*a_t(i, k)/cpm(i, k)
10925 a_pgdep(i, k) = a_temp3
10926 a_cpm(i, k) = a_cpm(i, k) - pgdep(i, k)*a_temp3/cpm(i, k)
10927 CALL POPCONTROL1B(branch)
10928 IF (branch .EQ. 0) THEN
10929 a_qrs(i, k, 3) = 0.0_8
10931 a_pgdep(i, k) = a_pgdep(i, k) + dtcld*a_qrs(i, k, 3)
10933 CALL POPCONTROL1B(branch)
10934 IF (branch .EQ. 0) THEN
10935 CALL POPREAL8(q(i, k))
10938 CALL POPREAL8(q(i, k))
10939 a_pgdep(i, k) = a_pgdep(i, k) - dtcld*a_q(i, k)
10941 CALL POPCONTROL1B(branch)
10942 IF (branch .NE. 0) a_pgdep(i, k) = 0.0_8
10943 CALL POPREAL8(pgdep(i, k))
10944 a_fsupcol = pgdep(i, k)*a_pgdep(i, k)
10945 a_pgdep(i, k) = fsupcol*a_pgdep(i, k)
10946 CALL POPCONTROL2B(branch)
10947 IF (branch .LT. 2) THEN
10948 IF (branch .EQ. 0) THEN
10949 a_x5 = a_pgdep(i, k)
10950 a_pgdep(i, k) = 0.0_8
10952 a_pgdep(i, k) = 0.0_8
10955 CALL POPCONTROL1B(branch)
10956 IF (branch .EQ. 0) THEN
10957 a_qrs(i, k, 3) = a_qrs(i, k, 3) - a_x5/dtcld
10964 IF (branch .EQ. 2) THEN
10965 a_x6 = a_pgdep(i, k)
10966 a_pgdep(i, k) = 0.0_8
10968 a_pgdep(i, k) = 0.0_8
10971 CALL POPCONTROL1B(branch)
10972 IF (branch .EQ. 0) THEN
10980 a_e = (pgdep_a*a+pgdep_b*b)*a_pgdep3
10981 a_a = pgdep_a*e*a_pgdep3
10982 a_b = pgdep_b*e*a_pgdep3
10984 a_temp3 = a_e/(c+d)
10985 a_rh(i, k, 2) = a_rh(i, k, 2) + a_temp3
10986 a_temp5 = -((rh(i, k, 2)-1.)*a_temp3/(c+d))
10990 temp15 = t(i, k)**1.81
10991 temp14 = temp15*qs(i, k, 2)
10992 a_temp6 = diffac_b*a_d/temp14
10993 a_temp5 = -(p(i, k)*a_temp6/temp14)
10994 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 2)*a_temp5
10995 a_qs(i, k, 2) = a_qs(i, k, 2) + temp15*a_temp5
10997 temp15 = rv*t(i, k)**3.5
10998 a_temp5 = diffac_a*xls**2*a_c/temp15
10999 a_t(i, k) = a_t(i, k) + (den(i, k)-3.5*t(i, k)**2.5*rv*den(i, k)&
11000 & *(t(i, k)+120.)/temp15)*a_temp5
11002 temp15 = (3.*bvtg+13.)/24.
11003 temp14 = den(i, k)**temp15
11004 temp13 = (bvtg+5.)/8.
11005 temp12 = max4**temp13
11007 temp10 = p(i, k)**temp11
11008 temp9 = temp10*temp12
11010 temp7 = t(i, k)**temp8
11012 temp6 = (t(i, k)+120.)**temp5/temp7
11013 a_temp7 = temp9*temp14*a_b/temp7
11014 a_temp8 = temp6*a_b
11015 IF (p(i, k) .LE. 0.0_8 .AND. (temp11 .EQ. 0.0_8 .OR. temp11 .NE.&
11016 & INT(temp11))) THEN
11017 a_p(i, k) = a_p(i, k) + a_temp6
11019 a_p(i, k) = a_p(i, k) + a_temp6 + temp11*p(i, k)**(temp11-1)*&
11020 & temp12*temp14*a_temp8
11022 IF (den(i, k) .LE. 0.0_8 .AND. (temp15 .EQ. 0.0_8 .OR. temp15 &
11023 & .NE. INT(temp15))) THEN
11024 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*a_temp5
11026 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*a_temp5 + temp15*&
11027 & den(i, k)**(temp15-1)*temp9*a_temp8
11029 IF (max4 .LE. 0.0_8 .AND. (temp13 .EQ. 0.0_8 .OR. temp13 .NE. &
11030 & INT(temp13))) THEN
11033 a_max4 = temp13*max4**(temp13-1)*temp10*temp14*a_temp8
11035 IF (.NOT.(t(i, k) + 120. .LE. 0.0_8 .AND. (temp5 .EQ. 0.0_8 .OR.&
11036 & temp5 .NE. INT(temp5)))) a_t(i, k) = a_t(i, k) + temp5*(t(i&
11037 & , k)+120.)**(temp5-1)*a_temp7
11038 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8 &
11039 & .NE. INT(temp8)))) a_t(i, k) = a_t(i, k) - temp8*t(i, k)**(&
11040 & temp8-1)*temp6*a_temp7
11041 CALL POPCONTROL1B(branch)
11042 IF (branch .EQ. 0) THEN
11043 CALL POPREAL8(max4)
11045 CALL POPREAL8(max4)
11046 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max4
11049 IF (den(i, k)*max3 .EQ. 0.0_8) THEN
11052 a_temp3 = a_a/(2.0*SQRT(den(i, k)*max3))
11054 a_den(i, k) = a_den(i, k) + max3*a_temp3
11055 a_max3 = den(i, k)*a_temp3
11056 CALL POPCONTROL1B(branch)
11057 IF (branch .EQ. 0) THEN
11058 CALL POPREAL8(max3)
11060 CALL POPREAL8(max3)
11061 a_qrs(i, k, 3) = a_qrs(i, k, 3) + a_max3
11063 CALL POPREAL8(fsupcol)
11065 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't+')
11066 CALL POPREAL8(cpm(i, k))
11067 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
11068 a_cpm(i, k) = 0.0_8
11069 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
11071 a_supsat = a_satdt/dtcld
11072 a_q(i, k) = a_q(i, k) + a_supsat
11073 a_qs(i, k, 2) = a_qs(i, k, 2) - a_supsat
11074 CALL POPREAL8ARRAY(rh(i, k, :), 3)
11075 CALL POPREAL8ARRAY(qs(i, k, :), 3)
11076 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
11077 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
11079 CALL POPREAL8(supcol)
11080 a_t(i, k) = a_t(i, k) - a_supcol
11081 CALL POPREAL8(t(i, k))
11082 a_temp3 = dtcld*xls*a_t(i, k)/cpm(i, k)
11083 a_psdep(i, k) = a_temp3
11084 a_cpm(i, k) = a_cpm(i, k) - psdep(i, k)*a_temp3/cpm(i, k)
11085 CALL POPCONTROL1B(branch)
11086 IF (branch .EQ. 0) THEN
11087 a_qrs(i, k, 2) = 0.0_8
11089 a_psdep(i, k) = a_psdep(i, k) + dtcld*a_qrs(i, k, 2)
11091 CALL POPCONTROL1B(branch)
11092 IF (branch .EQ. 0) THEN
11093 CALL POPREAL8(q(i, k))
11096 CALL POPREAL8(q(i, k))
11097 a_psdep(i, k) = a_psdep(i, k) - dtcld*a_q(i, k)
11099 CALL POPCONTROL1B(branch)
11100 IF (branch .NE. 0) a_psdep(i, k) = 0.0_8
11101 CALL POPREAL8(psdep(i, k))
11102 a_fsupcol = psdep(i, k)*a_psdep(i, k)
11103 a_psdep(i, k) = fsupcol*a_psdep(i, k)
11104 CALL POPCONTROL2B(branch)
11105 IF (branch .LT. 2) THEN
11106 IF (branch .EQ. 0) THEN
11107 a_x3 = a_psdep(i, k)
11108 a_psdep(i, k) = 0.0_8
11110 a_psdep(i, k) = 0.0_8
11113 CALL POPCONTROL1B(branch)
11114 IF (branch .EQ. 0) THEN
11115 a_qrs(i, k, 2) = a_qrs(i, k, 2) - a_x3/dtcld
11122 IF (branch .EQ. 2) THEN
11123 a_x4 = a_psdep(i, k)
11124 a_psdep(i, k) = 0.0_8
11126 a_psdep(i, k) = 0.0_8
11129 CALL POPCONTROL1B(branch)
11130 IF (branch .EQ. 0) THEN
11138 a_e = (psdep_a*a+psdep_b*b)*a_psdep0
11139 a_a = psdep_a*e*a_psdep0
11140 a_b = psdep_b*e*a_psdep0
11142 a_temp3 = a_e/(c+d)
11143 a_rh(i, k, 2) = a_rh(i, k, 2) + a_temp3
11144 a_temp5 = -((rh(i, k, 2)-1.)*a_temp3/(c+d))
11148 temp15 = t(i, k)**1.81
11149 temp14 = temp15*qs(i, k, 2)
11150 a_temp6 = diffac_b*a_d/temp14
11151 a_temp5 = -(p(i, k)*a_temp6/temp14)
11152 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 2)*a_temp5
11153 a_qs(i, k, 2) = a_qs(i, k, 2) + temp15*a_temp5
11155 temp15 = rv*t(i, k)**3.5
11156 a_temp5 = diffac_a*xls**2*a_c/temp15
11158 temp3 = (bvts+5.)/8.
11159 temp2 = max10**temp3
11161 temp4 = p(i, k)**temp1
11162 temp5 = temp4*temp2
11164 temp7 = t(i, k)**temp6
11166 temp9 = (t(i, k)+120.)**temp8/temp7
11167 temp11 = (3.*bvts+13.)/24.
11168 temp12 = den(i, k)**temp11
11169 temp13 = (-bvts+3.)*alpha*max2/8.
11170 temp14 = EXP(temp13)
11171 a_temp2 = temp9*temp5*a_b
11172 IF (den(i, k) .LE. 0.0_8 .AND. (temp11 .EQ. 0.0_8 .OR. temp11 &
11173 & .NE. INT(temp11))) THEN
11174 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*a_temp5
11176 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*a_temp5 + temp11*&
11177 & den(i, k)**(temp11-1)*temp14*a_temp2
11179 a_temp3 = temp14*temp12*a_b
11180 IF (p(i, k) .LE. 0.0_8 .AND. (temp1 .EQ. 0.0_8 .OR. temp1 .NE. &
11181 & INT(temp1))) THEN
11182 a_p(i, k) = a_p(i, k) + a_temp6
11184 a_p(i, k) = a_p(i, k) + a_temp6 + temp1*p(i, k)**(temp1-1)*&
11185 & temp2*temp9*a_temp3
11187 a_temp4 = temp5*a_temp3/temp7
11188 IF (t(i, k) + 120. .LE. 0.0_8 .AND. (temp8 .EQ. 0.0_8 .OR. temp8&
11189 & .NE. INT(temp8))) THEN
11190 a_t(i, k) = a_t(i, k) + (den(i, k)-3.5*t(i, k)**2.5*rv*den(i, &
11191 & k)*(t(i, k)+120.)/temp15)*a_temp5
11193 a_t(i, k) = a_t(i, k) + (den(i, k)-3.5*t(i, k)**2.5*rv*den(i, &
11194 & k)*(t(i, k)+120.)/temp15)*a_temp5 + temp8*(t(i, k)+120.)**(&
11197 IF (max10 .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. temp3 .NE. INT&
11201 a_max10 = temp3*max10**(temp3-1)*temp4*temp9*a_temp3
11203 IF (.NOT.(t(i, k) .LE. 0.0_8 .AND. (temp6 .EQ. 0.0_8 .OR. temp6 &
11204 & .NE. INT(temp6)))) a_t(i, k) = a_t(i, k) - temp6*t(i, k)**(&
11205 & temp6-1)*temp9*a_temp4
11206 a_max2 = (3.-bvts)*alpha*EXP(temp13)*temp12*a_temp2/8.
11207 CALL POPCONTROL1B(branch)
11208 IF (branch .EQ. 0) THEN
11209 CALL POPREAL8(max10)
11211 CALL POPREAL8(max10)
11212 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max10
11214 CALL POPCONTROL1B(branch)
11215 IF (branch .EQ. 0) THEN
11216 CALL POPREAL8(max2)
11219 CALL POPREAL8(max2)
11222 CALL POPCONTROL1B(branch)
11223 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y2
11225 temp3 = den(i, k)*max9
11226 temp2 = SQRT(temp3)
11227 temp1 = alpha*max1/2.
11228 a_max1 = alpha*EXP(temp1)*temp2*a_a/2.
11229 IF (temp3 .EQ. 0.0_8) THEN
11232 a_temp0 = EXP(temp1)*a_a/(2.0*temp2)
11234 a_den(i, k) = a_den(i, k) + max9*a_temp0
11235 a_max9 = den(i, k)*a_temp0
11236 CALL POPCONTROL1B(branch)
11237 IF (branch .EQ. 0) THEN
11238 CALL POPREAL8(max9)
11240 CALL POPREAL8(max9)
11241 a_qrs(i, k, 2) = a_qrs(i, k, 2) + a_max9
11243 CALL POPCONTROL1B(branch)
11244 IF (branch .EQ. 0) THEN
11245 CALL POPREAL8(max1)
11248 CALL POPREAL8(max1)
11251 CALL POPCONTROL1B(branch)
11252 IF (branch .EQ. 0) a_t(i, k) = a_t(i, k) - a_y1
11253 CALL POPREAL8(fsupcol)
11255 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't+')
11256 CALL POPREAL8(cpm(i, k))
11257 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
11258 a_cpm(i, k) = 0.0_8
11259 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
11261 a_supsat = a_satdt/dtcld
11262 a_q(i, k) = a_q(i, k) + a_supsat
11263 a_qs(i, k, 2) = a_qs(i, k, 2) - a_supsat
11264 CALL POPREAL8ARRAY(rh(i, k, :), 3)
11265 CALL POPREAL8ARRAY(qs(i, k, :), 3)
11266 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
11267 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
11269 CALL POPREAL8(supcol)
11270 a_t(i, k) = a_t(i, k) - a_supcol
11271 CALL POPREAL8(t(i, k))
11272 a_temp0 = dtcld*xls*a_t(i, k)/cpm(i, k)
11273 a_pidep(i, k) = a_temp0
11274 a_cpm(i, k) = a_cpm(i, k) - pidep(i, k)*a_temp0/cpm(i, k)
11275 CALL POPCONTROL1B(branch)
11276 IF (branch .EQ. 0) THEN
11277 CALL POPREAL8(qci(i, k, 2))
11278 a_qci(i, k, 2) = 0.0_8
11280 CALL POPREAL8(qci(i, k, 2))
11281 a_pidep(i, k) = a_pidep(i, k) + dtcld*a_qci(i, k, 2)
11283 CALL POPCONTROL1B(branch)
11284 IF (branch .EQ. 0) THEN
11285 CALL POPREAL8(q(i, k))
11288 CALL POPREAL8(q(i, k))
11289 a_pidep(i, k) = a_pidep(i, k) - dtcld*a_q(i, k)
11291 CALL POPCONTROL1B(branch)
11292 IF (branch .NE. 0) a_pidep(i, k) = 0.0_8
11293 CALL POPREAL8(pidep(i, k))
11294 a_fsupcol = pidep(i, k)*a_pidep(i, k)
11295 a_pidep(i, k) = fsupcol*a_pidep(i, k)
11296 CALL POPCONTROL2B(branch)
11297 IF (branch .LT. 2) THEN
11298 IF (branch .EQ. 0) THEN
11299 a_x1 = a_pidep(i, k)
11300 a_pidep(i, k) = 0.0_8
11302 a_pidep(i, k) = 0.0_8
11305 CALL POPCONTROL1B(branch)
11306 IF (branch .EQ. 0) THEN
11307 a_qci(i, k, 2) = a_qci(i, k, 2) - a_x1/dtcld
11314 IF (branch .EQ. 2) THEN
11315 a_x2 = a_pidep(i, k)
11316 a_pidep(i, k) = 0.0_8
11318 a_pidep(i, k) = 0.0_8
11321 CALL POPCONTROL1B(branch)
11322 IF (branch .EQ. 0) THEN
11330 CALL POPCONTROL1B(branch)
11331 IF (branch .EQ. 0) THEN
11333 temp2 = den(i, k)*qci(i, k, 2)
11334 a_a = temp2**temp3*pidep_a*a_pidep0
11335 IF (temp2 .LE. 0.0_8 .AND. (temp3 .EQ. 0.0_8 .OR. temp3 .NE. &
11336 & INT(temp3))) THEN
11339 a_temp = temp3*temp2**(temp3-1)*a*pidep_a*a_pidep0
11341 a_den(i, k) = a_den(i, k) + qci(i, k, 2)*a_temp
11342 a_qci(i, k, 2) = a_qci(i, k, 2) + den(i, k)*a_temp
11344 a_temp0 = a_a/(b+c)
11345 a_rh(i, k, 2) = a_rh(i, k, 2) + a_temp0
11346 a_temp = -((rh(i, k, 2)-1.)*a_temp0/(b+c))
11350 temp2 = t(i, k)**1.81
11351 temp1 = temp2*qs(i, k, 2)
11352 a_temp0 = diffac_b*a_c/temp1
11353 a_p(i, k) = a_p(i, k) + a_temp0
11354 a_temp1 = -(p(i, k)*a_temp0/temp1)
11355 a_qs(i, k, 2) = a_qs(i, k, 2) + temp2*a_temp1
11357 temp1 = rv*t(i, k)**3.5
11358 a_temp = diffac_a*xls**2*a_b/temp1
11359 a_t(i, k) = a_t(i, k) + 1.81*t(i, k)**0.81*qs(i, k, 2)*a_temp1&
11360 & + (den(i, k)-3.5*t(i, k)**2.5*rv*den(i, k)*(t(i, k)+120.)/&
11362 a_den(i, k) = a_den(i, k) + (t(i, k)+120.)*a_temp
11364 CALL POPREAL8(fsupcol)
11366 CALL A_SMOOTHIF(supcol, a_supcol, 0., fsupcol, a_fsupcol, 't+')
11367 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
11368 a_cpm(i, k) = 0.0_8
11369 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
11371 a_supsat = a_satdt/dtcld
11372 CALL POPREAL8(supsat)
11373 a_q(i, k) = a_q(i, k) + a_supsat
11374 a_qs(i, k, 2) = a_qs(i, k, 2) - a_supsat
11375 CALL POPREAL8ARRAY(qs(i, k, :), 3)
11376 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
11377 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
11379 CALL POPREAL8(supcol)
11380 a_t(i, k) = a_t(i, k) - a_supcol
11383 END SUBROUTINE A_ACCRET3
11385 !=======================================================================
11387 !=======================================================================
11388 SUBROUTINE ACCRET3(qrs, qci, rh, t, p, den, dtcld, q, qs, psdep, pgdep&
11389 & , pigen, psaut, pgaut, psevp, pgevp, pidep, ims, ime, kms, kme, its&
11392 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
11393 !-------------------------------------------------------------------
11394 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
11395 REAL, DIMENSION(ims:ime, kms:kme) :: den, q, p
11396 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, rh, qs
11397 REAL, DIMENSION(its:ite, kts:kte) :: pigen, psevp, pgevp, pidep, t, &
11398 & xl, cpm, psdep, pgdep, psaut, pgaut
11399 REAL :: supcol, dtcld, satdt, supsat, qimax, diameter, xni0, roqi0, &
11400 & supice1, supice2, supice3, supice4, alpha2
11401 REAL :: pidep0, pidep1, psdep0, pgdep3, pigen0, psevp0, pgevp0, &
11402 & coeres1, coeres2, coeres3, coeres4
11403 REAL :: temp0, temp, xmi
11405 REAL :: fqi, fqr, fqv, fqs, fqg, frh, ft0, fpidep, fpsdep, fpgdep, &
11406 & fsupcol, fsupsat, pidep2
11407 REAL :: value01, factor01, source01, vice, a, b, c, d, e, f, g
11451 !-------------------------------------------------------------
11452 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
11453 ! (T<T0: V->I or I->V)
11454 ! rh(i,k,2)>1.,pidep>0: V->I, min=0, max=satdt
11455 ! rh(i,k,2)<1.,pidep<0: I->V, min=-qi/dtcld,max=0,
11456 !-------------------------------------------------------------
11458 supcol = t0c - t(i, k)
11460 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11462 supsat = q(i, k) - qs(i, k, 2)
11463 satdt = supsat/dtcld
11465 xl(i, k) = XLCAL(t(i, k))
11466 cpm(i, k) = CPMCAL(q(i, k))
11467 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
11468 IF (qci(i, k, 2) .GT. 0.) THEN
11469 b = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
11470 c = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
11471 a = (rh(i, k, 2)-1.)/(b+c)
11472 pidep0 = pidep_a*a*(den(i, k)*qci(i, k, 2))**(7./8.)
11476 IF (pidep0 .LT. 0.) THEN
11477 IF (pidep0 .LT. -(qci(i, k, 2)/dtcld)) THEN
11478 x1 = -(qci(i, k, 2)/dtcld)
11482 IF (x1 .GT. 0.) THEN
11488 IF (pidep0 .GT. satdt) THEN
11493 IF (x2 .LT. 0.) THEN
11499 pidep(i, k) = fsupcol*pidep(i, k)
11500 IF (pidep(i, k) .GE. 0.) THEN
11503 abs0 = -pidep(i, k)
11505 IF (abs0 .LT. qmin/dtcld) pidep(i, k) = 0.
11506 IF (q(i, k) - pidep(i, k)*dtcld .LT. 0.) THEN
11509 q(i, k) = q(i, k) - pidep(i, k)*dtcld
11511 IF (qci(i, k, 2) + pidep(i, k)*dtcld .LT. 0.) THEN
11514 qci(i, k, 2) = qci(i, k, 2) + pidep(i, k)*dtcld
11516 t(i, k) = t(i, k) + pidep(i, k)*dtcld*xls/cpm(i, k)
11519 !-------------------------------------------------------------
11520 ! psdep: deposition/sublimation rate of snow [HDC 14]
11521 ! (T<T0: V->S or S->V)
11522 ! rh(i,k,2)>1.,psdep>0: V->S, min=0, max=satdt
11523 ! rh(i,k,2)<1.,psdep<0: S->V, min=-qs/dtcld,max=0,
11524 !-------------------------------------------------------------
11526 supcol = t0c - t(i, k)
11528 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11530 supsat = q(i, k) - qs(i, k, 2)
11531 satdt = supsat/dtcld
11533 xl(i, k) = XLCAL(t(i, k))
11534 cpm(i, k) = CPMCAL(q(i, k))
11535 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
11536 IF (90. .GT. t0c - t(i, k)) THEN
11541 IF (0. .LT. y1) THEN
11546 IF (qrs(i, k, 2) .LT. qcrmin) THEN
11549 max9 = qrs(i, k, 2)
11551 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
11552 ! call smoothif(q (i,k ),0.,fqv,'q+')
11553 a = EXP(alpha*max1/2.)*SQRT(den(i, k)*max9)
11554 IF (90. .GT. t0c - t(i, k)) THEN
11559 IF (0. .LT. y2) THEN
11564 IF (qrs(i, k, 2) .LT. qcrmin) THEN
11567 max10 = qrs(i, k, 2)
11569 b = EXP((3.-bvts)*alpha*max2/8.)*(t(i, k)+120.)**(1./6.)/t(i, k)&
11570 & **(5.12/6.)*p(i, k)**(1./3.)*den(i, k)**((13.+3.*bvts)/24.)*&
11571 & max10**((5.+bvts)/8.)
11572 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
11573 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
11574 e = (rh(i, k, 2)-1.)/(c+d)
11575 psdep0 = e*(psdep_a*a+psdep_b*b)
11576 IF (psdep0 .LT. 0.) THEN
11577 IF (psdep0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
11578 x3 = -(qrs(i, k, 2)/dtcld)
11582 IF (x3 .GT. 0.) THEN
11588 IF (psdep0 .GT. satdt) THEN
11593 IF (x4 .LT. 0.) THEN
11599 psdep(i, k) = fsupcol*psdep(i, k)
11600 IF (psdep(i, k) .GE. 0.) THEN
11603 abs1 = -psdep(i, k)
11605 IF (abs1 .LT. qmin/dtcld) psdep(i, k) = 0.
11606 IF (q(i, k) - psdep(i, k)*dtcld .LT. 0.) THEN
11609 q(i, k) = q(i, k) - psdep(i, k)*dtcld
11611 IF (qrs(i, k, 2) + psdep(i, k)*dtcld .LT. 0.) THEN
11614 qrs(i, k, 2) = qrs(i, k, 2) + psdep(i, k)*dtcld
11616 t(i, k) = t(i, k) + psdep(i, k)*dtcld*xls/cpm(i, k)
11619 !------------------------------------------------------------
11620 ! pgdep: deposition/sublimation rate of graupel [LFO 46]
11621 ! (T<T0: V->G or G->V)
11622 ! rh(i,k,2)>1.,pgdep>0: V->G, min=0, max=satdt
11623 ! rh(i,k,2)<1.,pgdep<0: G->V, min=-qg/dtcld,max=0,
11624 !------------------------------------------------------------
11626 supcol = t0c - t(i, k)
11628 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11630 supsat = q(i, k) - qs(i, k, 2)
11631 satdt = supsat/dtcld
11633 xl(i, k) = XLCAL(t(i, k))
11634 cpm(i, k) = CPMCAL(q(i, k))
11635 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
11636 IF (qrs(i, k, 3) .LT. qcrmin) THEN
11639 max3 = qrs(i, k, 3)
11641 ! call smoothif(qrs(i,k,3),0.,fqg,'q+')
11642 ! call smoothif(q (i,k ),0.,fqv,'q+')
11643 a = SQRT(den(i, k)*max3)
11644 IF (qrs(i, k, 3) .LT. qcrmin) THEN
11647 max4 = qrs(i, k, 3)
11649 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
11650 & den(i, k)**((13.+3.*bvtg)/24.)*max4**((5.+bvtg)/8.)
11651 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
11652 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
11653 e = (rh(i, k, 2)-1.)/(c+d)
11654 pgdep3 = e*(pgdep_a*a+pgdep_b*b)
11655 IF (pgdep3 .LT. 0.) THEN
11656 IF (pgdep3 .LT. -(qrs(i, k, 3)/dtcld)) THEN
11657 x5 = -(qrs(i, k, 3)/dtcld)
11661 IF (x5 .GT. 0.) THEN
11667 IF (pgdep3 .GT. satdt) THEN
11672 IF (x6 .LT. 0.) THEN
11678 pgdep(i, k) = fsupcol*pgdep(i, k)
11679 IF (pgdep(i, k) .GE. 0.) THEN
11682 abs2 = -pgdep(i, k)
11684 IF (abs2 .LT. qmin/dtcld) pgdep(i, k) = 0.
11685 IF (q(i, k) - pgdep(i, k)*dtcld .LT. 0.) THEN
11688 q(i, k) = q(i, k) - pgdep(i, k)*dtcld
11690 IF (qrs(i, k, 3) + pgdep(i, k)*dtcld .LT. 0.) THEN
11693 qrs(i, k, 3) = qrs(i, k, 3) + pgdep(i, k)*dtcld
11695 t(i, k) = t(i, k) + pgdep(i, k)*dtcld*xls/cpm(i, k)
11697 !-------------------------------------------------------------
11698 ! pigen: generation(nucleation) of ice from vapor [HDC 7-8]
11699 ! (T<T0: V->I) min=0,max=min(roqi0/den(i,k)-max(qci(i,k,2),0.))/dtcld,satdt)
11700 !-------------------------------------------------------------
11702 supcol = t0c - t(i, k)
11703 cpm(i, k) = CPMCAL(q(i, k))
11705 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11707 supsat = q(i, k) - qs(i, k, 2)
11708 satdt = supsat/dtcld
11709 CALL SMOOTHIF(supsat, 0., fsupsat, 'q+')
11710 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
11711 xni0 = 1.e3*EXP(0.1*supcol)
11712 roqi0 = 4.92e-11*xni0**1.33
11713 IF (qci(i, k, 2) .LT. 0.) THEN
11716 max11 = qci(i, k, 2)
11718 x7 = (roqi0/den(i, k)-max11)/dtcld
11719 IF (x7 .GT. satdt) THEN
11724 IF (pigen0 .LT. 0.) THEN
11727 pigen(i, k) = pigen0
11729 pigen(i, k) = fsupcol*fsupsat*pigen(i, k)
11730 IF (pigen(i, k) .GE. 0.) THEN
11733 abs3 = -pigen(i, k)
11735 IF (abs3 .LT. qmin/dtcld) pigen(i, k) = 0.
11736 IF (q(i, k) - pigen(i, k)*dtcld .LT. 0.) THEN
11739 q(i, k) = q(i, k) - pigen(i, k)*dtcld
11741 IF (qci(i, k, 2) + pigen(i, k)*dtcld .LT. 0.) THEN
11744 qci(i, k, 2) = qci(i, k, 2) + pigen(i, k)*dtcld
11746 t(i, k) = t(i, k) + pigen(i, k)*dtcld*xls/cpm(i, k)
11749 !------------------------------------------------------------
11750 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
11751 ! (T<T0: I->S) psaut>0, min=0,max=(qci(i,k,2)-qimax)/dtcld
11752 !-------------------------------------------------------------
11754 supcol = t0c - t(i, k)
11755 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
11756 ! call smoothif(qci(i,k,2),0.,fqi,'q+')
11757 qimax = roqimax/den(i, k)
11758 IF (0. .LT. (qci(i, k, 2)-qimax)/dtcld) THEN
11759 psaut(i, k) = (qci(i, k, 2)-qimax)/dtcld
11763 psaut(i, k) = fsupcol*psaut(i, k)
11764 IF (psaut(i, k) .GE. 0.) THEN
11767 abs4 = -psaut(i, k)
11769 IF (abs4 .LT. qmin/dtcld) psaut(i, k) = 0.
11770 IF (qci(i, k, 2) - psaut(i, k)*dtcld .LT. 0.) THEN
11773 qci(i, k, 2) = qci(i, k, 2) - psaut(i, k)*dtcld
11775 IF (qrs(i, k, 2) + psaut(i, k)*dtcld .LT. 0.) THEN
11778 qrs(i, k, 2) = qrs(i, k, 2) + psaut(i, k)*dtcld
11782 !-------------------------------------------------------------
11783 ! pgaut: conversion(aggregation) of snow to graupel [LFO 37]
11784 ! (T<T0: S->G) pgaut>0 min=0.,max=qrs(i,k,2)/dtcld
11785 !-------------------------------------------------------------
11787 ! supcol = t0c-t(i,k) ! not change
11788 ! call smoothif(supcol,0.,fsupcol,'t0')
11789 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
11790 alpha2 = 1.e-3*EXP(0.09*(-supcol))
11791 IF (0. .LT. alpha2*(qrs(i, k, 2)-qs0)) THEN
11792 x8 = alpha2*(qrs(i, k, 2)-qs0)
11796 IF (x8 .GT. qrs(i, k, 2)/dtcld) THEN
11797 pgaut(i, k) = qrs(i, k, 2)/dtcld
11801 pgaut(i, k) = fsupcol*pgaut(i, k)
11802 IF (pgaut(i, k) .GE. 0.) THEN
11805 abs5 = -pgaut(i, k)
11807 IF (abs5 .LT. qmin/dtcld) pgaut(i, k) = 0.
11808 IF (qrs(i, k, 2) - pgaut(i, k)*dtcld .LT. 0.) THEN
11811 qrs(i, k, 2) = qrs(i, k, 2) - pgaut(i, k)*dtcld
11813 IF (qrs(i, k, 3) + pgaut(i, k)*dtcld .LT. 0.) THEN
11816 qrs(i, k, 3) = qrs(i, k, 3) + pgaut(i, k)*dtcld
11820 !-------------------------------------------------------------
11821 ! psevp: Evaporation of melting snow [RH83 A27]
11822 ! (T>=T0: S->V) rh<1., psevp<0, min=-qrs(i,k,2)/dtcld, max=0.
11823 !-------------------------------------------------------------
11824 ! supcol = t0c-t(i,k) ! not change
11826 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11828 xl(i, k) = XLCAL(t(i, k))
11829 cpm(i, k) = CPMCAL(q(i, k))
11830 CALL SMOOTHIF(t(i, k), t0c, ft0, 't+')
11831 IF (90. .GT. t0c - t(i, k)) THEN
11836 IF (0. .LT. y3) THEN
11841 IF (qrs(i, k, 2) .LT. qcrmin) THEN
11844 max12 = qrs(i, k, 2)
11846 a = EXP(alpha*max5/2.)*SQRT(den(i, k)*max12)
11847 IF (90. .GT. t0c - t(i, k)) THEN
11852 IF (0. .LT. y4) THEN
11857 IF (qrs(i, k, 2) .LT. qcrmin) THEN
11860 max13 = qrs(i, k, 2)
11862 b = EXP((3.-bvts)*alpha*max6/8.)*(t(i, k)+120.)**(1./6.)/t(i, k)&
11863 & **(5.12/6.)*p(i, k)**(1./3.)*den(i, k)**((13.+3.*bvts)/24.)*&
11864 & max13**((5.+bvts)/8.)
11865 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
11867 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
11868 e = (rh(i, k, 1)-1.)/(c+d)
11869 psevp0 = e*(psevp_a*a+psevp_b*b)
11870 IF (psevp0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
11871 x9 = -(qrs(i, k, 2)/dtcld)
11875 IF (x9 .GT. 0.) THEN
11880 psevp(i, k) = ft0*psevp(i, k)
11881 IF (psevp(i, k) .GE. 0.) THEN
11884 abs6 = -psevp(i, k)
11886 IF (abs6 .LT. qmin/dtcld) psevp(i, k) = 0.
11887 IF (q(i, k) - psevp(i, k)*dtcld .LT. 0.) THEN
11890 q(i, k) = q(i, k) - psevp(i, k)*dtcld
11892 IF (qrs(i, k, 2) + psevp(i, k)*dtcld .LT. 0.) THEN
11895 qrs(i, k, 2) = qrs(i, k, 2) + psevp(i, k)*dtcld
11897 t(i, k) = t(i, k) + psevp(i, k)*dtcld*xls/cpm(i, k)
11900 !-------------------------------------------------------------
11901 ! pgevp: Evaporation of melting graupel [RH84 A19]
11902 ! (T>=T0: G->V) rh<1., pgevp<0, min=-qrs(i,k,3)/dtcld, max=0.
11903 !-------------------------------------------------------------
11904 supcol = t0c - t(i, k)
11906 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
11908 xl(i, k) = XLCAL(t(i, k))
11909 cpm(i, k) = CPMCAL(q(i, k))
11910 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
11911 IF (qrs(i, k, 3) .LT. qcrmin) THEN
11914 max7 = qrs(i, k, 3)
11916 a = SQRT(den(i, k)*max7)
11917 IF (qrs(i, k, 3) .LT. qcrmin) THEN
11920 max8 = qrs(i, k, 3)
11922 b = (t(i, k)+120.)**(1./6.)/t(i, k)**(5.12/6.)*p(i, k)**(1./3.)*&
11923 & den(i, k)**((13.+3.*bvtg)/24.)*max8**((5.+bvtg)/8.)
11924 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
11926 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
11927 e = (rh(i, k, 1)-1.)/(c+d)
11928 pgevp0 = e*(pgevp_a*a+pgevp_b*b)
11929 IF (pgevp0 .LT. -(qrs(i, k, 3)/dtcld)) THEN
11930 x10 = -(qrs(i, k, 3)/dtcld)
11934 IF (x10 .GT. 0.) THEN
11939 pgevp(i, k) = ft0*pgevp(i, k)
11940 IF (pgevp(i, k) .GE. 0.) THEN
11943 abs7 = -pgevp(i, k)
11945 IF (abs7 .LT. qmin/dtcld) pgevp(i, k) = 0.
11946 IF (q(i, k) - pgevp(i, k)*dtcld .LT. 0.) THEN
11949 q(i, k) = q(i, k) - pgevp(i, k)*dtcld
11951 IF (qrs(i, k, 3) + pgevp(i, k)*dtcld .LT. 0.) THEN
11954 qrs(i, k, 3) = qrs(i, k, 3) + pgevp(i, k)*dtcld
11956 t(i, k) = t(i, k) + pgevp(i, k)*dtcld*xls/cpm(i, k)
11960 END SUBROUTINE ACCRET3
11962 ! Differentiation of pconadd in reverse (adjoint) mode (with options r8):
11963 ! gradient of useful results: p q t qs cpm xl qci
11964 ! with respect to varying inputs: p q t qs cpm xl qci
11965 !=======================================================================
11967 !=======================================================================
11968 SUBROUTINE A_PCONADD(t, a_t, p, a_p, q, a_q, qci, a_qci, qs, a_qs, xl&
11969 & , a_xl, cpm, a_cpm, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
11971 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
11972 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
11973 REAL, DIMENSION(its:ite, kts:kte, 2) :: a_qci
11974 REAL, DIMENSION(its:ite, kts:kte) :: t, xl, pcond, work2, cpm
11975 REAL, DIMENSION(its:ite, kts:kte) :: a_t, a_xl, a_pcond, a_cpm
11976 REAL, DIMENSION(its:ite, kts:kte, 3) :: qs, work1, rh
11977 REAL, DIMENSION(its:ite, kts:kte, 3) :: a_qs, a_work1, a_rh
11978 REAL, DIMENSION(ims:ime, kms:kme) :: q, p
11979 REAL, DIMENSION(ims:ime, kms:kme) :: a_q, a_p
11981 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
11982 & dtcld, qs1, qs2, qs3, qs4, w1, q1
11983 REAL :: tmp1, tmp2, f1, f2, qs0
11999 CALL PUSHREAL8ARRAY(qs(i, k, :), 3)
12000 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
12002 xl(i, k) = XLCAL(t(i, k))
12003 CALL PUSHREAL8(cpm(i, k))
12004 cpm(i, k) = CPMCAL(q(i, k))
12005 !----------------------------------------------------------------
12006 ! pcond: condensational/evaporational rate of cloud water [RH83 A6]
12007 ! if there exists additional water vapor condensated/if
12008 ! evaporation of cloud water is not enough to remove subsaturation
12009 !q>qs, work1>0, pcond>0 V->C min=0, max=q(i,k)/dtcld
12010 !q<qs, work1<0, pcond<0 C->V min=-qci(i,k,1)/dtcld, max=0,
12011 work1(i, k, 1) = CONDEN(t(i, k), q(i, k), qs(i, k, 1), xl(i, k)&
12013 IF (work1(i, k, 1) .GT. 0.) THEN
12014 IF (q(i, k) .LT. 0.) THEN
12015 CALL PUSHCONTROL1B(0)
12019 CALL PUSHCONTROL1B(1)
12021 IF (work1(i, k, 1) .GT. y1) THEN
12023 CALL PUSHCONTROL1B(0)
12025 min1 = work1(i, k, 1)
12026 CALL PUSHCONTROL1B(1)
12028 pcond(i, k) = min1/dtcld
12029 CALL PUSHCONTROL1B(1)
12031 IF (work1(i, k, 1) .LT. -qci(i, k, 1)) THEN
12032 max1 = -qci(i, k, 1)
12033 CALL PUSHCONTROL1B(0)
12035 max1 = work1(i, k, 1)
12036 CALL PUSHCONTROL1B(1)
12038 pcond(i, k) = max1/dtcld
12039 CALL PUSHCONTROL1B(0)
12041 IF (pcond(i, k) .GE. 0.) THEN
12044 abs0 = -pcond(i, k)
12046 IF (abs0 .LT. qmin/dtcld) THEN
12048 CALL PUSHCONTROL1B(1)
12050 CALL PUSHCONTROL1B(0)
12052 IF (q(i, k) - pcond(i, k)*dtcld .LT. 0.) THEN
12053 CALL PUSHCONTROL1B(0)
12055 CALL PUSHCONTROL1B(1)
12057 IF (qci(i, k, 1) + pcond(i, k)*dtcld .LT. 0.) THEN
12058 CALL PUSHCONTROL1B(0)
12060 CALL PUSHCONTROL1B(1)
12068 a_temp = dtcld*a_t(i, k)/cpm(i, k)
12069 a_pcond(i, k) = xl(i, k)*a_temp
12070 a_xl(i, k) = a_xl(i, k) + pcond(i, k)*a_temp
12071 a_cpm(i, k) = a_cpm(i, k) - pcond(i, k)*xl(i, k)*a_temp/cpm(i, k&
12073 CALL POPCONTROL1B(branch)
12074 IF (branch .EQ. 0) THEN
12075 a_qci(i, k, 1) = 0.0_8
12077 a_pcond(i, k) = a_pcond(i, k) + dtcld*a_qci(i, k, 1)
12079 CALL POPCONTROL1B(branch)
12080 IF (branch .EQ. 0) THEN
12083 a_pcond(i, k) = a_pcond(i, k) - dtcld*a_q(i, k)
12085 CALL POPCONTROL1B(branch)
12086 IF (branch .NE. 0) a_pcond(i, k) = 0.0_8
12087 CALL POPCONTROL1B(branch)
12088 IF (branch .EQ. 0) THEN
12089 a_max1 = a_pcond(i, k)/dtcld
12090 a_pcond(i, k) = 0.0_8
12091 CALL POPCONTROL1B(branch)
12092 IF (branch .EQ. 0) THEN
12093 a_qci(i, k, 1) = a_qci(i, k, 1) - a_max1
12095 a_work1(i, k, 1) = a_work1(i, k, 1) + a_max1
12098 a_min1 = a_pcond(i, k)/dtcld
12099 a_pcond(i, k) = 0.0_8
12100 CALL POPCONTROL1B(branch)
12101 IF (branch .EQ. 0) THEN
12104 a_work1(i, k, 1) = a_work1(i, k, 1) + a_min1
12107 CALL POPCONTROL1B(branch)
12108 IF (branch .NE. 0) a_q(i, k) = a_q(i, k) + a_y1
12110 CALL A_CONDEN0(t(i, k), a_t(i, k), q(i, k), a_q(i, k), qs(i, k, &
12111 & 1), a_qs(i, k, 1), xl(i, k), a_xl(i, k), cpm(i, k), &
12112 & a_cpm(i, k), a_work1(i, k, 1))
12113 a_work1(i, k, 1) = 0.0_8
12114 CALL POPREAL8(cpm(i, k))
12115 CALL A_CPMCAL0(q(i, k), a_q(i, k), a_cpm(i, k))
12116 a_cpm(i, k) = 0.0_8
12117 CALL A_XLCAL0(t(i, k), a_t(i, k), a_xl(i, k))
12119 CALL POPREAL8ARRAY(qs(i, k, :), 3)
12121 CALL A_CALCRH(t(i, k), a_t(i, k), p(i, k), a_p(i, k), q(i, k), &
12122 & a_q(i, k), rh(i, k, :), a_rh(i, k, :), qs(i, k, :), a_qs&
12126 END SUBROUTINE A_PCONADD
12128 !=======================================================================
12130 !=======================================================================
12131 SUBROUTINE PCONADD(t, p, q, qci, qs, xl, cpm, dtcld, kte, kts, its, &
12132 & ite, kme, kms, ims, ime)
12134 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
12135 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
12136 REAL, DIMENSION(its:ite, kts:kte) :: t, xl, pcond, work2, cpm
12137 REAL, DIMENSION(its:ite, kts:kte, 3) :: qs, work1, rh
12138 REAL, DIMENSION(ims:ime, kms:kme) :: q, p
12140 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
12141 & dtcld, qs1, qs2, qs3, qs4, w1, q1
12142 REAL :: tmp1, tmp2, f1, f2, qs0
12153 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
12155 xl(i, k) = XLCAL(t(i, k))
12156 cpm(i, k) = CPMCAL(q(i, k))
12157 !----------------------------------------------------------------
12158 ! pcond: condensational/evaporational rate of cloud water [RH83 A6]
12159 ! if there exists additional water vapor condensated/if
12160 ! evaporation of cloud water is not enough to remove subsaturation
12161 !q>qs, work1>0, pcond>0 V->C min=0, max=q(i,k)/dtcld
12162 !q<qs, work1<0, pcond<0 C->V min=-qci(i,k,1)/dtcld, max=0,
12163 work1(i, k, 1) = CONDEN(t(i, k), q(i, k), qs(i, k, 1), xl(i, k)&
12165 IF (work1(i, k, 1) .GT. 0.) THEN
12166 IF (q(i, k) .LT. 0.) THEN
12171 IF (work1(i, k, 1) .GT. y1) THEN
12174 min1 = work1(i, k, 1)
12176 pcond(i, k) = min1/dtcld
12178 IF (work1(i, k, 1) .LT. -qci(i, k, 1)) THEN
12179 max1 = -qci(i, k, 1)
12181 max1 = work1(i, k, 1)
12183 pcond(i, k) = max1/dtcld
12185 IF (pcond(i, k) .GE. 0.) THEN
12188 abs0 = -pcond(i, k)
12190 IF (abs0 .LT. qmin/dtcld) pcond(i, k) = 0.
12191 IF (q(i, k) - pcond(i, k)*dtcld .LT. 0.) THEN
12194 q(i, k) = q(i, k) - pcond(i, k)*dtcld
12196 IF (qci(i, k, 1) + pcond(i, k)*dtcld .LT. 0.) THEN
12199 qci(i, k, 1) = qci(i, k, 1) + pcond(i, k)*dtcld
12201 t(i, k) = t(i, k) + pcond(i, k)*dtcld*xl(i, k)/cpm(i, k)
12205 END SUBROUTINE PCONADD
12207 ! Differentiation of smoothif in reverse (adjoint) mode (with options r8):
12208 ! gradient of useful results: f x
12209 ! with respect to varying inputs: x
12210 !=======================================================================
12212 !=======================================================================
12213 SUBROUTINE A_SMOOTHIF(x, a_x, a, f, a_f, opt)
12215 REAL, INTENT(IN) :: x, a
12217 CHARACTER(len=2), INTENT(IN) :: opt
12220 REAL(kind=8) :: k1, a1, x1, c1, f1, k, b
12221 REAL(kind=8) :: a_x1, a_f1, a_k
12223 REAL(kind=8) :: temp1, temp2
12226 IF (opt(1:1) .EQ. 'q') THEN
12231 !f=1/(1+exp(-k*(x-b))
12233 IF (opt(2:2) .EQ. '+') THEN
12240 temp1 = 1/( EXP(k) + 1.)
12241 temp2 = 1/( EXP(-k) + 1.)
12242 a_k = -(temp1*temp2*a_f1)
12245 END SUBROUTINE A_SMOOTHIF
12247 !=======================================================================
12249 !=======================================================================
12250 SUBROUTINE SMOOTHIF(x, a, f, opt)
12252 REAL, INTENT(IN) :: x, a
12253 CHARACTER(len=2), INTENT(IN) :: opt
12254 REAL, INTENT(OUT) :: f
12255 REAL(kind=8) :: k1, a1, x1, c1, f1, k, b
12259 IF (opt(1:1) .EQ. 'q') THEN
12265 IF (opt(2:2) .EQ. '+') THEN
12271 f1 = 1./(1.+EXP(k))
12273 END SUBROUTINE SMOOTHIF
12277 !=======================================================================
12279 !=======================================================================
12280 REAL FUNCTION RGMMA(x)
12282 !-------------------------------------------------------------------
12283 ! rgmma function: use infinite product form
12285 PARAMETER (euler=0.577215664901532)
12290 IF (x .EQ. 1.) THEN
12293 rgmma = x*EXP(euler*x)
12296 rgmma = rgmma*(1.000+x/y)*EXP(-(x/y))
12302 ! Differentiation of cpmcal in reverse (adjoint) mode (with options r8):
12303 ! gradient of useful results: x cpmcal
12304 ! with respect to varying inputs: x
12307 !=======================================================================
12309 !=======================================================================
12310 ! compute internal functions
12311 SUBROUTINE A_CPMCAL0(x, a_x, a_cpmcal)
12314 REAL :: a_cpmcal, a_x
12315 a_x = a_x + (cpv-cpd)*a_cpmcal
12316 END SUBROUTINE A_CPMCAL0
12320 !=======================================================================
12322 !=======================================================================
12323 ! compute internal functions
12327 cpmcal = cpd + x*(cpv-cpd)
12328 END FUNCTION CPMCAL
12330 ! Differentiation of xlcal in reverse (adjoint) mode (with options r8):
12331 ! gradient of useful results: xlcal x
12332 ! with respect to varying inputs: x
12334 !=======================================================================
12336 !=======================================================================
12337 SUBROUTINE A_XLCAL0(x, a_x, a_xlcal)
12340 REAL :: a_xlcal, a_x
12341 a_x = a_x - xlv1*a_xlcal
12342 END SUBROUTINE A_XLCAL0
12345 !=======================================================================
12347 !=======================================================================
12351 xlcal = xlv0 - xlv1*(x-t0c)
12354 ! Differentiation of conden in reverse (adjoint) mode (with options r8):
12355 ! gradient of useful results: d e conden a b c
12356 ! with respect to varying inputs: d e a b c
12357 !=======================================================================
12358 ! a:t, b:q, c:qs, d:xl, e:cpm
12359 !=======================================================================
12360 SUBROUTINE A_CONDEN0(a, a_a, b, a_b, c, a_c, d, a_d, e, a_e, a_conden)
12362 REAL :: conden, a, b, c, d, e
12363 REAL :: a_conden, a_a, a_b, a_c, a_d, a_e
12372 a_temp = a_conden/(temp0+1.)
12374 a_temp0 = -((b-c)*a_temp/(temp*(temp0+1.)))
12375 a_c = a_c + d**2*a_temp0 - a_temp
12376 a_d = a_d + 2*d*c*a_temp0
12377 a_temp1 = -(temp0*a_temp0)
12378 a_e = a_e + rv*a**2*a_temp1
12379 a_a = a_a + 2*a*rv*e*a_temp1
12380 END SUBROUTINE A_CONDEN0
12382 !=======================================================================
12383 ! a:t, b:q, c:qs, d:xl, e:cpm
12384 !=======================================================================
12385 FUNCTION CONDEN(a, b, c, d, e)
12387 REAL :: conden, a, b, c, d, e
12389 conden = (b-c)/(1.+d*d/(rv*e)*c/(a*a))
12390 END FUNCTION CONDEN
12392 END MODULE A_MODULE_MP_WSM6R