1 ! Generated by TAPENADE (INRIA, Ecuador team)
2 ! Tapenade 3.16 (master) - 9 Oct 2020 17:47
4 MODULE G_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 :: g_vt2i, g_vt2r, g_vt2s, g_vt2g
98 ! Differentiation of wsm6r in forward (tangent) mode (with options r8):
99 ! variations 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:in q:in-out qr:in-out qs:in-out delz:in den:in
105 ! rain:in-out rainncv:in-out pii:in
106 !=======================================================================
108 !=======================================================================
109 SUBROUTINE G_WSM6R(th, g_th, q, g_q, qc, g_qc, qr, g_qr, qi, g_qi, qs&
110 & , g_qs, qg, g_qg, den, g_den, pii, g_pii, p, g_p, delz, g_delz, delt&
111 & , rain, g_rain, rainncv, g_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) :: g_th, &
120 & g_q, g_qc, g_qi, g_qr, g_qs, g_qg
121 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: den, pii, &
123 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: g_den, &
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) :: g_rain, &
130 REAL, DIMENSION(its:ite, kts:kte) :: t
131 REAL, DIMENSION(its:ite, kts:kte) :: g_t
132 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
133 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
134 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
135 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs
136 REAL, DIMENSION(ims:ime, kms:kme) :: q2d, den2d, p2d, delz2d
137 REAL, DIMENSION(ims:ime, kms:kme) :: g_q2d, g_den2d, g_p2d, g_delz2d
138 REAL, DIMENSION(ims:ime) :: r1d, rcv1d
139 REAL, DIMENSION(ims:ime) :: g_r1d, g_rcv1d
141 INTEGER :: i, j, k, ierr
155 g_r1d(i) = g_rain(i, j)
157 g_rcv1d(i) = g_rainncv(i, j)
158 rcv1d(i) = rainncv(i, j)
160 g_t(i, k) = pii(i, k, j)*g_th(i, k, j) + th(i, k, j)*g_pii(i, &
162 t(i, k) = th(i, k, j)*pii(i, k, j)
163 g_qci(i, k, 1) = g_qc(i, k, j)
164 qci(i, k, 1) = qc(i, k, j)
165 g_qci(i, k, 2) = g_qi(i, k, j)
166 qci(i, k, 2) = qi(i, k, j)
167 g_qrs(i, k, 1) = g_qr(i, k, j)
168 qrs(i, k, 1) = qr(i, k, j)
169 g_qrs(i, k, 2) = g_qs(i, k, j)
170 qrs(i, k, 2) = qs(i, k, j)
171 g_qrs(i, k, 3) = g_qg(i, k, j)
172 qrs(i, k, 3) = qg(i, k, j)
173 g_q2d(i, k) = g_q(i, k, j)
174 q2d(i, k) = q(i, k, j)
175 g_den2d(i, k) = g_den(i, k, j)
176 den2d(i, k) = den(i, k, j)
177 g_p2d(i, k) = g_p(i, k, j)
178 p2d(i, k) = p(i, k, j)
179 g_delz2d(i, k) = g_delz(i, k, j)
180 delz2d(i, k) = delz(i, k, j)
183 ! Sending array starting locations of optional variables may cause
184 ! troubles, so we explicitly change the call.
185 CALL G_WSM62D(t, g_t, q2d, g_q2d, qci, g_qci, qrs, g_qrs, den2d, &
186 & g_den2d, p2d, g_p2d, delz2d, g_delz2d, delt1, r1d, g_r1d, &
187 & rcv1d, g_rcv1d, ims, ime, kms, kme, its, ite, kts, kte)
189 g_rain(i, j) = g_r1d(i)
191 g_rainncv(i, j) = g_rcv1d(i)
192 rainncv(i, j) = rcv1d(i)
194 temp = t(i, k)/pii(i, k, j)
195 g_th(i, k, j) = (g_t(i, k)-temp*g_pii(i, k, j))/pii(i, k, j)
197 g_qc(i, k, j) = g_qci(i, k, 1)
198 qc(i, k, j) = qci(i, k, 1)
199 g_qi(i, k, j) = g_qci(i, k, 2)
200 qi(i, k, j) = qci(i, k, 2)
201 g_qr(i, k, j) = g_qrs(i, k, 1)
202 qr(i, k, j) = qrs(i, k, 1)
203 g_qs(i, k, j) = g_qrs(i, k, 2)
204 qs(i, k, j) = qrs(i, k, 2)
205 g_qg(i, k, j) = g_qrs(i, k, 3)
206 qg(i, k, j) = qrs(i, k, 3)
207 g_q(i, k, j) = g_q2d(i, k)
208 q(i, k, j) = q2d(i, k)
212 END SUBROUTINE G_WSM6R
214 !=======================================================================
216 !=======================================================================
217 SUBROUTINE WSM6R(th, q, qc, qr, qi, qs, qg, den, pii, p, delz, delt, &
218 & rain, rainncv, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms&
219 & , kme, its, ite, jts, jte, kts, kte)
221 !-------------------------------------------------------------------
222 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde, ims, ime, jms, &
223 & jme, kms, kme, its, ite, jts, jte, kts, kte
224 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: th, q, &
226 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: den, pii, &
228 REAL, INTENT(IN) :: delt
229 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: rain, rainncv
231 REAL, DIMENSION(its:ite, kts:kte) :: t
232 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
233 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
234 REAL, DIMENSION(ims:ime, kms:kme) :: q2d, den2d, p2d, delz2d
235 REAL, DIMENSION(ims:ime) :: r1d, rcv1d
237 INTEGER :: i, j, k, ierr
242 rcv1d(i) = rainncv(i, j)
244 t(i, k) = th(i, k, j)*pii(i, k, j)
245 qci(i, k, 1) = qc(i, k, j)
246 qci(i, k, 2) = qi(i, k, j)
247 qrs(i, k, 1) = qr(i, k, j)
248 qrs(i, k, 2) = qs(i, k, j)
249 qrs(i, k, 3) = qg(i, k, j)
250 q2d(i, k) = q(i, k, j)
251 den2d(i, k) = den(i, k, j)
252 p2d(i, k) = p(i, k, j)
253 delz2d(i, k) = delz(i, k, j)
256 ! Sending array starting locations of optional variables may cause
257 ! troubles, so we explicitly change the call.
258 CALL WSM62D(t, q2d, qci, qrs, den2d, p2d, delz2d, delt1, r1d, &
259 & rcv1d, ims, ime, kms, kme, its, ite, kts, kte)
262 rainncv(i, j) = rcv1d(i)
264 th(i, k, j) = t(i, k)/pii(i, k, j)
265 qc(i, k, j) = qci(i, k, 1)
266 qi(i, k, j) = qci(i, k, 2)
267 qr(i, k, j) = qrs(i, k, 1)
268 qs(i, k, j) = qrs(i, k, 2)
269 qg(i, k, j) = qrs(i, k, 3)
270 q(i, k, j) = q2d(i, k)
276 ! Differentiation of wsm62d in forward (tangent) mode (with options r8):
277 ! variations of useful results: q t qrs rain qci rainncv
278 ! with respect to varying inputs: p q t delz den qrs rain qci
280 !=======================================================================
282 !=======================================================================
283 SUBROUTINE G_WSM62D(t, g_t, q, g_q, qci, g_qci, qrs, g_qrs, den, g_den&
284 & , p, g_p, delz, g_delz, delt, rain, g_rain, rainncv, g_rainncv, ims&
285 & , ime, kms, kme, its, ite, kts, kte)
289 !-------------------------------------------------------------------
290 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
291 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: t
292 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: g_t
293 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: qci
294 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: g_qci
295 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: qrs
296 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: g_qrs
297 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: q
298 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: g_q
299 REAL, DIMENSION(ims:ime, kms:kme), INTENT(IN) :: den, p, delz
300 REAL, DIMENSION(ims:ime, kms:kme), INTENT(IN) :: g_den, g_p, g_delz
301 REAL, INTENT(IN) :: delt
302 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: rain, rainncv
303 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: g_rain, g_rainncv
305 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, rslope, rslope2, &
306 & rslope3, rslopeb, falk, fall, work1
307 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_rh, g_qs, g_falk, g_fall
308 REAL, DIMENSION(its:ite, kts:kte) :: pracw, psacw, pgacw, pgacr, &
309 & pgacs, psaci, praci, piacr, pracs, psacr, pgaci, pseml, pgeml, fallc&
310 & , praut, psaut, pgaut, prevp, psdep, pgdep
311 REAL, DIMENSION(its:ite, kts:kte) :: g_pracw, g_psacw, g_pgacw, &
312 & g_pgacr, g_pgacs, g_psaci, g_praci, g_piacr, g_pracs, g_psacr, &
313 & g_pgaci, g_pseml, g_pgeml, g_fallc, g_praut, g_psaut, g_pgaut, &
314 & g_prevp, g_psdep, g_pgdep
315 REAL, DIMENSION(its:ite, kts:kte) :: pigen, pidep, pcond, xl, cpm, &
316 & psevp, xni, pgevp, n0sfac, work2
317 REAL, DIMENSION(its:ite, kts:kte) :: g_pigen, g_pidep, g_xl, g_cpm, &
319 ! LOGICAL, DIMENSION( its:ite ) :: flgcld
320 REAL :: dtcld, temp, temp0, supcol, supsat, satdt, eacrs, xmi, &
321 & diameter, delta2, delta3
322 INTEGER :: i, k, loop, loops
323 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
324 & qs10, qs11, qs20, qs21
325 REAL :: fq, fqc, fqi, fqr, fqs, fqg, fallsum
329 !=================================================================
332 !----------------------------------------------------------------
333 ! paddint 0 for negative values generated by dynamics
337 IF (q(i, k) .LT. 0.) THEN
343 IF (qci(i, k, 1) .LT. 0.) THEN
344 g_qci(i, k, 1) = 0.0_8
347 qci(i, k, 1) = qci(i, k, 1)
349 IF (qrs(i, k, 1) .LT. 0.) THEN
350 g_qrs(i, k, 1) = 0.0_8
353 qrs(i, k, 1) = qrs(i, k, 1)
355 IF (qci(i, k, 2) .LT. 0.) THEN
356 g_qci(i, k, 2) = 0.0_8
359 qci(i, k, 2) = qci(i, k, 2)
361 IF (qrs(i, k, 2) .LT. 0.) THEN
362 g_qrs(i, k, 2) = 0.0_8
365 qrs(i, k, 2) = qrs(i, k, 2)
367 IF (qrs(i, k, 3) .LT. 0.) THEN
368 g_qrs(i, k, 3) = 0.0_8
371 qrs(i, k, 3) = qrs(i, k, 3)
375 x1 = NINT(delt/dtcldcr)
382 IF (delt .LE. dtcldcr) THEN
449 !----------------------------------------------------------------
450 ! initialize the variables for microphysical physics
451 CALL G_INIMP(prevp, g_prevp, psdep, g_psdep, pgdep, g_pgdep, praut&
452 & , g_praut, psaut, g_psaut, pgaut, g_pgaut, pracw, g_pracw, &
453 & praci, g_praci, piacr, g_piacr, psaci, g_psaci, psacw, &
454 & g_psacw, pracs, g_pracs, psacr, g_psacr, pgacw, g_pgacw, &
455 & pgaci, g_pgaci, pgacr, g_pgacr, pgacs, g_pgacs, pigen, &
456 & g_pigen, pidep, g_pidep, pcond, pseml, g_pseml, pgeml, &
457 & g_pgeml, psevp, g_psevp, pgevp, g_pgevp, falk, g_falk, fall&
458 & , g_fall, fallc, g_fallc, xni, kts, kte, its, ite)
459 !----------------------------------------------------------------
460 ! compute the fallout term:
461 ! first, vertical terminal velosity for minor loops
462 CALL G_FALLK(cpm, g_cpm, t, g_t, p, g_p, q, g_q, den, g_den, qrs, &
463 & g_qrs, delz, g_delz, dtcld, falk, g_falk, fall, g_fall, kte&
464 & , kts, its, ite, kme, kms, ims, ime)
465 CALL G_FALLKC(qci, g_qci, fallc, g_fallc, den, g_den, delz, g_delz&
466 & , dtcld, kte, kts, its, ite, kme, kms, ims, ime)
467 CALL G_RAINSC(fall, g_fall, fallc, g_fallc, xl, g_xl, t, g_t, q, &
468 & qci, g_qci, cpm, g_cpm, den, g_den, qrs, g_qrs, delz, &
469 & g_delz, rain, g_rain, rainncv, g_rainncv, dtcld, kte, kts&
470 & , its, ite, kme, kms, ims, ime)
471 CALL G_WARMR(t, g_t, q, g_q, qci, g_qci, qrs, g_qrs, den, g_den, p&
472 & , g_p, dtcld, xl, g_xl, rh, g_rh, qs, g_qs, praut, g_praut&
473 & , pracw, g_pracw, prevp, g_prevp, ims, ime, kms, kme, its, &
476 ! cold rain processes
479 CALL G_ACCRET1(qci, g_qci, den, g_den, qrs, g_qrs, t, g_t, q, g_q&
480 & , dtcld, praci, g_praci, piacr, g_piacr, psaci, g_psaci, &
481 & pgaci, g_pgaci, psacw, g_psacw, pgacw, g_pgacw, ims, ime&
482 & , kms, kme, its, ite, kts, kte)
483 CALL G_ACCRET2(qrs, g_qrs, t, g_t, q, g_q, den, g_den, dtcld, &
484 & psacw, g_psacw, pgacw, g_pgacw, pracs, g_pracs, psacr, &
485 & g_psacr, pgacr, g_pgacr, pgacs, g_pgacs, pseml, g_pseml, &
486 & pgeml, g_pgeml, ims, ime, kms, kme, its, ite, kts, kte)
487 CALL G_ACCRET3(qrs, g_qrs, qci, g_qci, rh, g_rh, t, g_t, p, g_p, &
488 & den, g_den, dtcld, q, g_q, qs, g_qs, psdep, g_psdep, &
489 & pgdep, g_pgdep, pigen, g_pigen, psaut, g_psaut, pgaut, &
490 & g_pgaut, psevp, g_psevp, pgevp, g_pgevp, pidep, g_pidep, &
491 & ims, ime, kms, kme, its, ite, kts, kte)
492 CALL G_PCONADD(t, g_t, p, g_p, q, g_q, qci, g_qci, qs, g_qs, xl, &
493 & g_xl, cpm, g_cpm, dtcld, kte, kts, its, ite, kme, kms, &
496 END SUBROUTINE G_WSM62D
498 !=======================================================================
500 !=======================================================================
501 SUBROUTINE WSM62D(t, q, qci, qrs, den, p, delz, delt, rain, rainncv, &
502 & ims, ime, kms, kme, its, ite, kts, kte)
506 !-------------------------------------------------------------------
507 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
508 REAL, DIMENSION(its:ite, kts:kte), INTENT(INOUT) :: t
509 REAL, DIMENSION(its:ite, kts:kte, 2), INTENT(INOUT) :: qci
510 REAL, DIMENSION(its:ite, kts:kte, 3), INTENT(INOUT) :: qrs
511 REAL, DIMENSION(ims:ime, kms:kme), INTENT(INOUT) :: q
512 REAL, DIMENSION(ims:ime, kms:kme), INTENT(IN) :: den, p, delz
513 REAL, INTENT(IN) :: delt
514 REAL, DIMENSION(ims:ime), INTENT(INOUT) :: rain, rainncv
516 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, rslope, rslope2, &
517 & rslope3, rslopeb, falk, fall, work1
518 REAL, DIMENSION(its:ite, kts:kte) :: pracw, psacw, pgacw, pgacr, &
519 & pgacs, psaci, praci, piacr, pracs, psacr, pgaci, pseml, pgeml, fallc&
520 & , praut, psaut, pgaut, prevp, psdep, pgdep
521 REAL, DIMENSION(its:ite, kts:kte) :: pigen, pidep, pcond, xl, cpm, &
522 & psevp, xni, pgevp, n0sfac, work2
523 ! LOGICAL, DIMENSION( its:ite ) :: flgcld
524 REAL :: dtcld, temp, temp0, supcol, supsat, satdt, eacrs, xmi, &
525 & diameter, delta2, delta3
526 INTEGER :: i, k, loop, loops
527 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
528 & qs10, qs11, qs20, qs21
529 REAL :: fq, fqc, fqi, fqr, fqs, fqg, fallsum
533 !=================================================================
536 !----------------------------------------------------------------
537 ! paddint 0 for negative values generated by dynamics
541 IF (q(i, k) .LT. 0.) THEN
546 IF (qci(i, k, 1) .LT. 0.) THEN
549 qci(i, k, 1) = qci(i, k, 1)
551 IF (qrs(i, k, 1) .LT. 0.) THEN
554 qrs(i, k, 1) = qrs(i, k, 1)
556 IF (qci(i, k, 2) .LT. 0.) THEN
559 qci(i, k, 2) = qci(i, k, 2)
561 IF (qrs(i, k, 2) .LT. 0.) THEN
564 qrs(i, k, 2) = qrs(i, k, 2)
566 IF (qrs(i, k, 3) .LT. 0.) THEN
569 qrs(i, k, 3) = qrs(i, k, 3)
573 x1 = NINT(delt/dtcldcr)
580 IF (delt .LE. dtcldcr) dtcld = delt
584 !----------------------------------------------------------------
585 ! initialize the variables for microphysical physics
586 CALL INIMP(prevp, psdep, pgdep, praut, psaut, pgaut, pracw, praci&
587 & , piacr, psaci, psacw, pracs, psacr, pgacw, pgaci, pgacr, &
588 & pgacs, pigen, pidep, pcond, pseml, pgeml, psevp, pgevp, falk&
589 & , fall, fallc, xni, kts, kte, its, ite)
590 !----------------------------------------------------------------
591 ! compute the fallout term:
592 ! first, vertical terminal velosity for minor loops
593 CALL FALLK(cpm, t, p, q, den, qrs, delz, dtcld, falk, fall, kte, &
594 & kts, its, ite, kme, kms, ims, ime)
595 CALL FALLKC(qci, fallc, den, delz, dtcld, kte, kts, its, ite, kme&
597 CALL RAINSC(fall, fallc, xl, t, q, qci, cpm, den, qrs, delz, rain&
598 & , rainncv, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
599 CALL WARMR(t, q, qci, qrs, den, p, dtcld, xl, rh, qs, praut, pracw&
600 & , prevp, ims, ime, kms, kme, its, ite, kts, kte)
602 ! cold rain processes
605 CALL ACCRET1(qci, den, qrs, t, q, dtcld, praci, piacr, psaci, &
606 & pgaci, psacw, pgacw, ims, ime, kms, kme, its, ite, kts, kte&
608 CALL ACCRET2(qrs, t, q, den, dtcld, psacw, pgacw, pracs, psacr, &
609 & pgacr, pgacs, pseml, pgeml, ims, ime, kms, kme, its, ite, &
611 CALL ACCRET3(qrs, qci, rh, t, p, den, dtcld, q, qs, psdep, pgdep, &
612 & pigen, psaut, pgaut, psevp, pgevp, pidep, ims, ime, kms, &
613 & kme, its, ite, kts, kte)
614 CALL PCONADD(t, p, q, qci, qs, xl, cpm, dtcld, kte, kts, its, ite&
615 & , kme, kms, ims, ime)
617 END SUBROUTINE WSM62D
619 ! Differentiation of calcrh in forward (tangent) mode (with options r8):
620 ! variations of useful results: qs rh
621 ! with respect to varying inputs: p q t qs rh
622 !=======================================================================
624 !=======================================================================
625 SUBROUTINE G_CALCRH(t, g_t, p, g_p, q, g_q, rh, g_rh, qs, g_qs)
627 REAL, INTENT(IN) :: t, q, p
628 REAL, INTENT(IN) :: g_t, g_q, g_p
629 REAL, DIMENSION(3), INTENT(OUT) :: rh, qs
630 REAL, DIMENSION(3), INTENT(OUT) :: g_rh, g_qs
631 REAL :: tr, qs10, qs11, qs20, qs21
632 REAL :: g_tr, g_qs10, g_qs11, g_qs20, g_qs21
633 REAL, PARAMETER :: hsub=xls
634 REAL, PARAMETER :: hvap=xlv0
635 REAL, PARAMETER :: cvap=cpv
636 REAL, PARAMETER :: ttp=t0c+0.01
637 REAL, PARAMETER :: dldt=cvap-cliq
638 REAL, PARAMETER :: xa=-(dldt/rv)
639 REAL, PARAMETER :: xb=xa+hvap/(rv*ttp)
640 REAL, PARAMETER :: dldti=cvap-cice
641 REAL, PARAMETER :: xai=-(dldti/rv)
642 REAL, PARAMETER :: xbi=xai+hsub/(rv*ttp)
654 g_tr = -(ttp*g_t/t**2)
658 temp = EXP(xb*(-tr+1.))
660 g_qs10 = psat*(temp*EXP(arg1)*g_arg1-temp0*EXP(xb*(1.-tr))*xb*g_tr)
661 qs10 = psat*(temp0*temp)
662 temp0 = qs10/(p-qs10)
663 g_qs11 = ep2*(g_qs10-temp0*(g_p-g_qs10))/(p-qs10)
667 IF (qs(1) .LT. qmin) THEN
674 g_rh(1) = (g_q-q*g_max1/max1)/max1
678 temp0 = EXP(xbi*(-tr+1.))
680 g_qs20 = psat*(temp0*EXP(arg1)*g_arg1-temp*EXP(xbi*(1.-tr))*xbi*g_tr&
682 qs20 = psat*(temp*temp0)
683 temp0 = qs20/(p-qs20)
684 g_qs21 = ep2*(g_qs20-temp0*(g_p-g_qs20))/(p-qs20)
688 IF (qs(2) .LT. qmin) THEN
695 g_rh(2) = (g_q-q*g_max2/max2)/max2
697 END SUBROUTINE G_CALCRH
699 !=======================================================================
701 !=======================================================================
702 SUBROUTINE CALCRH(t, p, q, rh, qs)
704 REAL, INTENT(IN) :: t, q, p
705 REAL, DIMENSION(3), INTENT(OUT) :: rh, qs
706 REAL :: tr, qs10, qs11, qs20, qs21
707 REAL, PARAMETER :: hsub=xls
708 REAL, PARAMETER :: hvap=xlv0
709 REAL, PARAMETER :: cvap=cpv
710 REAL, PARAMETER :: ttp=t0c+0.01
711 REAL, PARAMETER :: dldt=cvap-cliq
712 REAL, PARAMETER :: xa=-(dldt/rv)
713 REAL, PARAMETER :: xb=xa+hvap/(rv*ttp)
714 REAL, PARAMETER :: dldti=cvap-cice
715 REAL, PARAMETER :: xai=-(dldti/rv)
716 REAL, PARAMETER :: xbi=xai+hsub/(rv*ttp)
725 qs10 = psat*EXP(arg1)*EXP(xb*(1.-tr))
726 qs11 = ep2*qs10/(p-qs10)
728 IF (qs(1) .LT. qmin) THEN
735 qs20 = psat*EXP(arg1)*EXP(xbi*(1.-tr))
736 qs21 = ep2*qs20/(p-qs20)
738 IF (qs(2) .LT. qmin) THEN
744 END SUBROUTINE CALCRH
747 !=======================================================================
749 !=======================================================================
750 SUBROUTINE WSM6RINIT()
761 !-------------------------------------------------------------------
762 !.... constants which may not be tunable
766 qc0 = 4./3.*pi*denr*r0**3*xncr/den0
771 qck1 = .104*9.8*peaut/pwr1/xmyu*pwr2
773 bvtr2 = 2.5 + .5*bvtr
783 g5pbro2 = RGMMA(bvtr2)
785 roqimax = 2.08e22*dimax**8
788 bvts2 = 2.5 + .5*bvts
796 g5pbso2 = RGMMA(bvts2)
801 bvtg2 = 2.5 + .5*bvtg
807 g5pbgo2 = RGMMA(bvtg2)
813 vt2r_a = pvtr*pwr1*result1
817 vt2s_a = pvts*pwr1*result1
821 vt2g_a = pvtg*pwr1*result1
827 result1 = SQRT(pidn0r)
828 prevp_a = 1.56*pi*n0r/result1
830 pwy1 = -((5.+bvtr)/8.)
833 result3 = SQRT(result2)
834 prevp_b = 130.37*pi*result1*n0r*pwr1*result3*g5pbro2
835 result1 = SQRT(pidn0s)
836 psdep_a = 2.6*n0s/result1
838 pwy1 = -((5.+bvts)/8.)
841 result3 = SQRT(result2)
842 psdep_b = 370.08*result1*n0s*pwr1*result3*g5pbso2
845 result1 = SQRT(pidn0g)
846 pgdep_a = 1.56*pi*n0g/result1
848 pwy1 = -((5.+bvtg)/8.)
851 result3 = SQRT(result2)
852 pgdep_b = 130.37*pi*result1*n0g*pwr1*result3*g5pbgo2
855 result1 = SQRT(pidn0s)
856 psmlt_a = 2.75e-3*pi*n0s/result1/xlf0
858 result2 = SQRT(result1)
860 pwy1 = -((5.+bvts)/8.)
862 psmlt_b = 0.391*pi*n0s*result2*result3*pwr1*g5pbso2/xlf0
863 result1 = SQRT(pidn0g)
864 pgmlt_a = 3.3e-3*pi*n0g/result1/xlf0
866 result2 = SQRT(result1)
868 pwy1 = -((5.+bvtg)/8.)
870 pgmlt_b = 0.276*pi*n0g*result2*result3*pwr1*g5pbgo2/xlf0
872 pwr1 = pidn0r**(3./4.)
874 result1 = SQRT(pidn0r)
875 praci_c = 3.245e-3/result1
876 result1 = SQRT(pidn0r)
877 result2 = SQRT(result1)
878 praci_d = 2.633e-6/result2
880 pwr1 = pidn0s**(3./4.)
882 result1 = SQRT(pidn0s)
883 psaci_c = 3.245e-3/result1
884 result1 = SQRT(pidn0s)
885 result2 = SQRT(result1)
886 psaci_d = 2.633e-6/result2
888 pwr1 = pidn0g**(3./4.)
890 result1 = SQRT(pidn0g)
891 pgaci_c = 3.245e-3/result1
892 result1 = SQRT(pidn0g)
893 result2 = SQRT(result1)
894 pgaci_d = 2.633e-6/result2
895 pracs_a = pi*n0r*pidn0s
896 pwr1 = pidn0s**(3./2.)
897 result1 = SQRT(pidn0r)
898 result2 = SQRT(result1)
899 pracs_b = 5./pwr1/result2
900 pwr1 = pidn0s**(5./4.)
901 result1 = SQRT(pidn0r)
902 pracs_c = 2./pwr1/result1
903 pwr1 = pidn0r**(3./4.)
904 pracs_d = .5/pidn0s/pwr1
905 psacr_a = pi*n0s*pidn0r
906 pwr1 = pidn0r**(3./2.)
907 result1 = SQRT(pidn0s)
908 result2 = SQRT(result1)
909 psacr_b = 5./pwr1/result2
910 pwr1 = pidn0r**(5./4.)
911 result1 = SQRT(pidn0s)
912 psacr_c = 2./pwr1/result1
913 pwr1 = pidn0s**(3./4.)
914 psacr_d = .5/pidn0r/pwr1
915 pgacr_a = pi*n0g*pidn0r
916 pwr1 = pidn0r**(3./2.)
917 result1 = SQRT(pidn0g)
918 result2 = SQRT(result1)
919 pgacr_b = 5./pwr1/result2
920 pwr1 = pidn0r**(5./4.)
921 result1 = SQRT(pidn0g)
922 pgacr_c = 2./pwr1/result1
923 pwr1 = pidn0g**(3./4.)
924 pgacr_d = .5/pidn0r/pwr1
925 pgacs_a = pi*n0g*pidn0s
926 pwr1 = pidn0s**(3./2.)
927 result1 = SQRT(pidn0g)
928 result2 = SQRT(result1)
929 pgacs_b = 5./pwr1/result2
930 pwr1 = pidn0s**(5./4.)
931 result1 = SQRT(pidn0g)
932 pgacs_c = 2./pwr1/result1
933 pwr1 = pidn0g**(3./4.)
934 pgacs_d = .5/pidn0s/pwr1
938 pwr1 = pidn0r**(3./4.)
939 pgfrz_a = 20.*pi*pfrz1/pwr1
941 pwy1 = -((6.+bvtr)/4.)
943 piacr_a = 5.38e7*pi*avtr*pidn0r*g6pbr*result1*pwr1/24.
945 pwy1 = -((3.+bvtr)/4.)
947 pracw_a = .25*pi*avtr*n0r*g3pbr*result1*pwr1
949 pwy1 = -((3.+bvts)/4.)
951 psacw_a = .25*pi*avts*n0s*g3pbs*result1*pwr1
953 pwy1 = -((3.+bvtg)/4.)
955 pgacw_a = .25*pi*avtg*n0g*g3pbg*result1*pwr1
956 END SUBROUTINE WSM6RINIT
958 ! Differentiation of inimp in forward (tangent) mode (with options r8):
959 ! variations of useful results: fallc piacr psaci pgaci psacr
960 ! praci psacw pgacr pgacs pracs pgacw pigen pracw
961 ! psevp pidep falk fall pgevp prevp psdep pseml
962 ! pgdep pgeml psaut pgaut praut
963 ! with respect to varying inputs: fallc piacr psaci pgaci psacr
964 ! praci psacw pgacr pgacs pracs pgacw pigen pracw
965 ! psevp pidep falk fall pgevp prevp psdep pseml
966 ! pgdep pgeml psaut pgaut praut
967 !=======================================================================
969 !=======================================================================
970 SUBROUTINE G_INIMP(prevp, g_prevp, psdep, g_psdep, pgdep, g_pgdep, &
971 & praut, g_praut, psaut, g_psaut, pgaut, g_pgaut, pracw, g_pracw, &
972 & praci, g_praci, piacr, g_piacr, psaci, g_psaci, psacw, g_psacw, &
973 & pracs, g_pracs, psacr, g_psacr, pgacw, g_pgacw, pgaci, g_pgaci, &
974 & pgacr, g_pgacr, pgacs, g_pgacs, pigen, g_pigen, pidep, g_pidep, &
975 & pcond, pseml, g_pseml, pgeml, g_pgeml, psevp, g_psevp, pgevp, &
976 & g_pgevp, falk, g_falk, fall, g_fall, fallc, g_fallc, xni, kts, kte, &
979 INTEGER :: kts, kte, its, ite, k, i
980 REAL, DIMENSION(its:ite, kts:kte, 3) :: falk, fall
981 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_falk, g_fall
982 REAL, DIMENSION(its:ite, kts:kte) :: xni, pgevp, pigen, pidep, pcond&
983 & , fallc, pracw, psacw, pgacw, pgacr, pgacs, psaci, praci, piacr, &
984 & pracs, psacr, pgaci, pseml, pgeml, psevp, praut, psaut, pgaut, prevp&
986 REAL, DIMENSION(its:ite, kts:kte) :: g_pgevp, g_pigen, g_pidep, &
987 & g_fallc, g_pracw, g_psacw, g_pgacw, g_pgacr, g_pgacs, g_psaci, &
988 & g_praci, g_piacr, g_pracs, g_psacr, g_pgaci, g_pseml, g_pgeml, &
989 & g_psevp, g_praut, g_psaut, g_pgaut, g_prevp, g_psdep, g_pgdep
992 g_prevp(i, k) = 0.0_8
994 g_psdep(i, k) = 0.0_8
996 g_pgdep(i, k) = 0.0_8
998 g_praut(i, k) = 0.0_8
1000 g_psaut(i, k) = 0.0_8
1002 g_pgaut(i, k) = 0.0_8
1004 g_pracw(i, k) = 0.0_8
1006 g_praci(i, k) = 0.0_8
1008 g_piacr(i, k) = 0.0_8
1010 g_psaci(i, k) = 0.0_8
1012 g_psacw(i, k) = 0.0_8
1014 g_pracs(i, k) = 0.0_8
1016 g_psacr(i, k) = 0.0_8
1018 g_pgacw(i, k) = 0.0_8
1020 g_pgaci(i, k) = 0.0_8
1022 g_pgacr(i, k) = 0.0_8
1024 g_pgacs(i, k) = 0.0_8
1026 g_pigen(i, k) = 0.0_8
1028 g_pidep(i, k) = 0.0_8
1031 g_pseml(i, k) = 0.0_8
1033 g_pgeml(i, k) = 0.0_8
1035 g_psevp(i, k) = 0.0_8
1037 g_pgevp(i, k) = 0.0_8
1039 g_falk(i, k, 1) = 0.0_8
1041 g_falk(i, k, 2) = 0.0_8
1043 g_falk(i, k, 3) = 0.0_8
1045 g_fall(i, k, 1) = 0.0_8
1047 g_fall(i, k, 2) = 0.0_8
1049 g_fall(i, k, 3) = 0.0_8
1051 g_fallc(i, k) = 0.0_8
1056 END SUBROUTINE G_INIMP
1058 !=======================================================================
1060 !=======================================================================
1061 SUBROUTINE INIMP(prevp, psdep, pgdep, praut, psaut, pgaut, pracw, &
1062 & praci, piacr, psaci, psacw, pracs, psacr, pgacw, pgaci, pgacr, pgacs&
1063 & , pigen, pidep, pcond, pseml, pgeml, psevp, pgevp, falk, fall, fallc&
1064 & , xni, kts, kte, its, ite)
1066 INTEGER :: kts, kte, its, ite, k, i
1067 REAL, DIMENSION(its:ite, kts:kte, 3) :: falk, fall
1068 REAL, DIMENSION(its:ite, kts:kte) :: xni, pgevp, pigen, pidep, pcond&
1069 & , fallc, pracw, psacw, pgacw, pgacr, pgacs, psaci, praci, piacr, &
1070 & pracs, psacr, pgaci, pseml, pgeml, psevp, praut, psaut, pgaut, prevp&
1108 END SUBROUTINE INIMP
1110 ! Differentiation of fallk in forward (tangent) mode (with options r8):
1111 ! variations of useful results: t cpm qrs falk fall
1112 ! with respect to varying inputs: p q t cpm delz den qrs falk
1114 !=======================================================================
1116 !=======================================================================
1117 SUBROUTINE G_FALLK(cpm, g_cpm, t, g_t, p, g_p, q, g_q, den, g_den, qrs&
1118 & , g_qrs, delz, g_delz, dtcld, falk, g_falk, fall, g_fall, kte, kts, &
1119 & its, ite, kme, kms, ims, ime)
1121 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
1122 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, falk, fall, work1
1123 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs, g_falk, g_fall, &
1125 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, p, q
1126 REAL, DIMENSION(ims:ime, kms:kme) :: g_delz, g_den, g_p, g_q
1127 REAL, DIMENSION(its:ite, kts:kte) :: psmlt, pgmlt, t, work2, cpm
1128 REAL, DIMENSION(its:ite, kts:kte) :: g_psmlt, g_pgmlt, g_t, g_cpm
1129 INTEGER, DIMENSION(its:ite) :: mstep, numdt
1130 REAL :: dtcld, coeres1, coeres2, coeresi, coeresh, xlf, psmlt0, &
1131 & pgmlt0, help_i, help_h, w1
1132 REAL :: g_psmlt0, g_pgmlt0
1133 REAL :: tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8
1134 REAL :: g_tmp1, g_tmp2, g_tmp3, g_tmp4, g_tmp5, g_tmp6, g_tmp7, &
1136 INTEGER :: mstepmax, k, i, n, nw, jj
1137 REAL :: fqs, fqg, supcol, a, b, c, d
1138 REAL :: g_a, g_b, g_c, g_d
1200 IF (qcrmin .LT. qrs(i, k, 1)) THEN
1201 g_max1 = g_qrs(i, k, 1)
1208 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
1212 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
1214 pwr1 = den(i, k)**pwy1
1216 IF (max1 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
1220 g_pwr2 = pwy2*max1**(pwy2-1)*g_max1
1223 temp = pwr1*pwr2/delz(i, k)
1224 g_work1(i, k, 1) = vt2r_a*(pwr2*g_pwr1+pwr1*g_pwr2-temp*g_delz(i&
1226 work1(i, k, 1) = vt2r_a*temp
1227 IF (qcrmin .LT. qrs(i, k, 2)) THEN
1228 g_max2 = g_qrs(i, k, 2)
1234 IF (90. .GT. t0c - t(i, k)) THEN
1241 IF (0. .LT. y3) THEN
1249 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
1253 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
1255 pwr1 = den(i, k)**pwy1
1257 IF (max2 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
1261 g_pwr2 = pwy2*max2**(pwy2-1)*g_max2
1264 g_arg1 = -(bvts*alpha*g_max8/4.)
1265 arg1 = -(bvts*alpha*max8/4.)
1267 temp0 = pwr1*pwr2/delz(i, k)
1268 g_work1(i, k, 2) = vt2s_a*(temp*(pwr2*g_pwr1+pwr1*g_pwr2-temp0*&
1269 & g_delz(i, k))/delz(i, k)+temp0*EXP(arg1)*g_arg1)
1270 work1(i, k, 2) = vt2s_a*(temp0*temp)
1271 IF (qcrmin .LT. qrs(i, k, 3)) THEN
1272 g_max3 = g_qrs(i, k, 3)
1279 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
1283 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
1285 pwr1 = den(i, k)**pwy1
1287 IF (max3 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
1291 g_pwr2 = pwy2*max3**(pwy2-1)*g_max3
1294 temp0 = pwr1*pwr2/delz(i, k)
1295 g_work1(i, k, 3) = vt2g_a*(pwr2*g_pwr1+pwr1*g_pwr2-temp0*g_delz(&
1297 work1(i, k, 3) = vt2g_a*temp0
1298 IF (work1(i, k, 1) .GE. work1(i, k, 2) .AND. work1(i, k, 1) .GE.&
1299 & work1(i, k, 3)) THEN
1301 ELSE IF (work1(i, k, 2) .GE. work1(i, k, 1) .AND. work1(i, k, 2)&
1302 & .GE. work1(i, k, 3)) THEN
1307 nw = NINT(w1*dtcld + .5)
1313 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
1317 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
1323 IF (n .LE. mstep(i)) THEN
1325 temp0 = qrs(i, k, 1)*work1(i, k, 1)
1326 temp = den(i, k)/mstep(i)
1327 g_falk(i, k, 1) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i, &
1328 & k, 1)*g_qrs(i, k, 1)+qrs(i, k, 1)*g_work1(i, k, 1))
1329 falk(i, k, 1) = temp*temp0
1330 temp0 = qrs(i, k, 2)*work1(i, k, 2)
1331 temp = den(i, k)/mstep(i)
1332 g_falk(i, k, 2) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i, &
1333 & k, 2)*g_qrs(i, k, 2)+qrs(i, k, 2)*g_work1(i, k, 2))
1334 falk(i, k, 2) = temp*temp0
1335 temp0 = qrs(i, k, 3)*work1(i, k, 3)
1336 temp = den(i, k)/mstep(i)
1337 g_falk(i, k, 3) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i, &
1338 & k, 3)*g_qrs(i, k, 3)+qrs(i, k, 3)*g_work1(i, k, 3))
1339 falk(i, k, 3) = temp*temp0
1340 g_fall(i, k, 1) = g_fall(i, k, 1) + g_falk(i, k, 1)
1341 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
1342 g_fall(i, k, 2) = g_fall(i, k, 2) + g_falk(i, k, 2)
1343 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
1344 g_fall(i, k, 3) = g_fall(i, k, 3) + g_falk(i, k, 3)
1345 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
1347 temp0 = falk(i, k, jj)/den(i, k)
1348 g_x1 = dtcld*(g_falk(i, k, jj)-temp0*g_den(i, k))/den(i, k)
1350 IF (x1 .GT. qrs(i, k, jj)) THEN
1351 g_tmp1 = g_qrs(i, k, jj)
1352 tmp1 = qrs(i, k, jj)
1357 IF (tmp1 .GE. 0.) THEN
1362 IF (abs0 .LT. qmin) THEN
1366 g_qrs(i, k, jj) = g_qrs(i, k, jj) - g_tmp1
1367 qrs(i, k, jj) = qrs(i, k, jj) - tmp1
1373 IF (n .LE. mstep(i)) THEN
1374 temp0 = qrs(i, k, 1)*work1(i, k, 1)
1375 temp = den(i, k)/mstep(i)
1376 g_falk(i, k, 1) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i&
1377 & , k, 1)*g_qrs(i, k, 1)+qrs(i, k, 1)*g_work1(i, k, 1))
1378 falk(i, k, 1) = temp*temp0
1379 temp0 = qrs(i, k, 2)*work1(i, k, 2)
1380 temp = den(i, k)/mstep(i)
1381 g_falk(i, k, 2) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i&
1382 & , k, 2)*g_qrs(i, k, 2)+qrs(i, k, 2)*g_work1(i, k, 2))
1383 falk(i, k, 2) = temp*temp0
1384 temp0 = qrs(i, k, 3)*work1(i, k, 3)
1385 temp = den(i, k)/mstep(i)
1386 g_falk(i, k, 3) = temp0*g_den(i, k)/mstep(i) + temp*(work1(i&
1387 & , k, 3)*g_qrs(i, k, 3)+qrs(i, k, 3)*g_work1(i, k, 3))
1388 falk(i, k, 3) = temp*temp0
1389 g_fall(i, k, 1) = g_fall(i, k, 1) + g_falk(i, k, 1)
1390 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
1391 g_fall(i, k, 2) = g_fall(i, k, 2) + g_falk(i, k, 2)
1392 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
1393 g_fall(i, k, 3) = g_fall(i, k, 3) + g_falk(i, k, 3)
1394 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
1396 IF ((falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/delz(i, &
1397 & k))*dtcld/den(i, k) .GT. qrs(i, k, jj)) THEN
1398 g_tmp2 = g_qrs(i, k, jj)
1399 tmp2 = qrs(i, k, jj)
1401 temp0 = delz(i, k+1)/delz(i, k)
1402 temp = (falk(i, k, jj)-falk(i, k+1, jj)*temp0)/den(i, k)
1403 g_tmp2 = dtcld*(g_falk(i, k, jj)-temp0*g_falk(i, k+1, jj&
1404 & )-falk(i, k+1, jj)*(g_delz(i, k+1)-temp0*g_delz(i, k))&
1405 & /delz(i, k)-temp*g_den(i, k))/den(i, k)
1408 IF (tmp2 .GE. 0.) THEN
1413 IF (abs1 .LT. qmin) THEN
1417 g_qrs(i, k, jj) = g_qrs(i, k, jj) - g_tmp2
1418 qrs(i, k, jj) = qrs(i, k, jj) - tmp2
1425 IF (n .LE. mstep(i)) THEN
1427 !---------------------------------------------------------------
1428 ! psmlt: melting of snow [RH83 A25]
1429 ! (T>T0: S->R) psmlt<0: min=-qrs(i,k,2), max=0
1430 !---------------------------------------------------------------
1432 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
1434 IF (90. .GT. t0c - t(i, k)) THEN
1441 IF (0. .LT. y1) THEN
1448 temp0 = alpha*max4/2.
1449 g_a = EXP(temp0)*alpha*g_max4/2.
1451 IF (90. .GT. t0c - t(i, k)) THEN
1458 IF (0. .LT. y2) THEN
1465 g_arg1 = alpha*(3-bvts)*g_max5/8.
1466 arg1 = alpha*max5*(3-bvts)/8.
1467 g_b = EXP(arg1)*g_arg1
1469 temp0 = (t0c-t(i, k))/(t(i, k)+120.)
1471 g_c = (temp0*1.5*t(i, k)**0.5-temp*(temp0+1.0)/(t(i, k)+120.&
1474 IF (t(i, k) .LE. 0.0_8 .AND. (3.88/6. .EQ. 0.0_8 .OR. 3.88/&
1475 & 6. .NE. INT(3.88/6.))) THEN
1478 g_pwr1 = 3.88*t(i, k)**(3.88/6.-1)*g_t(i, k)/6.
1480 pwr1 = t(i, k)**(3.88/6.)
1482 pwx2 = t(i, k) + 120.
1483 IF (pwx2 .LE. 0.0_8 .AND. (5./6. .EQ. 0.0_8 .OR. 5./6. .NE. &
1487 g_pwr2 = 5.*pwx2**(5./6.-1)*g_pwx2/6.
1489 pwr2 = pwx2**(5./6.)
1491 g_d = (t0c-t(i, k))*(g_pwr1-temp0*g_pwr2)/pwr2 - temp0*g_t(i&
1493 d = (t0c-t(i, k))*temp0
1494 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1498 g_max6 = g_qrs(i, k, 2)
1501 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1505 g_max9 = g_qrs(i, k, 2)
1508 g_arg1 = max6*g_den(i, k) + den(i, k)*g_max6
1509 arg1 = den(i, k)*max6
1511 IF (arg1 .EQ. 0.0_8) THEN
1514 g_result1 = g_arg1/(2.0*temp0)
1517 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. &
1518 & .NE. INT(1.0/3.))) THEN
1521 g_pwr1 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
1523 pwr1 = p(i, k)**(1./3.)
1524 pwy2 = (13.+3*bvts)/24.
1525 IF (den(i, k) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
1526 & .NE. INT(pwy2))) THEN
1529 g_pwr2 = pwy2*den(i, k)**(pwy2-1)*g_den(i, k)
1531 pwr2 = den(i, k)**pwy2
1533 IF (max9 .LE. 0.0_8 .AND. (pwy3 .EQ. 0.0_8 .OR. pwy3 .NE. &
1537 g_pwr3 = pwy3*max9**(pwy3-1)*g_max9
1541 g_psmlt0 = psmlt_a*(result1*(c*g_a+a*g_c)+a*c*g_result1) + &
1542 & psmlt_b*(pwr1*pwr2*(pwr3*(d*g_b+b*g_d)+b*d*g_pwr3)+temp0*(&
1543 & pwr2*g_pwr1+pwr1*g_pwr2))
1544 psmlt0 = psmlt_a*(a*c*result1) + psmlt_b*(temp0*(pwr1*pwr2))
1545 g_tmp3 = dtcld*g_psmlt0/mstep(i)
1546 tmp3 = psmlt0*dtcld/mstep(i)
1547 g_tmp4 = -(g_qrs(i, k, 2)/mstep(i))
1548 tmp4 = -(qrs(i, k, 2)/mstep(i))
1549 IF (tmp3 .GT. tmp4) THEN
1556 IF (tmp5 .LT. 0.) THEN
1557 g_psmlt(i, k) = g_tmp5
1560 g_psmlt(i, k) = 0.0_8
1563 IF (psmlt(i, k) .GE. 0.) THEN
1568 IF (abs2 .LT. qmin) THEN
1569 g_psmlt(i, k) = 0.0_8
1572 IF (qrs(i, k, 2) + psmlt(i, k) .LT. 0.) THEN
1573 g_qrs(i, k, 2) = 0.0_8
1576 g_qrs(i, k, 2) = g_qrs(i, k, 2) + g_psmlt(i, k)
1577 qrs(i, k, 2) = qrs(i, k, 2) + psmlt(i, k)
1579 IF (qrs(i, k, 1) - psmlt(i, k) .LT. 0.) THEN
1580 g_qrs(i, k, 1) = 0.0_8
1583 g_qrs(i, k, 1) = g_qrs(i, k, 1) - g_psmlt(i, k)
1584 qrs(i, k, 1) = qrs(i, k, 1) - psmlt(i, k)
1586 temp0 = psmlt(i, k)/cpm(i, k)
1587 g_t(i, k) = g_t(i, k) + xlf*(g_psmlt(i, k)-temp0*g_cpm(i, k)&
1589 t(i, k) = t(i, k) + xlf*temp0
1593 !---------------------------------------------------------------
1594 ! pgmlt: melting of graupel [LFO 47]
1595 ! (T>T0: G->R) pgmlt<0: min=-qrs(i,k,3), max=0
1596 !---------------------------------------------------------------
1599 IF (n .LE. mstep(i)) THEN
1602 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
1603 temp0 = (t0c-t(i, k))/(t(i, k)+120.)
1605 g_c = (temp0*1.5*t(i, k)**0.5-temp*(temp0+1.0)/(t(i, k)+120.&
1608 IF (t(i, k) .LE. 0.0_8 .AND. (3.88/6. .EQ. 0.0_8 .OR. 3.88/&
1609 & 6. .NE. INT(3.88/6.))) THEN
1612 g_pwr1 = 3.88*t(i, k)**(3.88/6.-1)*g_t(i, k)/6.
1614 pwr1 = t(i, k)**(3.88/6.)
1616 pwx2 = t(i, k) + 120.
1617 IF (pwx2 .LE. 0.0_8 .AND. (5./6. .EQ. 0.0_8 .OR. 5./6. .NE. &
1621 g_pwr2 = 5.*pwx2**(5./6.-1)*g_pwx2/6.
1623 pwr2 = pwx2**(5./6.)
1625 g_d = (t0c-t(i, k))*(g_pwr1-temp0*g_pwr2)/pwr2 - temp0*g_t(i&
1627 d = (t0c-t(i, k))*temp0
1628 IF (qrs(i, k, 3) .LT. qcrmin) THEN
1632 g_max7 = g_qrs(i, k, 3)
1635 IF (qrs(i, k, 3) .LT. qcrmin) THEN
1639 g_max10 = g_qrs(i, k, 3)
1640 max10 = qrs(i, k, 3)
1642 g_arg1 = max7*g_den(i, k) + den(i, k)*g_max7
1643 arg1 = den(i, k)*max7
1645 IF (arg1 .EQ. 0.0_8) THEN
1648 g_result1 = g_arg1/(2.0*temp0)
1651 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. &
1652 & .NE. INT(1.0/3.))) THEN
1655 g_pwr1 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
1657 pwr1 = p(i, k)**(1./3.)
1658 pwy2 = (13.+3*bvtg)/24.
1659 IF (den(i, k) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
1660 & .NE. INT(pwy2))) THEN
1663 g_pwr2 = pwy2*den(i, k)**(pwy2-1)*g_den(i, k)
1665 pwr2 = den(i, k)**pwy2
1667 IF (max10 .LE. 0.0_8 .AND. (pwy3 .EQ. 0.0_8 .OR. pwy3 .NE. &
1671 g_pwr3 = pwy3*max10**(pwy3-1)*g_max10
1674 g_pgmlt0 = pgmlt_a*(result1*g_c+c*g_result1) + pgmlt_b*(pwr2&
1675 & *pwr3*(pwr1*g_d+d*g_pwr1)+d*pwr1*(pwr3*g_pwr2+pwr2*g_pwr3)&
1677 pgmlt0 = pgmlt_a*c*result1 + pgmlt_b*d*pwr1*pwr2*pwr3
1678 g_tmp6 = dtcld*g_pgmlt0/mstep(i)
1679 tmp6 = pgmlt0*dtcld/mstep(i)
1680 g_tmp7 = -(g_qrs(i, k, 3)/mstep(i))
1681 tmp7 = -(qrs(i, k, 3)/mstep(i))
1682 IF (tmp6 .GT. tmp7) THEN
1689 IF (tmp8 .LT. 0.) THEN
1690 g_pgmlt(i, k) = g_tmp8
1693 g_pgmlt(i, k) = 0.0_8
1696 IF (pgmlt(i, k) .GE. 0.) THEN
1701 IF (abs3 .LT. qmin) THEN
1702 g_pgmlt(i, k) = 0.0_8
1705 IF (qrs(i, k, 3) + pgmlt(i, k) .LT. 0.) THEN
1706 g_qrs(i, k, 3) = 0.0_8
1709 g_qrs(i, k, 3) = g_qrs(i, k, 3) + g_pgmlt(i, k)
1710 qrs(i, k, 3) = qrs(i, k, 3) + pgmlt(i, k)
1712 IF (qrs(i, k, 1) - pgmlt(i, k) .LT. 0.) THEN
1713 g_qrs(i, k, 1) = 0.0_8
1716 g_qrs(i, k, 1) = g_qrs(i, k, 1) - g_pgmlt(i, k)
1717 qrs(i, k, 1) = qrs(i, k, 1) - pgmlt(i, k)
1719 temp0 = pgmlt(i, k)/cpm(i, k)
1720 g_t(i, k) = g_t(i, k) + xlf*(g_pgmlt(i, k)-temp0*g_cpm(i, k)&
1722 t(i, k) = t(i, k) + xlf*temp0
1727 END SUBROUTINE G_FALLK
1729 !=======================================================================
1731 !=======================================================================
1732 SUBROUTINE FALLK(cpm, t, p, q, den, qrs, delz, dtcld, falk, fall, kte&
1733 & , kts, its, ite, kme, kms, ims, ime)
1735 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
1736 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, falk, fall, work1
1737 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, p, q
1738 REAL, DIMENSION(its:ite, kts:kte) :: psmlt, pgmlt, t, work2, cpm
1739 INTEGER, DIMENSION(its:ite) :: mstep, numdt
1740 REAL :: dtcld, coeres1, coeres2, coeresi, coeresh, xlf, psmlt0, &
1741 & pgmlt0, help_i, help_h, w1
1742 REAL :: tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8
1743 INTEGER :: mstepmax, k, i, n, nw, jj
1744 REAL :: fqs, fqg, supcol, a, b, c, d
1783 IF (qcrmin .LT. qrs(i, k, 1)) THEN
1789 pwr1 = den(i, k)**pwy1
1792 work1(i, k, 1) = vt2r_a*pwr1*pwr2/delz(i, k)
1793 IF (qcrmin .LT. qrs(i, k, 2)) THEN
1798 IF (90. .GT. t0c - t(i, k)) THEN
1803 IF (0. .LT. y3) THEN
1809 pwr1 = den(i, k)**pwy1
1812 arg1 = -(bvts*alpha*max8/4.)
1813 work1(i, k, 2) = vt2s_a*pwr1*pwr2/delz(i, k)*EXP(arg1)
1814 IF (qcrmin .LT. qrs(i, k, 3)) THEN
1820 pwr1 = den(i, k)**pwy1
1823 work1(i, k, 3) = vt2g_a*pwr1*pwr2/delz(i, k)
1824 IF (work1(i, k, 1) .GE. work1(i, k, 2) .AND. work1(i, k, 1) .GE.&
1825 & work1(i, k, 3)) THEN
1827 ELSE IF (work1(i, k, 2) .GE. work1(i, k, 1) .AND. work1(i, k, 2)&
1828 & .GE. work1(i, k, 3)) THEN
1833 nw = NINT(w1*dtcld + .5)
1839 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
1843 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
1847 IF (n .LE. mstep(i)) THEN
1849 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(i)
1850 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(i)
1851 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(i)
1852 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
1853 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
1854 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
1856 x1 = falk(i, k, jj)*dtcld/den(i, k)
1857 IF (x1 .GT. qrs(i, k, jj)) THEN
1858 tmp1 = qrs(i, k, jj)
1862 IF (tmp1 .GE. 0.) THEN
1867 IF (abs0 .LT. qmin) tmp1 = 0.
1868 qrs(i, k, jj) = qrs(i, k, jj) - tmp1
1874 IF (n .LE. mstep(i)) THEN
1875 falk(i, k, 1) = den(i, k)*qrs(i, k, 1)*work1(i, k, 1)/mstep(&
1877 falk(i, k, 2) = den(i, k)*qrs(i, k, 2)*work1(i, k, 2)/mstep(&
1879 falk(i, k, 3) = den(i, k)*qrs(i, k, 3)*work1(i, k, 3)/mstep(&
1881 fall(i, k, 1) = fall(i, k, 1) + falk(i, k, 1)
1882 fall(i, k, 2) = fall(i, k, 2) + falk(i, k, 2)
1883 fall(i, k, 3) = fall(i, k, 3) + falk(i, k, 3)
1885 IF ((falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/delz(i, &
1886 & k))*dtcld/den(i, k) .GT. qrs(i, k, jj)) THEN
1887 tmp2 = qrs(i, k, jj)
1889 tmp2 = (falk(i, k, jj)-falk(i, k+1, jj)*delz(i, k+1)/&
1890 & delz(i, k))*dtcld/den(i, k)
1892 IF (tmp2 .GE. 0.) THEN
1897 IF (abs1 .LT. qmin) tmp2 = 0.
1898 qrs(i, k, jj) = qrs(i, k, jj) - tmp2
1905 IF (n .LE. mstep(i)) THEN
1907 !---------------------------------------------------------------
1908 ! psmlt: melting of snow [RH83 A25]
1909 ! (T>T0: S->R) psmlt<0: min=-qrs(i,k,2), max=0
1910 !---------------------------------------------------------------
1912 cpm(i, k) = CPMCAL(q(i, k))
1914 IF (90. .GT. t0c - t(i, k)) THEN
1919 IF (0. .LT. y1) THEN
1924 a = EXP(alpha*max4/2.)
1925 IF (90. .GT. t0c - t(i, k)) THEN
1930 IF (0. .LT. y2) THEN
1935 arg1 = alpha*max5*(3-bvts)/8.
1937 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
1938 pwr1 = t(i, k)**(3.88/6.)
1939 pwx2 = t(i, k) + 120.
1940 pwr2 = pwx2**(5./6.)
1941 d = pwr1*(t0c-t(i, k))/pwr2
1942 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1947 IF (qrs(i, k, 2) .LT. qcrmin) THEN
1952 arg1 = den(i, k)*max6
1953 result1 = SQRT(arg1)
1954 pwr1 = p(i, k)**(1./3.)
1955 pwy2 = (13.+3*bvts)/24.
1956 pwr2 = den(i, k)**pwy2
1959 psmlt0 = psmlt_a*a*c*result1 + psmlt_b*b*d*pwr1*pwr2*pwr3
1960 tmp3 = psmlt0*dtcld/mstep(i)
1961 tmp4 = -(qrs(i, k, 2)/mstep(i))
1962 IF (tmp3 .GT. tmp4) THEN
1967 IF (tmp5 .LT. 0.) THEN
1972 IF (psmlt(i, k) .GE. 0.) THEN
1977 IF (abs2 .LT. qmin) psmlt(i, k) = 0.
1978 IF (qrs(i, k, 2) + psmlt(i, k) .LT. 0.) THEN
1981 qrs(i, k, 2) = qrs(i, k, 2) + psmlt(i, k)
1983 IF (qrs(i, k, 1) - psmlt(i, k) .LT. 0.) THEN
1986 qrs(i, k, 1) = qrs(i, k, 1) - psmlt(i, k)
1988 t(i, k) = t(i, k) + xlf/cpm(i, k)*psmlt(i, k)
1992 !---------------------------------------------------------------
1993 ! pgmlt: melting of graupel [LFO 47]
1994 ! (T>T0: G->R) pgmlt<0: min=-qrs(i,k,3), max=0
1995 !---------------------------------------------------------------
1998 IF (n .LE. mstep(i)) THEN
2001 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
2002 c = t(i, k)**1.5*(t0c-t(i, k))/(t(i, k)+120.)
2003 pwr1 = t(i, k)**(3.88/6.)
2004 pwx2 = t(i, k) + 120.
2005 pwr2 = pwx2**(5./6.)
2006 d = pwr1*(t0c-t(i, k))/pwr2
2007 IF (qrs(i, k, 3) .LT. qcrmin) THEN
2012 IF (qrs(i, k, 3) .LT. qcrmin) THEN
2015 max10 = qrs(i, k, 3)
2017 arg1 = den(i, k)*max7
2018 result1 = SQRT(arg1)
2019 pwr1 = p(i, k)**(1./3.)
2020 pwy2 = (13.+3*bvtg)/24.
2021 pwr2 = den(i, k)**pwy2
2024 pgmlt0 = pgmlt_a*c*result1 + pgmlt_b*d*pwr1*pwr2*pwr3
2025 tmp6 = pgmlt0*dtcld/mstep(i)
2026 tmp7 = -(qrs(i, k, 3)/mstep(i))
2027 IF (tmp6 .GT. tmp7) THEN
2032 IF (tmp8 .LT. 0.) THEN
2037 IF (pgmlt(i, k) .GE. 0.) THEN
2042 IF (abs3 .LT. qmin) pgmlt(i, k) = 0.
2043 IF (qrs(i, k, 3) + pgmlt(i, k) .LT. 0.) THEN
2046 qrs(i, k, 3) = qrs(i, k, 3) + pgmlt(i, k)
2048 IF (qrs(i, k, 1) - pgmlt(i, k) .LT. 0.) THEN
2051 qrs(i, k, 1) = qrs(i, k, 1) - pgmlt(i, k)
2053 t(i, k) = t(i, k) + xlf/cpm(i, k)*pgmlt(i, k)
2058 END SUBROUTINE FALLK
2060 ! Differentiation of fallkc in forward (tangent) mode (with options r8):
2061 ! variations of useful results: fallc qci
2062 ! with respect to varying inputs: fallc delz den qci
2063 !=======================================================================
2065 !=======================================================================
2066 SUBROUTINE G_FALLKC(qci, g_qci, fallc, g_fallc, den, g_den, delz, &
2067 & g_delz, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
2069 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2070 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2071 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
2072 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den
2073 REAL, DIMENSION(ims:ime, kms:kme) :: g_delz, g_den
2074 REAL, DIMENSION(its:ite, kts:kte) :: falkc, work1c, work2c, xni, &
2076 REAL, DIMENSION(its:ite, kts:kte) :: g_falkc, g_fallc
2077 INTEGER, DIMENSION(its:ite) :: mstep, numdt
2078 REAL :: dtcld, xmi, diameter, temp1, temp2, temp3, temp4, temp5, &
2080 REAL :: g_temp3, g_temp4
2081 INTEGER :: mstepmax, k, i, n
2102 pwx1 = den(i, k)*qci(i, k, 2)
2103 pwr1 = pwx1**(1.31/8.)
2104 work1c(i, k) = vt2i_a*pwr1
2105 work2c(i, k) = work1c(i, k)/delz(i, k)
2106 x1 = NINT(work2c(i, k)*dtcld + .5)
2112 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
2116 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
2122 IF (n .LE. mstep(i)) THEN
2123 g_pwx1 = qci(i, k, 2)*g_den(i, k) + den(i, k)*g_qci(i, k, 2)
2124 pwx1 = den(i, k)*qci(i, k, 2)
2125 IF (pwx1 .LE. 0.0_8 .AND. (9.31/8. .EQ. 0.0_8 .OR. 9.31/8. &
2126 & .NE. INT(9.31/8.))) THEN
2129 g_pwr1 = 9.31*pwx1**(9.31/8.-1)*g_pwx1/8.
2131 pwr1 = pwx1**(9.31/8.)
2132 temp = mstep(i)*delz(i, k)
2133 g_falkc(i, k) = falli_a*(g_pwr1-pwr1*mstep(i)*g_delz(i, k)/&
2135 falkc(i, k) = falli_a*(pwr1/temp)
2136 g_fallc(i, k) = g_fallc(i, k) + g_falkc(i, k)
2137 fallc(i, k) = fallc(i, k) + falkc(i, k)
2138 temp = falkc(i, k)/den(i, k)
2139 g_x2 = dtcld*(g_falkc(i, k)-temp*g_den(i, k))/den(i, k)
2141 IF (x2 .GT. qci(i, k, 2)) THEN
2142 g_temp3 = g_qci(i, k, 2)
2143 temp3 = qci(i, k, 2)
2148 IF (temp3 .GE. 0.) THEN
2153 IF (abs0 .LT. qmin) THEN
2157 g_qci(i, k, 2) = g_qci(i, k, 2) - g_temp3
2158 qci(i, k, 2) = qci(i, k, 2) - temp3
2163 IF (n .LE. mstep(i)) THEN
2164 g_pwx1 = qci(i, k, 2)*g_den(i, k) + den(i, k)*g_qci(i, k, 2)
2165 pwx1 = den(i, k)*qci(i, k, 2)
2166 IF (pwx1 .LE. 0.0_8 .AND. (9.31/8. .EQ. 0.0_8 .OR. 9.31/8. &
2167 & .NE. INT(9.31/8.))) THEN
2170 g_pwr1 = 9.31*pwx1**(9.31/8.-1)*g_pwx1/8.
2172 pwr1 = pwx1**(9.31/8.)
2173 temp = mstep(i)*delz(i, k)
2174 g_falkc(i, k) = falli_a*(g_pwr1-pwr1*mstep(i)*g_delz(i, k)/&
2176 falkc(i, k) = falli_a*(pwr1/temp)
2177 g_fallc(i, k) = g_fallc(i, k) + g_falkc(i, k)
2178 fallc(i, k) = fallc(i, k) + falkc(i, k)
2179 IF ((falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k))*&
2180 & dtcld/den(i, k) .GT. qci(i, k, 2)) THEN
2181 g_temp4 = g_qci(i, k, 2)
2182 temp4 = qci(i, k, 2)
2184 temp = falkc(i, k+1)/delz(i, k)
2185 temp6 = (falkc(i, k)-temp*delz(i, k+1))/den(i, k)
2186 g_temp4 = dtcld*(g_falkc(i, k)-delz(i, k+1)*(g_falkc(i, k+&
2187 & 1)-temp*g_delz(i, k))/delz(i, k)-temp*g_delz(i, k+1)-&
2188 & temp6*g_den(i, k))/den(i, k)
2191 IF (temp4 .GE. 0.) THEN
2196 IF (abs1 .LT. qmin) THEN
2200 g_qci(i, k, 2) = g_qci(i, k, 2) - g_temp4
2201 qci(i, k, 2) = qci(i, k, 2) - temp4
2206 END SUBROUTINE G_FALLKC
2208 !=======================================================================
2210 !=======================================================================
2211 SUBROUTINE FALLKC(qci, fallc, den, delz, dtcld, kte, kts, its, ite, &
2212 & kme, kms, ims, ime)
2214 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2215 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2216 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den
2217 REAL, DIMENSION(its:ite, kts:kte) :: falkc, work1c, work2c, xni, &
2219 INTEGER, DIMENSION(its:ite) :: mstep, numdt
2220 REAL :: dtcld, xmi, diameter, temp1, temp2, temp3, temp4, temp5, &
2222 INTEGER :: mstepmax, k, i, n
2238 pwx1 = den(i, k)*qci(i, k, 2)
2239 pwr1 = pwx1**(1.31/8.)
2240 work1c(i, k) = vt2i_a*pwr1
2241 work2c(i, k) = work1c(i, k)/delz(i, k)
2242 x1 = NINT(work2c(i, k)*dtcld + .5)
2248 IF (numdt(i) .GE. mstep(i)) mstep(i) = numdt(i)
2252 IF (mstepmax .LE. mstep(i)) mstepmax = mstep(i)
2257 IF (n .LE. mstep(i)) THEN
2258 pwx1 = den(i, k)*qci(i, k, 2)
2259 pwr1 = pwx1**(9.31/8.)
2260 falkc(i, k) = falli_a*pwr1/delz(i, k)/mstep(i)
2261 fallc(i, k) = fallc(i, k) + falkc(i, k)
2262 x2 = falkc(i, k)*dtcld/den(i, k)
2263 IF (x2 .GT. qci(i, k, 2)) THEN
2264 temp3 = qci(i, k, 2)
2268 IF (temp3 .GE. 0.) THEN
2273 IF (abs0 .LT. qmin) temp3 = 0.
2274 qci(i, k, 2) = qci(i, k, 2) - temp3
2279 IF (n .LE. mstep(i)) THEN
2280 pwx1 = den(i, k)*qci(i, k, 2)
2281 pwr1 = pwx1**(9.31/8.)
2282 falkc(i, k) = falli_a*pwr1/delz(i, k)/mstep(i)
2283 fallc(i, k) = fallc(i, k) + falkc(i, k)
2284 IF ((falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k))*&
2285 & dtcld/den(i, k) .GT. qci(i, k, 2)) THEN
2286 temp4 = qci(i, k, 2)
2288 temp4 = (falkc(i, k)-falkc(i, k+1)*delz(i, k+1)/delz(i, k)&
2291 IF (temp4 .GE. 0.) THEN
2296 IF (abs1 .LT. qmin) temp4 = 0.
2297 qci(i, k, 2) = qci(i, k, 2) - temp4
2302 END SUBROUTINE FALLKC
2304 ! Differentiation of rainsc in forward (tangent) mode (with options r8):
2305 ! variations of useful results: t xl qrs rain qci rainncv
2306 ! with respect to varying inputs: fallc t cpm xl delz den qrs
2307 ! fall rain qci rainncv
2308 !=======================================================================
2310 !=======================================================================
2311 SUBROUTINE G_RAINSC(fall, g_fall, fallc, g_fallc, xl, g_xl, t, g_t, q&
2312 & , qci, g_qci, cpm, g_cpm, den, g_den, qrs, g_qrs, delz, g_delz, rain&
2313 & , g_rain, rainncv, g_rainncv, dtcld, kte, kts, its, ite, kme, kms, &
2316 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2317 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, fall
2318 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs, g_fall
2319 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2320 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
2321 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, q
2322 REAL, DIMENSION(ims:ime, kms:kme) :: g_delz, g_den
2323 REAL, DIMENSION(its:ite, kts:kte) :: xl, t, cpm, fallc
2324 REAL, DIMENSION(its:ite, kts:kte) :: g_xl, g_t, g_cpm, g_fallc
2325 REAL, DIMENSION(ims:ime) :: rain, rainncv
2326 REAL, DIMENSION(ims:ime) :: g_rain, g_rainncv
2328 REAL :: dtcld, fallsum, supcol, xlf, temp, temp0, pfrzdtr, pfrzdtc
2329 REAL :: g_fallsum, g_supcol, g_xlf, g_temp, g_pfrzdtr, g_pfrzdtc
2330 REAL :: ft0, ft40, fsupcol, fqc, fqi, fqr, qtmp
2331 REAL :: g_ft0, g_ft40, g_qtmp
2352 g_fallsum = g_fall(i, kts, 1) + g_fall(i, kts, 2) + g_fall(i, kts&
2353 & , 3) + g_fallc(i, kts)
2354 fallsum = fall(i, kts, 1) + fall(i, kts, 2) + fall(i, kts, 3) + &
2356 IF (fallsum .GT. qmin) THEN
2357 !rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
2358 g_rainncv(i) = dtcld*1000.*(fallsum*g_delz(i, kts)/denr+delz(i, &
2359 & kts)*g_fallsum/denr)
2360 rainncv(i) = fallsum*delz(i, kts)/denr*dtcld*1000.
2361 g_rain(i) = dtcld*1000.*(fallsum*g_delz(i, kts)/denr+delz(i, kts&
2362 & )*g_fallsum/denr) + g_rain(i)
2363 rain(i) = fallsum*delz(i, kts)/denr*dtcld*1000. + rain(i)
2368 !---------------------------------------------------------------
2369 ! pimlt: instantaneous melting of cloud ice [RH83 A28]
2370 ! (T>T0: I->C) pimlt=qci(i,k,2) t-
2371 !---------------------------------------------------------------
2373 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
2374 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2376 xlf = xls - xl(i, k)
2377 supcol = t0c - t(i, k)
2378 IF (supcol .LT. 0.) THEN
2382 CALL G_SMOOTHIF(t(i, k), g_t(i, k), t0c, ft0, g_ft0, 't0')
2383 IF (qci(i, k, 2) .LT. 0.) THEN
2387 g_max1 = g_qci(i, k, 2)
2390 g_qtmp = max1*g_ft0 + ft0*g_max1
2392 IF (qtmp .GE. 0.) THEN
2397 IF (abs0 .LT. qmin) THEN
2401 IF (qci(i, k, 1) + qtmp .LT. 0.) THEN
2402 g_qci(i, k, 1) = 0.0_8
2405 g_qci(i, k, 1) = g_qci(i, k, 1) + g_qtmp
2406 qci(i, k, 1) = qci(i, k, 1) + qtmp
2408 IF (qci(i, k, 2) - qtmp .LT. 0.) THEN
2409 g_qci(i, k, 2) = 0.0_8
2412 g_qci(i, k, 2) = g_qci(i, k, 2) - g_qtmp
2413 qci(i, k, 2) = qci(i, k, 2) - qtmp
2415 temp1 = xlf*qtmp/cpm(i, k)
2416 g_t(i, k) = g_t(i, k) - (qtmp*g_xlf+xlf*g_qtmp-temp1*g_cpm(i, k)&
2418 t(i, k) = t(i, k) - temp1
2419 !---------------------------------------------------------------
2420 ! pihmf: homogeneous freezing of cloud water below -40c
2421 ! (T<-40C: C->I) min=0,pihmf=qci(i,k,1) t+
2422 !---------------------------------------------------------------
2424 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
2425 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2427 xlf = xls - xl(i, k)
2428 g_supcol = -g_t(i, k)
2429 supcol = t0c - t(i, k)
2430 IF (supcol .LT. 0.) THEN
2434 CALL G_SMOOTHIF(supcol, g_supcol, 40., ft40, g_ft40, 't0')
2435 IF (ft40*qci(i, k, 1) .LT. 0.) THEN
2439 g_qtmp = qci(i, k, 1)*g_ft40 + ft40*g_qci(i, k, 1)
2440 qtmp = ft40*qci(i, k, 1)
2442 IF (qtmp .GE. 0.) THEN
2448 IF (abs1 .LT. qmin) THEN
2452 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2453 g_qci(i, k, 2) = 0.0_8
2456 g_qci(i, k, 2) = g_qci(i, k, 2) + g_qtmp
2457 qci(i, k, 2) = qci(i, k, 2) + qtmp
2459 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2460 g_qci(i, k, 1) = 0.0_8
2463 g_qci(i, k, 1) = g_qci(i, k, 1) - g_qtmp
2464 qci(i, k, 1) = qci(i, k, 1) - qtmp
2466 temp1 = xlf*qtmp/cpm(i, k)
2467 g_t(i, k) = g_t(i, k) + (qtmp*g_xlf+xlf*g_qtmp-temp1*g_cpm(i, k)&
2469 t(i, k) = t(i, k) + temp1
2470 !---------------------------------------------------------------
2471 ! pihtf: heterogeneous freezing of cloud water
2472 ! (T0>T>-40C: C->I) max=qci(i,k,1),min=0. t+
2473 !---------------------------------------------------------------
2475 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
2476 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2478 xlf = xls - xl(i, k)
2479 g_supcol = -g_t(i, k)
2480 supcol = t0c - t(i, k)
2481 IF (supcol .LT. 0.) THEN
2485 !t>-40C=t0c-40,t0c-t<40, supcol<40,-supcol>-40
2486 CALL G_SMOOTHIF(-supcol, -g_supcol, -40., ft40, g_ft40, 't0')
2487 temp1 = den(i, k)/(denr*xncr)
2488 temp2 = qci(i, k, 1)*qci(i, k, 1)
2489 temp3 = EXP(pfrz2*supcol) - 1.
2490 g_x1 = pfrz1*dtcld*(temp2*temp1*EXP(pfrz2*supcol)*pfrz2*g_supcol&
2491 & +temp3*(temp1*2*qci(i, k, 1)*g_qci(i, k, 1)+temp2*g_den(i, k)/&
2493 x1 = pfrz1*dtcld*(temp3*(temp2*temp1))
2494 IF (x1 .GT. qci(i, k, 1)) THEN
2495 g_pfrzdtc = g_qci(i, k, 1)
2496 pfrzdtc = qci(i, k, 1)
2501 IF (ft40*pfrzdtc .LT. 0.) THEN
2505 g_qtmp = pfrzdtc*g_ft40 + ft40*g_pfrzdtc
2508 IF (qtmp .GE. 0.) THEN
2514 IF (abs2 .LT. qmin) THEN
2518 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2519 g_qci(i, k, 2) = 0.0_8
2522 g_qci(i, k, 2) = g_qci(i, k, 2) + g_qtmp
2523 qci(i, k, 2) = qci(i, k, 2) + qtmp
2525 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2526 g_qci(i, k, 1) = 0.0_8
2529 g_qci(i, k, 1) = g_qci(i, k, 1) - g_qtmp
2530 qci(i, k, 1) = qci(i, k, 1) - qtmp
2532 temp3 = xlf*qtmp/cpm(i, k)
2533 g_t(i, k) = g_t(i, k) + (qtmp*g_xlf+xlf*g_qtmp-temp3*g_cpm(i, k)&
2535 t(i, k) = t(i, k) + temp3
2536 !---------------------------------------------------------------
2537 ! pgfrz: freezing of rain water [LFO 45]
2538 ! (T<T0, R->G) max=qrs(i,k,1),min=0. t+
2539 !---------------------------------------------------------------
2541 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
2542 ! cpm(i,k)=cpmcal(q(i,k))!not change
2544 xlf = xls - xl(i, k)
2545 g_supcol = -g_t(i, k)
2546 supcol = t0c - t(i, k)
2547 IF (supcol .LT. 0.) THEN
2551 IF (qrs(i, k, 1) .GT. 0.) THEN
2552 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. &
2553 & .NE. INT(3./4.))) THEN
2556 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
2558 pwr1 = den(i, k)**(3./4.)
2559 IF (qrs(i, k, 1) .LE. 0.0_8 .AND. (7./4. .EQ. 0.0_8 .OR. 7./4.&
2560 & .NE. INT(7./4.))) THEN
2563 g_pwr2 = 7.*qrs(i, k, 1)**(7./4.-1)*g_qrs(i, k, 1)/4.
2565 pwr2 = qrs(i, k, 1)**(7./4.)
2566 temp3 = EXP(pfrz2*supcol) - 1.
2567 g_temp = pgfrz_a*(pwr1*pwr2*EXP(pfrz2*supcol)*pfrz2*g_supcol+&
2568 & temp3*(pwr2*g_pwr1+pwr1*g_pwr2))
2569 temp = pgfrz_a*(temp3*(pwr1*pwr2))
2574 IF (temp*dtcld .GT. qrs(i, k, 1)) THEN
2575 g_pfrzdtr = g_qrs(i, k, 1)
2576 pfrzdtr = qrs(i, k, 1)
2578 g_pfrzdtr = dtcld*g_temp
2579 pfrzdtr = temp*dtcld
2581 IF (pfrzdtr .LT. 0.) THEN
2588 IF (qtmp .GE. 0.) THEN
2593 IF (abs3 .LT. qmin) THEN
2597 IF (qrs(i, k, 3) + qtmp .LT. 0.) THEN
2598 g_qrs(i, k, 3) = 0.0_8
2601 g_qrs(i, k, 3) = g_qrs(i, k, 3) + g_qtmp
2602 qrs(i, k, 3) = qrs(i, k, 3) + qtmp
2604 IF (qrs(i, k, 1) - qtmp .LT. 0.) THEN
2605 g_qrs(i, k, 1) = 0.0_8
2608 g_qrs(i, k, 1) = g_qrs(i, k, 1) - g_qtmp
2609 qrs(i, k, 1) = qrs(i, k, 1) - qtmp
2611 temp3 = xlf*qtmp/cpm(i, k)
2612 g_t(i, k) = g_t(i, k) + (qtmp*g_xlf+xlf*g_qtmp-temp3*g_cpm(i, k)&
2614 t(i, k) = t(i, k) + temp3
2617 END SUBROUTINE G_RAINSC
2619 !=======================================================================
2621 !=======================================================================
2622 SUBROUTINE RAINSC(fall, fallc, xl, t, q, qci, cpm, den, qrs, delz, &
2623 & rain, rainncv, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
2625 INTEGER :: kte, kts, its, ite, kme, kms, ims, ime
2626 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, fall
2627 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2628 REAL, DIMENSION(ims:ime, kms:kme) :: delz, den, q
2629 REAL, DIMENSION(its:ite, kts:kte) :: xl, t, cpm, fallc
2630 REAL, DIMENSION(ims:ime) :: rain, rainncv
2632 REAL :: dtcld, fallsum, supcol, xlf, temp, temp0, pfrzdtr, pfrzdtc
2633 REAL :: ft0, ft40, fsupcol, fqc, fqi, fqr, qtmp
2647 fallsum = fall(i, kts, 1) + fall(i, kts, 2) + fall(i, kts, 3) + &
2649 IF (fallsum .GT. qmin) THEN
2650 !rain (unit is mm/sec;kgm-2s-1: /1000*delt ===> m)==> mm for wrf
2651 rainncv(i) = fallsum*delz(i, kts)/denr*dtcld*1000.
2652 rain(i) = fallsum*delz(i, kts)/denr*dtcld*1000. + rain(i)
2657 !---------------------------------------------------------------
2658 ! pimlt: instantaneous melting of cloud ice [RH83 A28]
2659 ! (T>T0: I->C) pimlt=qci(i,k,2) t-
2660 !---------------------------------------------------------------
2662 xl(i, k) = XLCAL(t(i, k))
2663 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2664 xlf = xls - xl(i, k)
2665 supcol = t0c - t(i, k)
2666 IF (supcol .LT. 0.) xlf = xlf0
2667 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
2668 IF (qci(i, k, 2) .LT. 0.) THEN
2674 IF (qtmp .GE. 0.) THEN
2679 IF (abs0 .LT. qmin) qtmp = 0.
2680 IF (qci(i, k, 1) + qtmp .LT. 0.) THEN
2683 qci(i, k, 1) = qci(i, k, 1) + qtmp
2685 IF (qci(i, k, 2) - qtmp .LT. 0.) THEN
2688 qci(i, k, 2) = qci(i, k, 2) - qtmp
2690 t(i, k) = t(i, k) - xlf/cpm(i, k)*qtmp
2691 !---------------------------------------------------------------
2692 ! pihmf: homogeneous freezing of cloud water below -40c
2693 ! (T<-40C: C->I) min=0,pihmf=qci(i,k,1) t+
2694 !---------------------------------------------------------------
2696 xl(i, k) = XLCAL(t(i, k))
2697 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2698 xlf = xls - xl(i, k)
2699 supcol = t0c - t(i, k)
2700 IF (supcol .LT. 0.) xlf = xlf0
2701 CALL SMOOTHIF(supcol, 40., ft40, 't0')
2702 IF (ft40*qci(i, k, 1) .LT. 0.) THEN
2705 qtmp = ft40*qci(i, k, 1)
2707 IF (qtmp .GE. 0.) THEN
2713 IF (abs1 .LT. qmin) qtmp = 0.
2714 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2717 qci(i, k, 2) = qci(i, k, 2) + qtmp
2719 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2722 qci(i, k, 1) = qci(i, k, 1) - qtmp
2724 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
2725 !---------------------------------------------------------------
2726 ! pihtf: heterogeneous freezing of cloud water
2727 ! (T0>T>-40C: C->I) max=qci(i,k,1),min=0. t+
2728 !---------------------------------------------------------------
2730 xl(i, k) = XLCAL(t(i, k))
2731 ! cpm(i,k)=cpmcal(q(i,k)) !not change
2732 xlf = xls - xl(i, k)
2733 supcol = t0c - t(i, k)
2734 IF (supcol .LT. 0.) xlf = xlf0
2735 !t>-40C=t0c-40,t0c-t<40, supcol<40,-supcol>-40
2736 CALL SMOOTHIF(-supcol, -40., ft40, 't0')
2737 x1 = pfrz1*(EXP(pfrz2*supcol)-1.)*den(i, k)/denr/xncr*qci(i, k, &
2738 & 1)*qci(i, k, 1)*dtcld
2739 IF (x1 .GT. qci(i, k, 1)) THEN
2740 pfrzdtc = qci(i, k, 1)
2744 IF (ft40*pfrzdtc .LT. 0.) THEN
2749 IF (qtmp .GE. 0.) THEN
2755 IF (abs2 .LT. qmin) qtmp = 0.
2756 IF (qci(i, k, 2) + qtmp .LT. 0.) THEN
2759 qci(i, k, 2) = qci(i, k, 2) + qtmp
2761 IF (qci(i, k, 1) - qtmp .LT. 0.) THEN
2764 qci(i, k, 1) = qci(i, k, 1) - qtmp
2766 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
2767 !---------------------------------------------------------------
2768 ! pgfrz: freezing of rain water [LFO 45]
2769 ! (T<T0, R->G) max=qrs(i,k,1),min=0. t+
2770 !---------------------------------------------------------------
2772 xl(i, k) = XLCAL(t(i, k))
2773 ! cpm(i,k)=cpmcal(q(i,k))!not change
2774 xlf = xls - xl(i, k)
2775 supcol = t0c - t(i, k)
2776 IF (supcol .LT. 0.) xlf = xlf0
2777 IF (qrs(i, k, 1) .GT. 0.) THEN
2778 pwr1 = den(i, k)**(3./4.)
2779 pwr2 = qrs(i, k, 1)**(7./4.)
2780 temp = pgfrz_a*(EXP(pfrz2*supcol)-1.)*pwr1*pwr2
2784 IF (temp*dtcld .GT. qrs(i, k, 1)) THEN
2785 pfrzdtr = qrs(i, k, 1)
2787 pfrzdtr = temp*dtcld
2789 IF (pfrzdtr .LT. 0.) THEN
2794 IF (qtmp .GE. 0.) THEN
2799 IF (abs3 .LT. qmin) qtmp = 0.
2800 IF (qrs(i, k, 3) + qtmp .LT. 0.) THEN
2803 qrs(i, k, 3) = qrs(i, k, 3) + qtmp
2805 IF (qrs(i, k, 1) - qtmp .LT. 0.) THEN
2808 qrs(i, k, 1) = qrs(i, k, 1) - qtmp
2810 t(i, k) = t(i, k) + xlf/cpm(i, k)*qtmp
2813 END SUBROUTINE RAINSC
2815 ! Differentiation of warmr in forward (tangent) mode (with options r8):
2816 ! variations of useful results: q t qs xl pracw rh qrs prevp
2818 ! with respect to varying inputs: p q t qs xl pracw rh den qrs
2820 !=======================================================================
2822 !=======================================================================
2823 SUBROUTINE G_WARMR(t, g_t, q, g_q, qci, g_qci, qrs, g_qrs, den, g_den&
2824 & , p, g_p, dtcld, xl, g_xl, rh, g_rh, qs, g_qs, praut, g_praut, pracw&
2825 & , g_pracw, prevp, g_prevp, ims, ime, kms, kme, its, ite, kts, kte)
2827 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
2828 !------------------------------------------------------------------
2829 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
2830 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
2831 REAL, DIMENSION(ims:ime, kms:kme) :: q, den, p
2832 REAL, DIMENSION(ims:ime, kms:kme) :: g_q, g_den, g_p
2833 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, qrs, work1
2834 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_rh, g_qs, g_qrs
2835 REAL, DIMENSION(its:ite, kts:kte) :: praut, prevp, pracw, xl, denfac&
2837 REAL, DIMENSION(its:ite, kts:kte) :: g_praut, g_prevp, g_pracw, g_xl&
2839 REAL :: coeres, supsat, satdt, dtcld, praut1
2840 REAL :: g_supsat, g_satdt, g_praut1
2842 REAL :: fqv, fqc, fqr, fqc0, fprevp, prevp0, prevp1, temp, a, b, c, &
2844 REAL :: g_fqc0, g_a, g_b, g_c, g_d, g_e
2889 !---------------------------------------------------------------
2890 ! praut: auto conversion rate from cloud to rain [HDC 16]
2891 ! (C->R) praut>0 max=qci(i,k,1)/dtcld, min=0.
2892 !---------------------------------------------------------------
2893 CALL G_SMOOTHIF(qci(i, k, 1), g_qci(i, k, 1), qc0, fqc0, g_fqc0&
2896 IF (qci(i, k, 1) .GT. 0.) THEN
2898 !(qci(i,k,1)**(7./3.))
2899 g_arg1 = 7.*g_qci(i, k, 1)/(3.*qci(i, k, 1))
2900 arg1 = LOG(qci(i, k, 1))*(7./3.)
2902 g_praut1 = qck1*(temp0*g_fqc0+fqc0*EXP(arg1)*g_arg1)
2903 praut1 = qck1*(fqc0*temp0)
2908 IF (praut1 .GT. qci(i, k, 1)/dtcld) THEN
2909 g_praut(i, k) = g_qci(i, k, 1)/dtcld
2910 praut(i, k) = qci(i, k, 1)/dtcld
2912 g_praut(i, k) = g_praut1
2913 praut(i, k) = praut1
2915 IF (praut(i, k) .GE. 0.) THEN
2920 IF (abs0 .LT. qmin/dtcld) THEN
2921 g_praut(i, k) = 0.0_8
2924 IF (qci(i, k, 1) - praut(i, k)*dtcld .LT. 0.) THEN
2925 g_qci(i, k, 1) = 0.0_8
2928 g_qci(i, k, 1) = g_qci(i, k, 1) - dtcld*g_praut(i, k)
2929 qci(i, k, 1) = qci(i, k, 1) - praut(i, k)*dtcld
2931 IF (qrs(i, k, 1) + praut(i, k)*dtcld .LT. 0.) THEN
2932 g_qrs(i, k, 1) = 0.0_8
2935 g_qrs(i, k, 1) = g_qrs(i, k, 1) + dtcld*g_praut(i, k)
2936 qrs(i, k, 1) = qrs(i, k, 1) + praut(i, k)*dtcld
2938 g_praut(i, k) = 0.0_8
2940 !---------------------------------------------------------------
2941 ! pracw: accretion of cloud water by rain [LFO 51]
2942 ! (C->R) max=qci(i,k,1)/dtcld, min=0.
2943 !---------------------------------------------------------------
2944 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
2945 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
2946 IF (qrs(i, k, 1) .GT. 0 .AND. qci(i, k, 1) .GT. 0.) THEN
2948 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE.&
2952 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
2954 pwr1 = den(i, k)**pwy1
2956 IF (qrs(i, k, 1) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
2957 & .NE. INT(pwy2))) THEN
2960 g_pwr2 = pwy2*qrs(i, k, 1)**(pwy2-1)*g_qrs(i, k, 1)
2962 pwr2 = qrs(i, k, 1)**pwy2
2963 g_pracw(i, k) = pracw_a*(qci(i, k, 1)*(pwr2*g_pwr1+pwr1*g_pwr2&
2964 & )+pwr1*pwr2*g_qci(i, k, 1))
2965 pracw(i, k) = pracw_a*pwr1*pwr2*qci(i, k, 1)
2967 g_pracw(i, k) = 0.0_8
2970 IF (pracw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
2971 g_x1 = g_qci(i, k, 1)/dtcld
2972 x1 = qci(i, k, 1)/dtcld
2974 g_x1 = g_pracw(i, k)
2977 IF (x1 .LT. 0.) THEN
2978 g_pracw(i, k) = 0.0_8
2981 g_pracw(i, k) = g_x1
2984 IF (pracw(i, k) .GE. 0.) THEN
2989 IF (abs1 .LT. qmin/dtcld) THEN
2990 g_pracw(i, k) = 0.0_8
2993 IF (qci(i, k, 1) - pracw(i, k)*dtcld .LT. 0.) THEN
2994 g_qci(i, k, 1) = 0.0_8
2997 g_qci(i, k, 1) = g_qci(i, k, 1) - dtcld*g_pracw(i, k)
2998 qci(i, k, 1) = qci(i, k, 1) - pracw(i, k)*dtcld
3000 IF (qrs(i, k, 1) + pracw(i, k)*dtcld .LT. 0.) THEN
3001 g_qrs(i, k, 1) = 0.0_8
3004 g_qrs(i, k, 1) = g_qrs(i, k, 1) + dtcld*g_pracw(i, k)
3005 qrs(i, k, 1) = qrs(i, k, 1) + pracw(i, k)*dtcld
3007 g_pracw(i, k) = 0.0_8
3010 !---------------------------------------------------------------
3011 ! prevp: evaporation/condensation rate of rain [HDC 14]
3012 ! (V->R or R->V) rh(i,k,1)>1., prevp>0, V->R, min=0., max=satdt ;
3013 ! rh(i,k,1)<1., prevp<0, R->V, min=-qrs(i,k,1)/dtcld, max=0.
3014 !---------------------------------------------------------------
3016 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
3017 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
3020 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
3021 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
3022 g_supsat = g_q(i, k) - g_qs(i, k, 1)
3023 supsat = q(i, k) - qs(i, k, 1)
3024 g_satdt = g_supsat/dtcld
3025 satdt = supsat/dtcld
3026 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3030 g_max1 = g_qrs(i, k, 1)
3033 temp0 = den(i, k)*max1
3035 IF (temp0 .EQ. 0.0_8) THEN
3038 g_a = (max1*g_den(i, k)+den(i, k)*g_max1)/(2.0*temp1)
3041 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3045 g_max2 = g_qrs(i, k, 1)
3049 pwx1 = t(i, k) + 120.
3050 IF (pwx1 .LE. 0.0_8 .AND. (1.0/6. .EQ. 0.0_8 .OR. 1.0/6. .NE. &
3051 & INT(1.0/6.))) THEN
3054 g_pwr1 = pwx1**(1.0/6.-1)*g_pwx1/6.
3056 pwr1 = pwx1**(1./6.)
3057 IF (t(i, k) .LE. 0.0_8 .AND. (5.12/6. .EQ. 0.0_8 .OR. 5.12/6. &
3058 & .NE. INT(5.12/6.))) THEN
3061 g_pwr2 = 5.12*t(i, k)**(5.12/6.-1)*g_t(i, k)/6.
3063 pwr2 = t(i, k)**(5.12/6.)
3064 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. .NE.&
3065 & INT(1.0/3.))) THEN
3068 g_pwr3 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
3070 pwr3 = p(i, k)**(1./3.)
3071 pwy4 = (13.+3.*bvtr)/24.
3072 IF (den(i, k) .LE. 0.0_8 .AND. (pwy4 .EQ. 0.0_8 .OR. pwy4 .NE. &
3076 g_pwr4 = pwy4*den(i, k)**(pwy4-1)*g_den(i, k)
3078 pwr4 = den(i, k)**pwy4
3080 IF (max2 .LE. 0.0_8 .AND. (pwy5 .EQ. 0.0_8 .OR. pwy5 .NE. INT(&
3084 g_pwr5 = pwy5*max2**(pwy5-1)*g_max2
3087 temp1 = pwr1*pwr3/pwr2
3088 g_b = pwr4*pwr5*(pwr3*g_pwr1+pwr1*g_pwr3-temp1*g_pwr2)/pwr2 + &
3089 & temp1*(pwr5*g_pwr4+pwr4*g_pwr5)
3090 b = temp1*(pwr4*pwr5)
3091 temp1 = rv*t(i, k)**3.5
3092 temp0 = den(i, k)*(t(i, k)+120.)
3093 temp2 = xl(i, k)*xl(i, k)
3094 temp3 = temp2*temp0/temp1
3095 g_c = diffac_a*(temp0*2*xl(i, k)*g_xl(i, k)+temp2*((t(i, k)+120.&
3096 & )*g_den(i, k)+den(i, k)*g_t(i, k))-temp3*rv*3.5*t(i, k)**2.5*&
3099 temp3 = t(i, k)**1.81
3100 temp2 = temp3*qs(i, k, 1)
3101 temp1 = p(i, k)/temp2
3102 g_d = diffac_b*(g_p(i, k)-temp1*(qs(i, k, 1)*1.81*t(i, k)**0.81*&
3103 & g_t(i, k)+temp3*g_qs(i, k, 1)))/temp2
3105 temp3 = (rh(i, k, 1)-1.)/(c+d)
3106 g_e = (g_rh(i, k, 1)-temp3*(g_c+g_d))/(c+d)
3108 temp3 = prevp_a*a + prevp_b*b
3109 g_prevp(i, k) = e*(prevp_a*g_a+prevp_b*g_b) + temp3*g_e
3110 prevp(i, k) = temp3*e
3111 IF (prevp(i, k) .LT. 0.) THEN
3112 IF (prevp(i, k) .LT. -(qrs(i, k, 1)/dtcld)) THEN
3113 g_x2 = -(g_qrs(i, k, 1)/dtcld)
3114 x2 = -(qrs(i, k, 1)/dtcld)
3116 g_x2 = g_prevp(i, k)
3119 IF (x2 .GT. 0.) THEN
3120 g_prevp(i, k) = 0.0_8
3123 g_prevp(i, k) = g_x2
3127 IF (prevp(i, k) .GT. satdt) THEN
3131 g_x3 = g_prevp(i, k)
3134 IF (x3 .LT. 0.) THEN
3135 g_prevp(i, k) = 0.0_8
3138 g_prevp(i, k) = g_x3
3142 IF (prevp(i, k) .GE. 0.) THEN
3147 IF (abs2 .LT. qmin/dtcld) THEN
3148 g_prevp(i, k) = 0.0_8
3151 IF (q(i, k) - prevp(i, k)*dtcld .LT. 0.) THEN
3155 g_q(i, k) = g_q(i, k) - dtcld*g_prevp(i, k)
3156 q(i, k) = q(i, k) - prevp(i, k)*dtcld
3158 IF (qrs(i, k, 1) + prevp(i, k)*dtcld .LT. 0.) THEN
3159 g_qrs(i, k, 1) = 0.0_8
3162 g_qrs(i, k, 1) = g_qrs(i, k, 1) + dtcld*g_prevp(i, k)
3163 qrs(i, k, 1) = qrs(i, k, 1) + prevp(i, k)*dtcld
3165 temp3 = prevp(i, k)*xl(i, k)/cpm(i, k)
3166 g_t(i, k) = g_t(i, k) + dtcld*(xl(i, k)*g_prevp(i, k)+prevp(i, k&
3167 & )*g_xl(i, k)-temp3*g_cpm(i, k))/cpm(i, k)
3168 t(i, k) = t(i, k) + dtcld*temp3
3169 g_prevp(i, k) = 0.0_8
3173 END SUBROUTINE G_WARMR
3175 !=======================================================================
3177 !=======================================================================
3178 SUBROUTINE WARMR(t, q, qci, qrs, den, p, dtcld, xl, rh, qs, praut, &
3179 & pracw, prevp, ims, ime, kms, kme, its, ite, kts, kte)
3181 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
3182 !------------------------------------------------------------------
3183 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
3184 REAL, DIMENSION(ims:ime, kms:kme) :: q, den, p
3185 REAL, DIMENSION(its:ite, kts:kte, 3) :: rh, qs, qrs, work1
3186 REAL, DIMENSION(its:ite, kts:kte) :: praut, prevp, pracw, xl, denfac&
3188 REAL :: coeres, supsat, satdt, dtcld, praut1
3190 REAL :: fqv, fqc, fqr, fqc0, fprevp, prevp0, prevp1, temp, a, b, c, &
3219 !---------------------------------------------------------------
3220 ! praut: auto conversion rate from cloud to rain [HDC 16]
3221 ! (C->R) praut>0 max=qci(i,k,1)/dtcld, min=0.
3222 !---------------------------------------------------------------
3223 CALL SMOOTHIF(qci(i, k, 1), qc0, fqc0, 'q0')
3225 IF (qci(i, k, 1) .GT. 0.) THEN
3227 !(qci(i,k,1)**(7./3.))
3228 arg1 = LOG(qci(i, k, 1))*(7./3.)
3229 praut1 = fqc0*qck1*EXP(arg1)
3233 IF (praut1 .GT. qci(i, k, 1)/dtcld) THEN
3234 praut(i, k) = qci(i, k, 1)/dtcld
3236 praut(i, k) = praut1
3238 IF (praut(i, k) .GE. 0.) THEN
3243 IF (abs0 .LT. qmin/dtcld) praut(i, k) = 0.
3244 IF (qci(i, k, 1) - praut(i, k)*dtcld .LT. 0.) THEN
3247 qci(i, k, 1) = qci(i, k, 1) - praut(i, k)*dtcld
3249 IF (qrs(i, k, 1) + praut(i, k)*dtcld .LT. 0.) THEN
3252 qrs(i, k, 1) = qrs(i, k, 1) + praut(i, k)*dtcld
3255 !---------------------------------------------------------------
3256 ! pracw: accretion of cloud water by rain [LFO 51]
3257 ! (C->R) max=qci(i,k,1)/dtcld, min=0.
3258 !---------------------------------------------------------------
3259 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
3260 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
3261 IF (qrs(i, k, 1) .GT. 0 .AND. qci(i, k, 1) .GT. 0.) THEN
3263 pwr1 = den(i, k)**pwy1
3265 pwr2 = qrs(i, k, 1)**pwy2
3266 pracw(i, k) = pracw_a*pwr1*pwr2*qci(i, k, 1)
3270 IF (pracw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
3271 x1 = qci(i, k, 1)/dtcld
3275 IF (x1 .LT. 0.) THEN
3280 IF (pracw(i, k) .GE. 0.) THEN
3285 IF (abs1 .LT. qmin/dtcld) pracw(i, k) = 0.
3286 IF (qci(i, k, 1) - pracw(i, k)*dtcld .LT. 0.) THEN
3289 qci(i, k, 1) = qci(i, k, 1) - pracw(i, k)*dtcld
3291 IF (qrs(i, k, 1) + pracw(i, k)*dtcld .LT. 0.) THEN
3294 qrs(i, k, 1) = qrs(i, k, 1) + pracw(i, k)*dtcld
3298 !---------------------------------------------------------------
3299 ! prevp: evaporation/condensation rate of rain [HDC 14]
3300 ! (V->R or R->V) rh(i,k,1)>1., prevp>0, V->R, min=0., max=satdt ;
3301 ! rh(i,k,1)<1., prevp<0, R->V, min=-qrs(i,k,1)/dtcld, max=0.
3302 !---------------------------------------------------------------
3304 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
3306 xl(i, k) = XLCAL(t(i, k))
3307 cpm(i, k) = CPMCAL(q(i, k))
3308 supsat = q(i, k) - qs(i, k, 1)
3309 satdt = supsat/dtcld
3310 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3315 a = SQRT(den(i, k)*max1)
3316 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3321 pwx1 = t(i, k) + 120.
3322 pwr1 = pwx1**(1./6.)
3323 pwr2 = t(i, k)**(5.12/6.)
3324 pwr3 = p(i, k)**(1./3.)
3325 pwy4 = (13.+3.*bvtr)/24.
3326 pwr4 = den(i, k)**pwy4
3329 b = pwr1/pwr2*pwr3*pwr4*pwr5
3330 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
3332 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
3333 e = (rh(i, k, 1)-1.)/(c+d)
3334 prevp(i, k) = (prevp_a*a+prevp_b*b)*e
3335 IF (prevp(i, k) .LT. 0.) THEN
3336 IF (prevp(i, k) .LT. -(qrs(i, k, 1)/dtcld)) THEN
3337 x2 = -(qrs(i, k, 1)/dtcld)
3341 IF (x2 .GT. 0.) THEN
3347 IF (prevp(i, k) .GT. satdt) THEN
3352 IF (x3 .LT. 0.) THEN
3358 IF (prevp(i, k) .GE. 0.) THEN
3363 IF (abs2 .LT. qmin/dtcld) prevp(i, k) = 0.
3364 IF (q(i, k) - prevp(i, k)*dtcld .LT. 0.) THEN
3367 q(i, k) = q(i, k) - prevp(i, k)*dtcld
3369 IF (qrs(i, k, 1) + prevp(i, k)*dtcld .LT. 0.) THEN
3372 qrs(i, k, 1) = qrs(i, k, 1) + prevp(i, k)*dtcld
3374 t(i, k) = t(i, k) + prevp(i, k)*dtcld*xl(i, k)/cpm(i, k)
3378 END SUBROUTINE WARMR
3380 ! Differentiation of accret1 in forward (tangent) mode (with options r8):
3381 ! variations of useful results: piacr psaci pgaci t praci psacw
3383 ! with respect to varying inputs: piacr psaci q pgaci t praci
3384 ! psacw pgacw den qrs qci
3385 !===================================================================
3386 SUBROUTINE G_ACCRET1(qci, g_qci, den, g_den, qrs, g_qrs, t, g_t, q, &
3387 & g_q, dtcld, praci, g_praci, piacr, g_piacr, psaci, g_psaci, pgaci, &
3388 & g_pgaci, psacw, g_psacw, pgacw, g_pgacw, ims, ime, kms, kme, its, &
3391 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
3392 !-------------------------------------------------------------------
3393 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
3394 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
3395 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
3396 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs
3397 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
3398 REAL, DIMENSION(ims:ime, kms:kme) :: g_den, g_q
3399 REAL, DIMENSION(its:ite, kts:kte) :: praci, piacr, psaci, pgaci, &
3400 & psacw, pgacw, t, xl, cpm
3401 REAL, DIMENSION(its:ite, kts:kte) :: g_praci, g_piacr, g_psaci, &
3402 & g_pgaci, g_psacw, g_pgacw, g_t, g_xl, g_cpm
3403 REAL :: supcol, dtcld, eacrs, egi, praci1, piacr1, psaci1, pgaci1, &
3405 REAL :: g_supcol, g_eacrs, g_egi, g_praci1, g_piacr1, g_psaci1, &
3408 REAL :: fsupcol, fqc, fqi, fqr, fqs, fqg, delta3, xlf, a, b, c, d, e
3409 REAL :: g_fsupcol, g_xlf, g_a, g_b, g_c, g_d
3543 !-------------------------------------------------------------
3544 ! praci: Accretion of cloud ice by rain [LFO 25]
3545 ! (T<T0: I->S or I->G) praci: min=0,max=qci(i,k,2)/dtcld
3546 !-------------------------------------------------------------
3547 g_supcol = -g_t(i, k)
3548 supcol = t0c - t(i, k)
3549 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
3550 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3554 g_max1 = g_qrs(i, k, 1)
3558 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
3562 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
3564 pwr1 = den(i, k)**pwy1
3566 IF (max1 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
3570 g_pwr2 = pwy2*max1**(pwy2-1)*g_max1
3573 g_vt2r = vt2r_a*(pwr2*g_pwr1+pwr1*g_pwr2)
3574 vt2r = vt2r_a*pwr1*pwr2
3575 IF (qci(i, k, 2) .LT. qmin) THEN
3579 g_max2 = g_qci(i, k, 2)
3582 g_pwx1 = max2*g_den(i, k) + den(i, k)*g_max2
3583 pwx1 = den(i, k)*max2
3584 IF (pwx1 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. 1.31/8. .NE. &
3585 & INT(1.31/8.))) THEN
3588 g_pwr1 = 1.31*pwx1**(1.31/8.-1)*g_pwx1/8.
3590 pwr1 = pwx1**(1.31/8.)
3591 g_vt2i = vt2i_a*g_pwr1
3593 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3597 g_max3 = g_qrs(i, k, 1)
3600 IF (qci(i, k, 2) .LT. qmin) THEN
3604 g_max18 = g_qci(i, k, 2)
3605 max18 = qci(i, k, 2)
3607 g_pwx1 = max3*g_den(i, k) + den(i, k)*g_max3
3608 pwx1 = den(i, k)*max3
3609 IF (pwx1 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT(&
3613 g_pwr1 = 3.*pwx1**(3./4.-1)*g_pwx1/4.
3615 pwr1 = pwx1**(3./4.)
3616 g_b = max18*g_pwr1 + pwr1*g_max18
3618 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3622 g_max4 = g_qrs(i, k, 1)
3625 IF (qci(i, k, 2) .LT. qmin) THEN
3629 g_max19 = g_qci(i, k, 2)
3630 max19 = qci(i, k, 2)
3632 IF (den(i, k) .LE. 0.0_8 .AND. (5./8. .EQ. 0.0_8 .OR. 5./8. .NE.&
3636 g_pwr1 = 5.*den(i, k)**(5./8.-1)*g_den(i, k)/8.
3638 pwr1 = den(i, k)**(5./8.)
3640 IF (max4 .EQ. 0.0_8) THEN
3643 g_result1 = g_max4/(2.0*temp1)
3646 IF (max19 .LE. 0.0_8 .AND. (9./8. .EQ. 0.0_8 .OR. 9./8. .NE. INT&
3650 g_pwr2 = 9.*max19**(9./8.-1)*g_max19/8.
3652 pwr2 = max19**(9./8.)
3653 g_c = pwr2*(result1*g_pwr1+pwr1*g_result1) + pwr1*result1*g_pwr2
3654 c = pwr1*result1*pwr2
3655 IF (qrs(i, k, 1) .LT. qcrmin) THEN
3659 g_max5 = g_qrs(i, k, 1)
3662 IF (qci(i, k, 2) .LT. qmin) THEN
3666 g_max20 = g_qci(i, k, 2)
3667 max20 = qci(i, k, 2)
3669 temp1 = SQRT(den(i, k))
3670 IF (den(i, k) .EQ. 0.0_8) THEN
3673 g_result1 = g_den(i, k)/(2.0*temp1)
3677 IF (max5 .EQ. 0.0_8) THEN
3680 g_result2 = g_max5/(2.0*temp1)
3683 temp1 = SQRT(result2)
3684 IF (result2 .EQ. 0.0_8) THEN
3687 g_result3 = g_result2/(2.0*temp1)
3690 IF (max20 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
3694 g_pwr1 = 5.*max20**(5./4.-1)*g_max20/4.
3696 pwr1 = max20**(5./4.)
3697 g_d = pwr1*(result3*g_result1+result1*g_result3) + result1*&
3699 d = result1*result3*pwr1
3700 IF (vt2r - vt2i .GE. 0.) THEN
3701 g_abs0 = g_vt2r - g_vt2i
3704 g_abs0 = g_vt2i - g_vt2r
3707 temp1 = praci_b*b + praci_c*c + praci_d*d
3708 g_praci1 = praci_a*(temp1*g_abs0+abs0*(praci_b*g_b+praci_c*g_c+&
3710 praci1 = praci_a*(abs0*temp1)
3711 IF (praci1 .GT. qci(i, k, 2)/dtcld) THEN
3712 g_praci(i, k) = g_qci(i, k, 2)/dtcld
3713 praci(i, k) = qci(i, k, 2)/dtcld
3715 g_praci(i, k) = g_praci1
3716 praci(i, k) = praci1
3718 g_praci(i, k) = praci(i, k)*g_fsupcol + fsupcol*g_praci(i, k)
3719 praci(i, k) = fsupcol*praci(i, k)
3721 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
3726 IF (praci(i, k) .GE. 0.) THEN
3731 IF (abs1 .LT. qmin/dtcld) THEN
3732 g_praci(i, k) = 0.0_8
3735 IF (qci(i, k, 2) - praci(i, k)*dtcld .LT. 0.) THEN
3736 g_qci(i, k, 2) = 0.0_8
3739 g_qci(i, k, 2) = g_qci(i, k, 2) - dtcld*g_praci(i, k)
3740 qci(i, k, 2) = qci(i, k, 2) - praci(i, k)*dtcld
3742 g_x1 = g_qrs(i, k, 2) + delta3*dtcld*g_praci(i, k)
3743 x1 = qrs(i, k, 2) + praci(i, k)*delta3*dtcld
3744 IF (x1 .LT. 0.) THEN
3745 g_qrs(i, k, 2) = 0.0_8
3748 g_qrs(i, k, 2) = g_x1
3751 g_x2 = g_qrs(i, k, 3) + (1-delta3)*dtcld*g_praci(i, k)
3752 x2 = qrs(i, k, 3) + praci(i, k)*(1-delta3)*dtcld
3753 IF (x2 .LT. 0.) THEN
3754 g_qrs(i, k, 3) = 0.0_8
3757 g_qrs(i, k, 3) = g_x2
3760 g_praci(i, k) = 0.0_8
3762 !-------------------------------------------------------------
3763 ! piacr: Accretion of rain by cloud ice [LFO 26]
3764 ! (T<T0: R->S or R->G) piacr: min=0,max=qrs(i,k,1)/dtcld
3765 !-------------------------------------------------------------
3766 ! supcol = t0c-t(i,k) !not change
3767 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
3768 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
3769 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
3771 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
3772 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
3774 xlf = xls - xl(i, k)
3775 IF (supcol .LT. 0.) THEN
3779 IF (qci(i, k, 2) .GT. 0. .AND. qrs(i, k, 1) .GT. 0.) THEN
3782 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE.&
3786 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
3788 pwr1 = den(i, k)**pwy1
3790 IF (qrs(i, k, 1) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
3791 & .NE. INT(pwy2))) THEN
3794 g_pwr2 = pwy2*qrs(i, k, 1)**(pwy2-1)*g_qrs(i, k, 1)
3796 pwr2 = qrs(i, k, 1)**pwy2
3797 temp1 = qci(i, k, 2)**0.75
3798 g_piacr1 = piacr_a*(pwr1*pwr2*0.75*qci(i, k, 2)**(-0.25)*g_qci&
3799 & (i, k, 2)+temp1*(pwr2*g_pwr1+pwr1*g_pwr2))
3800 piacr1 = piacr_a*(temp1*(pwr1*pwr2))
3805 IF (piacr1 .GT. qrs(i, k, 1)/dtcld) THEN
3806 g_piacr(i, k) = g_qrs(i, k, 1)/dtcld
3807 piacr(i, k) = qrs(i, k, 1)/dtcld
3809 g_piacr(i, k) = g_piacr1
3810 piacr(i, k) = piacr1
3812 g_piacr(i, k) = piacr(i, k)*g_fsupcol + fsupcol*g_piacr(i, k)
3813 piacr(i, k) = fsupcol*piacr(i, k)
3815 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
3820 IF (piacr(i, k) .GE. 0.) THEN
3825 IF (abs2 .LT. qmin/dtcld) THEN
3826 g_piacr(i, k) = 0.0_8
3829 IF (qrs(i, k, 1) - piacr(i, k)*dtcld .LT. 0.) THEN
3830 g_qrs(i, k, 1) = 0.0_8
3833 g_qrs(i, k, 1) = g_qrs(i, k, 1) - dtcld*g_piacr(i, k)
3834 qrs(i, k, 1) = qrs(i, k, 1) - piacr(i, k)*dtcld
3836 g_x3 = g_qrs(i, k, 2) + delta3*dtcld*g_piacr(i, k)
3837 x3 = qrs(i, k, 2) + piacr(i, k)*delta3*dtcld
3838 IF (x3 .LT. 0.) THEN
3839 g_qrs(i, k, 2) = 0.0_8
3842 g_qrs(i, k, 2) = g_x3
3845 g_x4 = g_qrs(i, k, 3) + (1-delta3)*dtcld*g_piacr(i, k)
3846 x4 = qrs(i, k, 3) + piacr(i, k)*(1-delta3)*dtcld
3847 IF (x4 .LT. 0.) THEN
3848 g_qrs(i, k, 3) = 0.0_8
3851 g_qrs(i, k, 3) = g_x4
3854 temp1 = piacr(i, k)*xlf/cpm(i, k)
3855 g_t(i, k) = g_t(i, k) + dtcld*(xlf*g_piacr(i, k)+piacr(i, k)*&
3856 & g_xlf-temp1*g_cpm(i, k))/cpm(i, k)
3857 t(i, k) = t(i, k) + dtcld*temp1
3858 g_piacr(i, k) = 0.0_8
3860 !-------------------------------------------------------------
3861 ! psaci: Accretion of cloud ice by snow [HDC 10]
3862 ! (T<T0: I->S) psaci: min=0, max=qci(i,k,2)/dtcld
3863 !-------------------------------------------------------------
3864 g_supcol = -g_t(i, k)
3865 supcol = t0c - t(i, k)
3866 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
3867 g_x5 = -(EXP(-(0.07*supcol))*0.07*g_supcol)
3868 x5 = EXP(0.07*(-supcol))
3869 IF (x5 .GT. 1.) THEN
3876 IF (qrs(i, k, 2) .LT. qcrmin) THEN
3880 g_max6 = g_qrs(i, k, 2)
3883 IF (90. .GT. t0c - t(i, k)) THEN
3890 IF (0. .LT. y6) THEN
3898 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
3902 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
3904 pwr1 = den(i, k)**pwy1
3906 IF (max6 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
3910 g_pwr2 = pwy2*max6**(pwy2-1)*g_max6
3913 g_arg1 = -(alpha*bvts*g_max21/4.)
3914 arg1 = -(alpha*bvts*max21/4.)
3916 g_vt2s = vt2s_a*(temp1*(pwr2*g_pwr1+pwr1*g_pwr2)+pwr1*pwr2*EXP(&
3918 vt2s = vt2s_a*(pwr1*pwr2*temp1)
3919 IF (qci(i, k, 2) .LT. qmin) THEN
3923 g_max7 = g_qci(i, k, 2)
3926 g_pwx1 = max7*g_den(i, k) + den(i, k)*g_max7
3927 pwx1 = den(i, k)*max7
3928 IF (pwx1 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. 1.31/8. .NE. &
3929 & INT(1.31/8.))) THEN
3932 g_pwr1 = 1.31*pwx1**(1.31/8.-1)*g_pwx1/8.
3934 pwr1 = pwx1**(1.31/8.)
3935 g_vt2i = vt2i_a*g_pwr1
3937 IF (90. .GT. t0c - t(i, k)) THEN
3944 IF (0. .LT. y1) THEN
3951 g_a = EXP(alpha*max8)*alpha*g_max8
3953 IF (90. .GT. t0c - t(i, k)) THEN
3960 IF (0. .LT. y2) THEN
3967 IF (qrs(i, k, 2) .LT. qcrmin) THEN
3971 g_max22 = g_qrs(i, k, 2)
3972 max22 = qrs(i, k, 2)
3974 IF (qci(i, k, 2) .LT. qmin) THEN
3978 g_max28 = g_qci(i, k, 2)
3979 max28 = qci(i, k, 2)
3981 g_arg1 = -(alpha*3.*g_max9/4.)
3982 arg1 = -(3.*alpha*max9/4.)
3983 g_pwx1 = max22*g_den(i, k) + den(i, k)*g_max22
3984 pwx1 = den(i, k)*max22
3985 IF (pwx1 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT(&
3989 g_pwr1 = 3.*pwx1**(3./4.-1)*g_pwx1/4.
3991 pwr1 = pwx1**(3./4.)
3993 g_b = pwr1*max28*EXP(arg1)*g_arg1 + temp1*(max28*g_pwr1+pwr1*&
3995 b = temp1*(pwr1*max28)
3996 IF (90. .GT. t0c - t(i, k)) THEN
4003 IF (0. .LT. y3) THEN
4010 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4014 g_max23 = g_qrs(i, k, 2)
4015 max23 = qrs(i, k, 2)
4017 IF (qci(i, k, 2) .LT. qmin) THEN
4021 g_max29 = g_qci(i, k, 2)
4022 max29 = qci(i, k, 2)
4024 g_arg1 = -(alpha*g_max10/2.)
4025 arg1 = -(alpha*max10/2.)
4026 IF (den(i, k) .LE. 0.0_8 .AND. (5./8. .EQ. 0.0_8 .OR. 5./8. .NE.&
4030 g_pwr1 = 5.*den(i, k)**(5./8.-1)*g_den(i, k)/8.
4032 pwr1 = den(i, k)**(5./8.)
4034 IF (max23 .EQ. 0.0_8) THEN
4037 g_result1 = g_max23/(2.0*temp1)
4040 IF (max29 .LE. 0.0_8 .AND. (9./8. .EQ. 0.0_8 .OR. 9./8. .NE. INT&
4044 g_pwr2 = 9.*max29**(9./8.-1)*g_max29/8.
4046 pwr2 = max29**(9./8.)
4047 temp1 = pwr1*result1*pwr2
4049 g_c = temp1*EXP(arg1)*g_arg1 + temp2*(pwr2*(result1*g_pwr1+pwr1*&
4050 & g_result1)+pwr1*result1*g_pwr2)
4052 IF (90. .GT. t0c - t(i, k)) THEN
4059 IF (0. .LT. y4) THEN
4066 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4070 g_max24 = g_qrs(i, k, 2)
4071 max24 = qrs(i, k, 2)
4073 IF (qci(i, k, 2) .LT. qmin) THEN
4077 g_max30 = g_qci(i, k, 2)
4078 max30 = qci(i, k, 2)
4080 g_arg1 = -(alpha*g_max11/4.)
4081 arg1 = -(alpha*max11/4.)
4082 temp2 = SQRT(den(i, k))
4083 IF (den(i, k) .EQ. 0.0_8) THEN
4086 g_result1 = g_den(i, k)/(2.0*temp2)
4090 IF (max24 .EQ. 0.0_8) THEN
4093 g_result2 = g_max24/(2.0*temp2)
4096 temp2 = SQRT(result2)
4097 IF (result2 .EQ. 0.0_8) THEN
4100 g_result3 = g_result2/(2.0*temp2)
4103 IF (max30 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
4107 g_pwr1 = 5.*max30**(5./4.-1)*g_max30/4.
4109 pwr1 = max30**(5./4.)
4110 temp2 = result1*result3*pwr1
4112 g_d = temp2*EXP(arg1)*g_arg1 + temp1*(pwr1*(result3*g_result1+&
4113 & result1*g_result3)+result1*result3*g_pwr1)
4115 IF (vt2s - vt2i .GE. 0.) THEN
4116 g_abs3 = g_vt2s - g_vt2i
4119 g_abs3 = g_vt2i - g_vt2s
4122 temp2 = psaci_b*b + psaci_c*c + psaci_d*d
4123 temp1 = a*abs3*eacrs
4124 g_psaci1 = psaci_a*(temp2*(eacrs*(abs3*g_a+a*g_abs3)+a*abs3*&
4125 & g_eacrs)+temp1*(psaci_b*g_b+psaci_c*g_c+psaci_d*g_d))
4126 psaci1 = psaci_a*(temp1*temp2)
4127 IF (psaci1 .GT. qci(i, k, 2)/dtcld) THEN
4128 g_psaci(i, k) = g_qci(i, k, 2)/dtcld
4129 psaci(i, k) = qci(i, k, 2)/dtcld
4131 g_psaci(i, k) = g_psaci1
4132 psaci(i, k) = psaci1
4134 g_psaci(i, k) = psaci(i, k)*g_fsupcol + fsupcol*g_psaci(i, k)
4135 psaci(i, k) = fsupcol*psaci(i, k)
4136 IF (psaci(i, k) .GE. 0.) THEN
4141 IF (abs4 .LT. qmin/dtcld) THEN
4142 g_psaci(i, k) = 0.0_8
4145 IF (qci(i, k, 2) - psaci(i, k)*dtcld .LT. 0.) THEN
4146 g_qci(i, k, 2) = 0.0_8
4149 g_qci(i, k, 2) = g_qci(i, k, 2) - dtcld*g_psaci(i, k)
4150 qci(i, k, 2) = qci(i, k, 2) - psaci(i, k)*dtcld
4152 IF (qrs(i, k, 2) + psaci(i, k)*dtcld .LT. 0.) THEN
4153 g_qrs(i, k, 2) = 0.0_8
4156 g_qrs(i, k, 2) = g_qrs(i, k, 2) + dtcld*g_psaci(i, k)
4157 qrs(i, k, 2) = qrs(i, k, 2) + psaci(i, k)*dtcld
4159 g_psaci(i, k) = 0.0_8
4161 !-------------------------------------------------------------
4162 ! pgaci: Accretion of cloud ice by graupel [LFO 41]
4163 ! (T<T0: I->G) pgaci:min=0,max=qci(i,k,2)/dtcld
4164 !-------------------------------------------------------------
4165 ! supcol = t0c-t(i,k) !not change
4166 ! call smoothif(supcol, 0.,fsupcol,'t0')
4167 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
4168 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
4169 !min(exp(0.07*(-supcol)),1.)
4172 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4176 g_max12 = g_qrs(i, k, 3)
4177 max12 = qrs(i, k, 3)
4180 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
4184 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
4186 pwr1 = den(i, k)**pwy1
4188 IF (max12 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
4192 g_pwr2 = pwy2*max12**(pwy2-1)*g_max12
4195 g_vt2g = vt2g_a*(pwr2*g_pwr1+pwr1*g_pwr2)
4196 vt2g = vt2g_a*pwr1*pwr2
4197 IF (qci(i, k, 2) .LT. qmin) THEN
4201 g_max13 = g_qci(i, k, 2)
4202 max13 = qci(i, k, 2)
4204 g_pwx1 = max13*g_den(i, k) + den(i, k)*g_max13
4205 pwx1 = den(i, k)*max13
4206 IF (pwx1 .LE. 0.0_8 .AND. (1.31/8. .EQ. 0.0_8 .OR. 1.31/8. .NE. &
4207 & INT(1.31/8.))) THEN
4210 g_pwr1 = 1.31*pwx1**(1.31/8.-1)*g_pwx1/8.
4212 pwr1 = pwx1**(1.31/8.)
4213 g_vt2i = vt2i_a*g_pwr1
4215 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4219 g_max14 = g_qrs(i, k, 3)
4220 max14 = qrs(i, k, 3)
4222 IF (qci(i, k, 2) .LT. qmin) THEN
4226 g_max25 = g_qci(i, k, 2)
4227 max25 = qci(i, k, 2)
4229 g_pwx1 = max14*g_den(i, k) + den(i, k)*g_max14
4230 pwx1 = den(i, k)*max14
4231 IF (pwx1 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT(&
4235 g_pwr1 = 3.*pwx1**(3./4.-1)*g_pwx1/4.
4237 pwr1 = pwx1**(3./4.)
4238 g_b = max25*g_pwr1 + pwr1*g_max25
4240 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4244 g_max15 = g_qrs(i, k, 3)
4245 max15 = qrs(i, k, 3)
4247 IF (qci(i, k, 2) .LT. qmin) THEN
4251 g_max26 = g_qci(i, k, 2)
4252 max26 = qci(i, k, 2)
4254 IF (den(i, k) .LE. 0.0_8 .AND. (5./8. .EQ. 0.0_8 .OR. 5./8. .NE.&
4258 g_pwr1 = 5.*den(i, k)**(5./8.-1)*g_den(i, k)/8.
4260 pwr1 = den(i, k)**(5./8.)
4262 IF (max15 .EQ. 0.0_8) THEN
4265 g_result1 = g_max15/(2.0*temp2)
4268 IF (max26 .LE. 0.0_8 .AND. (9./8. .EQ. 0.0_8 .OR. 9./8. .NE. INT&
4272 g_pwr2 = 9.*max26**(9./8.-1)*g_max26/8.
4274 pwr2 = max26**(9./8.)
4275 g_c = pwr2*(result1*g_pwr1+pwr1*g_result1) + pwr1*result1*g_pwr2
4276 c = pwr1*result1*pwr2
4277 IF (qrs(i, k, 3) .LT. qcrmin) THEN
4281 g_max16 = g_qrs(i, k, 3)
4282 max16 = qrs(i, k, 3)
4284 IF (qci(i, k, 2) .LT. qmin) THEN
4288 g_max27 = g_qci(i, k, 2)
4289 max27 = qci(i, k, 2)
4291 temp2 = SQRT(den(i, k))
4292 IF (den(i, k) .EQ. 0.0_8) THEN
4295 g_result1 = g_den(i, k)/(2.0*temp2)
4299 IF (max16 .EQ. 0.0_8) THEN
4302 g_result2 = g_max16/(2.0*temp2)
4305 temp2 = SQRT(result2)
4306 IF (result2 .EQ. 0.0_8) THEN
4309 g_result3 = g_result2/(2.0*temp2)
4312 IF (max27 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
4316 g_pwr1 = 5.*max27**(5./4.-1)*g_max27/4.
4318 pwr1 = max27**(5./4.)
4319 g_d = pwr1*(result3*g_result1+result1*g_result3) + result1*&
4321 d = result1*result3*pwr1
4322 IF (vt2g - vt2i .GE. 0.) THEN
4323 g_abs5 = g_vt2g - g_vt2i
4326 g_abs5 = g_vt2i - g_vt2g
4329 temp2 = pgaci_b*b + pgaci_c*c + pgaci_d*d
4330 g_pgaci1 = pgaci_a*(abs5*egi*(pgaci_b*g_b+pgaci_c*g_c+pgaci_d*&
4331 & g_d)+temp2*(egi*g_abs5+abs5*g_egi))
4332 pgaci1 = pgaci_a*(temp2*(abs5*egi))
4333 IF (pgaci1 .GT. qci(i, k, 2)/dtcld) THEN
4334 g_pgaci(i, k) = g_qci(i, k, 2)/dtcld
4335 pgaci(i, k) = qci(i, k, 2)/dtcld
4337 g_pgaci(i, k) = g_pgaci1
4338 pgaci(i, k) = pgaci1
4340 g_pgaci(i, k) = pgaci(i, k)*g_fsupcol + fsupcol*g_pgaci(i, k)
4341 pgaci(i, k) = fsupcol*pgaci(i, k)
4342 IF (pgaci(i, k) .GE. 0.) THEN
4347 IF (abs6 .LT. qmin/dtcld) THEN
4348 g_pgaci(i, k) = 0.0_8
4351 IF (qci(i, k, 2) - pgaci(i, k)*dtcld .LT. 0.) THEN
4352 g_qci(i, k, 2) = 0.0_8
4355 g_qci(i, k, 2) = g_qci(i, k, 2) - dtcld*g_pgaci(i, k)
4356 qci(i, k, 2) = qci(i, k, 2) - pgaci(i, k)*dtcld
4358 IF (qrs(i, k, 3) + pgaci(i, k)*dtcld .LT. 0.) THEN
4359 g_qrs(i, k, 3) = 0.0_8
4362 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgaci(i, k)
4363 qrs(i, k, 3) = qrs(i, k, 3) + pgaci(i, k)*dtcld
4365 g_pgaci(i, k) = 0.0_8
4367 !-------------------------------------------------------------
4368 ! psacw: Accretion of cloud water by snow [LFO 24]
4369 ! (T<T0: C->G, and T>=T0: C->R) psacw:min=0,max=qci(i,k,1)/dtcld
4370 !-------------------------------------------------------------
4371 ! supcol = t0c-t(i,k) !not change
4372 ! call smoothif(supcol, 0.,fsupcol,'t0')
4373 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
4374 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
4376 ! cpm(i,k)=cpmcal(q(i,k)) !not change
4377 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
4379 xlf = xls - xl(i, k)
4380 IF (supcol .LT. 0.) THEN
4384 IF (qrs(i, k, 2) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
4385 IF (90. .GT. t0c - t(i, k)) THEN
4392 IF (0. .LT. y5) THEN
4399 g_arg1 = (1.-bvts)*alpha*g_max17/4.
4400 arg1 = (1.-bvts)*alpha*max17/4.
4401 g_a = EXP(arg1)*g_arg1
4404 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE.&
4408 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
4410 pwr1 = den(i, k)**pwy1
4412 IF (qrs(i, k, 2) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
4413 & .NE. INT(pwy2))) THEN
4416 g_pwr2 = pwy2*qrs(i, k, 2)**(pwy2-1)*g_qrs(i, k, 2)
4418 pwr2 = qrs(i, k, 2)**pwy2
4420 g_psacw(i, k) = psacw_a*(qci(i, k, 1)*(pwr2*(pwr1*g_a+a*g_pwr1&
4421 & )+a*pwr1*g_pwr2)+temp2*g_qci(i, k, 1))
4422 psacw(i, k) = psacw_a*(temp2*qci(i, k, 1))
4424 g_psacw(i, k) = 0.0_8
4427 IF (psacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
4428 g_x6 = g_qci(i, k, 1)/dtcld
4429 x6 = qci(i, k, 1)/dtcld
4431 g_x6 = g_psacw(i, k)
4434 IF (x6 .LT. 0.) THEN
4435 g_psacw(i, k) = 0.0_8
4438 g_psacw(i, k) = g_x6
4441 g_psacw(i, k) = psacw(i, k)*g_fsupcol + fsupcol*g_psacw(i, k)
4442 psacw(i, k) = fsupcol*psacw(i, k)
4443 IF (psacw(i, k) .GE. 0.) THEN
4448 IF (abs7 .LT. qmin/dtcld) THEN
4449 g_psacw(i, k) = 0.0_8
4452 IF (qci(i, k, 1) - psacw(i, k)*dtcld .LT. 0.) THEN
4453 g_qci(i, k, 1) = 0.0_8
4456 g_qci(i, k, 1) = g_qci(i, k, 1) - dtcld*g_psacw(i, k)
4457 qci(i, k, 1) = qci(i, k, 1) - psacw(i, k)*dtcld
4459 g_x7 = g_qrs(i, k, 1) + dtcld*((1.-fsupcol)*g_psacw(i, k)-psacw(&
4461 x7 = qrs(i, k, 1) + (1.-fsupcol)*psacw(i, k)*dtcld
4462 IF (x7 .LT. 0.) THEN
4463 g_qrs(i, k, 1) = 0.0_8
4466 g_qrs(i, k, 1) = g_x7
4469 g_x8 = g_qrs(i, k, 3) + dtcld*(psacw(i, k)*g_fsupcol+fsupcol*&
4471 x8 = qrs(i, k, 3) + fsupcol*psacw(i, k)*dtcld
4472 IF (x8 .LT. 0.) THEN
4473 g_qrs(i, k, 3) = 0.0_8
4476 g_qrs(i, k, 3) = g_x8
4479 temp2 = psacw(i, k)/cpm(i, k)
4480 g_t(i, k) = g_t(i, k) + dtcld*(temp2*(xlf*g_fsupcol+fsupcol*&
4481 & g_xlf)+fsupcol*xlf*(g_psacw(i, k)-temp2*g_cpm(i, k))/cpm(i, k)&
4483 t(i, k) = t(i, k) + dtcld*(fsupcol*xlf*temp2)
4485 g_psacw(i, k) = (1-fsupcol)*g_psacw(i, k) - psacw(i, k)*&
4487 psacw(i, k) = (1-fsupcol)*psacw(i, k)
4488 !-------------------------------------------------------------
4489 ! pgacw: Accretion of cloud water by graupel [LFO 40]
4490 ! (T<T0: C->G, and T>=T0: C->R) pgacw:min=0.,max=qci(i,k,1)/dtcld
4491 !-------------------------------------------------------------
4492 g_supcol = -g_t(i, k)
4493 supcol = t0c - t(i, k)
4494 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
4495 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
4496 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
4497 ! cpm(i,k)=cpmcal(q(i,k)) !not change
4498 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
4500 xlf = xls - xl(i, k)
4501 IF (supcol .LT. 0.) THEN
4505 IF (qrs(i, k, 3) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
4507 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE.&
4511 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
4513 pwr1 = den(i, k)**pwy1
4515 IF (qrs(i, k, 3) .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 &
4516 & .NE. INT(pwy2))) THEN
4519 g_pwr2 = pwy2*qrs(i, k, 3)**(pwy2-1)*g_qrs(i, k, 3)
4521 pwr2 = qrs(i, k, 3)**pwy2
4522 g_pgacw(i, k) = pgacw_a*(qci(i, k, 1)*(pwr2*g_pwr1+pwr1*g_pwr2&
4523 & )+pwr1*pwr2*g_qci(i, k, 1))
4524 pgacw(i, k) = pgacw_a*pwr1*pwr2*qci(i, k, 1)
4526 g_pgacw(i, k) = 0.0_8
4529 IF (pgacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
4530 g_x9 = g_qci(i, k, 1)/dtcld
4531 x9 = qci(i, k, 1)/dtcld
4533 g_x9 = g_pgacw(i, k)
4536 IF (x9 .LT. 0.) THEN
4537 g_pgacw(i, k) = 0.0_8
4540 g_pgacw(i, k) = g_x9
4543 IF (pgacw(i, k) .GE. 0.) THEN
4548 !pgacw(i,k)=fqg*fqc*pgacw(i,k)
4549 IF (abs8 .LT. qmin/dtcld) THEN
4550 g_pgacw(i, k) = 0.0_8
4553 IF (qci(i, k, 1) - pgacw(i, k)*dtcld .LT. 0.) THEN
4554 g_qci(i, k, 1) = 0.0_8
4557 g_qci(i, k, 1) = g_qci(i, k, 1) - dtcld*g_pgacw(i, k)
4558 qci(i, k, 1) = qci(i, k, 1) - pgacw(i, k)*dtcld
4560 g_x10 = g_qrs(i, k, 1) + dtcld*((1.-fsupcol)*g_pgacw(i, k)-pgacw&
4562 x10 = qrs(i, k, 1) + (1.-fsupcol)*pgacw(i, k)*dtcld
4563 IF (x10 .LT. 0.) THEN
4564 g_qrs(i, k, 1) = 0.0_8
4567 g_qrs(i, k, 1) = g_x10
4570 g_x11 = g_qrs(i, k, 3) + dtcld*(pgacw(i, k)*g_fsupcol+fsupcol*&
4572 x11 = qrs(i, k, 3) + fsupcol*pgacw(i, k)*dtcld
4573 IF (x11 .LT. 0.) THEN
4574 g_qrs(i, k, 3) = 0.0_8
4577 g_qrs(i, k, 3) = g_x11
4580 temp2 = pgacw(i, k)/cpm(i, k)
4581 g_t(i, k) = g_t(i, k) + dtcld*(temp2*(xlf*g_fsupcol+fsupcol*&
4582 & g_xlf)+fsupcol*xlf*(g_pgacw(i, k)-temp2*g_cpm(i, k))/cpm(i, k)&
4584 t(i, k) = t(i, k) + dtcld*(fsupcol*xlf*temp2)
4586 g_pgacw(i, k) = (1-fsupcol)*g_pgacw(i, k) - pgacw(i, k)*&
4588 pgacw(i, k) = (1-fsupcol)*pgacw(i, k)
4591 END SUBROUTINE G_ACCRET1
4593 !===================================================================
4594 SUBROUTINE ACCRET1(qci, den, qrs, t, q, dtcld, praci, piacr, psaci, &
4595 & pgaci, psacw, pgacw, ims, ime, kms, kme, its, ite, kts, kte)
4597 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
4598 !-------------------------------------------------------------------
4599 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
4600 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
4601 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
4602 REAL, DIMENSION(its:ite, kts:kte) :: praci, piacr, psaci, pgaci, &
4603 & psacw, pgacw, t, xl, cpm
4604 REAL :: supcol, dtcld, eacrs, egi, praci1, piacr1, psaci1, pgaci1, &
4607 REAL :: fsupcol, fqc, fqi, fqr, fqs, fqg, delta3, xlf, a, b, c, d, e
4680 !-------------------------------------------------------------
4681 ! praci: Accretion of cloud ice by rain [LFO 25]
4682 ! (T<T0: I->S or I->G) praci: min=0,max=qci(i,k,2)/dtcld
4683 !-------------------------------------------------------------
4684 supcol = t0c - t(i, k)
4685 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4686 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4692 pwr1 = den(i, k)**pwy1
4695 vt2r = vt2r_a*pwr1*pwr2
4696 IF (qci(i, k, 2) .LT. qmin) THEN
4701 pwx1 = den(i, k)*max2
4702 pwr1 = pwx1**(1.31/8.)
4704 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4709 IF (qci(i, k, 2) .LT. qmin) THEN
4712 max18 = qci(i, k, 2)
4714 pwx1 = den(i, k)*max3
4715 pwr1 = pwx1**(3./4.)
4717 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4722 IF (qci(i, k, 2) .LT. qmin) THEN
4725 max19 = qci(i, k, 2)
4727 pwr1 = den(i, k)**(5./8.)
4728 result1 = SQRT(max4)
4729 pwr2 = max19**(9./8.)
4730 c = pwr1*result1*pwr2
4731 IF (qrs(i, k, 1) .LT. qcrmin) THEN
4736 IF (qci(i, k, 2) .LT. qmin) THEN
4739 max20 = qci(i, k, 2)
4741 result1 = SQRT(den(i, k))
4742 result2 = SQRT(max5)
4743 result3 = SQRT(result2)
4744 pwr1 = max20**(5./4.)
4745 d = result1*result3*pwr1
4746 IF (vt2r - vt2i .GE. 0.) THEN
4751 praci1 = praci_a*abs0*(praci_b*b+praci_c*c+praci_d*d)
4752 IF (praci1 .GT. qci(i, k, 2)/dtcld) THEN
4753 praci(i, k) = qci(i, k, 2)/dtcld
4755 praci(i, k) = praci1
4757 praci(i, k) = fsupcol*praci(i, k)
4759 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
4764 IF (praci(i, k) .GE. 0.) THEN
4769 IF (abs1 .LT. qmin/dtcld) praci(i, k) = 0.
4770 IF (qci(i, k, 2) - praci(i, k)*dtcld .LT. 0.) THEN
4773 qci(i, k, 2) = qci(i, k, 2) - praci(i, k)*dtcld
4775 x1 = qrs(i, k, 2) + praci(i, k)*delta3*dtcld
4776 IF (x1 .LT. 0.) THEN
4781 x2 = qrs(i, k, 3) + praci(i, k)*(1-delta3)*dtcld
4782 IF (x2 .LT. 0.) THEN
4788 !-------------------------------------------------------------
4789 ! piacr: Accretion of rain by cloud ice [LFO 26]
4790 ! (T<T0: R->S or R->G) piacr: min=0,max=qrs(i,k,1)/dtcld
4791 !-------------------------------------------------------------
4792 ! supcol = t0c-t(i,k) !not change
4793 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4794 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
4795 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
4797 cpm(i, k) = CPMCAL(q(i, k))
4798 xl(i, k) = XLCAL(t(i, k))
4799 xlf = xls - xl(i, k)
4800 IF (supcol .LT. 0.) xlf = xlf0
4801 IF (qci(i, k, 2) .GT. 0. .AND. qrs(i, k, 1) .GT. 0.) THEN
4804 pwr1 = den(i, k)**pwy1
4806 pwr2 = qrs(i, k, 1)**pwy2
4807 piacr1 = piacr_a*pwr1*qci(i, k, 2)**0.75*pwr2
4811 IF (piacr1 .GT. qrs(i, k, 1)/dtcld) THEN
4812 piacr(i, k) = qrs(i, k, 1)/dtcld
4814 piacr(i, k) = piacr1
4816 piacr(i, k) = fsupcol*piacr(i, k)
4818 IF (qrs(i, k, 1) .LT. 1.e-4) THEN
4823 IF (piacr(i, k) .GE. 0.) THEN
4828 IF (abs2 .LT. qmin/dtcld) piacr(i, k) = 0.
4829 IF (qrs(i, k, 1) - piacr(i, k)*dtcld .LT. 0.) THEN
4832 qrs(i, k, 1) = qrs(i, k, 1) - piacr(i, k)*dtcld
4834 x3 = qrs(i, k, 2) + piacr(i, k)*delta3*dtcld
4835 IF (x3 .LT. 0.) THEN
4840 x4 = qrs(i, k, 3) + piacr(i, k)*(1-delta3)*dtcld
4841 IF (x4 .LT. 0.) THEN
4846 t(i, k) = t(i, k) + piacr(i, k)*dtcld*xlf/cpm(i, k)
4848 !-------------------------------------------------------------
4849 ! psaci: Accretion of cloud ice by snow [HDC 10]
4850 ! (T<T0: I->S) psaci: min=0, max=qci(i,k,2)/dtcld
4851 !-------------------------------------------------------------
4852 supcol = t0c - t(i, k)
4853 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
4854 x5 = EXP(0.07*(-supcol))
4855 IF (x5 .GT. 1.) THEN
4860 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4865 IF (90. .GT. t0c - t(i, k)) THEN
4870 IF (0. .LT. y6) THEN
4876 pwr1 = den(i, k)**pwy1
4879 arg1 = -(alpha*bvts*max21/4.)
4880 vt2s = vt2s_a*pwr1*pwr2*EXP(arg1)
4881 IF (qci(i, k, 2) .LT. qmin) THEN
4886 pwx1 = den(i, k)*max7
4887 pwr1 = pwx1**(1.31/8.)
4889 IF (90. .GT. t0c - t(i, k)) THEN
4894 IF (0. .LT. y1) THEN
4900 IF (90. .GT. t0c - t(i, k)) THEN
4905 IF (0. .LT. y2) THEN
4910 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4913 max22 = qrs(i, k, 2)
4915 IF (qci(i, k, 2) .LT. qmin) THEN
4918 max28 = qci(i, k, 2)
4920 arg1 = -(3.*alpha*max9/4.)
4921 pwx1 = den(i, k)*max22
4922 pwr1 = pwx1**(3./4.)
4923 b = EXP(arg1)*pwr1*max28
4924 IF (90. .GT. t0c - t(i, k)) THEN
4929 IF (0. .LT. y3) THEN
4934 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4937 max23 = qrs(i, k, 2)
4939 IF (qci(i, k, 2) .LT. qmin) THEN
4942 max29 = qci(i, k, 2)
4944 arg1 = -(alpha*max10/2.)
4945 pwr1 = den(i, k)**(5./8.)
4946 result1 = SQRT(max23)
4947 pwr2 = max29**(9./8.)
4948 c = EXP(arg1)*pwr1*result1*pwr2
4949 IF (90. .GT. t0c - t(i, k)) THEN
4954 IF (0. .LT. y4) THEN
4959 IF (qrs(i, k, 2) .LT. qcrmin) THEN
4962 max24 = qrs(i, k, 2)
4964 IF (qci(i, k, 2) .LT. qmin) THEN
4967 max30 = qci(i, k, 2)
4969 arg1 = -(alpha*max11/4.)
4970 result1 = SQRT(den(i, k))
4971 result2 = SQRT(max24)
4972 result3 = SQRT(result2)
4973 pwr1 = max30**(5./4.)
4974 d = EXP(arg1)*result1*result3*pwr1
4975 IF (vt2s - vt2i .GE. 0.) THEN
4980 psaci1 = psaci_a*a*abs3*(psaci_b*b+psaci_c*c+psaci_d*d)*eacrs
4981 IF (psaci1 .GT. qci(i, k, 2)/dtcld) THEN
4982 psaci(i, k) = qci(i, k, 2)/dtcld
4984 psaci(i, k) = psaci1
4986 psaci(i, k) = fsupcol*psaci(i, k)
4987 IF (psaci(i, k) .GE. 0.) THEN
4992 IF (abs4 .LT. qmin/dtcld) psaci(i, k) = 0.
4993 IF (qci(i, k, 2) - psaci(i, k)*dtcld .LT. 0.) THEN
4996 qci(i, k, 2) = qci(i, k, 2) - psaci(i, k)*dtcld
4998 IF (qrs(i, k, 2) + psaci(i, k)*dtcld .LT. 0.) THEN
5001 qrs(i, k, 2) = qrs(i, k, 2) + psaci(i, k)*dtcld
5004 !-------------------------------------------------------------
5005 ! pgaci: Accretion of cloud ice by graupel [LFO 41]
5006 ! (T<T0: I->G) pgaci:min=0,max=qci(i,k,2)/dtcld
5007 !-------------------------------------------------------------
5008 ! supcol = t0c-t(i,k) !not change
5009 ! call smoothif(supcol, 0.,fsupcol,'t0')
5010 !call smoothif(qci(i,k,2),qmin ,fqi,'q0')
5011 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
5012 !min(exp(0.07*(-supcol)),1.)
5014 IF (qrs(i, k, 3) .LT. qcrmin) THEN
5017 max12 = qrs(i, k, 3)
5020 pwr1 = den(i, k)**pwy1
5023 vt2g = vt2g_a*pwr1*pwr2
5024 IF (qci(i, k, 2) .LT. qmin) THEN
5027 max13 = qci(i, k, 2)
5029 pwx1 = den(i, k)*max13
5030 pwr1 = pwx1**(1.31/8.)
5032 IF (qrs(i, k, 3) .LT. qcrmin) THEN
5035 max14 = qrs(i, k, 3)
5037 IF (qci(i, k, 2) .LT. qmin) THEN
5040 max25 = qci(i, k, 2)
5042 pwx1 = den(i, k)*max14
5043 pwr1 = pwx1**(3./4.)
5045 IF (qrs(i, k, 3) .LT. qcrmin) THEN
5048 max15 = qrs(i, k, 3)
5050 IF (qci(i, k, 2) .LT. qmin) THEN
5053 max26 = qci(i, k, 2)
5055 pwr1 = den(i, k)**(5./8.)
5056 result1 = SQRT(max15)
5057 pwr2 = max26**(9./8.)
5058 c = pwr1*result1*pwr2
5059 IF (qrs(i, k, 3) .LT. qcrmin) THEN
5062 max16 = qrs(i, k, 3)
5064 IF (qci(i, k, 2) .LT. qmin) THEN
5067 max27 = qci(i, k, 2)
5069 result1 = SQRT(den(i, k))
5070 result2 = SQRT(max16)
5071 result3 = SQRT(result2)
5072 pwr1 = max27**(5./4.)
5073 d = result1*result3*pwr1
5074 IF (vt2g - vt2i .GE. 0.) THEN
5079 pgaci1 = pgaci_a*abs5*(pgaci_b*b+pgaci_c*c+pgaci_d*d)*egi
5080 IF (pgaci1 .GT. qci(i, k, 2)/dtcld) THEN
5081 pgaci(i, k) = qci(i, k, 2)/dtcld
5083 pgaci(i, k) = pgaci1
5085 pgaci(i, k) = fsupcol*pgaci(i, k)
5086 IF (pgaci(i, k) .GE. 0.) THEN
5091 IF (abs6 .LT. qmin/dtcld) pgaci(i, k) = 0.
5092 IF (qci(i, k, 2) - pgaci(i, k)*dtcld .LT. 0.) THEN
5095 qci(i, k, 2) = qci(i, k, 2) - pgaci(i, k)*dtcld
5097 IF (qrs(i, k, 3) + pgaci(i, k)*dtcld .LT. 0.) THEN
5100 qrs(i, k, 3) = qrs(i, k, 3) + pgaci(i, k)*dtcld
5103 !-------------------------------------------------------------
5104 ! psacw: Accretion of cloud water by snow [LFO 24]
5105 ! (T<T0: C->G, and T>=T0: C->R) psacw:min=0,max=qci(i,k,1)/dtcld
5106 !-------------------------------------------------------------
5107 ! supcol = t0c-t(i,k) !not change
5108 ! call smoothif(supcol, 0.,fsupcol,'t0')
5109 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
5110 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
5112 ! cpm(i,k)=cpmcal(q(i,k)) !not change
5113 xl(i, k) = XLCAL(t(i, k))
5114 xlf = xls - xl(i, k)
5115 IF (supcol .LT. 0.) xlf = xlf0
5116 IF (qrs(i, k, 2) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
5117 IF (90. .GT. t0c - t(i, k)) THEN
5122 IF (0. .LT. y5) THEN
5127 arg1 = (1.-bvts)*alpha*max17/4.
5130 pwr1 = den(i, k)**pwy1
5132 pwr2 = qrs(i, k, 2)**pwy2
5133 psacw(i, k) = psacw_a*a*pwr1*pwr2*qci(i, k, 1)
5137 IF (psacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
5138 x6 = qci(i, k, 1)/dtcld
5142 IF (x6 .LT. 0.) THEN
5147 psacw(i, k) = fsupcol*psacw(i, k)
5148 IF (psacw(i, k) .GE. 0.) THEN
5153 IF (abs7 .LT. qmin/dtcld) psacw(i, k) = 0.
5154 IF (qci(i, k, 1) - psacw(i, k)*dtcld .LT. 0.) THEN
5157 qci(i, k, 1) = qci(i, k, 1) - psacw(i, k)*dtcld
5159 x7 = qrs(i, k, 1) + (1.-fsupcol)*psacw(i, k)*dtcld
5160 IF (x7 .LT. 0.) THEN
5165 x8 = qrs(i, k, 3) + fsupcol*psacw(i, k)*dtcld
5166 IF (x8 .LT. 0.) THEN
5171 t(i, k) = t(i, k) + fsupcol*psacw(i, k)*dtcld*xlf/cpm(i, k)
5173 psacw(i, k) = (1-fsupcol)*psacw(i, k)
5174 !-------------------------------------------------------------
5175 ! pgacw: Accretion of cloud water by graupel [LFO 40]
5176 ! (T<T0: C->G, and T>=T0: C->R) pgacw:min=0.,max=qci(i,k,1)/dtcld
5177 !-------------------------------------------------------------
5178 supcol = t0c - t(i, k)
5179 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
5180 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
5181 !call smoothif(qci(i,k,1),qmin ,fqc,'q0')
5182 ! cpm(i,k)=cpmcal(q(i,k)) !not change
5183 xl(i, k) = XLCAL(t(i, k))
5184 xlf = xls - xl(i, k)
5185 IF (supcol .LT. 0.) xlf = xlf0
5186 IF (qrs(i, k, 3) .GT. 0. .AND. qci(i, k, 1) .GT. 0.) THEN
5188 pwr1 = den(i, k)**pwy1
5190 pwr2 = qrs(i, k, 3)**pwy2
5191 pgacw(i, k) = pgacw_a*pwr1*pwr2*qci(i, k, 1)
5195 IF (pgacw(i, k) .GT. qci(i, k, 1)/dtcld) THEN
5196 x9 = qci(i, k, 1)/dtcld
5200 IF (x9 .LT. 0.) THEN
5205 IF (pgacw(i, k) .GE. 0.) THEN
5210 !pgacw(i,k)=fqg*fqc*pgacw(i,k)
5211 IF (abs8 .LT. qmin/dtcld) pgacw(i, k) = 0.
5212 IF (qci(i, k, 1) - pgacw(i, k)*dtcld .LT. 0.) THEN
5215 qci(i, k, 1) = qci(i, k, 1) - pgacw(i, k)*dtcld
5217 x10 = qrs(i, k, 1) + (1.-fsupcol)*pgacw(i, k)*dtcld
5218 IF (x10 .LT. 0.) THEN
5223 x11 = qrs(i, k, 3) + fsupcol*pgacw(i, k)*dtcld
5224 IF (x11 .LT. 0.) THEN
5229 t(i, k) = t(i, k) + fsupcol*pgacw(i, k)*dtcld*xlf/cpm(i, k)
5231 pgacw(i, k) = (1-fsupcol)*pgacw(i, k)
5234 END SUBROUTINE ACCRET1
5236 ! Differentiation of accret2 in forward (tangent) mode (with options r8):
5237 ! variations of useful results: t psacr psacw pgacr pgacs pracs
5238 ! pgacw qrs pseml pgeml
5239 ! with respect to varying inputs: q t psacr psacw pgacr pgacs
5240 ! pracs pgacw den qrs pseml pgeml
5241 !=======================================================================
5243 !=======================================================================
5244 SUBROUTINE G_ACCRET2(qrs, g_qrs, t, g_t, q, g_q, den, g_den, dtcld, &
5245 & psacw, g_psacw, pgacw, g_pgacw, pracs, g_pracs, psacr, g_psacr, &
5246 & pgacr, g_pgacr, pgacs, g_pgacs, pseml, g_pseml, pgeml, g_pgeml, ims&
5247 & , ime, kms, kme, its, ite, kts, kte)
5249 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
5250 !-------------------------------------------------------------------
5251 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
5252 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs
5253 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
5254 REAL, DIMENSION(ims:ime, kms:kme) :: g_den, g_q
5255 REAL, DIMENSION(its:ite, kts:kte) :: psacw, pgacw, pracs, psacr, &
5256 & pgacr, pgacs, pseml, pgeml, t, xl, cpm
5257 REAL, DIMENSION(its:ite, kts:kte) :: g_psacw, g_pgacw, g_pracs, &
5258 & g_psacr, g_pgacr, g_pgacs, g_pseml, g_pgeml, g_t, g_xl, g_cpm
5259 REAL :: supcol, vt2r, vt2s, vt2g, dtcld, xlf, egs
5260 REAL :: g_supcol, g_vt2r, g_vt2s, g_vt2g, g_xlf, g_egs
5261 REAL :: acrfac1, acrfac2, acrfac3, acrfac4, pracs1, psacr1, pgacr1, &
5263 REAL :: g_pracs1, g_psacr1, g_pgacr1, g_pgacs1
5265 REAL :: fsupcol, ft0, fqr, fqs, fqg, temp1, delta2, a, b, c, d
5266 REAL :: g_fsupcol, g_ft0, g_fqs, g_fqg, g_a, g_b, g_c, g_d
5444 !-------------------------------------------------------------
5445 ! pracs: Accretion of snow by rain [LFO 27]
5446 ! (T<T0: S->G) pracs: min=0., max=qrs(i,k,2)/dtcld
5447 !-------------------------------------------------------------
5448 g_supcol = -g_t(i, k)
5449 supcol = t0c - t(i, k)
5450 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
5451 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5455 g_max1 = g_qrs(i, k, 1)
5458 !call smoothif(qrs(i,k,1),1.e-4,fqr,'q0')
5459 !call smoothif(qrs(i,k,2),1.e-4,fqs,'q0')
5461 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
5465 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
5467 pwr1 = den(i, k)**pwy1
5469 IF (max1 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
5473 g_pwr2 = pwy2*max1**(pwy2-1)*g_max1
5476 g_vt2r = vt2r_a*(pwr2*g_pwr1+pwr1*g_pwr2)
5477 vt2r = vt2r_a*pwr1*pwr2
5478 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5482 g_max2 = g_qrs(i, k, 2)
5485 IF (90. .GT. t0c - t(i, k)) THEN
5492 IF (0. .LT. y13) THEN
5500 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
5504 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
5506 pwr1 = den(i, k)**pwy1
5508 IF (max2 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
5512 g_pwr2 = pwy2*max2**(pwy2-1)*g_max2
5515 g_arg1 = -(alpha*bvts*g_max24/4.)
5516 arg1 = -(alpha*bvts*max24/4.)
5518 g_vt2s = vt2s_a*(temp*(pwr2*g_pwr1+pwr1*g_pwr2)+pwr1*pwr2*EXP(&
5520 vt2s = vt2s_a*(pwr1*pwr2*temp)
5521 IF (90. .GT. t0c - t(i, k)) THEN
5528 IF (0. .LT. y1) THEN
5535 g_a = EXP(alpha*max3)*alpha*g_max3
5537 IF (90. .GT. t0c - t(i, k)) THEN
5544 IF (0. .LT. y2) THEN
5551 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5555 g_max25 = g_qrs(i, k, 2)
5556 max25 = qrs(i, k, 2)
5558 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5562 g_max39 = g_qrs(i, k, 1)
5563 max39 = qrs(i, k, 1)
5565 g_arg1 = -(alpha*3.*g_max4/2.)
5566 arg1 = -(3.*alpha*max4/2.)
5567 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
5571 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
5573 pwr1 = den(i, k)**(3./4.)
5574 IF (max25 .LE. 0.0_8 .AND. (3./2. .EQ. 0.0_8 .OR. 3./2. .NE. INT&
5578 g_pwr2 = 3.*max25**(3./2.-1)*g_max25/2.
5580 pwr2 = max25**(3./2.)
5582 IF (max39 .EQ. 0.0_8) THEN
5585 g_result1 = g_max39/(2.0*temp)
5588 temp = SQRT(result1)
5589 IF (result1 .EQ. 0.0_8) THEN
5592 g_result2 = g_result1/(2.0*temp)
5595 temp = pwr1*pwr2*result2
5597 g_b = temp*EXP(arg1)*g_arg1 + temp0*(result2*(pwr2*g_pwr1+pwr1*&
5598 & g_pwr2)+pwr1*pwr2*g_result2)
5600 IF (90. .GT. t0c - t(i, k)) THEN
5607 IF (0. .LT. y3) THEN
5614 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5618 g_max26 = g_qrs(i, k, 2)
5619 max26 = qrs(i, k, 2)
5621 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5625 g_max40 = g_qrs(i, k, 1)
5626 max40 = qrs(i, k, 1)
5628 g_arg1 = -(alpha*5.*g_max5/4.)
5629 arg1 = -(5.*alpha*max5/4.)
5630 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
5634 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
5636 pwr1 = den(i, k)**(3./4.)
5637 IF (max26 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
5641 g_pwr2 = 5.*max26**(5./4.-1)*g_max26/4.
5643 pwr2 = max26**(5./4.)
5645 IF (max40 .EQ. 0.0_8) THEN
5648 g_result1 = g_max40/(2.0*temp0)
5651 temp0 = pwr1*pwr2*result1
5653 g_c = temp0*EXP(arg1)*g_arg1 + temp*(result1*(pwr2*g_pwr1+pwr1*&
5654 & g_pwr2)+pwr1*pwr2*g_result1)
5656 IF (90. .GT. t0c - t(i, k)) THEN
5663 IF (0. .LT. y4) THEN
5670 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5674 g_max27 = g_qrs(i, k, 2)
5675 max27 = qrs(i, k, 2)
5677 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5681 g_max41 = g_qrs(i, k, 1)
5682 max41 = qrs(i, k, 1)
5684 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
5688 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
5690 pwr1 = den(i, k)**(3./4.)
5691 IF (max41 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT&
5695 g_pwr2 = 3.*max41**(3./4.-1)*g_max41/4.
5697 pwr2 = max41**(3./4.)
5698 temp0 = pwr1*max27*pwr2
5699 temp = EXP(-(alpha*max6))
5700 g_d = temp*(pwr2*(max27*g_pwr1+pwr1*g_max27)+pwr1*max27*g_pwr2) &
5701 & - temp0*EXP(-(alpha*max6))*alpha*g_max6
5703 IF (vt2r - vt2s .GE. 0.) THEN
5704 g_abs0 = g_vt2r - g_vt2s
5707 g_abs0 = g_vt2s - g_vt2r
5710 temp0 = pracs_b*b + pracs_c*c + pracs_d*d
5711 g_pracs1 = pracs_a*(temp0*(abs0*g_a+a*g_abs0)+a*abs0*(pracs_b*&
5712 & g_b+pracs_c*g_c+pracs_d*g_d))
5713 pracs1 = pracs_a*(a*abs0*temp0)
5714 IF (pracs1 .GT. qrs(i, k, 2)/dtcld) THEN
5715 g_pracs(i, k) = g_qrs(i, k, 2)/dtcld
5716 pracs(i, k) = qrs(i, k, 2)/dtcld
5718 g_pracs(i, k) = g_pracs1
5719 pracs(i, k) = pracs1
5721 g_pracs(i, k) = pracs(i, k)*g_fsupcol + fsupcol*g_pracs(i, k)
5722 pracs(i, k) = fsupcol*pracs(i, k)
5723 IF (pracs(i, k) .GE. 0.) THEN
5728 IF (abs1 .LT. qmin/dtcld) THEN
5729 g_pracs(i, k) = 0.0_8
5732 IF (qrs(i, k, 2) - pracs(i, k)*dtcld .LT. 0.) THEN
5733 g_qrs(i, k, 2) = 0.0_8
5736 g_qrs(i, k, 2) = g_qrs(i, k, 2) - dtcld*g_pracs(i, k)
5737 qrs(i, k, 2) = qrs(i, k, 2) - pracs(i, k)*dtcld
5739 IF (qrs(i, k, 3) + pracs(i, k)*dtcld .LT. 0.) THEN
5740 g_qrs(i, k, 3) = 0.0_8
5743 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pracs(i, k)
5744 qrs(i, k, 3) = qrs(i, k, 3) + pracs(i, k)*dtcld
5746 g_pracs(i, k) = 0.0_8
5748 !-------------------------------------------------------------
5749 ! psacr: Accretion of rain by snow [LFO 28]
5750 ! (T< T0: R->S or R->G) min=0.,max=qrs(i,k,1)/dtcld
5751 ! (T>=T0: S->R enhance melting of snow) min=0.,max=qrs(i,k,2)/dtcld
5752 !-------------------------------------------------------------
5753 ! supcol = t0c-t(i,k) !not change
5754 ! call smoothif(supcol,0.,fsupcol,'t0')
5755 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
5756 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
5758 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
5759 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
5761 xlf = xls - xl(i, k)
5762 IF (supcol .LT. 0.) THEN
5766 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5770 g_max7 = g_qrs(i, k, 1)
5774 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
5778 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
5780 pwr1 = den(i, k)**pwy1
5782 IF (max7 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
5786 g_pwr2 = pwy2*max7**(pwy2-1)*g_max7
5789 g_vt2r = vt2r_a*(pwr2*g_pwr1+pwr1*g_pwr2)
5790 vt2r = vt2r_a*pwr1*pwr2
5791 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5795 g_max8 = g_qrs(i, k, 2)
5798 IF (90. .GT. t0c - t(i, k)) THEN
5805 IF (0. .LT. y14) THEN
5813 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
5817 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
5819 pwr1 = den(i, k)**pwy1
5821 IF (max8 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
5825 g_pwr2 = pwy2*max8**(pwy2-1)*g_max8
5828 g_arg1 = -(alpha*bvts*g_max28/4.)
5829 arg1 = -(alpha*bvts*max28/4.)
5831 g_vt2s = vt2s_a*(temp0*(pwr2*g_pwr1+pwr1*g_pwr2)+pwr1*pwr2*EXP(&
5833 vt2s = vt2s_a*(pwr1*pwr2*temp0)
5834 IF (90. .GT. t0c - t(i, k)) THEN
5841 IF (0. .LT. y5) THEN
5848 g_a = EXP(alpha*max9)*alpha*g_max9
5850 IF (90. .GT. t0c - t(i, k)) THEN
5857 IF (0. .LT. y6) THEN
5864 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5868 g_max29 = g_qrs(i, k, 1)
5869 max29 = qrs(i, k, 1)
5871 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5875 g_max42 = g_qrs(i, k, 2)
5876 max42 = qrs(i, k, 2)
5878 g_arg1 = -(alpha*g_max10/4.)
5879 arg1 = -(alpha*max10/4.)
5880 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
5884 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
5886 pwr1 = den(i, k)**(3./4.)
5887 IF (max29 .LE. 0.0_8 .AND. (3./2. .EQ. 0.0_8 .OR. 3./2. .NE. INT&
5891 g_pwr2 = 3.*max29**(3./2.-1)*g_max29/2.
5893 pwr2 = max29**(3./2.)
5895 IF (max42 .EQ. 0.0_8) THEN
5898 g_result1 = g_max42/(2.0*temp0)
5901 temp0 = SQRT(result1)
5902 IF (result1 .EQ. 0.0_8) THEN
5905 g_result2 = g_result1/(2.0*temp0)
5908 temp0 = pwr1*pwr2*result2
5910 g_b = temp0*EXP(arg1)*g_arg1 + temp*(result2*(pwr2*g_pwr1+pwr1*&
5911 & g_pwr2)+pwr1*pwr2*g_result2)
5913 IF (90. .GT. t0c - t(i, k)) THEN
5920 IF (0. .LT. y7) THEN
5927 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5931 g_max30 = g_qrs(i, k, 1)
5932 max30 = qrs(i, k, 1)
5934 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5938 g_max43 = g_qrs(i, k, 2)
5939 max43 = qrs(i, k, 2)
5941 g_arg1 = -(alpha*g_max11/2.)
5942 arg1 = -(alpha*max11/2.)
5943 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
5947 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
5949 pwr1 = den(i, k)**(3./4.)
5950 IF (max30 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
5954 g_pwr2 = 5.*max30**(5./4.-1)*g_max30/4.
5956 pwr2 = max30**(5./4.)
5958 IF (max43 .EQ. 0.0_8) THEN
5961 g_result1 = g_max43/(2.0*temp0)
5964 temp0 = pwr1*pwr2*result1
5966 g_c = temp0*EXP(arg1)*g_arg1 + temp*(result1*(pwr2*g_pwr1+pwr1*&
5967 & g_pwr2)+pwr1*pwr2*g_result1)
5969 IF (90. .GT. t0c - t(i, k)) THEN
5976 IF (0. .LT. y8) THEN
5983 IF (qrs(i, k, 1) .LT. qcrmin) THEN
5987 g_max31 = g_qrs(i, k, 1)
5988 max31 = qrs(i, k, 1)
5990 IF (qrs(i, k, 2) .LT. qcrmin) THEN
5994 g_max44 = g_qrs(i, k, 2)
5995 max44 = qrs(i, k, 2)
5997 g_arg1 = -(alpha*3.*g_max12/4.)
5998 arg1 = -(3.*alpha*max12/4.)
5999 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6003 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6005 pwr1 = den(i, k)**(3./4.)
6006 IF (max44 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT&
6010 g_pwr2 = 3.*max44**(3./4.-1)*g_max44/4.
6012 pwr2 = max44**(3./4.)
6013 temp0 = pwr1*max31*pwr2
6015 g_d = temp0*EXP(arg1)*g_arg1 + temp*(pwr2*(max31*g_pwr1+pwr1*&
6016 & g_max31)+pwr1*max31*g_pwr2)
6018 IF (vt2r - vt2s .GE. 0.) THEN
6019 g_abs2 = g_vt2r - g_vt2s
6022 g_abs2 = g_vt2s - g_vt2r
6025 temp0 = psacr_b*b + psacr_c*c + psacr_d*d
6026 g_psacr1 = psacr_a*(temp0*(abs2*g_a+a*g_abs2)+a*abs2*(psacr_b*&
6027 & g_b+psacr_c*g_c+psacr_d*g_d))
6028 psacr1 = psacr_a*(a*abs2*temp0)
6029 IF (supcol .GT. 0.) THEN
6030 IF (psacr1 .GT. qrs(i, k, 1)/dtcld) THEN
6031 g_psacr(i, k) = g_qrs(i, k, 1)/dtcld
6032 psacr(i, k) = qrs(i, k, 1)/dtcld
6034 g_psacr(i, k) = g_psacr1
6035 psacr(i, k) = psacr1
6037 ELSE IF (psacr1 .GT. qrs(i, k, 2)/dtcld) THEN
6038 g_psacr(i, k) = g_qrs(i, k, 2)/dtcld
6039 psacr(i, k) = qrs(i, k, 2)/dtcld
6041 g_psacr(i, k) = g_psacr1
6042 psacr(i, k) = psacr1
6044 IF (psacr(i, k) .GE. 0.) THEN
6049 !psacr(i,k)=fqr*fqs*psacr(i,k)
6050 IF (abs3 .LT. qmin/dtcld) THEN
6051 g_psacr(i, k) = 0.0_8
6055 IF (qrs(i, k, 1) .LT. 1.e-4 .AND. qrs(i, k, 2) .LT. 1.e-4) THEN
6060 IF (qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld .LT. 0.) THEN
6061 g_qrs(i, k, 1) = 0.0_8
6064 g_qrs(i, k, 1) = g_qrs(i, k, 1) - dtcld*(psacr(i, k)*g_fsupcol&
6065 & +fsupcol*g_psacr(i, k))
6066 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld
6068 g_x1 = g_qrs(i, k, 2) + delta2*dtcld*(psacr(i, k)*g_fsupcol+&
6069 & fsupcol*g_psacr(i, k))
6070 x1 = qrs(i, k, 2) + fsupcol*delta2*psacr(i, k)*dtcld
6071 IF (x1 .LT. 0.) THEN
6072 g_qrs(i, k, 2) = 0.0_8
6075 g_qrs(i, k, 2) = g_x1
6078 g_x2 = g_qrs(i, k, 3) + (1-delta2)*dtcld*(psacr(i, k)*g_fsupcol+&
6079 & fsupcol*g_psacr(i, k))
6080 x2 = qrs(i, k, 3) + fsupcol*(1-delta2)*psacr(i, k)*dtcld
6081 IF (x2 .LT. 0.) THEN
6082 g_qrs(i, k, 3) = 0.0_8
6085 g_qrs(i, k, 3) = g_x2
6088 temp0 = psacr(i, k)/cpm(i, k)
6089 g_t(i, k) = g_t(i, k) + dtcld*(temp0*(xlf*g_fsupcol+fsupcol*&
6090 & g_xlf)+fsupcol*xlf*(g_psacr(i, k)-temp0*g_cpm(i, k))/cpm(i, k)&
6092 t(i, k) = t(i, k) + dtcld*(fsupcol*xlf*temp0)
6094 g_psacr(i, k) = (1-fsupcol)*g_psacr(i, k) - psacr(i, k)*&
6096 psacr(i, k) = (1-fsupcol)*psacr(i, k)
6097 !-------------------------------------------------------------
6098 ! pgacr: Accretion of rain by graupel [LFO 42]
6099 ! (T< T0: R->G) min=0.,max=qrs(i,k,1)/dtcld
6100 ! (T>=T0: G->R enhance melting of graupel) min=0.,max=qrs(i,k,3)/dtcld
6101 !-------------------------------------------------------------
6102 g_supcol = -g_t(i, k)
6103 supcol = t0c - t(i, k)
6104 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't0')
6105 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
6106 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
6108 ! cpm(i,k)=cpmcal(q(i,k)) !not change
6109 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
6111 xlf = xls - xl(i, k)
6112 IF (supcol .LT. 0.) THEN
6116 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6120 g_max13 = g_qrs(i, k, 1)
6121 max13 = qrs(i, k, 1)
6124 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
6128 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
6130 pwr1 = den(i, k)**pwy1
6132 IF (max13 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
6136 g_pwr2 = pwy2*max13**(pwy2-1)*g_max13
6139 g_vt2r = vt2r_a*(pwr2*g_pwr1+pwr1*g_pwr2)
6140 vt2r = vt2r_a*pwr1*pwr2
6141 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6145 g_max14 = g_qrs(i, k, 3)
6146 max14 = qrs(i, k, 3)
6149 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
6153 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
6155 pwr1 = den(i, k)**pwy1
6157 IF (max14 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
6161 g_pwr2 = pwy2*max14**(pwy2-1)*g_max14
6164 g_vt2g = vt2g_a*(pwr2*g_pwr1+pwr1*g_pwr2)
6165 vt2g = vt2g_a*pwr1*pwr2
6166 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6170 g_max15 = g_qrs(i, k, 1)
6171 max15 = qrs(i, k, 1)
6173 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6177 g_max32 = g_qrs(i, k, 3)
6178 max32 = qrs(i, k, 3)
6180 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6184 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6186 pwr1 = den(i, k)**(3./4.)
6187 IF (max15 .LE. 0.0_8 .AND. (3./2. .EQ. 0.0_8 .OR. 3./2. .NE. INT&
6191 g_pwr2 = 3.*max15**(3./2.-1)*g_max15/2.
6193 pwr2 = max15**(3./2.)
6195 IF (max32 .EQ. 0.0_8) THEN
6198 g_result1 = g_max32/(2.0*temp0)
6201 temp0 = SQRT(result1)
6202 IF (result1 .EQ. 0.0_8) THEN
6205 g_result2 = g_result1/(2.0*temp0)
6208 g_b = result2*(pwr2*g_pwr1+pwr1*g_pwr2) + pwr1*pwr2*g_result2
6209 b = pwr1*pwr2*result2
6210 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6214 g_max16 = g_qrs(i, k, 1)
6215 max16 = qrs(i, k, 1)
6217 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6221 g_max33 = g_qrs(i, k, 3)
6222 max33 = qrs(i, k, 3)
6224 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6228 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6230 pwr1 = den(i, k)**(3./4.)
6231 IF (max16 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
6235 g_pwr2 = 5.*max16**(5./4.-1)*g_max16/4.
6237 pwr2 = max16**(5./4.)
6239 IF (max33 .EQ. 0.0_8) THEN
6242 g_result1 = g_max33/(2.0*temp0)
6245 g_c = result1*(pwr2*g_pwr1+pwr1*g_pwr2) + pwr1*pwr2*g_result1
6246 c = pwr1*pwr2*result1
6247 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6251 g_max17 = g_qrs(i, k, 1)
6252 max17 = qrs(i, k, 1)
6254 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6258 g_max34 = g_qrs(i, k, 3)
6259 max34 = qrs(i, k, 3)
6261 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6265 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6267 pwr1 = den(i, k)**(3./4.)
6268 IF (max34 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT&
6272 g_pwr2 = 3.*max34**(3./4.-1)*g_max34/4.
6274 pwr2 = max34**(3./4.)
6275 g_d = pwr2*(max17*g_pwr1+pwr1*g_max17) + pwr1*max17*g_pwr2
6277 IF (vt2r - vt2g .GE. 0.) THEN
6278 g_abs4 = g_vt2r - g_vt2g
6281 g_abs4 = g_vt2g - g_vt2r
6284 temp0 = pgacr_b*b + pgacr_c*c + pgacr_d*d
6285 g_pgacr1 = pgacr_a*(temp0*g_abs4+abs4*(pgacr_b*g_b+pgacr_c*g_c+&
6287 pgacr1 = pgacr_a*(abs4*temp0)
6288 IF (supcol .GT. 0.) THEN
6289 IF (pgacr1 .GT. qrs(i, k, 1)/dtcld) THEN
6290 g_pgacr(i, k) = g_qrs(i, k, 1)/dtcld
6291 pgacr(i, k) = qrs(i, k, 1)/dtcld
6293 g_pgacr(i, k) = g_pgacr1
6294 pgacr(i, k) = pgacr1
6296 ELSE IF (pgacr1 .GT. qrs(i, k, 3)/dtcld) THEN
6297 g_pgacr(i, k) = g_qrs(i, k, 3)/dtcld
6298 pgacr(i, k) = qrs(i, k, 3)/dtcld
6300 g_pgacr(i, k) = g_pgacr1
6301 pgacr(i, k) = pgacr1
6303 IF (pgacr(i, k) .GE. 0.) THEN
6308 !pgacr(i,k)=fqg*fqr*pgacr(i,k)
6309 IF (abs5 .LT. qmin/dtcld) THEN
6310 g_pgacr(i, k) = 0.0_8
6313 IF (qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld .LT. 0.) THEN
6314 g_qrs(i, k, 1) = 0.0_8
6317 g_qrs(i, k, 1) = g_qrs(i, k, 1) - dtcld*(pgacr(i, k)*g_fsupcol&
6318 & +fsupcol*g_pgacr(i, k))
6319 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld
6321 g_x3 = g_qrs(i, k, 3) + dtcld*(pgacr(i, k)*g_fsupcol+fsupcol*&
6323 x3 = qrs(i, k, 3) + fsupcol*pgacr(i, k)*dtcld
6324 IF (x3 .LT. 0.) THEN
6325 g_qrs(i, k, 3) = 0.0_8
6328 g_qrs(i, k, 3) = g_x3
6331 temp0 = pgacr(i, k)/cpm(i, k)
6332 g_t(i, k) = g_t(i, k) + dtcld*(temp0*(xlf*g_fsupcol+fsupcol*&
6333 & g_xlf)+fsupcol*xlf*(g_pgacr(i, k)-temp0*g_cpm(i, k))/cpm(i, k)&
6335 t(i, k) = t(i, k) + dtcld*(fsupcol*xlf*temp0)
6337 g_pgacr(i, k) = (1-fsupcol)*g_pgacr(i, k) - pgacr(i, k)*&
6339 pgacr(i, k) = (1-fsupcol)*pgacr(i, k)
6340 !-------------------------------------------------------------
6341 ! pgacs: Accretion of snow by graupel [LFO 29]
6342 ! (S->G) min=0,max=qrs(i,k,2)/dtcld
6343 !-------------------------------------------------------------
6344 g_supcol = -g_t(i, k)
6345 supcol = t0c - t(i, k)
6346 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6347 g_x4 = -(EXP(-(0.09*supcol))*0.09*g_supcol)
6348 x4 = EXP(-(0.09*supcol))
6349 IF (x4 .GT. 1.) THEN
6356 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6360 g_max18 = g_qrs(i, k, 3)
6361 max18 = qrs(i, k, 3)
6364 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
6368 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
6370 pwr1 = den(i, k)**pwy1
6372 IF (max18 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
6376 g_pwr2 = pwy2*max18**(pwy2-1)*g_max18
6379 g_vt2g = vt2g_a*(pwr2*g_pwr1+pwr1*g_pwr2)
6380 vt2g = vt2g_a*pwr1*pwr2
6381 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6385 g_max19 = g_qrs(i, k, 2)
6386 max19 = qrs(i, k, 2)
6388 IF (90. .GT. t0c - t(i, k)) THEN
6395 IF (0. .LT. y15) THEN
6403 IF (den(i, k) .LE. 0.0_8 .AND. (pwy1 .EQ. 0.0_8 .OR. pwy1 .NE. &
6407 g_pwr1 = pwy1*den(i, k)**(pwy1-1)*g_den(i, k)
6409 pwr1 = den(i, k)**pwy1
6411 IF (max19 .LE. 0.0_8 .AND. (pwy2 .EQ. 0.0_8 .OR. pwy2 .NE. INT(&
6415 g_pwr2 = pwy2*max19**(pwy2-1)*g_max19
6418 g_arg1 = -(alpha*bvts*g_max35/4.)
6419 arg1 = -(alpha*bvts*max35/4.)
6421 g_vt2s = vt2s_a*(temp0*(pwr2*g_pwr1+pwr1*g_pwr2)+pwr1*pwr2*EXP(&
6423 vt2s = vt2s_a*(pwr1*pwr2*temp0)
6424 IF (90. .GT. t0c - t(i, k)) THEN
6431 IF (0. .LT. y9) THEN
6438 g_a = EXP(alpha*max20)*alpha*g_max20
6439 a = EXP(alpha*max20)
6440 IF (90. .GT. t0c - t(i, k)) THEN
6447 IF (0. .LT. y10) THEN
6454 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6458 g_max36 = g_qrs(i, k, 2)
6459 max36 = qrs(i, k, 2)
6461 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6465 g_max45 = g_qrs(i, k, 3)
6466 max45 = qrs(i, k, 3)
6468 g_arg1 = -(alpha*3.*g_max21/2.)
6469 arg1 = -(3.*alpha*max21/2.)
6470 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6474 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6476 pwr1 = den(i, k)**(3./4.)
6477 IF (max36 .LE. 0.0_8 .AND. (3./2. .EQ. 0.0_8 .OR. 3./2. .NE. INT&
6481 g_pwr2 = 3.*max36**(3./2.-1)*g_max36/2.
6483 pwr2 = max36**(3./2.)
6485 IF (max45 .EQ. 0.0_8) THEN
6488 g_result1 = g_max45/(2.0*temp0)
6491 temp0 = SQRT(result1)
6492 IF (result1 .EQ. 0.0_8) THEN
6495 g_result2 = g_result1/(2.0*temp0)
6498 temp0 = pwr1*pwr2*result2
6500 g_b = temp0*EXP(arg1)*g_arg1 + temp*(result2*(pwr2*g_pwr1+pwr1*&
6501 & g_pwr2)+pwr1*pwr2*g_result2)
6503 IF (90. .GT. t0c - t(i, k)) THEN
6510 IF (0. .LT. y11) THEN
6517 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6521 g_max37 = g_qrs(i, k, 2)
6522 max37 = qrs(i, k, 2)
6524 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6528 g_max46 = g_qrs(i, k, 3)
6529 max46 = qrs(i, k, 3)
6531 g_arg1 = -(alpha*5.*g_max22/4.)
6532 arg1 = -(5.*alpha*max22/4.)
6533 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6537 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6539 pwr1 = den(i, k)**(3./4.)
6540 IF (max37 .LE. 0.0_8 .AND. (5./4. .EQ. 0.0_8 .OR. 5./4. .NE. INT&
6544 g_pwr2 = 5.*max37**(5./4.-1)*g_max37/4.
6546 pwr2 = max37**(5./4.)
6548 IF (max46 .EQ. 0.0_8) THEN
6551 g_result1 = g_max46/(2.0*temp0)
6554 temp0 = pwr1*pwr2*result1
6556 g_c = temp0*EXP(arg1)*g_arg1 + temp*(result1*(pwr2*g_pwr1+pwr1*&
6557 & g_pwr2)+pwr1*pwr2*g_result1)
6559 IF (90. .GT. t0c - t(i, k)) THEN
6566 IF (0. .LT. y12) THEN
6573 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6577 g_max38 = g_qrs(i, k, 2)
6578 max38 = qrs(i, k, 2)
6580 IF (qrs(i, k, 3) .LT. qcrmin) THEN
6584 g_max47 = g_qrs(i, k, 3)
6585 max47 = qrs(i, k, 3)
6587 IF (den(i, k) .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE.&
6591 g_pwr1 = 3.*den(i, k)**(3./4.-1)*g_den(i, k)/4.
6593 pwr1 = den(i, k)**(3./4.)
6594 IF (max47 .LE. 0.0_8 .AND. (3./4. .EQ. 0.0_8 .OR. 3./4. .NE. INT&
6598 g_pwr2 = 3.*max47**(3./4.-1)*g_max47/4.
6600 pwr2 = max47**(3./4.)
6601 temp0 = pwr1*max38*pwr2
6602 temp = EXP(-(alpha*max23))
6603 g_d = temp*(pwr2*(max38*g_pwr1+pwr1*g_max38)+pwr1*max38*g_pwr2) &
6604 & - temp0*EXP(-(alpha*max23))*alpha*g_max23
6606 IF (vt2g - vt2s .GE. 0.) THEN
6607 g_abs6 = g_vt2g - g_vt2s
6610 g_abs6 = g_vt2s - g_vt2g
6613 temp0 = pgacs_b*b + pgacs_c*c + pgacs_d*d
6615 g_pgacs1 = pgacs_a*(temp0*(egs*(abs6*g_a+a*g_abs6)+a*abs6*g_egs)&
6616 & +temp*(pgacs_b*g_b+pgacs_c*g_c+pgacs_d*g_d))
6617 pgacs1 = pgacs_a*(temp*temp0)
6618 IF (pgacs1 .GT. qrs(i, k, 2)/dtcld) THEN
6619 g_pgacs(i, k) = g_qrs(i, k, 2)/dtcld
6620 pgacs(i, k) = qrs(i, k, 2)/dtcld
6622 g_pgacs(i, k) = g_pgacs1
6623 pgacs(i, k) = pgacs1
6625 IF (pgacs(i, k) .GE. 0.) THEN
6630 !pgacs(i,k)=fqg*fqs*pgacs(i,k)
6631 IF (abs7 .LT. qmin/dtcld) THEN
6632 g_pgacs(i, k) = 0.0_8
6635 IF (qrs(i, k, 2) - pgacs(i, k)*dtcld .LT. 0.) THEN
6636 g_qrs(i, k, 2) = 0.0_8
6639 g_qrs(i, k, 2) = g_qrs(i, k, 2) - dtcld*g_pgacs(i, k)
6640 qrs(i, k, 2) = qrs(i, k, 2) - pgacs(i, k)*dtcld
6642 IF (qrs(i, k, 3) + pgacs(i, k)*dtcld .LT. 0.) THEN
6643 g_qrs(i, k, 3) = 0.0_8
6646 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgacs(i, k)
6647 qrs(i, k, 3) = qrs(i, k, 3) + pgacs(i, k)*dtcld
6649 g_pgacs(i, k) = 0.0_8
6651 !-------------------------------------------------------------
6652 ! pseml: Enhanced melting of snow by accretion of water
6653 ! (T>=T0: S->R) pseml<0 max=0,min=-qrs(i,k,2)/dtcld
6654 !-------------------------------------------------------------
6655 ! supcol = t0c-t(i,k) ! not change
6657 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
6658 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
6660 xlf = xls - xl(i, k)
6661 IF (supcol .LT. 0.) THEN
6665 CALL G_SMOOTHIF(t(i, k), g_t(i, k), t0c, ft0, g_ft0, 't0')
6666 CALL G_SMOOTHIF(qrs(i, k, 2), g_qrs(i, k, 2), 0., fqs, g_fqs, &
6669 temp = psacw(i, k) + psacr(i, k)
6670 g_x7 = cliq*(temp0*(g_psacw(i, k)+g_psacr(i, k))+temp*(g_supcol-&
6672 x7 = cliq*(temp*temp0)
6673 IF (x7 .LT. -(qrs(i, k, 2)/dtcld)) THEN
6674 g_x5 = -(g_qrs(i, k, 2)/dtcld)
6675 x5 = -(qrs(i, k, 2)/dtcld)
6680 IF (x5 .GT. 0.) THEN
6681 g_pseml(i, k) = 0.0_8
6684 g_pseml(i, k) = g_x5
6687 g_pseml(i, k) = pseml(i, k)*(fqs*g_ft0+ft0*g_fqs) + ft0*fqs*&
6689 pseml(i, k) = ft0*fqs*pseml(i, k)
6690 IF (pseml(i, k) .GE. 0.) THEN
6695 IF (abs8 .LT. qmin/dtcld) THEN
6696 g_pseml(i, k) = 0.0_8
6699 IF (qrs(i, k, 1) - pseml(i, k)*dtcld .LT. 0.) THEN
6700 g_qrs(i, k, 1) = 0.0_8
6703 g_qrs(i, k, 1) = g_qrs(i, k, 1) - dtcld*g_pseml(i, k)
6704 qrs(i, k, 1) = qrs(i, k, 1) - pseml(i, k)*dtcld
6706 IF (qrs(i, k, 2) + pseml(i, k)*dtcld .LT. 0.) THEN
6707 g_qrs(i, k, 2) = 0.0_8
6710 g_qrs(i, k, 2) = g_qrs(i, k, 2) + dtcld*g_pseml(i, k)
6711 qrs(i, k, 2) = qrs(i, k, 2) + pseml(i, k)*dtcld
6713 temp0 = pseml(i, k)*xlf/cpm(i, k)
6714 g_t(i, k) = g_t(i, k) + dtcld*(xlf*g_pseml(i, k)+pseml(i, k)*&
6715 & g_xlf-temp0*g_cpm(i, k))/cpm(i, k)
6716 t(i, k) = t(i, k) + dtcld*temp0
6717 g_pseml(i, k) = 0.0_8
6719 g_psacw(i, k) = 0.0_8
6721 g_psacr(i, k) = 0.0_8
6723 !-------------------------------------------------------------
6724 ! pgeml: Enhanced melting of graupel by accretion of water [RH84 A21-A22]
6725 ! (T>=T0: G->R) pgeml<0 max=0,min=-qrs(i,k,3)/dtcld
6726 !-------------------------------------------------------------
6727 g_supcol = -g_t(i, k)
6728 supcol = t0c - t(i, k)
6730 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
6731 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
6733 xlf = xls - xl(i, k)
6734 IF (supcol .LT. 0.) THEN
6738 CALL G_SMOOTHIF(t(i, k), g_t(i, k), t0c, ft0, g_ft0, 't0')
6739 CALL G_SMOOTHIF(qrs(i, k, 3), g_qrs(i, k, 3), 0., fqg, g_fqg, &
6742 temp = pgacw(i, k) + pgacr(i, k)
6743 g_x8 = cliq*(temp0*(g_pgacw(i, k)+g_pgacr(i, k))+temp*(g_supcol-&
6745 x8 = cliq*(temp*temp0)
6746 IF (x8 .LT. -(qrs(i, k, 3)/dtcld)) THEN
6747 g_x6 = -(g_qrs(i, k, 3)/dtcld)
6748 x6 = -(qrs(i, k, 3)/dtcld)
6753 IF (x6 .GT. 0.) THEN
6754 g_pgeml(i, k) = 0.0_8
6757 g_pgeml(i, k) = g_x6
6760 g_pgeml(i, k) = pgeml(i, k)*(fqg*g_ft0+ft0*g_fqg) + ft0*fqg*&
6762 pgeml(i, k) = ft0*fqg*pgeml(i, k)
6763 IF (pgeml(i, k) .GE. 0.) THEN
6768 IF (abs9 .LT. qmin/dtcld) THEN
6769 g_pgeml(i, k) = 0.0_8
6772 IF (qrs(i, k, 1) - pgeml(i, k)*dtcld .LT. 0.) THEN
6773 g_qrs(i, k, 1) = 0.0_8
6776 g_qrs(i, k, 1) = g_qrs(i, k, 1) - dtcld*g_pgeml(i, k)
6777 qrs(i, k, 1) = qrs(i, k, 1) - pgeml(i, k)*dtcld
6779 IF (qrs(i, k, 3) + pgeml(i, k)*dtcld .LT. 0.) THEN
6780 g_qrs(i, k, 3) = 0.0_8
6783 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgeml(i, k)
6784 qrs(i, k, 3) = qrs(i, k, 3) + pgeml(i, k)*dtcld
6786 temp0 = pgeml(i, k)*xlf/cpm(i, k)
6787 g_t(i, k) = g_t(i, k) + dtcld*(xlf*g_pgeml(i, k)+pgeml(i, k)*&
6788 & g_xlf-temp0*g_cpm(i, k))/cpm(i, k)
6789 t(i, k) = t(i, k) + dtcld*temp0
6790 g_pgeml(i, k) = 0.0_8
6792 g_pgacw(i, k) = 0.0_8
6794 g_pgacr(i, k) = 0.0_8
6798 END SUBROUTINE G_ACCRET2
6800 !=======================================================================
6802 !=======================================================================
6803 SUBROUTINE ACCRET2(qrs, t, q, den, dtcld, psacw, pgacw, pracs, psacr, &
6804 & pgacr, pgacs, pseml, pgeml, ims, ime, kms, kme, its, ite, kts, kte)
6806 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
6807 !-------------------------------------------------------------------
6808 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs
6809 REAL, DIMENSION(ims:ime, kms:kme) :: den, q
6810 REAL, DIMENSION(its:ite, kts:kte) :: psacw, pgacw, pracs, psacr, &
6811 & pgacr, pgacs, pseml, pgeml, t, xl, cpm
6812 REAL :: supcol, vt2r, vt2s, vt2g, dtcld, xlf, egs
6813 REAL :: acrfac1, acrfac2, acrfac3, acrfac4, pracs1, psacr1, pgacr1, &
6816 REAL :: fsupcol, ft0, fqr, fqs, fqg, temp1, delta2, a, b, c, d
6911 !-------------------------------------------------------------
6912 ! pracs: Accretion of snow by rain [LFO 27]
6913 ! (T<T0: S->G) pracs: min=0., max=qrs(i,k,2)/dtcld
6914 !-------------------------------------------------------------
6915 supcol = t0c - t(i, k)
6916 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
6917 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6922 !call smoothif(qrs(i,k,1),1.e-4,fqr,'q0')
6923 !call smoothif(qrs(i,k,2),1.e-4,fqs,'q0')
6925 pwr1 = den(i, k)**pwy1
6928 vt2r = vt2r_a*pwr1*pwr2
6929 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6934 IF (90. .GT. t0c - t(i, k)) THEN
6939 IF (0. .LT. y13) THEN
6945 pwr1 = den(i, k)**pwy1
6948 arg1 = -(alpha*bvts*max24/4.)
6949 vt2s = vt2s_a*pwr1*pwr2*EXP(arg1)
6950 IF (90. .GT. t0c - t(i, k)) THEN
6955 IF (0. .LT. y1) THEN
6961 IF (90. .GT. t0c - t(i, k)) THEN
6966 IF (0. .LT. y2) THEN
6971 IF (qrs(i, k, 2) .LT. qcrmin) THEN
6974 max25 = qrs(i, k, 2)
6976 IF (qrs(i, k, 1) .LT. qcrmin) THEN
6979 max39 = qrs(i, k, 1)
6981 arg1 = -(3.*alpha*max4/2.)
6982 pwr1 = den(i, k)**(3./4.)
6983 pwr2 = max25**(3./2.)
6984 result1 = SQRT(max39)
6985 result2 = SQRT(result1)
6986 b = EXP(arg1)*pwr1*pwr2*result2
6987 IF (90. .GT. t0c - t(i, k)) THEN
6992 IF (0. .LT. y3) THEN
6997 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7000 max26 = qrs(i, k, 2)
7002 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7005 max40 = qrs(i, k, 1)
7007 arg1 = -(5.*alpha*max5/4.)
7008 pwr1 = den(i, k)**(3./4.)
7009 pwr2 = max26**(5./4.)
7010 result1 = SQRT(max40)
7011 c = EXP(arg1)*pwr1*pwr2*result1
7012 IF (90. .GT. t0c - t(i, k)) THEN
7017 IF (0. .LT. y4) THEN
7022 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7025 max27 = qrs(i, k, 2)
7027 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7030 max41 = qrs(i, k, 1)
7032 pwr1 = den(i, k)**(3./4.)
7033 pwr2 = max41**(3./4.)
7034 d = EXP(-(alpha*max6))*pwr1*max27*pwr2
7035 IF (vt2r - vt2s .GE. 0.) THEN
7040 pracs1 = pracs_a*a*abs0*(pracs_b*b+pracs_c*c+pracs_d*d)
7041 IF (pracs1 .GT. qrs(i, k, 2)/dtcld) THEN
7042 pracs(i, k) = qrs(i, k, 2)/dtcld
7044 pracs(i, k) = pracs1
7046 pracs(i, k) = fsupcol*pracs(i, k)
7047 IF (pracs(i, k) .GE. 0.) THEN
7052 IF (abs1 .LT. qmin/dtcld) pracs(i, k) = 0.
7053 IF (qrs(i, k, 2) - pracs(i, k)*dtcld .LT. 0.) THEN
7056 qrs(i, k, 2) = qrs(i, k, 2) - pracs(i, k)*dtcld
7058 IF (qrs(i, k, 3) + pracs(i, k)*dtcld .LT. 0.) THEN
7061 qrs(i, k, 3) = qrs(i, k, 3) + pracs(i, k)*dtcld
7064 !-------------------------------------------------------------
7065 ! psacr: Accretion of rain by snow [LFO 28]
7066 ! (T< T0: R->S or R->G) min=0.,max=qrs(i,k,1)/dtcld
7067 ! (T>=T0: S->R enhance melting of snow) min=0.,max=qrs(i,k,2)/dtcld
7068 !-------------------------------------------------------------
7069 ! supcol = t0c-t(i,k) !not change
7070 ! call smoothif(supcol,0.,fsupcol,'t0')
7071 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
7072 !call smoothif(qrs(i,k,2),qcrmin,fqs,'q0')
7074 cpm(i, k) = CPMCAL(q(i, k))
7075 xl(i, k) = XLCAL(t(i, k))
7076 xlf = xls - xl(i, k)
7077 IF (supcol .LT. 0.) xlf = xlf0
7078 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7084 pwr1 = den(i, k)**pwy1
7087 vt2r = vt2r_a*pwr1*pwr2
7088 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7093 IF (90. .GT. t0c - t(i, k)) THEN
7098 IF (0. .LT. y14) THEN
7104 pwr1 = den(i, k)**pwy1
7107 arg1 = -(alpha*bvts*max28/4.)
7108 vt2s = vt2s_a*pwr1*pwr2*EXP(arg1)
7109 IF (90. .GT. t0c - t(i, k)) THEN
7114 IF (0. .LT. y5) THEN
7120 IF (90. .GT. t0c - t(i, k)) THEN
7125 IF (0. .LT. y6) THEN
7130 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7133 max29 = qrs(i, k, 1)
7135 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7138 max42 = qrs(i, k, 2)
7140 arg1 = -(alpha*max10/4.)
7141 pwr1 = den(i, k)**(3./4.)
7142 pwr2 = max29**(3./2.)
7143 result1 = SQRT(max42)
7144 result2 = SQRT(result1)
7145 b = EXP(arg1)*pwr1*pwr2*result2
7146 IF (90. .GT. t0c - t(i, k)) THEN
7151 IF (0. .LT. y7) THEN
7156 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7159 max30 = qrs(i, k, 1)
7161 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7164 max43 = qrs(i, k, 2)
7166 arg1 = -(alpha*max11/2.)
7167 pwr1 = den(i, k)**(3./4.)
7168 pwr2 = max30**(5./4.)
7169 result1 = SQRT(max43)
7170 c = EXP(arg1)*pwr1*pwr2*result1
7171 IF (90. .GT. t0c - t(i, k)) THEN
7176 IF (0. .LT. y8) THEN
7181 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7184 max31 = qrs(i, k, 1)
7186 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7189 max44 = qrs(i, k, 2)
7191 arg1 = -(3.*alpha*max12/4.)
7192 pwr1 = den(i, k)**(3./4.)
7193 pwr2 = max44**(3./4.)
7194 d = EXP(arg1)*pwr1*max31*pwr2
7195 IF (vt2r - vt2s .GE. 0.) THEN
7200 psacr1 = psacr_a*a*abs2*(psacr_b*b+psacr_c*c+psacr_d*d)
7201 IF (supcol .GT. 0.) THEN
7202 IF (psacr1 .GT. qrs(i, k, 1)/dtcld) THEN
7203 psacr(i, k) = qrs(i, k, 1)/dtcld
7205 psacr(i, k) = psacr1
7207 ELSE IF (psacr1 .GT. qrs(i, k, 2)/dtcld) THEN
7208 psacr(i, k) = qrs(i, k, 2)/dtcld
7210 psacr(i, k) = psacr1
7212 IF (psacr(i, k) .GE. 0.) THEN
7217 !psacr(i,k)=fqr*fqs*psacr(i,k)
7218 IF (abs3 .LT. qmin/dtcld) psacr(i, k) = 0.
7220 IF (qrs(i, k, 1) .LT. 1.e-4 .AND. qrs(i, k, 2) .LT. 1.e-4) THEN
7225 IF (qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld .LT. 0.) THEN
7228 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*psacr(i, k)*dtcld
7230 x1 = qrs(i, k, 2) + fsupcol*delta2*psacr(i, k)*dtcld
7231 IF (x1 .LT. 0.) THEN
7236 x2 = qrs(i, k, 3) + fsupcol*(1-delta2)*psacr(i, k)*dtcld
7237 IF (x2 .LT. 0.) THEN
7242 t(i, k) = t(i, k) + fsupcol*psacr(i, k)*dtcld*xlf/cpm(i, k)
7244 psacr(i, k) = (1-fsupcol)*psacr(i, k)
7245 !-------------------------------------------------------------
7246 ! pgacr: Accretion of rain by graupel [LFO 42]
7247 ! (T< T0: R->G) min=0.,max=qrs(i,k,1)/dtcld
7248 ! (T>=T0: G->R enhance melting of graupel) min=0.,max=qrs(i,k,3)/dtcld
7249 !-------------------------------------------------------------
7250 supcol = t0c - t(i, k)
7251 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
7252 !call smoothif(qrs(i,k,3),qcrmin,fqg,'q0')
7253 !call smoothif(qrs(i,k,1),qcrmin,fqr,'q0')
7255 ! cpm(i,k)=cpmcal(q(i,k)) !not change
7256 xl(i, k) = XLCAL(t(i, k))
7257 xlf = xls - xl(i, k)
7258 IF (supcol .LT. 0.) xlf = xlf0
7259 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7262 max13 = qrs(i, k, 1)
7265 pwr1 = den(i, k)**pwy1
7268 vt2r = vt2r_a*pwr1*pwr2
7269 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7272 max14 = qrs(i, k, 3)
7275 pwr1 = den(i, k)**pwy1
7278 vt2g = vt2g_a*pwr1*pwr2
7279 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7282 max15 = qrs(i, k, 1)
7284 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7287 max32 = qrs(i, k, 3)
7289 pwr1 = den(i, k)**(3./4.)
7290 pwr2 = max15**(3./2.)
7291 result1 = SQRT(max32)
7292 result2 = SQRT(result1)
7293 b = pwr1*pwr2*result2
7294 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7297 max16 = qrs(i, k, 1)
7299 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7302 max33 = qrs(i, k, 3)
7304 pwr1 = den(i, k)**(3./4.)
7305 pwr2 = max16**(5./4.)
7306 result1 = SQRT(max33)
7307 c = pwr1*pwr2*result1
7308 IF (qrs(i, k, 1) .LT. qcrmin) THEN
7311 max17 = qrs(i, k, 1)
7313 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7316 max34 = qrs(i, k, 3)
7318 pwr1 = den(i, k)**(3./4.)
7319 pwr2 = max34**(3./4.)
7321 IF (vt2r - vt2g .GE. 0.) THEN
7326 pgacr1 = pgacr_a*abs4*(pgacr_b*b+pgacr_c*c+pgacr_d*d)
7327 IF (supcol .GT. 0.) THEN
7328 IF (pgacr1 .GT. qrs(i, k, 1)/dtcld) THEN
7329 pgacr(i, k) = qrs(i, k, 1)/dtcld
7331 pgacr(i, k) = pgacr1
7333 ELSE IF (pgacr1 .GT. qrs(i, k, 3)/dtcld) THEN
7334 pgacr(i, k) = qrs(i, k, 3)/dtcld
7336 pgacr(i, k) = pgacr1
7338 IF (pgacr(i, k) .GE. 0.) THEN
7343 !pgacr(i,k)=fqg*fqr*pgacr(i,k)
7344 IF (abs5 .LT. qmin/dtcld) pgacr(i, k) = 0.
7345 IF (qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld .LT. 0.) THEN
7348 qrs(i, k, 1) = qrs(i, k, 1) - fsupcol*pgacr(i, k)*dtcld
7350 x3 = qrs(i, k, 3) + fsupcol*pgacr(i, k)*dtcld
7351 IF (x3 .LT. 0.) THEN
7356 t(i, k) = t(i, k) + fsupcol*pgacr(i, k)*dtcld*xlf/cpm(i, k)
7358 pgacr(i, k) = (1-fsupcol)*pgacr(i, k)
7359 !-------------------------------------------------------------
7360 ! pgacs: Accretion of snow by graupel [LFO 29]
7361 ! (S->G) min=0,max=qrs(i,k,2)/dtcld
7362 !-------------------------------------------------------------
7363 supcol = t0c - t(i, k)
7364 CALL SMOOTHIF(supcol, 0., fsupcol, 't0')
7365 x4 = EXP(-(0.09*supcol))
7366 IF (x4 .GT. 1.) THEN
7371 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7374 max18 = qrs(i, k, 3)
7377 pwr1 = den(i, k)**pwy1
7380 vt2g = vt2g_a*pwr1*pwr2
7381 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7384 max19 = qrs(i, k, 2)
7386 IF (90. .GT. t0c - t(i, k)) THEN
7391 IF (0. .LT. y15) THEN
7397 pwr1 = den(i, k)**pwy1
7400 arg1 = -(alpha*bvts*max35/4.)
7401 vt2s = vt2s_a*pwr1*pwr2*EXP(arg1)
7402 IF (90. .GT. t0c - t(i, k)) THEN
7407 IF (0. .LT. y9) THEN
7412 a = EXP(alpha*max20)
7413 IF (90. .GT. t0c - t(i, k)) THEN
7418 IF (0. .LT. y10) THEN
7423 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7426 max36 = qrs(i, k, 2)
7428 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7431 max45 = qrs(i, k, 3)
7433 arg1 = -(3.*alpha*max21/2.)
7434 pwr1 = den(i, k)**(3./4.)
7435 pwr2 = max36**(3./2.)
7436 result1 = SQRT(max45)
7437 result2 = SQRT(result1)
7438 b = EXP(arg1)*pwr1*pwr2*result2
7439 IF (90. .GT. t0c - t(i, k)) THEN
7444 IF (0. .LT. y11) THEN
7449 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7452 max37 = qrs(i, k, 2)
7454 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7457 max46 = qrs(i, k, 3)
7459 arg1 = -(5.*alpha*max22/4.)
7460 pwr1 = den(i, k)**(3./4.)
7461 pwr2 = max37**(5./4.)
7462 result1 = SQRT(max46)
7463 c = EXP(arg1)*pwr1*pwr2*result1
7464 IF (90. .GT. t0c - t(i, k)) THEN
7469 IF (0. .LT. y12) THEN
7474 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7477 max38 = qrs(i, k, 2)
7479 IF (qrs(i, k, 3) .LT. qcrmin) THEN
7482 max47 = qrs(i, k, 3)
7484 pwr1 = den(i, k)**(3./4.)
7485 pwr2 = max47**(3./4.)
7486 d = EXP(-(alpha*max23))*pwr1*max38*pwr2
7487 IF (vt2g - vt2s .GE. 0.) THEN
7492 pgacs1 = pgacs_a*a*abs6*(pgacs_b*b+pgacs_c*c+pgacs_d*d)*egs
7493 IF (pgacs1 .GT. qrs(i, k, 2)/dtcld) THEN
7494 pgacs(i, k) = qrs(i, k, 2)/dtcld
7496 pgacs(i, k) = pgacs1
7498 IF (pgacs(i, k) .GE. 0.) THEN
7503 !pgacs(i,k)=fqg*fqs*pgacs(i,k)
7504 IF (abs7 .LT. qmin/dtcld) pgacs(i, k) = 0.
7505 IF (qrs(i, k, 2) - pgacs(i, k)*dtcld .LT. 0.) THEN
7508 qrs(i, k, 2) = qrs(i, k, 2) - pgacs(i, k)*dtcld
7510 IF (qrs(i, k, 3) + pgacs(i, k)*dtcld .LT. 0.) THEN
7513 qrs(i, k, 3) = qrs(i, k, 3) + pgacs(i, k)*dtcld
7516 !-------------------------------------------------------------
7517 ! pseml: Enhanced melting of snow by accretion of water
7518 ! (T>=T0: S->R) pseml<0 max=0,min=-qrs(i,k,2)/dtcld
7519 !-------------------------------------------------------------
7520 ! supcol = t0c-t(i,k) ! not change
7522 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
7523 xl(i, k) = XLCAL(t(i, k))
7524 xlf = xls - xl(i, k)
7525 IF (supcol .LT. 0.) xlf = xlf0
7526 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
7527 CALL SMOOTHIF(qrs(i, k, 2), 0., fqs, 'q+')
7528 x7 = cliq*supcol*(psacw(i, k)+psacr(i, k))/xlf
7529 IF (x7 .LT. -(qrs(i, k, 2)/dtcld)) THEN
7530 x5 = -(qrs(i, k, 2)/dtcld)
7534 IF (x5 .GT. 0.) THEN
7539 pseml(i, k) = ft0*fqs*pseml(i, k)
7540 IF (pseml(i, k) .GE. 0.) THEN
7545 IF (abs8 .LT. qmin/dtcld) pseml(i, k) = 0.
7546 IF (qrs(i, k, 1) - pseml(i, k)*dtcld .LT. 0.) THEN
7549 qrs(i, k, 1) = qrs(i, k, 1) - pseml(i, k)*dtcld
7551 IF (qrs(i, k, 2) + pseml(i, k)*dtcld .LT. 0.) THEN
7554 qrs(i, k, 2) = qrs(i, k, 2) + pseml(i, k)*dtcld
7556 t(i, k) = t(i, k) + pseml(i, k)*dtcld*xlf/cpm(i, k)
7560 !-------------------------------------------------------------
7561 ! pgeml: Enhanced melting of graupel by accretion of water [RH84 A21-A22]
7562 ! (T>=T0: G->R) pgeml<0 max=0,min=-qrs(i,k,3)/dtcld
7563 !-------------------------------------------------------------
7564 supcol = t0c - t(i, k)
7566 ! cpm(i,k)=cpmcal(q(i,k)) ! not change
7567 xl(i, k) = XLCAL(t(i, k))
7568 xlf = xls - xl(i, k)
7569 IF (supcol .LT. 0.) xlf = xlf0
7570 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
7571 CALL SMOOTHIF(qrs(i, k, 3), 0., fqg, 'q+')
7572 x8 = cliq*supcol*(pgacw(i, k)+pgacr(i, k))/xlf
7573 IF (x8 .LT. -(qrs(i, k, 3)/dtcld)) THEN
7574 x6 = -(qrs(i, k, 3)/dtcld)
7578 IF (x6 .GT. 0.) THEN
7583 pgeml(i, k) = ft0*fqg*pgeml(i, k)
7584 IF (pgeml(i, k) .GE. 0.) THEN
7589 IF (abs9 .LT. qmin/dtcld) pgeml(i, k) = 0.
7590 IF (qrs(i, k, 1) - pgeml(i, k)*dtcld .LT. 0.) THEN
7593 qrs(i, k, 1) = qrs(i, k, 1) - pgeml(i, k)*dtcld
7595 IF (qrs(i, k, 3) + pgeml(i, k)*dtcld .LT. 0.) THEN
7598 qrs(i, k, 3) = qrs(i, k, 3) + pgeml(i, k)*dtcld
7600 t(i, k) = t(i, k) + pgeml(i, k)*dtcld*xlf/cpm(i, k)
7606 END SUBROUTINE ACCRET2
7608 ! Differentiation of accret3 in forward (tangent) mode (with options r8):
7609 ! variations of useful results: q t qs pigen rh qrs psevp pidep
7610 ! pgevp psdep qci pgdep psaut pgaut
7611 ! with respect to varying inputs: p q t qs pigen rh den qrs psevp
7612 ! pidep pgevp psdep qci pgdep psaut pgaut
7613 !=======================================================================
7615 !=======================================================================
7616 SUBROUTINE G_ACCRET3(qrs, g_qrs, qci, g_qci, rh, g_rh, t, g_t, p, g_p&
7617 & , den, g_den, dtcld, q, g_q, qs, g_qs, psdep, g_psdep, pgdep, &
7618 & g_pgdep, pigen, g_pigen, psaut, g_psaut, pgaut, g_pgaut, psevp, &
7619 & g_psevp, pgevp, g_pgevp, pidep, g_pidep, ims, ime, kms, kme, its, &
7622 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
7623 !-------------------------------------------------------------------
7624 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
7625 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
7626 REAL, DIMENSION(ims:ime, kms:kme) :: den, q, p
7627 REAL, DIMENSION(ims:ime, kms:kme) :: g_den, g_q, g_p
7628 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, rh, qs
7629 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qrs, g_rh, g_qs
7630 REAL, DIMENSION(its:ite, kts:kte) :: pigen, psevp, pgevp, pidep, t, &
7631 & xl, cpm, psdep, pgdep, psaut, pgaut
7632 REAL, DIMENSION(its:ite, kts:kte) :: g_pigen, g_psevp, g_pgevp, &
7633 & g_pidep, g_t, g_xl, g_cpm, g_psdep, g_pgdep, g_psaut, g_pgaut
7634 REAL :: supcol, dtcld, satdt, supsat, qimax, diameter, xni0, roqi0, &
7635 & supice1, supice2, supice3, supice4, alpha2
7636 REAL :: g_supcol, g_satdt, g_supsat, g_qimax, g_xni0, g_roqi0, &
7638 REAL :: pidep0, pidep1, psdep0, pgdep3, pigen0, psevp0, pgevp0, &
7639 & coeres1, coeres2, coeres3, coeres4
7640 REAL :: g_pidep0, g_psdep0, g_pgdep3, g_pigen0, g_psevp0, g_pgevp0
7641 REAL :: temp0, temp, xmi
7643 REAL :: fqi, fqr, fqv, fqs, fqg, frh, ft0, fpidep, fpsdep, fpgdep, &
7644 & fsupcol, fsupsat, pidep2
7645 REAL :: g_ft0, g_fsupcol, g_fsupsat
7646 REAL :: value01, factor01, source01, vice, a, b, c, d, e, f, g
7647 REAL :: g_a, g_b, g_c, g_d, g_e
7744 !-------------------------------------------------------------
7745 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
7746 ! (T<T0: V->I or I->V)
7747 ! rh(i,k,2)>1.,pidep>0: V->I, min=0, max=satdt
7748 ! rh(i,k,2)<1.,pidep<0: I->V, min=-qi/dtcld,max=0,
7749 !-------------------------------------------------------------
7751 g_supcol = -g_t(i, k)
7752 supcol = t0c - t(i, k)
7754 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
7755 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
7758 g_supsat = g_q(i, k) - g_qs(i, k, 2)
7759 supsat = q(i, k) - qs(i, k, 2)
7760 g_satdt = g_supsat/dtcld
7761 satdt = supsat/dtcld
7763 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
7764 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
7765 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't+')
7766 IF (qci(i, k, 2) .GT. 0.) THEN
7767 temp1 = diffac_a*(xls*xls)
7768 temp2 = rv*t(i, k)**3.5
7769 temp3 = den(i, k)*(t(i, k)+120.)/temp2
7770 g_b = temp1*((t(i, k)+120.)*g_den(i, k)+(den(i, k)-temp3*rv*&
7771 & 3.5*t(i, k)**2.5)*g_t(i, k))/temp2
7773 temp3 = t(i, k)**1.81
7774 temp2 = temp3*qs(i, k, 2)
7775 temp1 = p(i, k)/temp2
7776 g_c = diffac_b*(g_p(i, k)-temp1*(qs(i, k, 2)*1.81*t(i, k)**&
7777 & 0.81*g_t(i, k)+temp3*g_qs(i, k, 2)))/temp2
7779 temp3 = (rh(i, k, 2)-1.)/(b+c)
7780 g_a = (g_rh(i, k, 2)-temp3*(g_b+g_c))/(b+c)
7782 g_pwx1 = qci(i, k, 2)*g_den(i, k) + den(i, k)*g_qci(i, k, 2)
7783 pwx1 = den(i, k)*qci(i, k, 2)
7784 IF (pwx1 .LE. 0.0_8 .AND. (7./8. .EQ. 0.0_8 .OR. 7./8. .NE. &
7788 g_pwr1 = 7.*pwx1**(7./8.-1)*g_pwx1/8.
7790 pwr1 = pwx1**(7./8.)
7791 g_pidep0 = pidep_a*(pwr1*g_a+a*g_pwr1)
7792 pidep0 = pidep_a*a*pwr1
7797 IF (pidep0 .LT. 0.) THEN
7798 IF (pidep0 .LT. -(qci(i, k, 2)/dtcld)) THEN
7799 g_x1 = -(g_qci(i, k, 2)/dtcld)
7800 x1 = -(qci(i, k, 2)/dtcld)
7805 IF (x1 .GT. 0.) THEN
7806 g_pidep(i, k) = 0.0_8
7809 g_pidep(i, k) = g_x1
7813 IF (pidep0 .GT. satdt) THEN
7820 IF (x2 .LT. 0.) THEN
7821 g_pidep(i, k) = 0.0_8
7824 g_pidep(i, k) = g_x2
7828 g_pidep(i, k) = pidep(i, k)*g_fsupcol + fsupcol*g_pidep(i, k)
7829 pidep(i, k) = fsupcol*pidep(i, k)
7830 IF (pidep(i, k) .GE. 0.) THEN
7835 IF (abs0 .LT. qmin/dtcld) THEN
7836 g_pidep(i, k) = 0.0_8
7839 IF (q(i, k) - pidep(i, k)*dtcld .LT. 0.) THEN
7843 g_q(i, k) = g_q(i, k) - dtcld*g_pidep(i, k)
7844 q(i, k) = q(i, k) - pidep(i, k)*dtcld
7846 IF (qci(i, k, 2) + pidep(i, k)*dtcld .LT. 0.) THEN
7847 g_qci(i, k, 2) = 0.0_8
7850 g_qci(i, k, 2) = g_qci(i, k, 2) + dtcld*g_pidep(i, k)
7851 qci(i, k, 2) = qci(i, k, 2) + pidep(i, k)*dtcld
7853 temp3 = pidep(i, k)/cpm(i, k)
7854 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_pidep(i, k)-temp3*g_cpm(i, &
7856 t(i, k) = t(i, k) + dtcld*xls*temp3
7857 g_pidep(i, k) = 0.0_8
7860 !-------------------------------------------------------------
7861 ! psdep: deposition/sublimation rate of snow [HDC 14]
7862 ! (T<T0: V->S or S->V)
7863 ! rh(i,k,2)>1.,psdep>0: V->S, min=0, max=satdt
7864 ! rh(i,k,2)<1.,psdep<0: S->V, min=-qs/dtcld,max=0,
7865 !-------------------------------------------------------------
7867 g_supcol = -g_t(i, k)
7868 supcol = t0c - t(i, k)
7870 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
7871 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
7874 g_supsat = g_q(i, k) - g_qs(i, k, 2)
7875 supsat = q(i, k) - qs(i, k, 2)
7876 g_satdt = g_supsat/dtcld
7877 satdt = supsat/dtcld
7879 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
7880 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
7881 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't+')
7882 IF (90. .GT. t0c - t(i, k)) THEN
7889 IF (0. .LT. y1) THEN
7896 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7900 g_max9 = g_qrs(i, k, 2)
7903 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
7904 ! call smoothif(q (i,k ),0.,fqv,'q+')
7905 g_arg1 = alpha*g_max1/2.
7906 arg1 = alpha*max1/2.
7907 g_arg2 = max9*g_den(i, k) + den(i, k)*g_max9
7908 arg2 = den(i, k)*max9
7910 IF (arg2 .EQ. 0.0_8) THEN
7913 g_result1 = g_arg2/(2.0*temp3)
7917 g_a = result1*EXP(arg1)*g_arg1 + temp3*g_result1
7919 IF (90. .GT. t0c - t(i, k)) THEN
7926 IF (0. .LT. y2) THEN
7933 IF (qrs(i, k, 2) .LT. qcrmin) THEN
7937 g_max10 = g_qrs(i, k, 2)
7938 max10 = qrs(i, k, 2)
7940 g_arg1 = (3.-bvts)*alpha*g_max2/8.
7941 arg1 = (3.-bvts)*alpha*max2/8.
7943 pwx1 = t(i, k) + 120.
7944 IF (pwx1 .LE. 0.0_8 .AND. (1.0/6. .EQ. 0.0_8 .OR. 1.0/6. .NE. &
7945 & INT(1.0/6.))) THEN
7948 g_pwr1 = pwx1**(1.0/6.-1)*g_pwx1/6.
7950 pwr1 = pwx1**(1./6.)
7951 IF (t(i, k) .LE. 0.0_8 .AND. (5.12/6. .EQ. 0.0_8 .OR. 5.12/6. &
7952 & .NE. INT(5.12/6.))) THEN
7955 g_pwr2 = 5.12*t(i, k)**(5.12/6.-1)*g_t(i, k)/6.
7957 pwr2 = t(i, k)**(5.12/6.)
7958 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. .NE.&
7959 & INT(1.0/3.))) THEN
7962 g_pwr3 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
7964 pwr3 = p(i, k)**(1./3.)
7965 pwy4 = (13.+3.*bvts)/24.
7966 IF (den(i, k) .LE. 0.0_8 .AND. (pwy4 .EQ. 0.0_8 .OR. pwy4 .NE. &
7970 g_pwr4 = pwy4*den(i, k)**(pwy4-1)*g_den(i, k)
7972 pwr4 = den(i, k)**pwy4
7974 IF (max10 .LE. 0.0_8 .AND. (pwy5 .EQ. 0.0_8 .OR. pwy5 .NE. INT(&
7978 g_pwr5 = pwy5*max10**(pwy5-1)*g_max10
7981 temp3 = pwr1*pwr3/pwr2
7982 temp2 = temp3*pwr4*pwr5
7984 g_b = temp2*EXP(arg1)*g_arg1 + temp1*(pwr4*pwr5*(pwr3*g_pwr1+&
7985 & pwr1*g_pwr3-temp3*g_pwr2)/pwr2+temp3*(pwr5*g_pwr4+pwr4*g_pwr5)&
7988 temp3 = diffac_a*(xls*xls)
7989 temp2 = rv*t(i, k)**3.5
7990 temp1 = den(i, k)*(t(i, k)+120.)/temp2
7991 g_c = temp3*((t(i, k)+120.)*g_den(i, k)+(den(i, k)-temp1*rv*3.5*&
7992 & t(i, k)**2.5)*g_t(i, k))/temp2
7994 temp3 = t(i, k)**1.81
7995 temp2 = temp3*qs(i, k, 2)
7996 temp1 = p(i, k)/temp2
7997 g_d = diffac_b*(g_p(i, k)-temp1*(qs(i, k, 2)*1.81*t(i, k)**0.81*&
7998 & g_t(i, k)+temp3*g_qs(i, k, 2)))/temp2
8000 temp3 = (rh(i, k, 2)-1.)/(c+d)
8001 g_e = (g_rh(i, k, 2)-temp3*(g_c+g_d))/(c+d)
8003 temp3 = psdep_a*a + psdep_b*b
8004 g_psdep0 = temp3*g_e + e*(psdep_a*g_a+psdep_b*g_b)
8006 IF (psdep0 .LT. 0.) THEN
8007 IF (psdep0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
8008 g_x3 = -(g_qrs(i, k, 2)/dtcld)
8009 x3 = -(qrs(i, k, 2)/dtcld)
8014 IF (x3 .GT. 0.) THEN
8015 g_psdep(i, k) = 0.0_8
8018 g_psdep(i, k) = g_x3
8022 IF (psdep0 .GT. satdt) THEN
8029 IF (x4 .LT. 0.) THEN
8030 g_psdep(i, k) = 0.0_8
8033 g_psdep(i, k) = g_x4
8037 g_psdep(i, k) = psdep(i, k)*g_fsupcol + fsupcol*g_psdep(i, k)
8038 psdep(i, k) = fsupcol*psdep(i, k)
8039 IF (psdep(i, k) .GE. 0.) THEN
8044 IF (abs1 .LT. qmin/dtcld) THEN
8045 g_psdep(i, k) = 0.0_8
8048 IF (q(i, k) - psdep(i, k)*dtcld .LT. 0.) THEN
8052 g_q(i, k) = g_q(i, k) - dtcld*g_psdep(i, k)
8053 q(i, k) = q(i, k) - psdep(i, k)*dtcld
8055 IF (qrs(i, k, 2) + psdep(i, k)*dtcld .LT. 0.) THEN
8056 g_qrs(i, k, 2) = 0.0_8
8059 g_qrs(i, k, 2) = g_qrs(i, k, 2) + dtcld*g_psdep(i, k)
8060 qrs(i, k, 2) = qrs(i, k, 2) + psdep(i, k)*dtcld
8062 temp3 = psdep(i, k)/cpm(i, k)
8063 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_psdep(i, k)-temp3*g_cpm(i, &
8065 t(i, k) = t(i, k) + dtcld*xls*temp3
8066 g_psdep(i, k) = 0.0_8
8069 !------------------------------------------------------------
8070 ! pgdep: deposition/sublimation rate of graupel [LFO 46]
8071 ! (T<T0: V->G or G->V)
8072 ! rh(i,k,2)>1.,pgdep>0: V->G, min=0, max=satdt
8073 ! rh(i,k,2)<1.,pgdep<0: G->V, min=-qg/dtcld,max=0,
8074 !------------------------------------------------------------
8076 g_supcol = -g_t(i, k)
8077 supcol = t0c - t(i, k)
8079 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
8080 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
8083 g_supsat = g_q(i, k) - g_qs(i, k, 2)
8084 supsat = q(i, k) - qs(i, k, 2)
8085 g_satdt = g_supsat/dtcld
8086 satdt = supsat/dtcld
8088 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
8089 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
8090 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't+')
8091 IF (qrs(i, k, 3) .LT. qcrmin) THEN
8095 g_max3 = g_qrs(i, k, 3)
8098 ! call smoothif(qrs(i,k,3),0.,fqg,'q+')
8099 ! call smoothif(q (i,k ),0.,fqv,'q+')
8100 temp3 = den(i, k)*max3
8102 IF (temp3 .EQ. 0.0_8) THEN
8105 g_a = (max3*g_den(i, k)+den(i, k)*g_max3)/(2.0*temp2)
8108 IF (qrs(i, k, 3) .LT. qcrmin) THEN
8112 g_max4 = g_qrs(i, k, 3)
8116 pwx1 = t(i, k) + 120.
8117 IF (pwx1 .LE. 0.0_8 .AND. (1.0/6. .EQ. 0.0_8 .OR. 1.0/6. .NE. &
8118 & INT(1.0/6.))) THEN
8121 g_pwr1 = pwx1**(1.0/6.-1)*g_pwx1/6.
8123 pwr1 = pwx1**(1./6.)
8124 IF (t(i, k) .LE. 0.0_8 .AND. (5.12/6. .EQ. 0.0_8 .OR. 5.12/6. &
8125 & .NE. INT(5.12/6.))) THEN
8128 g_pwr2 = 5.12*t(i, k)**(5.12/6.-1)*g_t(i, k)/6.
8130 pwr2 = t(i, k)**(5.12/6.)
8131 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. .NE.&
8132 & INT(1.0/3.))) THEN
8135 g_pwr3 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
8137 pwr3 = p(i, k)**(1./3.)
8138 pwy4 = (13.+3.*bvtg)/24.
8139 IF (den(i, k) .LE. 0.0_8 .AND. (pwy4 .EQ. 0.0_8 .OR. pwy4 .NE. &
8143 g_pwr4 = pwy4*den(i, k)**(pwy4-1)*g_den(i, k)
8145 pwr4 = den(i, k)**pwy4
8147 IF (max4 .LE. 0.0_8 .AND. (pwy5 .EQ. 0.0_8 .OR. pwy5 .NE. INT(&
8151 g_pwr5 = pwy5*max4**(pwy5-1)*g_max4
8154 temp3 = pwr1*pwr3/pwr2
8155 g_b = pwr4*pwr5*(pwr3*g_pwr1+pwr1*g_pwr3-temp3*g_pwr2)/pwr2 + &
8156 & temp3*(pwr5*g_pwr4+pwr4*g_pwr5)
8157 b = temp3*(pwr4*pwr5)
8158 temp3 = diffac_a*(xls*xls)
8159 temp2 = rv*t(i, k)**3.5
8160 temp1 = den(i, k)*(t(i, k)+120.)/temp2
8161 g_c = temp3*((t(i, k)+120.)*g_den(i, k)+(den(i, k)-temp1*rv*3.5*&
8162 & t(i, k)**2.5)*g_t(i, k))/temp2
8164 temp3 = t(i, k)**1.81
8165 temp2 = temp3*qs(i, k, 2)
8166 temp1 = p(i, k)/temp2
8167 g_d = diffac_b*(g_p(i, k)-temp1*(qs(i, k, 2)*1.81*t(i, k)**0.81*&
8168 & g_t(i, k)+temp3*g_qs(i, k, 2)))/temp2
8170 temp3 = (rh(i, k, 2)-1.)/(c+d)
8171 g_e = (g_rh(i, k, 2)-temp3*(g_c+g_d))/(c+d)
8173 temp3 = pgdep_a*a + pgdep_b*b
8174 g_pgdep3 = temp3*g_e + e*(pgdep_a*g_a+pgdep_b*g_b)
8176 IF (pgdep3 .LT. 0.) THEN
8177 IF (pgdep3 .LT. -(qrs(i, k, 3)/dtcld)) THEN
8178 g_x5 = -(g_qrs(i, k, 3)/dtcld)
8179 x5 = -(qrs(i, k, 3)/dtcld)
8184 IF (x5 .GT. 0.) THEN
8185 g_pgdep(i, k) = 0.0_8
8188 g_pgdep(i, k) = g_x5
8192 IF (pgdep3 .GT. satdt) THEN
8199 IF (x6 .LT. 0.) THEN
8200 g_pgdep(i, k) = 0.0_8
8203 g_pgdep(i, k) = g_x6
8207 g_pgdep(i, k) = pgdep(i, k)*g_fsupcol + fsupcol*g_pgdep(i, k)
8208 pgdep(i, k) = fsupcol*pgdep(i, k)
8209 IF (pgdep(i, k) .GE. 0.) THEN
8214 IF (abs2 .LT. qmin/dtcld) THEN
8215 g_pgdep(i, k) = 0.0_8
8218 IF (q(i, k) - pgdep(i, k)*dtcld .LT. 0.) THEN
8222 g_q(i, k) = g_q(i, k) - dtcld*g_pgdep(i, k)
8223 q(i, k) = q(i, k) - pgdep(i, k)*dtcld
8225 IF (qrs(i, k, 3) + pgdep(i, k)*dtcld .LT. 0.) THEN
8226 g_qrs(i, k, 3) = 0.0_8
8229 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgdep(i, k)
8230 qrs(i, k, 3) = qrs(i, k, 3) + pgdep(i, k)*dtcld
8232 temp3 = pgdep(i, k)/cpm(i, k)
8233 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_pgdep(i, k)-temp3*g_cpm(i, &
8235 t(i, k) = t(i, k) + dtcld*xls*temp3
8236 g_pgdep(i, k) = 0.0_8
8238 !-------------------------------------------------------------
8239 ! pigen: generation(nucleation) of ice from vapor [HDC 7-8]
8240 ! (T<T0: V->I) min=0,max=min(roqi0/den(i,k)-max(qci(i,k,2),0.))/dtcld,satdt)
8241 !-------------------------------------------------------------
8243 g_supcol = -g_t(i, k)
8244 supcol = t0c - t(i, k)
8245 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
8247 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
8248 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
8251 g_supsat = g_q(i, k) - g_qs(i, k, 2)
8252 supsat = q(i, k) - qs(i, k, 2)
8253 g_satdt = g_supsat/dtcld
8254 satdt = supsat/dtcld
8255 CALL G_SMOOTHIF(supsat, g_supsat, 0., fsupsat, g_fsupsat, 'q+')
8256 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't+')
8257 g_xni0 = 1.e3*EXP(0.1*supcol)*0.1*g_supcol
8258 xni0 = 1.e3*EXP(0.1*supcol)
8259 g_roqi0 = 4.92e-11*1.33*xni0**0.33*g_xni0
8260 roqi0 = 4.92e-11*xni0**1.33
8261 IF (qci(i, k, 2) .LT. 0.) THEN
8265 g_max11 = g_qci(i, k, 2)
8266 max11 = qci(i, k, 2)
8268 temp3 = roqi0/den(i, k)
8269 g_x7 = ((g_roqi0-temp3*g_den(i, k))/den(i, k)-g_max11)/dtcld
8270 x7 = (temp3-max11)/dtcld
8271 IF (x7 .GT. satdt) THEN
8278 IF (pigen0 .LT. 0.) THEN
8279 g_pigen(i, k) = 0.0_8
8282 g_pigen(i, k) = g_pigen0
8283 pigen(i, k) = pigen0
8285 g_pigen(i, k) = pigen(i, k)*(fsupsat*g_fsupcol+fsupcol*g_fsupsat&
8286 & ) + fsupcol*fsupsat*g_pigen(i, k)
8287 pigen(i, k) = fsupcol*fsupsat*pigen(i, k)
8288 IF (pigen(i, k) .GE. 0.) THEN
8293 IF (abs3 .LT. qmin/dtcld) THEN
8294 g_pigen(i, k) = 0.0_8
8297 IF (q(i, k) - pigen(i, k)*dtcld .LT. 0.) THEN
8301 g_q(i, k) = g_q(i, k) - dtcld*g_pigen(i, k)
8302 q(i, k) = q(i, k) - pigen(i, k)*dtcld
8304 IF (qci(i, k, 2) + pigen(i, k)*dtcld .LT. 0.) THEN
8305 g_qci(i, k, 2) = 0.0_8
8308 g_qci(i, k, 2) = g_qci(i, k, 2) + dtcld*g_pigen(i, k)
8309 qci(i, k, 2) = qci(i, k, 2) + pigen(i, k)*dtcld
8311 temp3 = pigen(i, k)/cpm(i, k)
8312 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_pigen(i, k)-temp3*g_cpm(i, &
8314 t(i, k) = t(i, k) + dtcld*xls*temp3
8315 g_pigen(i, k) = 0.0_8
8318 !------------------------------------------------------------
8319 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
8320 ! (T<T0: I->S) psaut>0, min=0,max=(qci(i,k,2)-qimax)/dtcld
8321 !-------------------------------------------------------------
8323 g_supcol = -g_t(i, k)
8324 supcol = t0c - t(i, k)
8325 CALL G_SMOOTHIF(supcol, g_supcol, 0., fsupcol, g_fsupcol, 't+')
8326 ! call smoothif(qci(i,k,2),0.,fqi,'q+')
8327 temp3 = roqimax/den(i, k)
8328 g_qimax = -(temp3*g_den(i, k)/den(i, k))
8330 IF (0. .LT. (qci(i, k, 2)-qimax)/dtcld) THEN
8331 g_psaut(i, k) = (g_qci(i, k, 2)-g_qimax)/dtcld
8332 psaut(i, k) = (qci(i, k, 2)-qimax)/dtcld
8334 g_psaut(i, k) = 0.0_8
8337 g_psaut(i, k) = psaut(i, k)*g_fsupcol + fsupcol*g_psaut(i, k)
8338 psaut(i, k) = fsupcol*psaut(i, k)
8339 IF (psaut(i, k) .GE. 0.) THEN
8344 IF (abs4 .LT. qmin/dtcld) THEN
8345 g_psaut(i, k) = 0.0_8
8348 IF (qci(i, k, 2) - psaut(i, k)*dtcld .LT. 0.) THEN
8349 g_qci(i, k, 2) = 0.0_8
8352 g_qci(i, k, 2) = g_qci(i, k, 2) - dtcld*g_psaut(i, k)
8353 qci(i, k, 2) = qci(i, k, 2) - psaut(i, k)*dtcld
8355 IF (qrs(i, k, 2) + psaut(i, k)*dtcld .LT. 0.) THEN
8356 g_qrs(i, k, 2) = 0.0_8
8359 g_qrs(i, k, 2) = g_qrs(i, k, 2) + dtcld*g_psaut(i, k)
8360 qrs(i, k, 2) = qrs(i, k, 2) + psaut(i, k)*dtcld
8362 g_psaut(i, k) = 0.0_8
8365 !-------------------------------------------------------------
8366 ! pgaut: conversion(aggregation) of snow to graupel [LFO 37]
8367 ! (T<T0: S->G) pgaut>0 min=0.,max=qrs(i,k,2)/dtcld
8368 !-------------------------------------------------------------
8370 ! supcol = t0c-t(i,k) ! not change
8371 ! call smoothif(supcol,0.,fsupcol,'t0')
8372 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
8373 g_alpha2 = -(1.e-3*EXP(-(0.09*supcol))*0.09*g_supcol)
8374 alpha2 = 1.e-3*EXP(0.09*(-supcol))
8375 IF (0. .LT. alpha2*(qrs(i, k, 2)-qs0)) THEN
8376 g_x8 = (qrs(i, k, 2)-qs0)*g_alpha2 + alpha2*g_qrs(i, k, 2)
8377 x8 = alpha2*(qrs(i, k, 2)-qs0)
8382 IF (x8 .GT. qrs(i, k, 2)/dtcld) THEN
8383 g_pgaut(i, k) = g_qrs(i, k, 2)/dtcld
8384 pgaut(i, k) = qrs(i, k, 2)/dtcld
8386 g_pgaut(i, k) = g_x8
8389 g_pgaut(i, k) = pgaut(i, k)*g_fsupcol + fsupcol*g_pgaut(i, k)
8390 pgaut(i, k) = fsupcol*pgaut(i, k)
8391 IF (pgaut(i, k) .GE. 0.) THEN
8396 IF (abs5 .LT. qmin/dtcld) THEN
8397 g_pgaut(i, k) = 0.0_8
8400 IF (qrs(i, k, 2) - pgaut(i, k)*dtcld .LT. 0.) THEN
8401 g_qrs(i, k, 2) = 0.0_8
8404 g_qrs(i, k, 2) = g_qrs(i, k, 2) - dtcld*g_pgaut(i, k)
8405 qrs(i, k, 2) = qrs(i, k, 2) - pgaut(i, k)*dtcld
8407 IF (qrs(i, k, 3) + pgaut(i, k)*dtcld .LT. 0.) THEN
8408 g_qrs(i, k, 3) = 0.0_8
8411 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgaut(i, k)
8412 qrs(i, k, 3) = qrs(i, k, 3) + pgaut(i, k)*dtcld
8414 g_pgaut(i, k) = 0.0_8
8417 !-------------------------------------------------------------
8418 ! psevp: Evaporation of melting snow [RH83 A27]
8419 ! (T>=T0: S->V) rh<1., psevp<0, min=-qrs(i,k,2)/dtcld, max=0.
8420 !-------------------------------------------------------------
8421 ! supcol = t0c-t(i,k) ! not change
8423 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
8424 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
8427 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
8428 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
8429 CALL G_SMOOTHIF(t(i, k), g_t(i, k), t0c, ft0, g_ft0, 't+')
8430 IF (90. .GT. t0c - t(i, k)) THEN
8437 IF (0. .LT. y3) THEN
8444 IF (qrs(i, k, 2) .LT. qcrmin) THEN
8448 g_max12 = g_qrs(i, k, 2)
8449 max12 = qrs(i, k, 2)
8451 g_arg1 = alpha*g_max5/2.
8452 arg1 = alpha*max5/2.
8453 g_arg2 = max12*g_den(i, k) + den(i, k)*g_max12
8454 arg2 = den(i, k)*max12
8456 IF (arg2 .EQ. 0.0_8) THEN
8459 g_result1 = g_arg2/(2.0*temp3)
8463 g_a = result1*EXP(arg1)*g_arg1 + temp3*g_result1
8465 IF (90. .GT. t0c - t(i, k)) THEN
8472 IF (0. .LT. y4) THEN
8479 IF (qrs(i, k, 2) .LT. qcrmin) THEN
8483 g_max13 = g_qrs(i, k, 2)
8484 max13 = qrs(i, k, 2)
8486 g_arg1 = (3.-bvts)*alpha*g_max6/8.
8487 arg1 = (3.-bvts)*alpha*max6/8.
8489 pwx1 = t(i, k) + 120.
8490 IF (pwx1 .LE. 0.0_8 .AND. (1.0/6. .EQ. 0.0_8 .OR. 1.0/6. .NE. &
8491 & INT(1.0/6.))) THEN
8494 g_pwr1 = pwx1**(1.0/6.-1)*g_pwx1/6.
8496 pwr1 = pwx1**(1./6.)
8497 IF (t(i, k) .LE. 0.0_8 .AND. (5.12/6. .EQ. 0.0_8 .OR. 5.12/6. &
8498 & .NE. INT(5.12/6.))) THEN
8501 g_pwr2 = 5.12*t(i, k)**(5.12/6.-1)*g_t(i, k)/6.
8503 pwr2 = t(i, k)**(5.12/6.)
8504 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. .NE.&
8505 & INT(1.0/3.))) THEN
8508 g_pwr3 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
8510 pwr3 = p(i, k)**(1./3.)
8511 pwy4 = (13.+3.*bvts)/24.
8512 IF (den(i, k) .LE. 0.0_8 .AND. (pwy4 .EQ. 0.0_8 .OR. pwy4 .NE. &
8516 g_pwr4 = pwy4*den(i, k)**(pwy4-1)*g_den(i, k)
8518 pwr4 = den(i, k)**pwy4
8520 IF (max13 .LE. 0.0_8 .AND. (pwy5 .EQ. 0.0_8 .OR. pwy5 .NE. INT(&
8524 g_pwr5 = pwy5*max13**(pwy5-1)*g_max13
8527 temp3 = pwr1*pwr3/pwr2
8528 temp2 = temp3*pwr4*pwr5
8530 g_b = temp2*EXP(arg1)*g_arg1 + temp1*(pwr4*pwr5*(pwr3*g_pwr1+&
8531 & pwr1*g_pwr3-temp3*g_pwr2)/pwr2+temp3*(pwr5*g_pwr4+pwr4*g_pwr5)&
8534 temp3 = rv*t(i, k)**3.5
8535 temp2 = den(i, k)*(t(i, k)+120.)
8536 temp1 = xl(i, k)*xl(i, k)
8537 temp4 = temp1*temp2/temp3
8538 g_c = diffac_a*(temp2*2*xl(i, k)*g_xl(i, k)+temp1*((t(i, k)+120.&
8539 & )*g_den(i, k)+den(i, k)*g_t(i, k))-temp4*rv*3.5*t(i, k)**2.5*&
8542 temp4 = t(i, k)**1.81
8543 temp3 = temp4*qs(i, k, 1)
8544 temp2 = p(i, k)/temp3
8545 g_d = diffac_b*(g_p(i, k)-temp2*(qs(i, k, 1)*1.81*t(i, k)**0.81*&
8546 & g_t(i, k)+temp4*g_qs(i, k, 1)))/temp3
8548 temp4 = (rh(i, k, 1)-1.)/(c+d)
8549 g_e = (g_rh(i, k, 1)-temp4*(g_c+g_d))/(c+d)
8551 temp4 = psevp_a*a + psevp_b*b
8552 g_psevp0 = temp4*g_e + e*(psevp_a*g_a+psevp_b*g_b)
8554 IF (psevp0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
8555 g_x9 = -(g_qrs(i, k, 2)/dtcld)
8556 x9 = -(qrs(i, k, 2)/dtcld)
8561 IF (x9 .GT. 0.) THEN
8562 g_psevp(i, k) = 0.0_8
8565 g_psevp(i, k) = g_x9
8568 g_psevp(i, k) = psevp(i, k)*g_ft0 + ft0*g_psevp(i, k)
8569 psevp(i, k) = ft0*psevp(i, k)
8570 IF (psevp(i, k) .GE. 0.) THEN
8575 IF (abs6 .LT. qmin/dtcld) THEN
8576 g_psevp(i, k) = 0.0_8
8579 IF (q(i, k) - psevp(i, k)*dtcld .LT. 0.) THEN
8583 g_q(i, k) = g_q(i, k) - dtcld*g_psevp(i, k)
8584 q(i, k) = q(i, k) - psevp(i, k)*dtcld
8586 IF (qrs(i, k, 2) + psevp(i, k)*dtcld .LT. 0.) THEN
8587 g_qrs(i, k, 2) = 0.0_8
8590 g_qrs(i, k, 2) = g_qrs(i, k, 2) + dtcld*g_psevp(i, k)
8591 qrs(i, k, 2) = qrs(i, k, 2) + psevp(i, k)*dtcld
8593 temp4 = psevp(i, k)/cpm(i, k)
8594 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_psevp(i, k)-temp4*g_cpm(i, &
8596 t(i, k) = t(i, k) + dtcld*xls*temp4
8597 g_psevp(i, k) = 0.0_8
8600 !-------------------------------------------------------------
8601 ! pgevp: Evaporation of melting graupel [RH84 A19]
8602 ! (T>=T0: G->V) rh<1., pgevp<0, min=-qrs(i,k,3)/dtcld, max=0.
8603 !-------------------------------------------------------------
8604 supcol = t0c - t(i, k)
8606 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
8607 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
8610 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
8611 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
8612 CALL G_SMOOTHIF(t(i, k), g_t(i, k), t0c, ft0, g_ft0, 't0')
8613 IF (qrs(i, k, 3) .LT. qcrmin) THEN
8617 g_max7 = g_qrs(i, k, 3)
8620 temp4 = den(i, k)*max7
8622 IF (temp4 .EQ. 0.0_8) THEN
8625 g_a = (max7*g_den(i, k)+den(i, k)*g_max7)/(2.0*temp3)
8628 IF (qrs(i, k, 3) .LT. qcrmin) THEN
8632 g_max8 = g_qrs(i, k, 3)
8636 pwx1 = t(i, k) + 120.
8637 IF (pwx1 .LE. 0.0_8 .AND. (1.0/6. .EQ. 0.0_8 .OR. 1.0/6. .NE. &
8638 & INT(1.0/6.))) THEN
8641 g_pwr1 = pwx1**(1.0/6.-1)*g_pwx1/6.
8643 pwr1 = pwx1**(1./6.)
8644 IF (t(i, k) .LE. 0.0_8 .AND. (5.12/6. .EQ. 0.0_8 .OR. 5.12/6. &
8645 & .NE. INT(5.12/6.))) THEN
8648 g_pwr2 = 5.12*t(i, k)**(5.12/6.-1)*g_t(i, k)/6.
8650 pwr2 = t(i, k)**(5.12/6.)
8651 IF (p(i, k) .LE. 0.0_8 .AND. (1.0/3. .EQ. 0.0_8 .OR. 1.0/3. .NE.&
8652 & INT(1.0/3.))) THEN
8655 g_pwr3 = p(i, k)**(1.0/3.-1)*g_p(i, k)/3.
8657 pwr3 = p(i, k)**(1./3.)
8658 pwy4 = (13.+3.*bvtg)/24.
8659 IF (den(i, k) .LE. 0.0_8 .AND. (pwy4 .EQ. 0.0_8 .OR. pwy4 .NE. &
8663 g_pwr4 = pwy4*den(i, k)**(pwy4-1)*g_den(i, k)
8665 pwr4 = den(i, k)**pwy4
8667 IF (max8 .LE. 0.0_8 .AND. (pwy5 .EQ. 0.0_8 .OR. pwy5 .NE. INT(&
8671 g_pwr5 = pwy5*max8**(pwy5-1)*g_max8
8674 temp4 = pwr1*pwr3/pwr2
8675 g_b = pwr4*pwr5*(pwr3*g_pwr1+pwr1*g_pwr3-temp4*g_pwr2)/pwr2 + &
8676 & temp4*(pwr5*g_pwr4+pwr4*g_pwr5)
8677 b = temp4*(pwr4*pwr5)
8678 temp4 = rv*t(i, k)**3.5
8679 temp3 = den(i, k)*(t(i, k)+120.)
8680 temp2 = xl(i, k)*xl(i, k)
8681 temp1 = temp2*temp3/temp4
8682 g_c = diffac_a*(temp3*2*xl(i, k)*g_xl(i, k)+temp2*((t(i, k)+120.&
8683 & )*g_den(i, k)+den(i, k)*g_t(i, k))-temp1*rv*3.5*t(i, k)**2.5*&
8686 temp4 = t(i, k)**1.81
8687 temp3 = temp4*qs(i, k, 1)
8688 temp2 = p(i, k)/temp3
8689 g_d = diffac_b*(g_p(i, k)-temp2*(qs(i, k, 1)*1.81*t(i, k)**0.81*&
8690 & g_t(i, k)+temp4*g_qs(i, k, 1)))/temp3
8692 temp4 = (rh(i, k, 1)-1.)/(c+d)
8693 g_e = (g_rh(i, k, 1)-temp4*(g_c+g_d))/(c+d)
8695 temp4 = pgevp_a*a + pgevp_b*b
8696 g_pgevp0 = temp4*g_e + e*(pgevp_a*g_a+pgevp_b*g_b)
8698 IF (pgevp0 .LT. -(qrs(i, k, 3)/dtcld)) THEN
8699 g_x10 = -(g_qrs(i, k, 3)/dtcld)
8700 x10 = -(qrs(i, k, 3)/dtcld)
8705 IF (x10 .GT. 0.) THEN
8706 g_pgevp(i, k) = 0.0_8
8709 g_pgevp(i, k) = g_x10
8712 g_pgevp(i, k) = pgevp(i, k)*g_ft0 + ft0*g_pgevp(i, k)
8713 pgevp(i, k) = ft0*pgevp(i, k)
8714 IF (pgevp(i, k) .GE. 0.) THEN
8719 IF (abs7 .LT. qmin/dtcld) THEN
8720 g_pgevp(i, k) = 0.0_8
8723 IF (q(i, k) - pgevp(i, k)*dtcld .LT. 0.) THEN
8727 g_q(i, k) = g_q(i, k) - dtcld*g_pgevp(i, k)
8728 q(i, k) = q(i, k) - pgevp(i, k)*dtcld
8730 IF (qrs(i, k, 3) + pgevp(i, k)*dtcld .LT. 0.) THEN
8731 g_qrs(i, k, 3) = 0.0_8
8734 g_qrs(i, k, 3) = g_qrs(i, k, 3) + dtcld*g_pgevp(i, k)
8735 qrs(i, k, 3) = qrs(i, k, 3) + pgevp(i, k)*dtcld
8737 temp4 = pgevp(i, k)/cpm(i, k)
8738 g_t(i, k) = g_t(i, k) + dtcld*xls*(g_pgevp(i, k)-temp4*g_cpm(i, &
8740 t(i, k) = t(i, k) + dtcld*xls*temp4
8741 g_pgevp(i, k) = 0.0_8
8745 END SUBROUTINE G_ACCRET3
8747 !=======================================================================
8749 !=======================================================================
8750 SUBROUTINE ACCRET3(qrs, qci, rh, t, p, den, dtcld, q, qs, psdep, pgdep&
8751 & , pigen, psaut, pgaut, psevp, pgevp, pidep, ims, ime, kms, kme, its&
8754 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
8755 !-------------------------------------------------------------------
8756 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
8757 REAL, DIMENSION(ims:ime, kms:kme) :: den, q, p
8758 REAL, DIMENSION(its:ite, kts:kte, 3) :: qrs, rh, qs
8759 REAL, DIMENSION(its:ite, kts:kte) :: pigen, psevp, pgevp, pidep, t, &
8760 & xl, cpm, psdep, pgdep, psaut, pgaut
8761 REAL :: supcol, dtcld, satdt, supsat, qimax, diameter, xni0, roqi0, &
8762 & supice1, supice2, supice3, supice4, alpha2
8763 REAL :: pidep0, pidep1, psdep0, pgdep3, pigen0, psevp0, pgevp0, &
8764 & coeres1, coeres2, coeres3, coeres4
8765 REAL :: temp0, temp, xmi
8767 REAL :: fqi, fqr, fqv, fqs, fqg, frh, ft0, fpidep, fpsdep, fpgdep, &
8768 & fsupcol, fsupsat, pidep2
8769 REAL :: value01, factor01, source01, vice, a, b, c, d, e, f, g
8824 !-------------------------------------------------------------
8825 ! pidep: Deposition/Sublimation rate of ice [HDC 9]
8826 ! (T<T0: V->I or I->V)
8827 ! rh(i,k,2)>1.,pidep>0: V->I, min=0, max=satdt
8828 ! rh(i,k,2)<1.,pidep<0: I->V, min=-qi/dtcld,max=0,
8829 !-------------------------------------------------------------
8831 supcol = t0c - t(i, k)
8833 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
8835 supsat = q(i, k) - qs(i, k, 2)
8836 satdt = supsat/dtcld
8838 xl(i, k) = XLCAL(t(i, k))
8839 cpm(i, k) = CPMCAL(q(i, k))
8840 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
8841 IF (qci(i, k, 2) .GT. 0.) THEN
8842 b = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
8843 c = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
8844 a = (rh(i, k, 2)-1.)/(b+c)
8845 pwx1 = den(i, k)*qci(i, k, 2)
8846 pwr1 = pwx1**(7./8.)
8847 pidep0 = pidep_a*a*pwr1
8851 IF (pidep0 .LT. 0.) THEN
8852 IF (pidep0 .LT. -(qci(i, k, 2)/dtcld)) THEN
8853 x1 = -(qci(i, k, 2)/dtcld)
8857 IF (x1 .GT. 0.) THEN
8863 IF (pidep0 .GT. satdt) THEN
8868 IF (x2 .LT. 0.) THEN
8874 pidep(i, k) = fsupcol*pidep(i, k)
8875 IF (pidep(i, k) .GE. 0.) THEN
8880 IF (abs0 .LT. qmin/dtcld) pidep(i, k) = 0.
8881 IF (q(i, k) - pidep(i, k)*dtcld .LT. 0.) THEN
8884 q(i, k) = q(i, k) - pidep(i, k)*dtcld
8886 IF (qci(i, k, 2) + pidep(i, k)*dtcld .LT. 0.) THEN
8889 qci(i, k, 2) = qci(i, k, 2) + pidep(i, k)*dtcld
8891 t(i, k) = t(i, k) + pidep(i, k)*dtcld*xls/cpm(i, k)
8894 !-------------------------------------------------------------
8895 ! psdep: deposition/sublimation rate of snow [HDC 14]
8896 ! (T<T0: V->S or S->V)
8897 ! rh(i,k,2)>1.,psdep>0: V->S, min=0, max=satdt
8898 ! rh(i,k,2)<1.,psdep<0: S->V, min=-qs/dtcld,max=0,
8899 !-------------------------------------------------------------
8901 supcol = t0c - t(i, k)
8903 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
8905 supsat = q(i, k) - qs(i, k, 2)
8906 satdt = supsat/dtcld
8908 xl(i, k) = XLCAL(t(i, k))
8909 cpm(i, k) = CPMCAL(q(i, k))
8910 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
8911 IF (90. .GT. t0c - t(i, k)) THEN
8916 IF (0. .LT. y1) THEN
8921 IF (qrs(i, k, 2) .LT. qcrmin) THEN
8926 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
8927 ! call smoothif(q (i,k ),0.,fqv,'q+')
8928 arg1 = alpha*max1/2.
8929 arg2 = den(i, k)*max9
8930 result1 = SQRT(arg2)
8931 a = EXP(arg1)*result1
8932 IF (90. .GT. t0c - t(i, k)) THEN
8937 IF (0. .LT. y2) THEN
8942 IF (qrs(i, k, 2) .LT. qcrmin) THEN
8945 max10 = qrs(i, k, 2)
8947 arg1 = (3.-bvts)*alpha*max2/8.
8948 pwx1 = t(i, k) + 120.
8949 pwr1 = pwx1**(1./6.)
8950 pwr2 = t(i, k)**(5.12/6.)
8951 pwr3 = p(i, k)**(1./3.)
8952 pwy4 = (13.+3.*bvts)/24.
8953 pwr4 = den(i, k)**pwy4
8956 b = EXP(arg1)*pwr1/pwr2*pwr3*pwr4*pwr5
8957 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
8958 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
8959 e = (rh(i, k, 2)-1.)/(c+d)
8960 psdep0 = e*(psdep_a*a+psdep_b*b)
8961 IF (psdep0 .LT. 0.) THEN
8962 IF (psdep0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
8963 x3 = -(qrs(i, k, 2)/dtcld)
8967 IF (x3 .GT. 0.) THEN
8973 IF (psdep0 .GT. satdt) THEN
8978 IF (x4 .LT. 0.) THEN
8984 psdep(i, k) = fsupcol*psdep(i, k)
8985 IF (psdep(i, k) .GE. 0.) THEN
8990 IF (abs1 .LT. qmin/dtcld) psdep(i, k) = 0.
8991 IF (q(i, k) - psdep(i, k)*dtcld .LT. 0.) THEN
8994 q(i, k) = q(i, k) - psdep(i, k)*dtcld
8996 IF (qrs(i, k, 2) + psdep(i, k)*dtcld .LT. 0.) THEN
8999 qrs(i, k, 2) = qrs(i, k, 2) + psdep(i, k)*dtcld
9001 t(i, k) = t(i, k) + psdep(i, k)*dtcld*xls/cpm(i, k)
9004 !------------------------------------------------------------
9005 ! pgdep: deposition/sublimation rate of graupel [LFO 46]
9006 ! (T<T0: V->G or G->V)
9007 ! rh(i,k,2)>1.,pgdep>0: V->G, min=0, max=satdt
9008 ! rh(i,k,2)<1.,pgdep<0: G->V, min=-qg/dtcld,max=0,
9009 !------------------------------------------------------------
9011 supcol = t0c - t(i, k)
9013 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9015 supsat = q(i, k) - qs(i, k, 2)
9016 satdt = supsat/dtcld
9018 xl(i, k) = XLCAL(t(i, k))
9019 cpm(i, k) = CPMCAL(q(i, k))
9020 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
9021 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9026 ! call smoothif(qrs(i,k,3),0.,fqg,'q+')
9027 ! call smoothif(q (i,k ),0.,fqv,'q+')
9028 a = SQRT(den(i, k)*max3)
9029 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9034 pwx1 = t(i, k) + 120.
9035 pwr1 = pwx1**(1./6.)
9036 pwr2 = t(i, k)**(5.12/6.)
9037 pwr3 = p(i, k)**(1./3.)
9038 pwy4 = (13.+3.*bvtg)/24.
9039 pwr4 = den(i, k)**pwy4
9042 b = pwr1/pwr2*pwr3*pwr4*pwr5
9043 c = diffac_a*den(i, k)*xls*xls*(t(i, k)+120.)/rv/t(i, k)**3.5
9044 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 2)
9045 e = (rh(i, k, 2)-1.)/(c+d)
9046 pgdep3 = e*(pgdep_a*a+pgdep_b*b)
9047 IF (pgdep3 .LT. 0.) THEN
9048 IF (pgdep3 .LT. -(qrs(i, k, 3)/dtcld)) THEN
9049 x5 = -(qrs(i, k, 3)/dtcld)
9053 IF (x5 .GT. 0.) THEN
9059 IF (pgdep3 .GT. satdt) THEN
9064 IF (x6 .LT. 0.) THEN
9070 pgdep(i, k) = fsupcol*pgdep(i, k)
9071 IF (pgdep(i, k) .GE. 0.) THEN
9076 IF (abs2 .LT. qmin/dtcld) pgdep(i, k) = 0.
9077 IF (q(i, k) - pgdep(i, k)*dtcld .LT. 0.) THEN
9080 q(i, k) = q(i, k) - pgdep(i, k)*dtcld
9082 IF (qrs(i, k, 3) + pgdep(i, k)*dtcld .LT. 0.) THEN
9085 qrs(i, k, 3) = qrs(i, k, 3) + pgdep(i, k)*dtcld
9087 t(i, k) = t(i, k) + pgdep(i, k)*dtcld*xls/cpm(i, k)
9089 !-------------------------------------------------------------
9090 ! pigen: generation(nucleation) of ice from vapor [HDC 7-8]
9091 ! (T<T0: V->I) min=0,max=min(roqi0/den(i,k)-max(qci(i,k,2),0.))/dtcld,satdt)
9092 !-------------------------------------------------------------
9094 supcol = t0c - t(i, k)
9095 cpm(i, k) = CPMCAL(q(i, k))
9097 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9099 supsat = q(i, k) - qs(i, k, 2)
9100 satdt = supsat/dtcld
9101 CALL SMOOTHIF(supsat, 0., fsupsat, 'q+')
9102 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
9103 xni0 = 1.e3*EXP(0.1*supcol)
9104 roqi0 = 4.92e-11*xni0**1.33
9105 IF (qci(i, k, 2) .LT. 0.) THEN
9108 max11 = qci(i, k, 2)
9110 x7 = (roqi0/den(i, k)-max11)/dtcld
9111 IF (x7 .GT. satdt) THEN
9116 IF (pigen0 .LT. 0.) THEN
9119 pigen(i, k) = pigen0
9121 pigen(i, k) = fsupcol*fsupsat*pigen(i, k)
9122 IF (pigen(i, k) .GE. 0.) THEN
9127 IF (abs3 .LT. qmin/dtcld) pigen(i, k) = 0.
9128 IF (q(i, k) - pigen(i, k)*dtcld .LT. 0.) THEN
9131 q(i, k) = q(i, k) - pigen(i, k)*dtcld
9133 IF (qci(i, k, 2) + pigen(i, k)*dtcld .LT. 0.) THEN
9136 qci(i, k, 2) = qci(i, k, 2) + pigen(i, k)*dtcld
9138 t(i, k) = t(i, k) + pigen(i, k)*dtcld*xls/cpm(i, k)
9141 !------------------------------------------------------------
9142 ! psaut: conversion(aggregation) of ice to snow [HDC 12]
9143 ! (T<T0: I->S) psaut>0, min=0,max=(qci(i,k,2)-qimax)/dtcld
9144 !-------------------------------------------------------------
9146 supcol = t0c - t(i, k)
9147 CALL SMOOTHIF(supcol, 0., fsupcol, 't+')
9148 ! call smoothif(qci(i,k,2),0.,fqi,'q+')
9149 qimax = roqimax/den(i, k)
9150 IF (0. .LT. (qci(i, k, 2)-qimax)/dtcld) THEN
9151 psaut(i, k) = (qci(i, k, 2)-qimax)/dtcld
9155 psaut(i, k) = fsupcol*psaut(i, k)
9156 IF (psaut(i, k) .GE. 0.) THEN
9161 IF (abs4 .LT. qmin/dtcld) psaut(i, k) = 0.
9162 IF (qci(i, k, 2) - psaut(i, k)*dtcld .LT. 0.) THEN
9165 qci(i, k, 2) = qci(i, k, 2) - psaut(i, k)*dtcld
9167 IF (qrs(i, k, 2) + psaut(i, k)*dtcld .LT. 0.) THEN
9170 qrs(i, k, 2) = qrs(i, k, 2) + psaut(i, k)*dtcld
9174 !-------------------------------------------------------------
9175 ! pgaut: conversion(aggregation) of snow to graupel [LFO 37]
9176 ! (T<T0: S->G) pgaut>0 min=0.,max=qrs(i,k,2)/dtcld
9177 !-------------------------------------------------------------
9179 ! supcol = t0c-t(i,k) ! not change
9180 ! call smoothif(supcol,0.,fsupcol,'t0')
9181 ! call smoothif(qrs(i,k,2),0.,fqs,'q+')
9182 alpha2 = 1.e-3*EXP(0.09*(-supcol))
9183 IF (0. .LT. alpha2*(qrs(i, k, 2)-qs0)) THEN
9184 x8 = alpha2*(qrs(i, k, 2)-qs0)
9188 IF (x8 .GT. qrs(i, k, 2)/dtcld) THEN
9189 pgaut(i, k) = qrs(i, k, 2)/dtcld
9193 pgaut(i, k) = fsupcol*pgaut(i, k)
9194 IF (pgaut(i, k) .GE. 0.) THEN
9199 IF (abs5 .LT. qmin/dtcld) pgaut(i, k) = 0.
9200 IF (qrs(i, k, 2) - pgaut(i, k)*dtcld .LT. 0.) THEN
9203 qrs(i, k, 2) = qrs(i, k, 2) - pgaut(i, k)*dtcld
9205 IF (qrs(i, k, 3) + pgaut(i, k)*dtcld .LT. 0.) THEN
9208 qrs(i, k, 3) = qrs(i, k, 3) + pgaut(i, k)*dtcld
9212 !-------------------------------------------------------------
9213 ! psevp: Evaporation of melting snow [RH83 A27]
9214 ! (T>=T0: S->V) rh<1., psevp<0, min=-qrs(i,k,2)/dtcld, max=0.
9215 !-------------------------------------------------------------
9216 ! supcol = t0c-t(i,k) ! not change
9218 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9220 xl(i, k) = XLCAL(t(i, k))
9221 cpm(i, k) = CPMCAL(q(i, k))
9222 CALL SMOOTHIF(t(i, k), t0c, ft0, 't+')
9223 IF (90. .GT. t0c - t(i, k)) THEN
9228 IF (0. .LT. y3) THEN
9233 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9236 max12 = qrs(i, k, 2)
9238 arg1 = alpha*max5/2.
9239 arg2 = den(i, k)*max12
9240 result1 = SQRT(arg2)
9241 a = EXP(arg1)*result1
9242 IF (90. .GT. t0c - t(i, k)) THEN
9247 IF (0. .LT. y4) THEN
9252 IF (qrs(i, k, 2) .LT. qcrmin) THEN
9255 max13 = qrs(i, k, 2)
9257 arg1 = (3.-bvts)*alpha*max6/8.
9258 pwx1 = t(i, k) + 120.
9259 pwr1 = pwx1**(1./6.)
9260 pwr2 = t(i, k)**(5.12/6.)
9261 pwr3 = p(i, k)**(1./3.)
9262 pwy4 = (13.+3.*bvts)/24.
9263 pwr4 = den(i, k)**pwy4
9266 b = EXP(arg1)*pwr1/pwr2*pwr3*pwr4*pwr5
9267 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
9269 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
9270 e = (rh(i, k, 1)-1.)/(c+d)
9271 psevp0 = e*(psevp_a*a+psevp_b*b)
9272 IF (psevp0 .LT. -(qrs(i, k, 2)/dtcld)) THEN
9273 x9 = -(qrs(i, k, 2)/dtcld)
9277 IF (x9 .GT. 0.) THEN
9282 psevp(i, k) = ft0*psevp(i, k)
9283 IF (psevp(i, k) .GE. 0.) THEN
9288 IF (abs6 .LT. qmin/dtcld) psevp(i, k) = 0.
9289 IF (q(i, k) - psevp(i, k)*dtcld .LT. 0.) THEN
9292 q(i, k) = q(i, k) - psevp(i, k)*dtcld
9294 IF (qrs(i, k, 2) + psevp(i, k)*dtcld .LT. 0.) THEN
9297 qrs(i, k, 2) = qrs(i, k, 2) + psevp(i, k)*dtcld
9299 t(i, k) = t(i, k) + psevp(i, k)*dtcld*xls/cpm(i, k)
9302 !-------------------------------------------------------------
9303 ! pgevp: Evaporation of melting graupel [RH84 A19]
9304 ! (T>=T0: G->V) rh<1., pgevp<0, min=-qrs(i,k,3)/dtcld, max=0.
9305 !-------------------------------------------------------------
9306 supcol = t0c - t(i, k)
9308 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9310 xl(i, k) = XLCAL(t(i, k))
9311 cpm(i, k) = CPMCAL(q(i, k))
9312 CALL SMOOTHIF(t(i, k), t0c, ft0, 't0')
9313 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9318 a = SQRT(den(i, k)*max7)
9319 IF (qrs(i, k, 3) .LT. qcrmin) THEN
9324 pwx1 = t(i, k) + 120.
9325 pwr1 = pwx1**(1./6.)
9326 pwr2 = t(i, k)**(5.12/6.)
9327 pwr3 = p(i, k)**(1./3.)
9328 pwy4 = (13.+3.*bvtg)/24.
9329 pwr4 = den(i, k)**pwy4
9332 b = pwr1/pwr2*pwr3*pwr4*pwr5
9333 c = diffac_a*den(i, k)*xl(i, k)*xl(i, k)*(t(i, k)+120.)/rv/t(i, &
9335 d = diffac_b*p(i, k)/t(i, k)**1.81/qs(i, k, 1)
9336 e = (rh(i, k, 1)-1.)/(c+d)
9337 pgevp0 = e*(pgevp_a*a+pgevp_b*b)
9338 IF (pgevp0 .LT. -(qrs(i, k, 3)/dtcld)) THEN
9339 x10 = -(qrs(i, k, 3)/dtcld)
9343 IF (x10 .GT. 0.) THEN
9348 pgevp(i, k) = ft0*pgevp(i, k)
9349 IF (pgevp(i, k) .GE. 0.) THEN
9354 IF (abs7 .LT. qmin/dtcld) pgevp(i, k) = 0.
9355 IF (q(i, k) - pgevp(i, k)*dtcld .LT. 0.) THEN
9358 q(i, k) = q(i, k) - pgevp(i, k)*dtcld
9360 IF (qrs(i, k, 3) + pgevp(i, k)*dtcld .LT. 0.) THEN
9363 qrs(i, k, 3) = qrs(i, k, 3) + pgevp(i, k)*dtcld
9365 t(i, k) = t(i, k) + pgevp(i, k)*dtcld*xls/cpm(i, k)
9369 END SUBROUTINE ACCRET3
9371 ! Differentiation of pconadd in forward (tangent) mode (with options r8):
9372 ! variations of useful results: q t qs cpm xl qci
9373 ! with respect to varying inputs: p q t qs cpm xl qci
9374 !=======================================================================
9376 !=======================================================================
9377 SUBROUTINE G_PCONADD(t, g_t, p, g_p, q, g_q, qci, g_qci, qs, g_qs, xl&
9378 & , g_xl, cpm, g_cpm, dtcld, kte, kts, its, ite, kme, kms, ims, ime)
9380 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
9381 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
9382 REAL, DIMENSION(its:ite, kts:kte, 2) :: g_qci
9383 REAL, DIMENSION(its:ite, kts:kte) :: t, xl, pcond, work2, cpm
9384 REAL, DIMENSION(its:ite, kts:kte) :: g_t, g_xl, g_pcond, g_cpm
9385 REAL, DIMENSION(its:ite, kts:kte, 3) :: qs, work1, rh
9386 REAL, DIMENSION(its:ite, kts:kte, 3) :: g_qs, g_work1, g_rh
9387 REAL, DIMENSION(ims:ime, kms:kme) :: q, p
9388 REAL, DIMENSION(ims:ime, kms:kme) :: g_q, g_p
9390 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
9391 & dtcld, qs1, qs2, qs3, qs4, w1, q1
9392 REAL :: tmp1, tmp2, f1, f2, qs0
9410 CALL G_CALCRH(t(i, k), g_t(i, k), p(i, k), g_p(i, k), q(i, k), &
9411 & g_q(i, k), rh(i, k, :), g_rh(i, k, :), qs(i, k, :), g_qs&
9414 g_xl(i, k) = G_XLCAL(t(i, k), g_t(i, k), xl(i, k))
9415 g_cpm(i, k) = G_CPMCAL(q(i, k), g_q(i, k), cpm(i, k))
9416 !----------------------------------------------------------------
9417 ! pcond: condensational/evaporational rate of cloud water [RH83 A6]
9418 ! if there exists additional water vapor condensated/if
9419 ! evaporation of cloud water is not enough to remove subsaturation
9420 !q>qs, work1>0, pcond>0 V->C min=0, max=q(i,k)/dtcld
9421 !q<qs, work1<0, pcond<0 C->V min=-qci(i,k,1)/dtcld, max=0,
9422 g_work1(i, k, 1) = G_CONDEN(t(i, k), g_t(i, k), q(i, k), g_q(i, &
9423 & k), qs(i, k, 1), g_qs(i, k, 1), xl(i, k), g_xl(i, k), cpm(i, k&
9424 & ), g_cpm(i, k), work1(i, k, 1))
9425 IF (work1(i, k, 1) .GT. 0.) THEN
9426 IF (q(i, k) .LT. 0.) THEN
9433 IF (work1(i, k, 1) .GT. y1) THEN
9437 g_min1 = g_work1(i, k, 1)
9438 min1 = work1(i, k, 1)
9440 g_pcond(i, k) = g_min1/dtcld
9441 pcond(i, k) = min1/dtcld
9443 IF (work1(i, k, 1) .LT. -qci(i, k, 1)) THEN
9444 g_max1 = -g_qci(i, k, 1)
9445 max1 = -qci(i, k, 1)
9447 g_max1 = g_work1(i, k, 1)
9448 max1 = work1(i, k, 1)
9450 g_pcond(i, k) = g_max1/dtcld
9451 pcond(i, k) = max1/dtcld
9453 IF (pcond(i, k) .GE. 0.) THEN
9458 IF (abs0 .LT. qmin/dtcld) THEN
9459 g_pcond(i, k) = 0.0_8
9462 IF (q(i, k) - pcond(i, k)*dtcld .LT. 0.) THEN
9466 g_q(i, k) = g_q(i, k) - dtcld*g_pcond(i, k)
9467 q(i, k) = q(i, k) - pcond(i, k)*dtcld
9469 IF (qci(i, k, 1) + pcond(i, k)*dtcld .LT. 0.) THEN
9470 g_qci(i, k, 1) = 0.0_8
9473 g_qci(i, k, 1) = g_qci(i, k, 1) + dtcld*g_pcond(i, k)
9474 qci(i, k, 1) = qci(i, k, 1) + pcond(i, k)*dtcld
9476 temp = pcond(i, k)*xl(i, k)/cpm(i, k)
9477 g_t(i, k) = g_t(i, k) + dtcld*(xl(i, k)*g_pcond(i, k)+pcond(i, k&
9478 & )*g_xl(i, k)-temp*g_cpm(i, k))/cpm(i, k)
9479 t(i, k) = t(i, k) + dtcld*temp
9480 g_pcond(i, k) = 0.0_8
9484 END SUBROUTINE G_PCONADD
9486 !=======================================================================
9488 !=======================================================================
9489 SUBROUTINE PCONADD(t, p, q, qci, qs, xl, cpm, dtcld, kte, kts, its, &
9490 & ite, kme, kms, ims, ime)
9492 INTEGER :: ims, ime, kms, kme, its, ite, kts, kte
9493 REAL, DIMENSION(its:ite, kts:kte, 2) :: qci
9494 REAL, DIMENSION(its:ite, kts:kte) :: t, xl, pcond, work2, cpm
9495 REAL, DIMENSION(its:ite, kts:kte, 3) :: qs, work1, rh
9496 REAL, DIMENSION(ims:ime, kms:kme) :: q, p
9498 REAL :: hsub, hvap, cvap, ttp, dldt, xa, xb, dldti, xai, xbi, tr, &
9499 & dtcld, qs1, qs2, qs3, qs4, w1, q1
9500 REAL :: tmp1, tmp2, f1, f2, qs0
9511 CALL CALCRH(t(i, k), p(i, k), q(i, k), rh(i, k, :), qs(i, k, :))
9513 xl(i, k) = XLCAL(t(i, k))
9514 cpm(i, k) = CPMCAL(q(i, k))
9515 !----------------------------------------------------------------
9516 ! pcond: condensational/evaporational rate of cloud water [RH83 A6]
9517 ! if there exists additional water vapor condensated/if
9518 ! evaporation of cloud water is not enough to remove subsaturation
9519 !q>qs, work1>0, pcond>0 V->C min=0, max=q(i,k)/dtcld
9520 !q<qs, work1<0, pcond<0 C->V min=-qci(i,k,1)/dtcld, max=0,
9521 work1(i, k, 1) = CONDEN(t(i, k), q(i, k), qs(i, k, 1), xl(i, k)&
9523 IF (work1(i, k, 1) .GT. 0.) THEN
9524 IF (q(i, k) .LT. 0.) THEN
9529 IF (work1(i, k, 1) .GT. y1) THEN
9532 min1 = work1(i, k, 1)
9534 pcond(i, k) = min1/dtcld
9536 IF (work1(i, k, 1) .LT. -qci(i, k, 1)) THEN
9537 max1 = -qci(i, k, 1)
9539 max1 = work1(i, k, 1)
9541 pcond(i, k) = max1/dtcld
9543 IF (pcond(i, k) .GE. 0.) THEN
9548 IF (abs0 .LT. qmin/dtcld) pcond(i, k) = 0.
9549 IF (q(i, k) - pcond(i, k)*dtcld .LT. 0.) THEN
9552 q(i, k) = q(i, k) - pcond(i, k)*dtcld
9554 IF (qci(i, k, 1) + pcond(i, k)*dtcld .LT. 0.) THEN
9557 qci(i, k, 1) = qci(i, k, 1) + pcond(i, k)*dtcld
9559 t(i, k) = t(i, k) + pcond(i, k)*dtcld*xl(i, k)/cpm(i, k)
9563 END SUBROUTINE PCONADD
9565 ! Differentiation of smoothif in forward (tangent) mode (with options r8):
9566 ! variations of useful results: f
9567 ! with respect to varying inputs: x
9568 !=======================================================================
9570 !=======================================================================
9571 SUBROUTINE G_SMOOTHIF(x, g_x, a, f, g_f, opt)
9573 REAL, INTENT(IN) :: x, a
9574 REAL, INTENT(IN) :: g_x
9575 CHARACTER(len=2), INTENT(IN) :: opt
9576 REAL, INTENT(OUT) :: f
9577 REAL, INTENT(OUT) :: g_f
9578 REAL(kind=8) :: k1, a1, x1, c1, f1, k, b
9579 REAL(kind=8) :: g_x1, g_f1, g_k
9582 REAL(kind=8) :: temp1, temp2
9586 IF (opt(1:1) .EQ. 'q') THEN
9591 !f=1/(1+exp(-k*(x-b))
9593 IF (opt(2:2) .EQ. '+') THEN
9600 temp1 = 1.0/(EXP(k)+1.)
9601 temp2 = 1.0/(EXP(-k)+1.)
9602 g_f1 = -(temp1*temp2*g_k)
9604 g_f = g_f1 !REAL(g_f1, 4)
9606 END SUBROUTINE G_SMOOTHIF
9608 !=======================================================================
9610 !=======================================================================
9611 SUBROUTINE SMOOTHIF(x, a, f, opt)
9613 REAL, INTENT(IN) :: x, a
9614 CHARACTER(len=2), INTENT(IN) :: opt
9615 REAL, INTENT(OUT) :: f
9616 REAL(kind=8) :: k1, a1, x1, c1, f1, k, b
9620 IF (opt(1:1) .EQ. 'q') THEN
9626 IF (opt(2:2) .EQ. '+') THEN
9634 END SUBROUTINE SMOOTHIF
9638 !=======================================================================
9640 !=======================================================================
9641 REAL FUNCTION RGMMA(x)
9643 !-------------------------------------------------------------------
9644 ! rgmma function: use infinite product form
9646 PARAMETER (euler=0.577215664901532)
9654 rgmma = x*EXP(euler*x)
9657 rgmma = rgmma*(1.000+x/y)*EXP(-(x/y))
9663 ! Differentiation of cpmcal in forward (tangent) mode (with options r8):
9664 ! variations of useful results: cpmcal
9665 ! with respect to varying inputs: x
9668 !=======================================================================
9670 !=======================================================================
9671 ! compute internal functions
9672 FUNCTION G_CPMCAL(x, g_x, cpmcal)
9675 REAL :: g_cpmcal, g_x
9676 g_cpmcal = (cpv-cpd)*g_x
9677 cpmcal = cpd + x*(cpv-cpd)
9678 END FUNCTION G_CPMCAL
9682 !=======================================================================
9684 !=======================================================================
9685 ! compute internal functions
9689 cpmcal = cpd + x*(cpv-cpd)
9692 ! Differentiation of xlcal in forward (tangent) mode (with options r8):
9693 ! variations of useful results: xlcal
9694 ! with respect to varying inputs: x
9696 !=======================================================================
9698 !=======================================================================
9699 FUNCTION G_XLCAL(x, g_x, xlcal)
9702 REAL :: g_xlcal, g_x
9703 g_xlcal = -(xlv1*g_x)
9704 xlcal = xlv0 - xlv1*(x-t0c)
9705 END FUNCTION G_XLCAL
9708 !=======================================================================
9710 !=======================================================================
9714 xlcal = xlv0 - xlv1*(x-t0c)
9717 ! Differentiation of conden in forward (tangent) mode (with options r8):
9718 ! variations of useful results: conden
9719 ! with respect to varying inputs: d e a b c
9720 !=======================================================================
9721 ! a:t, b:q, c:qs, d:xl, e:cpm
9722 !=======================================================================
9723 FUNCTION G_CONDEN(a, g_a, b, g_b, c, g_c, d, g_d, e, g_e, conden)
9725 REAL :: conden, a, b, c, d, e
9726 REAL :: g_conden, g_a, g_b, g_c, g_d, g_e
9733 temp1 = (b-c)/(temp0+1.)
9734 g_conden = (g_b-g_c-temp1*(c*2*d*g_d+d**2*g_c-temp0*(a**2*rv*g_e+rv*&
9735 & e*2*a*g_a))/temp)/(temp0+1.)
9737 END FUNCTION G_CONDEN
9739 !=======================================================================
9740 ! a:t, b:q, c:qs, d:xl, e:cpm
9741 !=======================================================================
9742 FUNCTION CONDEN(a, b, c, d, e)
9744 REAL :: conden, a, b, c, d, e
9746 conden = (b-c)/(1.+d*d/(rv*e)*c/(a*a))
9749 END MODULE G_MODULE_MP_WSM6R