CCPP SciDoc v7.0.0  v7.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
module_mp_tempo_utils.F90
2 !! utilities for tempo microphysics
3 use module_mp_tempo_params, only : wp, sp, dp
4 implicit none
5 private
6
7 public :: snow_moments, calc_gamma_p, get_nuc, get_constant_cloud_number, &
8 calc_rslf, calc_rsif, compute_efrw, compute_efsw, compute_drop_evap, qi_aut_qs
9
10 contains
11
12 subroutine get_constant_cloud_number(land, nc)
13 !! returns land-specific value of cloud droplet number concentration
14 !! when aerosol-aware = false if land = 1, else returns ocean-specific value
15 use module_mp_tempo_params, only : nt_c_l, nt_c_o
16
17 integer, intent(in), optional :: land
18 real(wp), dimension(:), intent(out) :: nc
19
20 nc = nt_c_l
21 if (present(land)) then
22 if (land /= 1) nc = nt_c_o
23 endif
24 end subroutine get_constant_cloud_number
25
26
27 function calc_gamma_p(a, x) result(gamma_p)
28 !! normalized lower gamma function calculated either with a
29 !! series expansion or continued fraction method
30 !!
31 !! input: a = gamma function argument, x = upper limit of integration
32 !!
33 !! output: gamma_p = \‍(\gamma(a, x) / \Gamma(a)\‍)
34 real(wp), intent(in) :: a, x
35 real(wp) :: gamma_p
36
37 if ((x < 0.0_wp) .or. (a <= 0.0_wp)) then
38 write(*,*) "Invalid arguments for function gamma_p"
39 return
40 endif
41
42 ! tests show that the continued fraction solution will blow up
43 ! if a = x + 1, and so while faster, series expansion is used
44 ! for a > x - 1
45 if (x < (a + 1.0_wp)) then
46 gamma_p = calc_gamma_series(a, x)
47 else
48 ! gammma_cf computes the upper series
49 gamma_p = 1.0_wp - calc_gamma_cf(a, x)
50 endif
51 end function calc_gamma_p
52
53
54 function calc_gamma_series(a, x) result(gamma_series)
55 !! solves the normalized lower gamma function
56 !!
57 !! \‍(\gamma(a,x) / \Gamma(a) = x^{a} * \gamma*(a,x)\‍)
58 !!
59 !! see [Equation 8.7.1](https://dlmf.nist.gov/8.7)
60 !! \‍(\gamma(a,x) = exp(-x) * \sum_{k=0}^{\infty} \frac{x^{k}}{\Gamma(a+k+1)}\‍)
61 !!
62 !! see also [Equation 8.2.6](https://dlmf.nist.gov/8.2#E6)
63 !! see also Numerical Recipes in Fortran
64 !!
65 !! input: a = gamma function argument, x = upper limit of integration
66 !!
67 !! output: normalized lower gamma function \‍(\gamma(a, x) / \Gamma(a)\‍)
68
69 ! Iterations:
70 ! k_term = k-1_term * x * (Gamma(a+k)/Gamma(a+k+1)) = k-1_term * x * (1 / (a + k))
71
72 real(wp), intent(in) :: a, x
73 integer :: k
74 integer, parameter :: it_max = 100
75 real(wp), parameter :: smallvalue = 1.e-7_wp
76 real(wp) :: aj, sum_term, sum
77 real(wp) :: gamma_series
78
79 ! if (x <= 0.0_wp) stop "Invalid arguments for function gamma_series"
80 ! k = 0 summation term is 1 / Gamma(a+1)
81 aj = a
82 sum_term = 1.0_wp / gamma(aj+1.0_wp)
83 sum = sum_term
84 do k = 1, it_max
85 aj = aj + 1.0_wp
86 sum_term = sum_term * x / aj
87 sum = sum + sum_term
88 if (abs(sum_term) < (abs(sum) * smallvalue)) exit
89 enddo
90 ! if (k == it_max) stop "gamma_series solution did not converge"
91 gamma_series = sum * x**a * exp(-x)
92 end function calc_gamma_series
93
94
95 function calc_gamma_cf(a, x) result(gamma_cf)
96 !! solves the normalized upper gamma function \‍(\gamma(a,x) / \Gamma(a)\‍)
97 !! using a continued fractions method
98 !! [(modified Lentz Algorithm)](http://functions.wolfram.com/06.06.10.0003.01)
99 !! see also Numerical Recipes in Fortran
100 !!
101 !!input: a = gamma function argument, x = lower limit of integration
102 !!
103 !!output: normalized upper gamma function: \‍(\gamma(a, x) / \Gamma(a)\‍)
104
105 ! Iteration:
106 ! set f0 = b0, where b0 = 0
107 ! set c0 = f0
108 ! set d0 = 0
109 ! dj = bj + aj * dj-1 (set dj to TINY if dj = 0)
110 ! cj = bj + aj / cj-1 (set cj to TINY if cj = 0)
111 ! dj = 1 / dj
112 ! deltaj = cj * dj
113 ! fj = fj-1 * deltaj
114
115 real(wp), intent(in) :: a, x
116 integer :: k
117 integer, parameter :: it_max = 100
118 real(wp), parameter :: smallvalue = 1.e-7_wp
119 real(wp), parameter :: offset = 1.e-30_wp
120 real(wp) :: b, d, f0, c, delta, f, aj
121 real(wp) :: gamma_cf
122
123 f0 = offset
124 ! iteration 1
125 b = 1.0_wp - a + x
126 d = 1.0_wp / b
127 c = b + (1.0_wp / f0)
128 delta = c * d
129 f = f0 * delta
130
131 do k = 1, it_max
132 aj = k * (a-k)
133 b = b + 2.0_wp
134 d = b + aj*d
135 if(abs(d) < offset) d = offset
136 c = b + aj/c
137 if(abs(c) < offset) c = offset
138 d = 1.0_wp / d
139 delta = c * d
140 f = f * delta
141 if (abs(delta-1.0_wp) < smallvalue) exit
142 enddo
143 ! if (k == it_max) stop "gamma_cf solution did not converge"
144 gamma_cf = exp(-x+a*log(x)) * f / gamma(a)
145 end function calc_gamma_cf
146
147
148 subroutine snow_moments(rs, tc, smob, smoc, ns, smo0, smo1, smo2, smoe, smof, smog, smoz)
149 !! computes snow moments from
150 !! [Field et al. (2005)](https://doi.org/10.1256/qj.04.134)
151 ! smo0 = 0th moment
152 ! smo1 = 1st moment
153 ! smo2 = 2nd moment
154 ! ns = total number concentration (not smo0)
155 ! smob = rs*oams (2nd moment when bm_s=2)
156 ! smoc = (bm_s+1)th moment
157 ! smoe = (bv_s+2)th moment
158 ! smof = (1+(bv_s+1)/2)th moment
159 ! smog = (bm_s+bv_s+2)th moment
160 ! somz = (bm**2)th moment for reflectivity
161 use module_mp_tempo_params, only : bm_s, sa, sb, &
162 oams, cse, csg, lam0, lam1, kap0, kap1, mu_s
163
164 real(wp), intent(in) :: rs, tc
165 real(dp) :: loga_, a_, b_, smo2_, m0, mrat, slam1, slam2
166 real(dp), intent(out) :: smob, smoc
167 real(dp), intent(out), optional :: ns, smo0, smo1, smo2, smoe, smof, smog, smoz
168
169 ! Second moment and smob
170 smob = real(rs*oams, kind=dp)
171 if (bm_s > 2.0_wp-1.e-3_wp .and. bm_s < 2.0_wp+1.e-3_wp) then
172 loga_ = sa(1) + sa(2)*tc + sa(3)*bm_s &
173 + sa(4)*tc*bm_s + sa(5)*tc*tc &
174 + sa(6)*bm_s*bm_s + sa(7)*tc*tc*bm_s &
175 + sa(8)*tc*bm_s*bm_s + sa(9)*tc*tc*tc &
176 + sa(10)*bm_s*bm_s*bm_s
177 a_ = 10.0_wp**loga_
178 b_ = sb(1) + sb(2)*tc + sb(3)*bm_s &
179 + sb(4)*tc*bm_s + sb(5)*tc*tc &
180 + sb(6)*bm_s*bm_s + sb(7)*tc*tc*bm_s &
181 + sb(8)*tc*bm_s*bm_s + sb(9)*tc*tc*tc &
182 + sb(10)*bm_s*bm_s*bm_s
183 smo2_ = (smob/a_)**(1._wp/b_)
184 else
185 smo2_ = smob
186 endif
187 if (present(smo2)) smo2 = smo2_
188
189 ! bm+1 moment. Useful for diameter calcs.
190 loga_ = sa(1) + sa(2)*tc + sa(3)*cse(1) &
191 + sa(4)*tc*cse(1) + sa(5)*tc*tc &
192 + sa(6)*cse(1)*cse(1) + sa(7)*tc*tc*cse(1) &
193 + sa(8)*tc*cse(1)*cse(1) + sa(9)*tc*tc*tc &
194 + sa(10)*cse(1)*cse(1)*cse(1)
195 a_ = 10.0_dp**loga_
196 b_ = sb(1)+sb(2)*tc+sb(3)*cse(1) + sb(4)*tc*cse(1) &
197 + sb(5)*tc*tc + sb(6)*cse(1)*cse(1) &
198 + sb(7)*tc*tc*cse(1) + sb(8)*tc*cse(1)*cse(1) &
199 + sb(9)*tc*tc*tc+sb(10)*cse(1)*cse(1)*cse(1)
200 smoc = a_ * smo2_**b_
201
202 ! 0th moment. Represents snow number concentration.
203 loga_ = sa(1) + sa(2)*tc + sa(5)*tc*tc + sa(9)*tc*tc*tc
204 a_ = 10.0**loga_
205 b_ = sb(1) + sb(2)*tc + sb(5)*tc*tc + sb(9)*tc*tc*tc
206 if (present(smo0)) smo0 = a_ * smo2_**b_
207
208 ! 1st moment. Useful for depositional growth and melting.
209 loga_ = sa(1) + sa(2)*tc + sa(3) &
210 + sa(4)*tc + sa(5)*tc*tc &
211 + sa(6) + sa(7)*tc*tc &
212 + sa(8)*tc + sa(9)*tc*tc*tc &
213 + sa(10)
214 a_ = 10.0**loga_
215 b_ = sb(1)+ sb(2)*tc + sb(3) + sb(4)*tc &
216 + sb(5)*tc*tc + sb(6) &
217 + sb(7)*tc*tc + sb(8)*tc &
218 + sb(9)*tc*tc*tc + sb(10)
219 if (present(smo1)) smo1 = a_ * smo2_**b_
220
221 ! snow number concentration (explicit integral, not smo0)
222 m0 = smob/smoc
223 mrat = smob*m0*m0*m0
224 slam1 = m0 * lam0
225 slam2 = m0 * lam1
226 if (present(ns)) then
227 ns = mrat*kap0/slam1 + mrat*kap1*m0**mu_s*csg(15)/slam2**cse(15)
228 endif
229
230 ! bv_s+2 (th) moment. Useful for riming.
231 loga_ = sa(1) + sa(2)*tc + sa(3)*cse(13) &
232 + sa(4)*tc*cse(13) + sa(5)*tc*tc &
233 + sa(6)*cse(13)*cse(13) + sa(7)*tc*tc*cse(13) &
234 + sa(8)*tc*cse(13)*cse(13) + sa(9)*tc*tc*tc &
235 + sa(10)*cse(13)*cse(13)*cse(13)
236 a_ = 10.0**loga_
237 b_ = sb(1)+ sb(2)*tc + sb(3)*cse(13) + sb(4)*tc*cse(13) &
238 + sb(5)*tc*tc + sb(6)*cse(13)*cse(13) &
239 + sb(7)*tc*tc*cse(13) + sb(8)*tc*cse(13)*cse(13) &
240 + sb(9)*tc*tc*tc + sb(10)*cse(13)*cse(13)*cse(13)
241 if (present(smoe)) smoe = a_ * smo2_**b_
242
243 ! 1+(bv_s+1)/2 (th) moment. Useful for depositional growth.
244 loga_ = sa(1) + sa(2)*tc + sa(3)*cse(16) &
245 + sa(4)*tc*cse(16) + sa(5)*tc*tc &
246 + sa(6)*cse(16)*cse(16) + sa(7)*tc*tc*cse(16) &
247 + sa(8)*tc*cse(16)*cse(16) + sa(9)*tc*tc*tc &
248 + sa(10)*cse(16)*cse(16)*cse(16)
249 a_ = 10.0**loga_
250 b_ = sb(1)+ sb(2)*tc + sb(3)*cse(16) + sb(4)*tc*cse(16) &
251 + sb(5)*tc*tc + sb(6)*cse(16)*cse(16) &
252 + sb(7)*tc*tc*cse(16) + sb(8)*tc*cse(16)*cse(16) &
253 + sb(9)*tc*tc*tc + sb(10)*cse(16)*cse(16)*cse(16)
254 if (present(smof)) smof = a_ * smo2_**b_
255
256 ! bm_s + bv_s+2 (th) moment. Useful for riming into graupel.
257 loga_ = sa(1) + sa(2)*tc + sa(3)*cse(17) &
258 + sa(4)*tc*cse(17) + sa(5)*tc*tc &
259 + sa(6)*cse(17)*cse(17) + sa(7)*tc*tc*cse(17) &
260 + sa(8)*tc*cse(17)*cse(17) + sa(9)*tc*tc*tc &
261 + sa(10)*cse(17)*cse(17)*cse(17)
262 a_ = 10.0**loga_
263 b_ = sb(1)+ sb(2)*tc + sb(3)*cse(17) + sb(4)*tc*cse(17) &
264 + sb(5)*tc*tc + sb(6)*cse(17)*cse(17) &
265 + sb(7)*tc*tc*cse(17) + sb(8)*tc*cse(17)*cse(17) &
266 + sb(9)*tc*tc*tc + sb(10)*cse(17)*cse(17)*cse(17)
267 if (present(smog)) smog = a_ * smo2_**b_
268
269 !..Calculate bm_s*2 (th) moment. Useful for reflectivity.
270 loga_ = sa(1) + sa(2)*tc + sa(3)*cse(3) &
271 + sa(4)*tc*cse(3) + sa(5)*tc*tc &
272 + sa(6)*cse(3)*cse(3) + sa(7)*tc*tc*cse(3) &
273 + sa(8)*tc*cse(3)*cse(3) + sa(9)*tc*tc*tc &
274 + sa(10)*cse(3)*cse(3)*cse(3)
275 a_ = 10.0**loga_
276 b_ = sb(1)+ sb(2)*tc + sb(3)*cse(3) + sb(4)*tc*cse(3) &
277 + sb(5)*tc*tc + sb(6)*cse(3)*cse(3) &
278 + sb(7)*tc*tc*cse(3) + sb(8)*tc*cse(3)*cse(3) &
279 + sb(9)*tc*tc*tc + sb(10)*cse(3)*cse(3)*cse(3)
280 if (present(smoz)) smoz = a_ * smo2**b_
281
282 end subroutine snow_moments
283
284
285 function calc_rslf(p, t) result(rslf)
286 !! calculates liquid saturation vapor mixing ratio
287 real(wp), intent(in) :: p, t
288 real(wp) :: esl, x
289 real(wp), parameter :: c0 = .611583699e03_wp
290 real(wp), parameter :: c1 = .444606896e02_wp
291 real(wp), parameter :: c2 = .143177157e01_wp
292 real(wp), parameter :: c3 = .264224321e-1_wp
293 real(wp), parameter :: c4 = .299291081e-3_wp
294 real(wp), parameter :: c5 = .203154182e-5_wp
295 real(wp), parameter :: c6 = .702620698e-8_wp
296 real(wp), parameter :: c7 = .379534310e-11_wp
297 real(wp), parameter :: c8 = -.321582393e-13_wp
298 real(wp) :: rslf
299
300 x = max(-80._wp, t-273.16_wp)
301 esl = c0+x*(c1+x*(c2+x*(c3+x*(c4+x*(c5+x*(c6+x*(c7+x*c8)))))))
302 esl = min(esl, p*0.15)
303 !! @note
304 !! even with p = 1050 mb and t = 55 C, the saturation vapor
305 !! pressure only contributes to 15% of the total pressure,
306 !! thus the limit on the saturation vapor pressure is set to 15%
307 !! @endnote
308 rslf = .622*esl/(p-esl)
309 end function calc_rslf
310
311
312 function calc_rsif(p, t) result(rsif)
313 !! calculates liquid saturation vapor mixing ratio
314 real(wp), intent(in) :: p, t
315 real(wp) :: esi, x
316 real(wp), parameter :: c0 = .609868993e03_wp
317 real(wp), parameter :: c1 = .499320233e02_wp
318 real(wp), parameter :: c2 = .184672631e01_wp
319 real(wp), parameter :: c3 = .402737184e-1_wp
320 real(wp), parameter :: c4 = .565392987e-3_wp
321 real(wp), parameter :: c5 = .521693933e-5_wp
322 real(wp), parameter :: c6 = .307839583e-7_wp
323 real(wp), parameter :: c7 = .105785160e-9_wp
324 real(wp), parameter :: c8 = .161444444e-12_wp
325 real(wp) :: rsif
326
327 x = max(-80._wp, t-273.16_wp)
328 esi = c0+x*(c1+x*(c2+x*(c3+x*(c4+x*(c5+x*(c6+x*(c7+x*c8)))))))
329 esi = min(esi, p*0.15)
330 rsif = .622*esi/max(1.e-4_wp,(p-esi))
331 end function calc_rsif
332
333
334 function get_nuc(nc) result(nu_c)
335 !! returns nu_c for cloud water (values from 2-15)
336 use module_mp_tempo_params, only : nu_c_scale
337
338 real(wp), intent(in) :: nc
339 integer :: nu_c
340
341 if ((nu_c_scale/nc) >= 12.5_wp) then
342 nu_c = 15
343 else
344 nu_c = min(15, nint(nu_c_scale/nc) + 2)
345 endif
346 end function get_nuc
347
348
349 subroutine compute_efrw()
350 !! collision efficiency for rain collecting cloud water from Beard and Grover (1974)
351 !! if a/A < 0.25
352 !! https://doi.org/10.1175/1520-0469(1974)031<0543:NCEFSR>2.0.CO;2
353 !! otherwise uses polynomials to get close match of Pruppacher and Klett Fig. 14-9
354 use module_mp_tempo_params, only : nbc, nbr, dc, dr, t_efrw, rho_w, pi
355
356 real(dp) :: vtr, stokes, reynolds, ef_rw
357 real(dp) :: p, yc0, f, g, h, z, k0, x
358 integer :: i, j
359
360 do j = 1, nbc
361 do i = 1, nbr
362 ef_rw = 0.0_dp
363 p = dc(j) / dr(i)
364 if (dr(i) < 50.e-6_dp .or. dc(j) < 3.e-6_dp) then
365 t_efrw(i,j) = 0.0_dp
366 elseif (p > 0.25_dp) then
367 x = dc(j) * 1.e6_dp
368 if (dr(i) < 75.e-6_dp) then
369 ef_rw = 0.026794_dp*x - 0.20604_dp
370 elseif (dr(i) < 125.e-6_dp) then
371 ef_rw = -0.00066842_dp*x*x + 0.061542_dp*x - 0.37089_dp
372 elseif (dr(i) < 175.e-6_dp) then
373 ef_rw = 4.091e-06_dp*x*x*x*x - 0.00030908_dp*x*x*x + &
374 0.0066237_dp*x*x - 0.0013687_dp*x - 0.073022_dp
375 elseif (dr(i) < 250.e-6_dp) then
376 ef_rw = 9.6719e-5_dp*x*x*x - 0.0068901_dp*x*x + 0.17305_dp*x - 0.65988_dp
377 elseif (dr(i) < 350.e-6_dp) then
378 ef_rw = 9.0488e-5_dp*x*x*x - 0.006585_dp*x*x + 0.16606_dp*x - 0.56125_dp
379 else
380 ef_rw = 0.00010721_dp*x*x*x - 0.0072962_dp*x*x + 0.1704_dp*x - 0.46929_dp
381 endif
382 else
383 vtr = -0.1021_dp + 4.932e3_dp*dr(i) - 0.9551e6_dp*dr(i)*dr(i) + 0.07934e9_dp*dr(i)*dr(i)*dr(i) &
384 - 0.002362e12_dp*dr(i)*dr(i)*dr(i)*dr(i)
385 stokes = dc(j) * dc(j) * vtr * rho_w / (9._dp*1.718e-5_dp*dr(i))
386 reynolds = 9._dp * stokes / (p*p*rho_w)
387
388 f = log(reynolds)
389 g = -0.1007_dp - 0.358_dp*f + 0.0261_dp*f*f
390 k0 = exp(g)
391 z = log(stokes / (k0+1.e-15_dp))
392 h = 0.1465_dp + 1.302_dp*z - 0.607_dp*z*z + 0.293_dp*z*z*z
393 yc0 = 2.0_dp / pi * atan(h)
394 ef_rw = (yc0+p)*(yc0+p) / ((1.+p)*(1.+p))
395 endif
396
397 t_efrw(i,j) = max(0.0_dp, min(ef_rw, 0.95_dp))
398 enddo
399 enddo
400 end subroutine compute_efrw
401
402
403 subroutine compute_efsw()
404 !! collision efficiency for snow collecting cloud water from Wang and Ji (2000)
405 !! https://doi.org/10.1175/1520-0469(2000)057<1001:CEOICA>2.0.CO;2
406 !! equating melted snow diameter to effective collision cross-section
407 use module_mp_tempo_params, only : wp, sp, dp, &
408 nbc, dc, av_s, bv_s, ds, nbs, am_s, bm_s, am_r, obmr, fv_s, &
409 t_efsw, d0s, rho_w, pi
410
411 real(dp) :: ds_m, vts, vtc, stokes, reynolds, ef_sw
412 real(dp) :: p, yc0, f, g, h, z, k0
413 integer :: i, j
414
415 do j = 1, nbc
416 vtc = 1.19e4_dp * (1.0e4_dp*dc(j)*dc(j)*0.25_dp)
417 do i = 1, nbs
418 vts = av_s*ds(i)**bv_s * exp(real(-fv_s*ds(i), kind=dp)) - vtc
419 ds_m = (am_s*ds(i)**bm_s / am_r)**obmr
420 p = dc(j) / ds_m
421
422 if (p > 0.25_dp .or. ds(i) < d0s .or. dc(j) < 6.e-6_dp .or. vts < 1.e-3_dp) then
423 t_efsw(i,j) = 0.0_dp
424 else
425 stokes = dc(j) * dc(j) * vts * rho_w / (9.*1.718e-5_dp*ds_m)
426 reynolds = 9._dp * stokes / (p*p*rho_w)
427
428 f = log(reynolds)
429 g = -0.1007_dp - 0.358_dp*f + 0.0261_dp*f*f
430 k0 = exp(g)
431 z = log(stokes / (k0+1.e-15_dp))
432 h = 0.1465_dp + 1.302_dp*z - 0.607_dp*z*z + 0.293_dp*z*z*z
433 yc0 = 2.0_dp / pi * atan(h)
434 ef_sw = (yc0+p)*(yc0+p) / ((1.+p)*(1.+p))
435
436 t_efsw(i,j) = max(0.0_dp, min(ef_sw, 0.95_dp))
437 endif
438 enddo
439 enddo
440 end subroutine compute_efsw
441
442
443 subroutine qi_aut_qs()
444 !! calculates cloud ice conversion to snow
445 !! and depositional growth by binning cloud ice distributions and
446 !! determining both the size bins > d0s (that are converted to snow) and the
447 !! depositional growth up to d0s (for cloud ice) and > d0s for snow
448 !! following Harrington et al. (1995)
449 !! https://doi.org/10.1175/1520-0469(1995)052<4344:POICCP>2.0.CO;2
450 use module_mp_tempo_params, only : wp, sp, dp, &
451 nbi, ntb_i, ntb_i1, &
452 am_i, cie, cig, oig1, nt_i, r_i, obmi, bm_i, mu_i, d0s, d0i, &
453 tpi_ide, tps_iaus, tni_iaus, di, dti
454
455 integer :: i, j, n2
456 real(dp), dimension(nbi) :: n_i
457 real(dp) :: n0_i, lami, di_mean, t1, t2
458 real(wp) :: xlimit_intg
459
460 do j = 1, ntb_i1
461 do i = 1, ntb_i
462 lami = (am_i*cig(2)*oig1*nt_i(j)/r_i(i))**obmi
463 di_mean = (bm_i + mu_i + 1.) / lami
464 n0_i = nt_i(j)*oig1 * lami**cie(1)
465 t1 = 0.
466 t2 = 0.
467 if (real(di_mean, kind=wp) > 5.*d0s) then
468 t1 = r_i(i)
469 t2 = nt_i(j)
470 tpi_ide(i,j) = 0.
471 elseif (real(di_mean, kind=wp) < d0i) then
472 t1 = 0.
473 t2 = 0.
474 tpi_ide(i,j) = 1.
475 else
476 xlimit_intg = lami*d0s
477 tpi_ide(i,j) = real(calc_gamma_p(mu_i+2.0, xlimit_intg), kind=dp)
478 do n2 = 1, nbi
479 n_i(n2) = n0_i*di(n2)**mu_i * exp(-lami*di(n2))*dti(n2)
480 if (di(n2) >= d0s) then
481 t1 = t1 + n_i(n2) * am_i*di(n2)**bm_i
482 t2 = t2 + n_i(n2)
483 endif
484 enddo
485 endif
486 tps_iaus(i,j) = t1
487 tni_iaus(i,j) = t2
488 enddo
489 enddo
490 end subroutine qi_aut_qs
491
492
493 subroutine compute_drop_evap()
494 !! calculates droplet evaporation data
495 use module_mp_tempo_params, only: wp, sp, dp, &
496 nbc, am_r, dc, bm_r, nu_c_scale, nu_c_max, nu_c_min, &
497 t_nc, ntb_c, cce, ccg, ocg1, r_c, obmr, dtc, &
498 tpc_wev, tnc_wev
499
500 integer :: i, j, k, n
501 real(dp), dimension(nbc) :: n_c, massc
502 real(dp) :: summ, summ2, lamc, n0_c
503 integer :: nu_c
504
505 do n = 1, nbc
506 massc(n) = am_r*dc(n)**bm_r
507 enddo
508
509 do k = 1, nbc
510 nu_c = get_nuc(real(t_nc(k), kind=wp))
511 do j = 1, ntb_c
512 lamc = (t_nc(k)*am_r* ccg(2,nu_c)*ocg1(nu_c) / r_c(j))**obmr
513 n0_c = t_nc(k)*ocg1(nu_c) * lamc**cce(1,nu_c)
514 do i = 1, nbc
515 n_c(i) = n0_c* dc(i)**nu_c*exp(-lamc*dc(i))*dtc(i)
516 summ = 0._dp
517 summ2 = 0._dp
518 do n = 1, i
519 summ = summ + massc(n)*n_c(n)
520 summ2 = summ2 + n_c(n)
521 enddo
522 tpc_wev(i,j,k) = summ
523 tnc_wev(i,j,k) = summ2
524 enddo
525 enddo
526 enddo
527 end subroutine compute_drop_evap
528
529end module module_mp_tempo_utils