SCALE-RM
scale_atmos_phy_mp_sn14.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
48 !-------------------------------------------------------------------------------
49 
50 #include "scalelib.h"
52  !-----------------------------------------------------------------------------
53  !
54  !++ used modules
55  !
56  use scale_precision
57  use scale_io
58  use scale_prof
59 
60  use scale_const, only: &
61  grav => const_grav, &
62  pi => const_pi, &
63  undef8 => const_undef8, &
64  rdry => const_rdry, &
65  cpdry => const_cpdry, &
66  cvdry => const_cvdry, &
67  p00 => const_pre00, &
68  t00 => const_tem00, &
69  rvap => const_rvap, &
70  cpvap => const_cpvap, &
71  cvvap => const_cvvap, &
72  cl => const_cl, &
73  ci => const_ci, &
74  lhv => const_lhv00, &
75  lhf => const_lhf00, &
76  lhv0 => const_lhv0, &
77  lhf0 => const_lhf0, &
78  lhs0 => const_lhs0, &
79  lhv00 => const_lhv00, &
80  lhf00 => const_lhf00, &
81  psat0 => const_psat0, &
82  emelt => const_emelt, &
83  dwatr => const_dwatr, &
84  small => const_eps
85 
86  use scale_atmos_hydrometeor, only: &
87  n_hyd
88 
89  !-----------------------------------------------------------------------------
90  implicit none
91  private
92  !-----------------------------------------------------------------------------
93  !
94  !++ Public procedure
95  !
96  public :: atmos_phy_mp_sn14_setup
105 
106  !-----------------------------------------------------------------------------
107  !
108  !++ Public parameters & variables
109  !
110  integer, public, parameter :: qa_mp = 11
111 
112  integer, parameter, public :: atmos_phy_mp_sn14_ntracers = qa_mp
113  integer, parameter, public :: atmos_phy_mp_sn14_nwaters = 2
114  integer, parameter, public :: atmos_phy_mp_sn14_nices = 3
115  character(len=H_SHORT), parameter, public :: atmos_phy_mp_sn14_tracer_names(qa_mp) = (/ &
116  'QV', &
117  'QC', &
118  'QR', &
119  'QI', &
120  'QS', &
121  'QG', &
122  'NC', &
123  'NR', &
124  'NI', &
125  'NS', &
126  'NG' /)
127  character(len=H_MID) , parameter, public :: atmos_phy_mp_sn14_tracer_descriptions(qa_mp) = (/ &
128  'Ratio of Water Vapor mass to total mass (Specific humidity)', &
129  'Ratio of Cloud Water mass to total mass ', &
130  'Ratio of Rain Water mass to total mass ', &
131  'Ratio of Cloud Ice mass ratio to total mass ', &
132  'Ratio of Snow mass ratio to total mass ', &
133  'Ratio of Graupel mass ratio to total mass ', &
134  'Cloud Water Number Density ', &
135  'Rain Water Number Density ', &
136  'Cloud Ice Number Density ', &
137  'Snow Number Density ', &
138  'Graupel Number Density '/)
139  character(len=H_SHORT), parameter, public :: atmos_phy_mp_sn14_tracer_units(qa_mp) = (/ &
140  'kg/kg ', &
141  'kg/kg ', &
142  'kg/kg ', &
143  'kg/kg ', &
144  'kg/kg ', &
145  'kg/kg ', &
146  'num/kg', &
147  'num/kg', &
148  'num/kg', &
149  'num/kg', &
150  'num/kg' /)
151 
152  !-----------------------------------------------------------------------------
153  !
154  !++ Private procedure
155  !
156  private :: mp_sn14_init
157  private :: mp_sn14
158 
159  !-----------------------------------------------------------------------------
160  !
161  !++ Private parameters
162  !
163  integer, private, parameter :: i_qv = 1
164  integer, private, parameter :: i_qc = 2
165  integer, private, parameter :: i_qr = 3
166  integer, private, parameter :: i_qi = 4
167  integer, private, parameter :: i_qs = 5
168  integer, private, parameter :: i_qg = 6
169  integer, private, parameter :: i_nc = 7
170  integer, private, parameter :: i_nr = 8
171  integer, private, parameter :: i_ni = 9
172  integer, private, parameter :: i_ns = 10
173  integer, private, parameter :: i_ng = 11
174 
175  integer, private, parameter :: hydro_max = 5
176 
177  integer, private, parameter :: i_mp_qc = 1
178  integer, private, parameter :: i_mp_qr = 2
179  integer, private, parameter :: i_mp_qi = 3
180  integer, private, parameter :: i_mp_qs = 4
181  integer, private, parameter :: i_mp_qg = 5
182  integer, private, parameter :: i_mp_nc = 6
183  integer, private, parameter :: i_mp_nr = 7
184  integer, private, parameter :: i_mp_ni = 8
185  integer, private, parameter :: i_mp_ns = 9
186  integer, private, parameter :: i_mp_ng = 10
187 
188  ! production rate
189  ! nucleation
190  integer, parameter :: i_lcccn = 1
191  integer, parameter :: i_ncccn = 2
192  integer, parameter :: i_liccn = 3
193  integer, parameter :: i_niccn = 4
194  ! freezing
195  integer, parameter :: i_lchom = 5
196  integer, parameter :: i_nchom = 6
197  integer, parameter :: i_lchet = 7
198  integer, parameter :: i_nchet = 8
199  integer, parameter :: i_lrhet = 9
200  integer, parameter :: i_nrhet = 10
201  ! melting
202  integer, parameter :: i_limlt = 11
203  integer, parameter :: i_nimlt = 12
204  integer, parameter :: i_lsmlt = 13
205  integer, parameter :: i_nsmlt = 14
206  integer, parameter :: i_lgmlt = 15
207  integer, parameter :: i_ngmlt = 16
208  ! vapor deposition
209  integer, parameter :: i_lrdep = 17
210  integer, parameter :: i_nrdep = 18
211  integer, parameter :: i_lidep = 19
212  integer, parameter :: i_nidep = 20
213  integer, parameter :: i_lsdep = 21
214  integer, parameter :: i_nsdep = 22
215  integer, parameter :: i_lgdep = 23
216  integer, parameter :: i_ngdep = 24
217  integer, parameter :: i_lcdep = 25
218 ! integer, parameter :: I_NCdep = 26
219  ! warm collection process
220  ! auto-conversion
221  integer, parameter :: i_lcaut = 26
222  integer, parameter :: i_ncaut = 27
223  integer, parameter :: i_nraut = 28
224  ! accretion
225  integer, parameter :: i_lcacc = 29
226  integer, parameter :: i_ncacc = 30
227  ! self-colletion, break-up
228  integer, parameter :: i_nrslc = 31
229  integer, parameter :: i_nrbrk = 32
230 
231  ! partial conversion(ice, snow => graupel)
232  integer, parameter :: i_licon = 33
233  integer, parameter :: i_nicon = 34
234  integer, parameter :: i_lscon = 35
235  integer, parameter :: i_nscon = 36
236  ! enhanced melting due to
237  integer, parameter :: i_liacm = 37 ! ice-cloud
238  integer, parameter :: i_niacm = 38
239  integer, parameter :: i_liarm = 39 ! ice-rain
240  integer, parameter :: i_niarm = 40
241  integer, parameter :: i_lsacm = 41 ! snow-cloud
242  integer, parameter :: i_nsacm = 42
243  integer, parameter :: i_lsarm = 43 ! snow-rain
244  integer, parameter :: i_nsarm = 44
245  integer, parameter :: i_lgacm = 45 ! graupel-cloud
246  integer, parameter :: i_ngacm = 46
247  integer, parameter :: i_lgarm = 47 ! graupel-rain
248  integer, parameter :: i_ngarm = 48
249  ! ice multiplication by splintering
250  integer, parameter :: i_lgspl = 49
251  integer, parameter :: i_lsspl = 50
252  integer, parameter :: i_nispl = 51
253  integer, parameter :: i_lihom = 52
254  integer, parameter :: i_nihom = 53
255  ! for charge density
256  integer, parameter :: i_ngspl = 54
257  integer, parameter :: i_nsspl = 55
258 
259  integer, parameter :: pq_max = 55
260 
261 
262  ! production rate of mixed-phase collection process
263  ! PXXacYY2ZZ means XX collect YY produce ZZ
264  integer, parameter :: i_liaclc2li = 1 ! cloud-ice
265  integer, parameter :: i_niacnc2ni = 2
266  integer, parameter :: i_lsaclc2ls = 3 ! cloud-snow(cloud change)
267  integer, parameter :: i_nsacnc2ns = 4
268  integer, parameter :: i_lgaclc2lg = 5 ! cloud-graupel
269  integer, parameter :: i_ngacnc2ng = 6
270  integer, parameter :: i_lracli2lg_i = 7 ! rain-ice(ice change)
271  integer, parameter :: i_nracni2ng_i = 8
272  integer, parameter :: i_lracli2lg_r = 9 ! rain-ice(rain change)
273  integer, parameter :: i_nracni2ng_r = 10
274  integer, parameter :: i_lracls2lg_s = 11 ! rain-snow(snow change)
275  integer, parameter :: i_nracns2ng_s = 12
276  integer, parameter :: i_lracls2lg_r = 13 ! rain-snow(rain change)
277  integer, parameter :: i_nracns2ng_r = 14
278  integer, parameter :: i_lraclg2lg = 15 ! rain-graupel(rain change)
279  integer, parameter :: i_nracng2ng = 16
280  integer, parameter :: i_liacli2ls = 17 ! ice-ice
281  integer, parameter :: i_niacni2ns = 18
282  integer, parameter :: i_liacls2ls = 19 ! ice-snow(ice change)
283  integer, parameter :: i_niacns2ns = 20
284  integer, parameter :: i_nsacns2ns = 21 ! snow-snow
285  integer, parameter :: i_ngacng2ng = 22 ! graupel-graupel
286  integer, parameter :: i_lgacls2lg = 23 ! snow-graupel
287  integer, parameter :: i_ngacns2ng = 24
288  integer, parameter :: i_lraclg2lr = 25
289  integer, parameter :: i_nracng2nr = 26
290  integer, parameter :: i_liaclg2lg = 27
291  integer, parameter :: i_niacng2ng = 28
292  integer, parameter :: i_cgngacns2ng = 29
293  integer, parameter :: i_cgngacni2ng = 30
294 
295  integer, parameter :: pac_max = 30
296  integer, parameter :: pcrg_max = 30
297 
298 
299  integer, private, parameter :: w_nmax = pq_max + pac_max
300  character(len=H_SHORT), private :: w_name(w_nmax)
301 
302  data w_name / 'I_LCccn', &
303  'I_NCccn', &
304  'I_LIccn', &
305  'I_NIccn', &
306  'I_LChom', &
307  'I_NChom', &
308  'I_LChet', &
309  'I_NChet', &
310  'I_LRhet', &
311  'I_NRhet', & ! 10
312  'I_LImlt', &
313  'I_NImlt', &
314  'I_LSmlt', &
315  'I_NSmlt', &
316  'I_LGmlt', &
317  'I_NGmlt', &
318  'I_LRdep', &
319  'I_NRdep', &
320  'I_LIdep', &
321  'I_NIdep', & ! 20
322  'I_LSdep', &
323  'I_NSdep', &
324  'I_LGdep', &
325  'I_NGdep', &
326  'I_LCdep', &
327  'I_LCaut', &
328  'I_NCaut', &
329  'I_NRaut', &
330  'I_LCacc', &
331  'I_NCacc', & ! 30
332  'I_NRslc', &
333  'I_NRbrk', &
334  'I_LIcon', &
335  'I_NIcon', &
336  'I_LScon', &
337  'I_NScon', &
338  'I_LIacm', &
339  'I_NIacm', &
340  'I_LIarm', &
341  'I_NIarm', & ! 40
342  'I_LSacm', &
343  'I_NSacm', &
344  'I_LSarm', &
345  'I_NSarm', &
346  'I_LGacm', &
347  'I_NGacm', &
348  'I_LGarm', &
349  'I_NGarm', &
350  'I_LGspl', &
351  'I_LSspl', & ! 50
352  'I_NIspl', &
353  'I_LIhom', &
354  'I_NIhom', &
355  'I_NGspl', &
356  'I_NSspl', & ! PQ_MAX
357  'I_LIacLC2LI', &
358  'I_NIacNC2NI', &
359  'I_LSacLC2LS', &
360  'I_NSacNC2NS', &
361  'I_LGacLC2LG', &
362  'I_NGacNC2NG', &
363  'I_LRacLI2LG_I', &
364  'I_NRacNI2NG_I', &
365  'I_LRacLI2LG_R', &
366  'I_NRacNI2NG_R', & ! 10
367  'I_LRacLS2LG_S', &
368  'I_NRacNS2NG_S', &
369  'I_LRacLS2LG_R', &
370  'I_NRacNS2NG_R', &
371  'I_LRacLG2LG', &
372  'I_NRacNG2NG', &
373  'I_LIacLI2LS', &
374  'I_NIacNI2NS', &
375  'I_LIacLS2LS', &
376  'I_NIacNS2NS', & ! 20
377  'I_NSacNS2NS', &
378  'I_NGacNG2NG', &
379  'I_LGacLS2LG', &
380  'I_NGacNS2NG', &
381  'I_LRacLG2LR', &
382  'I_NRacNG2NR', &
383  'I_LIacLG2LG', &
384  'I_NIacNG2NG', &
385  'I_CGNGacNS2NG', &
386  'I_CGNGacNI2NG' / ! 30 Pac_MAX
387 
388  real(rp), private, allocatable :: w3d(:,:,:,:)
389  integer, private :: hist_id(w_nmax), hist_idx(w_nmax)
390  integer, private :: hist_max
391 
392 
393  real(rp), private, parameter :: rhow = 1000.0_rp ! typical density for warm particles [kg/m3]
394  real(rp), private, parameter :: rhof = 100.0_rp ! typical density for frozen particles [kg/m3]
395  real(rp), private, parameter :: rhog = 400.0_rp ! typical density for grapel particles [kg/m3]
396 
397  ! for all processes
398  ! SB06, Table 1.
399  real(rp), private, parameter :: xc_min = 4.20e-15_rp ! [kg] : min mass, D_min=2um
400  real(rp), private, parameter :: xr_min = 2.60e-10_rp ! [kg] : min mass, D_min=79um
401  real(rp), private, parameter :: xi_min = 3.382e-13_rp ! [kg] : min mass, D_min=10um
402  real(rp), private, parameter :: xs_min = 1.847e-12_rp ! [kg] : min mass, D_min=20um
403  real(rp), private, parameter :: xg_min = 1.230e-10_rp ! [kg] : min mass, D_min=100um
404  ! refer to Seifert(2002) (Dr. Thesis, Table.5.1)
405  real(rp), private, parameter :: xc_max = 2.6e-10_rp ! [kg] : max, D_max=79um
406  real(rp), private, parameter :: xr_max = 5.00e-6_rp ! [kg] : max, D_max=2mm
407  real(rp), private, parameter :: xi_max = 1.377e-6_rp ! [kg] : max, D_max=5mm
408  real(rp), private, parameter :: xs_max = 7.519e-6_rp ! [kg] : max, D_max=1cm
409  real(rp), private, parameter :: xg_max = 4.900e-5_rp ! [kg] : max, D_max=1cm
410  ! filter similar to Ikawa et al.(1991) sec.3.5
411  real(rp), private, parameter :: xmin_filter= xc_min
412  ! filter of effective radius(1 micron)
413  real(rp), private, parameter :: rmin_re= 1.e-6_rp
414  !
415  ! SB06(95),(96)
416  real(rp), private, parameter :: n0r_min= 2.5e+5_rp ! [m-4]: min intercept parameter of rain
417  real(rp), private, parameter :: n0r_max= 2.0e+7_rp ! [m-4]: max
418  real(rp), private, parameter :: lambdar_min= 1.e+3_rp ! [m-1]: min slope parameter of rain
419  real(rp), private, parameter :: lambdar_max= 1.e+4_rp ! [m-1]: max
420  ! empirical value from Meyers etal.(1991), 1[/liter] = 1.d3[/m3]
421  real(rp), private, parameter :: nc_min = 1.e+4_rp ! [m-3] empirical T.Mitsui
422  real(rp), private, parameter :: nr_min = 1.0_rp ! [m-3] 1/1000 [/liter]
423  real(rp), private, parameter :: ni_min = 1.0_rp ! [m-3]
424  real(rp), private, parameter :: ns_min = 1.e-4_rp ! [m-3]
425  real(rp), private, parameter :: ng_min = 1.e-4_rp ! [m-3]
426  ! empirical filter
427  real(rp), private, parameter :: lc_min = xc_min*nc_min
428  real(rp), private, parameter :: lr_min = xr_min*nr_min
429  real(rp), private, parameter :: li_min = xi_min*ni_min
430  real(rp), private, parameter :: ls_min = xs_min*ns_min
431  real(rp), private, parameter :: lg_min = xg_min*ng_min
432  !
433  real(rp), private, parameter :: x_sep = 2.6e-10_rp ! boundary mass between cloud and rain
434  !
435  real(rp), private, parameter :: tem_min=100.0_rp
436  real(rp), private, parameter :: rho_min=1.e-5_rp ! 3.e-3 is lower limit recognized in many experiments.
437  real(rp), private, parameter :: rhoi = 916.70_rp
438  !
439  integer, private, save :: ntmax_phase_change = 1
440  integer, private, save :: ntmax_collection = 1
441  !
442  !--- standard density
443  real(rp), private, parameter :: rho_0 = 1.280_rp
444  !--- max number of Nc( activatable aerosol number concentration )
445  real(rp), allocatable, private, save :: nc_uplim_d(:,:,:)
446  !
447  !--- thermal conductivity of air
448  real(rp), private, parameter :: ka0 = 2.428e-2_rp
449 
450  real(rp), private, parameter :: dka_dt = 7.47e-5_rp
451 
452  !====== Ka = Ka0 + temc*dKa_dT
453  !
454  !--- Dynamic viscosity
455  real(rp), private, parameter :: mua0 = 1.718e-5_rp
456 
457  real(rp), private, parameter :: dmua_dt = 5.28e-8_rp
458 
459  !====== mua = mua0 + temc*dmua_dT
460  !
461  real(rp), private, save :: xc_ccn = 1.e-12_rp ! [kg]
462  real(rp), private, save :: xi_ccn = 1.e-12_rp ! [kg] ! [move] 11/08/30 T.Mitsui
463  !
464  ! capacity of diffusional growth
465  ! ( dependent of their geometries )
466  real(rp), private, save :: cap(hydro_max)
467  !
468  ! constants for Diameter-Mass relation
469  ! D = a * x^b
470  real(rp), private, save :: a_m(hydro_max), log_a_m(hydro_max)
471  real(rp), private, save :: b_m(hydro_max)
472  !$acc declare create(a_m, log_a_m, b_m)
473 
474  ! constants for Terminal velocity-Mass relation
475  ! vt = alpha * x^beta * f
476  real(rp), private, save :: alpha_v(hydro_max,2), log_alpha_v(hydro_max,2)
477  real(rp), private, save :: beta_v(hydro_max,2), log_beta_v(hydro_max,2)
478  real(rp), private, save :: alpha_vn(hydro_max,2) !
479  real(rp), private, save :: beta_vn(hydro_max,2) !
480  real(rp), private, save :: gamma_v(hydro_max)
481  !$acc declare create(beta_v, beta_vn, gamma_v)
482 
483  ! Aerodynamical factor for correction of terminal velocity.(Heymsfield and Iaquinta, 2000)
484  ! vt(tem,pre) = vt0 * (pre/pre0)**a_pre0 * (tem/tem0)**a_tem0
485  real(rp), private, parameter :: pre0_vt = 300.e+2_rp ! 300hPa
486  real(rp), private, parameter :: tem0_vt = 233.0_rp ! -40degC
487  real(rp), private, parameter :: a_pre0_vt = -0.1780_rp
488  real(rp), private, parameter :: a_tem0_vt = -0.3940_rp
489  ! Parameters to determine Droplet Size Distribution
490  ! as a General Gamma Distribution
491  ! f(x) = A x^nu exp(-lambda x^mu )
492  ! for Marshall Palmer Distribution ( popular for rain )
493  ! mu=1/3, nu=-2/3
494  ! for Gamma Distribution ( popular for cloud )
495  ! mu=1
496  real(rp), private, save :: nu(hydro_max)
497  real(rp), private, save :: mu(hydro_max)
498  !$acc declare create(nu)
499 
500  ! Mitchell(1996), JAS, vol.53, No.12, pp.1710-1723
501  ! area = a_area*D^b_area
502  ! area = ax_area*x^bx_area
503  ! Auer and Veal(1970), JAS, vol.27, pp.919-pp.926
504  ! height = a_h*x^b_h( based on h=a_ar*D^b_ar, ar:aspect ratio)
505  real(rp), private, save :: a_area(hydro_max) !
506  real(rp), private, save :: b_area(hydro_max) !
507  real(rp), private, save :: ax_area(hydro_max) !
508  real(rp), private, save :: bx_area(hydro_max) !
509  ! parameters for radius of equivalent area
510  ! r_ea = a_rea*x**b_rea
511  real(rp), private, save :: a_rea(hydro_max) !
512  real(rp), private, save :: b_rea(hydro_max) !
513  real(rp), private, save :: a_rea2(hydro_max) !
514  real(rp), private, save :: b_rea2(hydro_max) !
515  real(rp), private, save :: a_rea3(hydro_max) !
516  real(rp), private, save :: b_rea3(hydro_max) !
517  !
518  real(rp), private, save :: a_d2vt(hydro_max) !
519  real(rp), private, save :: b_d2vt(hydro_max) !
520  ! coefficient of x^2 moment of DSD
521  ! Z = integral x*x*f(x) dx
522  ! = coef_m2*N*(L/N)^2
523  real(rp), private, save :: coef_m2(hydro_max)
524  ! radar reflectivity coefficient defined by diameter
525  real(rp), private, save :: coef_d6(hydro_max) !
526  ! volume coefficient defined by diameter
527  real(rp), private, save :: coef_d3(hydro_max) !
528  ! coefficient of weighted mean diameter
529  real(rp), private, save :: coef_d(hydro_max)
530  ! coefficient of weighted mean d*d*v
531  real(rp), private, save :: coef_d2v(hydro_max) !
532  ! coefficient of moment of d*d*v
533  real(rp), private, save :: coef_md2v(hydro_max) !
534  !
535  ! for effective radius(spherical particle)
536  real(rp), private, save :: coef_r2(hydro_max)
537  real(rp), private, save :: coef_r3(hydro_max)
538  real(rp), private, save :: coef_re(hydro_max)
539  ! for effective radius(hexagonal plate)
540  real(rp), private, save :: coef_rea2(hydro_max) !
541  real(rp), private, save :: coef_rea3(hydro_max) !
542  logical, private, save :: opt_m96_ice=.true. !
543  logical, private, save :: opt_m96_column_ice=.false. !
544  !
545  ! coefficeint of weighted mean terminal velocity
546  ! vt0 is number weighted and
547  ! vt1 is mass weighted.
548  real(rp), private, save :: coef_vt0(hydro_max,2), log_coef_vt0(hydro_max,2)
549  real(rp), private, save :: coef_vt1(hydro_max,2), log_coef_vt1(hydro_max,2)
550  real(rp), private, save :: coef_deplc
551  real(rp), private, save :: coef_dave_n(hydro_max), log_coef_dave_n(hydro_max)
552  real(rp), private, save :: coef_dave_l(hydro_max), log_coef_dave_l(hydro_max)
553  !$acc declare create(log_coef_vt0, log_coef_vt1)
554  !$acc declare create(log_coef_dave_N, log_coef_dave_L)
555 
556  ! diameter of terminal velocity branch
557  !
558  real(rp), private, save :: d0_ni=261.76e-6_rp, log_d0_ni
559  real(rp), private, save :: d0_li=398.54e-6_rp, log_d0_li
560  real(rp), private, parameter :: d0_ns=270.03e-6_rp, log_d0_ns = log(d0_ns)
561  real(rp), private, parameter :: d0_ls=397.47e-6_rp, log_d0_ls = log(d0_ls)
562  real(rp), private, parameter :: d0_ng=269.08e-6_rp, log_d0_ng = log(d0_ng)
563  real(rp), private, parameter :: d0_lg=376.36e-6_rp, log_d0_lg = log(d0_lg)
564  !$acc declare create(log_d0_ni, log_d0_li)
565 
566  !
567  real(rp), private, parameter :: coef_vtr_ar1=9.65_rp ! coef. for large branch
568  ! original parameter of Rogers etal.(1993)
569  real(rp), private, parameter :: coef_vtr_br1=10.43_rp ! ...
570  real(rp), private, parameter :: coef_vtr_cr1=600.0_rp ! ...
571  real(rp), private, parameter :: coef_vtr_ar2=4.e+3_rp ! coef. for small branch
572  real(rp), private, parameter :: coef_vtr_br2=12.e+3_rp ! ...
573  real(rp), private, parameter :: d_vtr_branch=0.745e-3_rp ! 0.745 mm (diameter dividing 2-branches)
574  ! equilibrium diameter of rain break-up
575  real(rp), private, parameter :: dr_eq = 1.10e-3_rp ! eqilibrium diameter, Seifert 2008(36)
576  ! coefficient of General Gamma.
577  ! f(x) = A x^nu exp(-lambda x^mu )
578  ! lambda = coef_lambda * (L/N)^{-mu}
579  ! A = coef_A*N*lambda^slope_A
580  real(rp), private, save :: coef_a(hydro_max)
581  real(rp), private, save :: coef_lambda(hydro_max)
582 ! real(RP), private, save :: slope_A(HYDRO_MAX)
583  ! coefficeint of weighted ventilation effect.
584  ! large, and small branch is by PK97(13-60),(13-61),(13-88),(13-89)
585  real(rp), private, save :: ah_vent (hydro_max,2) !
586  real(rp), private, save :: bh_vent (hydro_max,2) !
587  real(rp), private, save :: ah_vent0 (hydro_max,2) !
588  real(rp), private, save :: bh_vent0 (hydro_max,2) !
589  real(rp), private, save :: ah_vent1 (hydro_max,2) !
590  real(rp), private, save :: bh_vent1 (hydro_max,2) !
591  ! coefficient of collision growth
592  real(rp), private, save :: delta_b0 (hydro_max)
593  real(rp), private, save :: delta_b1 (hydro_max)
594  real(rp), private, save :: delta_ab0(hydro_max,hydro_max)
595  real(rp), private, save :: delta_ab1(hydro_max,hydro_max)
596  !
597  real(rp), private, save :: theta_b0 (hydro_max)
598  real(rp), private, save :: theta_b1 (hydro_max)
599  real(rp), private, save :: theta_ab0(hydro_max,hydro_max)
600  real(rp), private, save :: theta_ab1(hydro_max,hydro_max)
601  !
602  logical, private, save :: opt_debug=.false.
603  !
604  logical, private, save :: opt_debug_inc=.true.
605  logical, private, save :: opt_debug_act=.true.
606  logical, private, save :: opt_debug_ree=.true.
607  logical, private, save :: opt_debug_bcs=.true.
608 
609  logical, save, private :: opt_collection_bin = .false. ! SO22
610 
611  logical, private, save :: mp_doautoconversion = .true.
612  logical, private, save :: mp_couple_aerosol = .false. ! apply CCN effect?
613  real(rp), private, save :: mp_ssw_lim = 1.e+1_rp
614 
615  !
616  ! namelist variables for nucleation
617  !
618  ! total aerosol number concentration [/m3]
619  real(rp), private, parameter :: c_ccn_ocean= 1.00e+8_rp
620  real(rp), private, parameter :: c_ccn_land = 1.26e+9_rp
621  real(rp), private, save :: c_ccn = 1.00e+8_rp
622  ! aerosol activation factor
623  real(rp), private, parameter :: kappa_ocean= 0.462_rp
624  real(rp), private, parameter :: kappa_land = 0.308_rp
625  real(rp), private, save :: kappa = 0.462_rp
626  real(rp), private, save :: c_in = 1.0_rp
627  ! SB06 (36)
628  real(rp), private, save :: nm_m92 = 1.e+3_rp
629  real(rp), private, save :: am_m92 = -0.639_rp
630  real(rp), private, save :: bm_m92 = 12.96_rp
631  !
632  real(rp), private, save :: in_max = 1000.e+3_rp ! max num. of Ice-Nuclei [num/m3]
633  real(rp), private, save :: ssi_max= 0.60_rp
634  real(rp), private, save :: ssw_max= 1.1_rp ! [%]
635  !
636  real(rp), private, save :: qke_min = 0.03_rp ! sigma=0.1[m/s], 09/08/18 T.Mitsui
637  real(rp), private, save :: tem_ccn_low=233.150_rp ! = -40 degC ! [Add] 10/08/03 T.Mitsui
638  real(rp), private, save :: tem_in_low =173.150_rp ! = -100 degC ! [Add] 10/08/03 T.Mitsui
639  logical, private, save :: nucl_twomey = .false.
640  logical, private, save :: inucl_w = .false.
641  logical, private, save :: so22_het = .false. ! SO22
642  logical, private, save :: opt_nucleation_ice_hom = .false. ! SO22
643 
644  ! for incomplete gamma function
645  real(rp), private, parameter :: rc_cr= 12.e-6_rp ! critical size[micron]
646  real(rp), private, save :: xc_cr ! mass[kg] of cloud with r=critical size[micron]
647  real(rp), private, save :: alpha ! slope parameter of gamma function
648  real(rp), private, save :: gm, lgm ! gamma(alpha), log(gamma(alpha))
649 
650 
651  !=== for collection
652  !--- threshold of diameters to collide with others
653  real(rp), private, save :: dc0 = 15.0e-6_rp ! lower threshold of cloud
654  real(rp), private, save :: dc1 = 40.0e-6_rp ! upper threshold of cloud
655  real(rp), private, save :: di0 = 150.0e-6_rp ! lower threshold of cloud
656  real(rp), private, save :: ds0 = 150.0e-6_rp ! lower threshold of cloud
657  real(rp), private, save :: dg0 = 150.0e-6_rp ! lower threshold of cloud
658  !--- standard deviation of terminal velocity[m/s]
659  real(rp), private, save :: sigma_c=0.00_rp ! cloud
660  real(rp), private, save :: sigma_r=0.00_rp ! rain
661  real(rp), private, save :: sigma_i=0.2_rp ! ice
662  real(rp), private, save :: sigma_s=0.2_rp ! snow
663  real(rp), private, save :: sigma_g=0.00_rp ! graupel
664  !--- max collection efficiency for cloud
665  real(rp), private, save :: e_im = 0.80_rp ! ice max
666  real(rp), private, save :: e_sm = 0.80_rp ! snow max
667  real(rp), private, save :: e_gm = 1.00_rp ! graupel max
668  !--- collection efficiency between 2 species
669  real(rp), private, save :: e_ir=1.0_rp ! ice x rain
670  real(rp), private, save :: e_sr=1.0_rp ! snow x rain
671  real(rp), private, save :: e_gr=1.0_rp ! graupel x rain
672  real(rp), private, save :: e_ii=1.0_rp ! ice x ice
673  real(rp), private, save :: e_si=1.0_rp ! snow x ice
674  real(rp), private, save :: e_gi=1.0_rp ! graupel x ice
675  real(rp), private, save :: e_ss=1.0_rp ! snow x snow
676  real(rp), private, save :: e_gs=1.0_rp ! graupel x snow
677  real(rp), private, save :: e_gg=1.0_rp ! graupel x graupel
678  !=== for partial conversion
679  !--- flag: 1=> partial conversion to graupel, 0=> no conversion
680  integer, private, save :: i_iconv2g=1 ! ice => graupel
681  integer, private, save :: i_sconv2g=1 ! snow => graupel
682  !--- bulk density of graupel
683  real(rp), private, save :: rho_g = 900.0_rp ! [kg/m3]
684  !--- space filling coefficient [%]
685  real(rp), private, save :: cfill_i = 0.68_rp ! ice
686  real(rp), private, save :: cfill_s = 0.01_rp ! snow
687  !--- critical diameter for ice conversion
688  real(rp), private, save :: di_cri = 500.e-6_rp ! [m]
689  logical, private, save :: opt_stick_ks96=.false.
690  logical, private, save :: opt_stick_co86=.false.
691  ! from Seiki and Ohno (2022)
692  logical, private, save :: opt_stick_rhh57=.false.
693  logical, private, save :: opt_stick_rhks96=.false.
694  real(rp), private, save :: tem_min_estick=253.0_rp
695  logical, private, save :: opt_stick_c12=.false.
696 
697  real(rp), private, save :: fac_cndc = 1.0_rp
698  logical, private, save :: opt_fix_taucnd_c=.false.
699 
700  ! limitter for vapor diffusivity
701  ! this value was suggested in Pruppacher and Klett(1997),(13-3)
702  ! although Hall and Pruppacher (1976) extrapolated upto -80 deg
703  real(rp), private, save :: temc_lim_diff = -80.0_rp ! HP76
704  ! -40.0_RP ! PK97
705 
706 
707 
708  !-----------------------------------------------------------------------------
709 contains
710  !-----------------------------------------------------------------------------
714  subroutine atmos_phy_mp_sn14_setup( &
715  KA, IA, JA )
716  use scale_prc, only: &
717  prc_abort
718  use scale_file_history, only: &
720  implicit none
721  integer, intent(in) :: ka
722  integer, intent(in) :: ia
723  integer, intent(in) :: ja
724 
725  namelist / param_atmos_phy_mp_sn14 / &
726  mp_doautoconversion, &
727  mp_ssw_lim, &
728  mp_couple_aerosol
729 
730  integer :: ip
731  integer :: ierr
732  !---------------------------------------------------------------------------
733 
734  log_newline
735  log_info("ATMOS_PHY_MP_sn14_setup",*) 'Setup'
736  log_info("ATMOS_PHY_MP_sn14_setup",*) 'Seiki and Nakajima (2014) 2-moment bulk 6 category'
737 
738  !--- read namelist
739  rewind(io_fid_conf)
740  read(io_fid_conf,nml=param_atmos_phy_mp_sn14,iostat=ierr)
741  if( ierr < 0 ) then !--- missing
742  log_info("ATMOS_PHY_MP_sn14_setup",*) 'Not found namelist. Default used.'
743  elseif( ierr > 0 ) then !--- fatal error
744  log_error("ATMOS_PHY_MP_sn14_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14. Check!'
745  call prc_abort
746  endif
747  log_nml(param_atmos_phy_mp_sn14)
748 
749  call mp_sn14_init
750 
751  allocate(nc_uplim_d(1,ia,ja))
752  nc_uplim_d(:,:,:) = 150.e6_rp
753 
754  hist_max = 0
755  hist_idx(:) = -1
756  do ip = 1, w_nmax
757  call file_history_reg( w_name(ip), 'individual tendency term in SN14', 'kg/kg/s', &
758  hist_id(ip) )
759  if ( hist_id(ip) > 0 ) then
760  hist_max = hist_max + 1
761  hist_idx(ip) = hist_max
762  end if
763  enddo
764  allocate( w3d(ka,ia,ja,hist_max) )
765  w3d(:,:,:,:) = 0.0_rp
766 
767  return
768  end subroutine atmos_phy_mp_sn14_setup
769 
770  !-----------------------------------------------------------------------------
772  subroutine atmos_phy_mp_sn14_finalize
773 
774  deallocate(nc_uplim_d)
775 
776  return
777  end subroutine atmos_phy_mp_sn14_finalize
778 
779  !-----------------------------------------------------------------------------
783  subroutine atmos_phy_mp_sn14_tendency( &
784  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
785  DENS, &
786  W, &
787  QTRC, &
788  PRES, &
789  TEMP, &
790  Qdry, &
791  CPtot, &
792  CVtot, &
793  CCN, &
794  dt, &
795  cz, &
796  fz, &
797  RHOQ_t, &
798  RHOE_t, &
799  CPtot_t, &
800  CVtot_t, &
801  EVAPORATE, &
802  flg_lt, &
803  d0_crg, v0_crg, &
804  dqcrg, &
805  beta_crg, &
806  QTRC_crg, &
807  QSPLT_in, Sarea, &
808  RHOQcrg_t )
809  implicit none
810 
811  integer, intent(in) :: ka, ks, ke
812  integer, intent(in) :: ia, is, ie
813  integer, intent(in) :: ja, js, je
814 
815  real(rp), intent(in) :: dens (ka,ia,ja)
816  real(rp), intent(in) :: w (ka,ia,ja)
817  real(rp), intent(in) :: qtrc (ka,ia,ja,qa_mp)
818  real(rp), intent(in) :: pres(ka,ia,ja)
819  real(rp), intent(in) :: temp(ka,ia,ja)
820  real(rp), intent(in) :: qdry(ka,ia,ja)
821  real(rp), intent(in) :: cptot(ka,ia,ja)
822  real(rp), intent(in) :: cvtot(ka,ia,ja)
823  real(rp), intent(in) :: ccn (ka,ia,ja)
824  real(dp), intent(in) :: dt
825  real(rp), intent(in) :: cz( ka,ia,ja)
826  real(rp), intent(in) :: fz(0:ka,ia,ja)
827 
828  real(rp), intent(out) :: rhoq_t (ka,ia,ja,qa_mp)
829  real(rp), intent(out) :: rhoe_t (ka,ia,ja)
830  real(rp), intent(out) :: cptot_t(ka,ia,ja)
831  real(rp), intent(out) :: cvtot_t(ka,ia,ja)
832  real(rp), intent(out) :: evaporate(ka,ia,ja) !--- number of evaporated cloud [/m3]
833 
834  ! Optional for Lightning
835  logical, intent(in), optional :: flg_lt
836  real(rp), intent(in), optional :: d0_crg, v0_crg
837  real(rp), intent(in), optional :: dqcrg(ka,ia,ja)
838  real(rp), intent(in), optional :: beta_crg(ka,ia,ja)
839  real(rp), intent(in), optional :: qtrc_crg(ka,ia,ja,hydro_max)
840  real(rp), intent(out), optional :: qsplt_in(ka,ia,ja,3)
841  real(rp), intent(out), optional :: sarea(ka,ia,ja,hydro_max)
842  real(rp), intent(out), optional :: rhoqcrg_t(ka,ia,ja,hydro_max)
843  !---------------------------------------------------------------------------
844 
845  log_progress(*) 'atmosphere / physics / microphysics / SN14'
846 
847 #ifdef PROFILE_FIPP
848  call fipp_start()
849 #endif
850 
851  !##### MP Main #####
852  call mp_sn14 ( &
853  ka, ks, ke, ia, is, ie, ja, js, je, &
854  dens(:,:,:), w(:,:,:), qtrc(:,:,:,:), pres(:,:,:), temp(:,:,:), & ! (in)
855  qdry(:,:,:), cptot(:,:,:), cvtot(:,:,:), ccn(:,:,:), & ! (in)
856  real(dt,rp), cz(:,:,:), fz(:,:,:), & ! (in)
857  rhoq_t(:,:,:,:), rhoe_t(:,:,:), cptot_t(:,:,:), cvtot_t(:,:,:), & ! (out)
858  evaporate(:,:,:), & ! (out)
859  flg_lt, d0_crg, v0_crg, dqcrg(:,:,:), beta_crg(:,:,:), & ! (optional in)
860  qtrc_crg(:,:,:,:), & ! (optional in)
861  qsplt_in(:,:,:,:), sarea(:,:,:,:), rhoqcrg_t(:,:,:,:) ) ! (optional out)
862 
863 #ifdef PROFILE_FIPP
864  call fipp_stop()
865 #endif
866 
867  return
868  end subroutine atmos_phy_mp_sn14_tendency
869 
870  !-----------------------------------------------------------------------------
875  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
876  QTRC, &
877  mask_criterion, &
878  cldfrac )
879  implicit none
880  integer, intent(in) :: ka, ks, ke
881  integer, intent(in) :: ia, is, ie
882  integer, intent(in) :: ja, js, je
883 
884  real(rp), intent(in) :: qtrc (ka,ia,ja,qa_mp-1)
885  real(rp), intent(in) :: mask_criterion
886 
887  real(rp), intent(out) :: cldfrac(ka,ia,ja)
888 
889  real(rp) :: qhydro
890  integer :: k, i, j, iq
891  !---------------------------------------------------------------------------
892 
893  !$omp parallel do &
894  !$omp private(qhydro)
895  do j = js, je
896  do i = is, ie
897  do k = ks, ke
898  qhydro = 0.0_rp
899  do iq = i_mp_qc, i_mp_qg
900  qhydro = qhydro + qtrc(k,i,j,iq)
901  enddo
902  cldfrac(k,i,j) = 0.5_rp + sign(0.5_rp,qhydro-mask_criterion)
903  enddo
904  enddo
905  enddo
906 
907  return
908  end subroutine atmos_phy_mp_sn14_cloud_fraction
909  !-----------------------------------------------------------------------------
914  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
915  DENS0, TEMP0, QTRC0, &
916  Re )
918  n_hyd, &
919  i_hc, &
920  i_hr, &
921  i_hi, &
922  i_hs, &
923  i_hg, &
924  i_hh
925  implicit none
926  integer, intent(in) :: ka, ks, ke
927  integer, intent(in) :: ia, is, ie
928  integer, intent(in) :: ja, js, je
929 
930  real(rp), intent(in) :: dens0(ka,ia,ja) ! density [kg/m3]
931  real(rp), intent(in) :: temp0(ka,ia,ja) ! temperature [K]
932  real(rp), intent(in) :: qtrc0(ka,ia,ja,i_qc:i_ng) ! tracer mass concentration [kg/kg]
933 
934  real(rp), intent(out) :: re (ka,ia,ja,n_hyd) ! effective radius [cm]
935 
936  ! mass concentration[kg/m3] and mean particle mass[kg]
937  real(rp) :: xc(ka)
938  real(rp) :: xr(ka)
939  real(rp) :: xi(ka)
940  real(rp) :: xs(ka)
941  real(rp) :: xg(ka)
942  ! diameter of average mass[kg/m3]
943  real(rp) :: dc_ave(ka)
944  real(rp) :: dr_ave(ka)
945  ! radius of average mass
946  real(rp) :: rc, rr
947  ! 2nd. and 3rd. order moment of DSD
948  real(rp) :: ri2m(ka), ri3m(ka)
949  real(rp) :: rs2m(ka), rs3m(ka)
950  real(rp) :: rg2m(ka), rg3m(ka)
951 
952  real(rp), parameter :: coef_fuetal1998 = 3.0_rp / (4.0_rp*rhoi)
953 
954  ! r2m_min is minimum value(moment of 1 particle with 1 micron)
955  real(rp), parameter :: r2m_min=1.e-12_rp
956  real(rp), parameter :: um2cm = 100.0_rp
957 
958  real(rp) :: limitsw, zerosw
959  integer :: k, i, j
960  !---------------------------------------------------------------------------
961 
962  !$omp parallel do &
963  !$omp private(xc,xr,xi,xs,xg,dc_ave,dr_ave,rc,rr,ri2m,ri3m,rs2m,rs3m,rg2m,rg3m, &
964  !$omp limitsw,zerosw)
965  do j = js, je
966  do i = is, ie
967 
968  ! mean particle mass[kg]
969  do k = ks, ke
970  xc(k) = min( xc_max, max( xc_min, dens0(k,i,j)*qtrc0(k,i,j,i_qc)/(qtrc0(k,i,j,i_nc)+nc_min) ) )
971  xr(k) = min( xr_max, max( xr_min, dens0(k,i,j)*qtrc0(k,i,j,i_qr)/(qtrc0(k,i,j,i_nr)+nr_min) ) )
972  xi(k) = min( xi_max, max( xi_min, dens0(k,i,j)*qtrc0(k,i,j,i_qi)/(qtrc0(k,i,j,i_ni)+ni_min) ) )
973  xs(k) = min( xs_max, max( xs_min, dens0(k,i,j)*qtrc0(k,i,j,i_qs)/(qtrc0(k,i,j,i_ns)+ns_min) ) )
974  xg(k) = min( xg_max, max( xg_min, dens0(k,i,j)*qtrc0(k,i,j,i_qg)/(qtrc0(k,i,j,i_ng)+ng_min) ) )
975  enddo
976 
977  ! diameter of average mass : SB06 eq.(32)
978  do k = ks, ke
979  dc_ave(k) = a_m(i_mp_qc) * xc(k)**b_m(i_mp_qc)
980  dr_ave(k) = a_m(i_mp_qr) * xr(k)**b_m(i_mp_qr)
981  enddo
982 
983  ! cloud effective radius
984  do k = ks, ke
985  rc = 0.5_rp * dc_ave(k)
986  limitsw = 0.5_rp + sign(0.5_rp, rc-rmin_re )
987  re(k,i,j,i_hc) = coef_re(i_mp_qc) * rc * limitsw * um2cm
988  enddo
989 
990  ! rain effective radius
991  do k = ks, ke
992  rr = 0.5_rp * dr_ave(k)
993  limitsw = 0.5_rp + sign(0.5_rp, rr-rmin_re )
994  re(k,i,j,i_hr) = coef_re(i_mp_qr) * rr * limitsw * um2cm
995  enddo
996 
997  do k = ks, ke
998  ri2m(k) = pi * coef_rea2(i_mp_qi) * qtrc0(k,i,j,i_ni) * a_rea2(i_mp_qi) * xi(k)**b_rea2(i_mp_qi)
999  rs2m(k) = pi * coef_rea2(i_mp_qs) * qtrc0(k,i,j,i_ns) * a_rea2(i_mp_qs) * xs(k)**b_rea2(i_mp_qs)
1000  rg2m(k) = pi * coef_rea2(i_mp_qg) * qtrc0(k,i,j,i_ng) * a_rea2(i_mp_qg) * xg(k)**b_rea2(i_mp_qg)
1001  enddo
1002 
1003  ! Fu(1996), eq.(3.11) or Fu et al.(1998), eq.(2.5)
1004  do k = ks, ke
1005  ri3m(k) = coef_fuetal1998 * qtrc0(k,i,j,i_ni) * xi(k)
1006  rs3m(k) = coef_fuetal1998 * qtrc0(k,i,j,i_ns) * xs(k)
1007  rg3m(k) = coef_fuetal1998 * qtrc0(k,i,j,i_ng) * xg(k)
1008  enddo
1009 
1010  ! ice effective radius
1011  do k = ks, ke
1012  zerosw = 0.5_rp - sign(0.5_rp, ri2m(k) - r2m_min )
1013  re(k,i,j,i_hi) = ri3m(k) / ( ri2m(k) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
1014  enddo
1015 
1016  ! snow effective radius
1017  do k = ks, ke
1018  zerosw = 0.5_rp - sign(0.5_rp, rs2m(k) - r2m_min )
1019  re(k,i,j,i_hs) = rs3m(k) / ( rs2m(k) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
1020  enddo
1021 
1022  ! graupel effective radius
1023  do k = ks, ke
1024  zerosw = 0.5_rp - sign(0.5_rp, rg2m(k) - r2m_min )
1025  re(k,i,j,i_hg) = rg3m(k) / ( rg2m(k) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
1026  enddo
1027 
1028  do k = ks, ke
1029  re(k,i,j,i_hh) = 0.0_rp
1030  end do
1031 
1032  enddo
1033  enddo
1034 
1035 
1036  return
1037  end subroutine atmos_phy_mp_sn14_effective_radius
1038  !-----------------------------------------------------------------------------
1042  subroutine atmos_phy_mp_sn14_qtrc2qhyd( &
1043  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
1044  QTRC0, &
1045  Qe )
1047  n_hyd, &
1048  i_hc, &
1049  i_hr, &
1050  i_hi, &
1051  i_hs, &
1052  i_hg, &
1053  i_hh
1054  implicit none
1055  integer, intent(in) :: ka, ks, ke
1056  integer, intent(in) :: ia, is, ie
1057  integer, intent(in) :: ja, js, je
1058 
1059  real(rp), intent(in) :: qtrc0(ka,ia,ja,qa_mp-1) ! tracer mass concentration [kg/kg]
1060 
1061  real(rp), intent(out) :: qe (ka,ia,ja,n_hyd) ! mixing ratio of each cateory [kg/kg]
1062 
1063  integer :: k, i, j
1064  !---------------------------------------------------------------------------
1065 
1066 !OCL XFILL
1067  !$omp parallel do
1068  do j = js, je
1069  do i = is, ie
1070  do k = ks, ke
1071  qe(k,i,j,i_hc) = qtrc0(k,i,j,i_mp_qc)
1072  qe(k,i,j,i_hr) = qtrc0(k,i,j,i_mp_qr)
1073  qe(k,i,j,i_hi) = qtrc0(k,i,j,i_mp_qi)
1074  qe(k,i,j,i_hs) = qtrc0(k,i,j,i_mp_qs)
1075  qe(k,i,j,i_hg) = qtrc0(k,i,j,i_mp_qg)
1076  qe(k,i,j,i_hh) = 0.0_rp
1077  end do
1078  end do
1079  end do
1080 
1081  return
1082  end subroutine atmos_phy_mp_sn14_qtrc2qhyd
1083 
1085  subroutine atmos_phy_mp_sn14_qtrc2nhyd( &
1086  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
1087  QTRC0, &
1088  Ne )
1090  n_hyd, &
1091  i_hc, &
1092  i_hr, &
1093  i_hi, &
1094  i_hs, &
1095  i_hg, &
1096  i_hh
1097  implicit none
1098  integer, intent(in) :: ka, ks, ke
1099  integer, intent(in) :: ia, is, ie
1100  integer, intent(in) :: ja, js, je
1101 
1102  real(rp), intent(in) :: qtrc0(ka,ia,ja,qa_mp-1) ! tracer mass concentration [kg/kg]
1103 
1104  real(rp), intent(out) :: ne (ka,ia,ja,n_hyd) ! number density of each cateory [1/m3]
1105 
1106  integer :: k, i, j
1107  !---------------------------------------------------------------------------
1108 
1109 !OCL XFILL
1110  !$omp parallel do
1111  do j = js, je
1112  do i = is, ie
1113  do k = ks, ke
1114  ne(k,i,j,i_hc) = qtrc0(k,i,j,i_mp_nc)
1115  ne(k,i,j,i_hr) = qtrc0(k,i,j,i_mp_nr)
1116  ne(k,i,j,i_hi) = qtrc0(k,i,j,i_mp_ni)
1117  ne(k,i,j,i_hs) = qtrc0(k,i,j,i_mp_ns)
1118  ne(k,i,j,i_hg) = qtrc0(k,i,j,i_mp_ng)
1119  ne(k,i,j,i_hh) = 0.0_rp
1120  end do
1121  end do
1122  end do
1123 
1124  return
1125  end subroutine atmos_phy_mp_sn14_qtrc2nhyd
1126 
1127  subroutine atmos_phy_mp_sn14_qhyd2qtrc( &
1128  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
1129  Qe, &
1130  QTRC, &
1131  QNUM )
1132  use scale_const, only: &
1133  pi => const_pi, &
1134  undef => const_undef
1135  use scale_atmos_hydrometeor, only: &
1136  n_hyd, &
1137  i_hc, &
1138  i_hr, &
1139  i_hi, &
1140  i_hs, &
1141  i_hg, &
1142  i_hh
1143  implicit none
1144  integer, intent(in) :: ka, ks, ke
1145  integer, intent(in) :: ia, is, ie
1146  integer, intent(in) :: ja, js, je
1147 
1148  real(rp), intent(in) :: qe(ka,ia,ja,n_hyd) ! mass ratio of each cateory [kg/kg]
1149 
1150  real(rp), intent(out) :: qtrc(ka,ia,ja,qa_mp-1) ! tracer mass concentration [kg/kg]
1151 
1152  real(rp), intent(in), optional :: qnum(ka,ia,ja,n_hyd)
1153 
1154  real(rp), parameter :: dc = 20.e-6_rp ! typical particle diameter for cloud [m]
1155  real(rp), parameter :: dr = 200.e-6_rp ! typical particle diameter for rain [m]
1156  real(rp), parameter :: di = 80.e-6_rp ! typical particle diameter for ice [m]
1157  real(rp), parameter :: ds = 80.e-6_rp ! typical particle diameter for snow [m]
1158  real(rp), parameter :: dg = 200.e-6_rp ! typical particle diameter for grapel [m]
1159  real(rp), parameter :: b = 3.0_rp ! assume spherical form
1160 
1161  real(rp) :: piov6
1162 
1163  integer :: k, i, j
1164  !---------------------------------------------------------------------------
1165 
1166 
1167 !OCL XFILL
1168  !$omp parallel do
1169  do j = js, je
1170  do i = is, ie
1171  do k = ks, ke
1172  qtrc(k,i,j,i_mp_qc) = qe(k,i,j,i_hc)
1173  end do
1174  end do
1175  end do
1176 
1177 !OCL XFILL
1178  !$omp parallel do
1179  do j = js, je
1180  do i = is, ie
1181  do k = ks, ke
1182  qtrc(k,i,j,i_mp_qr) = qe(k,i,j,i_hr)
1183  end do
1184  end do
1185  end do
1186 
1187 !OCL XFILL
1188  !$omp parallel do
1189  do j = js, je
1190  do i = is, ie
1191  do k = ks, ke
1192  qtrc(k,i,j,i_mp_qi) = qe(k,i,j,i_hi)
1193  end do
1194  end do
1195  end do
1196 
1197 !OCL XFILL
1198  !$omp parallel do
1199  do j = js, je
1200  do i = is, ie
1201  do k = ks, ke
1202  qtrc(k,i,j,i_mp_qs) = qe(k,i,j,i_hs)
1203  end do
1204  end do
1205  end do
1206 
1207 !OCL XFILL
1208  !$omp parallel do
1209  do j = js, je
1210  do i = is, ie
1211  do k = ks, ke
1212  qtrc(k,i,j,i_mp_qg) = qe(k,i,j,i_hg) + qe(k,i,j,i_hh)
1213  end do
1214  end do
1215  end do
1216 
1217  piov6 = pi / 6.0_rp
1218 
1219  if ( present(qnum) ) then
1220 
1221 !OCL XFILL
1222  !$omp parallel do
1223  do j = js, je
1224  do i = is, ie
1225  do k = ks, ke
1226  if ( qnum(k,i,j,i_hc) .ne. undef ) then
1227  qtrc(k,i,j,i_mp_nc) = qnum(k,i,j,i_hc)
1228  else
1229  qtrc(k,i,j,i_mp_nc) = qtrc(k,i,j,i_mp_qc) / ( (piov6*rhow) * dc**b )
1230  end if
1231  end do
1232  end do
1233  end do
1234 
1235 !OCL XFILL
1236  !$omp parallel do
1237  do j = js, je
1238  do i = is, ie
1239  do k = ks, ke
1240  if ( qnum(k,i,j,i_hr) .ne. undef ) then
1241  qtrc(k,i,j,i_mp_nr) = qnum(k,i,j,i_hr)
1242  else
1243  qtrc(k,i,j,i_mp_nr) = qtrc(k,i,j,i_mp_qr) / ( (piov6*rhow) * dr**b )
1244  end if
1245  end do
1246  end do
1247  end do
1248 
1249 !OCL XFILL
1250  !$omp parallel do
1251  do j = js, je
1252  do i = is, ie
1253  do k = ks, ke
1254  if ( qnum(k,i,j,i_hi) .ne. undef ) then
1255  qtrc(k,i,j,i_mp_ni) = qnum(k,i,j,i_hi)
1256  else
1257  qtrc(k,i,j,i_mp_ni) = qtrc(k,i,j,i_mp_qi) / ( (piov6*rhof) * di**b )
1258  end if
1259  end do
1260  end do
1261  end do
1262 
1263 !OCL XFILL
1264  !$omp parallel do
1265  do j = js, je
1266  do i = is, ie
1267  do k = ks, ke
1268  if ( qnum(k,i,j,i_hs) .ne. undef ) then
1269  qtrc(k,i,j,i_mp_ns) = qnum(k,i,j,i_hs)
1270  else
1271  qtrc(k,i,j,i_mp_ns) = qtrc(k,i,j,i_mp_qs) / ( (piov6*rhof) * ds**b )
1272  end if
1273  end do
1274  end do
1275  end do
1276 
1277 !OCL XFILL
1278  !$omp parallel do
1279  do j = js, je
1280  do i = is, ie
1281  do k = ks, ke
1282  if ( qnum(k,i,j,i_hg) .ne. undef ) then
1283  if ( qnum(k,i,j,i_hh) .ne. undef ) then
1284  qtrc(k,i,j,i_mp_ng) = qnum(k,i,j,i_hg) + qnum(k,i,j,i_hh)
1285  else
1286  qtrc(k,i,j,i_mp_ng) = qnum(k,i,j,i_hg)
1287  end if
1288  else
1289  qtrc(k,i,j,i_mp_ng) = qtrc(k,i,j,i_mp_qg) / ( (piov6*rhog) * dg**b )
1290  end if
1291  end do
1292  end do
1293  end do
1294 
1295  else
1296 
1297 !OCL XFILL
1298  !$omp parallel do
1299  do j = js, je
1300  do i = is, ie
1301  do k = ks, ke
1302  qtrc(k,i,j,i_mp_nc) = qtrc(k,i,j,i_mp_qc) / ( (piov6*rhow) * dc**b )
1303  end do
1304  end do
1305  end do
1306 
1307 !OCL XFILL
1308  !$omp parallel do
1309  do j = js, je
1310  do i = is, ie
1311  do k = ks, ke
1312  qtrc(k,i,j,i_mp_nr) = qtrc(k,i,j,i_mp_qr) / ( (piov6*rhow) * dr**b )
1313  end do
1314  end do
1315  end do
1316 
1317 !OCL XFILL
1318  !$omp parallel do
1319  do j = js, je
1320  do i = is, ie
1321  do k = ks, ke
1322  qtrc(k,i,j,i_mp_ni) = qtrc(k,i,j,i_mp_qi) / ( (piov6*rhof) * di**b )
1323  end do
1324  end do
1325  end do
1326 
1327 !OCL XFILL
1328  !$omp parallel do
1329  do j = js, je
1330  do i = is, ie
1331  do k = ks, ke
1332  qtrc(k,i,j,i_mp_ns) = qtrc(k,i,j,i_mp_qs) / ( (piov6*rhof) * ds**b )
1333  end do
1334  end do
1335  end do
1336 
1337 !OCL XFILL
1338  !$omp parallel do
1339  do j = js, je
1340  do i = is, ie
1341  do k = ks, ke
1342  qtrc(k,i,j,i_mp_ng) = qtrc(k,i,j,i_mp_qg) / ( (piov6*rhog) * dg**b )
1343  end do
1344  end do
1345  end do
1346 
1347  end if
1348 
1349  return
1350  end subroutine atmos_phy_mp_sn14_qhyd2qtrc
1351 
1352  !-----------------------------------------------------------------------------
1356 !OCL SERIAL
1358  KA, KS, KE, &
1359  DENS, &
1360  TEMP, &
1361  RHOQ, &
1362  PRES, &
1363  vterm )
1364  !$acc routine vector
1365  use scale_const, only: &
1366  const_undef
1367  implicit none
1368 
1369  integer, intent(in) :: ka, ks, ke
1370 
1371  real(rp), intent(in) :: rhoq(ka,i_qc:i_ng) ! rho * q
1372  real(rp), intent(in) :: dens(ka) ! rho
1373  real(rp), intent(in) :: temp(ka) ! temperature
1374  real(rp), intent(in) :: pres(ka) ! pressure
1375 
1376  real(rp), intent(out) :: vterm(ka,qa_mp-1) ! terminal velocity of cloud mass
1377 
1378  real(rp) :: xq, log_xq ! average mass of 1 particle( mass/number )
1379 
1380  real(rp) :: rhofac ! density factor for terminal velocity
1381  real(rp) :: rhofac_q(ka), log_rhofac_q
1382 
1383  real(rp) :: rlambdar(ka) ! work for diagnosis of Rain DSD ( Seifert, 2008 )
1384  real(rp) :: mud_r
1385  real(rp) :: dq, log_dq ! weigthed diameter. Improved Rogers etal. (1993) formula by T.Mitsui
1386 
1387  real(rp) :: weight ! weighting coefficient for 2-branches is determined by ratio between 0.745mm and weighted diameter. SB06 Table.1
1388  real(rp) :: velq_s ! terminal velocity for small branch of Rogers formula
1389  real(rp) :: velq_l ! terminal velocity for large branch of Rogers formula
1390 
1391  real(rp) :: tmp
1392  integer :: k, i, j, iq
1393  !---------------------------------------------------------------------------
1394 
1395  ! QC, NC
1396  do k = ks, ke
1397  rhofac = rho_0 / max( dens(k), rho_min )
1398 
1399  log_rhofac_q = log(rhofac) * gamma_v(i_mp_qc)
1400  log_xq = log( max( xc_min, min( xc_max, rhoq(k,i_qc) / ( rhoq(k,i_nc) + nc_min ) ) ) )
1401 
1402  vterm(k,i_mp_qc) = - exp( log_rhofac_q + log_coef_vt1(i_mp_qc,1) + log_xq * beta_v(i_mp_qc,1) )
1403 
1404  vterm(k,i_mp_nc) = - exp( log_rhofac_q + log_coef_vt0(i_mp_qc,1) + log_xq * beta_vn(i_mp_qc,1) )
1405  end do
1406 
1407  ! QR, NR
1408  mud_r = 3.0_rp * nu(i_mp_qr) + 2.0_rp
1409  do k = ks, ke
1410  rhofac = rho_0 / max( dens(k), rho_min )
1411  rhofac_q(k) = rhofac**gamma_v(i_mp_qr)
1412  end do
1413  do k = ks, ke
1414  xq = max( xr_min, min( xr_max, rhoq(k,i_qr) / ( rhoq(k,i_nr) + nr_min ) ) )
1415 
1416  rlambdar(k) = a_m(i_mp_qr) * xq**b_m(i_mp_qr) &
1417  * ( (mud_r+3.0_rp) * (mud_r+2.0_rp) * (mud_r+1.0_rp) )**(-0.333333333_rp)
1418  end do
1419 !OCL LOOP_FISSION_TARGET(LS)
1420  do k = ks, ke
1421  dq = ( 4.0_rp + mud_r ) * rlambdar(k) ! D^(3)+mu weighted mean diameter
1422  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + tanh( pi * log( dq/d_vtr_branch ) ) ) ) )
1423  velq_s = coef_vtr_ar2 * dq &
1424  * ( 1.0_rp - ( 1.0_rp + coef_vtr_br2*rlambdar(k) )**(-5.0_rp-mud_r) )
1425  velq_l = coef_vtr_ar1 &
1426  - coef_vtr_br1 * ( 1.0_rp + coef_vtr_cr1*rlambdar(k) )**(-4.0_rp-mud_r)
1427  vterm(k,i_mp_qr) = -rhofac_q(k) * ( velq_l * ( weight ) &
1428  + velq_s * ( 1.0_rp - weight ) )
1429  end do
1430 !OCL LOOP_FISSION_TARGET(LS)
1431  do k = ks, ke
1432  dq = ( 1.0_rp + mud_r ) * rlambdar(k) ! D^(0)+mu weighted mean diameter
1433  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + tanh( pi * log( dq/d_vtr_branch ) ) ) ) )
1434  velq_s = coef_vtr_ar2 * dq &
1435  * ( 1.0_rp - ( 1.0_rp + coef_vtr_br2*rlambdar(k) )**(-2.0_rp-mud_r) )
1436  velq_l = coef_vtr_ar1 &
1437  - coef_vtr_br1 * ( 1.0_rp + coef_vtr_cr1*rlambdar(k) )**(-1.0_rp-mud_r)
1438  vterm(k,i_mp_nr) = -rhofac_q(k) * ( velq_l * ( weight ) &
1439  + velq_s * ( 1.0_rp - weight ) )
1440  end do
1441 
1442  do k = ks, ke
1443  rhofac_q(k) = exp( log( pres(k)/pre0_vt ) * a_pre0_vt + log( temp(k)/tem0_vt ) * a_tem0_vt )
1444  end do
1445 
1446  ! QI, NI
1447 !OCL LOOP_FISSION_TARGET(LS)
1448  do k = ks, ke
1449  log_xq = log( max( xi_min, min( xi_max, rhoq(k,i_qi) / ( rhoq(k,i_ni) + ni_min ) ) ) )
1450 
1451  tmp = log_a_m(i_mp_qi) + log_xq * b_m(i_mp_qi)
1452  log_dq = log_coef_dave_l(i_mp_qi) + tmp
1453  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_li ) ) )
1454 
1455  velq_s = exp( log_coef_vt1(i_mp_qi,1) + log_xq * beta_v(i_mp_qi,1) )
1456  velq_l = exp( log_coef_vt1(i_mp_qi,2) + log_xq * beta_v(i_mp_qi,2) )
1457  vterm(k,i_mp_qi) = - rhofac_q(k) * ( velq_l * ( weight ) &
1458  + velq_s * ( 1.0_rp - weight ) )
1459 
1460  log_dq = log_coef_dave_n(i_mp_qi) + tmp
1461  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_ni ) ) )
1462 
1463  velq_s = exp( log_coef_vt0(i_mp_qi,1) + log_xq * beta_vn(i_mp_qi,1) )
1464  velq_l = exp( log_coef_vt0(i_mp_qi,2) + log_xq * beta_vn(i_mp_qi,2) )
1465  vterm(k,i_mp_ni) = - rhofac_q(k) * ( velq_l * ( weight ) &
1466  + velq_s * ( 1.0_rp - weight ) )
1467  end do
1468 
1469  ! QS, NS
1470 !OCL LOOP_FISSION_TARGET(LS)
1471  do k = ks, ke
1472  log_xq = log( max( xs_min, min( xs_max, rhoq(k,i_qs) / ( rhoq(k,i_ns) + ns_min ) ) ) )
1473 
1474  tmp = log_a_m(i_mp_qs) + log_xq * b_m(i_mp_qs)
1475  log_dq = log_coef_dave_l(i_mp_qs) + tmp
1476  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_ls ) ) )
1477 
1478  velq_s = exp( log_coef_vt1(i_mp_qs,1) + log_xq * beta_v(i_mp_qs,1) )
1479  velq_l = exp( log_coef_vt1(i_mp_qs,2) + log_xq * beta_v(i_mp_qs,2) )
1480  vterm(k,i_mp_qs) = - rhofac_q(k) * ( velq_l * ( weight ) &
1481  + velq_s * ( 1.0_rp - weight ) )
1482 
1483  log_dq = log_coef_dave_n(i_mp_qs) + tmp
1484  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_ns ) ) )
1485 
1486  velq_s = exp( log_coef_vt0(i_mp_qs,1) + log_xq * beta_vn(i_mp_qs,1) )
1487  velq_l = exp( log_coef_vt0(i_mp_qs,2) + log_xq * beta_vn(i_mp_qs,2) )
1488  vterm(k,i_mp_ns) = - rhofac_q(k) * ( velq_l * ( weight ) &
1489  + velq_s * ( 1.0_rp - weight ) )
1490  end do
1491 
1492  ! QG, NG
1493 !OCL LOOP_FISSION_TARGET(LS)
1494  do k = ks, ke
1495  log_xq = log( max( xg_min, min( xg_max, rhoq(k,i_qg) / ( rhoq(k,i_ng) + ng_min ) ) ) )
1496 
1497  tmp = log_a_m(i_mp_qg) + log_xq * b_m(i_mp_qg)
1498  log_dq = log_coef_dave_l(i_mp_qg) + tmp
1499  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_lg ) ) )
1500 
1501  velq_s = exp( log_coef_vt1(i_mp_qg,1) + log_xq * beta_v(i_mp_qg,1) )
1502  velq_l = exp( log_coef_vt1(i_mp_qg,2) + log_xq * beta_v(i_mp_qg,2) )
1503  vterm(k,i_mp_qg) = - rhofac_q(k) * ( velq_l * ( weight ) &
1504  + velq_s * ( 1.0_rp - weight ) )
1505 
1506  log_dq = log_coef_dave_n(i_mp_qg) + tmp
1507  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log_dq - log_d0_ng ) ) )
1508 
1509  velq_s = exp( log_coef_vt0(i_mp_qg,1) + log_xq * beta_vn(i_mp_qg,1) )
1510  velq_l = exp( log_coef_vt0(i_mp_qg,2) + log_xq * beta_vn(i_mp_qg,2) )
1511  vterm(k,i_mp_ng) = - rhofac_q(k) * ( velq_l * ( weight ) &
1512  + velq_s * ( 1.0_rp - weight ) )
1513  enddo
1514 
1515  do iq = 1, qa_mp-1
1516  vterm(1:ks-2 ,iq) = const_undef
1517  vterm(ks-1 ,iq) = vterm(ks,iq)
1518  vterm(ke+1:ka,iq) = const_undef
1519  enddo
1520 
1521  return
1523 
1524 
1525  ! private
1526  !-----------------------------------------------------------------------------
1527  subroutine mp_sn14_init
1528  use scale_prc, only: &
1529  prc_abort
1530  use scale_specfunc, only: &
1531  gammafunc => sf_gamma
1532  implicit none
1533 
1534  real(rp), parameter :: eps_gamma=1.e-30_rp
1535 
1536  real(rp) :: w1(hydro_max)
1537  real(rp) :: w2(hydro_max)
1538  real(rp) :: w3(hydro_max)
1539  real(rp) :: w4(hydro_max)
1540  real(rp) :: w5(hydro_max)
1541  real(rp) :: w6(hydro_max)
1542  real(rp) :: w7(hydro_max)
1543  real(rp) :: w8(hydro_max)
1544 
1545  character(len=H_SHORT) :: wlabel(hydro_max)
1546 
1547  ! work for calculation of capacity, Mitchell and Arnott (1994) , eq.(9)
1548  real(rp) :: ar_ice_fix = 0.7_rp
1549  real(rp) :: wcap1, wcap2
1550  ! work for ventilation coefficient
1551  logical :: flag_vent0(hydro_max), flag_vent1(hydro_max)
1552  integer :: ierr
1553  integer :: iw, ia, ib
1554  integer :: n
1555  !
1556  namelist / param_atmos_phy_mp_sn14_init / &
1557  opt_debug, &
1558  opt_debug_inc, &
1559  opt_debug_act, &
1560  opt_debug_ree, &
1561  opt_debug_bcs, &
1562  opt_collection_bin, &
1563  ntmax_phase_change, &
1564  ntmax_collection
1565  !
1566  namelist / param_atmos_phy_mp_sn14_particles / &
1567  a_m, b_m, alpha_v, beta_v, gamma_v, &
1568  alpha_vn, beta_vn, &
1569  a_area, b_area, cap, &
1570  nu, mu, &
1571  opt_m96_column_ice, &
1572  opt_m96_ice, &
1573  ar_ice_fix
1574 
1575  namelist / param_atmos_phy_mp_sn14_nucleation / &
1576  in_max, & !
1577  c_ccn, kappa, & ! cloud nucleation
1578  nm_m92, am_m92, bm_m92, & ! ice nucleation
1579  xc_ccn, xi_ccn, &
1580  tem_ccn_low, &
1581  tem_in_low, &
1582  ssw_max, ssi_max, &
1583  nucl_twomey, inucl_w, &
1584  so22_het, opt_nucleation_ice_hom
1585 
1586  namelist / param_atmos_phy_mp_sn14_collection / &
1587  dc0, dc1, di0, ds0, dg0, &
1588  sigma_c, sigma_r, sigma_i, sigma_s, sigma_g, &
1589  opt_stick_ks96, &
1590  opt_stick_co86, &
1591  e_im, e_sm, e_gm, &
1592  e_ir, e_sr, e_gr, e_ii, e_si, e_gi, e_ss, e_gs, e_gg, &
1593  i_iconv2g, i_sconv2g, rho_g, cfill_i, cfill_s, di_cri
1594 
1595  !
1596  namelist / param_atmos_phy_mp_sn14_collection_bin / &
1597  dc0, dc1, di0, ds0, dg0, &
1598  opt_stick_ks96, &
1599  opt_stick_co86, &
1600  tem_min_estick, &
1601  opt_stick_rhh57, &
1602  opt_stick_rhks96, &
1603  opt_stick_c12, &
1604  e_im, e_sm, e_gm, &
1605  e_ir, e_sr, e_gr, e_ii, e_si, e_gi, e_ss, e_gs, e_gg, &
1606  i_iconv2g, i_sconv2g, rho_g, cfill_i, cfill_s, di_cri
1607 
1608  namelist / param_atmos_phy_mp_sn14_condensation / &
1609  opt_fix_taucnd_c, fac_cndc
1610 
1611 
1612  a_m(:) = undef8
1613  log_a_m(:) = undef8
1614  b_m(:) = undef8
1615  alpha_v(:,:) = undef8
1616  beta_v(:,:) = undef8
1617  alpha_vn(:,:) = undef8
1618  beta_vn(:,:) = undef8
1619  gamma_v(:) = undef8
1620  a_d2vt(:) = undef8
1621  b_d2vt(:) = undef8
1622  a_area(:) = undef8
1623  b_area(:) = undef8
1624  ax_area(:) = undef8
1625  bx_area(:) = undef8
1626  a_rea(:) = undef8
1627  b_rea(:) = undef8
1628  a_rea2(:) = undef8
1629  b_rea2(:) = undef8
1630  a_rea3(:) = undef8
1631  b_rea3(:) = undef8
1632  nu(:) = undef8
1633  mu(:) = undef8
1634  cap(:) = undef8
1635  coef_m2(:) = undef8
1636  coef_dave_n(:) = undef8
1637  coef_dave_l(:) = undef8
1638  log_coef_dave_n(:) = undef8
1639  log_coef_dave_l(:) = undef8
1640  coef_d(:) = undef8
1641  coef_d3(:) = undef8
1642  coef_d6(:) = undef8
1643  coef_d2v(:) = undef8
1644  coef_md2v(:) = undef8
1645  coef_r2(:) = undef8
1646  coef_r3(:) = undef8
1647  coef_re(:) = undef8
1648  coef_rea2(:) = undef8
1649  coef_rea3(:) = undef8
1650  coef_a(:) = undef8
1651 ! slope_A(:) = UNDEF8
1652  coef_lambda(:) = undef8
1653  coef_vt0(:,:) = undef8
1654  coef_vt1(:,:) = undef8
1655  log_coef_vt0(:,:) = undef8
1656  log_coef_vt1(:,:) = undef8
1657  delta_b0(:) = undef8
1658  delta_b1(:) = undef8
1659  delta_ab0(:,:) = undef8
1660  delta_ab1(:,:) = undef8
1661  theta_b0(:) = undef8
1662  theta_b1(:) = undef8
1663  theta_ab0(:,:) = undef8
1664  theta_ab1(:,:) = undef8
1665  !
1666  ah_vent(:,:) = undef8
1667  ah_vent0(:,:) = undef8
1668  ah_vent1(:,:) = undef8
1669  bh_vent(:,:) = undef8
1670  bh_vent0(:,:) = undef8
1671  bh_vent1(:,:) = undef8
1672 
1673  !--- read namelist
1674  rewind(io_fid_conf)
1675  read(io_fid_conf,nml=param_atmos_phy_mp_sn14_init,iostat=ierr)
1676 
1677  if( ierr < 0 ) then !--- missing
1678  log_info("ATMOS_PHY_MP_sn14_init",*) 'Not found namelist. Default used.'
1679  elseif( ierr > 0 ) then !--- fatal error
1680  log_error("ATMOS_PHY_MP_sn14_init",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_init. Check!'
1681  call prc_abort
1682  endif
1683  log_nml(param_atmos_phy_mp_sn14_init)
1684 
1685  !
1686  ! default setting
1687  !
1688  ! Area parameters with mks unit originated by Mitchell(1996)
1689  a_area(i_mp_qc) = pi/4.0_rp ! sphere
1690  a_area(i_mp_qr) = pi/4.0_rp ! sphere
1691  a_area(i_mp_qi) = 0.65_rp*1.e-4_rp*100.0_rp**(2.00_rp) ! Mitchell(1996), Hexagonal Plate
1692  a_area(i_mp_qs) = 0.2285_rp*1.e-4_rp*100.0_rp**(1.88_rp) ! Mitchell(1996), Aggregates
1693  a_area(i_mp_qg) = 0.50_rp*1.e-4_rp*100.0_rp**(2.0_rp) ! Mitchell(1996), Lump Graupel
1694  b_area(i_mp_qc) = 2.0_rp
1695  b_area(i_mp_qr) = 2.0_rp
1696  b_area(i_mp_qi) = 2.0_rp
1697  b_area(i_mp_qs) = 1.88_rp
1698  b_area(i_mp_qg) = 2.0_rp
1699  !
1700  ! Seifert and Beheng(2006), Table. 1 or List of symbols
1701  !----------------------------------------------------------
1702  ! Diameter-Mass relationship
1703  ! D = a * x^b
1704  a_m(i_mp_qc) = 0.124_rp
1705  a_m(i_mp_qr) = 0.124_rp
1706  a_m(i_mp_qi) = 0.217_rp
1707  a_m(i_mp_qs) = 8.156_rp
1708  a_m(i_mp_qg) = 0.190_rp
1709  b_m(i_mp_qc) = 1.0_rp/3.0_rp
1710  b_m(i_mp_qr) = 1.0_rp/3.0_rp
1711  b_m(i_mp_qi) = 0.302_rp
1712  b_m(i_mp_qs) = 0.526_rp
1713  b_m(i_mp_qg) = 0.323_rp
1714  !----------------------------------------------------------
1715  ! Terminal velocity-Mass relationship
1716  ! vt = alpha * x^beta * (rho0/rho)^gamma
1717  alpha_v(i_mp_qc,:)= 3.75e+5_rp
1718  alpha_v(i_mp_qr,:)= 159.0_rp ! not for sedimantation
1719  alpha_v(i_mp_qi,:)= 317.0_rp
1720  alpha_v(i_mp_qs,:)= 27.70_rp
1721  alpha_v(i_mp_qg,:)= 40.0_rp
1722  beta_v(i_mp_qc,:) = 2.0_rp/3.0_rp
1723  beta_v(i_mp_qr,:) = 0.266_rp ! not for sedimantation
1724  beta_v(i_mp_qi,:) = 0.363_rp
1725  beta_v(i_mp_qs,:) = 0.216_rp
1726  beta_v(i_mp_qg,:) = 0.230_rp
1727  gamma_v(i_mp_qc) = 1.0_rp
1728  ! This is high Reynolds number limit(Beard 1980)
1729  gamma_v(i_mp_qr) = 1.0_rp/2.0_rp
1730  gamma_v(i_mp_qi) = 1.0_rp/2.0_rp
1731  gamma_v(i_mp_qs) = 1.0_rp/2.0_rp
1732  gamma_v(i_mp_qg) = 1.0_rp/2.0_rp
1733  !----------------------------------------------------------
1734  ! DSD parameters
1735  ! f(x) = A x^nu exp( -lambda x^mu )
1736  ! Gamma Disribution : mu=1 , nu:arbitrary
1737  ! Marshall-Palmer Distribution: mu=1/3, nu:-2/3
1738  ! In the case of MP, f(D) dD = f(x)dx
1739  ! f(x) = c * f(D)/D^2 (c:coefficient)
1740  nu(i_mp_qc) = 1.0_rp ! arbitrary for Gamma
1741  nu(i_mp_qr) = -1.0_rp/3.0_rp ! nu(diameter)=1, equilibrium condition.
1742  nu(i_mp_qi) = 1.0_rp !
1743  nu(i_mp_qs) = 1.0_rp !
1744  nu(i_mp_qg) = 1.0_rp !
1745  !
1746  mu(i_mp_qc) = 1.0_rp ! Gamma
1747  mu(i_mp_qr) = 1.0_rp/3.0_rp ! Marshall Palmer
1748  mu(i_mp_qi) = 1.0_rp/3.0_rp !
1749  mu(i_mp_qs) = 1.0_rp/3.0_rp !
1750  mu(i_mp_qg) = 1.0_rp/3.0_rp !
1751  !----------------------------------------------------------
1752  ! Geomeries for diffusion growth
1753  ! Pruppacher and Klett(1997), (13-77)-(13-80) and
1754  ! originally derived by McDonald(1963b)
1755  ! sphere: cap=2
1756  ! plate : cap=pi
1757  ! needle with aspect ratio a/b
1758  ! : cap=log(2*a/b)
1759  cap(i_mp_qc) = 2.0_rp ! sphere
1760  cap(i_mp_qr) = 2.0_rp ! sphere
1761  cap(i_mp_qi) = pi ! hexagonal plate
1762  cap(i_mp_qs) = 2.0_rp ! mix aggregates
1763  cap(i_mp_qg) = 2.0_rp ! lump
1764  !
1765  alpha_vn(:,:) = alpha_v(:,:)
1766  beta_vn(:,:) = beta_v(:,:)
1767  !------------------------------------------------------------------------
1768  !
1769  ! additional setting
1770  !
1771 
1772  !--- read namelist
1773  rewind(io_fid_conf)
1774  read(io_fid_conf,nml=param_atmos_phy_mp_sn14_particles,iostat=ierr)
1775  if( ierr < 0 ) then !--- missing
1776  log_info("ATMOS_PHY_MP_sn14_init",*) 'Not found namelist. Default used.'
1777  elseif( ierr > 0 ) then !--- fatal error
1778  log_error("ATMOS_PHY_MP_sn14_init",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_particles. Check!'
1779  call prc_abort
1780  endif
1781  log_nml(param_atmos_phy_mp_sn14_particles)
1782 
1783  ! [Add] 10/08/03 T.Mitsui
1784  ! particles shapes are
1785  if( opt_m96_ice ) then
1786  ! ice is randomly oriented Hexagonal plate (Auer and Veal 1970, Takano and Liou 1995, Mitchell 1996)
1787  ! snow is assemblages of planar polycrystals(Mitchell 1996)
1788  ! graupel is Lump graupel(R4b) is assumed(Mitchell 1996)
1789  a_area(i_mp_qi) = 0.120284936_rp
1790  a_area(i_mp_qs) = 0.131488_rp
1791  a_area(i_mp_qg) = 0.5_rp
1792  b_area(i_mp_qi) = 1.850000_rp
1793  b_area(i_mp_qs) = 1.880000_rp
1794  b_area(i_mp_qg) = 2.0_rp
1795  a_m(i_mp_qi) = 1.23655360084766_rp
1796  a_m(i_mp_qs) = a_m(i_mp_qi)
1797  a_m(i_mp_qg) = 0.346111225718402_rp
1798  b_m(i_mp_qi) = 0.408329930583912_rp
1799  b_m(i_mp_qs) = b_m(i_mp_qi)
1800  b_m(i_mp_qg) = 0.357142857142857_rp
1801  !
1802  if( opt_m96_column_ice )then
1803  d0_ni=240.49e-6_rp ! this is column
1804  d0_li=330.09e-6_rp ! this is column
1805  a_area(i_mp_qi)= (0.684_rp*1.e-4_rp)*10.0_rp**(2.0_rp*2.00_rp)
1806  b_area(i_mp_qi)= 2.0_rp
1807  a_m(i_mp_qi) = 0.19834046116844_rp
1808  b_m(i_mp_qi) = 0.343642611683849_rp
1809  ! [Add] 11/08/30 T.Mitsui
1810  ! approximated by the capacity for prolate spheroid with constant aspect ratio
1811  wcap1 = sqrt(1.0_rp-ar_ice_fix**2)
1812  wcap2 = log( (1.0_rp+wcap1)/ar_ice_fix )
1813  cap(i_mp_qi) = 2.0_rp*wcap2/wcap1
1814  !
1815  end if
1816  !
1817  ! These value are derived by least-square fitting in the range
1818  ! qi [100um:1000um] in diameter
1819  ! qs [100um:1000um] in diameter
1820  ! qg [200um:2000um] in diameter
1821  ! small branch , large branch
1822  if( opt_m96_column_ice )then
1823  alpha_v(i_mp_qi,:) = (/2901.0_rp, 32.20_rp/)
1824  alpha_vn(i_mp_qi,:) = (/9675.2_rp, 64.16_rp/)
1825  else
1826  alpha_v(i_mp_qi,:) =(/ 5798.60107421875_rp, 167.347076416016_rp/)
1827  alpha_vn(i_mp_qi,:) =(/ 12408.177734375_rp, 421.799865722656_rp/)
1828  end if
1829  alpha_v(i_mp_qs,:) =(/ 15173.3916015625_rp, 305.678619384766_rp/)
1830  alpha_vn(i_mp_qs,:) =(/ 29257.1601562500_rp, 817.985717773438_rp/)
1831  alpha_v(i_mp_qg,:) =(/ 15481.6904296875_rp, 311.642242431641_rp/)
1832  alpha_vn(i_mp_qg,:) =(/ 27574.6562500000_rp, 697.536132812500_rp/)
1833  !
1834  beta_v(i_mp_qi,:) =(/ 0.504873454570770_rp, 0.324817866086960_rp/)
1835  beta_vn(i_mp_qi,:) =(/ 0.548495233058929_rp, 0.385287821292877_rp/)
1836  if( opt_m96_column_ice )then
1837  beta_v(i_mp_qi,:) =(/ 0.465552181005478_rp, 0.223826110363007_rp/)
1838  beta_vn(i_mp_qi,:) =(/ 0.530453503131866_rp, 0.273761242628098_rp/)
1839  end if
1840  beta_v(i_mp_qs,:) =(/ 0.528109610080719_rp, 0.329863965511322_rp/)
1841  beta_vn(i_mp_qs,:) =(/ 0.567154467105865_rp, 0.393876969814301_rp/)
1842  beta_v(i_mp_qg,:) =(/ 0.534656763076782_rp, 0.330253750085831_rp/)
1843  beta_vn(i_mp_qg,:) =(/ 0.570551633834839_rp, 0.387124240398407_rp/)
1844  end if
1845  !
1846  ! area-diameter relation => area-mass relation
1847  ax_area(:) = a_area(:)*a_m(:)**b_area(:)
1848  bx_area(:) = b_area(:)*b_m(:)
1849  !
1850  ! radius of equivalent area - m ass relation
1851  ! pi*rea**2 = ax_area*x**bx_area
1852  a_rea(:) = sqrt(ax_area(:)/pi)
1853  b_rea(:) = bx_area(:)/2.0_rp
1854  a_rea2(:) = a_rea(:)**2
1855  b_rea2(:) = b_rea(:)*2.0_rp
1856  a_rea3(:) = a_rea(:)**3
1857  b_rea3(:) = b_rea(:)*3.0_rp
1858  !
1859  a_d2vt(:)=alpha_v(:,2)*(1.0_rp/alpha_v(:,2))**(beta_v(:,2)/b_m(:))
1860  b_d2vt(:)=(beta_v(:,2)/b_m(:))
1861  !
1862  ! Calculation of Moment Coefficient
1863  !
1864  w1(:) = 0.0_rp
1865  w2(:) = 0.0_rp
1866  w3(:) = 0.0_rp
1867  w4(:) = 0.0_rp
1868  w5(:) = 0.0_rp
1869  w6(:) = 0.0_rp
1870  w7(:) = 0.0_rp
1871  w8(:) = 0.0_rp
1872  !-------------------------------------------------------
1873  ! moment coefficient
1874  ! SB06 (82)
1875  ! M^n /= coef_mn * N * (L/N)**n
1876  ! M^2 = Z = coef_m2 * N *(L/N)**2
1877  ! a*M^b = a*integral x^b f(x) dx = ave D
1878  do iw=1, hydro_max
1879  n = 2
1880  w1(iw) = gammafunc( (n+nu(iw)+1.0_rp)/mu(iw) )
1881  w2(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
1882  w3(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
1883  coef_m2(iw) = w1(iw)/w2(iw)*( w2(iw)/w3(iw) )**n
1884  !
1885  w4(iw) = gammafunc( (b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
1886  coef_d(iw) = a_m(iw) * w4(iw)/w2(iw)*( w2(iw)/w3(iw) )**b_m(iw)
1887  w5(iw) = gammafunc( (2.0_rp*b_m(iw)+beta_v(iw,2)+nu(iw)+1.0_rp)/mu(iw) )
1888  w6(iw) = gammafunc( (3.0_rp*b_m(iw)+beta_v(iw,2)+nu(iw)+1.0_rp)/mu(iw) )
1889  coef_d2v(iw) = a_m(iw) * w6(iw)/w5(iw)* ( w2(iw)/w3(iw) )**b_m(iw)
1890  coef_md2v(iw)= w5(iw)/w2(iw)* ( w2(iw)/w3(iw) )**(2.0_rp*b_m(iw)+beta_v(iw,2))
1891  ! 09/04/14 [Add] T.Mitsui, volume and radar reflectivity
1892  w7(iw) = gammafunc( (3.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
1893  coef_d3(iw) = a_m(iw)**3 * w7(iw)/w2(iw)*( w2(iw)/w3(iw) )**(3.0_rp*b_m(iw))
1894  w8(iw) = gammafunc( (6.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
1895  coef_d6(iw) = a_m(iw)**6 * w8(iw)/w2(iw)*( w2(iw)/w3(iw) )**(6.0_rp*b_m(iw))
1896  end do
1897  !
1898  coef_deplc = coef_d(i_mp_qc)/a_m(i_mp_qc)
1899  !-------------------------------------------------------
1900  ! coefficient of 2nd and 3rd moments for effective radius
1901  ! for spherical particle
1902  do iw=1, hydro_max
1903  ! integ r^2 f(x)dx
1904  w1(iw) = gammafunc( (2.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
1905  w2(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
1906  w3(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
1907  ! integ r^3 f(x)dx
1908  w4(iw) = gammafunc( (3.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
1909  !
1910  coef_r2(iw)=w1(iw)/w2(iw)*( w2(iw)/w3(iw) )**(2.0_rp*b_m(iw))
1911  coef_r3(iw)=w4(iw)/w2(iw)*( w2(iw)/w3(iw) )**(3.0_rp*b_m(iw))
1912  coef_re(iw)=coef_r3(iw)/coef_r2(iw)
1913  !
1914  end do
1915  !-------------------------------------------------------
1916  ! coefficient for effective radius of equivalent area and
1917  ! coefficient for volume of equivalent area
1918  do iw=1, hydro_max
1919  w1(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
1920  w2(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
1921  w3(iw) = gammafunc( (b_rea2(iw)+nu(iw)+1.0_rp)/mu(iw) )
1922  w4(iw) = gammafunc( (b_rea3(iw)+nu(iw)+1.0_rp)/mu(iw) )
1923  !
1924  coef_rea2(iw) = w3(iw)/w1(iw)*( w1(iw)/w2(iw) )**b_rea2(iw)
1925  coef_rea3(iw) = w4(iw)/w1(iw)*( w1(iw)/w2(iw) )**b_rea3(iw)
1926  end do
1927  !-------------------------------------------------------
1928  ! coefficient of gamma-distribution
1929  ! SB06(80)
1930  do iw=1, hydro_max
1931  w1(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1932  w2(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1933  coef_a(iw) = mu(iw)/w1(iw)
1934 ! slope_A(iw) = w1(iw)
1935  coef_lambda(iw) = (w1(iw)/w2(iw))**(-mu(iw))
1936  end do
1937  !-------------------------------------------------------
1938  ! coefficient for terminal velocity in sedimentation
1939  ! SB06(78)
1940  do ia=1,2
1941  do iw=1, hydro_max
1942  n = 0
1943  w1(iw) = gammafunc( (beta_vn(iw,ia) + nu(iw) + 1.0_rp + n)/mu(iw) )
1944  w2(iw) = gammafunc( ( nu(iw) + 1.0_rp + n)/mu(iw) )
1945  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1946  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1947  ! coefficient of terminal velocity for number
1948  coef_vt0(iw,ia) = alpha_vn(iw,ia) * w1(iw) / w2(iw) * ( w3(iw) / w4(iw) )**beta_vn(iw,ia)
1949  log_coef_vt0(iw,ia) = log( coef_vt0(iw,ia) )
1950  n = 1
1951  w1(iw) = gammafunc( (beta_v(iw,ia) + nu(iw) + 1.0_rp + n)/mu(iw) )
1952  w2(iw) = gammafunc( ( nu(iw) + 1.0_rp + n)/mu(iw) )
1953  ! coefficient of terminal velocity for mass
1954  coef_vt1(iw,ia) = alpha_v(iw,ia) * w1(iw) / w2(iw) * ( w3(iw) / w4(iw) )**beta_v(iw,ia)
1955  log_coef_vt1(iw,ia) = log( coef_vt1(iw,ia) )
1956  end do
1957  end do
1958  ! coefficient for weighted diameter used in calculation of terminal velocity
1959  do iw=1, hydro_max
1960  w1(iw) = gammafunc( ( b_m(iw) + nu(iw) + 1.0_rp)/mu(iw) )
1961  w2(iw) = gammafunc( (1.0_rp + b_m(iw) + nu(iw) + 1.0_rp)/mu(iw) )
1962  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1963  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1964  coef_dave_n(iw) = ( w1(iw) / w3(iw) ) * ( w3(iw) / w4(iw) )**( b_m(iw))
1965  coef_dave_l(iw) = ( w2(iw) / w3(iw) ) * ( w3(iw) / w4(iw) )**(1.0_rp+b_m(iw))
1966  log_coef_dave_n(iw) = log( coef_dave_n(iw) )
1967  log_coef_dave_l(iw) = log( coef_dave_l(iw) )
1968  end do
1969  !-------------------------------------------------------
1970  !
1971  ah_vent(i_mp_qc,1:2) = (/1.0000_rp,1.0000_rp/) ! no effect
1972  ah_vent(i_mp_qr,1:2) = (/1.0000_rp,0.780_rp/)
1973  ah_vent(i_mp_qi,1:2) = (/1.0000_rp,0.860_rp/)
1974  ah_vent(i_mp_qs,1:2) = (/1.0000_rp,0.780_rp/)
1975  ah_vent(i_mp_qg,1:2) = (/1.0000_rp,0.780_rp/)
1976  bh_vent(i_mp_qc,1:2) = (/0.0000_rp,0.0000_rp/)
1977  bh_vent(i_mp_qr,1:2) = (/0.108_rp,0.308_rp/)
1978  bh_vent(i_mp_qi,1:2) = (/0.140_rp,0.280_rp/)
1979  bh_vent(i_mp_qs,1:2) = (/0.108_rp,0.308_rp/)
1980  bh_vent(i_mp_qg,1:2) = (/0.108_rp,0.308_rp/)
1981  !
1982  do iw=1, hydro_max
1983  n = 0
1984  if( (nu(iw) + b_m(iw) + n) > eps_gamma )then
1985  w1(iw) = gammafunc( (nu(iw) + b_m(iw) + n)/mu(iw) )
1986  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1987  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1988  ah_vent0(iw,1)= ah_vent(iw,1)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1989  ah_vent0(iw,2)= ah_vent(iw,2)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1990  flag_vent0(iw)=.true.
1991  else
1992  ah_vent0(iw,1)= 1.0_rp
1993  ah_vent0(iw,2)= 1.0_rp
1994  flag_vent0(iw)=.false.
1995  end if
1996  n = 1
1997  if( (nu(iw) + b_m(iw) + n) > eps_gamma )then
1998  w1(iw) = gammafunc( (nu(iw) + b_m(iw) + n)/mu(iw) )
1999  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2000  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2001  ah_vent1(iw,1)= ah_vent(iw,1)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
2002  ah_vent1(iw,2)= ah_vent(iw,2)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
2003  flag_vent1(iw)=.true.
2004  else
2005  ah_vent1(iw,1)= 1.0_rp
2006  ah_vent1(iw,2)= 1.0_rp
2007  flag_vent1(iw)=.true.
2008  end if
2009  end do
2010  do iw=1, hydro_max
2011  n = 0
2012  if( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n) < eps_gamma )then
2013  flag_vent0(iw)=.false.
2014  end if
2015  if(flag_vent0(iw))then
2016 ! w1(iw) = gammafunc( (nu(iw) + 1.5_RP*b_m(iw) + 0.5_RP*beta_v(iw,1) + n)/mu(iw) )
2017  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2018  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2019  ! [Add] 11/08/30 T.Mitsui
2020  w4(iw) = gammafunc( (nu(iw) + 2.0_rp*b_m(iw) + beta_v(iw,1) + n)/mu(iw) )
2021  bh_vent0(iw,1)=bh_vent(iw,1)*(w4(iw)/w2(iw))*(w2(iw)/w3(iw))**(2.00_rp*b_m(iw)+beta_v(iw,1)+n-1.0_rp)
2022  w5(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,2) + n)/mu(iw) )
2023  bh_vent0(iw,2)=bh_vent(iw,2)*(w5(iw)/w2(iw))*(w2(iw)/w3(iw))**(1.5_rp*b_m(iw)+0.5_rp*beta_v(iw,2)+n-1.0_rp)
2024  else
2025  bh_vent0(iw,1) = 0.0_rp
2026  bh_vent0(iw,2) = 0.0_rp
2027  end if
2028  !
2029  n = 1
2030  if( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n) < eps_gamma )then
2031  flag_vent1(iw)=.false.
2032  end if
2033  if(flag_vent1(iw))then
2034 ! w1(iw) = gammafunc( (nu(iw) + 1.5_RP*b_m(iw) + 0.5_RP*beta_v(iw,1) + n)/mu(iw) )
2035  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2036  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2037  ! [Add] 11/08/30 T.Mitsui
2038  w4(iw) = gammafunc( (nu(iw) + 2.0_rp*b_m(iw) + beta_v(iw,1) + n)/mu(iw) )
2039  bh_vent1(iw,1)=bh_vent(iw,1)*(w4(iw)/w2(iw))*(w2(iw)/w3(iw))**(2.00_rp*b_m(iw)+beta_v(iw,1)+n-1.0_rp)
2040  !
2041  w5(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,2) + n)/mu(iw) )
2042  bh_vent1(iw,2)=bh_vent(iw,2)*(w5(iw)/w2(iw))*(w2(iw)/w3(iw))**(1.5_rp*b_m(iw)+0.5_rp*beta_v(iw,2)+n-1.0_rp)
2043  else
2044  bh_vent1(iw,1) = 0.0_rp
2045  bh_vent1(iw,2) = 0.0_rp
2046  end if
2047  end do
2048  !-------------------------------------------------------
2049  ! coefficient for collision process
2050  ! stochastic coefficient for collision cross section
2051  ! sb06 (90) -- self collection
2052  do iw=1, hydro_max
2053  n = 0
2054  w1(iw) = gammafunc( (2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2055  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2056  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2057  delta_b0(iw) = w1(iw)/w2(iw) &
2058  *( w2(iw)/w3(iw) )**(2.0_rp*b_rea(iw) + n)
2059  n = 1
2060  w1(iw) = gammafunc( (2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2061  delta_b1(iw) = w1(iw)/w2(iw) &
2062  *( w2(iw)/w3(iw) )**(2.0_rp*b_rea(iw) + n)
2063  end do
2064  ! stochastic coefficient for collision cross section
2065  ! sb06(91) -- riming( collide with others )
2066  do iw=1, hydro_max
2067  n = 0
2068  w1(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2069  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2070  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2071  w4(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
2072  n = 1
2073  w5(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2074  end do
2075  ! ia > ib ( larger particles "a" catch smaller particles "b" )
2076  do ia=1, hydro_max
2077  do ib=1, hydro_max
2078  n=0 !
2079  ! NOTE, collected particle has a moment of n.
2080  ! collecting particle has only number(n=0).
2081  delta_ab0(ia,ib) = 2.0_rp*(w1(ib)/w2(ib))*(w4(ia)/w2(ia)) &
2082  * ( w2(ib)/w3(ib) )**(b_rea(ib)+n) &
2083  * ( w2(ia)/w3(ia) )**(b_rea(ia) )
2084  n=1 !
2085  delta_ab1(ia,ib) = 2.0_rp*(w5(ib)/w2(ib))*(w4(ia)/w2(ia)) &
2086  * ( w2(ib)/w3(ib) )**(b_rea(ib)+n) &
2087  * ( w2(ia)/w3(ia) )**(b_rea(ia) )
2088  end do
2089  end do
2090  ! stochastic coefficient for terminal velocity
2091  ! sb06(92) -- self collection
2092  ! assuming equivalent area circle.
2093  do iw=1, hydro_max
2094  n = 0
2095  w1(iw) = gammafunc( (2.0_rp*beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2096  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2097  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2098  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2099  theta_b0(iw) = w1(iw)/w2(iw) * ( w3(iw)/w4(iw) )**(2.0_rp*beta_v(iw,2))
2100  n = 1
2101  w1(iw) = gammafunc( (2.0_rp*beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2102  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2103  theta_b1(iw) = w1(iw)/w2(iw) * ( w3(iw)/w4(iw) )**(2.0_rp*beta_v(iw,2))
2104  end do
2105  !
2106  ! stochastic coefficient for terminal velocity
2107  ! sb06(93) -- riming( collide with others )
2108  do iw=1, hydro_max
2109  n = 0
2110  w1(iw) = gammafunc( (beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2111  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2112  w3(iw) = gammafunc( (beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
2113  w4(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
2114  !
2115  w5(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
2116  w6(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
2117  n = 1
2118  w7(iw) = gammafunc( (beta_v(iw,2) + b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2119  w8(iw) = gammafunc( ( b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
2120  end do
2121  ! ia > ib ( larger particles "a" catch smaller particles "b" )
2122  do ia=1, hydro_max
2123  do ib=1, hydro_max
2124  theta_ab0(ia,ib) = 2.0_rp * (w1(ib)/w2(ib))*(w3(ia)/w4(ia)) &
2125  * (w5(ia)/w6(ia))**beta_v(ia,2) &
2126  * (w5(ib)/w6(ib))**beta_v(ib,2)
2127  theta_ab1(ia,ib) = 2.0_rp * (w7(ib)/w8(ib))*(w3(ia)/w4(ia)) &
2128  * (w5(ia)/w6(ia))**beta_v(ia,2) &
2129  * (w5(ib)/w6(ib))**beta_v(ib,2)
2130  end do
2131  end do
2132 
2133  rewind(io_fid_conf)
2134  read(io_fid_conf, nml=param_atmos_phy_mp_sn14_nucleation, iostat=ierr)
2135  if( ierr < 0 ) then !--- missing
2136  log_info("ATMOS_PHY_MP_sn14_init",*) 'PARAM_ATMOS_PHY_MP_SN14_nucleation is not specified. Default used.'
2137  elseif( ierr > 0 ) then !--- fatal error
2138  log_error("ATMOS_PHY_MP_sn14_init",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_nucleation. Check!'
2139  call prc_abort
2140  endif
2141  log_nml(param_atmos_phy_mp_sn14_nucleation)
2142  if ( mp_couple_aerosol .AND. nucl_twomey ) then
2143  log_error("ATMOS_PHY_MP_SN14_nucleation_kij",*) "nucl_twomey should be false when MP_couple_aerosol is true, stop"
2144  call prc_abort
2145  endif
2146 
2147 
2148  if ( opt_collection_bin ) then
2149 
2150  rewind(io_fid_conf)
2151  read(io_fid_conf,nml=param_atmos_phy_mp_sn14_collection_bin,iostat=ierr)
2152  if ( ierr < 0 ) then
2153  log_info("ATMOS_PHY_MP_sn14_init",*) 'PARAM_ATMOS_PHY_MP_SN14_collection_bin is not specified. Default used.'
2154  elseif( ierr > 0 ) then
2155  log_error("ATMOS_PHY_MP_sn14_init",*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_collection_bin. STOP.' ! write(IO_FID_LOG,*)
2156  call prc_abort
2157  endif
2158  log_nml(param_atmos_phy_mp_sn14_collection_bin)
2159 
2160  else
2161 
2162  rewind( io_fid_conf )
2163  read( io_fid_conf, nml=param_atmos_phy_mp_sn14_collection, iostat=ierr )
2164  if( ierr < 0 ) then !--- missing
2165  log_info("ATMOS_PHY_MP_sn14_init",*) 'PARAM_ATMOS_PHY_MP_SN14_collection is not specified. Default used.'
2166  elseif( ierr > 0 ) then !--- fatal error
2167  log_error("ATMOS_PHY_MP_sn14_init",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_collection. Check!'
2168  call prc_abort
2169  endif
2170  log_nml(param_atmos_phy_mp_sn14_collection)
2171 
2172  end if
2173 
2174 
2175  rewind(io_fid_conf)
2176  read (io_fid_conf,nml=param_atmos_phy_mp_sn14_condensation, iostat=ierr )
2177  if( ierr < 0 ) then !--- missing
2178  log_info("ATMOS_PHY_MP_sn14_init",*) 'PARAM_ATMOS_PHY_MP_SN14_condensation is not specified. Default used.'
2179  elseif( ierr > 0 ) then !--- fatal error
2180  log_error("ATMOS_PHY_MP_sn14_init",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_MP_SN14_condensation. Check!'
2181  call prc_abort
2182  endif
2183  log_nml(param_atmos_phy_mp_sn14_condensation)
2184 
2185 
2186 
2187  ! work for Incomplete Gamma function
2188  xc_cr = (2.0_rp*rc_cr/a_m(i_mp_qc))**(1.0_rp/b_m(i_mp_qc))
2189  alpha = (nu(i_mp_qc)+1.0_rp)/mu(i_mp_qc)
2190  gm = gammafunc(alpha)
2191  lgm = log(gm)
2192 
2193 
2194  ! log
2195  do ia=1, hydro_max
2196  log_a_m(ia) = log( a_m(ia) )
2197  log_alpha_v(ia,1) = log( alpha_v(ia,1) )
2198  log_alpha_v(ia,2) = log( alpha_v(ia,2) )
2199  log_beta_v(ia,1) = log( beta_v(ia,1) )
2200  log_beta_v(ia,2) = log( beta_v(ia,2) )
2201  end do
2202  log_d0_li = log( d0_li )
2203  log_d0_ni = log( d0_ni )
2204 
2205  wlabel(1) = "CLOUD"
2206  wlabel(2) = "RAIN"
2207  wlabel(3) = "ICE"
2208  wlabel(4) = "SNOW"
2209  wlabel(5) = "GRAUPEL"
2210 
2211  log_info("ATMOS_PHY_MP_sn14_init",'(100a16)') "LABEL ",wlabel(:)
2212  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "capacity ",cap(:) ! [Add] 11/08/30 T.Mitsui
2213  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_m2 ",coef_m2(:)
2214  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_d ",coef_d(:)
2215  !
2216  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_d3 ",coef_d3(:)
2217  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_d6 ",coef_d6(:)
2218  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_d2v ",coef_d2v(:)
2219  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_md2v ",coef_md2v(:)
2220  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "a_d2vt ",a_d2vt(:)
2221  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "b_d2vt ",b_d2vt(:)
2222  !
2223  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_r2 ",coef_r2(:)
2224  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_r3 ",coef_r3(:)
2225  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_re ",coef_re(:)
2226  !
2227  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "a_area ",a_area(:)
2228  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "b_area ",b_area(:)
2229  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "ax_area ",ax_area(:)
2230  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "bx_area ",bx_area(:)
2231  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "a_rea ",a_rea(:)
2232  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "b_rea ",b_rea(:)
2233  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "a_rea3 ",a_rea3(:)
2234  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "b_rea3 ",b_rea3(:)
2235  !
2236  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_rea2 ",coef_rea2(:)
2237  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_rea3 ",coef_rea3(:)
2238  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_vt0 ",coef_vt0(:,1)
2239  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_vt1 ",coef_vt1(:,1)
2240  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_A ",coef_a(:)
2241  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "coef_lambda ",coef_lambda(:)
2242 
2243  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "ah_vent0 sml",ah_vent0(:,1)
2244  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "ah_vent0 lrg",ah_vent0(:,2)
2245  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "ah_vent1 sml",ah_vent1(:,1)
2246  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "ah_vent1 lrg",ah_vent1(:,2)
2247  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "bh_vent0 sml",bh_vent0(:,1)
2248  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "bh_vent0 lrg",bh_vent0(:,2)
2249  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "bh_vent1 sml",bh_vent1(:,1)
2250  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "bh_vent1 lrg",bh_vent1(:,2)
2251 
2252  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "delta_b0 ",delta_b0(:)
2253  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "delta_b1 ",delta_b1(:)
2254  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "theta_b0 ",theta_b0(:)
2255  log_info("ATMOS_PHY_MP_sn14_init",'(a,100ES16.6)') "theta_b1 ",theta_b1(:)
2256 
2257  do ia=1, hydro_max
2258  log_info("ATMOS_PHY_MP_sn14_init",'(a,a10,a,100ES16.6)') "delta0(a,b)=(",trim(wlabel(ia)),",b)=",(delta_ab0(ia,ib),ib=1,hydro_max)
2259  enddo
2260  do ia=1, hydro_max
2261  log_info("ATMOS_PHY_MP_sn14_init",'(a,a10,a,100ES16.6)') "delta1(a,b)=(",trim(wlabel(ia)),",b)=",(delta_ab1(ia,ib),ib=1,hydro_max)
2262  enddo
2263  do ia=1, hydro_max
2264  log_info("ATMOS_PHY_MP_sn14_init",'(a,a10,a,100ES16.6)') "theta0(a,b)=(",trim(wlabel(ia)),",b)=",(theta_ab0(ia,ib),ib=1,hydro_max)
2265  enddo
2266  do ia=1, hydro_max
2267  log_info("ATMOS_PHY_MP_sn14_init",'(a,a10,a,100ES16.6)') "theta1(a,b)=(",trim(wlabel(ia)),",b)=",(theta_ab1(ia,ib),ib=1,hydro_max)
2268  enddo
2269 
2270  !$acc update device(nu)
2271  !$acc update device(a_m, log_a_m, b_m)
2272  !$acc update device(beta_v, beta_vn, gamma_v)
2273  !$acc update device(log_d0_ni, log_d0_li)
2274  !$acc update device(log_coef_vt0, log_coef_vt1)
2275  !$acc update device(log_coef_dave_N, log_coef_dave_L)
2276 
2277 
2278  return
2279  end subroutine mp_sn14_init
2280  !-----------------------------------------------------------------------------
2281  subroutine mp_sn14 ( &
2282  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
2283  DENS, &
2284  W, &
2285  QTRC, &
2286  PRES0, &
2287  TEMP0, &
2288  Qdry, &
2289  CPtot0, &
2290  CVtot0, &
2291  CCN, &
2292  dt, &
2293  cz, &
2294  fz, &
2295  RHOQ_t, &
2296  RHOE_t, &
2297  CPtot_t, &
2298  CVtot_t, &
2299  EVAPORATE, &
2300  flg_lt, &
2301  d0_crg, &
2302  v0_crg, &
2303  dqcrg, &
2304  beta_crg, &
2305  QTRC_crg, &
2306  QSPLT_in, &
2307  Sarea, &
2308  RHOQcrg_t_mp )
2309  use scale_atmos_hydrometeor, only: &
2310  cp_vapor, &
2311  cp_water, &
2312  cp_ice, &
2313  cv_vapor, &
2314  cv_water, &
2315  cv_ice
2316  use scale_atmos_saturation, only: &
2317  moist_psat_liq => atmos_saturation_psat_liq, &
2318  moist_psat_ice => atmos_saturation_psat_ice, &
2319  moist_pres2qsat_ice => atmos_saturation_pres2qsat_ice
2320  use scale_file_history, only: &
2321  file_history_query, &
2322  file_history_put
2323  implicit none
2324 
2325  integer, intent(in) :: ka, ks, ke
2326  integer, intent(in) :: ia, is, ie
2327  integer, intent(in) :: ja, js, je
2328 
2329  real(rp), intent(in) :: dens (ka,ia,ja)
2330  real(rp), intent(in) :: w (ka,ia,ja)
2331  real(rp), intent(in) :: qtrc (ka,ia,ja,qa_mp)
2332  real(rp), intent(in) :: pres0 (ka,ia,ja)
2333  real(rp), intent(in) :: temp0 (ka,ia,ja)
2334  real(rp), intent(in) :: qdry (ka,ia,ja)
2335  real(rp), intent(in) :: cptot0(ka, ia, ja)
2336  real(rp), intent(in) :: cvtot0(ka, ia, ja)
2337  real(rp), intent(in) :: ccn (ka,ia,ja)
2338  real(rp), intent(in) :: dt
2339  real(rp), intent(in) :: cz( ka,ia,ja)
2340  real(rp), intent(in) :: fz(0:ka,ia,ja)
2341 
2342  real(rp),intent(out) :: rhoq_t(ka,ia,ja,qa_mp)
2343  real(rp),intent(out) :: rhoe_t(ka,ia,ja)
2344  real(rp),intent(out) :: cptot_t(ka,ia,ja)
2345  real(rp),intent(out) :: cvtot_t(ka,ia,ja)
2346 
2347  real(rp), intent(out) :: evaporate(ka,ia,ja) ! number of evaporated cloud [/m3/s]
2348 
2349  !--- for lightning
2350  logical, intent(in), optional :: flg_lt
2351  real(rp), intent(in), optional :: d0_crg, v0_crg
2352  real(rp), intent(in), optional :: dqcrg(ka,ia,ja)
2353  real(rp), intent(in), optional :: beta_crg(ka,ia,ja)
2354  real(rp), intent(in), optional :: qtrc_crg(ka,ia,ja,hydro_max)
2355  real(rp), intent(out), optional :: qsplt_in(ka,ia,ja,3)
2356  real(rp), intent(out), optional :: sarea(ka,ia,ja,hydro_max)
2357  real(rp), intent(out), optional :: rhoqcrg_t_mp(ka,ia,ja,hydro_max)
2358 
2359  real(rp) :: pres (ka)
2360  real(rp) :: temp (ka)
2361  real(rp) :: cva (ka)
2362  real(rp) :: cpa (ka)
2363  real(rp) :: rrho (ka)
2364  real(rp) :: rhoe (ka)
2365  real(rp) :: rhoq (ka,i_qv:i_ng)
2366  !
2367  real(rp) :: rhoq0_t (ka,qa_mp)
2368  real(rp) :: rhoe0_t (ka)
2369  real(rp) :: cptot0_t(ka)
2370  real(rp) :: cvtot0_t(ka)
2371  !
2372  real(rp) :: xq(ka,hydro_max)
2373  !
2374  real(rp) :: dq_xa(ka,hydro_max)
2375  real(rp) :: vt_xa(ka,hydro_max,2) ! terminal velocity
2376 
2377  real(rp) :: wtemp(ka) ! filtered temperature
2378  real(rp) :: esw (ka) ! saturated vapor pressure(water)
2379  real(rp) :: esi (ka) ! saturated vapor pressure(ice)
2380  !
2381  real(rp) :: log_rho_fac
2382  real(rp) :: log_rho_fac_q(ka,hydro_max) ! factor for tracers, 1:cloud, 2:rain, 3:ice, 4: snow, 5:graupel
2383  !
2384  real(rp) :: drhoqv ! d (rho*qv)
2385  real(rp) :: drhoqc, drhonc ! qc, nc
2386  real(rp) :: drhoqr, drhonr ! qr, nr
2387  real(rp) :: drhoqi, drhoni ! qi, ni
2388  real(rp) :: drhoqs, drhons ! qs, ns
2389  real(rp) :: drhoqg, drhong ! qg, ng
2390 
2391  real(rp) :: drhoqvhom ! d (rho*qv)
2392  real(rp) :: drhoqihom, drhonihom ! qi, ni
2393 
2394  ! production rate
2395  real(rp) :: pq(ka,pq_max)
2396  real(rp) :: wrm_dqc, wrm_dnc
2397  real(rp) :: wrm_dqr, wrm_dnr
2398 
2399  ! production rate of mixed-phase collection process
2400  real(rp) :: pac(ka,pac_max)
2401 
2402  real(rp) :: gc_dqc, gc_dnc
2403  real(rp) :: sc_dqc, sc_dnc
2404  real(rp) :: ic_dqc, ic_dnc
2405  real(rp) :: rg_dqg, rg_dng
2406  real(rp) :: rg_dqr, rg_dnr
2407  real(rp) :: rs_dqr, rs_dnr, rs_dqs, rs_dns
2408  real(rp) :: ri_dqr, ri_dnr
2409  real(rp) :: ri_dqi, ri_dni
2410  real(rp) :: ii_dqi, ii_dni
2411  real(rp) :: is_dqi, is_dni, ss_dns
2412  real(rp) :: gs_dqs, gs_dns, gg_dng
2413 
2414  ! mixed-phase collection process total plus(clp_), total minus(clm_)
2415  real(rp) :: clp_dqc, clp_dnc, clm_dqc, clm_dnc
2416  real(rp) :: clp_dqr, clp_dnr, clm_dqr, clm_dnr
2417  real(rp) :: clp_dqi, clp_dni, clm_dqi, clm_dni
2418  real(rp) :: clp_dqs, clp_dns, clm_dqs, clm_dns
2419  real(rp) :: clp_dqg, clp_dng, clm_dqg, clm_dng
2420  real(rp) :: fac1, fac3, fac4(ka), fac6(ka), fac7, fac9(ka)
2421 
2422  ! production rate of partial conversion(ice, snow => graupel)
2423  real(rp) :: pco_dqi, pco_dni
2424  real(rp) :: pco_dqs, pco_dns
2425  real(rp) :: pco_dqg, pco_dng
2426 
2427  ! production rate of enhanced melting due to
2428  real(rp) :: eml_dqc, eml_dnc
2429  real(rp) :: eml_dqr, eml_dnr
2430  real(rp) :: eml_dqi, eml_dni
2431  real(rp) :: eml_dqs, eml_dns
2432  real(rp) :: eml_dqg, eml_dng
2433 
2434  ! production rate of ice multiplication by splintering
2435  real(rp) :: spl_dqi, spl_dni
2436  real(rp) :: spl_dqg, spl_dqs
2437 
2438  !-----------------------------------------------
2439  ! work for explicit supersaturation modeling
2440  !-----------------------------------------------
2441  real(rp) :: dtdt_equiv_d(ka)
2442  real(rp) :: qsi(ka)
2443  real(rp) :: dtdt_dep(ka)
2444  real(rp) :: plidep_total(ka)
2445  !--------------------------------------------------
2446  !
2447  ! variables for output
2448  !
2449  !--------------------------------------------------
2450  ! work for column production term
2451  real(rp) :: sl_plcdep
2452  real(rp) :: sl_plrdep, sl_pnrdep
2453  !--------------------------------------------------
2454  real(rp) :: qke_d(ka)
2455 
2456  real(rp), parameter :: eps = 1.e-19_rp
2457  real(rp), parameter :: eps_qv = 1.e-19_rp
2458  real(rp), parameter :: eps_rhoe = 1.e-19_rp
2459  real(rp), parameter :: eps_rho = 1.e-19_rp
2460 
2461  ! for limitter
2462  real(rp) :: di2l, dtem
2463  real(rp) :: fact(ka)
2464 
2465  real(rp) :: sw
2466 
2467  integer :: k, i, j, iq
2468 
2469  real(rp) :: dqv, dql, dqi
2470  real(rp) :: dcv, dcp
2471  real(rp) :: dqvhom, dqihom
2472  real(rp) :: dcvhom, dcphom
2473 
2474  !---- for Lightning component
2475 ! logical, private, save :: MP_doice_graupel_collection = .false.
2476 ! real(RP), private :: flg_igcol = 0.0_RP
2477  !--- for Charge separation
2478  real(rp) :: v0_crg_l, d0_crg_l
2479  real(rp) :: dqcrg_l(ka)
2480  real(rp) :: beta_crg_l(ka)
2481  real(rp) :: facq(i_qc:i_qg), f_crg
2482  integer :: grid(2), pp, qq
2483  real(rp) :: drhoqcrg_c, drhoqcrg_r
2484  real(rp) :: drhoqcrg_i, drhoqcrg_s, drhoqcrg_g
2485 
2486  ! production rate of charge density
2487  real(rp) :: pcrg1(ka,pq_max)
2488  real(rp) :: pcrg2(ka,pcrg_max)
2489  real(rp) :: rhoq_crg(ka,i_qc:i_qg)
2490  real(rp) :: rhoqcrg0_t(ka,i_qc:i_qg)
2491  real(rp) :: qtrc0(ka,qa_mp)
2492  real(rp) :: crs(ka,hydro_max)
2493 
2494  real(rp) :: crg_split_s
2495  real(rp) :: crg_split_g
2496  real(rp) :: crg_split_i
2497  real(rp) :: wrm_dnc_crg
2498  real(rp) :: wrm_dnr_crg
2499  real(rp) :: gc_dnc_crg
2500  real(rp) :: sc_dnc_crg
2501  real(rp) :: ic_dnc_crg
2502  real(rp) :: rg_dng_crg
2503  real(rp) :: rg_dnr_crg
2504  real(rp) :: rs_dnr_crg
2505  real(rp) :: rs_dns_crg
2506  real(rp) :: ri_dnr_crg
2507  real(rp) :: ri_dni_crg
2508  real(rp) :: ii_dni_crg
2509  real(rp) :: is_dni_crg
2510  real(rp) :: ss_dns_crg
2511  real(rp) :: gs_dns_crg
2512  real(rp) :: gi_dni_crg
2513  real(rp) :: gg_dng_crg
2514  ! mixed-phase collection process total plus(clp_), total minus(clm_)
2515  real(rp) :: clp_dnc_crg, clm_dnc_crg
2516  real(rp) :: clp_dnr_crg, clm_dnr_crg
2517  real(rp) :: clp_dni_crg, clm_dni_crg
2518  real(rp) :: clp_dns_crg, clm_dns_crg
2519  real(rp) :: clp_dng_crg, clm_dng_crg
2520  ! production rate of partial conversion(ice, snow => graupel)
2521  real(rp) :: pco_dni_crg
2522  real(rp) :: pco_dns_crg
2523  real(rp) :: pco_dng_crg
2524  ! production rate of enhanced melting due to
2525  real(rp) :: eml_dnc_crg
2526  real(rp) :: eml_dnr_crg
2527  real(rp) :: eml_dni_crg
2528  real(rp) :: eml_dns_crg
2529  real(rp) :: eml_dng_crg
2530  ! production rate of ice multiplication by splintering
2531  real(rp) :: spl_dni_crg
2532  real(rp) :: spl_dns_crg
2533  real(rp) :: spl_dng_crg
2534  real(rp) :: rate1
2535  logical :: flg_lt_l
2536 
2537  real(rp) :: sw1, sw2
2538  real(rp) :: tmp
2539  integer :: ip
2540 
2541  logical :: hist_sw(w_nmax)
2542  !---------------------------------------------------------------------------
2543 
2544  if ( present(flg_lt) ) then
2545  flg_lt_l = flg_lt
2546  else
2547  flg_lt_l = .false.
2548  end if
2549 
2550 
2551  !--- Lightning component is on
2552  if( flg_lt_l ) then
2553 ! flg_igcol = 0.0_RP
2554  d0_crg_l = d0_crg
2555  v0_crg_l = v0_crg
2556 
2557  !$omp workshare
2558 !OCL ZFILL
2559  qsplt_in(:,:,:,:) = 0.0_rp
2560 !OCL ZFILL
2561  rhoqcrg_t_mp(:,:,:,:) = 0.0_rp
2562  !$omp end workshare
2563 
2564 ! if( MP_doice_graupel_collection ) then
2565 ! flg_igcol = 1.0_RP
2566 ! else
2567 ! write(*,*) 'xxx MP_doice_graupel_collection should be true for TK78 Stop!'
2568 ! call PRC_MPIstop
2569 ! flg_igcol = 0.0_RP
2570 ! endif
2571  else
2572  d0_crg_l = 1.0_rp
2573  v0_crg_l = 1.0_rp
2574  endif
2575 
2576  do ip = 1, w_nmax
2577  call file_history_query( hist_id(ip), hist_sw(ip) )
2578  end do
2579 
2580  !$omp parallel do default(none) &
2581  !$omp shared(KA,KS,KE,IS,IE,JS,JE, &
2582  !$omp CP_VAPOR,CP_WATER,CP_ICE,CV_VAPOR,CV_WATER,CV_ICE,LHV,LHF,LHF0, &
2583  !$omp MP_doautoconversion, &
2584  !$omp DENS,W,QTRC,TEMP0,PRES0,QDRY,CPtot0,CVtot0,CCN, &
2585  !$omp cz,fz,dt, &
2586  !$omp RHOQ_t,RHOE_t,CPtot_t,CVtot_t,EVAPORATE, &
2587  !$omp c_ccn,gamma_v,nc_uplim_d,a_m,b_m,alpha_v,log_alpha_v,beta_v,log_beta_v,a_rea,b_rea, &
2588  !$omp ntmax_phase_change, &
2589  !$omp opt_collection_bin,opt_nucleation_ice_hom,so22_het, &
2590  !$omp w3d,HIST_sw,HIST_idx, &
2591  !$omp QTRC_crg,QSPLT_in,RHOQcrg_t_mp,Sarea, &
2592  !$omp d0_crg_l,v0_crg_l,beta_crg,dqcrg,flg_lt_l) &
2593  !$omp private (pres,temp,rrho,rhoe,rhoq,cva,cpa,rhoq0_t,rhoe0_t,cptot0_t,cvtot0_t, &
2594  !$omp xq,dq_xa,vt_xa,wtemp,esw,esi,log_rho_fac,log_rho_fac_q, &
2595  !$omp drhoqv,drhoqc,drhonc,drhoqr,drhonr,drhoqi,drhoni,drhoqs,drhons,drhoqg,drhong, &
2596  !$omp PQ,Pac,wrm_dqc,wrm_dnc,wrm_dqr,wrm_dnr, &
2597  !$omp gc_dqc,gc_dnc,sc_dqc,sc_dnc,ic_dqc,ic_dnc, &
2598  !$omp rg_dqg,rg_dng,rg_dqr,rg_dnr,rs_dqr,rs_dnr,rs_dqs,rs_dns,ri_dqr,ri_dnr,ri_dqi,ri_dni, &
2599  !$omp ii_dqi,ii_dni,is_dqi,is_dni,ss_dns,gs_dqs,gs_dns,gg_dng, &
2600  !$omp clp_dqc,clp_dnc,clm_dqc,clm_dnc,clp_dqr,clp_dnr,clm_dqr,clm_dnr, &
2601  !$omp clp_dqi,clp_dni,clm_dqi,clm_dni,clp_dqs,clp_dns,clm_dqs,clm_dns,clp_dqg,clp_dng,clm_dqg,clm_dng, &
2602  !$omp dqvhom, dqihom,dcvhom,dcphom,drhoqvhom,drhoqihom,drhonihom, &
2603  !$omp rhoq_crg,RHOQcrg0_t,Pcrg1,Pcrg2, &
2604  !$omp drhoqcrg_c,drhoqcrg_r,drhoqcrg_i,drhoqcrg_s,drhoqcrg_g, &
2605  !$omp crg_split_s,crg_split_g,crg_split_i,wrm_dnc_crg,wrm_dnr_crg,QTRC0,crs, &
2606  !$omp gc_dnc_crg,sc_dnc_crg,ic_dnc_crg,rg_dng_crg,rg_dnr_crg,rs_dnr_crg,rs_dns_crg,ri_dnr_crg,ri_dni_crg, &
2607  !$omp ii_dni_crg,is_dni_crg,ss_dns_crg,gs_dns_crg,gi_dni_crg,gg_dng_crg, &
2608  !$omp clp_dnc_crg,clm_dnc_crg,clp_dnr_crg,clm_dnr_crg,clp_dni_crg,clm_dni_crg,clp_dns_crg,clm_dns_crg,clp_dng_crg,clm_dng_crg, &
2609  !$omp pco_dni_crg,pco_dns_crg,pco_dng_crg,eml_dnc_crg,eml_dnr_crg,eml_dni_crg,eml_dns_crg,eml_dng_crg,spl_dni_crg,spl_dns_crg,spl_dng_crg, &
2610  !$omp fac1,fac3,fac4,fac6,fac7,fac9, &
2611  !$omp pco_dqi,pco_dni,pco_dqs,pco_dns,pco_dqg,pco_dng, &
2612  !$omp eml_dqc,eml_dnc,eml_dqr,eml_dnr,eml_dqi,eml_dni,eml_dqs,eml_dns,eml_dqg,eml_dng, &
2613  !$omp spl_dqi,spl_dni,spl_dqg,spl_dqs, &
2614  !$omp dTdt_equiv_d,sl_PLCdep,sl_PLRdep,sl_PNRdep,qke_d, &
2615  !$omp beta_crg_l,dqcrg_l, &
2616  !$omp dqv,dql,dqi,dcv,dcp, &
2617  !$omp di2l,dtem,fact,sw,sw1,sw2,tmp)
2618  do j = js, je
2619  do i = is, ie
2620 
2621  ! total tendency
2622  do k = ks, ke
2623  rhoq_t(k,i,j,:) = 0.0_rp
2624  rhoe_t(k,i,j) = 0.0_rp
2625  cptot_t(k,i,j) = 0.0_rp
2626  cvtot_t(k,i,j) = 0.0_rp
2627  end do
2628 
2629  ! intermidiate variable
2630  do k = ks, ke
2631  cpa(k) = cptot0(k,i,j)
2632  cva(k) = cvtot0(k,i,j)
2633  pres(k) = pres0(k,i,j)
2634  temp(k) = temp0(k,i,j)
2635  enddo
2636 
2637  !============================================================================
2638  !
2639  !-- Each process is integrated sequentially.
2640  ! 1. Nucleation and filter
2641  ! 2. Phase change
2642  ! 3. Collection
2643  !
2644  !============================================================================
2645 
2646  do iq = i_qv, i_ng
2647  do k = ks, ke
2648  rhoq(k,iq) = dens(k,i,j) * qtrc(k,i,j,iq)
2649  enddo
2650  enddo
2651 
2652  do k = ks, ke
2653  log_rho_fac = log(rho_0 / max(dens(k,i,j),rho_min))
2654  log_rho_fac_q(k,i_mp_qc) = log_rho_fac * gamma_v(i_mp_qc)
2655  log_rho_fac_q(k,i_mp_qr) = log_rho_fac * gamma_v(i_mp_qr)
2656  end do
2657 
2658  if( so22_het .or. opt_nucleation_ice_hom) then
2659 
2660  do k = ks, ke
2661  log_rho_fac_q(k,i_mp_qi) = log(pres(k)/pre0_vt) * a_pre0_vt + log(temp(k)/tem0_vt) * a_tem0_vt
2662  log_rho_fac_q(k,i_mp_qs) = log_rho_fac_q(k,i_mp_qi)
2663  log_rho_fac_q(k,i_mp_qg) = log_rho_fac_q(k,i_mp_qi)
2664  enddo
2665 
2666  call get_terminal_velocity( &
2667  ka, ks, ke, &
2668  vt_xa(:,:,:), xq(:,:), & ! (out)
2669  rhoq(:,:), & ! (in)
2670  log_rho_fac_q(:,:) ) ! (in)
2671 
2672  call get_diamiter( &
2673  ka, ks, ke, &
2674  dq_xa(:,:), & ! (out)
2675  xq(:,:) ) ! (in)
2676 
2677  endif
2678 
2679  !----------------------------------------------------------------------------
2680  !
2681  ! 1.Nucleation of cloud water and cloud ice
2682  !
2683  !----------------------------------------------------------------------------
2684  do k = ks, ke
2685  rrho(k) = 1.0_rp / dens(k,i,j)
2686  rhoe(k) = dens(k,i,j) * temp(k) * cva(k)
2687  wtemp(k) = max(temp(k), tem_min)
2688  enddo
2689 
2690 #ifdef DEBUG
2691  call debug_tem( ka, ks, ke, &
2692  1, i, j, temp(:), dens(:,i,j), pres(:), qtrc(:,i,j,i_qv) )
2693 #endif
2694 
2695  do k = ks, ke
2696  log_rho_fac_q(k,i_mp_qi) = log(pres(k)/pre0_vt) * a_pre0_vt + log(temp(k)/tem0_vt) * a_tem0_vt
2697  log_rho_fac_q(k,i_mp_qs) = log_rho_fac_q(k,i_mp_qi)
2698  log_rho_fac_q(k,i_mp_qg) = log_rho_fac_q(k,i_mp_qi)
2699  enddo
2700 
2701  sl_plcdep = 0.0_rp
2702  sl_plrdep = 0.0_rp
2703  sl_pnrdep = 0.0_rp
2704 
2705 !OCL XFILL
2706  do k = ks, ke
2707  qke_d(k) = 0.0_rp ! 2*TKE
2708  enddo
2709 
2710 !OCL XFILL
2711  do k = ks, ke
2712  dtdt_equiv_d(k) = 0.0_rp
2713  enddo
2714 
2715 ! nc_uplim_d(1) = c_ccn_map(1,i,j)*1.5_RP
2716  nc_uplim_d(1,i,j) = c_ccn*1.5_rp
2717 
2718 
2719  call nucleation( &
2720  ka, ks, ke, &
2721  cz(:,i,j), fz(:,i,j), & ! (in)
2722  w(:,i,j), dens(:,i,j), & ! (in)
2723  wtemp(:), pres(:), qdry(:,i,j), & ! (in)
2724  rhoq(:,:), cpa(:), cva(:), & ! (in)
2725  dtdt_equiv_d(:), & ! (in)
2726  qke_d(:), & ! (in)
2727  ccn(:,i,j), nc_uplim_d(1,i,j), & ! (in)
2728  dt, & ! (in)
2729  dq_xa, vt_xa, & ! (in)
2730  pq(:,:) ) ! (out)
2731 
2732 
2733  if( opt_nucleation_ice_hom ) then
2734 
2735  ! homogeneous ice nucleation
2736  do k = ks, ke
2737  drhoqihom = pq(k,i_lihom)
2738  tmp = - drhoqihom
2739  drhoqvhom = max( - rhoq(k,i_qv) / dt , tmp )
2740  fac1 = drhoqvhom / min( tmp, -eps ) ! drhoqc and drhoqi must be >= 0, otherwise fac1 can be artificially huge value.
2741 
2742  drhoqihom = drhoqihom * fac1
2743 
2744  rhoq0_t(k,i_qv) = drhoqvhom
2745  rhoq0_t(k,i_qi) = drhoqihom
2746 
2747  rhoe0_t(k) = - lhv * drhoqvhom + lhf * drhoqihom
2748 
2749  dqvhom = rrho(k) * drhoqvhom
2750  dqihom = rrho(k) * drhoqihom
2751 
2752  dcvhom = cv_vapor * dqvhom + cv_ice * dqihom
2753  dcphom = cp_vapor * dqvhom + cp_ice * dqihom
2754 
2755  cvtot0_t(k) = dcvhom
2756  cptot0_t(k) = dcphom
2757 
2758  drhonihom = pq(k,i_nihom) * fac1
2759  rhoq0_t(k,i_ni) = drhonihom
2760  end do
2761 
2762  ! total tendency
2763  do k = ks, ke
2764  rhoe_t(k,i,j) = rhoe_t(k,i,j) + rhoe0_t(k)
2765  cvtot_t(k,i,j) = cvtot_t(k,i,j) + cvtot0_t(k)
2766  cptot_t(k,i,j) = cptot_t(k,i,j) + cptot0_t(k)
2767  enddo
2768 
2769  ! update intermidiate variable
2770  do k = ks, ke
2771  rhoq(k,i_qv) = rhoq(k,i_qv) + rhoq0_t(k,i_qv)*dt
2772  rhoq(k,i_qi) = max(0.0_rp, rhoq(k,i_qi) + rhoq0_t(k,i_qi)*dt )
2773  rhoq(k,i_ni) = max(0.0_rp, rhoq(k,i_ni) + rhoq0_t(k,i_ni)*dt )
2774  enddo
2775 
2776  do k = ks, ke
2777  rhoe(k) = rhoe(k) + rhoe0_t(k)*dt
2778  cva(k) = cva(k) + cvtot0_t(k)*dt
2779  cpa(k) = cpa(k) + cptot0_t(k)*dt
2780 
2781  temp(k) = rhoe(k) / ( dens(k,i,j) * cva(k) )
2782  pres(k) = dens(k,i,j) * (cpa(k)-cva(k)) * temp(k)
2783  wtemp(k) = max( temp(k), tem_min )
2784  enddo
2785 
2786  endif
2787 
2788  ! nucleation
2789  do k = ks, ke
2790  drhoqc = pq(k,i_lcccn)
2791  drhoqi = pq(k,i_liccn)
2792  tmp = - drhoqc - drhoqi
2793  drhoqv = max( - rhoq(k,i_qv) / dt, tmp )
2794 
2795  ! limiting coefficient
2796  fac1 = drhoqv / min( tmp, -eps ) ! drhoqc and drhoqi must be >= 0, otherwise fac1 can be artificially huge value.
2797 
2798  drhoqc = drhoqc * fac1
2799  drhoqi = drhoqi * fac1
2800 
2801  rhoq0_t(k,i_qv) = drhoqv
2802  rhoq0_t(k,i_qc) = drhoqc
2803  rhoq0_t(k,i_qi) = drhoqi
2804 
2805  rhoe0_t(k) = - lhv * drhoqv + lhf * drhoqi
2806 
2807  dqv = rrho(k) * drhoqv
2808  dql = rrho(k) * drhoqc
2809  dqi = rrho(k) * drhoqi
2810 
2811  dcv = cv_vapor * dqv + cv_water * dql + cv_ice * dqi
2812  dcp = cp_vapor * dqv + cp_water * dql + cp_ice * dqi
2813 
2814  cvtot0_t(k) = dcv
2815  cptot0_t(k) = dcp
2816 
2817  drhonc = pq(k,i_ncccn) * fac1
2818  drhoni = pq(k,i_niccn) * fac1
2819  rhoq0_t(k,i_nc) = drhonc
2820  rhoq0_t(k,i_ni) = drhoni
2821  end do
2822 
2823  ! total tendency
2824  do k = ks, ke
2825  rhoe_t(k,i,j) = rhoe_t(k,i,j) + rhoe0_t(k)
2826  cvtot_t(k,i,j) = cvtot_t(k,i,j) + cvtot0_t(k)
2827  cptot_t(k,i,j) = cptot_t(k,i,j) + cptot0_t(k)
2828  enddo
2829 
2830  ! update intermidiate variable
2831  do k = ks, ke
2832  rhoq(k,i_qv) = rhoq(k,i_qv) + rhoq0_t(k,i_qv)*dt
2833  rhoq(k,i_qc) = max(0.0_rp, rhoq(k,i_qc) + rhoq0_t(k,i_qc)*dt )
2834  rhoq(k,i_qi) = max(0.0_rp, rhoq(k,i_qi) + rhoq0_t(k,i_qi)*dt )
2835  rhoq(k,i_nc) = max(0.0_rp, rhoq(k,i_nc) + rhoq0_t(k,i_nc)*dt )
2836  rhoq(k,i_ni) = max(0.0_rp, rhoq(k,i_ni) + rhoq0_t(k,i_ni)*dt )
2837 
2838  ! cloud number concentration filter
2839  rhoq(k,i_nc) = min( rhoq(k,i_nc), nc_uplim_d(1,i,j) )
2840  end do
2841 
2842  do k = ks, ke
2843  rhoe(k) = rhoe(k) + rhoe0_t(k)*dt
2844  cva(k) = cva(k) + cvtot0_t(k)*dt
2845  cpa(k) = cpa(k) + cptot0_t(k)*dt
2846 
2847  temp(k) = rhoe(k) / ( dens(k,i,j) * cva(k) )
2848  pres(k) = dens(k,i,j) * (cpa(k)-cva(k)) * temp(k)
2849  wtemp(k) = max( temp(k), tem_min )
2850  enddo
2851 
2852 
2853 #ifdef DEBUG
2854  call debug_tem( ka, ks, ke, &
2855  2, i, j, temp(:), dens(:,i,j), pres(:), qtrc(:,i,j,i_qv) )
2856 #endif
2857 
2858 
2859  !----------------------------------------------------------------------------
2860  !
2861  ! 2.Phase change: Freezing, Melting, Vapor deposition
2862  !
2863  !----------------------------------------------------------------------------
2864  call get_terminal_velocity( &
2865  ka, ks, ke, &
2866  vt_xa(:,:,:), xq(:,:), & ! (out)
2867  rhoq(:,:), & ! (in)
2868  log_rho_fac_q(:,:) ) ! (in)
2869 
2870  call get_diamiter( &
2871  ka, ks, ke, &
2872  dq_xa(:,:), & ! (out)
2873  xq(:,:) ) ! (in)
2874 
2875  if (flg_lt_l) then
2876  do iq = i_qc, i_qg
2877  do k = ks, ke
2878  rhoq_crg(k,iq) = dens(k,i,j) * qtrc_crg(k,i,j,iq-1)
2879  enddo
2880  enddo
2881  end if
2882 
2883  call moist_psat_liq( ka, ks, ke, &
2884  wtemp(:), esw(:) ) ! [IN], [OUT]
2885  call moist_psat_ice( ka, ks, ke, &
2886  wtemp(:), esi(:) ) ! [IN], [OUT]
2887 
2888  call freezing_water( &
2889  ka, ks, ke, &
2890  dt, & ! (in)
2891  rhoq(:,:), xq(:,:), temp(:), & ! (in)
2892  pq(:,:) ) ! (inout)
2893 
2894  call dep_vapor_melt_ice( &
2895  ka, ks, ke, &
2896  dens(:,i,j), wtemp(:), pres(:), qdry(:,i,j), rhoq(:,:), & ! (in)
2897  esw(:), esi(:), xq(:,:), vt_xa(:,:,:), dq_xa(:,:), & ! (in)
2898  pq(:,:) ) ! (inout)
2899 
2900  !
2901  ! update subroutine
2902  !
2903  call update_by_phase_change( &
2904  ka, ks, ke, &
2905  ntmax_phase_change, dt, & ! (in)
2906  cz(:,i,j), fz(:,i,j), & ! (in)
2907  w(:,i,j), & ! (in)
2908  dtdt_equiv_d(:), & ! (in)
2909  dens(:,i,j), qdry(:,i,j), & ! (in)
2910  esw(:), esi(:), & ! (in)
2911  rhoq(:,:), pres(:), temp(:), & ! (in)
2912  cpa(:), cva(:), & ! (in)
2913  flg_lt_l, & ! (in)
2914  pq(:,:), & ! (inout)
2915  sl_plcdep, sl_plrdep, sl_pnrdep, & ! (inout)
2916  rhoq0_t(:,:), rhoe0_t(:), & ! (out)
2917  cptot0_t(:), cvtot0_t(:), & ! (out)
2918  evaporate(:,i,j), & ! (out)
2919  rhoq_crg(:,:), & ! (in:optional)
2920  rhoqcrg0_t(:,:) ) ! (out:optional)
2921 
2922  ! total tendency
2923  do k = ks, ke
2924  rhoe_t(k,i,j) = rhoe_t(k,i,j) + rhoe0_t(k)
2925  cvtot_t(k,i,j) = cvtot_t(k,i,j) + cvtot0_t(k)
2926  cptot_t(k,i,j) = cptot_t(k,i,j) + cptot0_t(k)
2927  enddo
2928 
2929  ! update intermidiate variable
2930  do iq = 1, qa_mp
2931  do k = ks, ke
2932  rhoq(k,iq) = max(0.0_rp, rhoq(k,iq) + rhoq0_t(k,iq)*dt )
2933  enddo
2934  enddo
2935 
2936  do k = ks, ke
2937  rhoe(k) = rhoe(k) + rhoe0_t(k)*dt
2938  cva(k) = cva(k) + cvtot0_t(k)*dt
2939  cpa(k) = cpa(k) + cptot0_t(k)*dt
2940  temp(k) = rhoe(k) / ( dens(k,i,j) * cva(k) )
2941  pres(k) = dens(k,i,j) * ( cpa(k) - cva(k) ) * temp(k)
2942  enddo
2943 
2944  if (flg_lt_l) then
2945  do iq = i_qc, i_qg
2946  do k = ks, ke
2947  rhoq_crg(k,iq) = rhoq_crg(k,iq) + rhoqcrg0_t(k,iq) * dt ! need limiter?
2948  enddo
2949  enddo
2950  end if
2951 
2952 #ifdef DEBUG
2953  call debug_tem( ka, ks, ke, &
2954  3, i, j, temp(:), dens(:,i,j), pres(:), qtrc(:,i,j,i_qv) )
2955 #endif
2956 
2957  !---------------------------------------------------------------------------
2958  !
2959  ! 3.Collection process
2960  !
2961  !---------------------------------------------------------------------------
2962 
2963  ! parameter setting
2964 
2965  call get_terminal_velocity( &
2966  ka, ks, ke, &
2967  vt_xa(:,:,:), xq(:,:), & ! (out)
2968  rhoq(:,:), & ! (in)
2969  log_rho_fac_q(:,:) ) ! (in)
2970 
2971  ! effective cross section is assume as area equivalent circle
2972  do k = ks, ke
2973  dq_xa(k,i_mp_qc) = 2.0_rp*a_rea(i_mp_qc)*xq(k,i_mp_qc)**b_rea(i_mp_qc)
2974  dq_xa(k,i_mp_qr) = 2.0_rp*a_rea(i_mp_qr)*xq(k,i_mp_qr)**b_rea(i_mp_qr)
2975  dq_xa(k,i_mp_qi) = 2.0_rp*a_rea(i_mp_qi)*xq(k,i_mp_qi)**b_rea(i_mp_qi)
2976  dq_xa(k,i_mp_qs) = 2.0_rp*a_rea(i_mp_qs)*xq(k,i_mp_qs)**b_rea(i_mp_qs)
2977  dq_xa(k,i_mp_qg) = 2.0_rp*a_rea(i_mp_qg)*xq(k,i_mp_qg)**b_rea(i_mp_qg)
2978  end do
2979 
2980  pcrg1(:,:) = 0.0_rp
2981  pcrg2(:,:) = 0.0_rp
2982 
2983  ! Auto-conversion, Accretion, Self-collection, Break-up
2984  if ( mp_doautoconversion ) then
2985  call aut_acc_slc_brk( &
2986  ka, ks, ke, &
2987  flg_lt_l, & ! (in)
2988  rhoq(:,:), & ! (in)
2989  rhoq_crg(:,:), & ! (in)
2990  xq(:,:), dq_xa(:,:), & ! (in)
2991  dens(:,i,j), & ! (in)
2992  pq(:,:), & ! (in)
2993  pcrg1(:,:) ) ! (inout)
2994 
2995  else
2996 !OCL XFILL
2997  do k = ks, ke
2998  pq(k,i_lcaut) = 0.0_rp
2999  pq(k,i_ncaut) = 0.0_rp
3000  pq(k,i_nraut) = 0.0_rp
3001  pq(k,i_lcacc) = 0.0_rp
3002  pq(k,i_ncacc) = 0.0_rp
3003  pq(k,i_nrslc) = 0.0_rp
3004  pq(k,i_nrbrk) = 0.0_rp
3005  !--- for lightning
3006  pcrg1(k,i_lcaut) = 0.0_rp
3007  pcrg1(k,i_ncaut) = 0.0_rp
3008  pcrg1(k,i_nraut) = 0.0_rp
3009  pcrg1(k,i_lcacc) = 0.0_rp
3010  pcrg1(k,i_ncacc) = 0.0_rp
3011  pcrg1(k,i_nrslc) = 0.0_rp
3012  pcrg1(k,i_nrbrk) = 0.0_rp
3013  end do
3014  endif
3015 
3016  if ( flg_lt_l ) then
3017  do k = ks, ke
3018  beta_crg_l(k) = beta_crg(k,i,j)
3019  dqcrg_l(k) = dqcrg(k,i,j)
3020  end do
3021  end if
3022 
3023  ! collection process
3024  if( opt_collection_bin ) then
3026  ka, ks, ke, & ! (in)
3027  flg_lt_l, & ! (in)
3028  d0_crg_l, v0_crg_l, & ! (in)
3029  beta_crg_l(:), dqcrg_l(:), & ! (in)
3030  temp(:), rhoq(:,:), & ! (in)
3031  rhoq_crg(:,:), & ! (in)
3032  xq(:,:), dq_xa(:,:), vt_xa(:,:,:), & ! (in)
3033  dens(:,i,j), & ! (in)
3034  pq(:,:), & ! (inout)
3035  pcrg1(:,:), & ! (inout)
3036  pcrg2(:,:), & ! (inout)
3037  pac(:,:) ) ! (out)
3038  else
3039  call mixed_phase_collection( &
3040  ka, ks, ke, & ! (in)
3041  flg_lt_l, & ! (in)
3042  d0_crg_l, v0_crg_l, & ! (in)
3043  beta_crg_l(:), dqcrg_l(:), & ! (in)
3044  temp(:), rhoq(:,:), & ! (in)
3045  rhoq_crg(:,:), & ! (in)
3046  xq(:,:), dq_xa(:,:), vt_xa(:,:,:), & ! (in)
3047  pq(:,:), & ! (inout)
3048  pcrg1(:,:), & ! (inout)
3049  pcrg2(:,:), & ! (inout)
3050  pac(:,:) ) ! (out)
3051  endif
3052 
3053 
3054  call ice_multiplication( &
3055  ka, ks, ke, & ! (in)
3056  flg_lt_l, & ! (in)
3057  pac(:,:), & ! (in)
3058  temp(:), rhoq(:,:), & ! (in)
3059  rhoq_crg(:,:), & ! (in)
3060  xq(:,:), & ! (in)
3061  pq(:,:), & ! (inout)
3062  pcrg1(:,:) ) ! (inout)
3063 
3064  !
3065  ! update
3066  !
3067 !OCL LOOP_FISSION_TARGET(LS)
3068  do k = ks, ke
3069  ! warm collection process
3070  wrm_dqc = max( dt*( pq(k,i_lcaut)+pq(k,i_lcacc) ), -rhoq(k,i_qc) )
3071  wrm_dnc = max( dt*( pq(k,i_ncaut)+pq(k,i_ncacc) ), -rhoq(k,i_nc) )
3072  wrm_dnr = max( dt*( pq(k,i_nraut)+pq(k,i_nrslc)+pq(k,i_nrbrk) ), -rhoq(k,i_nr) )
3073  wrm_dqr = -wrm_dqc
3074 
3075  ! mixed phase collection
3076  ! Pxxacyy2zz xx and yy decrease and zz increase .
3077  !
3078  ! At first fixer is applied to decreasing particles.
3079  ! order of fixer: graupel-cloud, snow-cloud, ice-cloud, graupel-rain, snow-rain, ice-rain,
3080  ! snow-ice, ice-ice, graupel-snow, snow-snow
3081  ! cloud mass decrease
3082  gc_dqc = max( dt*pac(k,i_lgaclc2lg), min(0.0_rp, -rhoq(k,i_qc)-wrm_dqc )) ! => dqg
3083  sc_dqc = max( dt*pac(k,i_lsaclc2ls), min(0.0_rp, -rhoq(k,i_qc)-wrm_dqc-gc_dqc )) ! => dqs
3084  ic_dqc = max( dt*pac(k,i_liaclc2li), min(0.0_rp, -rhoq(k,i_qc)-wrm_dqc-gc_dqc-sc_dqc )) ! => dqi
3085  ! cloud num. decrease
3086  gc_dnc = max( dt*pac(k,i_ngacnc2ng), min(0.0_rp, -rhoq(k,i_nc)-wrm_dnc )) ! => dnc:minus
3087  sc_dnc = max( dt*pac(k,i_nsacnc2ns), min(0.0_rp, -rhoq(k,i_nc)-wrm_dnc-gc_dnc )) ! => dnc:minus
3088  ic_dnc = max( dt*pac(k,i_niacnc2ni), min(0.0_rp, -rhoq(k,i_nc)-wrm_dnc-gc_dnc-sc_dnc )) ! => dnc:minus
3089 
3090  ! rain mass decrease ( tem < 273.15K)
3091  sw = sign(0.5_rp, t00-temp(k)) + 0.5_rp ! if( temp(k,i,j) <= T00 )then sw=1, else sw=0
3092  rg_dqr = max( dt*pac(k,i_lraclg2lg ), min(0.0_rp, -rhoq(k,i_qr)-wrm_dqr )) * sw
3093  rg_dqg = max( dt*pac(k,i_lraclg2lg ), min(0.0_rp, -rhoq(k,i_qg) )) * ( 1.0_rp - sw )
3094  rs_dqr = max( dt*pac(k,i_lracls2lg_r), min(0.0_rp, -rhoq(k,i_qr)-wrm_dqr-rg_dqr )) * sw
3095  ri_dqr = max( dt*pac(k,i_lracli2lg_r), min(0.0_rp, -rhoq(k,i_qr)-wrm_dqr-rg_dqr-rs_dqr )) * sw
3096 
3097  ! rain num. decrease
3098  rg_dnr = max( dt*pac(k,i_nracng2ng ), min(0.0_rp, -rhoq(k,i_nr)-wrm_dnr )) * sw
3099  rg_dng = max( dt*pac(k,i_nracng2ng ), min(0.0_rp, -rhoq(k,i_ng) )) * ( 1.0_rp - sw )
3100  rs_dnr = max( dt*pac(k,i_nracns2ng_r), min(0.0_rp, -rhoq(k,i_nr)-wrm_dnr-rg_dnr )) * sw
3101  ri_dnr = max( dt*pac(k,i_nracni2ng_r), min(0.0_rp, -rhoq(k,i_nr)-wrm_dnr-rg_dnr-rs_dnr )) * sw
3102 
3103  ! ice mass decrease
3104  fac1 = (ri_dqr-eps)/ (dt*pac(k,i_lracli2lg_r)-eps) ! suppress factor by filter of rain
3105  ri_dqi = max( dt*pac(k,i_lracli2lg_i)*fac1, min(0.0_rp, -rhoq(k,i_qi)+ic_dqc )) ! => dqg
3106  ii_dqi = max( dt*pac(k,i_liacli2ls ) , min(0.0_rp, -rhoq(k,i_qi)+ic_dqc-ri_dqi )) ! => dqs
3107  is_dqi = max( dt*pac(k,i_liacls2ls ) , min(0.0_rp, -rhoq(k,i_qi)+ic_dqc-ri_dqi-ii_dqi )) ! => dqs
3108 !! !-- Y.Sato added(2018/8/31)
3109 !! gi_dqi = max( dt*Pac(k,I_LGacLI2LG) , min(0.0_RP, -rhoq(k,I_QI)+ic_dqc-ri_dqi-ii_dqi-is_dqi )) ! => dqg
3110 
3111  ! ice num. decrease
3112  fac4(k) = (ri_dnr-eps)/ (dt*pac(k,i_nracni2ng_r)-eps) ! suppress factor by filter of rain
3113  ri_dni = max( dt*pac(k,i_nracni2ng_i)*fac4(k), min(0.0_rp, -rhoq(k,i_ni) )) ! => dni:minus
3114  ii_dni = max( dt*pac(k,i_niacni2ns ) , min(0.0_rp, -rhoq(k,i_ni)-ri_dni )) ! => dni:minus,dns:plus(*0.5)
3115  is_dni = max( dt*pac(k,i_niacns2ns ) , min(0.0_rp, -rhoq(k,i_ni)-ri_dni-ii_dni )) ! => dni:minus,dns:plus
3116 !! !-- Y.Sato added(2018/8/31)
3117 !! gi_dni = max( dt*Pac(k,I_NGacNI2NG) , min(0.0_RP, -rhoq(k,I_NI)-ri_dni-ii_dni-is_dni )) ! => dns:minus
3118 
3119  ! snow mass decrease
3120  fac3 = (rs_dqr-eps)/(dt*pac(k,i_lracls2lg_r)-eps) ! suppress factor by filter of rain
3121  rs_dqs = max( dt*pac(k,i_lracls2lg_s)*fac3, min(0.0_rp, -rhoq(k,i_qs)+sc_dqc+ii_dqi+is_dqi )) ! => dqg
3122  gs_dqs = max( dt*pac(k,i_lgacls2lg ) , min(0.0_rp, -rhoq(k,i_qs)+sc_dqc+ii_dqi+is_dqi-rs_dqs )) ! => dqg
3123  ! snow num. decrease
3124  fac6(k) = (rs_dnr-eps)/(dt*pac(k,i_nracns2ng_r)-eps) ! suppress factor by filter of rain
3125  ! fac7 = (is_dni-eps)/(dt*Pac(I_NIacNS2NS, k,i,j)-eps) ! suppress factor by filter of ice
3126  rs_dns = max( dt*pac(k,i_nracns2ng_s)*fac6(k), min(0.0_rp, -rhoq(k,i_ns)+0.50_rp*ii_dni+is_dni )) ! => dns:minus
3127  gs_dns = max( dt*pac(k,i_ngacns2ng ) , min(0.0_rp, -rhoq(k,i_ns)+0.50_rp*ii_dni+is_dni-rs_dns )) ! => dns:minus
3128  ss_dns = max( dt*pac(k,i_nsacns2ns ) , min(0.0_rp, -rhoq(k,i_ns)+0.50_rp*ii_dni+is_dni-rs_dns-gs_dns ))
3129  gg_dng = max( dt*pac(k,i_ngacng2ng ) , min(0.0_rp, -rhoq(k,i_ng) ))
3130 
3131  ! total plus in mixed phase collection(clp_)
3132  ! mass
3133  ! if( temp(k,i,j) <= T00 )then sw=1, else sw=0
3134  clp_dqc = 0.0_rp
3135  clp_dqr = (-rg_dqg-rs_dqs-ri_dqi) * (1.0_rp-sw)
3136  clp_dqi = -ic_dqc
3137  clp_dqs = -sc_dqc-ii_dqi-is_dqi
3138  clp_dqg = -gc_dqc -gs_dqs + (-rg_dqr-rs_dqr-rs_dqs-ri_dqr-ri_dqi) * sw
3139  ! num.( number only increase when a+b=>c, dnc=-dna)
3140  clp_dnc = 0.0_rp
3141  clp_dnr = 0.0_rp
3142  clp_dni = 0.0_rp
3143  clp_dns = -ii_dni*0.5_rp
3144  clp_dng = (-rs_dnr-ri_dnr) * sw
3145 
3146  ! total minus in mixed phase collection(clm_)
3147  ! mass
3148  clm_dqc = gc_dqc+sc_dqc+ic_dqc
3149  clm_dqr = (rg_dqr+rs_dqr+ri_dqr) * sw
3150  clm_dqi = ri_dqi+ii_dqi+is_dqi
3151  clm_dqs = rs_dqs+gs_dqs
3152  clm_dqg = rg_dqg * (1.0_rp-sw)
3153  ! num.
3154  clm_dnc = gc_dnc+sc_dnc+ic_dnc
3155  clm_dnr = (rg_dnr+rs_dnr+ri_dnr) * sw
3156  clm_dni = ri_dni+ii_dni+is_dni
3157  clm_dns = rs_dns+ss_dns+gs_dns
3158  clm_dng = gg_dng + rg_dng * (1.0_rp-sw)
3159 
3160  ! partial conversion
3161  ! 08/05/08 [Mod] T.Mitsui
3162  pco_dqi = max( dt*pq(k,i_licon), -clp_dqi )
3163  pco_dqs = max( dt*pq(k,i_lscon), -clp_dqs )
3164  pco_dqg = -pco_dqi-pco_dqs
3165  ! 08/05/08 [Mod] T.Mitsui
3166  pco_dni = max( dt*pq(k,i_nicon), -clp_dni )
3167  pco_dns = max( dt*pq(k,i_nscon), -clp_dns )
3168  pco_dng = -pco_dni-pco_dns
3169 
3170  ! enhanced melting ( always negative value )
3171  ! ice-cloud melting produces cloud, others produce rain
3172  eml_dqi = max( dt*pq(k,i_liacm), min(0.0_rp, -rhoq(k,i_qi)-(clp_dqi+clm_dqi)-pco_dqi ))
3173  eml_dqs = max( dt*pq(k,i_lsacm), min(0.0_rp, -rhoq(k,i_qs)-(clp_dqs+clm_dqs)-pco_dqs ))
3174  eml_dqg = max( dt*(pq(k,i_lgacm)+pq(k,i_lgarm)+pq(k,i_lsarm)+pq(k,i_liarm)), &
3175  min(0.0_rp, -rhoq(k,i_qg)-(clp_dqg+clm_dqg)-pco_dqg ))
3176  eml_dqc = -eml_dqi
3177  eml_dqr = -eml_dqs-eml_dqg
3178  !
3179  eml_dni = max( dt*pq(k,i_niacm), min(0.0_rp, -rhoq(k,i_ni)-(clp_dni+clm_dni)-pco_dni ))
3180  eml_dns = max( dt*pq(k,i_nsacm), min(0.0_rp, -rhoq(k,i_ns)-(clp_dns+clm_dns)-pco_dns ))
3181  eml_dng = max( dt*(pq(k,i_ngacm)+pq(k,i_ngarm)+pq(k,i_nsarm)+pq(k,i_niarm)), &
3182  min(0.0_rp, -rhoq(k,i_ng)-(clp_dng+clm_dng)-pco_dng ))
3183  eml_dnc = -eml_dni
3184  eml_dnr = -eml_dns-eml_dng
3185 
3186  ! ice multiplication
3187  spl_dqg = max( dt*pq(k,i_lgspl), min(0.0_rp, -rhoq(k,i_qg)-(clp_dqg+clm_dqg)-pco_dqg-eml_dqg ))
3188  spl_dqs = max( dt*pq(k,i_lsspl), min(0.0_rp, -rhoq(k,i_qs)-(clp_dqs+clm_dqs)-pco_dqs-eml_dqs ))
3189  spl_dqi = -spl_dqg-spl_dqs
3190  fac9(k) = (spl_dqg-eps)/(dt*pq(k,i_lgspl)-eps) * (spl_dqs-eps)/(dt*pq(k,i_lsspl)-eps)
3191  spl_dni = dt*pq(k,i_nispl)*fac9(k)
3192 
3193  !
3194  ! melting and freezing limiter
3195  di2l = clp_dqc + clp_dqr + clm_dqc + clm_dqr + eml_dqc + eml_dqr ! = - ( clp_dqi + clp_dqs + clp_dqg + clm_dqi + clm_dqs + clm_dqg + eml_dqi + eml_dqs + eml_dqg )
3196  dtem = - di2l * lhf0 / ( cva(k) * dens(k,i,j) )
3197  if ( abs(dtem) < eps ) then
3198  fact(k) = 1.0_rp
3199  else
3200  fact(k) = min( 1.0_rp, max( 0.0_rp, ( t00 - temp(k) ) / dtem ) )
3201  end if
3202 
3203  !
3204  ! total cloud change
3205  drhoqc = wrm_dqc + ( clp_dqc + clm_dqc + eml_dqc ) * fact(k)
3206  drhonc = wrm_dnc + ( clp_dnc + clm_dnc + eml_dnc ) * fact(k)
3207  ! total rain change
3208  drhoqr = wrm_dqr + ( clp_dqr + clm_dqr + eml_dqr ) * fact(k)
3209  drhonr = wrm_dnr + ( clp_dnr + clm_dnr + eml_dnr ) * fact(k)
3210  ! total ice change
3211  drhoqi = ( clp_dqi + clm_dqi + eml_dqi ) * fact(k) + pco_dqi + spl_dqi
3212  drhoni = ( clp_dni + clm_dni + eml_dni ) * fact(k) + pco_dni + spl_dni
3213  ! total snow change
3214  drhoqs = ( clp_dqs + clm_dqs + eml_dqs ) * fact(k) + pco_dqs + spl_dqs
3215  drhons = ( clp_dns + clm_dns + eml_dns ) * fact(k) + pco_dns
3216  ! total graupel change
3217  drhoqg = ( clp_dqg + clm_dqg + eml_dqg ) * fact(k) + pco_dqg + spl_dqg
3218  drhong = ( clp_dng + clm_dng + eml_dng ) * fact(k) + pco_dng
3219 
3220  ! tendency
3221  rhoq0_t(k,i_qc) = drhoqc / dt
3222  rhoq0_t(k,i_nc) = drhonc / dt
3223  rhoq0_t(k,i_qr) = drhoqr / dt
3224  rhoq0_t(k,i_nr) = drhonr / dt
3225  rhoq0_t(k,i_qi) = drhoqi / dt
3226  rhoq0_t(k,i_ni) = drhoni / dt
3227  rhoq0_t(k,i_qs) = drhoqs / dt
3228  rhoq0_t(k,i_ns) = drhons / dt
3229  rhoq0_t(k,i_qg) = drhoqg / dt
3230  rhoq0_t(k,i_ng) = drhong / dt
3231 
3232  rhoe0_t(k) = lhf * ( drhoqi + drhoqs + drhoqg ) / dt
3233 
3234  dql = rrho(k) * ( drhoqc + drhoqr )
3235  dqi = rrho(k) * ( drhoqi + drhoqs + drhoqg )
3236 
3237  dcv = cv_water * dql + cv_ice * dqi
3238  dcp = cp_water * dql + cp_ice * dqi
3239 
3240  cvtot0_t(k) = dcv / dt
3241  cptot0_t(k) = dcp / dt
3242 
3243 
3244  enddo
3245 
3246  ! total tendency
3247  do k = ks, ke
3248  rhoe_t(k,i,j) = rhoe_t(k,i,j) + rhoe0_t(k)
3249  cvtot_t(k,i,j) = cvtot_t(k,i,j) + cvtot0_t(k)
3250  cptot_t(k,i,j) = cptot_t(k,i,j) + cptot0_t(k)
3251  enddo
3252 
3253  !--- update
3254  do iq = i_qc, i_ng
3255  do k = ks, ke
3256  rhoq(k,iq) = max(0.0_rp, rhoq(k,iq) + rhoq0_t(k,iq) * dt )
3257  enddo
3258  enddo
3259 
3260  ! total tendency
3261  do iq = i_qv, i_ng
3262  do k = ks, ke
3263  rhoq_t(k,i,j,iq) = ( rhoq(k,iq) - dens(k,i,j)*qtrc(k,i,j,iq) )/dt
3264  enddo
3265  enddo
3266 
3267  do ip = 1, w_nmax
3268  if ( hist_sw(ip) ) then
3269  if(ip <= pq_max) then
3270  do k = ks, ke
3271  w3d(k,i,j,hist_idx(ip)) = pq(k,ip)
3272  end do
3273  else
3274  do k = ks, ke
3275  w3d(k,i,j,hist_idx(ip)) = pac(k,ip-pq_max)
3276  end do
3277  endif
3278  end if
3279  enddo
3280 
3281  !--- for lithgning component
3282  if ( flg_lt_l ) then
3283 
3284 !OCL LOOP_FISSION_TARGET(LS)
3285  do k = ks, ke
3286  sw = sign(0.5_rp, t00-temp(k)) + 0.5_rp ! if( temp(k,i,j) <= T00 )then sw=1, else sw=0
3287 
3288  wrm_dnc_crg = dt*( pcrg1(k,i_ncaut)+pcrg1(k,i_ncacc) ) ! C + C -> R
3289  !--- limiter
3290  sw1 = min( abs(rhoq_crg(k,i_qc)),abs(wrm_dnc_crg) )
3291  wrm_dnc_crg = sign( sw1,wrm_dnc_crg )
3292  wrm_dnr_crg = - wrm_dnc_crg
3293 
3294  ! Decrease of absolute value of cloud charge density
3295  gc_dnc_crg = dt*pcrg2(k,i_ngacnc2ng) ! C + G -> G ( move from c to g )
3296  sc_dnc_crg = dt*pcrg2(k,i_nsacnc2ns) ! C + S -> S ( move from c to s )
3297  ic_dnc_crg = dt*pcrg2(k,i_niacnc2ni) ! C + I -> I ( move from c to i )
3298  !--- limiter
3299  sw1 = min( abs(rhoq_crg(k,i_qc)+wrm_dnc_crg ),abs(gc_dnc_crg) )
3300  gc_dnc_crg = sign( sw1,gc_dnc_crg )
3301  sw1 = min( abs(rhoq_crg(k,i_qc)+wrm_dnc_crg+gc_dnc_crg ),abs(sc_dnc_crg) )
3302  sc_dnc_crg = sign( sw1,sc_dnc_crg )
3303  sw1 = min( abs(rhoq_crg(k,i_qc)+wrm_dnc_crg+gc_dnc_crg+sc_dnc_crg),abs(ic_dnc_crg) )
3304  ic_dnc_crg = sign( sw1,ic_dnc_crg )
3305 
3306  ! Decrease of absolute value of rain charge density
3307  rg_dnr_crg = dt*pcrg2(k,i_nracng2ng )* sw ! R + G -> G
3308  rg_dng_crg = dt*pcrg2(k,i_nracng2ng )* ( 1.0_rp - sw ) ! R + G -> R
3309  rs_dnr_crg = dt*pcrg2(k,i_nracns2ng_r)* sw ! R + S -> G
3310  ri_dnr_crg = dt*pcrg2(k,i_nracni2ng_r)* sw ! R + I -> G
3311  !--- limiter
3312  sw1 = min( abs(rhoq_crg(k,i_qr)+wrm_dnr_crg),abs(rg_dnr_crg) )
3313  rg_dnr_crg = sign( sw1,rg_dnr_crg )
3314  sw1 = min( abs(rhoq_crg(k,i_qg) ),abs(rg_dng_crg) )
3315  rg_dng_crg = sign( sw1,rg_dng_crg )
3316  sw1 = min( abs(rhoq_crg(k,i_qr)+wrm_dnr_crg),abs(rs_dnr_crg) )
3317  rs_dnr_crg = sign( sw1,rs_dnr_crg )
3318  sw1 = min( abs(rhoq_crg(k,i_qr)+wrm_dnr_crg),abs(ri_dnr_crg) )
3319  ri_dnr_crg = sign( sw1,ri_dnr_crg )
3320 
3321  ! Decrease of absolute value of ice charge density
3322  ri_dni_crg = dt*pcrg2(k,i_nracni2ng_i)*fac4(k) ! I + R -> G
3323  ii_dni_crg = dt*pcrg2(k,i_niacni2ns) ! I + I -> S
3324  is_dni_crg = dt*pcrg2(k,i_niacns2ns) ! I + S -> S
3325 !! !-- Y.Sato added(2018/8/31)
3326 !! gi_dni_crg = dt*Pcrg2(k,I_NGacNI2NG) ! G + S -> G
3327  !--- limiter
3328  sw1 = min( abs(rhoq_crg(k,i_qi)-ic_dnc_crg) ,abs(ri_dni_crg) )
3329  ri_dni_crg = sign( sw1,ri_dni_crg )
3330  sw1 = min( abs(rhoq_crg(k,i_qi)-ic_dnc_crg+ri_dni_crg) ,abs(ii_dni_crg) )
3331  ii_dni_crg = sign( sw1,ii_dni_crg )
3332  sw1 = min( abs(rhoq_crg(k,i_qi)-ic_dnc_crg+ri_dni_crg+ii_dni_crg),abs(is_dni_crg) )
3333  is_dni_crg = sign( sw1,is_dni_crg )
3334 !! !-- Y.Sato added(2018/8/31)
3335 !! sw1 = min( abs(rhoq_crg(k,I_QI)-ic_dnc_crg+ri_dni_crg+ii_dni_crg+is_dni_crg),abs(gi_dni_crg) )
3336 !! gi_dni_crg = sign( sw1,gi_dni_crg )
3337 
3338  ! Decrease of absolute value of snow charge density
3339  rs_dns_crg = dt*pcrg2(k,i_nracns2ng_s)*fac6(k) ! R + S -> G
3340  gs_dns_crg = dt*pcrg2(k,i_ngacns2ng) ! G + S -> G
3341  ss_dns_crg = 0.0_rp ! S + S -> S (No charge transfer)
3342  gg_dng_crg = 0.0_rp ! G + G -> G (No charge transfer)
3343  !--- limiter
3344  sw1 = min( abs(rhoq_crg(k,i_qs)-sc_dnc_crg-ii_dni_crg-is_dni_crg), abs(rs_dns_crg) )
3345  rs_dns_crg = sign( sw1,rs_dns_crg )
3346  sw1 = min( abs(rhoq_crg(k,i_qs)-sc_dnc_crg-ii_dni_crg-is_dni_crg+rs_dns_crg),abs(gs_dns_crg) )
3347  gs_dns_crg = sign( sw1,gs_dns_crg )
3348  !--- Charge split
3349  sw1 = sign(0.5_rp, abs( pcrg2(k,i_cgngacns2ng) )-eps ) + 0.5_rp ! if abs Pcrg2 is smaller than EPS, sw=1, else sw=0
3350  sw2 = sign(0.5_rp, abs( pcrg2(k,i_cgngacni2ng) )-eps ) + 0.5_rp ! if abs Pcrg2 is smaller than EPS, sw=1, else sw=0
3351  crg_split_g = dt*pcrg2(k,i_cgngacns2ng)*sw1 &
3352  + dt*pcrg2(k,i_cgngacni2ng)*sw2
3353  crg_split_s = -dt*pcrg2(k,i_cgngacns2ng)*sw1
3354  crg_split_i = 0.0_rp
3355 !! crg_split_i = -dt*Pcrg2(k,I_CGNGacNI2NG)*sw2 !Y.Sato (2018/8/31)
3356  qsplt_in(k,i,j,1) = crg_split_g / dt ! fC/s
3357  qsplt_in(k,i,j,3) = crg_split_s / dt ! fC/s
3358  qsplt_in(k,i,j,2) = crg_split_i / dt ! fC/s
3359 
3360  ! Decrease of absolute value of graupel charge density
3361  clp_dnc_crg = 0.0_rp
3362  clp_dnr_crg = -rg_dng_crg*(1.0_rp-sw)
3363  clp_dni_crg = -ic_dnc_crg !&
3364 !! +crg_split_i ! Y.Sato added (2018/8/31)
3365  clp_dns_crg = -sc_dnc_crg-ii_dni_crg-is_dni_crg-ss_dns_crg &
3366  +crg_split_s
3367  clp_dng_crg = -gc_dnc_crg+(-rg_dnr_crg-rs_dnr_crg-ri_dnr_crg)*sw &
3368  -ri_dni_crg-rs_dns_crg-gs_dns_crg-gg_dng_crg &
3369 !! -gi_dni_crg & !--- Y.Sato (2018/8/31)
3370  +crg_split_g
3371 
3372  clm_dnc_crg = gc_dnc_crg+sc_dnc_crg+ic_dnc_crg
3373  clm_dnr_crg = (rg_dnr_crg+rs_dnr_crg+ri_dnr_crg) * sw
3374  clm_dni_crg = ri_dni_crg+ii_dni_crg+is_dni_crg !!&
3375 !! + gi_dni_crg !Y.Sato (2018/8/31)
3376  clm_dns_crg = rs_dns_crg+gs_dns_crg+ss_dns_crg
3377  clm_dng_crg = gg_dng_crg+rg_dng_crg*(1.0_rp-sw)
3378 
3379  pco_dni_crg = dt*pcrg1(k,i_nicon)
3380  pco_dns_crg = dt*pcrg1(k,i_nscon)
3381  !--- limiter
3382  sw1 = min( abs(rhoq_crg(k,i_qi)+clp_dni_crg ),abs(pco_dni_crg) )
3383  pco_dni_crg = sign( sw1,pco_dni_crg )
3384  sw1 = min( abs(rhoq_crg(k,i_qs)+clp_dns_crg ),abs(pco_dns_crg) )
3385  pco_dns_crg = sign( sw1,pco_dns_crg )
3386  pco_dng_crg = -pco_dni_crg-pco_dns_crg
3387 
3388  eml_dni_crg = dt*pcrg1(k,i_niacm) ! I+C->C
3389  eml_dns_crg = dt*pcrg1(k,i_nsacm) ! S+C->R
3390  eml_dng_crg = dt*(pcrg1(k,i_ngacm)+pcrg1(k,i_ngarm)+pcrg1(k,i_nsarm)+pcrg1(k,i_niarm)) ! G+R->R, G+C->R
3391  !--- limiter
3392  sw1 = min( abs(rhoq_crg(k,i_qi)+clp_dni_crg+clm_dni_crg+pco_dni_crg ),abs(eml_dni_crg) )
3393  eml_dni_crg = sign( sw1,eml_dni_crg )
3394  sw1 = min( abs(rhoq_crg(k,i_qs)+clp_dns_crg+clm_dns_crg+pco_dns_crg ),abs(eml_dns_crg) )
3395  eml_dns_crg = sign( sw1,eml_dns_crg )
3396  sw1 = min( abs(rhoq_crg(k,i_qg)+clp_dng_crg+clm_dng_crg+pco_dng_crg ),abs(eml_dng_crg) )
3397  eml_dng_crg = sign( sw1,eml_dng_crg )
3398 
3399  eml_dnc_crg = -eml_dni_crg
3400  eml_dnr_crg = -eml_dns_crg-eml_dng_crg
3401 
3402  spl_dns_crg = dt*pcrg1(k,i_nsspl)*fac9(k)
3403  spl_dng_crg = dt*pcrg1(k,i_ngspl)*fac9(k)
3404  !--- limiter
3405  sw1 = min( abs(rhoq_crg(k,i_qs)+clp_dns_crg+pco_dns_crg+eml_dns_crg ),abs(spl_dns_crg) )
3406  spl_dns_crg = sign( sw1,spl_dns_crg )
3407  sw1 = min( abs(rhoq_crg(k,i_qg)+clp_dng_crg+pco_dng_crg+eml_dng_crg ),abs(spl_dng_crg) )
3408  spl_dng_crg = sign( sw1,spl_dng_crg )
3409  spl_dni_crg = -spl_dns_crg-spl_dng_crg
3410 
3411  drhoqcrg_c = wrm_dnc_crg + ( clp_dnc_crg + clm_dnc_crg + eml_dnc_crg ) * fact(k)
3412  drhoqcrg_r = wrm_dnr_crg + ( clp_dnr_crg + clm_dnr_crg + eml_dnr_crg ) * fact(k)
3413  drhoqcrg_i = ( clp_dni_crg + clm_dni_crg + eml_dni_crg ) * fact(k) + pco_dni_crg + spl_dni_crg
3414  drhoqcrg_s = ( clp_dns_crg + clm_dns_crg + eml_dns_crg ) * fact(k) + pco_dns_crg + spl_dns_crg
3415  drhoqcrg_g = ( clp_dng_crg + clm_dng_crg + eml_dng_crg ) * fact(k) + pco_dng_crg + spl_dng_crg
3416 
3417  rhoqcrg0_t(k,i_qc) = drhoqcrg_c / dt
3418  rhoqcrg0_t(k,i_qr) = drhoqcrg_r / dt
3419  rhoqcrg0_t(k,i_qi) = drhoqcrg_i / dt
3420  rhoqcrg0_t(k,i_qs) = drhoqcrg_s / dt
3421  rhoqcrg0_t(k,i_qg) = drhoqcrg_g / dt
3422  end do
3423 
3424 
3425  do iq = i_qc, i_qg
3426  do k = ks, ke
3427  rhoq_crg(k,iq) = rhoq_crg(k,iq) + rhoqcrg0_t(k,iq) * dt !-- need limiter?
3428  enddo
3429  enddo
3430 
3431  do iq = i_qc, i_ng
3432  do k = ks, ke
3433  qtrc0(k,iq) = rhoq(k,iq) / dens(k,i,j)
3434  enddo
3435  enddo
3436  call cross_section( ka, ks, ke, & ! [IN]
3437  qa_mp, & ! [IN]
3438  qtrc0(:,:), & ! [IN]
3439  dens(:,i,j), & ! [IN]
3440  crs(:,:) ) ! [OUT]
3441 
3442  do k = ks, ke
3443  sarea(k,i,j,i_mp_qc) = crs(k,i_mp_qc)
3444  sarea(k,i,j,i_mp_qr) = crs(k,i_mp_qr)
3445  sarea(k,i,j,i_mp_qi) = crs(k,i_mp_qi)
3446  sarea(k,i,j,i_mp_qs) = crs(k,i_mp_qs)
3447  sarea(k,i,j,i_mp_qg) = crs(k,i_mp_qg)
3448  enddo
3449 
3450  do iq = i_qc, i_qg
3451  do k = ks, ke
3452  rhoqcrg_t_mp(k,i,j,iq-1) = ( rhoq_crg(k,iq) - dens(k,i,j)*qtrc_crg(k,i,j,iq-1) ) / dt
3453  enddo
3454  enddo
3455 
3456  end if
3457 
3458 #ifdef DEBUG
3459  call debug_tem( ka, ks, ke, &
3460  4, i, j, temp(:), dens(:,i,j), pres(:), qtrc(:,i,j,i_qv) )
3461 #endif
3462 
3463  end do
3464  end do
3465 
3466  do ip = 1, w_nmax
3467  if ( hist_sw(ip) ) call file_history_put( hist_id(ip), w3d(:,:,:,hist_idx(ip)) )
3468  enddo
3469 
3470  return
3471  end subroutine mp_sn14
3472 
3473  !-----------------------------------------------------------------------------
3474 !OCL SERIAL
3475  subroutine debug_tem( &
3476  KA, KS, KE, &
3477  point, i, j, &
3478  tem, rho, pre, qv )
3479  use scale_prc, only: &
3480  prc_myrank
3481  implicit none
3482  integer, intent(in) :: KA, KS, KE
3483 
3484  integer, intent(in) :: point
3485  integer, intent(in) :: i, j
3486  real(RP), intent(in) :: tem(KA)
3487  real(RP), intent(in) :: rho(KA)
3488  real(RP), intent(in) :: pre(KA)
3489  real(RP), intent(in) :: qv (KA)
3490 
3491  integer :: k
3492  !---------------------------------------------------------------------------
3493 
3494  do k = ks, ke
3495  if ( tem(k) < tem_min &
3496  .OR. rho(k) < rho_min &
3497  .OR. pre(k) < 1.0_rp ) then
3498 
3499  log_info("ATMOS_PHY_MP_SN14_debug_tem_kij",'(A,I3,A,4(F16.5),3(I6))') &
3500  "point: ", point, " low tem,rho,pre:", tem(k), rho(k), pre(k), qv(k), k, i, j, prc_myrank
3501  endif
3502  enddo
3503 
3504  return
3505  end subroutine debug_tem
3506 
3507 !OCL SERIAL
3508  subroutine nucleation( &
3509  KA, KS, KE, &
3510  cz, fz, w, &
3511  rho, tem, pre, qdry, &
3512  rhoq, cpa, cva, &
3513  dTdt_rad, &
3514  qke, &
3515  CCN, nc_uplim_d, &
3516  dt, &
3517  dq_xa, vt_xa, &
3518  PQ )
3519  use scale_prc, only: &
3520  prc_abort
3521  use scale_atmos_saturation, only: &
3522  moist_psat_liq => atmos_saturation_psat_liq, &
3523  moist_psat_ice => atmos_saturation_psat_ice, &
3524  moist_pres2qsat_liq => atmos_saturation_pres2qsat_liq, &
3525  moist_pres2qsat_ice => atmos_saturation_pres2qsat_ice, &
3526  moist_dqsi_dtem_dens => atmos_saturation_dqs_dtem_dens_liq, &
3527  moist_dqs_dtem_dpre_ice => atmos_saturation_dqs_dtem_dpre_ice
3528  use scale_atmos_hydrometeor, only: &
3529  cv_vapor, &
3530  cv_ice
3531  implicit none
3532 
3533  integer, intent(in) :: KA, KS, KE
3534 
3535  real(RP), intent(in) :: cz( KA)
3536  real(RP), intent(in) :: fz(0:KA)
3537  real(RP), intent(in) :: w (KA) ! w of full level
3538  real(RP), intent(in) :: rho (KA)
3539  real(RP), intent(in) :: tem (KA)
3540  real(RP), intent(in) :: pre (KA)
3541  real(RP), intent(in) :: qdry(KA)
3542  !
3543  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
3544  !
3545  real(RP), intent(in) :: cpa(KA)
3546  real(RP), intent(in) :: dTdt_rad(KA)
3547  real(RP), intent(in) :: qke(KA)
3548  real(RP), intent(in) :: dt
3549  real(RP), intent(in) :: CCN(KA)
3550  real(RP), intent(in) :: nc_uplim_d
3551  !
3552  real(RP), intent(out) :: PQ(KA,PQ_MAX)
3553  !
3554  !
3555 ! real(RP) :: c_ccn_map(1) ! c_ccn horizontal distribution
3556 ! real(RP) :: kappa_map(1) ! kappa horizontal distribution
3557 ! real(RP) :: c_in_map(1) ! c_in horizontal distribution ! [Add] 11/08/30 T.Mitsui
3558  real(RP) :: esw(KA) ! saturation vapor pressure, water
3559  real(RP) :: esi(KA) ! ice
3560  real(RP) :: ssw(KA) ! super saturation (water)
3561  real(RP) :: ssi(KA) ! super saturation (ice)
3562 ! real(RP) :: w_dsswdz(KA) ! w*(d_ssw/ d_z) super saturation(water) flux
3563  real(RP) :: w_dssidz(KA) ! w*(d_ssi/ d_z), 09/04/14 T.Mitsui
3564 ! real(RP) :: ssw_below(KA) ! ssw(k-1)
3565  real(RP) :: ssi_below(KA) ! ssi(k-1), 09/04/14 T.Mitsui
3566  real(RP) :: z_below(KA) ! z(k-1)
3567  real(RP) :: dzh ! z(k)-z(k-1)
3568  real(RP) :: pv ! vapor pressure
3569  ! work variables for Twomey Equation.
3570  real(RP) :: qsw(KA)
3571  real(RP) :: qsi(KA)
3572  real(RP) :: dqsidtem_rho(KA)
3573  real(RP) :: dssidt_rad(KA)
3574  real(RP) :: wssi, wdssi
3575  !
3576 
3577  real(RP) :: cva(KA)
3578  real(RP) :: dq_xa(KA,HYDRO_MAX)
3579  real(RP) :: vt_xa(KA,HYDRO_MAX,2) ! terminal velocity
3580  real(RP) :: dTdt_dep(KA)
3581  real(RP) :: PLIdep_total(KA)
3582  real(RP) :: wtem(KA) ! temperature[K]
3583  real(RP) :: dqsidpre_tem(KA)
3584  real(RP) :: dqsidtem_pre(KA)
3585  real(RP) :: dssidt
3586  real(RP) :: dssidt_mp(KA)
3587  real(RP) :: dssidt_dyn(KA)
3588  !!
3589 
3590 
3591 ! real(RP) :: xi_nuc(1) ! xi use the value @ cloud base
3592 ! real(RP) :: alpha_nuc(1) ! alpha_nuc
3593 ! real(RP) :: eta_nuc(1) ! xi use the value @ cloud base
3594  !
3595  real(RP) :: sigma_w(KA)
3596  real(RP) :: weff(KA)
3597  real(RP) :: weff_max(KA)
3598  real(RP) :: velz(KA)
3599  !
3600  real(RP) :: coef_ccn
3601  real(RP) :: slope_ccn
3602  real(RP) :: nc_new(KA)
3603  real(RP) :: nc_new_below(KA)
3604  real(RP) :: dnc_new
3605  real(RP) :: nc_new_max ! Lohmann (2002),
3606  real(RP) :: a_max
3607  real(RP) :: b_max
3608  logical :: flag_nucleation(KA)
3609  !
3610  real(RP) :: r_gravity
3611  real(RP), parameter :: r_sqrt3=0.577350269_rp ! = sqrt(1.0/3.0)
3612  real(RP), parameter :: eps=1.e-30_rp
3613  !====> ! 09/08/18
3614  !
3615  real(RP) :: dlcdt_max, dli_max ! defined by supersaturation
3616  real(RP) :: dncdt_max, dni_max ! defined by supersaturation
3617  real(RP) :: rdt
3618 
3619  real(RP) :: tmp
3620  !
3621  integer :: k
3622  !
3623  !
3624 
3625  if( so22_het ) then
3626  do k = ks, ke
3627  ! Temperature lower limit is only used for saturation condition.
3628  ! On the other hand original "tem" is used for calculation of latent heat or energy equation.
3629  wtem(k) = max( tem(k), tem_min )
3630  end do
3631  endif
3632 
3633 
3634 ! c_ccn_map(1) = c_ccn
3635 ! kappa_map(1) = kappa
3636 ! c_in_map(1) = c_in
3637  !
3638  !
3639  rdt = 1.0_rp/dt
3640  r_gravity = 1.0_rp/grav
3641  !
3642  call moist_psat_liq ( ka, ks, ke, &
3643  tem(:), esw(:) ) ! [IN], [OUT]
3644  call moist_psat_ice ( ka, ks, ke, &
3645  tem(:), esi(:) ) ! [IN], [OUT]
3646  call moist_pres2qsat_liq ( ka, ks, ke, &
3647  tem(:), pre(:), qdry(:), & ! [IN]
3648  qsw(:) ) ! [OUT]
3649  call moist_pres2qsat_ice ( ka, ks, ke, &
3650  tem(:), pre(:), qdry(:), & ! [IN]
3651  qsi(:) ) ! [OUT]
3652  call moist_dqsi_dtem_dens( ka, ks, ke, &
3653  tem(:), rho(:), & ! [IN]
3654  dqsidtem_rho(:) ) ! [OUT]
3655 
3656  if( so22_het ) then
3657  call moist_dqs_dtem_dpre_ice( ka, ks, ke, &
3658  wtem(:), pre(:), qdry(:), & ! [IN]
3659  dqsidtem_pre(:), dqsidpre_tem(:) ) ! [OUT]
3660  endif
3661  !!
3662 
3663 
3664  !
3665  ! Lohmann (2002),JAS, eq.(1) but changing unit [cm-3] => [m-3]
3666  a_max = 1.e+6_rp*0.1_rp*(1.e-6_rp)**1.27_rp
3667  b_max = 1.27_rp
3668  !
3669  ssi_max = 1.0_rp
3670 
3671  do k = ks, ke
3672  pv = rhoq(k,i_qv)*rvap*tem(k)
3673  ssw(k) = min( mp_ssw_lim, ( pv/esw(k)-1.0_rp ) )*100.0_rp
3674  ssi(k) = ( pv/esi(k) - 1.00_rp )
3675 ! ssw_below(k+1) = ssw(k)
3676  ssi_below(k+1) = ssi(k)
3677  z_below(k+1) = cz(k)
3678  end do
3679 ! ssw_below(KS) = ssw(KS)
3680  ssi_below(ks) = ssi(ks)
3681  z_below(ks) = cz(ks-1)
3682 
3683  ! dS/dz is evaluated by first order upstream difference
3684  !*** Solution for Twomey Equation ***
3685 ! coef_ccn = 1.E+6_RP*0.88_RP*(c_ccn_map(1)*1.E-6_RP)**(2.0_RP/(kappa_map(1) + 2.0_RP)) * &
3686  coef_ccn = 1.e+6_rp*0.88_rp*(c_ccn*1.e-6_rp)**(2.0_rp/(kappa + 2.0_rp)) &
3687 ! * (70.0_RP)**(kappa_map(1)/(kappa_map(1) + 2.0_RP))
3688  * (70.0_rp)**(kappa/(kappa + 2.0_rp))
3689 ! slope_ccn = 1.5_RP*kappa_map(1)/(kappa_map(1) + 2.0_RP)
3690  slope_ccn = 1.5_rp*kappa/(kappa + 2.0_rp)
3691  !
3692  do k=ks, ke
3693  sigma_w(k) = r_sqrt3*sqrt(max(qke(k),qke_min))
3694  end do
3695  sigma_w(ks-1) = sigma_w(ks)
3696  sigma_w(ke+1) = sigma_w(ke)
3697  ! effective vertical velocity
3698  do k=ks, ke
3699  weff(k) = w(k) - cpa(k)*r_gravity*dtdt_rad(k)
3700  end do
3701  !
3702  if( mp_couple_aerosol ) then
3703 
3704  do k = ks, ke
3705  if( ssw(k) > 1.e-10_rp .AND. pre(k) > 300.e+2_rp ) then
3706  nc_new(k) = max( ccn(k), c_ccn )
3707  else
3708  nc_new(k) = 0.0_rp
3709  endif
3710  enddo
3711 
3712  else
3713 
3714  if( nucl_twomey ) then
3715  ! diagnose cloud condensation nuclei
3716  do k = ks, ke
3717  ! effective vertical velocity (maximum vertical velocity in turbulent flow)
3718  weff_max(k) = weff(k) + sigma_w(k)
3719  ! large scale upward motion region and saturated
3720  if( (weff(k) > 1.e-8_rp) .AND. (ssw(k) > 1.e-10_rp) .AND. pre(k) > 300.e+2_rp )then
3721  ! Lohmann (2002), eq.(1)
3722  nc_new_max = coef_ccn*weff_max(k)**slope_ccn
3723  nc_new(k) = a_max*nc_new_max**b_max
3724  else
3725  nc_new(k) = 0.0_rp
3726  end if
3727  end do
3728 
3729  else
3730  ! calculate cloud condensation nuclei
3731  do k = ks, ke
3732  if( ssw(k) > 1.e-10_rp .AND. pre(k) > 300.e+2_rp ) then
3733  nc_new(k) = c_ccn*ssw(k)**kappa
3734  else
3735  nc_new(k) = 0.0_rp
3736  endif
3737  enddo
3738  endif
3739 
3740  endif
3741 
3742  do k = ks, ke
3743  ! nc_new is bound by upper limit
3744  if( nc_new(k) > nc_uplim_d ) then ! no more CCN
3745  flag_nucleation(k) = .false.
3746  nc_new_below(k+1) = 1.e+30_rp
3747  else if( nc_new(k) > eps ) then ! nucleation can occur
3748  flag_nucleation(k) = .true.
3749  nc_new_below(k+1) = nc_new(k)
3750  else ! nucleation cannot occur(unsaturated or negative w)
3751  flag_nucleation(k) = .false.
3752  nc_new_below(k+1) = 0.0_rp
3753  end if
3754  end do
3755  nc_new_below(ks) = 0.0_rp
3756 ! do k=KS, KE
3757  ! search maximum value of nc_new
3758 ! if( ( nc_new(k) < nc_new_below(k) ) .OR. &
3759 ! ( nc_new_below(k) > c_ccn_map(1)*0.05_RP ) )then ! 5% of c_ccn
3760 ! ( nc_new_below(k) > c_ccn*0.05_RP ) )then ! 5% of c_ccn
3761 ! flag_nucleation(k) = .false.
3762 ! end if
3763 ! end do
3764 
3765  if( mp_couple_aerosol ) then
3766  do k = ks, ke
3767  ! nucleation occurs at only cloud base.
3768  ! if CCN is more than below parcel, nucleation newly occurs
3769  ! effective vertical velocity
3770  if ( flag_nucleation(k) .AND. & ! large scale upward motion region and saturated
3771  tem(k) > tem_ccn_low ) then
3772  dlcdt_max = ( rhoq(k,i_qv) - esw(k) / ( rvap * tem(k) ) ) * rdt
3773  dlcdt_max = max( dlcdt_max, 0.0_rp ) ! dlcdt_max can be artificially negative due to truncation error in floating point operation
3774  dncdt_max = dlcdt_max/xc_min
3775 ! dnc_new = nc_new(k)-rhoq(k,I_NC)
3776  dnc_new = nc_new(k)
3777  pq(k,i_ncccn) = min( dncdt_max, dnc_new*rdt )
3778  pq(k,i_lcccn) = min( dlcdt_max, xc_min*pq(k,i_ncccn) )
3779  else
3780  pq(k,i_ncccn) = 0.0_rp
3781  pq(k,i_lcccn) = 0.0_rp
3782  end if
3783  end do
3784  else
3785 
3786  if( nucl_twomey ) then
3787  do k = ks, ke
3788  ! nucleation occurs at only cloud base.
3789  ! if CCN is more than below parcel, nucleation newly occurs
3790  ! effective vertical velocity
3791  if ( flag_nucleation(k) .AND. & ! large scale upward motion region and saturated
3792  tem(k) > tem_ccn_low .AND. &
3793  nc_new(k) > rhoq(k,i_nc) ) then
3794  dlcdt_max = ( rhoq(k,i_qv) - esw(k) / ( rvap * tem(k) ) ) * rdt
3795  dlcdt_max = max( dlcdt_max, 0.0_rp ) ! dlcdt_max can be artificially negative due to truncation error in floating point operation
3796  dncdt_max = dlcdt_max/xc_min
3797  dnc_new = nc_new(k)-rhoq(k,i_nc)
3798  pq(k,i_ncccn) = min( dncdt_max, dnc_new*rdt )
3799  pq(k,i_lcccn) = min( dlcdt_max, xc_min*pq(k,i_ncccn) )
3800  else
3801  pq(k,i_ncccn) = 0.0_rp
3802  pq(k,i_lcccn) = 0.0_rp
3803  end if
3804  end do
3805  else
3806  do k = ks, ke
3807  ! effective vertical velocity
3808  if( tem(k) > tem_ccn_low .AND. &
3809  nc_new(k) > rhoq(k,i_nc) ) then
3810  dlcdt_max = ( rhoq(k,i_qv) - esw(k) / ( rvap * tem(k) ) ) * rdt
3811  dlcdt_max = max( dlcdt_max, 0.0_rp ) ! dlcdt_max can be artificially negative due to truncation error in floating point operation
3812  dncdt_max = dlcdt_max/xc_min
3813  dnc_new = nc_new(k)-rhoq(k,i_nc)
3814  pq(k,i_ncccn) = min( dncdt_max, dnc_new*rdt )
3815  pq(k,i_lcccn) = min( dlcdt_max, xc_min*pq(k,i_ncccn) )
3816  else
3817  pq(k,i_ncccn) = 0.0_rp
3818  pq(k,i_lcccn) = 0.0_rp
3819  end if
3820  end do
3821  endif
3822 
3823  endif
3824 
3825  !
3826  ! ice nucleation
3827  !
3828  ! +++ NOTE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3829  ! Based on Phillips etal.(2006).
3830  ! However this approach doesn't diagnose Ni itself but diagnose tendency.
3831  ! Original approach adjust Ni instantaneously .
3832  ! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3833 
3834  if( so22_het .or. opt_nucleation_ice_hom ) then
3835  call dep_vapor_ice_wrk( & ! in
3836  ka, ks, ke, & ! in
3837  plidep_total(:), & ! out for ice nucleation
3838  rho(:), tem(:), pre(:), & ! in
3839  qdry(:), esi(:), qsi(:), & ! in
3840  rhoq(:,:), & ! in
3841  vt_xa, dq_xa, & ! in
3842  dt ) ! in
3843 
3844  do k = ks, ke
3845  dtdt_dep(k) = (lhs0+(cv_vapor-cv_ice)*tem(k))*plidep_total(k)/(rho(k)*cva(k))
3846  enddo
3847  else
3848  dtdt_dep(:) = 0.0_rp
3849  endif
3850 
3851  do k = ks, ke-1
3852  velz(k) = ( w(k) * ( cz(k+1) - fz(k) ) + w(k+1) * ( fz(k) - cz(k) ) ) / ( cz(k+1) - cz(k) ) ! @ half level
3853  end do
3854  velz(ke) = 0.0_rp
3855  do k = ks, ke
3856  dzh = cz(k) - z_below(k)
3857  w_dssidz(k) = velz(k) * (ssi(k) - ssi_below(k))/dzh
3858  dssidt_rad(k) = -rhoq(k,i_qv)/(rho(k)*qsi(k)*qsi(k))*dqsidtem_rho(k)*dtdt_rad(k)
3859  dli_max = ( rhoq(k,i_qv) - esi(k) / ( rvap * tem(k) ) ) * rdt
3860  dli_max = max( dli_max, 0.0_rp ) ! dli_max can be artificially negative due to truncation error in floating point operation
3861  dni_max = min( dli_max/xi_ccn, (in_max-rhoq(k,i_ni))*rdt )
3862  wdssi = min( w_dssidz(k)+dssidt_rad(k), 0.01_rp)
3863  wssi = min( ssi(k), ssi_max)
3864 
3865  !! Seiki and Ohno 2022
3866  if( so22_het ) then
3867  dssidt_mp(k) = -plidep_total(k)/(rho(k)*qsi(k))
3868  !! PLIdep(k) -> PQ(k,I_LIdep)
3869  dssidt_rad(k) = -rhoq(k,i_qv)/(rho(k)*qsi(k)*qsi(k))*dqsidtem_rho(k)*dtdt_rad(k)
3870  !!
3871  dssidt_dyn(k) = +rhoq(k,i_qv)/(rho(k)*qsi(k)*qsi(k))&
3872  * velz(k)*grav*(dqsidtem_pre(k)/cpa(k)+dqsidpre_tem(k)*rho(k))
3873  ! * w(k)*CNST_GRAV*(dqsidtem_pre(ij,k)/cpa(ij,k)+dqsidpre_tem(ij,k)*rho(ij,k))
3874  dssidt = dssidt_mp(k) + dssidt_rad(k) + dssidt_dyn(k)
3875  endif
3876 
3877  ! SB06(34),(35)
3878 !# if( ( wdssi > eps ) .AND. & !
3879 !# (tem(k) < 273.15_RP ) .AND. & !
3880 !# (rhoq(k,I_NI) < in_max ) .AND. &
3881 !# (wssi >= eps ) )then !
3882 !# tmp = c_in * nm_M92 * exp( 0.3_RP * bm_M92 * ( wssi - 0.1_RP ) )
3883 !# if( inucl_w ) then
3884 !# tmp = bm_M92 * 0.3_RP * tmp * wdssi
3885 !# else
3886 !# tmp = max( tmp - rhoq(k,I_NI), 0.0_RP ) * rdt
3887 !# endif
3888 !# PQ(k,I_NIccn) = min(dni_max, tmp)
3889 !# PQ(k,I_LIccn) = min(dli_max, PQ(k,I_NIccn)*xi_ccn )
3890 !# else
3891 !# PQ(k,I_NIccn) = 0.0_RP
3892 !# PQ(k,I_LIccn) = 0.0_RP
3893 !# end if
3894  if( (tem(k) < 273.15_rp ) .AND. & !
3895  (rhoq(k,i_ni) < in_max ) .AND. &
3896  (wssi >= eps ) )then !
3897  tmp = c_in * nm_m92 * exp( 0.3_rp * bm_m92 * ( wssi - 0.1_rp ) )
3898  if( inucl_w .and. wdssi > eps ) then
3899  tmp = bm_m92 * 0.3_rp * tmp * wdssi
3900  elseif( so22_het .and. dssidt > eps ) then
3901  tmp = bm_m92 * 0.3_rp * tmp * dssidt
3902  else
3903  tmp = max( tmp - rhoq(k,i_ni), 0.0_rp ) * rdt
3904  endif
3905  pq(k,i_niccn) = min(dni_max, tmp)
3906  pq(k,i_liccn) = min(dli_max, pq(k,i_niccn)*xi_ccn )
3907  else
3908  pq(k,i_niccn) = 0.0_rp
3909  pq(k,i_liccn) = 0.0_rp
3910  end if
3911 
3912 
3913  end do
3914 
3915  if( opt_nucleation_ice_hom ) then
3916  call nucleation_ice_hom( &
3917  ka, ks, ke, & !in
3918  tem, pre, rho, & !in
3919  qdry, rhoq(:,i_qv), & !in
3920  cva, cpa, & !in
3921  w, & !in
3922  dtdt_rad, & !in
3923  dtdt_dep, & !in
3924  plidep_total, dt, & !in
3925  pq(:,i_lihom), & !out
3926  pq(:,i_nihom) ) !out
3927  else
3928  pq(:,i_lihom) = 0.0_rp
3929  pq(:,i_nihom) = 0.0_rp
3930  endif
3931 
3932 
3933  return
3934  end subroutine nucleation
3935  !----------------------------
3936 
3937 !OCL SERIAL
3938  subroutine nucleation_ice_hom( &
3939  KA, KS, KE, &
3940  tem, pre, rho, &
3941  qd, rhoq_qv, cva, cpa, &
3942  w, dTdt_rad, dTdt_dep, &
3943  PLIdep, dt, PLIhom, PNIhom )
3944  use scale_prc, only: &
3945  prc_abort
3946  use scale_const, only: &
3947  psat0 => const_psat0, &
3948  t00 => const_tem00, &
3949  pstd => const_pstd, &
3950  cpvap => const_cpvap, &
3951  cvvap => const_cvvap, &
3952  ci => const_ci, &
3953  cl => const_cl, &
3954  rvap => const_rvap, &
3955  rdry => const_rdry, &
3956  lhs00 => const_lhs00, &
3957  lhs0 => const_lhs0, &
3958  lhv00 => const_lhv00, &
3959  lhf00 => const_lhf00, &
3960  epsvap => const_epsvap, &
3961  grav => const_grav, &
3962  pi => const_pi
3963  implicit none
3964 
3965  integer, intent(in) :: KA, KS, KE
3966 
3967  real(RP), intent(in) :: tem(KA)
3968  real(RP), intent(in) :: pre(KA)
3969  real(RP), intent(in) :: rho(KA)
3970  real(RP), intent(in) :: qd(KA)
3971  real(RP), intent(in) :: rhoq_qv(KA)
3972  real(RP), intent(in) :: cpa(KA) ! specific heat @ cnst. pressure
3973  real(RP), intent(in) :: cva(KA) ! specific heat @ cnst. volume
3974  ! balance equation @ homogeneous ice nucleation
3975  real(RP), intent(in) :: w(KA) ! adiabatic ascending
3976  real(RP), intent(in) :: dTdt_rad(KA) ! effect of radiative heating
3977  real(RP), intent(in) :: dTdt_dep(KA) ! effect of radiative heating
3978  real(RP), intent(in) :: PLIdep(KA)
3979 ! real(RP), intent(out) :: PQ(KA,PQ_MAX) ! competition effect by vapor consumption
3980  real(RP), intent(out):: PLIhom(KA)
3981  real(RP), intent(out):: PNIhom(KA)
3982  real(RP), intent(in) :: dt
3983  real(RP), parameter :: rhoi=916.0_rp ! ice density [kg/m3]
3984  real(RP), parameter :: rrhoi=1.0_rp/rhoi !
3985  real(RP), parameter :: Mw=18.01528_rp ! Water Molar Weight
3986  real(RP), parameter :: Nav=6.0221415e+23_rp ! Avogadro Number
3987  real(RP), parameter :: vw=(mw*1.e-3_rp/nav)/rhoi ! volume of a water molecule in ice phase
3988  ! 18nm*exp( 3.0*log(1.5)**2 )=29.4760367
3989  real(RP), parameter :: r0=29.5e-9_rp ! aerosol mass(volume) mode radius
3990  real(RP), parameter :: c_gf = 1.01187_rp ! dAlmeida
3991  real(RP), parameter :: g_gf = -0.206449_rp ! dAlmeida
3992  real(RP), parameter :: rho_min=1.e-5_rp ! 3.e-3 is lower limit recognized in many experiments.
3993  real(RP), parameter :: tem_min=150.0_rp
3994  real(RP), parameter :: ni_max =300.e+6_rp
3995 ! real(RP) :: dTdt_dep(KA) ! effect of deposition heating
3996  real(RP) :: wtem
3997  real(RP) :: esi, esw
3998  real(RP) :: qsi
3999  real(RP) :: lhs
4000  real(RP) :: dqsidtem
4001  real(RP) :: den1, den2
4002  real(RP) :: dqsidt_pre
4003  real(RP) :: dqsidp_tem
4004  real(RP) :: rw
4005  real(RP) :: temc_lim
4006  real(RP) :: rho_lim
4007  real(RP) :: pre_lim
4008  real(RP) :: Dw
4009  real(RP) :: si, sw
4010  real(RP) :: Scr
4011  real(RP) :: dsidt_mp
4012  real(RP) :: dsidt_rd
4013  real(RP) :: wp
4014  real(RP) :: a1,a2,a3
4015  real(RP) :: b1,b2
4016  real(RP) :: dlogJdT
4017  real(RP) :: dtemdt_dyn
4018  real(RP) :: rtau ! 1/tau
4019  real(RP) :: delta
4020  real(RP) :: kappa
4021  real(RP) :: Rim_w
4022  real(RP) :: ri_wrk
4023  real(RP) :: ri
4024  !
4025  real(RP), parameter :: r2pi = 0.5_rp/pi ! 1/2pi
4026  real(RP), parameter :: sqrt_pi = sqrt(pi)
4027  real(RP), parameter :: coef_mi = 4.0_rp/3.0_rp*pi*rhoi
4028  real(RP), parameter :: eps = 1.e-30_rp
4029  real(RP) :: rdt
4030  integer :: ierr
4031  integer :: ij,k
4032  !
4033 
4034  rdt = 1.0_rp/dt
4035  plihom(:) = 0.0_rp
4036  pnihom(:) = 0.0_rp
4037 ! PQ(:,I_NIhom) = 0.0_RP
4038 ! PQ(:,I_LIhom) = 0.0_RP
4039 ! PQ(1:KS,I_NIhom) = 0.0_RP
4040 ! PQ(1:KS,I_LIhom) = 0.0_RP
4041 ! PQ(KE:KA,I_NIhom) = 0.0_RP
4042 ! PQ(KE:KA,I_LIhom) = 0.0_RP
4043  do k = ks, ke
4044  wtem= max(tem(k), tem_min)
4045  esi = min( psat0 &
4046  * ( wtem / t00 ) ** ( ( cpvap - ci ) / rvap ) &
4047  * exp( lhs00 / rvap &
4048  * ( 1.0_rp / t00 - 1.0_rp / wtem ) ), pre(k))
4049  esw = psat0 &
4050  * ( wtem / t00 ) ** ( ( cpvap - cl ) / rvap ) &
4051  * exp( lhv00 / rvap &
4052  * ( 1.0_rp / t00 - 1.0_rp / wtem ) )
4053  ! (10) in Ren and MacKenzie (2005)
4054  scr = 2.349_rp - wtem/259.0_rp
4055  qsi = epsvap * esi / ( pre(k) - ( 1.0_rp - epsvap ) * esi )
4056  si = rhoq_qv(k)*rvap*wtem/esi ! rho(k)*qv(k)
4057  ! sw must be less than 1 to calculate hygroscopic growth (otherwise, already activated)
4058  sw = min(rho(k)*rhoq_qv(k)*rvap*wtem/esw,0.999_rp)
4059  if ( si < scr ) then
4060  ! No nucleation occurs
4061  qsi = 0.0_rp
4062  lhs = lhs00 + (cpvap - ci )*(wtem-t00)
4063  dqsidtem = 0.0_rp
4064  si = 0.0_rp
4065  sw = 0.0_rp
4066  scr = 100.0_rp
4067  a1 = 0.0_rp
4068  wp = -1.0_rp
4069  rtau = -1.0_rp
4070  else
4071  ! (dsi/dt)_MP
4072  lhs = lhs0 + (cpvap - ci)*(wtem-t00)
4073  dqsidtem = esi/(rho(k)*rvap*wtem*wtem)&
4074  * (lhs/(rvap*wtem)-1.0_rp)
4075  dsidt_mp = -1.0_rp/(rho(k)*qsi) &
4076  * (1.0_rp+si*(lhv00+lhf00+(cvvap-ci)*wtem)/cva(k)*dqsidtem)&
4077  * plidep(k)
4078  dsidt_rd = -si/qsi*dqsidtem*dtdt_rad(k)
4079  ! This is an simple formulation from original paper
4080  a1 = lhs0*grav/(cpa(k)*rvap*tem(k)*tem(k))&
4081  - grav/(rdry*tem(k))
4082 !!$ ! alternative formulation for NICAM-EXACT
4083 !!$ den1 = (pre(k)-(1.0_RP-EPSvap)*esi)*(pre(k)-(1.0_RP-EPSvap)*esi)
4084 !!$ den2 = den1*Rvap*wtem*wtem
4085 !!$ dqsidp_tem=-EPSvap* esi/den1
4086 !!$ dqsidt_pre= EPSvap*pre(k)*lhs*esi/den2
4087 !!$ a1 = GRAV/qsi*(dqsidt_pre/cpa(k)+dqsidp_tem*rho(k))
4088  wp = w(k) + 1.0_rp/(a1*si)*(dsidt_mp+dsidt_rd)
4089  ! (21) in RM05
4090  dlogjdt = -0.004_rp*wtem*wtem + 2.0_rp*wtem - 304.4_rp
4091  ! (22) in RM05
4092  dtemdt_dyn= - grav*w(k)/cpa(k)
4093  rtau = dlogjdt*(dtdt_rad(k)+dtdt_dep(k)+dtemdt_dyn )
4094  endif
4095  rw = r0*c_gf*(1-sw)**g_gf
4096 
4097  if ( wp > eps .AND. rtau > eps ) then
4098  ! a1,a2,a3,b1,b2 are given by Appendix B in RM05
4099  temc_lim= max(tem(k)-t00, temc_lim_diff )
4100  rho_lim = max(rho(k),rho_min) !
4101  pre_lim = rho_lim*(qd(k)*rdry + rhoq_qv(k)*rvap)*(temc_lim+t00)! only for Dw
4102  dw = 0.211e-4_rp* (((temc_lim+t00)/t00)**1.94_rp) *(pstd/pre_lim)
4103  ! v_th = sqrt(8*Rv*T/pi) in the paragraph after eq(2) in Karcher etal.(2006)
4104  b2 = 0.5_rp/dw*sqrt(rvap*wtem*r2pi)
4105  b1 = (si-1.0_rp)*0.5_rp*rrhoi*esi/sqrt(2.0_rp*pi*rvap*wtem)
4106  a2 = mw*rvap*wtem/(nav*esi)
4107  a3 = epsvap*mw*lhs0*lhs0/(nav*cpa(k)*pre(k)*wtem)
4108  delta = b2*rw
4109  kappa = 2.0_rp*b1*b2/( rtau*(1.0_rp+delta)*(1.0_rp+delta) )
4110  ! (A9) in RM05
4111  rim_w = max(1.e-20_rp, 0.5_rp*(1.0_rp+delta)*(3.0_rp*kappa/(2.0_rp+sqrt(1.0_rp+9.0_rp/pi*kappa))) &
4112  + 1.0_rp/(1.0_rp+delta)*(3.0_rp /(2.0_rp+sqrt(1.0_rp+9.0_rp/pi*kappa)))+delta-1.0_rp )
4113  pnihom(k) = min( scr/(scr-1.0_rp)*a1*wp/(rim_w*4.0_rp*pi*dw/b2), ni_max )* rdt
4114  ri_wrk = 1.0_rp+b2*rw
4115  ri = ( sqrt(ri_wrk*ri_wrk + 2.0_rp*b1*b2*dt )-1.0_rp )/b2
4116  plihom(k) = coef_mi*ri*ri*ri*pnihom(k)
4117  else
4118  plihom(k) = 0.0_rp
4119  pnihom(k) = 0.0_rp
4120  endif
4121  enddo
4122  !
4123  return
4124  end subroutine nucleation_ice_hom
4125 
4126 !OCL SERIAL
4127  subroutine ice_multiplication( &
4128  KA, KS, KE, & ! in
4129  flg_lt, & ! in
4130  Pac, & ! in
4131  tem, rhoq, & ! in
4132  rhoq_crg, xq, & ! in
4133  PQ, Pcrg1 ) ! inout
4135  ! ice multiplication by splintering
4136  ! we consider Hallet-Mossop process
4137  use scale_specfunc, only: &
4138  gammafunc => sf_gamma
4139  implicit none
4140  integer, intent(in) :: KA, KS, KE
4141 
4142  real(RP), intent(in) :: Pac(KA,Pac_MAX)
4143  real(RP), intent(in) :: tem(KA)
4144  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
4145  real(RP), intent(in) :: xq(KA,HYDRO_MAX)
4146  !
4147  real(RP), intent(inout):: PQ(KA,PQ_MAX)
4148  ! for lightning
4149  logical, intent(in) :: flg_lt
4150  real(RP), intent(in) :: rhoq_crg(KA,I_QC:I_QG)
4151  real(RP), intent(inout):: Pcrg1(KA,PQ_MAX)
4152  !
4153  ! production of (350.d3 ice particles)/(cloud riming [g]) => 350*d6 [/kg]
4154  real(RP), parameter :: pice = 350.0e+6_rp
4155  ! production of (1 ice particle)/(250 cloud particles riming)
4156  real(RP), parameter :: pnc = 250.0_rp
4157  ! temperature factor
4158  real(RP) :: fp
4159 
4160  real(RP) :: igm ! in complete gamma(x,alpha)
4161  real(RP) :: x
4162  ! coefficient of expansion using in calculation of igm
4163  real(RP) :: a0,a1,a2,a3,a4,a5
4164  real(RP) :: a6,a7,a8,a9,a10
4165  real(RP) :: an1,an2,b0,b1,b2,c0,c1,c2
4166  real(RP) :: d0,d1,d2,e1,e2,h0,h1,h2
4167  real(RP), parameter :: eps=1.0e-30_rp
4168  ! number of cloud droplets larger than 12 micron(radius).
4169  real(RP) :: n12
4170  !
4171  real(RP) :: wn, wni, wns, wng
4172  integer :: k, iq
4173  real(RP) :: sw1
4174  !
4175  !
4176 !OCL LOOP_FISSION_TARGET(LS)
4177  do k = ks, ke
4178  ! Here we assume particle temperature is same as environment temperature.
4179  ! If you want to treat in a better manner,
4180  ! you can diagnose with eq.(64) in CT(86)
4181  if (tem(k) > 270.16_rp)then
4182  fp = 0.0_rp
4183  else if(tem(k) >= 268.16_rp)then
4184  fp = (270.16_rp-tem(k))*0.5_rp
4185  else if(tem(k) >= 265.16_rp)then
4186  fp = (tem(k)-265.16_rp)*0.333333333_rp
4187  else
4188  fp = 0.0_rp
4189  end if
4190  ! Approximation of Incomplete Gamma function
4191  ! Here we calculate with algorithm by Numerical Recipes.
4192  ! This approach is based on eq.(78) in Cotton etal.(1986),
4193  ! but more accurate and expanded for Generalized Gamma Distribution.
4194  x = coef_lambda(i_mp_qc)*(xc_cr/xq(k,i_mp_qc))**mu(i_mp_qc)
4195  !
4196  if(x<1.e-2_rp*alpha)then ! negligible
4197  igm = 0.0_rp
4198  else if(x<alpha+1.0_rp)then ! series expansion
4199  ! 10th-truncation is enough for cloud droplet.
4200  a0 = 1.0_rp/alpha ! n=0
4201  a1 = a0*x/(alpha+1.0_rp) ! n=1
4202  a2 = a1*x/(alpha+2.0_rp) ! n=2
4203  a3 = a2*x/(alpha+3.0_rp) ! n=3
4204  a4 = a3*x/(alpha+4.0_rp) ! n=4
4205  a5 = a4*x/(alpha+5.0_rp) ! n=5
4206  a6 = a5*x/(alpha+6.0_rp) ! n=6
4207  a7 = a6*x/(alpha+7.0_rp) ! n=7
4208  a8 = a7*x/(alpha+8.0_rp) ! n=8
4209  a9 = a8*x/(alpha+9.0_rp) ! n=9
4210  a10 = a9*x/(alpha+10.0_rp) ! n=10
4211  igm = (a0+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10)*exp( -x + alpha*log(x) - lgm )
4212  else if(x<alpha*100.0_rp) then ! continued fraction expansion
4213  ! 2nd-truncation is enough for cloud droplet.
4214  ! setup
4215  b0 = x+1.0_rp-alpha
4216  c0 = 1.0_rp/eps
4217  d0 = 1.0_rp/b0
4218  h0 = d0
4219  ! n=1
4220  an1 = -(1.0_rp-alpha)
4221  b1 = b0 + 2.0_rp
4222  d1 = 1.0_rp/(an1*d0+b1)
4223  c1 = b1+an1/c0
4224  e1 = d1*c1
4225  h1 = h0*e1
4226  ! n=2
4227  an2 = -2.0_rp*(2.0_rp-alpha)
4228  b2 = b1 + 2.0_rp
4229  d2 = 1.0_rp/(an2*d1+b2)
4230  c2 = b2+an2/c1
4231  e2 = d2*c2
4232  h2 = h1*e2
4233  !
4234  igm = 1.0_rp - exp( -x + alpha*log(x) - lgm )*h2
4235  else ! negligible
4236  igm = 1.0_rp
4237  end if
4238  ! n12 is number of cloud droplets larger than 12 micron.
4239  n12 = rhoq(k,i_nc)*(1.0_rp-igm)
4240  ! eq.(82) CT(86)
4241  wn = (pice + n12/((rhoq(k,i_qc)+xc_min)*pnc) )*fp ! filtered by xc_min
4242  wni = wn*(-pac(k,i_liaclc2li) ) ! riming production rate is all negative
4243  wns = wn*(-pac(k,i_lsaclc2ls) )
4244  wng = wn*(-pac(k,i_lgaclc2lg) )
4245  pq(k,i_nispl) = wni+wns+wng
4246  !
4247  pq(k,i_lsspl) = - wns*xq(k,i_mp_qi) ! snow => ice
4248  pq(k,i_lgspl) = - wng*xq(k,i_mp_qi) ! graupel => ice
4249  if (flg_lt) then
4250  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NC is small,ignore charge transfer
4251  pcrg1(k,i_nsspl) = - wns*(1.0_rp-sw1) &
4252  / (rhoq(k,i_ns)+sw1)*rhoq_crg(k,i_qs)
4253  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NC is small,ignore charge transfer
4254  pcrg1(k,i_ngspl) = - wng*(1.0_rp-sw1) &
4255  / (rhoq(k,i_ng)+sw1)*rhoq_crg(k,i_qg)
4256  pcrg1(k,i_nispl) = - ( pcrg1(k,i_nsspl) + pcrg1(k,i_ngspl) )
4257  end if
4258  !
4259  end do
4260  !
4261  return
4262  end subroutine ice_multiplication
4263 
4264  !----------------------------
4265 !OCL SERIAL
4266  subroutine mixed_phase_collection( &
4267  ! collection process
4268  KA, KS, KE, & ! in
4269  flg_lt, & ! in
4270  d0_crg, v0_crg, & ! in
4271  beta_crg, dqcrg, & ! in
4272  wtem, rhoq, rhoq_crg, & ! in
4273  xq, dq_xave, vt_xave, & ! in
4274  ! rho ! [Add] 11/08/30
4275  PQ, & ! inout
4276  Pcrg1, Pcrg2, & ! inout
4277  Pac ) ! out
4279  moist_psat_ice => atmos_saturation_psat_ice
4280  implicit none
4281 
4282  integer, intent(in) :: KA, KS, KE
4283 
4284  !--- mixed-phase collection process
4285  ! And all we set all production term as a negative sign to avoid confusion.
4286  !
4287  real(RP), intent(in) :: wtem(KA)
4288  !--- mass/number concentration[kg/m3]
4289  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
4290  ! necessary ?
4291  real(RP), intent(in) :: xq(KA,HYDRO_MAX)
4292  !--- diameter of averaged mass( D(ave x) )
4293  real(RP), intent(in) :: dq_xave(KA,HYDRO_MAX)
4294  !--- terminal velocity of averaged mass( vt(ave x) )
4295  real(RP), intent(in) :: vt_xave(KA,HYDRO_MAX,2)
4296  ! [Add] 11/08/30 T.Mitsui, for autoconversion of ice
4297  ! real(RP), intent(in) :: rho(KA)
4298  !--- partial conversion
4299  real(RP), intent(inout):: PQ(KA,PQ_MAX)
4300  !
4301  real(RP), intent(out):: Pac(KA,Pac_MAX)
4302  !--- for lightning component
4303  logical, intent(in) :: flg_lt
4304  real(RP), intent(in) :: beta_crg(KA)
4305  real(RP), intent(in) :: dqcrg(KA)
4306  real(RP), intent(in) :: d0_crg, v0_crg
4307  real(RP), intent(in) :: rhoq_crg(KA,I_QC:I_QG)
4308  real(RP), intent(inout):: Pcrg1(KA,PQ_MAX)
4309  real(RP), intent(inout):: Pcrg2(KA,Pcrg_MAX)
4310 
4311  real(RP), parameter :: a_dec = 0.883_rp
4312  real(RP), parameter :: b_dec = 0.093_rp
4313  real(RP), parameter :: c_dec = 0.00348_rp
4314  real(RP), parameter :: d_dec = 4.5185e-5_rp
4315  !
4316  !
4317  real(RP) :: tem(KA)
4318  !
4319  !--- collection efficency of each specie
4320  real(RP) :: E_c(KA), E_r, E_i, E_s, E_g
4321  real(RP) :: E_ic, E_sc, E_gc
4322  !--- sticking efficiency
4323  real(RP) :: E_stick(KA)
4324  ! [Add] 10/08/03 T.Mitsui
4325  real(RP) :: temc, temc2, temc3
4326  real(RP) :: E_dec
4327  real(RP) :: esi_rat
4328  real(RP) :: esi(KA)
4329  !
4330  real(RP) :: temc_p, temc_m ! celcius tem.
4331 ! real(RP) :: ci_aut(KA)
4332 ! real(RP) :: taui_aut(KA)
4333 ! real(RP) :: tau_sce(KA)
4334  !--- DSD averaged diameter for each species
4335  real(RP) :: ave_dc ! cloud
4336 ! real(RP) :: ave_dr ! rain
4337  real(RP) :: ave_di(KA) ! ice
4338  real(RP) :: ave_ds(KA) ! snow
4339  real(RP) :: ave_dg ! graupel
4340  !--- coefficient of collection equations(L:mass, N:number)
4341  real(RP) :: coef_acc_LCI, coef_acc_NCI ! cloud - cloud ice
4342  real(RP) :: coef_acc_LCS, coef_acc_NCS ! cloud - snow
4343  !
4344  real(RP) :: coef_acc_LCG, coef_acc_NCG ! cloud - graupel
4345  real(RP) :: coef_acc_LRI_I, coef_acc_NRI_I ! rain - cloud ice
4346  real(RP) :: coef_acc_LRI_R, coef_acc_NRI_R ! rain - cloud ice
4347  real(RP) :: coef_acc_LRS_S, coef_acc_NRS_S ! rain - snow
4348  real(RP) :: coef_acc_LRS_R, coef_acc_NRS_R ! rain - snow
4349  real(RP) :: coef_acc_LRG, coef_acc_NRG ! rain - graupel
4350  real(RP) :: coef_acc_LII, coef_acc_NII ! cloud ice - cloud ice
4351  real(RP) :: coef_acc_LIS, coef_acc_NIS ! cloud ice - snow
4352  real(RP) :: coef_acc_NSS ! snow - snow
4353  real(RP) :: coef_acc_NGG ! grauepl - graupel
4354  real(RP) :: coef_acc_LSG, coef_acc_NSG(KA) ! snow - graupel
4355  !--- (diameter) x (diameter)
4356  real(RP) :: dcdc(KA), dcdi, dcds, dcdg
4357  real(RP) :: drdr(KA), drdi(KA), drds(KA), drdg
4358  real(RP) :: didi(KA), dids, didg
4359  real(RP) :: dsds(KA), dsdg
4360  real(RP) :: dgdg(KA)
4361  !--- (terminal velocity) x (terminal velocity)
4362  real(RP) :: vcvc(KA), vcvi, vcvs, vcvg
4363  real(RP) :: vrvr(KA), vrvi(KA), vrvs(KA), vrvg
4364  real(RP) :: vivi(KA), vivs, vivg
4365  real(RP) :: vsvs(KA), vsvg
4366  real(RP) :: vgvg(KA)
4367  !
4368  real(RP) :: wx_cri, wx_crs
4369  real(RP) :: coef_emelt
4370  real(RP) :: w1
4371 
4372  real(RP) :: sw, sw1, sw2
4373  real(RP) :: alpha_lt
4374  !
4375  integer :: k, iqw
4376  !
4377  !
4378  do k = ks, ke
4379  tem(k) = max( wtem(k), tem_min ) ! 11/08/30 T.Mitsui
4380  end do
4381 
4382  call moist_psat_ice( ka, ks, ke, &
4383  tem(:), esi(:) ) ! [IN], [OUT]
4384 
4385  if( opt_stick_ks96 )then
4386  do k = ks, ke
4387  ! Khain and Sednev (1996), eq.(3.15)
4388  temc = tem(k) - t00
4389  temc2 = temc*temc
4390  temc3 = temc2*temc
4391  e_dec = max(0.0_rp, a_dec + b_dec*temc + c_dec*temc2 + d_dec*temc3 )
4392  esi_rat = rhoq(k,i_qv)*rvap*tem(k)/esi(k)
4393  e_stick(k) = min(1.0_rp, e_dec*esi_rat)
4394  end do
4395  else if( opt_stick_co86 )then
4396  do k = ks, ke
4397  ! [Add] 11/08/30 T.Mitsui, Cotton et al. (1986)
4398  temc = min(tem(k) - t00,0.0_rp)
4399  w1 = 0.035_rp*temc-0.7_rp
4400  e_stick(k) = 10._rp**w1
4401  end do
4402  else
4403  do k = ks, ke
4404  ! Lin et al. (1983)
4405  temc_m = min(tem(k) - t00,0.0_rp) ! T < 273.15
4406  e_stick(k) = exp(0.09_rp*temc_m)
4407  end do
4408  end if
4409 
4410  do k = ks, ke
4411  ! averaged diameter using SB06(82)
4412  ave_dc = coef_d(i_mp_qc)*xq(k,i_mp_qc)**b_m(i_mp_qc)
4413  !------------------------------------------------------------------------
4414  ! coellection efficiency are given as follows
4415  e_c(k) = max(0.0_rp, min(1.0_rp, (ave_dc-dc0)/(dc1-dc0) ))
4416  end do
4417 
4418  !------------------------------------------------------------------------
4419  ! Collection: a collects b ( assuming particle size a>b )
4420  do k = ks, ke
4421  dcdc(k) = dq_xave(k,i_mp_qc) * dq_xave(k,i_mp_qc)
4422  drdr(k) = dq_xave(k,i_mp_qr) * dq_xave(k,i_mp_qr)
4423  didi(k) = dq_xave(k,i_mp_qi) * dq_xave(k,i_mp_qi)
4424  dsds(k) = dq_xave(k,i_mp_qs) * dq_xave(k,i_mp_qs)
4425  dgdg(k) = dq_xave(k,i_mp_qg) * dq_xave(k,i_mp_qg)
4426  drdi(k) = dq_xave(k,i_mp_qr) * dq_xave(k,i_mp_qi)
4427  drds(k) = dq_xave(k,i_mp_qr) * dq_xave(k,i_mp_qs)
4428  end do
4429  do k = ks, ke
4430  vcvc(k) = vt_xave(k,i_mp_qc,2) * vt_xave(k,i_mp_qc,2)
4431  vrvr(k) = vt_xave(k,i_mp_qr,2) * vt_xave(k,i_mp_qr,2)
4432  vivi(k) = vt_xave(k,i_mp_qi,2) * vt_xave(k,i_mp_qi,2)
4433  vsvs(k) = vt_xave(k,i_mp_qs,2) * vt_xave(k,i_mp_qs,2)
4434  vgvg(k) = vt_xave(k,i_mp_qg,2) * vt_xave(k,i_mp_qg,2)
4435  vrvi(k) = vt_xave(k,i_mp_qr,2) * vt_xave(k,i_mp_qi,2)
4436  vrvs(k) = vt_xave(k,i_mp_qr,2) * vt_xave(k,i_mp_qs,2)
4437  end do
4438 
4439  do k = ks, ke
4440  ave_di(k) = coef_d(i_mp_qi)*xq(k,i_mp_qi)**b_m(i_mp_qi)
4441  ave_ds(k) = coef_d(i_mp_qs)*xq(k,i_mp_qs)**b_m(i_mp_qs)
4442  end do
4443 
4444  !------------------------------------------------------------------------
4445  !
4446  !+++ pattern 1: a + b => a (a>b)
4447  ! (i-c, s-c, g-c, s-i, g-r, s-g)
4448  !------------------------------------------------------------------------
4449 
4450  ! cloud-ice => ice
4451  ! reduction term of cloud
4452  do k = ks, ke
4453  dcdi = dq_xave(k,i_mp_qc) * dq_xave(k,i_mp_qi)
4454  vcvi = vt_xave(k,i_mp_qc,2) * vt_xave(k,i_mp_qi,2)
4455  sw = 0.5_rp - sign(0.5_rp, di0-ave_di(k)) ! if(ave_di>di0)then sw=1
4456  e_i = e_im * sw
4457  e_ic = e_i*e_c(k)
4458  coef_acc_lci = &
4459  ( delta_b1(i_mp_qc)*dcdc(k) + delta_ab1(i_mp_qi,i_mp_qc)*dcdi + delta_b0(i_mp_qi)*didi(k) ) &
4460  * sqrt( theta_b1(i_mp_qc)*vcvc(k) - theta_ab1(i_mp_qi,i_mp_qc)*vcvi + theta_b0(i_mp_qi)*vivi(k) &
4461  + sigma_i + sigma_c )
4462  coef_acc_nci = &
4463  ( delta_b0(i_mp_qc)*dcdc(k) + delta_ab0(i_mp_qi,i_mp_qc)*dcdi + delta_b0(i_mp_qi)*didi(k) ) &
4464  * sqrt( theta_b0(i_mp_qc)*vcvc(k) - theta_ab0(i_mp_qi,i_mp_qc)*vcvi + theta_b0(i_mp_qi)*vivi(k) &
4465  + sigma_i + sigma_c )
4466  pac(k,i_liaclc2li)= -0.25_rp*pi*e_ic*rhoq(k,i_ni)*rhoq(k,i_qc)*coef_acc_lci
4467  pac(k,i_niacnc2ni)= -0.25_rp*pi*e_ic*rhoq(k,i_ni)*rhoq(k,i_nc)*coef_acc_nci
4468  end do
4469 
4470  ! cloud-snow => snow
4471  ! reduction term of cloud
4472  do k = ks, ke
4473  dcds = dq_xave(k,i_mp_qc) * dq_xave(k,i_mp_qs)
4474  vcvs = vt_xave(k,i_mp_qc,2) * vt_xave(k,i_mp_qs,2)
4475  sw = 0.5_rp - sign(0.5_rp, ds0-ave_ds(k)) ! if(ave_ds>ds0)then sw=1
4476  e_s = e_sm * sw
4477  e_sc = e_s*e_c(k)
4478  coef_acc_lcs = &
4479  ( delta_b1(i_mp_qc)*dcdc(k) + delta_ab1(i_mp_qs,i_mp_qc)*dcds + delta_b0(i_mp_qs)*dsds(k) ) &
4480  * sqrt( theta_b1(i_mp_qc)*vcvc(k) - theta_ab1(i_mp_qs,i_mp_qc)*vcvs + theta_b0(i_mp_qs)*vsvs(k) &
4481  + sigma_s + sigma_c )
4482  coef_acc_ncs = &
4483  ( delta_b0(i_mp_qc)*dcdc(k) + delta_ab0(i_mp_qs,i_mp_qc)*dcds + delta_b0(i_mp_qs)*dsds(k) ) &
4484  * sqrt( theta_b0(i_mp_qc)*vcvc(k) - theta_ab0(i_mp_qs,i_mp_qc)*vcvs + theta_b0(i_mp_qs)*vsvs(k) &
4485  + sigma_s + sigma_c )
4486  pac(k,i_lsaclc2ls)= -0.25_rp*pi*e_sc*rhoq(k,i_ns)*rhoq(k,i_qc)*coef_acc_lcs
4487  pac(k,i_nsacnc2ns)= -0.25_rp*pi*e_sc*rhoq(k,i_ns)*rhoq(k,i_nc)*coef_acc_ncs
4488  end do
4489 
4490  ! cloud-graupel => graupel
4491  ! reduction term of cloud
4492  do k = ks, ke
4493  dcdg = dq_xave(k,i_mp_qc) * dq_xave(k,i_mp_qg)
4494  vcvg = vt_xave(k,i_mp_qc,2) * vt_xave(k,i_mp_qg,2)
4495  ave_dg = coef_d(i_mp_qg)*xq(k,i_mp_qg)**b_m(i_mp_qg)
4496  sw = 0.5_rp - sign(0.5_rp, dg0-ave_dg) ! if(ave_dg>dg0)then sw=1
4497  e_g = e_gm * sw
4498  e_gc = e_g*e_c(k)
4499  coef_acc_lcg = &
4500  ( delta_b1(i_mp_qc)*dcdc(k) + delta_ab1(i_mp_qg,i_mp_qc)*dcdg + delta_b0(i_mp_qg)*dgdg(k) ) &
4501  * sqrt( theta_b1(i_mp_qc)*vcvc(k) - theta_ab1(i_mp_qg,i_mp_qc)*vcvg + theta_b0(i_mp_qg)*vgvg(k) &
4502  + sigma_g + sigma_c )
4503  coef_acc_ncg = &
4504  ( delta_b0(i_mp_qc)*dcdc(k) + delta_ab0(i_mp_qg,i_mp_qc)*dcdg + delta_b0(i_mp_qg)*dgdg(k) ) &
4505  * sqrt( theta_b0(i_mp_qc)*vcvc(k) - theta_ab0(i_mp_qg,i_mp_qc)*vcvg + theta_b0(i_mp_qg)*vgvg(k) &
4506  + sigma_g + sigma_c )
4507  pac(k,i_lgaclc2lg)= -0.25_rp*pi*e_gc*rhoq(k,i_ng)*rhoq(k,i_qc)*coef_acc_lcg
4508  pac(k,i_ngacnc2ng)= -0.25_rp*pi*e_gc*rhoq(k,i_ng)*rhoq(k,i_nc)*coef_acc_ncg
4509  end do
4510 
4511  ! snow-graupel => graupel
4512  do k = ks, ke
4513  dsdg = dq_xave(k,i_mp_qs) * dq_xave(k,i_mp_qg)
4514  vsvg = vt_xave(k,i_mp_qs,2) * vt_xave(k,i_mp_qg,2)
4515  coef_acc_lsg = &
4516  ( delta_b1(i_mp_qs)*dsds(k) + delta_ab1(i_mp_qg,i_mp_qs)*dsdg + delta_b0(i_mp_qg)*dgdg(k) ) &
4517  * sqrt( theta_b1(i_mp_qs)*vsvs(k) - theta_ab1(i_mp_qg,i_mp_qs)*vsvg + theta_b0(i_mp_qg)*vgvg(k) &
4518  + sigma_g + sigma_s )
4519  coef_acc_nsg(k) = &
4520  ( delta_b0(i_mp_qs)*dsds(k) + delta_ab0(i_mp_qg,i_mp_qs)*dsdg + delta_b0(i_mp_qg)*dgdg(k) ) &
4521  ! [fix] T.Mitsui 08/05/08
4522  * sqrt( theta_b0(i_mp_qs)*vsvs(k) - theta_ab0(i_mp_qg,i_mp_qs)*vsvg + theta_b0(i_mp_qg)*vgvg(k) &
4523  + sigma_g + sigma_s )
4524  pac(k,i_lgacls2lg)= -0.25_rp*pi*e_stick(k)*e_gs*rhoq(k,i_ng)*rhoq(k,i_qs)*coef_acc_lsg
4525  pac(k,i_ngacns2ng)= -0.25_rp*pi*e_stick(k)*e_gs*rhoq(k,i_ng)*rhoq(k,i_ns)*coef_acc_nsg(k)
4526  end do
4527 
4528  !-----------------
4529  ! (start) Y.Sato added on 2018/8/31
4530  !--- ice-graupel => graupel
4531 !!$ do k = KS, KE
4532 !!$ didg = dq_xave(k,I_mp_QI) * dq_xave(k,I_mp_QG)
4533 !!$ vivg = vt_xave(k,I_mp_QI,2) * vt_xave(k,I_mp_QG,2)
4534 !!$ coef_acc_LIG = &
4535 !!$ ( delta_b1(I_QI)*didi(k) + delta_ab1(I_QG,I_QI)*didg + delta_b0(I_QG)*dgdg(k) ) &
4536 !!$ * sqrt( theta_b1(I_QI)*vivi(k) - theta_ab1(I_QG,I_QI)*vivg + theta_b0(I_QG)*vgvg(k) &
4537 !!$ + sigma_g + sigma_i )
4538 !!$ coef_acc_NIG(k) = &
4539 !!$ ( delta_b0(I_QI)*didi(k) + delta_ab0(I_QG,I_QI)*didg + delta_b0(I_QG)*dgdg(k) ) &
4540 !!$ * sqrt( theta_b0(I_QI)*vivi(k) - theta_ab0(I_QG,I_QI)*vivg + theta_b0(I_QG)*vgvg(k) &
4541 !!$ + sigma_g + sigma_i )
4542 !!$ Pac(k,I_LGacLI2LG)= -0.25_RP*pi*E_stick(k)*E_gi*rhoq(k,I_NG)*rhoq(k,I_QI)*coef_acc_LIG*flg_igcol
4543 !!$ Pac(k,I_NGacNI2NG)= -0.25_RP*pi*E_stick(k)*E_gi*rhoq(k,I_NG)*rhoq(k,I_NI)*coef_acc_NIG(k)*flg_igcol
4544 !!$ end do
4545 
4546  !------------------------------------------------------------------------
4547  ! ice-snow => snow
4548  ! reduction term of ice
4549  do k = ks, ke
4550  dids = dq_xave(k,i_mp_qi) * dq_xave(k,i_mp_qs)
4551  vivs = vt_xave(k,i_mp_qi,2) * vt_xave(k,i_mp_qs,2)
4552  coef_acc_lis = &
4553  ( delta_b1(i_mp_qi)*didi(k) + delta_ab1(i_mp_qs,i_mp_qi)*dids + delta_b0(i_mp_qs)*dsds(k) ) &
4554  * sqrt( theta_b1(i_mp_qi)*vivi(k) - theta_ab1(i_mp_qs,i_mp_qi)*vivs + theta_b0(i_mp_qs)*vsvs(k) &
4555  + sigma_i + sigma_s )
4556  coef_acc_nis = &
4557  ( delta_b0(i_mp_qi)*didi(k) + delta_ab0(i_mp_qs,i_mp_qi)*dids + delta_b0(i_mp_qs)*dsds(k) ) &
4558  * sqrt( theta_b0(i_mp_qi)*vivi(k) - theta_ab0(i_mp_qs,i_mp_qi)*vivs + theta_b0(i_mp_qs)*vsvs(k) &
4559  + sigma_i + sigma_s )
4560  pac(k,i_liacls2ls)= -0.25_rp*pi*e_stick(k)*e_si*rhoq(k,i_ns)*rhoq(k,i_qi)*coef_acc_lis
4561  pac(k,i_niacns2ns)= -0.25_rp*pi*e_stick(k)*e_si*rhoq(k,i_ns)*rhoq(k,i_ni)*coef_acc_nis
4562  end do
4563 
4564  do k = ks, ke
4565  drdg = dq_xave(k,i_mp_qr) * dq_xave(k,i_mp_qg)
4566  vrvg = vt_xave(k,i_mp_qr,2) * vt_xave(k,i_mp_qg,2)
4567  sw = sign(0.5_rp, t00-tem(k)) + 0.5_rp
4568  ! if ( tem(k) <= T00 )then
4569  ! rain-graupel => graupel
4570  ! reduction term of rain
4571  ! sw = 1
4572  ! else
4573  ! rain-graupel => rain
4574  ! reduction term of graupel
4575  ! sw = 0
4576  coef_acc_lrg = &
4577  ( ( delta_b1(i_mp_qr)*drdr(k) + delta_ab1(i_mp_qg,i_mp_qr)*drdg + delta_b0(i_mp_qg)*dgdg(k) ) * sw &
4578  + ( delta_b1(i_mp_qg)*dgdg(k) + delta_ab1(i_mp_qr,i_mp_qg)*drdg + delta_b0(i_mp_qr)*drdr(k) ) * (1.0_rp-sw) ) &
4579  * sqrt( ( theta_b1(i_mp_qr)*vrvr(k) - theta_ab1(i_mp_qg,i_mp_qr)*vrvg + theta_b0(i_mp_qg)*vgvg(k) ) * sw &
4580  + ( theta_b1(i_mp_qg)*vgvg(k) - theta_ab1(i_mp_qr,i_mp_qg)*vrvg + theta_b0(i_mp_qr)*vrvr(k) ) * (1.0_rp-sw) &
4581  + sigma_r + sigma_g )
4582  pac(k,i_lraclg2lg) = -0.25_rp*pi*e_gr*coef_acc_lrg * ( rhoq(k,i_ng)*rhoq(k,i_qr) * sw &
4583  + rhoq(k,i_nr)*rhoq(k,i_qg) * (1.0_rp-sw) )
4584  coef_acc_nrg = &
4585  ( delta_b0(i_mp_qr)*drdr(k) + delta_ab0(i_mp_qg,i_mp_qr)*drdg + delta_b0(i_mp_qg)*dgdg(k) ) &
4586  * sqrt( theta_b0(i_mp_qr)*vrvr(k) - theta_ab0(i_mp_qg,i_mp_qr)*vrvg + theta_b0(i_mp_qg)*vgvg(k) &
4587  + sigma_r + sigma_g )
4588  pac(k,i_nracng2ng) = -0.25_rp*pi*e_gr*rhoq(k,i_ng)*rhoq(k,i_nr)*coef_acc_nrg
4589  end do
4590 
4591  !------------------------------------------------------------------------
4592  !
4593  !+++ pattern 2: a + b => c (a>b)
4594  ! (r-i,r-s)
4595  !------------------------------------------------------------------------
4596 
4597  ! rain-ice => graupel
4598  ! reduction term of ice
4599  do k = ks, ke
4600  coef_acc_lri_i = &
4601  ( delta_b1(i_mp_qi)*didi(k) + delta_ab1(i_mp_qr,i_mp_qi)*drdi(k) + delta_b0(i_mp_qr)*drdr(k) ) &
4602  * sqrt( theta_b1(i_mp_qi)*vivi(k) - theta_ab1(i_mp_qr,i_mp_qi)*vrvi(k) + theta_b0(i_mp_qr)*vrvr(k) &
4603  + sigma_r + sigma_i )
4604  coef_acc_nri_i = &
4605  ( delta_b0(i_mp_qi)*didi(k) + delta_ab0(i_mp_qr,i_mp_qi)*drdi(k) + delta_b0(i_mp_qr)*drdr(k) ) &
4606  * sqrt( theta_b0(i_mp_qi)*vivi(k) - theta_ab0(i_mp_qr,i_mp_qi)*vrvi(k) + theta_b0(i_mp_qr)*vrvr(k) &
4607  + sigma_r + sigma_i )
4608  pac(k,i_lracli2lg_i)= -0.25_rp*pi*e_ir*rhoq(k,i_nr)*rhoq(k,i_qi)*coef_acc_lri_i
4609  pac(k,i_nracni2ng_i)= -0.25_rp*pi*e_ir*rhoq(k,i_nr)*rhoq(k,i_ni)*coef_acc_nri_i
4610  end do
4611 
4612  ! reduction term of rain
4613  do k = ks, ke
4614  coef_acc_lri_r = &
4615  ( delta_b1(i_mp_qr)*drdr(k) + delta_ab1(i_mp_qi,i_mp_qr)*drdi(k) + delta_b0(i_mp_qi)*didi(k) ) &
4616  * sqrt( theta_b1(i_mp_qr)*vrvr(k) - theta_ab1(i_mp_qi,i_mp_qr)*vrvi(k) + theta_b0(i_mp_qi)*vivi(k) &
4617  + sigma_r + sigma_i )
4618  coef_acc_nri_r = &
4619  ( delta_b0(i_mp_qr)*drdr(k) + delta_ab0(i_mp_qi,i_mp_qr)*drdi(k) + delta_b0(i_mp_qi)*didi(k) ) &
4620  * sqrt( theta_b0(i_mp_qr)*vrvr(k) - theta_ab0(i_mp_qi,i_mp_qr)*vrvi(k) + theta_b0(i_mp_qi)*vivi(k) &
4621  + sigma_r + sigma_i )
4622  pac(k,i_lracli2lg_r)= -0.25_rp*pi*e_ir*rhoq(k,i_ni)*rhoq(k,i_qr)*coef_acc_lri_r
4623  pac(k,i_nracni2ng_r)= -0.25_rp*pi*e_ir*rhoq(k,i_ni)*rhoq(k,i_nr)*coef_acc_nri_r
4624  end do
4625 
4626  ! rain-snow => graupel
4627  ! reduction term of snow
4628  do k = ks, ke
4629  coef_acc_lrs_s = &
4630  ( delta_b1(i_mp_qs)*dsds(k) + delta_ab1(i_mp_qr,i_mp_qs)*drds(k) + delta_b0(i_mp_qr)*drdr(k) ) &
4631  * sqrt( theta_b1(i_mp_qs)*vsvs(k) - theta_ab1(i_mp_qr,i_mp_qs)*vrvs(k) + theta_b0(i_mp_qr)*vrvr(k) &
4632  + sigma_r + sigma_s )
4633  coef_acc_nrs_s = &
4634  ( delta_b0(i_mp_qs)*dsds(k) + delta_ab0(i_mp_qr,i_mp_qs)*drds(k) + delta_b0(i_mp_qr)*drdr(k) ) &
4635  * sqrt( theta_b0(i_mp_qs)*vsvs(k) - theta_ab0(i_mp_qr,i_mp_qs)*vrvs(k) + theta_b0(i_mp_qr)*vrvr(k) &
4636  + sigma_r + sigma_s )
4637  pac(k,i_lracls2lg_s)= -0.25_rp*pi*e_sr*rhoq(k,i_nr)*rhoq(k,i_qs)*coef_acc_lrs_s
4638  pac(k,i_nracns2ng_s)= -0.25_rp*pi*e_sr*rhoq(k,i_nr)*rhoq(k,i_ns)*coef_acc_nrs_s
4639  end do
4640 
4641  ! reduction term of rain
4642  do k = ks, ke
4643  coef_acc_lrs_r = &
4644  ( delta_b1(i_mp_qr)*drdr(k) + delta_ab1(i_mp_qs,i_mp_qr)*drds(k) + delta_b0(i_mp_qs)*dsds(k) ) &
4645  * sqrt( theta_b1(i_mp_qr)*vrvr(k) - theta_ab1(i_mp_qs,i_mp_qr)*vrvs(k) + theta_b0(i_mp_qs)*vsvs(k) &
4646  + sigma_r + sigma_s )
4647  coef_acc_nrs_r = &
4648  ( delta_b0(i_mp_qr)*drdr(k) + delta_ab0(i_mp_qs,i_mp_qr)*drds(k) + delta_b0(i_mp_qs)*dsds(k) ) &
4649  * sqrt( theta_b0(i_mp_qr)*vrvr(k) - theta_ab0(i_mp_qs,i_mp_qr)*vrvs(k) + theta_b0(i_mp_qs)*vsvs(k) &
4650  + sigma_r + sigma_s )
4651  pac(k,i_lracls2lg_r)= -0.25_rp*pi*e_sr*rhoq(k,i_ns)*rhoq(k,i_qr)*coef_acc_lrs_r
4652  pac(k,i_nracns2ng_r)= -0.25_rp*pi*e_sr*rhoq(k,i_ns)*rhoq(k,i_nr)*coef_acc_nrs_r
4653  end do
4654 
4655  !------------------------------------------------------------------------
4656  !
4657  !+++ pattern 3: a + a => b (i-i)
4658  !
4659  !------------------------------------------------------------------------
4660 
4661  ! ice-ice ( reduction is double, but includes double-count)
4662  do k = ks, ke
4663  coef_acc_lii = &
4664  ( delta_b0(i_mp_qi)*didi(k) + delta_ab1(i_mp_qi,i_mp_qi)*didi(k) + delta_b1(i_mp_qi)*didi(k) ) &
4665  * sqrt( theta_b0(i_mp_qi)*vivi(k) - theta_ab1(i_mp_qi,i_mp_qi)*vivi(k) + theta_b1(i_mp_qi)*vivi(k) &
4666  + sigma_i + sigma_i )
4667  coef_acc_nii = &
4668  ( delta_b0(i_mp_qi)*didi(k) + delta_ab0(i_mp_qi,i_mp_qi)*didi(k) + delta_b0(i_mp_qi)*didi(k) ) &
4669  * sqrt( theta_b0(i_mp_qi)*vivi(k) - theta_ab0(i_mp_qi,i_mp_qi)*vivi(k) + theta_b0(i_mp_qi)*vivi(k) &
4670  + sigma_i + sigma_i )
4671  pac(k,i_liacli2ls)= -0.25_rp*pi*e_stick(k)*e_ii*rhoq(k,i_ni)*rhoq(k,i_qi)*coef_acc_lii
4672  pac(k,i_niacni2ns)= -0.25_rp*pi*e_stick(k)*e_ii*rhoq(k,i_ni)*rhoq(k,i_ni)*coef_acc_nii
4673 
4674 ! ci_aut(k) = 0.25_RP*pi*E_ii*rhoq(k,I_NI)*coef_acc_LII
4675 ! taui_aut(k) = 1._RP/max(E_stick(k)*ci_aut(k),1.E-10_RP)
4676 ! tau_sce(k) = rhoq(k,I_QI)/max(rhoq(k,I_QIj)+rhoq(k,I_QS),1.E-10_RP)
4677  end do
4678 
4679  !------------------------------------------------------------------------
4680  !
4681  !+++ pattern 4: a + a => a (s-s)
4682  !
4683  !------------------------------------------------------------------------
4684 
4685  ! snow-snow => snow
4686  do k = ks, ke
4687  coef_acc_nss = &
4688  ( delta_b0(i_mp_qs)*dsds(k) + delta_ab0(i_mp_qs,i_mp_qs)*dsds(k) + delta_b0(i_mp_qs)*dsds(k) ) &
4689  * sqrt( theta_b0(i_mp_qs)*vsvs(k) - theta_ab0(i_mp_qs,i_mp_qs)*vsvs(k) + theta_b0(i_mp_qs)*vsvs(k) &
4690  + sigma_s + sigma_s )
4691  pac(k,i_nsacns2ns)= -0.125_rp*pi*e_stick(k)*e_ss*rhoq(k,i_ns)*rhoq(k,i_ns)*coef_acc_nss
4692  end do
4693 
4694  ! graupel-grauple => graupel
4695  do k = ks, ke
4696  coef_acc_ngg = &
4697  ( delta_b0(i_mp_qg)*dgdg(k) + delta_ab0(i_mp_qg,i_mp_qg)*dgdg(k) + delta_b0(i_mp_qg)*dgdg(k) ) &
4698  * sqrt( theta_b0(i_mp_qg)*vgvg(k) - theta_ab0(i_mp_qg,i_mp_qg)*vgvg(k) + theta_b0(i_mp_qg)*vgvg(k) &
4699  + sigma_g + sigma_g )
4700  pac(k,i_ngacng2ng)= -0.125_rp*pi*e_stick(k)*e_gg*rhoq(k,i_ng)*rhoq(k,i_ng)*coef_acc_ngg
4701  end do
4702 
4703  !------------------------------------------------------------------------
4704  !--- Partial conversion
4705  ! SB06(70),(71)
4706  ! i_iconv2g: option whether partial conversions work or not
4707 
4708  ! ice-cloud => graupel
4709  do k = ks, ke
4710  sw = 0.5_rp - sign(0.5_rp,di_cri-ave_di(k)) ! if( ave_di > di_cri )then sw=1
4711  wx_cri = cfill_i*dwatr/rho_g*( pi/6.0_rp*rho_g*ave_di(k)**3/xq(k,i_mp_qi) - 1.0_rp ) * sw
4712  pq(k,i_licon) = i_iconv2g * pac(k,i_liaclc2li)/max(1.0_rp, wx_cri) * sw
4713  pq(k,i_nicon) = i_iconv2g * pq(k,i_licon)/xq(k,i_mp_qi) * sw
4714  end do
4715 
4716  ! snow-cloud => graupel
4717  do k = ks, ke
4718  wx_crs = cfill_s*dwatr/rho_g*( pi/6.0_rp*rho_g*ave_ds(k)**3/xq(k,i_mp_qs) - 1.0_rp )
4719  pq(k,i_lscon) = i_sconv2g * (pac(k,i_lsaclc2ls))/max(1.0_rp, wx_crs)
4720  pq(k,i_nscon) = i_sconv2g * pq(k,i_lscon)/xq(k,i_mp_qs)
4721  end do
4722 
4723  !--- enhanced melting( due to collection-freezing of water droplets )
4724  ! originally from Rutledge and Hobbs(1984). eq.(A.21)
4725  ! if T > 273.15 then temc_p=T-273.15, else temc_p=0
4726  ! 08/05/08 [fix] T.Mitsui LHF00 => LHF0
4727  ! melting occurs around T=273K, so LHF0 is suitable both SIMPLE and EXACT,
4728  ! otherwise LHF can have sign both negative(EXACT) and positive(SIMPLE).
4729  do k = ks, ke
4730 ! temc_m = min(tem(k) - T00, 0.0_RP) ! T < 273.15
4731  temc_p = max(tem(k) - t00, 0.0_rp) ! T > 273.15
4732 !!$ coef_emelt = -CL/LHF00*temc_p
4733  coef_emelt = cl/lhf0*temc_p
4734  ! cloud-graupel
4735  pq(k,i_lgacm) = coef_emelt*pac(k,i_lgaclc2lg)
4736  pq(k,i_ngacm) = pq(k,i_lgacm)/xq(k,i_mp_qg)
4737  ! rain-graupel
4738  pq(k,i_lgarm) = coef_emelt*pac(k,i_lraclg2lg)
4739  pq(k,i_ngarm) = pq(k,i_lgarm)/xq(k,i_mp_qg)
4740  ! cloud-snow
4741  pq(k,i_lsacm) = coef_emelt*(pac(k,i_lsaclc2ls))
4742  pq(k,i_nsacm) = pq(k,i_lsacm)/xq(k,i_mp_qs)
4743  ! rain-snow
4744  pq(k,i_lsarm) = coef_emelt*(pac(k,i_lracls2lg_r)+pac(k,i_lracls2lg_s))
4745  pq(k,i_nsarm) = pq(k,i_lsarm)/xq(k,i_mp_qg)
4746  ! cloud-ice
4747  pq(k,i_liacm) = coef_emelt*pac(k,i_liaclc2li)
4748  pq(k,i_niacm) = pq(k,i_liacm)/xq(k,i_mp_qi)
4749  ! rain-ice
4750  pq(k,i_liarm) = coef_emelt*(pac(k,i_lracli2lg_r)+pac(k,i_lracli2lg_i))
4751  pq(k,i_niarm) = pq(k,i_liarm)/xq(k,i_mp_qg)
4752  end do
4753 
4754 
4755  !---- for charge density
4756  if ( flg_lt ) then
4757  !--- C + I -> I (decrease from cloud charge)
4758  do k = ks, ke
4759  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small ) !--- if NC is small, ignore charge transfer
4760  pcrg2(k,i_niacnc2ni) = pac(k,i_niacnc2ni)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
4761  end do
4762 
4763  !--- C + S -> S (decrease from cloud charge)
4764  do k = ks, ke
4765  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small ) !--- if NC is small, ignore charge transfer
4766  pcrg2(k,i_nsacnc2ns) = pac(k,i_nsacnc2ns)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
4767  end do
4768 
4769  !--- C + G -> G (decrease from cloud charge)
4770  do k = ks, ke
4771  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small ) !--- if NC is small, ignore charge transfer
4772  pcrg2(k,i_ngacnc2ng) = pac(k,i_ngacnc2ng)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
4773  end do
4774 
4775  !--- S + G -> G (decrease from snow charge)
4776  do k = ks, ke
4777  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
4778  pcrg2(k,i_ngacns2ng) = pac(k,i_ngacns2ng)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
4779  end do
4780 
4781  !--- Charge separation by Snow-Graupel rebound--------------------------------
4782  do k = ks, ke
4783  alpha_lt = 5.0_rp * ( dq_xave(k,i_mp_qs) / d0_crg )**2 * vt_xave(k,i_mp_qg,2) / v0_crg
4784  alpha_lt = min( alpha_lt, 10.0_rp )
4785  pcrg2(k,i_cgngacns2ng)= 0.25_rp*pi*( 1.0_rp - e_stick(k) )*e_gs &
4786  * rhoq(k,i_ng)*rhoq(k,i_ns)*coef_acc_nsg(k) &
4787  * ( dqcrg(k)*alpha_lt ) &
4788  * beta_crg(k)
4789  end do
4790 
4791  !--- I + G -> G (decrease from snow charge)
4792 !!$ do k = KS, KE
4793 !!$ sw1 = 0.5_RP - sign( 0.5_RP, rhoq(k,I_NI)-SMALL ) !--- if NS is small, ignore charge transfer
4794 !!$ Pcrg2(k,I_NGacNI2NG) = Pac(k,I_NGacNI2NG)*(1.0_RP-sw1) / (rhoq(k,I_NI)+sw1) * rhoq_crg(k,I_QI) * flg_igcol
4795 !!$ !--- Charge separation by Ice-Graupel rebound--------------------------------
4796 !!$ alpha_lt = 5.0_RP * ( dq_xave(k,I_mp_QI) / d0_crg )**2 * vt_xave(k,I_mp_QG,2) / v0_crg
4797 !!$ alpha_lt = min( alpha_lt, 10.0_RP )
4798 !!$ Pcrg2(k,I_CGNGacNI2NG)= 0.25_RP*pi*( 1.0_RP - E_stick(k) )*E_gi &
4799 !!$ * rhoq(k,I_NG)*rhoq(k,I_NI)*coef_acc_NIG(k) &
4800 !!$ * ( dqcrg(k)*alpha_lt ) &
4801 !!$ * beta_crg(k) * flg_igcol
4802 !!$ end do
4803 
4804  !--- I + S -> S (decrease from ice charge)
4805  do k = ks, ke
4806  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4807  pcrg2(k,i_niacns2ns) = pac(k,i_niacns2ns)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4808  end do
4809 
4810  !--- R+G->R (T>T00 sw=0, decrease from graupel charge), ->G(T<=T00 sw=1, dcrerase from rain charge)
4811  do k = ks, ke
4812  sw = 0.5_rp + sign( 0.5_rp, t00-tem(k) )
4813  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small ) !--- if NR is small, ignore charge transfer
4814  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NG is small, ignore charge transfer
4815  pcrg2(k,i_nracng2ng) = pac(k,i_nracng2ng)*(1.0_rp-sw1)/(rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr) * sw &
4816  + pac(k,i_nracng2ng)*(1.0_rp-sw2)/(rhoq(k,i_ng)+sw2) * rhoq_crg(k,i_qg) * (1.0_rp-sw)
4817  end do
4818 
4819  !--- R + I -> G (decrease from both ice and rain charge, but only ice charge at this part)
4820  do k = ks, ke
4821  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4822  pcrg2(k,i_nracni2ng_i) = pac(k,i_nracni2ng_i)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4823  end do
4824 
4825  !--- R + I -> G (decrease from both ice and rain charge, but only rain charge at this part)
4826  do k = ks, ke
4827  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small ) !--- if NR is small, ignore charge transfer
4828  pcrg2(k,i_nracni2ng_r) = pac(k,i_nracni2ng_r)*(1.0_rp-sw1) / (rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr)
4829  end do
4830 
4831  !--- R + S -> G (decrease from both snow and rain charge, but only snow charge at this part)
4832  do k = ks, ke
4833  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
4834  pcrg2(k,i_nracns2ng_s) = pac(k,i_nracns2ng_s)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
4835  end do
4836 
4837  !--- R + S -> G (decrease from both snow and rain charge, but only rain charge at this part)
4838  do k = ks, ke
4839  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small ) !--- if NR is small, ignore charge transfer
4840  pcrg2(k,i_nracns2ng_r) = pac(k,i_nracns2ng_r)*(1.0_rp-sw1) / (rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr)
4841  end do
4842 
4843  !--- I + I -> S (decrease from ice charge)
4844  do k = ks, ke
4845  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4846  pcrg2(k,i_niacni2ns) = pac(k,i_niacni2ns)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4847  end do
4848 
4849  !--- I + C -> G (decrease from ice charge)
4850  do k = ks, ke
4851  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4852  pcrg1(k,i_nicon) = i_iconv2g * pq(k,i_nicon)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4853  end do
4854 
4855  !--- S + C -> G (decrease from snow charge)
4856  do k = ks, ke
4857  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
4858  pcrg1(k,i_nscon) = i_sconv2g * pq(k,i_nscon)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
4859  end do
4860 
4861  do k = ks, ke
4862  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NG is small, ignore charge transfer
4863  pcrg1(k,i_ngacm) = pq(k,i_ngacm)*(1.0_rp-sw1) / (rhoq(k,i_ng)+sw1) * rhoq_crg(k,i_qg)
4864  end do
4865 
4866  do k = ks, ke
4867  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NG is small, ignore charge transfer
4868  pcrg1(k,i_ngarm) = pq(k,i_ngarm)*(1.0_rp-sw1) / (rhoq(k,i_ng)+sw1) * rhoq_crg(k,i_qg)
4869  end do
4870 
4871  do k = ks, ke
4872  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
4873  pcrg1(k,i_nsacm) = pq(k,i_nsacm)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
4874  end do
4875 
4876  do k = ks, ke
4877  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
4878  pcrg1(k,i_nsarm) = pq(k,i_nsarm)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
4879  end do
4880 
4881  do k = ks, ke
4882  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4883  pcrg1(k,i_niacm) = pq(k,i_niacm)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4884  end do
4885 
4886  do k = ks, ke
4887  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
4888  pcrg1(k,i_niarm) = pq(k,i_niarm)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
4889  end do
4890 
4891  end if
4892 
4893  return
4894  end subroutine mixed_phase_collection
4895 
4896 !OCL SERIAL
4897  subroutine mixed_phase_collection_bin( &
4898  ! collection process
4899  KA, KS, KE, & ! in
4900  flg_lt, & ! in
4901  d0_crg, v0_crg, & ! in
4902  beta_crg, dqcrg, & ! in
4903  wtem, rhoq, rhoq_crg, & ! in
4904  xq, dq_xave, vt_xave, & ! in
4905  rho, & ! in
4906  PQ, & ! inout
4907  Pcrg1, Pcrg2, & ! inout
4908  Pac ) ! out
4910  moist_psat_ice => atmos_saturation_psat_ice
4911  use scale_prc, only: &
4912  prc_abort
4913  implicit none
4914 
4915  integer, intent(in) :: KA, KS, KE
4916 
4917  !--- mixed-phase collection process
4918  ! And all we set all production term as a negative sign to avoid confusion.
4919  !
4920  real(RP), intent(in) :: wtem(KA)
4921  !--- mass/number concentration[kg/m3]
4922  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
4923  real(RP), intent(in) :: rho(KA) ! air density
4924  ! necessary ?
4925  real(RP), intent(in) :: xq(KA,HYDRO_MAX)
4926  !--- diameter of averaged mass( D(ave x) )
4927  real(RP), intent(in) :: dq_xave(KA,HYDRO_MAX)
4928  !--- terminal velocity of averaged mass( vt(ave x) )
4929  real(RP), intent(in) :: vt_xave(KA,HYDRO_MAX,2)
4930  ! [Add] 11/08/30 T.Mitsui, for autoconversion of ice
4931  ! real(RP), intent(in) :: rho(KA)
4932  !--- partial conversion
4933  real(RP), intent(inout):: PQ(KA,PQ_MAX)
4934  !
4935  real(RP), intent(out):: Pac(KA,Pac_MAX)
4936  !--- for lightning component
4937  logical, intent(in) :: flg_lt
4938  real(RP), intent(in) :: beta_crg(KA)
4939  real(RP), intent(in) :: dqcrg(KA)
4940  real(RP), intent(in) :: d0_crg, v0_crg
4941  real(RP), intent(in) :: rhoq_crg(KA,I_QC:I_QG)
4942  real(RP), intent(inout):: Pcrg1(KA,PQ_MAX)
4943  real(RP), intent(inout):: Pcrg2(KA,Pcrg_MAX)
4944 
4945  real(RP), parameter :: a_dec = 0.883_rp
4946  real(RP), parameter :: b_dec = 0.093_rp
4947  real(RP), parameter :: c_dec = 0.00348_rp
4948  real(RP), parameter :: d_dec = 4.5185e-5_rp
4949  !
4950  !!!!from default SN14
4951 
4952  real(RP), parameter :: E_C12(6)=(/&
4953  0.010_rp, 0.080_rp, 0.10_rp, 0.60_rp, 0.20_rp, 0.10_rp/)
4954 
4955  real(RP) :: tem(KA)
4956  !
4957  !--- collection efficency of each specie
4958  real(RP) :: E_c, E_r, E_i, E_s, E_g
4959 ! real(RP) :: E_ic, E_sc, E_gc
4960  !--- sticking efficiency
4961  real(RP):: E_stick(KA)
4962  ! [Add] 10/08/03 T.Mitsui
4963  real(RP) :: temc, temc2, temc3
4964  real(RP) :: E_dec
4965  real(RP) :: esi_rat(KA)
4966  real(RP) :: esi(KA)
4967  !
4968  real(RP) :: temc_p, temc_m ! celcius tem.
4969 ! real(RP) :: ci_aut(KA)
4970 ! real(RP) :: taui_aut(KA)
4971 ! real(RP) :: tau_sce(KA)
4972  !--- DSD averaged diameter for each species
4973  real(RP) :: ave_dc ! cloud
4974 ! real(RP) :: ave_dr ! rain
4975  real(RP) :: ave_di(KA) ! ice
4976  real(RP) :: ave_ds(KA) ! snow
4977  real(RP) :: ave_dg ! graupel
4978  !--- coefficient of collection equations(L:mass, N:number)
4979  real(RP) :: coef_acc_LCI, coef_acc_NCI ! cloud - cloud ice
4980  real(RP) :: coef_acc_LCS, coef_acc_NCS ! cloud - snow
4981  !
4982  real(RP) :: coef_acc_LCG, coef_acc_NCG ! cloud - graupel
4983  real(RP) :: coef_acc_LRI_I, coef_acc_NRI_I ! rain - cloud ice
4984  real(RP) :: coef_acc_LRI_R, coef_acc_NRI_R ! rain - cloud ice
4985  real(RP) :: coef_acc_LRS_S, coef_acc_NRS_S ! rain - snow
4986  real(RP) :: coef_acc_LRS_R, coef_acc_NRS_R ! rain - snow
4987  real(RP) :: coef_acc_LRG, coef_acc_NRG ! rain - graupel
4988  real(RP) :: coef_acc_LII, coef_acc_NII ! cloud ice - cloud ice
4989  real(RP) :: coef_acc_LIS, coef_acc_NIS ! cloud ice - snow
4990  real(RP) :: coef_acc_NSS ! snow - snow
4991  real(RP) :: coef_acc_NGG ! grauepl - graupel
4992  real(RP) :: coef_acc_LSG, coef_acc_NSG(KA) ! snow - graupel
4993  !--- (diameter) x (diameter)
4994  real(RP) :: dcdc(KA), dcdi, dcds, dcdg
4995  real(RP) :: drdr(KA), drdi(KA), drds(KA), drdg
4996  real(RP) :: didi(KA), dids, didg
4997  real(RP) :: dsds(KA), dsdg
4998  real(RP) :: dgdg(KA)
4999 !# !--- (terminal velocity) x (terminal velocity)
5000 !# real(RP) :: vcvc(KA), vcvi, vcvs, vcvg
5001 !# real(RP) :: vrvr(KA), vrvi(KA), vrvs(KA), vrvg
5002 !# real(RP) :: vivi(KA), vivs, vivg
5003 !# real(RP) :: vsvs(KA), vsvg
5004 !# real(RP) :: vgvg(KA)
5005  !
5006 ! real(RP) :: wx_cri, wx_crs
5007 ! real(RP) :: coef_emelt
5008 ! real(RP) :: w1
5009 
5010  real(RP) :: sw, sw1, sw2, tmp
5011  real(RP) :: alpha_lt
5012  !
5013  integer :: k, iqw
5014  !
5015 
5016  real(RP) :: tem_e(KA) ! [Add] 15/05/19 T.Seiki
5017 
5018 
5019  !
5020  ! work for binary collision
5021  !
5022  ! work for Gauss-Legendre quadrature
5023  integer, parameter :: ngmax=4
5024 
5025  real(RP) :: lambdac(KA), lambdar(KA), lambdai(KA), lambdas(KA), lambdag(KA)
5026  real(RP) :: A_dsdc(KA), A_dsdr(KA), A_dsdi(KA), A_dsds(KA), A_dsdg(KA)
5027  real(RP) :: dNdx
5028  real(RP) :: dxdd
5029  real(RP) :: dNdD
5030  real(RP) :: dNc_glx(KA,ngmax), dNr_glx(KA,ngmax), dNi_glx(KA,ngmax), dNs_glx(KA,ngmax), dNg_glx(KA,ngmax)
5031  real(RP) :: dNc_gly, dNr_gly(KA,ngmax), dNi_gly(KA,ngmax), dNs_gly(KA,ngmax), dNg_gly(KA,ngmax)
5032  !
5033  real(RP) :: dc_glx, dr_glx, di_glx, ds_glx, dg_glx
5034  real(RP) :: dc_gly, dr_gly, di_gly, ds_gly, dg_gly
5035  real(RP) :: xc_glx(KA,ngmax), xr_glx(KA,ngmax), xi_glx(KA,ngmax), xs_glx(KA,ngmax), xg_glx(KA,ngmax)
5036  real(RP) :: xc_gly, xr_gly(KA,ngmax), xi_gly, xs_gly, xg_gly
5037 
5038  real(RP) :: vtc_glx(KA,ngmax), vtr_glx(KA,ngmax), vti_glx(KA,ngmax), vts_glx(KA,ngmax), vtg_glx(KA,ngmax)
5039  real(RP) :: vtc_gly, vtr_gly(KA,ngmax), vti_gly(KA,ngmax), vts_gly(KA,ngmax), vtg_gly(KA,ngmax)
5040  real(RP) :: dac_glx(KA,ngmax), dar_glx(KA,ngmax), dai_glx(KA,ngmax), das_glx(KA,ngmax), dag_glx(KA,ngmax)
5041  real(RP) :: dac_gly, dar_gly(KA,ngmax), dai_gly(KA,ngmax), das_gly(KA,ngmax), dag_gly(KA,ngmax)
5042  !
5043  integer :: ngx, ngy
5044  !
5045  real(RP) :: E_ic(KA), E_sc(KA), E_gc(KA)
5046  !
5047  ! Parameters to calculate terminal velocity formulated by Mitchell (1996)
5048  !
5049  real(RP) :: acx, bcx, gcx, scx ! geometric parameters of hexagonal column ice defined by Mitchell (1996)
5050  real(RP) :: acy, bcy, gcy, scy ! geometric parameters of hexagonal column ice defined by Mitchell (1996)
5051  real(RP), parameter :: as = 0.59452551_rp
5052  real(RP), parameter :: bs = 2.4490_rp
5053  real(RP), parameter :: gs = 0.131488_rp
5054  real(RP), parameter :: ss = 1.880000_rp
5055  real(RP), parameter :: ag = 19.5072514_rp !0.049d0*1.d-3*(100.0d0**2.8d0)
5056  real(RP), parameter :: bg = 2.8_rp
5057  real(RP), parameter :: gg = 0.5_rp
5058  real(RP), parameter :: sg = 2.0_rp
5059  real(RP) :: num_Besti_glx, num_Bests_glx, num_Bestg_glx
5060  real(RP) :: num_Besti_gly, num_Bests_gly, num_Bestg_gly
5061  real(RP) :: num_Rei_glx, num_Res_glx, num_Reg_glx
5062  real(RP) :: num_Rei_gly, num_Res_gly, num_Reg_gly
5063  real(RP), parameter :: c0=0.6_rp ! Bohm (1989)
5064  real(RP), parameter :: d0=5.83_rp ! Bohm (1989)
5065  !
5066  real(RP) :: mua(KA), nua(KA)
5067  !--- Dynamic viscosity
5068  real(RP), parameter :: mua0 = 1.718e-5_rp
5069 
5070  real(RP), parameter :: dmua_dT = 5.28e-8_rp
5071 
5072  !====== mua = mua0 + temc*dmua_dT
5073  !
5074  ! collection Kernel
5075  !
5076  real(RP) :: kernel_cg, kernel_cs, kernel_ci
5077  real(RP) :: kernel_rg, kernel_rs, kernel_ri
5078  real(RP) :: kernel_ig, kernel_is, kernel_ii
5079  real(RP) :: kernel_sg, kernel_ss
5080  real(RP) :: kernel_gg
5081  real(RP) :: kernel_sg_reb
5082  !
5083  !--------------------------
5084  !
5085  ! accurate for PSDs with optimization
5086  !
5087  !-------------------------------
5088  ! cloud
5089  ! gauss_range = 2.0_RP
5090  ! ngmax = 4
5091  ! rain,
5092  ! gauss_range = xxx
5093  ! ngmax = 4
5094  ! ice, snow, graupel
5095  ! gauss_range = 5.0_RP
5096  ! ngmax = 4
5097  !
5098  real(RP), parameter :: gauss_rangec=2.0_rp
5099  real(RP), parameter :: wc_gl(ngmax)=(/&
5100  0.2411146051511425e+00_rp, &
5101  0.4520325754088027e+00_rp, &
5102  0.4520325754088027e+00_rp, &
5103  0.2411146051511425e+00_rp &
5104  /)
5105  real(RP), parameter :: coefc_d_gl(ngmax)=(/&
5106  0.5505187813766612e+00_rp, &
5107  0.7900516927471093e+00_rp, &
5108  0.1265739962562290e+01_rp, &
5109  0.1816468454535444e+01_rp &
5110  /)
5111  real(RP), parameter :: gauss_ranger=8.0_rp
5112  real(RP), parameter :: wr_gl(ngmax)=(/&
5113  0.723343815453428e+00_rp,&
5114  1.35609772622641e+00_rp, &
5115  1.35609772622641e+00_rp, &
5116  0.723343815453428e+00_rp &
5117  /)
5118  real(RP), parameter :: coefr_d_gl(ngmax)=(/&
5119  0.166846238310235e+00_rp, &
5120  0.493135790663523e+00_rp, &
5121  2.02783902311062e+00_rp, &
5122  5.99354237846583e+00_rp &
5123  /)
5124  real(RP), parameter :: gauss_range=5.0_rp
5125  real(RP), parameter :: w_gl(ngmax)=(/&
5126  0.559850775788111e+00_rp, &
5127  1.04958713664599e+00_rp, &
5128  1.04958713664599e+00_rp, &
5129  0.559850775788111e+00_rp &
5130  /)
5131  real(RP), parameter :: coef_d_gl(ngmax)=(/&
5132  0.2500872485877803e+00_rp, &
5133  0.5785800417604080e+00_rp, &
5134  0.1728369331505741e+01_rp, &
5135  0.3998604509613778e+01_rp &
5136  /)
5137  !
5138  real(RP) :: wx_cri, wx_crs
5139  real(RP) :: coef_emelt
5140  real(RP) :: w1
5141 ! integer :: ij, k
5142  integer :: ierr
5143 
5144  !---------------------------------------------------------------------------
5145  !
5146  !
5147 
5148  do k = ks, ke
5149  tem(k) = max( wtem(k), tem_min ) ! 11/08/30 T.Mitsui
5150  end do
5151 
5152  call moist_psat_ice( ka, ks, ke, &
5153  tem(:), esi(:) ) ! [IN], [OUT]
5154 
5155  if( opt_stick_ks96 )then
5156  do k = ks, ke
5157  ! Khain and Sednev (1996), eq.(3.15)
5158  temc = tem(k) - t00
5159  temc2 = temc*temc
5160  temc3 = temc2*temc
5161  e_dec = max(0.0_rp, a_dec + b_dec*temc + c_dec*temc2 + d_dec*temc3 )
5162  esi_rat(k) = rhoq(k,i_qv)*rvap*tem(k)/esi(k)
5163  e_stick(k) = min(1.0_rp, e_dec*esi_rat(k))
5164  end do
5165  else if( opt_stick_co86 )then
5166  do k = ks, ke
5167  ! [Add] 11/08/30 T.Mitsui, Cotton et al. (1986)
5168  temc = min(tem(k) - t00,0.0_rp)
5169  w1 = 0.035_rp*temc-0.7_rp
5170  e_stick(k) = 10._rp**w1
5171  end do
5172  else
5173  do k = ks, ke
5174  ! Lin et al. (1983)
5175  temc_m = min(tem(k) - t00,0.0_rp) ! T < 273.15
5176  e_stick(k) = exp(0.09_rp*temc_m)
5177  end do
5178  end if
5179 
5180  !------------------------------------------------------------------------
5181 
5182 
5183  pac(:,:) = 0.0_rp
5184 
5185  tem(:) = max(wtem(:), tem_min )
5186  tem_e(:) = max(wtem(:), tem_min_estick )
5187 
5188  call moist_psat_ice( ka, ks, ke, tem(:), esi(:) )
5189 
5190 
5191  if ( opt_stick_ks96 ) then
5192  do k=ks, ke
5193  ! Khain and Sednev (1996), eq.(3.15)
5194  temc = tem_e(k) - t00 ![Mod] 15/05/19 T.Seiki
5195  temc2 = temc*temc
5196  temc3 = temc2*temc
5197  e_dec = max(0.0_rp, a_dec + b_dec*temc + c_dec*temc2 + d_dec*temc3 )
5198  esi_rat(k) = rhoq(k,i_qv)*rvap*tem(k)/esi(k)
5199  e_stick(k) = min(1.0_rp, e_dec*esi_rat(k))
5200  enddo
5201  elseif( opt_stick_co86 ) then
5202  do k=ks, ke
5203  temc = min(tem_e(k) - t00,0.0_rp)
5204  w1 = 0.035_rp*temc-0.7_rp
5205  e_stick(k) = 10.0_rp**w1
5206  enddo
5207  elseif( opt_stick_c12 ) then
5208  do k=ks, ke
5209  if (tem_e(k)>273.15_rp) then
5210  e_stick(k)=1.0_rp
5211  elseif(tem_e(k)<243.15_rp) then !-30degC
5212  e_stick(k)=e_c12(1)
5213  elseif(tem_e(k)<248.15_rp) then !-25degC
5214  e_stick(k)=e_c12(1)+0.2_rp*(e_c12(2)-e_c12(1))*(tem_e(k)-243.15_rp)
5215  elseif(tem_e(k)<253.15_rp) then !-20degC
5216  e_stick(k)=e_c12(2)+0.2_rp*(e_c12(3)-e_c12(2))*(tem_e(k)-248.15_rp)
5217  elseif(tem_e(k)<258.15_rp) then !-15degC
5218  e_stick(k)=e_c12(3)+0.2_rp*(e_c12(4)-e_c12(3))*(tem_e(k)-253.15_rp)
5219  elseif(tem_e(k)<263.15_rp) then !-10degC
5220  e_stick(k)=e_c12(4)+0.2_rp*(e_c12(5)-e_c12(4))*(tem_e(k)-258.15_rp)
5221  elseif(tem_e(k)<268.15_rp) then !- 5degC
5222  e_stick(k)=e_c12(5)+0.2_rp*(e_c12(6)-e_c12(5))*(tem_e(k)-263.15_rp)
5223  else ! 0degC
5224  e_stick(k)=e_c12(6)
5225  endif
5226  enddo
5227  else
5228  if ( opt_stick_rhh57 ) then
5229  do k=ks, ke
5230  if ( tem_e(k) < 270.0_rp .AND. rhoq(k,i_qv)*rvap*tem(k) < esi(k) ) then
5231  esi_rat(k) = 0.0_rp
5232  else
5233  esi_rat(k) = 1.0_rp
5234  endif
5235  enddo
5236  elseif( opt_stick_rhks96 ) then
5237  do k=ks, ke
5238  esi_rat(k) = min( rhoq(k,i_qv)*rvap*tem(k)/esi(k),1.0_rp )
5239  enddo
5240  else
5241  esi_rat(:) = 1.0_rp
5242  endif
5243  !
5244  do k=ks, ke
5245  ! Lin et al. (1983)
5246  temc_m = min(tem_e(k) - t00,0.0_rp) ! T < 273.15
5247  e_stick(k) = exp(0.09_rp*temc_m)*esi_rat(k)
5248  enddo
5249  endif
5250 
5251  !
5252  ! Integration Start
5253  !
5254 
5255  do k = ks, ke
5256  mua(k) = mua0 + dmua_dt*(tem(k)-273.15_rp)
5257  nua(k) = mua(k)/rho(k) ! [m2/s]
5258  end do
5259  do k = ks, ke
5260  lambdac(k) = xq(k,i_mp_qc)**(-mu(i_mp_qc))*coef_lambda(i_mp_qc)
5261  a_dsdc(k) = rhoq(k,i_nc)*coef_a(i_mp_qc)*lambdac(k)**((nu(i_mp_qc)+1.0_rp)/mu(i_mp_qc))
5262  end do
5263  do k = ks, ke
5264  lambdar(k) = xq(k,i_mp_qr)**(-mu(i_mp_qr))*coef_lambda(i_mp_qr)
5265  a_dsdr(k) = rhoq(k,i_nr)*coef_a(i_mp_qr)*lambdar(k)**((nu(i_mp_qr)+1.0_rp)/mu(i_mp_qr))
5266  end do
5267  do k = ks, ke
5268  lambdai(k) = xq(k,i_mp_qi)**(-mu(i_mp_qi))*coef_lambda(i_mp_qi)
5269  a_dsdi(k) = rhoq(k,i_ni)*coef_a(i_mp_qi)*lambdai(k)**((nu(i_mp_qi)+1.0_rp)/mu(i_mp_qi))
5270  end do
5271  do k = ks, ke
5272  lambdas(k) = xq(k,i_mp_qs)**(-mu(i_mp_qs))*coef_lambda(i_mp_qs)
5273  a_dsds(k) = rhoq(k,i_ns)*coef_a(i_mp_qs)*lambdas(k)**((nu(i_mp_qs)+1.0_rp)/mu(i_mp_qs))
5274  end do
5275  do k = ks, ke
5276  lambdag(k) = xq(k,i_mp_qg)**(-mu(i_mp_qg))*coef_lambda(i_mp_qg)
5277  a_dsdg(k) = rhoq(k,i_ng)*coef_a(i_mp_qg)*lambdag(k)**((nu(i_mp_qg)+1.0_rp)/mu(i_mp_qg))
5278  end do
5279 
5280  !
5281  ! Particle X
5282  !
5283  do ngx=1, ngmax ! X < Y
5284 !OCL LOOP_FISSION_TARGET(LS)
5285  do k = ks, ke
5286  dc_glx = dq_xave(k,i_mp_qc)*coefc_d_gl(ngx)
5287  xc_glx(k,ngx) = ( (dc_glx/a_m(i_mp_qc)) )**(1.0_rp/b_m(i_mp_qc))
5288  dnc_glx(k,ngx) = a_dsdc(k)*(xc_glx(k,ngx)**nu(i_mp_qc)) * exp(-lambdac(k)*xc_glx(k,ngx)**mu(i_mp_qc))&
5289  *(xc_glx(k,ngx)/(b_m(i_mp_qc)*dc_glx))*dc_glx*wc_gl(ngx) ! dNdlogD*weight
5290  !
5291  dr_glx = dq_xave(k,i_mp_qr)*coefr_d_gl(ngx)
5292  xr_glx(k,ngx) = ( (dr_glx/a_m(i_mp_qr)) )**(1.0_rp/b_m(i_mp_qr))
5293  dnr_glx(k,ngx) = a_dsdr(k)*(xr_glx(k,ngx)**nu(i_mp_qr)) * exp(-lambdar(k)*xr_glx(k,ngx)**mu(i_mp_qr))&
5294  *(xr_glx(k,ngx)/(b_m(i_mp_qr)*dr_glx))*dr_glx*wr_gl(ngx) ! dNdlogD*weight
5295  !
5296  di_glx = dq_xave(k,i_mp_qi)*coef_d_gl(ngx)
5297  xi_glx(k,ngx) = ( (di_glx/a_m(i_mp_qi)) )**(1.0_rp/b_m(i_mp_qi))
5298  dni_glx(k,ngx) = a_dsdi(k)*(xi_glx(k,ngx)**nu(i_mp_qi)) * exp(-lambdai(k)*xi_glx(k,ngx)**mu(i_mp_qi))&
5299  *(xi_glx(k,ngx)/(b_m(i_mp_qi)*di_glx))*di_glx*w_gl(ngx) ! dNdlogD*weight
5300  !
5301  ds_glx = dq_xave(k,i_mp_qs)*coef_d_gl(ngx)
5302  xs_glx(k,ngx) = ( (ds_glx/a_m(i_mp_qs)) )**(1.0_rp/b_m(i_mp_qs))
5303  dns_glx(k,ngx) = a_dsds(k)*(xs_glx(k,ngx)**nu(i_mp_qs)) * exp(-lambdas(k)*xs_glx(k,ngx)**mu(i_mp_qs))&
5304  *(xs_glx(k,ngx)/(b_m(i_mp_qs)*ds_glx))*ds_glx*w_gl(ngx)! dNdlogD*weight
5305  !
5306  dg_glx = dq_xave(k,i_mp_qg)*coef_d_gl(ngx)
5307  xg_glx(k,ngx) = ( (dg_glx/a_m(i_mp_qg)) )**(1.0_rp/b_m(i_mp_qg))
5308  dng_glx(k,ngx) = a_dsdg(k)*(xg_glx(k,ngx)**nu(i_mp_qg)) * exp(-lambdag(k)*xg_glx(k,ngx)**mu(i_mp_qg))&
5309  *(xg_glx(k,ngx)/(b_m(i_mp_qg)*dg_glx))*dg_glx*w_gl(ngx)! dNdlogD*weight
5310  !
5311  ! Hexagonal Columns
5312 !!$ if( di_glx <= 100.e-6_RP )then
5313 !!$ acx = 0.1677_RP*1.e-3_RP*(100.0_RP**2.91_RP)
5314 !!$ bcx = 2.91_RP
5315 !!$ gcx = (0.684_RP*1.e-4_RP)*10.0_RP**(2.0_RP*2.0_RP)
5316 !!$ scx = 2.0_RP
5317 !!$ else
5318 !!$ acx = 0.00166_RP*1.e-3_RP*(100.0_RP**1.91_RP)
5319 !!$ bcx = 1.91_RP
5320 !!$ gcx = (0.0696_RP*1.e-4_RP)*10.0_RP**(2.0_RP*1.5_RP)
5321 !!$ scx = 1.5_RP
5322 !!$ end if
5323  sw = 0.5_rp + sign(0.5_rp, di_glx - 100.e-6_rp )
5324  acx = ( 0.1677_rp*(1.0_rp-sw) + 0.00166_rp*sw ) * 1.e-3_rp * 100.0_rp**( 2.91_rp*(1.0_rp-sw) + 1.91_rp*sw )
5325  bcx = 2.91_rp*(1.0_rp-sw) + 1.91_rp*sw
5326  gcx = (0.684_rp*(1.0_rp-sw) + 0.0696_rp*sw ) * 1.e-4_rp * 10.0_rp**( 4.0_rp*(1.0_rp-sw) + 3.0_rp*sw )
5327  scx = 2.0_rp*(1.0_rp-sw) + 1.5_rp*sw
5328  num_besti_glx = 2.0_rp*acx*grav*rho(k)*di_glx**(bcx+2.0_rp-scx)/(gcx*mua(k)**2)
5329  num_bests_glx = 2.0_rp*as *grav*rho(k)*ds_glx**(bs +2.0_rp-ss )/(gs *mua(k)**2)
5330  num_bestg_glx = 2.0_rp*ag *grav*rho(k)*dg_glx**(bg +2.0_rp-sg )/(gg *mua(k)**2)
5331  num_rei_glx = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_besti_glx)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5332  num_res_glx = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_bests_glx)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5333  num_reg_glx = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_bestg_glx)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5334  !
5335  vtc_glx(k,ngx) = coef_vtr_ar2*dc_glx*(1.0_rp-exp(-coef_vtr_br2*dc_glx))
5336  !
5337 !!$ if( dr_glx < d_vtr_branch )then
5338 !!$ vtr_glx = coef_vtr_ar2*dr_glx*(1.0_RP-exp(-coef_vtr_br2*dr_glx))
5339 !!$ else
5340 !!$ vtr_glx = coef_vtr_ar1-coef_vtr_br1*exp(-coef_vtr_cr1*dr_glx)
5341 !!$ end if
5342  sw = 0.5_rp + sign( 0.5_rp, dr_glx - d_vtr_branch )
5343  tmp = exp( - ( coef_vtr_br2*(1.0_rp-sw) + coef_vtr_cr1*sw ) * dr_glx )
5344  vtr_glx(k,ngx) = coef_vtr_ar2 * dr_glx * ( 1.0_rp - tmp ) * (1.0_rp-sw) &
5345  + ( coef_vtr_ar1 - coef_vtr_br1 * tmp ) * sw
5346  !
5347  vti_glx(k,ngx) = num_rei_glx*nua(k)/di_glx
5348  vts_glx(k,ngx) = num_res_glx*nua(k)/ds_glx
5349  vtg_glx(k,ngx) = num_reg_glx*nua(k)/dg_glx
5350  ! equivalent area diameter
5351  dac_glx(k,ngx) = dc_glx
5352  dar_glx(k,ngx) = dr_glx
5353  dai_glx(k,ngx) = 2.0_rp*sqrt( (gcx*di_glx**scx)/pi )
5354  das_glx(k,ngx) = 2.0_rp*sqrt( (gs *ds_glx**ss )/pi )
5355  dag_glx(k,ngx) = 2.0_rp*sqrt( (gg *dg_glx**sg )/pi )
5356  end do
5357  end do
5358 
5359  !
5360  ! Particle Y
5361  !
5362  do ngy=1, ngmax
5363 !OCL LOOP_FISSION_TARGET(LS)
5364  do k = ks, ke
5365  dr_gly = dq_xave(k,i_mp_qr)*coefr_d_gl(ngy)
5366  xr_gly(k,ngy) = ( (dr_gly/a_m(i_mp_qr)) )**(1.0_rp/b_m(i_mp_qr))
5367  dnr_gly(k,ngy) = a_dsdr(k)*(xr_gly(k,ngy)**nu(i_mp_qr)) * exp(-lambdar(k)*xr_gly(k,ngy)**mu(i_mp_qr))&
5368  *(xr_gly(k,ngy)/(b_m(i_mp_qr)*dr_gly))*dr_gly*wr_gl(ngy) ! dNdlogD*weight
5369  !
5370  di_gly = dq_xave(k,i_mp_qi)*coef_d_gl(ngy)
5371  xi_gly = ( (di_gly/a_m(i_mp_qi)) )**(1.0_rp/b_m(i_mp_qi))
5372  dni_gly(k,ngy) = a_dsdi(k)*(xi_gly**nu(i_mp_qi)) * exp(-lambdai(k)*xi_gly**mu(i_mp_qi))&
5373  *(xi_gly/(b_m(i_mp_qi)*di_gly))*di_gly*w_gl(ngy) ! dNdlogD*weight
5374  !
5375  ds_gly = dq_xave(k,i_mp_qs)*coef_d_gl(ngy)
5376  xs_gly = ( (ds_gly/a_m(i_mp_qs)) )**(1.0_rp/b_m(i_mp_qs))
5377  dns_gly(k,ngy) = a_dsds(k)*(xs_gly**nu(i_mp_qs)) * exp(-lambdas(k)*xs_gly**mu(i_mp_qs))&
5378  *(xs_gly/(b_m(i_mp_qs)*ds_gly))*ds_gly*w_gl(ngy)! dNdlogD*weight
5379  !
5380  dg_gly = dq_xave(k,i_mp_qg)*coef_d_gl(ngy)
5381  xg_gly = ( (dg_gly/a_m(i_mp_qg)) )**(1.0_rp/b_m(i_mp_qg))
5382  dng_gly(k,ngy) = a_dsdg(k)*(xg_gly**nu(i_mp_qg)) * exp(-lambdag(k)*xg_gly**mu(i_mp_qg))&
5383  *(xg_gly/(b_m(i_mp_qg)*dg_gly))*dg_gly*w_gl(ngy)! dNdlogD*weight
5384  !
5385  ! Hexagonal Columns
5386 !!$ if( di_gly <= 100.e-6_RP )then
5387 !!$ acy = 0.1677_RP*1.d-3*(100.0_RP**2.91_RP)
5388 !!$ bcy = 2.91_RP
5389 !!$ gcy = (0.684_RP*1.e-4_RP)*10.0_RP**(2.0_RP*2.0_RP)
5390 !!$ scy = 2.0_RP
5391 !!$ else
5392 !!$ acy = 0.00166_RP*1.e-3_RP*(100.0_RP**1.91_RP)
5393 !!$ bcy = 1.91_RP
5394 !!$ gcy = (0.0696_RP*1.e-4_RP)*10.0_RP**(2.0_RP*1.5_RP)
5395 !!$ scy = 1.5_RP
5396 !!$ end if
5397  sw = 0.5_rp + sign( 0.5_rp, di_gly - 100.e-6_rp )
5398  acy = ( 0.1677_rp*(1.0_rp-sw) + 0.00166_rp*sw ) * 1.e-3_rp * 100.0_rp**( 2.91_rp*(1.0_rp-sw) + 1.91_rp*sw )
5399  bcy = 2.91_rp*(1.0_rp-sw) + 1.91_rp*sw
5400  gcy = ( 0.684_rp*(1.0_rp-sw) + 0.0696_rp*sw ) * 1.e-4_rp * 10.0_rp**( 4.0_rp*(1.0_rp-sw) + 3.0_rp*sw )
5401  scy = 2.0_rp*(1.0_rp-sw) + 1.5_rp*sw
5402  num_besti_gly = 2.0_rp*acy*grav*rho(k)*di_gly**(bcy+2.0_rp-scy)/(gcy*mua(k)**2)
5403  num_bests_gly = 2.0_rp*as *grav*rho(k)*ds_gly**(bs +2.0_rp-ss )/(gs *mua(k)**2)
5404  num_bestg_gly = 2.0_rp*ag *grav*rho(k)*dg_gly**(bg +2.0_rp-sg )/(gg *mua(k)**2)
5405  num_rei_gly = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_besti_gly)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5406  num_res_gly = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_bests_gly)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5407  num_reg_gly = 0.25_rp*d0*d0*( sqrt(1.0_rp+4.0_rp*sqrt(num_bestg_gly)/(d0*d0*sqrt(c0)))-1.0_rp )**2
5408  !
5409 !!$ if( dr_gly < d_vtr_branch )then
5410 !!$ vtr_gly(k,ngy) = coef_vtr_ar2*dr_gly*(1.0_RP-exp(-coef_vtr_br2*dr_gly))
5411 !!$ else
5412 !!$ vtr_gly(k,ngy) = coef_vtr_ar1-coef_vtr_br1*exp(-coef_vtr_cr1*dr_gly)
5413 !!$ end if
5414  sw = 0.5_rp + sign( 0.5_rp, dr_gly - d_vtr_branch )
5415  tmp = exp( - ( coef_vtr_br2*(1.0_rp-sw) + coef_vtr_cr1*sw ) * dr_gly )
5416  vtr_gly(k,ngy) = coef_vtr_ar2 * dr_gly * ( 1.0_rp - tmp ) * (1.0_rp-sw) &
5417  + ( coef_vtr_ar1 - coef_vtr_br1 * tmp ) * sw
5418  !
5419  vti_gly(k,ngy) = num_rei_gly*nua(k)/di_gly
5420  vts_gly(k,ngy) = num_res_gly*nua(k)/ds_gly
5421  vtg_gly(k,ngy) = num_reg_gly*nua(k)/dg_gly
5422  ! equivalent area diameter
5423  dar_gly(k,ngy) = dr_gly
5424  dai_gly(k,ngy) = 2.0_rp*sqrt( (gcy*di_gly**scy)/pi )
5425  das_gly(k,ngy) = 2.0_rp*sqrt( (gs *ds_gly**ss )/pi )
5426  dag_gly(k,ngy) = 2.0_rp*sqrt( (gg *dg_gly**sg )/pi )
5427  end do
5428  end do
5429 
5430  !
5431  ! BULK collection efficiency are given as follows
5432  !
5433  do k = ks, ke
5434  e_c = max(0.0_rp, min(1.0_rp, (dq_xave(k,i_mp_qc)-dc0)/(dc1-dc0) ))
5435  !
5436 !!$ if (dq_xave(k,I_mp_QI)>di0) then
5437 !!$ E_i = E_im
5438 !!$ else
5439 !!$ E_i = 0.0_RP
5440 !!$ endif
5441  sw = 0.5_rp + sign( 0.5_rp, dq_xave(k,i_mp_qi)-di0 )
5442  e_i = e_im * sw
5443 !!$ if (dq_xave(k,I_mp_QS)>ds0) then
5444 !!$ E_s = E_sm
5445 !!$ else
5446 !!$ E_s = 0.0_RP
5447 !!$ endif
5448  sw = 0.5_rp + sign( 0.5_rp, dq_xave(k,i_mp_qs)-ds0 )
5449  e_s = e_sm * sw
5450 !!$ if (dq_xave(k,I_mp_QG)>dg0) then
5451 !!$ E_g = E_gm
5452 !!$ else
5453 !!$ E_g = 0.0_RP
5454 !!$ endif
5455  sw = 0.5_rp + sign( 0.5_rp, dq_xave(k,i_mp_qg)-dg0 )
5456  e_g = e_gm * sw
5457 
5458  e_ic(k) = e_i*e_c
5459  e_sc(k) = e_s*e_c
5460  e_gc(k) = e_g*e_c
5461  end do
5462 
5463 
5464  !=========================================================================================
5465  ! collection equation
5466  !=========================================================================================
5467  do ngx=1, ngmax ! X < Y
5468  do ngy=1, ngmax
5469 
5470  do k = ks, ke
5471  !
5472  ! 1.c-g (X=Cloud, Y=Graupel)
5473  !
5474 ! kernel_cg = 0.25_RP*pi*(dag_gly(k,ngy)+dac_glx(k,ngx))*(dag_gly(k,ngy)+dac_glx(k,ngx))*sqrt((vtg_gly(k,ngy)-vtc_glx(k,ngx))*(vtg_gly(k,ngy)-vtc_glx(k,ngx))) * E_gc(k)
5475  kernel_cg = 0.25_rp * pi * (dag_gly(k,ngy)+dac_glx(k,ngx))**2 * abs(vtg_gly(k,ngy)-vtc_glx(k,ngx)) * e_gc(k)
5476  pac(k,i_ngacnc2ng) = pac(k,i_ngacnc2ng) - kernel_cg *dnc_glx(k,ngx)*dng_gly(k,ngy)
5477  pac(k,i_lgaclc2lg) = pac(k,i_lgaclc2lg) - kernel_cg*xc_glx(k,ngx)*dnc_glx(k,ngx)*dng_gly(k,ngy)
5478  end do
5479  do k = ks, ke
5480  !
5481  ! 2.c-s (X=Cloud, Y=Snow)
5482  !
5483 ! kernel_cs = 0.25_RP*pi*(das_gly(k,ngy)+dac_glx(k,ngx))*(das_gly(k,ngy)+dac_glx(k,ngx))*sqrt((vts_gly(k,ngy)-vtc_glx(k,ngx))*(vts_gly(k,ngy)-vtc_glx(k,ngx))) * E_sc(k)
5484  kernel_cs = 0.25_rp * pi * (das_gly(k,ngy)+dac_glx(k,ngx))**2 * abs(vts_gly(k,ngy)-vtc_glx(k,ngx)) * e_sc(k)
5485  pac(k,i_nsacnc2ns) = pac(k,i_nsacnc2ns) - kernel_cs *dnc_glx(k,ngx)*dns_gly(k,ngy)
5486  pac(k,i_lsaclc2ls) = pac(k,i_lsaclc2ls) - kernel_cs*xc_glx(k,ngx)*dnc_glx(k,ngx)*dns_gly(k,ngy)
5487  end do
5488  do k = ks, ke
5489  !
5490  ! 3.c-i (X=Cloud, Y=Cloud Ice)
5491  !
5492 ! kernel_ci = 0.25_RP*pi*(dai_gly(k,ngy)+dac_glx(k,ngx))*(dai_gly(k,ngy)+dac_glx(k,ngx))*sqrt((vti_gly(k,ngy)-vtc_glx(k,ngx))*(vti_gly(k,ngy)-vtc_glx(k,ngx))) * E_ic(k)
5493  kernel_ci = 0.25_rp * pi * (dai_gly(k,ngy)+dac_glx(k,ngx))**2 * abs(vti_gly(k,ngy)-vtc_glx(k,ngx)) * e_ic(k)
5494  pac(k,i_niacnc2ni) = pac(k,i_niacnc2ni) - kernel_ci *dnc_glx(k,ngx)*dni_gly(k,ngy)
5495  pac(k,i_liaclc2li) = pac(k,i_liaclc2li) - kernel_ci*xc_glx(k,ngx)*dnc_glx(k,ngx)*dni_gly(k,ngy)
5496  end do
5497  do k = ks, ke
5498  !
5499  ! 4.r-g
5500  !
5501 ! kernel_rg = 0.25_RP*pi*(dag_gly(k,ngy)+dar_glx(k,ngx))*(dag_gly(k,ngy)+dar_glx(k,ngx))*sqrt((vtg_gly(k,ngy)-vtr_glx(k,ngx))*(vtg_gly(k,ngy)-vtr_glx(k,ngx))) * E_gr
5502  kernel_rg = 0.25_rp * pi * (dag_gly(k,ngy)+dar_glx(k,ngx))**2 * abs(vtg_gly(k,ngy)-vtr_glx(k,ngx)) * e_gr
5503  ! T < 273K (X=Rain , Y=Graupel)
5504  pac(k,i_nracng2ng) = pac(k,i_nracng2ng) - kernel_rg *dnr_glx(k,ngx)*dng_gly(k,ngy)
5505  pac(k,i_lraclg2lg) = pac(k,i_lraclg2lg) - kernel_rg*xr_glx(k,ngx)*dnr_glx(k,ngx)*dng_gly(k,ngy)
5506  ! T > 273K (X=Graupel, Y=Rain )
5507  pac(k,i_nracng2nr) = pac(k,i_nracng2nr) - kernel_rg *dng_glx(k,ngx)*dnr_gly(k,ngy)
5508  pac(k,i_lraclg2lr) = pac(k,i_lraclg2lr) - kernel_rg*xg_glx(k,ngx)*dng_glx(k,ngx)*dnr_gly(k,ngy)
5509  end do
5510  do k = ks, ke
5511  !
5512  ! 5.r-s
5513  !
5514 ! kernel_rs = 0.25_RP*pi*(das_glx(k,ngx)+dar_gly(k,ngy))*(das_glx(k,ngx)+dar_gly(k,ngy))*sqrt((vts_glx(k,ngx)-vtr_gly(k,ngy))*(vts_glx(k,ngx)-vtr_gly(k,ngy))) * E_sr
5515  kernel_rs = 0.25_rp * pi * (das_glx(k,ngx)+dar_gly(k,ngy))**2 * abs(vts_glx(k,ngx)-vtr_gly(k,ngy)) * e_sr
5516  ! (X=Snow, Y=Rain)
5517  pac(k,i_nracns2ng_r) = pac(k,i_nracns2ng_r) - kernel_rs *dns_glx(k,ngx)*dnr_gly(k,ngy)
5518  pac(k,i_lracls2lg_r) = pac(k,i_lracls2lg_r) - kernel_rs*xr_gly(k,ngy)*dns_glx(k,ngx)*dnr_gly(k,ngy)
5519  !
5520  pac(k,i_nracns2ng_s) = pac(k,i_nracns2ng_s) - kernel_rs *dns_glx(k,ngx)*dnr_gly(k,ngy)
5521  pac(k,i_lracls2lg_s) = pac(k,i_lracls2lg_s) - kernel_rs*xs_glx(k,ngx)*dns_glx(k,ngx)*dnr_gly(k,ngy)
5522  end do
5523  do k = ks, ke
5524  !
5525  ! 6.r-i
5526  !
5527 ! kernel_ri = 0.25_RP*pi*(dai_glx(k,ngx)+dar_gly(k,ngy))*(dai_glx(k,ngx)+dar_gly(k,ngy))*sqrt((vti_glx(k,ngx)-vtr_gly(k,ngy))*(vti_glx(k,ngx)-vtr_gly(k,ngy))) * E_ir
5528  kernel_ri = 0.25_rp * pi * (dai_glx(k,ngx)+dar_gly(k,ngy))**2 * abs(vti_glx(k,ngx)-vtr_gly(k,ngy)) * e_ir
5529  ! (X=Cloud Ice, Y=Rain)
5530  pac(k,i_nracni2ng_r) = pac(k,i_nracni2ng_r) - kernel_ri *dni_glx(k,ngx)*dnr_gly(k,ngy)
5531  pac(k,i_lracli2lg_r) = pac(k,i_lracli2lg_r) - kernel_ri*xr_gly(k,ngy)*dni_glx(k,ngx)*dnr_gly(k,ngy)
5532  !
5533  pac(k,i_nracni2ng_i) = pac(k,i_nracni2ng_i) - kernel_ri *dni_glx(k,ngx)*dnr_gly(k,ngy)
5534  pac(k,i_lracli2lg_i) = pac(k,i_lracli2lg_i) - kernel_ri*xi_glx(k,ngx)*dni_glx(k,ngx)*dnr_gly(k,ngy)
5535  end do
5536  do k = ks, ke
5537  !
5538  ! 7.i-g
5539  !
5540 ! kernel_ig = 0.25_RP*pi*(dai_glx(k,ngx)+dag_gly(k,ngy))*(dai_glx(k,ngx)+dag_gly(k,ngy))*sqrt((vti_glx(k,ngx)-vtg_gly(k,ngy))*(vti_glx(k,ngx)-vtg_gly(k,ngy))) * E_stick(k) * E_gi
5541  kernel_ig = 0.25_rp * pi * (dai_glx(k,ngx)+dag_gly(k,ngy))**2 * abs(vti_glx(k,ngx)-vtg_gly(k,ngy)) * e_stick(k) * e_gi
5542  pac(k,i_niacng2ng) = pac(k,i_niacng2ng) - kernel_ig *dni_glx(k,ngx)*dng_gly(k,ngy)
5543  pac(k,i_liaclg2lg) = pac(k,i_liaclg2lg) - kernel_ig*xi_glx(k,ngx)*dni_glx(k,ngx)*dng_gly(k,ngy)
5544  end do
5545  do k = ks, ke
5546  !
5547  ! 8.i-s
5548  !
5549 ! kernel_is = 0.25_RP*pi*(dai_glx(k,ngx)+das_gly(k,ngy))*(dai_glx(k,ngx)+das_gly(k,ngy))*sqrt((vti_glx(k,ngx)-vts_gly(k,ngy))*(vti_glx(k,ngx)-vts_gly(k,ngy))) * E_stick(k) * E_si
5550  kernel_is = 0.25_rp * pi * (dai_glx(k,ngx)+das_gly(k,ngy))**2 * abs(vti_glx(k,ngx)-vts_gly(k,ngy)) * e_stick(k) * e_si
5551  pac(k,i_niacns2ns) = pac(k,i_niacns2ns) - kernel_is *dni_glx(k,ngx)*dns_gly(k,ngy)
5552  pac(k,i_liacls2ls) = pac(k,i_liacls2ls) - kernel_is*xi_glx(k,ngx)*dni_glx(k,ngx)*dns_gly(k,ngy)
5553  end do
5554  do k = ks, ke
5555  !
5556  ! 9.i-i
5557  !
5558 ! kernel_ii = 0.25_RP*pi*(dai_glx(k,ngx)+dai_gly(k,ngy))*(dai_glx(k,ngx)+dai_gly(k,ngy))*sqrt((vti_glx(k,ngx)-vti_gly(k,ngy))*(vti_glx(k,ngx)-vti_gly(k,ngy))) * E_stick(k) * E_ii
5559  kernel_ii = 0.25_rp * pi * (dai_glx(k,ngx)+dai_gly(k,ngy))**2 * abs(vti_glx(k,ngx)-vti_gly(k,ngy)) * e_stick(k) * e_ii
5560  pac(k,i_niacni2ns) = pac(k,i_niacni2ns) - kernel_ii *dni_glx(k,ngx)*dni_gly(k,ngy)
5561  pac(k,i_liacli2ls) = pac(k,i_liacli2ls) - kernel_ii*xi_glx(k,ngx)*dni_glx(k,ngx)*dni_gly(k,ngy)
5562  end do
5563  do k = ks, ke
5564  !
5565  ! 10.s-g
5566  !
5567 ! kernel_sg = 0.25_RP*pi*(das_glx(k,ngx)+dag_gly(k,ngy))*(das_glx(k,ngx)+dag_gly(k,ngy))*sqrt((vts_glx(k,ngx)-vtg_gly(k,ngy))*(vts_glx(k,ngx)-vtg_gly(k,ngy))) * E_stick(k) * E_gs
5568  kernel_sg = 0.25_rp * pi * (das_glx(k,ngx)+dag_gly(k,ngy))**2 * abs(vts_glx(k,ngx)-vtg_gly(k,ngy)) * e_stick(k) * e_gs
5569  pac(k,i_ngacns2ng) = pac(k,i_ngacns2ng) - kernel_sg *dns_glx(k,ngx)*dng_gly(k,ngy)
5570  pac(k,i_lgacls2lg) = pac(k,i_lgacls2lg) - kernel_sg*xs_glx(k,ngx)*dns_glx(k,ngx)*dng_gly(k,ngy)
5571  end do
5572  do k = ks, ke
5573  !
5574  ! 11.s-s
5575  !
5576 ! kernel_ss = 0.125_RP*pi*(das_glx(k,ngx)+das_gly(k,ngy))*(das_glx(k,ngx)+das_gly(k,ngy))*sqrt((vts_glx(k,ngx)-vts_gly(k,ngy))*(vts_glx(k,ngx)-vts_gly(k,ngy))) * E_stick(k) * E_ss
5577  kernel_ss = 0.125_rp * pi * (das_glx(k,ngx)+das_gly(k,ngy))**2 * abs(vts_glx(k,ngx)-vts_gly(k,ngy)) * e_stick(k) * e_ss
5578  pac(k,i_nsacns2ns) = pac(k,i_nsacns2ns) - kernel_ss*dns_glx(k,ngx)*dns_gly(k,ngy)
5579  end do
5580  do k = ks, ke
5581  !
5582  ! 12.g-g
5583  !
5584 ! kernel_gg = 0.125_RP*pi*(dag_glx(k,ngx)+dag_gly(k,ngy))*(dag_glx(k,ngx)+dag_gly(k,ngy))*sqrt((vtg_glx(k,ngx)-vtg_gly(k,ngy))*(vtg_glx(k,ngx)-vtg_gly(k,ngy))) * E_stick(k) * E_gg
5585  kernel_gg = 0.125_rp * pi * (dag_glx(k,ngx)+dag_gly(k,ngy))**2 * abs(vtg_glx(k,ngx)-vtg_gly(k,ngy)) * e_stick(k) * e_gg
5586  pac(k,i_ngacng2ng) = pac(k,i_ngacng2ng) - kernel_gg*dng_glx(k,ngx)*dng_gly(k,ngy)
5587 
5588  end do
5589  end do
5590  end do
5591 
5592  !--- Charge separation by Snow-Graupel rebound--------------------------------
5593  if ( flg_lt ) then
5594  do k = ks, ke
5595 !OCL UNROLL('full')
5596  do ngy = 1, ngmax
5597 !OCL UNROLL('full')
5598  do ngx = 1, ngmax
5599  alpha_lt = 5.0_rp * ( das_glx(k,ngx) / d0_crg )**2*vtg_gly(k,ngy)/v0_crg
5600  alpha_lt = min( alpha_lt, 10.0_rp )
5601 ! kernel_sg_reb = 0.25_RP*pi*(das_glx(k,ngx)+dag_gly(k,ngy))*(das_glx(k,ngx)+dag_gly(k,ngy))*sqrt((vts_glx(k,ngx)-vtg_gly(k,ngy))*(vts_glx(k,ngx)-vtg_gly(k,ngy))) &
5602  kernel_sg_reb = 0.25_rp * pi * (das_glx(k,ngx)+dag_gly(k,ngy))**2 * abs(vts_glx(k,ngx)-vtg_gly(k,ngy)) &
5603  * ( 1.0_rp - e_stick(k) ) * e_gs
5604  pcrg2(k,i_cgngacns2ng) = pcrg2(k,i_cgngacns2ng) + kernel_sg_reb*dns_glx(k,ngx)*dng_gly(k,ngy)*dqcrg(k)*alpha_lt*beta_crg(k)
5605  end do
5606  end do
5607  end do
5608  end if
5609 
5610  !
5611  !
5612  do k=ks, ke
5613  temc_p = max(tem(k) - t00,0.0_rp) ! T > 273.15
5614  !------------------------------------------------------------------------
5615  !--- Partial conversion
5616  ! SB06(70),(71)
5617  ! i_iconv2g: option whether partial conversions work or not
5618  ! ice-cloud => graupel
5619  if ( dq_xave(k,i_mp_qi) > di_cri ) then
5620  wx_cri = cfill_i*rhow/rho_g*( pi/6.0_rp*rho_g*dq_xave(k,i_mp_qi)*dq_xave(k,i_mp_qi)*dq_xave(k,i_mp_qi)/xq(k,i_mp_qi) - 1.0_rp )
5621  pq(k,i_licon) = i_iconv2g* pac(k,i_liaclc2li)/max(1.0_rp, wx_cri)
5622  pq(k,i_nicon) = i_iconv2g* pq(k,i_licon)/xq(k,i_mp_qi)
5623  else
5624  wx_cri = 0.0_rp
5625  pq(k,i_licon) = 0.0_rp
5626  pq(k,i_nicon) = 0.0_rp
5627  endif
5628  ! snow-cloud => graupel
5629  wx_crs = cfill_s*rhow/rho_g*( pi/6.0_rp*rho_g*dq_xave(k,i_mp_qs)*dq_xave(k,i_mp_qs)*dq_xave(k,i_mp_qs)/xq(k,i_mp_qs) - 1.0_rp )
5630  pq(k,i_lscon) = i_sconv2g* (pac(k,i_lsaclc2ls))/max(1.0_rp, wx_crs)
5631  pq(k,i_nscon) = i_sconv2g* pq(k,i_lscon)/xq(k,i_mp_qs)
5632  !------------------------------------------------------------------------
5633  !--- enhanced melting( due to collection-freezing of water droplets )
5634  ! originally from Rutledge and Hobbs(1984). eq.(A.21)
5635  ! if T > 273.15 then temc_p=T-273.15, else temc_p=0
5636  ! 08/05/08 [fix] T.Mitsui LHF00 => LHF0
5637  ! melting occurs around T=273K, so LHF0 is suitable both SIMPLE and EXACT,
5638  ! otherwise LHF can have sign both negative(EXACT) and positive(SIMPLE).
5639  coef_emelt = cl/lhf0*temc_p
5640  ! cloud-graupel
5641  pq(k,i_lgacm) = coef_emelt*pac(k,i_lgaclc2lg)
5642  pq(k,i_ngacm) = pq(k,i_lgacm)/xq(k,i_mp_qg)
5643  ! rain-graupel
5644  pq(k,i_lgarm) = coef_emelt*pac(k,i_lraclg2lg)
5645  pq(k,i_ngarm) = pq(k,i_lgarm)/xq(k,i_mp_qg)
5646  ! cloud-snow
5647  pq(k,i_lsacm) = coef_emelt*(pac(k,i_lsaclc2ls))
5648  pq(k,i_nsacm) = pq(k,i_lsacm)/xq(k,i_mp_qs)
5649  ! rain-snow
5650  pq(k,i_lsarm) = coef_emelt*(pac(k,i_lracls2lg_r)+pac(k,i_lracls2lg_s))
5651  pq(k,i_nsarm) = pq(k,i_lsarm)/xq(k,i_mp_qg)
5652  ! cloud-ice
5653  pq(k,i_liacm) = coef_emelt*pac(k,i_liaclc2li)
5654  pq(k,i_niacm) = pq(k,i_liacm)/xq(k,i_mp_qi)
5655  ! rain-ice
5656  pq(k,i_liarm) = coef_emelt*(pac(k,i_lracli2lg_r)+pac(k,i_lracli2lg_i))
5657  pq(k,i_niarm) = pq(k,i_liarm)/xq(k,i_mp_qg)
5658  enddo
5659 
5660  !---- for charge density
5661  if ( flg_lt ) then
5662 
5663  ! 1.c-g (X=Cloud, Y=Graupel)
5664  do k = ks, ke
5665  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small )
5666  pcrg2(k,i_ngacnc2ng) = pac(k,i_ngacnc2ng)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
5667  end do
5668 
5669  ! 2.c-s (X=Cloud, Y=Snow)
5670  do k = ks, ke
5671  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small )
5672  pcrg2(k,i_nsacnc2ns) = pac(k,i_nsacnc2ns)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
5673  end do
5674 
5675  ! 3.c-i (X=Cloud, Y=Cloud Ice)
5676  do k = ks, ke
5677  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small )
5678  pcrg2(k,i_niacnc2ni) = pac(k,i_niacnc2ni)*(1.0_rp-sw1) / (rhoq(k,i_nc)+sw1) * rhoq_crg(k,i_qc)
5679  end do
5680 
5681  ! 4.r-g
5682  do k = ks, ke
5683  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small )
5684  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small )
5685  pcrg2(k,i_nracng2ng) = pac(k,i_nracng2ng)*(1.0_rp-sw1) / (rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr)
5686  pcrg2(k,i_nracng2nr) = pac(k,i_nracng2nr)*(1.0_rp-sw2) / (rhoq(k,i_ng)+sw2) * rhoq_crg(k,i_qg)
5687  end do
5688 
5689  ! 5.r-s
5690  do k = ks, ke
5691  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small )
5692  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small )
5693  pcrg2(k,i_nracns2ng_r) = pac(k,i_nracns2ng_r)*(1.0_rp-sw1) / (rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr)
5694  pcrg2(k,i_nracns2ng_s) = pac(k,i_nracns2ng_s)*(1.0_rp-sw2) / (rhoq(k,i_ns)+sw2) * rhoq_crg(k,i_qs)
5695  end do
5696 
5697 
5698  ! 6.r-i
5699  do k = ks, ke
5700  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small )
5701  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5702  pcrg2(k,i_nracni2ng_r) = pac(k,i_nracni2ng_r)*(1.0_rp-sw1) / (rhoq(k,i_nr)+sw1) * rhoq_crg(k,i_qr)
5703  pcrg2(k,i_nracni2ng_i) = pac(k,i_nracni2ng_i)*(1.0_rp-sw2) / (rhoq(k,i_ni)+sw2) * rhoq_crg(k,i_qi)
5704  end do
5705 
5706  ! 7.i-g
5707  do k = ks, ke
5708  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5709  pcrg2(k,i_niacng2ng) = pac(k,i_niacng2ng)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5710  end do
5711 
5712  ! 8.i-s
5713  do k = ks, ke
5714  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5715  pcrg2(k,i_niacns2ns) = pac(k,i_niacns2ns)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5716  end do
5717 
5718  ! 9.i-i
5719  do k = ks, ke
5720  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5721  pcrg2(k,i_niacni2ns) = pac(k,i_niacni2ns)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5722  end do
5723 
5724  ! 10.s-g
5725  do k = ks, ke
5726  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small )
5727  pcrg2(k,i_ngacns2ng) = pac(k,i_ngacns2ng)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
5728  end do
5729 
5730  ! 11.s-s
5731  do k = ks, ke
5732  pcrg2(k,i_nsacns2ns) = 0.0_rp ! no charge transfer between category due to the collection of the same category (snow-snow)
5733  end do
5734 
5735  ! 12.g-g
5736  do k = ks, ke
5737  pcrg2(k,i_ngacng2ng) = 0.0_rp ! no charge transfer between category due to the collection of the same category (graupel-graupel)
5738  end do
5739 
5740  !--- Partial conversion
5741  ! ice-cloud => graupel
5742  do k = ks, ke
5743  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5744  pcrg1(k,i_nicon) = pq(k,i_nicon)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5745  end do
5746 
5747  ! snow-cloud => graupel
5748  do k = ks, ke
5749  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small )
5750  pcrg1(k,i_nscon) = pq(k,i_nscon)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
5751  end do
5752 
5753  !--- enhanced melting( due to collection-freezing of water droplets )
5754  ! cloud-graupel
5755  do k = ks, ke
5756  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small )
5757  pcrg1(k,i_ngacm) = pq(k,i_ngacm)*(1.0_rp-sw1) / (rhoq(k,i_ng)+sw1) * rhoq_crg(k,i_qg)
5758  end do
5759 
5760  ! rain-graupel
5761  do k = ks, ke
5762  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small )
5763  pcrg1(k,i_ngarm) = pq(k,i_ngarm)*(1.0_rp-sw1) / (rhoq(k,i_ng)+sw1) * rhoq_crg(k,i_qg)
5764  end do
5765 
5766  ! cloud-snow
5767  do k = ks, ke
5768  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small )
5769  pcrg1(k,i_nsacm) = pq(k,i_nsacm)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
5770  end do
5771 
5772  ! rain-snow
5773  do k = ks, ke
5774  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small )
5775  pcrg1(k,i_nsarm) = pq(k,i_nsarm)*(1.0_rp-sw1) / (rhoq(k,i_ns)+sw1) * rhoq_crg(k,i_qs)
5776  end do
5777 
5778  ! cloud-ice
5779  do k = ks, ke
5780  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5781  pcrg1(k,i_niacm) = pq(k,i_niacm)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5782  end do
5783 
5784  ! rain-ice
5785  do k = ks, ke
5786  sw1 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small )
5787  pcrg1(k,i_niarm) = pq(k,i_niarm)*(1.0_rp-sw1) / (rhoq(k,i_ni)+sw1) * rhoq_crg(k,i_qi)
5788  end do
5789 
5790  endif
5791 
5792  return
5793  end subroutine mixed_phase_collection_bin
5794 
5795  !----------------------------
5796  ! Auto-conversion, Accretion, Self-collection, Break-up
5797 !OCL SERIAL
5798  subroutine aut_acc_slc_brk( &
5799  KA, KS, KE, &
5800  flg_lt, &
5801  rhoq, rhoq_crg, &
5802  xq, dq_xave, &
5803  rho, &
5804  PQ, Pcrg )
5805  implicit none
5806 
5807  integer, intent(in) :: KA, KS, KE
5808  !
5809  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
5810  real(RP), intent(in) :: rhoq_crg(KA,I_QC:I_QG)
5811  logical, intent(in) :: flg_lt
5812  real(RP), intent(in) :: xq(KA,HYDRO_MAX)
5813  real(RP), intent(in) :: dq_xave(KA,HYDRO_MAX)
5814  real(RP), intent(in) :: rho(KA)
5815  !
5816  real(RP), intent(inout) :: PQ(KA,PQ_MAX)
5817  real(RP), intent(inout) :: Pcrg(KA,PQ_MAX)
5818  !
5819  ! parameter for autoconversion
5820  real(RP), parameter :: kcc = 4.44e+9_rp ! collision efficiency [m3/kg2/sec]
5821  real(RP), parameter :: tau_min = 1.e-20_rp ! empirical filter by T.Mitsui
5822  real(RP), parameter :: rx_sep = 1.0_rp/x_sep ! 1/x_sep, 10/08/03 [Add] T.Mitsui
5823  !
5824  ! parameter for accretion
5825  real(RP), parameter :: kcr = 5.8_rp ! collision efficiency [m3/kg2/sec]
5826  real(RP), parameter :: thr_acc = 5.e-5_rp ! threshold for universal function original
5827  !
5828  ! parameter for self collection and collison break-up
5829  real(RP), parameter :: krr = 4.33_rp ! k_rr, S08 (35)
5830  real(RP), parameter :: kaprr = 60.7_rp ! kappa_rr, SB06(11)
5831  real(RP), parameter :: kbr = 1000._rp ! k_br, SB06(14)
5832  real(RP), parameter :: kapbr = 2.3e+3_rp ! kappa_br, SB06(15)
5833  real(RP), parameter :: dr_min = 0.35e-3_rp ! minimum diameter, SB06(13)-(15)
5834  !
5835  ! work variables
5836  real(RP) :: coef_nuc0 ! coefficient of number for Auto-conversion
5837  real(RP) :: coef_nuc1 ! mass
5838  real(RP) :: coef_aut0 ! number
5839  real(RP) :: coef_aut1 ! mass
5840  real(RP) :: lwc ! lc+lr
5841  real(RP) :: tau ! conversion ratio: qr/(qc+qr) ranges [0:1]
5842  real(RP) :: rho_fac ! factor of air density
5843  real(RP) :: psi_aut ! Universal function of Auto-conversion
5844  real(RP) :: psi_acc ! Universal function of Accretion
5845  real(RP) :: psi_brk ! Universal function of Breakup
5846  real(RP) :: ddr ! diameter difference from equilibrium
5847  !
5848  integer :: k, iqw
5849  real(RP) :: sw
5850  !
5851  coef_nuc0 = (nu(i_mp_qc)+2.0_rp)/(nu(i_mp_qc)+1.0_rp)
5852  coef_nuc1 = (nu(i_mp_qc)+2.0_rp)*(nu(i_mp_qc)+4.0_rp)/(nu(i_mp_qc)+1.0_rp)/(nu(i_mp_qc)+1.0_rp)
5853  coef_aut0 = -kcc*coef_nuc0
5854  coef_aut1 = -kcc/x_sep/20._rp*coef_nuc1
5855  !
5856 !OCL LOOP_FISSION_TARGET(LS)
5857  do k = ks, ke
5858  lwc = rhoq(k,i_qr) + rhoq(k,i_qc)
5859  if( lwc > xc_min )then
5860  tau = max(tau_min, rhoq(k,i_qr)/lwc)
5861  else
5862  tau = tau_min
5863  end if
5864  rho_fac = sqrt(rho_0/max(rho(k),rho_min))
5865  !
5866  ! Auto-conversion ( cloud-cloud => rain )
5867  psi_aut = 400._rp*(tau**0.7_rp)*(1.0_rp - (tau**0.7_rp))**3 ! (6) SB06
5868  pq(k,i_ncaut) = coef_aut0*rhoq(k,i_qc)*rhoq(k,i_qc)*rho_fac*rho_fac ! (9) SB06 sc+aut
5869  ! lc = lwc*(1-tau), lr = lwc*tau
5870  pq(k,i_lcaut) = coef_aut1*lwc*lwc*xq(k,i_mp_qc)*xq(k,i_mp_qc) & ! (4) SB06
5871  *((1.0_rp-tau)*(1.0_rp-tau) + psi_aut)*rho_fac*rho_fac !
5872  pq(k,i_nraut) = -rx_sep*pq(k,i_lcaut) ! (A7) SB01
5873  !--- for Charge density
5874  if (flg_lt) then
5875  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small )
5876  pcrg(k,i_ncaut) = pq(k,i_ncaut)*(1.0_rp-sw)/(rhoq(k,i_nc)+sw)*rhoq_crg(k,i_qc)
5877  pcrg(k,i_nraut) = -pcrg(k,i_ncaut)
5878  end if
5879  !
5880  ! Accretion ( cloud-rain => rain )
5881  psi_acc =(tau/(tau+thr_acc))**4 ! (8) SB06
5882  pq(k,i_lcacc) = -kcr*rhoq(k,i_qc)*rhoq(k,i_qr)*rho_fac*psi_acc ! (7) SB06
5883  pq(k,i_ncacc) = -kcr*rhoq(k,i_nc)*rhoq(k,i_qr)*rho_fac*psi_acc ! (A6) SB01
5884  !--- for Charge density
5885  if (flg_lt) then
5886  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small )
5887  pcrg(k,i_ncacc) = pq(k,i_ncacc)*(1.0_rp-sw)/(rhoq(k,i_nc)+sw)*rhoq(k,i_qc)
5888  end if
5889  !
5890  ! Self-collection ( rain-rain => rain )
5891  pq(k,i_nrslc) = -krr*rhoq(k,i_nr)*rhoq(k,i_qr)*rho_fac ! (A.8) SB01
5892  !
5893  ! Collisional breakup of rain
5894  ddr = min(1.e-3_rp, dq_xave(k,i_mp_qr) - dr_eq )
5895  if ( dq_xave(k,i_mp_qr) < dr_min ) then ! negligible
5896  psi_brk = -1.0_rp
5897  else if ( dq_xave(k,i_mp_qr) <= dr_eq ) then
5898  psi_brk = kbr*ddr ! (14) SB06
5899  else
5900  psi_brk = exp(kapbr*ddr) - 1.0_rp ! (15) SB06 (SB06 has a typo)
5901  end if
5902  pq(k,i_nrbrk) = - (psi_brk + 1.0_rp)*pq(k,i_nrslc) ! (13) SB06
5903  !
5904  end do
5905  !
5906  return
5907  end subroutine aut_acc_slc_brk
5908 
5909  ! Vapor Deposition, Ice Melting
5910 !OCL SERIAL
5911  subroutine dep_vapor_melt_ice( &
5912  KA, KS, KE, &
5913  rho, tem, pre, qd, & ! in
5914  rhoq, & ! in
5915  esw, esi, & ! in
5916  xq, vt_xave, dq_xave, & ! in
5917  PQ ) ! inout
5918  use scale_const, only: &
5919  eps => const_eps
5920  implicit none
5921 
5922  integer, intent(in) :: KA, KS, KE
5923 
5924  ! Diffusion growth or Evaporation, Sublimation
5925  real(RP), intent(inout) :: PQ(KA,PQ_MAX) ! mass change for cloud
5926 
5927  real(RP), intent(in) :: rho(KA) ! air density
5928  real(RP), intent(in) :: tem(KA) ! air temperature
5929  real(RP), intent(in) :: pre(KA) ! air pressure
5930  real(RP), intent(in) :: qd (KA) ! mixing ratio of dry air
5931  real(RP), intent(in) :: esw(KA) ! saturation vapor pressure(liquid water)
5932  real(RP), intent(in) :: esi(KA) ! saturation vapor pressure(solid water)
5933  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
5934  real(RP), intent(in) :: xq(KA,HYDRO_MAX) ! mean mass
5935  ! Notice following values differ from mean terminal velocity or diameter.
5936  ! mean(vt(x)) /= vt(mean(x)) and mean(D(x)) /= D(mean(x))
5937  ! Following ones are vt(mean(x)) and D(mean(x)).
5938  real(RP), intent(in) :: vt_xave(KA,HYDRO_MAX,2) ! terminal velocity of mean cloud
5939  !
5940  real(RP), intent(in) :: dq_xave(KA,HYDRO_MAX) ! diameter
5941  !
5942  real(RP) :: rho_lim ! limited density
5943  real(RP) :: temc_lim ! limited temperature[celsius]
5944  real(RP) :: pre_lim ! limited density
5945  real(RP) :: temc ! temperature[celsius]
5946 ! real(RP) :: pv ! vapor pressure
5947  real(RP) :: qv ! mixing ratio of water vapor
5948 ! real(RP) :: ssw ! super saturation ratio(liquid water)
5949 ! real(RP) :: ssi ! super saturation ratio(ice water)
5950  real(RP) :: nua, r_nua ! kinematic viscosity of air
5951  real(RP) :: mua ! viscosity of air
5952  real(RP) :: Kalfa(KA) ! thermal conductance
5953  real(RP) :: Dw(KA) ! diffusivity of water vapor
5954  real(RP) :: Dt ! diffusivity of heat
5955  real(RP) :: Gw, Gi ! diffusion factor by balance between heat and vapor
5956  real(RP) :: Gwr, Gii, Gis, Gig ! for rain, ice, snow and graupel.
5957  real(RP) :: Gm ! melting factor by balance between heat and vapor
5958  real(RP) :: Nsc_r3 !
5959  ! [Mod] 11/08/30 T.Mitsui, considering large and small branches
5960 ! real(RP) :: Nrecs_r2
5961  real(RP) :: Nrers_r2, Nreis_r2 !
5962  real(RP) :: Nress_r2, Nregs_r2 !
5963 ! real(RP) :: Nrecl_r2
5964  real(RP) :: Nrerl_r2, Nreil_r2 !
5965  real(RP) :: Nresl_r2, Nregl_r2 !
5966  real(RP) :: NscNrer_s, NscNrer_l
5967  real(RP) :: NscNrei_s, NscNrei_l
5968  real(RP) :: NscNres_s, NscNres_l
5969  real(RP) :: NscNreg_s, NscNreg_l
5970  real(RP) :: ventLR_s, ventLR_l
5971  real(RP) :: ventNI_s, ventNI_l, ventLI_s, ventLI_l
5972  real(RP) :: ventNS_s, ventNS_l, ventLS_s, ventLS_l
5973  real(RP) :: ventNG_s, ventNG_l, ventLG_s, ventLG_l
5974  !
5975  real(RP) :: wtr, wti, wts, wtg
5976  real(RP), parameter :: r_14=1.0_rp/1.4_rp
5977  real(RP), parameter :: r_15=1.0_rp/1.5_rp
5978  !
5979  real(RP) :: ventLR
5980  real(RP) :: ventNI(KA), ventLI(KA)
5981  real(RP) :: ventNS(KA), ventLS(KA)
5982  real(RP) :: ventNG(KA), ventLG(KA)
5983  !
5984  real(RP), parameter :: Re_max=1.e+3_rp
5985  real(RP), parameter :: Re_min=1.e-4_rp
5986 
5987  real(RP) :: sw
5988  !
5989  integer :: k
5990  !
5991  ! Notice,T.Mitsui
5992  ! Vapor deposition and melting would not be solved iteratively to reach equilibrium.
5993  ! Because following phenomena are not adjustment but transition.
5994  ! Just time-scales differ among them.
5995  ! If we would treat more appropreately, there would be time-splitting method to solve each ones.
5996 
5997 !OCL LOOP_FISSION_TARGET(LS)
5998  do k = ks, ke
5999  temc = tem(k) - t00 ! degC
6000  temc_lim= max(temc, -40._rp ) ! [Add] 09/08/18 T.Mitsui, Pruppacher and Klett(1997),(13-3)
6001  rho_lim = max(rho(k),rho_min) ! [Add] 09/08/18 T.Mitsui
6002  qv = rhoq(k,i_qv)/rho_lim
6003  pre_lim = rho_lim*(qd(k)*rdry + qv*rvap)*(temc_lim+t00) ![Add] 09/08/18 T.Mitsui
6004  !--------------------------------------------------------------------
6005  ! Diffusion growth part is described in detail
6006  ! by Pruppacher and Klett (1997) Sec. 13.2(liquid) and 13.3(solid)
6007  !
6008  ! G:factor of thermal diffusion(1st.term) and vapor diffusion(2nd. term)
6009  ! SB06(23),(38), Lin et al(31),(52) or others
6010  ! Dw is introduced by Pruppacher and Klett(1997),(13-3)
6011  dw(k) = 0.211e-4_rp* (((temc_lim+t00)/t00)**1.94_rp) *(p00/pre_lim)
6012  kalfa(k) = ka0 + temc_lim*dka_dt
6013  mua = mua0 + temc_lim*dmua_dt
6014  nua = mua/rho_lim
6015  r_nua = 1.0_rp/nua
6016  gw = (lhv0/kalfa(k)/tem(k))*(lhv0/rvap/tem(k)-1.0_rp)+(rvap*tem(k)/dw(k)/esw(k))
6017  gi = (lhs0/kalfa(k)/tem(k))*(lhs0/rvap/tem(k)-1.0_rp)+(rvap*tem(k)/dw(k)/esi(k))
6018  ! capacities account for their surface geometries
6019  gwr = 4.0_rp*pi/cap(i_mp_qr)/gw
6020  gii = 4.0_rp*pi/cap(i_mp_qi)/gi
6021  gis = 4.0_rp*pi/cap(i_mp_qs)/gi
6022  gig = 4.0_rp*pi/cap(i_mp_qg)/gi
6023  ! vent: ventilation effect( asymmetry vapor field around particles due to aerodynamic )
6024  ! SB06 (30),(31) and each coefficient is by (88),(89)
6025  nsc_r3 = (nua/dw(k))**(0.33333333_rp) ! (Schmidt number )^(1/3)
6026  !
6027 ! Nrecs_r2 = sqrt(max(Re_min,min(Re_max,vt_xave(k,I_mp_QC,1)*dq_xave(k,I_mp_QC)*r_nua))) ! (Reynolds number)^(1/2) cloud
6028  nrers_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qr,1)*dq_xave(k,i_mp_qr)*r_nua))) ! (Reynolds number)^(1/2) rain
6029  nreis_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qi,1)*dq_xave(k,i_mp_qi)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
6030  nress_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qs,1)*dq_xave(k,i_mp_qs)*r_nua))) ! (Reynolds number)^(1/2) snow
6031  nregs_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qg,1)*dq_xave(k,i_mp_qg)*r_nua))) ! (Reynolds number)^(1/2) graupel
6032  !
6033 ! Nrecl_r2 = sqrt(max(Re_min,min(Re_max,vt_xave(k,I_mp_QC,2)*dq_xave(k,I_mp_QC)*r_nua))) ! (Reynolds number)^(1/2) cloud
6034  nrerl_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qr,2)*dq_xave(k,i_mp_qr)*r_nua))) ! (Reynolds number)^(1/2) rain
6035  nreil_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qi,2)*dq_xave(k,i_mp_qi)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
6036  nresl_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qs,2)*dq_xave(k,i_mp_qs)*r_nua))) ! (Reynolds number)^(1/2) snow
6037  nregl_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qg,2)*dq_xave(k,i_mp_qg)*r_nua))) ! (Reynolds number)^(1/2) graupel
6038  nscnrer_s=nsc_r3*nrers_r2 ! small rain
6039  nscnrer_l=nsc_r3*nrerl_r2 ! large rain
6040  !
6041  nscnrei_s=nsc_r3*nreis_r2 ! small ice
6042  nscnrei_l=nsc_r3*nreil_r2 ! large ice
6043  !
6044  nscnres_s=nsc_r3*nress_r2 ! small snow
6045  nscnres_l=nsc_r3*nresl_r2 ! large snow
6046  !
6047  nscnreg_s=nsc_r3*nregs_r2 ! small snow
6048  nscnreg_l=nsc_r3*nregl_r2 ! large snow
6049  !
6050  ventlr_s = ah_vent1(i_mp_qr,1) + bh_vent1(i_mp_qr,1)*nscnrer_s
6051  ventlr_l = ah_vent1(i_mp_qr,2) + bh_vent1(i_mp_qr,2)*nscnrer_l
6052  !
6053  ventni_s = ah_vent0(i_mp_qi,1) + bh_vent0(i_mp_qi,1)*nscnrei_s
6054  ventni_l = ah_vent0(i_mp_qi,2) + bh_vent0(i_mp_qi,2)*nscnrei_l
6055  ventli_s = ah_vent1(i_mp_qi,1) + bh_vent1(i_mp_qi,1)*nscnrei_s
6056  ventli_l = ah_vent1(i_mp_qi,2) + bh_vent1(i_mp_qi,2)*nscnrei_l
6057  !
6058  ventns_s = ah_vent0(i_mp_qs,1) + bh_vent0(i_mp_qs,1)*nscnres_s
6059  ventns_l = ah_vent0(i_mp_qs,2) + bh_vent0(i_mp_qs,2)*nscnres_l
6060  ventls_s = ah_vent1(i_mp_qs,1) + bh_vent1(i_mp_qs,1)*nscnres_s
6061  ventls_l = ah_vent1(i_mp_qs,2) + bh_vent1(i_mp_qs,2)*nscnres_l
6062  !
6063  ventng_s = ah_vent0(i_mp_qg,1) + bh_vent0(i_mp_qg,1)*nscnreg_s
6064  ventng_l = ah_vent0(i_mp_qg,2) + bh_vent0(i_mp_qg,2)*nscnreg_l
6065  ventlg_s = ah_vent1(i_mp_qg,1) + bh_vent1(i_mp_qg,1)*nscnreg_s
6066  ventlg_l = ah_vent1(i_mp_qg,2) + bh_vent1(i_mp_qg,2)*nscnreg_l
6067  !
6068  ! branch is 1.4 for rain, snow, graupel; is 1.0 for ice (PK97, 13-60,-61,-88,-89).
6069  !
6070  wtr = ( min(max( nscnrer_s*r_14, 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.4*0.5 and 1.4*2
6071  wti = ( min(max( nscnrei_s , 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.0*0.5 and 1.0*2
6072  wts = ( min(max( nscnres_s*r_14, 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.4*0.5 and 1.4*2
6073  wtg = ( min(max( nscnreg_s*r_14, 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.4*0.5 and 1.4*2
6074  ! interpolation between two branches
6075  ventni(k) = (1.0_rp-wti)*ventni_s + wti*ventni_l
6076  ventns(k) = (1.0_rp-wts)*ventns_s + wts*ventns_l
6077  ventng(k) = (1.0_rp-wtg)*ventng_s + wtg*ventng_l
6078  !
6079  ventlr = (1.0_rp-wtr)*ventlr_s + wtr*ventlr_l
6080  ventli(k) = (1.0_rp-wti)*ventli_s + wti*ventli_l
6081  ventls(k) = (1.0_rp-wts)*ventls_s + wts*ventls_l
6082  ventlg(k) = (1.0_rp-wtg)*ventlg_s + wtg*ventlg_l
6083  !
6084  ! SB06(29)
6085  ! [Mod] 08/05/08 T.Mitsui, recover PNXdep, and rain is only evaporation.
6086  ! Ni, Ns, Ng should decrease in nature so we add this term.
6087  ! And vapor deposition never occur unless number exist.
6088  ! [Add comment] 09/08/18
6089  ! recover condensation/evaporation of rain,
6090  ! and ventilation effects are not taken into account for cloud.
6091  !
6092 !!$***************************************************************************
6093 !!$ NOTICE:
6094 !!$ Hereafter PLxdep means inverse of timescale.
6095 !!$***************************************************************************
6096 !!$ PQ(k,I_LCdep) = Gwr*ssw*rhoq(k,I_NC)*dq_xave(k,I_mp_QC)*coef_deplc
6097 !!$ PQ(k,I_LRdep) = Gwr*ssw*rhoq(k,I_NR)*dq_xave(k,I_mp_QR)*ventLR
6098 !!$ PQ(k,I_LIdep) = Gii*ssi*rhoq(k,I_NI)*dq_xave(k,I_mp_QI)*ventLI(k)
6099 !!$ PQ(k,I_LSdep) = Gis*ssi*rhoq(k,I_NS)*dq_xave(k,I_mp_QS)*ventLS(k)
6100 !!$ PQ(k,I_LGdep) = Gig*ssi*rhoq(k,I_NG)*dq_xave(k,I_mp_QG)*ventLG(k)
6101  pq(k,i_lcdep) = gwr*rhoq(k,i_nc)*dq_xave(k,i_mp_qc)*coef_deplc
6102  pq(k,i_lrdep) = gwr*rhoq(k,i_nr)*dq_xave(k,i_mp_qr)*ventlr
6103  pq(k,i_lidep) = gii*rhoq(k,i_ni)*dq_xave(k,i_mp_qi)*ventli(k)
6104  pq(k,i_lsdep) = gis*rhoq(k,i_ns)*dq_xave(k,i_mp_qs)*ventls(k)
6105  pq(k,i_lgdep) = gig*rhoq(k,i_ng)*dq_xave(k,i_mp_qg)*ventlg(k)
6106  pq(k,i_nrdep) = pq(k,i_lrdep)/xq(k,i_mp_qr)
6107  pq(k,i_nidep) = 0.0_rp
6108  pq(k,i_nsdep) = pq(k,i_lsdep)/xq(k,i_mp_qs)
6109  pq(k,i_ngdep) = pq(k,i_lgdep)/xq(k,i_mp_qg)
6110  end do
6111 
6112  do k = ks, ke
6113  temc = tem(k) - t00 ! degC
6114  !------------------------------------------------------------------------
6115  ! Melting part is described by Pruppacher and Klett (1997) Sec.16.3.1
6116  ! Here we omit "Shedding" of snow-flakes and ice-particles.
6117  ! "Shedding" may be applicative if you refer
6118  ! eq.(38) in Cotton etal.(1986) Jour. Clim. Appl. Meteor. p.1658-1680.
6119  ! SB06(73)
6120  dt = kalfa(k)/(cpvap*rho_0)
6121  ! Gm: factor caused by balance between
6122  ! "water evaporation cooling(1st.)" and "fusion heating(2nd.)"
6123  ! SB06(76)
6124  ! [fix] 08/05/08 T.Mitsui LHF00 => EMELT and esw => PSAT0
6125  ! LHS0 is more suitable than LHS because melting occurs around 273.15 K.
6126  gm = 2.0_rp*pi/emelt&
6127  * ( (kalfa(k)*dt/dw(k))*(temc) + (dw(k)*lhs0/rvap)*(esi(k)/tem(k)-psat0/t00) )
6128  ! SB06(76)
6129  ! Notice! melting only occurs where T > 273.15 K else doesn't.
6130  ! [fix] 08/05/08 T.Mitsui, Gm could be both positive and negative value.
6131  ! See Pruppacher and Klett(1997) eq.(16-79) or Rasmussen and Pruppacher(1982)
6132  sw = ( sign(0.5_rp,temc) + 0.5_rp ) * ( sign(0.5_rp,gm-eps) + 0.5_rp ) ! sw = 1 if( (temc>=0.0_RP) .AND. (Gm>0.0_RP) ), otherwise sw = 0
6133  ! if Gm==0 then rh and tem is critical value for melting process.
6134  ! 08/05/16 [Mod] T.Mitsui, change term of PLimlt. N_i => L_i/ (limited x_i)
6135  ! because melting never occur when N_i=0.
6136  pq(k,i_limlt) = - gm * rhoq(k,i_qi)*dq_xave(k,i_mp_qi)*ventli(k)/xq(k,i_mp_qi) * sw
6137  pq(k,i_nimlt) = - gm * rhoq(k,i_ni)*dq_xave(k,i_mp_qi)*ventni(k)/xq(k,i_mp_qi) * sw
6138  pq(k,i_lsmlt) = - gm * rhoq(k,i_qs)*dq_xave(k,i_mp_qs)*ventls(k)/xq(k,i_mp_qs) * sw
6139  pq(k,i_nsmlt) = - gm * rhoq(k,i_ns)*dq_xave(k,i_mp_qs)*ventns(k)/xq(k,i_mp_qs) * sw
6140  pq(k,i_lgmlt) = - gm * rhoq(k,i_qg)*dq_xave(k,i_mp_qg)*ventlg(k)/xq(k,i_mp_qg) * sw
6141  pq(k,i_ngmlt) = - gm * rhoq(k,i_ng)*dq_xave(k,i_mp_qg)*ventng(k)/xq(k,i_mp_qg) * sw
6142  end do
6143 
6144  return
6145  end subroutine dep_vapor_melt_ice
6146  !-----------------------------------------------------------------------------
6147 
6148  ! Vapor Deposition [Add] 2022/03/23 T.Seiki for nucleation
6149 !OCL SERIAL
6150  subroutine dep_vapor_ice_wrk( &
6151  KA, KS, KE, &
6152  PLIdep_total, &
6153  rho, tem, pre, &
6154  qd, &
6155  esi, qsi, &
6156  rhoq, &
6157  vt_xave, dq_xave, &
6158  dt )
6159  use scale_const, only: &
6160  rvap => const_rvap, &
6161  rdry => const_rdry, &
6162  t00 => const_tem00, &
6163  lhs0 => const_lhs0, &
6164  lhf00 => const_lhf00, &
6165  pi => const_pi, &
6166  cpdry => const_cpdry, &
6167  pstd => const_pstd, &
6168  psat0 => const_psat0
6169  implicit none
6170 
6171  integer, intent(in) :: KA
6172  integer, intent(in) :: KS
6173  integer, intent(in) :: KE
6174  ! Diffusion growth or Evaporation, Sublimation
6175  real(RP), intent(out) :: PLIdep_total(KA) ! mass for cloud ice
6176  real(RP), intent(in) :: rho(KA) ! air density
6177  real(RP), intent(in) :: tem(KA) ! air temperature
6178  real(RP), intent(in) :: pre(KA) ! air pressure
6179  real(RP), intent(in) :: qd(KA) ! mixing ratio of dry air
6180  real(RP), intent(in) :: esi(KA) ! saturation vapor pressure(solid water)
6181  real(RP), intent(in) :: qsi(KA) ! saturation vapor pressure(solid water)
6182  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
6183  ! Notice following values differ from mean terminal velocity or diameter.
6184  ! mean(vt(x)) /= vt(mean(x)) and mean(D(x)) /= D(mean(x))
6185  ! Following ones are vt(mean(x)) and D(mean(x)).
6186  real(RP), intent(in) :: vt_xave(KA,HYDRO_MAX,1:2) ! terminal velocity of mean cloud
6187  real(RP), intent(in) :: dq_xave(KA,HYDRO_MAX) !
6188  real(RP), intent(in) :: dt
6189  !
6190 ! real(RP), intent(in) :: dtime
6191 ! real(RP) :: dtime
6192  !
6193  real(RP) :: rho_lim ! limited density
6194  real(RP) :: temc_lim ! limited temperature[celsius]
6195  real(RP) :: pre_lim ! limited density
6196  real(RP) :: temc ! temperature[celsius]
6197  real(RP) :: pv ! vapor pressure
6198  real(RP) :: qv ! vapor pressure
6199  real(RP) :: ssi ! super saturation ratio(ice water)
6200  real(RP) :: nua, r_nua ! kinematic viscosity of air
6201  real(RP) :: mua ! viscosity of air
6202  real(RP) :: Kat ! thermal conductance
6203  real(RP) :: Dw ! diffusivity of water vapor
6204  real(RP) :: Dht ! diffusivity of heat
6205  real(RP) :: Gi ! diffusion factor by balance between heat and vapor
6206  real(RP) :: Gii, Gis, Gig ! for rain, ice, snow and graupel.
6207  real(RP) :: Gm ! melting factor by balance between heat and vapor
6208  real(RP) :: Nsc_r3 !
6209  !
6210  real(RP) :: Nreis_r2 !
6211  real(RP) :: Nress_r2, Nregs_r2 !
6212  real(RP) :: Nreil_r2 !
6213  real(RP) :: Nresl_r2, Nregl_r2 !
6214  real(RP) :: NscNrei_s, NscNrei_l
6215  real(RP) :: NscNres_s, NscNres_l
6216  real(RP) :: NscNreg_s, NscNreg_l
6217  real(RP) :: ventLI_s, ventLI_l
6218  real(RP) :: ventLS_s, ventLS_l
6219  real(RP) :: ventLG_s, ventLG_l
6220  real(RP) :: wti, wts, wtg
6221  real(RP), parameter :: r_14=1.0_rp/1.4_rp
6222  real(RP), parameter :: r_15=1.0_rp/1.5_rp
6223  real(RP) :: ventLI !
6224  real(RP) :: ventLS !
6225  real(RP) :: ventLG !
6226  !
6227  real(RP) :: total_dep
6228  real(RP) :: PLIdep_wrk
6229  real(RP) :: PLSdep_wrk
6230  real(RP) :: PLGdep_wrk
6231  real(RP) :: dep_limiter
6232  !
6233  real(RP), parameter :: Re_max=1.e3_rp
6234  real(RP), parameter :: Re_min=1.e-4_rp
6235  integer :: k
6236  !
6237 ! PLIdep_total(1:KS)=0.0_RP
6238 ! PLIdep_total(KE:KA)=0.0_RP
6239  plidep_total(:)=0.0_rp !! 22/10/14
6240 
6241  !
6242  do k=ks, ke
6243  temc = tem(k) - t00 ! degC
6244  temc_lim= max(temc, temc_lim_diff) !
6245  rho_lim = max(rho(k),rho_min) !
6246  qv = rhoq(k,i_qv)/rho_lim
6247  pre_lim = rho_lim*(qd(k)*rdry + qv*rvap)*(temc_lim+t00)
6248  !--------------------------------------------------------------------
6249  ! Diffusion growth part is described in detail
6250  ! by Pruppacher and Klett (1997) Sec. 13.2(liquid) and 13.3(solid)
6251  ! G:factor of thermal diffusion(1st.term) and vapor diffusion(2nd. term)
6252  ! SB06(23),(38), Lin et al(31),(52) or others
6253  ! Dw is introduced by Pruppacher and Klett(1997),(13-3)
6254  dw = 0.211e-4_rp* (((temc_lim+t00)/t00)**1.94_rp) *(pstd/pre_lim)
6255  kat = ka0 + temc_lim*dka_dt
6256  mua = mua0 + temc_lim*dmua_dt
6257  nua = mua/rho_lim
6258  r_nua = 1.0_rp/nua
6259  gi = (lhs0/kat/tem(k))*(lhs0/rvap/tem(k)-1.0_rp)+(rvap*tem(k)/dw/esi(k))
6260  ! capacities account for their surface geometries
6261  gii = 4.0_rp*pi/cap(i_mp_qi)/gi
6262  gis = 4.0_rp*pi/cap(i_mp_qs)/gi
6263  gig = 4.0_rp*pi/cap(i_mp_qg)/gi
6264  ! vent: ventilation effect( asymmetry vapor field around particles due to aerodynamic )
6265  ! SB06 (30),(31) and each coefficient is by (88),(89)
6266  nsc_r3 = (nua/dw)**(0.33333333_rp) ! (Schmidt number )^(1/3)
6267  ! Beard and Pruppacher(1971) had performed in the range [0<Re<=320],
6268  ! So here we limit Re in the range Re_max=1000, Re_min=0.0001.
6269  nreis_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qi,1)*dq_xave(k,i_mp_qi)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
6270  nress_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qs,1)*dq_xave(k,i_mp_qs)*r_nua))) ! (Reynolds number)^(1/2) snow
6271  nregs_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qg,1)*dq_xave(k,i_mp_qg)*r_nua))) ! (Reynolds number)^(1/2) graupel
6272  nreil_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qi,2)*dq_xave(k,i_mp_qi)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
6273  nresl_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qs,2)*dq_xave(k,i_mp_qs)*r_nua))) ! (Reynolds number)^(1/2) snow
6274  nregl_r2 = sqrt(max(re_min,min(re_max,vt_xave(k,i_mp_qg,2)*dq_xave(k,i_mp_qg)*r_nua))) ! (Reynolds number)^(1/2) graupel
6275  !
6276  nscnrei_s=nsc_r3*nreis_r2 ! small ice
6277  nscnrei_l=nsc_r3*nreil_r2 ! large ice
6278  nscnres_s=nsc_r3*nress_r2 ! small snow
6279  nscnres_l=nsc_r3*nresl_r2 ! large snow
6280  nscnreg_s=nsc_r3*nregs_r2 ! small snow
6281  nscnreg_l=nsc_r3*nregl_r2 ! large snow
6282  !
6283  ventli_s = ah_vent1(i_mp_qi,1) + bh_vent1(i_mp_qi,1)*nscnrei_s
6284  ventli_l = ah_vent1(i_mp_qi,2) + bh_vent1(i_mp_qi,2)*nscnrei_l
6285  ventls_s = ah_vent1(i_mp_qs,1) + bh_vent1(i_mp_qs,1)*nscnres_s
6286  ventls_l = ah_vent1(i_mp_qs,2) + bh_vent1(i_mp_qs,2)*nscnres_l
6287  ventlg_s = ah_vent1(i_mp_qg,1) + bh_vent1(i_mp_qg,1)*nscnreg_s
6288  ventlg_l = ah_vent1(i_mp_qg,2) + bh_vent1(i_mp_qg,2)*nscnreg_l
6289  ! branch is 1.4 for rain, snow, graupel; is 1.0 for ice (PK97, 13-60,-61,-88,-89).
6290  wti = ( min(max( nscnrei_s , 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.0*0.5 and 1.0*2
6291  wts = ( min(max( nscnres_s*r_14, 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.4*0.5 and 1.4*2
6292  wtg = ( min(max( nscnreg_s*r_14, 0.5_rp), 2.0_rp) -0.5_rp )*r_15 ! weighting between 1.4*0.5 and 1.4*2
6293  ! interpolation between two branches
6294  ventli = (1.0_rp-wti)*ventli_s + wti*ventli_l
6295  ventls = (1.0_rp-wts)*ventls_s + wts*ventls_l
6296  ventlg = (1.0_rp-wtg)*ventlg_s + wtg*ventlg_l
6297  ! SB06(29)
6298  ssi = qv/qsi(k) - 1.0_rp ! supersaturation
6299  plidep_wrk = gii*ssi*max(rhoq(k,i_ni),0.0_rp)*dq_xave(k,i_mp_qi)*ventli
6300  plsdep_wrk = gis*ssi*max(rhoq(k,i_ns),0.0_rp)*dq_xave(k,i_mp_qs)*ventls
6301  plgdep_wrk = gig*ssi*max(rhoq(k,i_ng),0.0_rp)*dq_xave(k,i_mp_qg)*ventlg
6302  !
6303  dep_limiter = rho(k)*(qv-qsi(k))/dt
6304  if (ssi < -1.e-30_rp)then ! unsaturated
6305  plidep_total(k) = max(plidep_wrk+plsdep_wrk+plgdep_wrk, dep_limiter)
6306  else if (ssi > 1.e-30_rp)then ! saturated
6307  plidep_total(k) = min(plidep_wrk+plsdep_wrk+plgdep_wrk, dep_limiter)
6308  else
6309  plidep_total(k) = 0.0_rp
6310  end if
6311  enddo
6312 
6313  return
6314  end subroutine dep_vapor_ice_wrk
6315 
6316 
6317 !OCL SERIAL
6318  subroutine freezing_water( &
6319  KA, KS, KE, &
6320  dt, &
6321  rhoq, xq, tem, &
6322  PQ )
6323  implicit none
6324  !
6325  ! In this subroutine,
6326  ! We assumed surface temperature of droplets are same as environment.
6327 
6328  integer, intent(in) :: KA, KS, KE
6329 
6330  real(RP), intent(in) :: dt
6331  !
6332  real(RP), intent(in) :: tem(KA)
6333  !
6334  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
6335  real(RP), intent(in) :: xq(KA,HYDRO_MAX)
6336  !
6337  real(RP), intent(inout):: PQ(KA,PQ_MAX)
6338  !
6339  real(RP), parameter :: temc_min = -65.0_rp
6340  real(RP), parameter :: a_het = 0.2_rp ! SB06 (44)
6341  real(RP), parameter :: b_het = 0.65_rp ! SB06 (44)
6342  !
6343  real(RP) :: coef_m2_c
6344  real(RP) :: coef_m2_r
6345  ! temperature [celsius]
6346  real(RP) :: temc, temc2, temc3, temc4
6347  ! temperature function of homegenous/heterogenous freezing
6348  real(RP) :: Jhom, Jhet, Jh(KA)
6349  real(RP) :: rdt
6350  real(RP) :: tmp
6351  !
6352  integer :: k
6353  !
6354  rdt = 1.0_rp/dt
6355  !
6356  coef_m2_c = coef_m2(i_mp_qc)
6357  coef_m2_r = coef_m2(i_mp_qr)
6358  !
6359 
6360  ! Note, xc should be limited in range[xc_min:xc_max].
6361  ! and PNChom need to be calculated by NC
6362  ! because reduction rate of Nc need to be bound by NC.
6363  ! For the same reason PLChom also bound by LC and xc.
6364  ! Basically L and N should be independent
6365  ! but average particle mass x should be in suitable range.
6366 
6367  ! Homogenous Freezing
6368  do k = ks, ke
6369  pq(k,i_lchom) = 0.0_rp
6370  pq(k,i_nchom) = 0.0_rp
6371  end do
6372 
6373  ! Heterogenous Freezing
6374  do k = ks, ke
6375  temc = max( tem(k) - t00, temc_min )
6376  ! These cause from aerosol-droplet interaction.
6377  ! Bigg(1953) formula, Khain etal.(2000) eq.(4.5), Pruppacher and Klett(1997) eq.(9-48)
6378  jhet = a_het*( exp( -b_het*temc ) - 1.0_rp )
6379  ! These cause in nature.
6380  ! Cotton and Field 2002, QJRMS. (12)
6381  if( temc < -30.0_rp ) then
6382  temc2 = temc*temc
6383  temc3 = temc*temc2
6384  temc4 = temc2*temc2
6385  jhom = 10.0_rp**(&
6386  - 243.40_rp - 14.75_rp*temc - 0.307_rp*temc2 &
6387  - 0.00287_rp*temc3 - 0.0000102_rp*temc4 ) *1.e+3_rp
6388  else if( temc < 0.0_rp) then
6389  jhom = 10._rp**(-7.63_rp-2.996_rp*(temc+30.0_rp))*1.e+3_rp
6390  else
6391  jhom = 0.0_rp
6392  jhet = 0.0_rp
6393  end if
6394  jh(k) = ( jhet + jhom ) * dt
6395  end do
6396 
6397  do k = ks, ke
6398 #if defined(NVIDIA) || defined(SX)
6399  tmp = min( xq(k,i_mp_qc)*jh(k), 1.e+3_rp) ! apply exp limiter
6400  pq(k,i_lchet) = -rdt*rhoq(k,i_qc)*( 1.0_rp - exp( -coef_m2_c*tmp ) )
6401  pq(k,i_nchet) = -rdt*rhoq(k,i_nc)*( 1.0_rp - exp( - tmp ) )
6402 
6403  tmp = min( xq(k,i_mp_qr)*jh(k), 1.e+3_rp) ! apply exp limiter
6404  pq(k,i_lrhet) = -rdt*rhoq(k,i_qr)*( 1.0_rp - exp( -coef_m2_r*tmp ) )
6405  pq(k,i_nrhet) = -rdt*rhoq(k,i_nr)*( 1.0_rp - exp( - tmp ) )
6406 #else
6407  pq(k,i_lchet) = -rdt*rhoq(k,i_qc)*( 1.0_rp - exp( -coef_m2_c*xq(k,i_mp_qc)*jh(k) ) )
6408  pq(k,i_nchet) = -rdt*rhoq(k,i_nc)*( 1.0_rp - exp( - xq(k,i_mp_qc)*jh(k) ) )
6409  pq(k,i_lrhet) = -rdt*rhoq(k,i_qr)*( 1.0_rp - exp( -coef_m2_r*xq(k,i_mp_qr)*jh(k) ) )
6410  pq(k,i_nrhet) = -rdt*rhoq(k,i_nr)*( 1.0_rp - exp( - xq(k,i_mp_qr)*jh(k) ) )
6411 #endif
6412  end do
6413 
6414  !
6415  return
6416  end subroutine freezing_water
6417 
6418  !----------------------------------------------------------------
6419 !OCL SERIAL
6420  subroutine update_by_phase_change( &
6421  KA, KS, KE, &
6422  ntmax, & ! in
6423  dt, & ! in
6424  cz, & ! in
6425  fz, & ! in
6426  w, & ! in
6427  dTdt_rad, & ! in
6428  rho, & ! in
6429  qdry, & ! in
6430  esw, esi, rhoq, & ! in
6431  pre, tem, & ! in
6432  cpa,cva, & ! in
6433  flg_lt, & ! in
6434  PQ, & ! inout
6435  sl_PLCdep, & ! inout
6436  sl_PLRdep, sl_PNRdep, & ! inout
6437  RHOQ_t, & ! out
6438  RHOE_t, & ! out
6439  CPtot_t, & ! out
6440  CVtot_t, & ! out
6441  qc_evaporate, & ! out
6442  rhoq_crg, & ! in:optional
6443  RHOQcrg_t ) ! out:optional
6444 
6445  use scale_atmos_hydrometeor, only: &
6446  cp_vapor, &
6447  cp_water, &
6448  cp_ice, &
6449  cv_vapor, &
6450  cv_water, &
6451  cv_ice
6452  use scale_atmos_saturation, only: &
6453  moist_pres2qsat_liq => atmos_saturation_pres2qsat_liq, &
6454  moist_pres2qsat_ice => atmos_saturation_pres2qsat_ice, &
6455  moist_dqs_dtem_dens_liq => atmos_saturation_dqs_dtem_dens_liq, &
6456  moist_dqs_dtem_dens_ice => atmos_saturation_dqs_dtem_dens_ice, &
6457  moist_dqs_dtem_dpre_liq => atmos_saturation_dqs_dtem_dpre_liq, &
6458  moist_dqs_dtem_dpre_ice => atmos_saturation_dqs_dtem_dpre_ice
6459  implicit none
6460 
6461  integer, intent(in) :: KA, KS, KE
6462 
6463  integer, intent(in) :: ntmax
6464  !
6465  real(RP), intent(in) :: dt ! time step[s]
6466  real(RP), intent(in) :: cz(KA) ! altitude [m]
6467  real(RP), intent(in) :: fz(0:KA) ! altitude difference [m]
6468  real(RP), intent(in) :: w (KA) ! vertical velocity @ full level [m/s]
6469  real(RP), intent(in) :: dTdt_rad(KA) ! temperture tendency by radiation[K/s]
6470  real(RP), intent(in) :: rho (KA) ! density[kg/m3]
6471  real(RP), intent(in) :: qdry(KA) ! dry air mass ratio [kg/kg]
6472  real(RP), intent(in) :: esw (KA) ! saturated vapor pressure for liquid
6473  real(RP), intent(in) :: esi (KA) ! for ice
6474  real(RP), intent(in) :: rhoq(KA,I_QV:I_NG)
6475 
6476  real(RP), intent(in) :: tem(KA) ! temperature[K]
6477  real(RP), intent(in) :: pre(KA) ! pressure[Pa]
6478  real(RP), intent(in) :: cpa(KA) !
6479  real(RP), intent(in) :: cva(KA) ! specific heat at constant volume
6480 
6481  !+++ tendency[kg/m3/s]
6482  real(RP), intent(inout) :: PQ(KA,PQ_MAX)
6483  !+++ Column integrated tendency[kg/m2/s]
6484  real(RP), intent(inout) :: sl_PLCdep
6485  real(RP), intent(inout) :: sl_PLRdep, sl_PNRdep
6486 
6487  real(RP),intent(out) :: RHOQ_t(KA,QA_MP)
6488  real(RP),intent(out) :: RHOE_t(KA)
6489  real(RP),intent(out) :: CPtot_t(KA)
6490  real(RP),intent(out) :: CVtot_t(KA)
6491 
6492  !+++ tendency[kg/m3/s]
6493  real(RP), intent(out) :: qc_evaporate(KA)
6494 
6495  !--- for lightning component
6496  logical, intent(in) :: flg_lt ! false -> without lightning, true-> with lightning
6497  real(RP), intent(in), optional :: rhoq_crg(KA,I_QC:I_QG)
6498  real(RP), intent(out), optional :: RHOQcrg_t(KA,I_QC:I_QG)
6499 
6500  real(RP) :: xi ! mean mass of ice particles
6501  real(RP) :: rrho ! 1/rho
6502  real(RP) :: wtem(KA) ! temperature[K]
6503  !
6504  real(RP) :: r_cva ! specific heat at constant volume
6505  !real(RP) :: cpa ! specific heat at constant pressure
6506  real(RP) :: r_cpa ! specific heat at constant pressure
6507  real(RP) :: qsw(KA) ! saturated mixing ratio for liquid
6508  real(RP) :: qsi(KA) ! saturated mixing ratio for solid
6509  real(RP) :: dqswdtem_rho(KA) ! (dqsw/dtem)_rho
6510  real(RP) :: dqsidtem_rho(KA) ! (dqsi/dtem)_rho
6511  real(RP) :: dqswdtem_pre(KA) ! (dqsw/dtem)_pre
6512  real(RP) :: dqsidtem_pre(KA) ! (dqsi/dtem)_pre
6513  real(RP) :: dqswdpre_tem(KA) ! (dqsw/dpre)_tem
6514  real(RP) :: dqsidpre_tem(KA) ! (dqsi/dpre)_tem
6515  !
6516  real(RP) :: w2(KA) ! vetical velocity[m/s]
6517  real(RP) :: Acnd ! Pdynliq + Bergeron-Findeisen
6518  real(RP) :: Adep ! Pdyndep + Bergeron-Findeisen
6519  real(RP) :: aliqliq, asolliq
6520  real(RP) :: aliqsol, asolsol
6521  real(RP) :: Pdynliq ! production term of ssw by vertical motion
6522  real(RP) :: Pdynsol ! production term of ssi by vertical motion
6523  real(RP) :: Pradliq ! production term of ssw by radiation
6524  real(RP) :: Pradsol ! production term of ssi by radiation
6525  real(RP) :: taucnd, r_taucnd ! time scale of ssw change by MP
6526  real(RP) :: taudep, r_taudep ! time scale of ssi change by MP
6527  real(RP) :: taucnd_c(KA), r_taucnd_c ! by cloud
6528  real(RP) :: taucnd_r(KA), r_taucnd_r ! by rain
6529  real(RP) :: taudep_i(KA), r_taudep_i ! by ice
6530  real(RP) :: taudep_s(KA), r_taudep_s ! by snow
6531  real(RP) :: taudep_g(KA), r_taudep_g ! by graupel
6532  ! alternative tendency through changing ssw and ssi
6533  real(RP) :: PNCdep
6534  real(RP) :: PLR2NR, PLI2NI, PLS2NS, PLG2NG
6535  real(RP) :: coef_a_cnd, coef_b_cnd
6536  real(RP) :: coef_a_dep, coef_b_dep
6537  !
6538  real(RP) :: frz_dqc
6539  real(RP) :: frz_dnc(KA)
6540  real(RP) :: frz_dqr
6541  real(RP) :: frz_dnr(KA)
6542  real(RP) :: mlt_dqi
6543  real(RP) :: mlt_dni(KA)
6544  real(RP) :: mlt_dqs
6545  real(RP) :: mlt_dns(KA)
6546  real(RP) :: mlt_dqg
6547  real(RP) :: mlt_dng(KA)
6548  real(RP) :: dep_qv
6549  real(RP) :: dep_dqi(KA)
6550  real(RP) :: dep_dni(KA)
6551  real(RP) :: dep_dqs(KA)
6552  real(RP) :: dep_dns(KA)
6553  real(RP) :: dep_dqg(KA)
6554  real(RP) :: dep_dng(KA)
6555  real(RP) :: dep_dqr(KA)
6556  real(RP) :: dep_dnr(KA)
6557  real(RP) :: dep_dqc(KA)
6558  real(RP) :: dep_dnc(KA) ! 11/08/30 [Add] T.Mitsui, dep_dnc
6559  real(RP) :: r_xc_ccn, r_xi_ccn ! 11/08/30 [Add] T.Mitsui
6560  !
6561  real(RP) :: drhoqv(KA)
6562  real(RP) :: drhoqc(KA), drhoqr(KA), drhoqi(KA), drhoqs(KA), drhoqg(KA)
6563  real(RP) :: drhonc(KA), drhonr(KA), drhoni(KA), drhons(KA), drhong(KA)
6564  !-- for Charge densicty
6565  real(RP) :: drhoqcrg_c(KA), drhoqcrg_r(KA)
6566  real(RP) :: drhoqcrg_i(KA), drhoqcrg_s(KA), drhoqcrg_g(KA)
6567  real(RP) :: frz_dnc_crg
6568  real(RP) :: frz_dnr_crg
6569  real(RP) :: mlt_dni_crg
6570  real(RP) :: mlt_dns_crg
6571  real(RP) :: mlt_dng_crg
6572  real(RP) :: dep_dni_crg
6573  real(RP) :: dep_dns_crg
6574  real(RP) :: dep_dng_crg
6575  real(RP) :: dep_dnr_crg
6576  real(RP) :: dep_dnc_crg
6577  !
6578  real(RP) :: fac1, fac2, fac3, fac4, fac5, fac6
6579  real(RP) :: r_rvaptem(KA) ! 1/(Rvap*tem)
6580  real(RP) :: pv ! vapor pressure
6581  real(RP) :: lvsw, lvsi ! saturated vapor density
6582  real(RP) :: dlvsw, dlvsi !
6583  ! [Add] 11/08/30 T.Mitsui
6584  real(RP) :: dcnd, ddep ! total cndensation/deposition
6585  real(RP) :: uplim_cnd ! upper limit of condensation
6586  real(RP) :: lowlim_cnd ! lower limit of evaporation
6587  ! [Add] 11/08/30 T.Mitsui
6588  real(RP) :: uplim_dep ! upper limit of condensation
6589  real(RP) :: lowlim_dep ! lower limit of evaporation
6590  real(RP) :: ssw, ssi ! supersaturation ratio
6591  real(RP) :: r_esw, r_esi ! 1/esw, 1/esi
6592  real(RP) :: r_lvsw, r_lvsi ! 1/(lvsw*ssw), 1/(lvsi*ssi)
6593  real(RP) :: r_dt ! 1/dt
6594  real(RP) :: ssw_o, ssi_o
6595 ! real(RP) :: dt_dyn
6596 ! real(RP) :: dt_mp
6597  !
6598 ! real(RP) :: tem_lh(KA,IA,JA)
6599 ! real(RP) :: dtemdt_lh(KA,IA,JA)
6600 
6601  real(RP) :: fac_cndc_wrk
6602  !
6603  real(RP), parameter :: tau100day = 1.e+7_rp
6604  real(RP), parameter :: r_tau100day = 1.e-7_rp
6605  real(RP), parameter :: eps=1.e-30_rp
6606  !
6607  real(RP) :: PLCdep(KA), PLRdep(KA), PNRdep(KA)
6608  real(RP) :: dz
6609  !
6610  integer :: k,iqw
6611  real(RP) :: sw, sw2
6612  real(RP) :: dqv, dql, dqi
6613  real(RP) :: dcv, dcp
6614  real(RP) :: dqc_crg, dqr_crg, dqi_crg, dqs_crg, dqg_crg
6615 
6616  !
6617  real(RP) :: fact
6618 
6619  !
6620 ! dt_dyn = dt*ntmax
6621  !
6622  r_dt = 1.0_rp/dt
6623  !
6624  r_xc_ccn=1.0_rp/xc_ccn
6625 ! r_xi_ccn=1.0_RP/xi_ccn
6626  !
6627  if( opt_fix_taucnd_c )then
6628  fac_cndc_wrk = fac_cndc**(1.0_rp-b_m(i_mp_qc))
6629  do k = ks, ke
6630  pq(k,i_lcdep) = pq(k,i_lcdep)*fac_cndc_wrk
6631  end do
6632  log_info("ATMOS_PHY_MP_SN14_update_by_phase_change",*) "taucnd:fac_cndc_wrk=",fac_cndc_wrk
6633  end if
6634 
6635 !OCL XFILL
6636  do k = ks, ke
6637  ! Temperature lower limit is only used for saturation condition.
6638  ! On the other hand original "tem" is used for calculation of latent heat or energy equation.
6639  wtem(k) = max( tem(k), tem_min )
6640  end do
6641 
6642  call moist_pres2qsat_liq( ka, ks, ke, &
6643  wtem(:), pre(:), qdry(:), & ! [IN]
6644  qsw(:) ) ! [OUT]
6645  call moist_pres2qsat_ice( ka, ks, ke, &
6646  wtem(:), pre(:), qdry(:), & ! [IN]
6647  qsi(:) ) ! [OUT]
6648  call moist_dqs_dtem_dens_liq( ka, ks, ke, &
6649  wtem(:), rho(:), & ! [IN]
6650  dqswdtem_rho(:) ) ! [OUT]
6651  call moist_dqs_dtem_dens_ice( ka, ks, ke, &
6652  wtem(:), rho(:), & ! [IN]
6653  dqsidtem_rho(:) ) ! [OUT]
6654  call moist_dqs_dtem_dpre_liq( ka, ks, ke, &
6655  wtem(:), pre(:), qdry(:), & ! [IN]
6656  dqswdtem_pre(:), dqswdpre_tem(:) ) ! [OUT]
6657  call moist_dqs_dtem_dpre_ice( ka, ks, ke, &
6658  wtem(:), pre(:), qdry(:), & ! [IN]
6659  dqsidtem_pre(:), dqsidpre_tem(:) ) ! [OUT]
6660 
6661  do k = ks, ke
6662  if( cz(k) <= 25000.0_rp )then
6663  w2(k) = w(k)
6664  else
6665  w2(k) = 0.0_rp
6666  end if
6667  if( pre(k) < esw(k)+1.e-10_rp )then
6668  qsw(k) = 1.0_rp
6669  dqswdtem_rho(k) = 0.0_rp
6670  dqswdtem_pre(k) = 0.0_rp
6671  dqswdpre_tem(k) = 0.0_rp
6672  end if
6673  if( pre(k) < esi(k)+1.e-10_rp )then
6674  qsi(k) = 1.0_rp
6675  dqsidtem_rho(k) = 0.0_rp
6676  dqsidtem_pre(k) = 0.0_rp
6677  dqsidpre_tem(k) = 0.0_rp
6678  end if
6679  end do
6680 
6681 !OCL LOOP_FISSION_TARGET(LS)
6682  do k = ks, ke
6683  r_rvaptem(k) = 1.0_rp/(rvap*wtem(k))
6684  lvsw = esw(k)*r_rvaptem(k) ! rho=p/(Rv*T)
6685  lvsi = esi(k)*r_rvaptem(k)
6686  pv = rhoq(k,i_qv)*rvap*tem(k)
6687  r_esw = 1.0_rp/esw(k)
6688  r_esi = 1.0_rp/esi(k)
6689  ssw = min( mp_ssw_lim, ( pv*r_esw-1.0_rp ) )
6690  ssi = pv*r_esi - 1.0_rp
6691  r_lvsw = 1.0_rp/lvsw
6692  r_lvsi = 1.0_rp/lvsi
6693  r_taucnd_c = pq(k,i_lcdep)*r_lvsw
6694  r_taucnd_r = pq(k,i_lrdep)*r_lvsw
6695  r_taudep_i = pq(k,i_lidep)*r_lvsi
6696  r_taudep_s = pq(k,i_lsdep)*r_lvsi
6697  r_taudep_g = pq(k,i_lgdep)*r_lvsi
6698 ! taucnd_c(k) = 1.0_RP/(r_taucnd_c+r_tau100day)
6699 ! taucnd_r(k) = 1.0_RP/(r_taucnd_r+r_tau100day)
6700 ! taudep_i(k) = 1.0_RP/(r_taudep_i+r_tau100day)
6701 ! taudep_s(k) = 1.0_RP/(r_taudep_s+r_tau100day)
6702 ! taudep_g(k) = 1.0_RP/(r_taudep_g+r_tau100day)
6703 
6704  r_cva = 1.0_rp / cva(k)
6705  r_cpa = 1.0_rp / cpa(k)
6706 
6707  ! Coefficient of latent heat release for ssw change by PLCdep and PLRdep
6708  aliqliq = 1.0_rp &
6709  + r_cva*( lhv00 + (cvvap-cl)*tem(k) )*dqswdtem_rho(k)
6710  ! Coefficient of latent heat release for ssw change by PLIdep, PLSdep and PLGdep
6711  asolliq = 1.0_rp &
6712  + r_cva*( lhv00 + lhf00 + (cvvap-ci)*tem(k) )*dqswdtem_rho(k)
6713  ! Coefficient of latent heat release for ssi change by PLCdep and PLRdep
6714  aliqsol = 1.0_rp &
6715  + r_cva*( lhv00 + (cvvap-cl)*tem(k) )*dqsidtem_rho(k)
6716  ! Coefficient of latent heat release for ssi change by PLIdep, PLSdep and PLGdep
6717  asolsol = 1.0_rp &
6718  + r_cva*( lhv00 + lhf00 + (cvvap-ci)*tem(k) )*dqsidtem_rho(k)
6719  pdynliq = w2(k) * grav * ( r_cpa*dqswdtem_pre(k) + rho(k)*dqswdpre_tem(k) )
6720  pdynsol = w2(k) * grav * ( r_cpa*dqsidtem_pre(k) + rho(k)*dqsidpre_tem(k) )
6721  pradliq = -dtdt_rad(k) * dqswdtem_rho(k)
6722  pradsol = -dtdt_rad(k) * dqsidtem_rho(k)
6723 
6724  ssw_o = ssw
6725  ssi_o = ssi
6726 ! ssw_o = ssw - Pdynliq*(dt_dyn-dt_mp)/qsw(k) + Pradliq*r_qsw*dt_mp
6727 ! ssi_o = ssi - Pdynsol*(dt_dyn-dt_mp)/qsi(k) + Pradsol*r_qsi*dt_mp
6728 
6729  r_taucnd = &
6730  + aliqliq*( r_taucnd_c+r_taucnd_r ) &
6731  + asolliq*( r_taudep_i+r_taudep_s+r_taudep_g )
6732  r_taudep = &
6733  + aliqsol*( r_taucnd_c+r_taucnd_r )&
6734  + asolsol*( r_taudep_i+r_taudep_s+r_taudep_g )
6735 
6736  if( r_taucnd < r_tau100day )then
6737  uplim_cnd = max( rho(k)*ssw_o*qsw(k)*r_dt, 0.0_rp )
6738  lowlim_cnd = min( rho(k)*ssw_o*qsw(k)*r_dt, 0.0_rp )
6739 ! taucnd = tau100day
6740  pq(k,i_lcdep) = max(lowlim_cnd, min(uplim_cnd, pq(k,i_lcdep)*ssw_o ))
6741  pq(k,i_lrdep) = max(lowlim_cnd, min(uplim_cnd, pq(k,i_lrdep)*ssw_o ))
6742  pq(k,i_nrdep) = min(0.0_rp, pq(k,i_nrdep)*ssw_o )
6743 ! PLR2NR = 0.0_RP
6744  else
6745  acnd = pdynliq + pradliq &
6746  - ( r_taudep_i+r_taudep_s+r_taudep_g ) * ( qsw(k) - qsi(k) )
6747  taucnd = 1.0_rp/r_taucnd
6748  ! Production term for liquid water content
6749  coef_a_cnd = rho(k)*acnd*taucnd
6750  coef_b_cnd = rho(k)*taucnd*r_dt*(ssw_o*qsw(k)-acnd*taucnd) * ( exp(-dt*r_taucnd) - 1.0_rp )
6751  pq(k,i_lcdep) = coef_a_cnd*r_taucnd_c - coef_b_cnd*r_taucnd_c
6752  plr2nr = pq(k,i_nrdep)/(pq(k,i_lrdep)+1.e-30_rp)
6753  pq(k,i_lrdep) = coef_a_cnd*r_taucnd_r - coef_b_cnd*r_taucnd_r
6754  pq(k,i_nrdep) = min(0.0_rp, pq(k,i_lrdep)*plr2nr )
6755  end if
6756 
6757  if( r_taudep < r_tau100day )then
6758  uplim_dep = max( rho(k)*ssi_o*qsi(k)*r_dt, 0.0_rp )
6759  lowlim_dep = min( rho(k)*ssi_o*qsi(k)*r_dt, 0.0_rp )
6760 ! taudep = tau100day
6761  pq(k,i_lidep) = max(lowlim_dep, min(uplim_dep, pq(k,i_lidep)*ssi_o ))
6762  pq(k,i_lsdep) = max(lowlim_dep, min(uplim_dep, pq(k,i_lsdep)*ssi_o ))
6763  pq(k,i_lgdep) = max(lowlim_dep, min(uplim_dep, pq(k,i_lgdep)*ssi_o ))
6764  pq(k,i_nidep) = min(0.0_rp, pq(k,i_nidep)*ssi_o )
6765  pq(k,i_nsdep) = min(0.0_rp, pq(k,i_nsdep)*ssi_o )
6766  pq(k,i_ngdep) = min(0.0_rp, pq(k,i_ngdep)*ssi_o )
6767  else
6768  adep = pdynsol + pradsol &
6769  + ( r_taucnd_c+r_taucnd_r ) * ( qsw(k) - qsi(k) )
6770  taudep = 1.0_rp/r_taudep
6771  ! Production term for ice water content
6772  coef_a_dep = rho(k)*adep*taudep
6773  coef_b_dep = rho(k)*taudep*r_dt*(ssi_o*qsi(k)-adep*taudep) * ( exp(-dt*r_taudep) - 1.0_rp )
6774  pli2ni = pq(k,i_nidep)/max(pq(k,i_lidep),1.e-30_rp)
6775  pls2ns = pq(k,i_nsdep)/max(pq(k,i_lsdep),1.e-30_rp)
6776  plg2ng = pq(k,i_ngdep)/max(pq(k,i_lgdep),1.e-30_rp)
6777  pq(k,i_lidep) = coef_a_dep*r_taudep_i - coef_b_dep*r_taudep_i
6778  pq(k,i_lsdep) = coef_a_dep*r_taudep_s - coef_b_dep*r_taudep_s
6779  pq(k,i_lgdep) = coef_a_dep*r_taudep_g - coef_b_dep*r_taudep_g
6780  pq(k,i_nidep) = min(0.0_rp, pq(k,i_lidep)*pli2ni )
6781  pq(k,i_nsdep) = min(0.0_rp, pq(k,i_lsdep)*pls2ns )
6782  pq(k,i_ngdep) = min(0.0_rp, pq(k,i_lgdep)*plg2ng )
6783  end if
6784 
6785  end do
6786 
6787  !--- evaporation/condensation
6788 !OCL LOOP_FISSION_TARGET(LS)
6789  do k = ks, ke
6790  sw = 0.5_rp - sign(0.5_rp, pq(k,i_lcdep)+eps) != 1 for PLCdep<=-eps
6791  pncdep = min(0.0_rp, ((rhoq(k,i_qc)+pq(k,i_lcdep)*dt)*r_xc_ccn - rhoq(k,i_nc))*r_dt ) * sw
6792 ! if( PQ(k,I_LCdep) < -eps )then
6793 ! PNCdep = min(0.0_RP, ((rhoq(k,I_QC)+PQ(k,I_LCdep)*dt)*r_xc_ccn - rhoq(k,I_NC))*r_dt )
6794 ! else
6795 ! PNCdep = 0.0_RP
6796 ! end if
6797 ! if( PQ(k,I_LIdep) < -eps )then
6798 ! PQ(k,I_NIdep) = min(0.0_RP, ((li(k)+PQ(k,I_LIdep)*dt)*r_xi_ccn - rhoq(k,I_NI))*r_dt )
6799 ! else
6800 ! PQ(k,I_NIdep) = 0.0_RP
6801 ! end if
6802 
6803  lvsw = esw(k)*r_rvaptem(k)
6804  dlvsw = rhoq(k,i_qv)-lvsw
6805  dcnd = dt*(pq(k,i_lcdep)+pq(k,i_lrdep))
6806 
6807  sw = ( sign(0.5_rp,dcnd) + sign(0.5_rp,dlvsw) ) &
6808  * ( 0.5_rp + sign(0.5_rp,abs(dcnd)-eps) ) ! to avoid zero division
6809  ! sw= 1: always supersaturated
6810  ! sw=-1: always unsaturated
6811  ! sw= 0: partially unsaturated during timestep
6812  fac1 = min(dlvsw*sw,dcnd*sw)*sw / (abs(sw)-1.0_rp+dcnd) & ! sw=1,-1
6813  + 1.0_rp - abs(sw) ! sw=0
6814  dep_dqc(k) = max( dt*pq(k,i_lcdep)*fac1, &
6815  -rhoq(k,i_qc) - 1e30_rp*(sw+1.0_rp) )*abs(sw) != -lc for sw=-1, -inf for sw=1
6816  dep_dqr(k) = max( dt*pq(k,i_lrdep)*fac1, &
6817  -rhoq(k,i_qr) - 1e30_rp*(sw+1.0_rp) )*abs(sw) != -lr for sw=-1, -inf for sw=1
6818 ! if ( (dcnd > eps) .AND. (dlvsw > eps) )then
6819 ! ! always supersaturated
6820 ! fac1 = min(dlvsw,dcnd)/dcnd
6821 ! dep_dqc(k) = dt*PQ(k,I_LCdep)*fac1
6822 ! dep_dqr(k) = dt*PQ(k,I_LRdep)*fac1
6823 ! else if( (dcnd < -eps) .AND. (dlvsw < -eps) )then
6824 ! ! always unsaturated
6825 ! fac1 = max( dlvsw,dcnd )/dcnd
6826 ! dep_dqc(k) = max( dt*PQ(k,I_LCdep)*fac1, -rhoq(k,I_QC) )
6827 ! dep_dqr(k) = max( dt*PQ(k,I_LRdep)*fac1, -rhoq(k,I_QR) )
6828 ! else
6829 ! ! partially unsaturated during timestep
6830 ! fac1 = 1.0_RP
6831 ! dep_dqc(k) = 0.0_RP
6832 ! dep_dqr(k) = 0.0_RP
6833 ! end if
6834 
6835  ! evaporation always lose number(always negative).
6836  dep_dnc(k) = max( dt*pncdep*fac1, -rhoq(k,i_nc) ) ! ss>0 dep=0, ss<0 dep<0 ! [Add] 11/08/30 T.Mitsui
6837  dep_dnr(k) = max( dt*pq(k,i_nrdep)*fac1, -rhoq(k,i_nr) ) ! ss>0 dep=0, ss<0 dep<0
6838 
6839  qc_evaporate(k) = - dep_dnc(k) ! [Add] Y.Sato 15/09/08
6840  end do
6841 
6842  !--- deposition/sublimation
6843 !OCL LOOP_FISSION_TARGET(LS)
6844  do k = ks, ke
6845  lvsi = esi(k)*r_rvaptem(k)
6846  ddep = dt*(pq(k,i_lidep)+pq(k,i_lsdep)+pq(k,i_lgdep))
6847  dlvsi = rhoq(k,i_qv)-lvsi ! limiter for esi>1.0_RP
6848 
6849  sw = ( sign(0.5_rp,ddep) + sign(0.5_rp,dlvsi) ) &
6850  * ( 0.5_rp + sign(0.5_rp,abs(ddep)-eps) ) ! to avoid zero division
6851  ! sw= 1: always supersaturated
6852  ! sw=-1: always unsaturated
6853  ! sw= 0: partially unsaturated during timestep
6854  fac2 = min(dlvsi*sw,ddep*sw)*sw / (abs(sw)-1.0_rp+ddep) & ! sw=1,-1
6855  + 1.0_rp - abs(sw) ! sw=0
6856  dep_dqi(k) = max( dt*pq(k,i_lidep) &
6857  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
6858  -rhoq(k,i_qi) - 1e30_rp*(sw+1.0_rp) ) != -li for sw=-1, -inf for sw=0,1
6859  dep_dqs(k) = max( dt*pq(k,i_lsdep) &
6860  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
6861  -rhoq(k,i_qs) - 1e30_rp*(sw+1.0_rp) ) != -ls for sw=-1, -inf for sw=0,1
6862  dep_dqg(k) = max( dt*pq(k,i_lgdep) &
6863  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
6864  -rhoq(k,i_qg) - 1e30_rp*(sw+1.0_rp) ) != -lg for sw=-1, -inf for sw=0,1
6865 ! if ( (ddep > eps) .AND. (dlvsi > eps) )then
6866 ! ! always supersaturated
6867 ! fac2 = min(dlvsi,ddep)/ddep
6868 ! dep_dqi(k) = dt*PQ(k,I_LIdep)*fac2
6869 ! dep_dqs(k) = dt*PQ(k,I_LSdep)*fac2
6870 ! dep_dqg(k) = dt*PQ(k,I_LGdep)*fac2
6871 ! else if ( (ddep < -eps) .AND. (dlvsi < -eps) )then
6872 ! ! always unsaturated
6873 ! fac2 = max(dlvsi,ddep)/ddep
6874 ! dep_dqi(k) = max(dt*PQ(k,I_LIdep)*fac2, -rhoq(k,I_QI) )
6875 ! dep_dqs(k) = max(dt*PQ(k,I_LSdep)*fac2, -rhoq(k,I_QS) )
6876 ! dep_dqg(k) = max(dt*PQ(k,I_LGdep)*fac2, -rhoq(k,I_QG) )
6877 ! else
6878 ! ! partially unsaturated during timestep
6879 ! fac2 = 1.0_RP
6880 ! dep_dqi(k) = dt*PQ(k,I_LIdep)
6881 ! dep_dqs(k) = dt*PQ(k,I_LSdep)
6882 ! dep_dqg(k) = dt*PQ(k,I_LGdep)
6883 ! end if
6884 
6885  ! evaporation always lose number(always negative).
6886  dep_dni(k) = max( dt*pq(k,i_nidep)*fac2, -rhoq(k,i_ni) ) ! ss>0 dep=0, ss<0 dep<0
6887  dep_dns(k) = max( dt*pq(k,i_nsdep)*fac2, -rhoq(k,i_ns) ) ! ss>0 dep=0, ss<0 dep<0
6888  dep_dng(k) = max( dt*pq(k,i_ngdep)*fac2, -rhoq(k,i_ng) ) ! ss>0 dep=0, ss<0 dep<0
6889  end do
6890 
6891  !--- freezing of cloud drop
6892 !OCL LOOP_FISSION_TARGET(LS)
6893  do k = ks, ke
6894  frz_dqc = max( dt*(pq(k,i_lchom)+pq(k,i_lchet)), -rhoq(k,i_qc)-dep_dqc(k) ) ! negative value
6895  frz_dnc(k) = max( dt*(pq(k,i_nchom)+pq(k,i_nchet)), -rhoq(k,i_nc)-dep_dnc(k) ) ! negative value
6896 
6897  drhoqc(k) = frz_dqc
6898  drhonc(k) = frz_dnc(k)
6899  drhoqi(k) = - frz_dqc
6900  drhoni(k) = - frz_dnc(k)
6901 
6902  fac3 = ( frz_dqc -eps )/( dt*(pq(k,i_lchom)+pq(k,i_lchet))-eps )
6903  fac4 = ( frz_dnc(k)-eps )/( dt*(pq(k,i_nchom)+pq(k,i_nchet))-eps )
6904  pq(k,i_lchom) = fac3*pq(k,i_lchom)
6905  pq(k,i_lchet) = fac3*pq(k,i_lchet)
6906  pq(k,i_nchom) = fac4*pq(k,i_nchom)
6907  pq(k,i_nchet) = fac4*pq(k,i_nchet)
6908  end do
6909 
6910  !--- melting
6911 !OCL LOOP_FISSION_TARGET(LS)
6912  do k = ks, ke
6913  ! ice change
6914  mlt_dqi = max( dt*pq(k,i_limlt), -rhoq(k,i_qi)-dep_dqi(k) ) ! negative value
6915  mlt_dni(k) = max( dt*pq(k,i_nimlt), -rhoq(k,i_ni)-dep_dni(k) ) ! negative value
6916 
6917  ! snow change
6918  mlt_dqs = max( dt*pq(k,i_lsmlt), -rhoq(k,i_qs)-dep_dqs(k) ) ! negative value
6919  mlt_dns(k) = max( dt*pq(k,i_nsmlt), -rhoq(k,i_ns)-dep_dns(k) ) ! negative value
6920 
6921  ! graupel change
6922  mlt_dqg = max( dt*pq(k,i_lgmlt), -rhoq(k,i_qg)-dep_dqg(k) ) ! negative value
6923  mlt_dng(k) = max( dt*pq(k,i_ngmlt), -rhoq(k,i_ng)-dep_dng(k) ) ! negative value
6924 
6925  xi = min(xi_max, max(xi_min, rhoq(k,i_qi)/(rhoq(k,i_ni)+ni_min) ))
6926  sw = 0.5_rp + sign(0.5_rp,xi-x_sep) ! if (xi>=x_sep) then sw=1 else sw=0
6927  ! sw=1: large ice crystals turn into rain by melting
6928 
6929  drhoqc(k) = drhoqc(k) - mlt_dqi * (1.0_rp-sw)
6930  drhonc(k) = drhonc(k) - mlt_dni(k) * (1.0_rp-sw)
6931 
6932  drhoqr(k) = - mlt_dqi * sw - mlt_dqs - mlt_dqg
6933  drhonr(k) = - mlt_dni(k) * sw - mlt_dns(k) - mlt_dng(k)
6934 
6935  drhoqi(k) = drhoqi(k) + mlt_dqi
6936  drhoni(k) = drhoni(k) + mlt_dni(k)
6937 
6938  drhoqs(k) = mlt_dqs
6939  drhons(k) = mlt_dns(k)
6940 
6941  drhoqg(k) = mlt_dqg
6942  drhong(k) = mlt_dng(k)
6943  end do
6944 
6945  !--- freezing of larger droplets
6946 !OCL LOOP_FISSION_TARGET(LS)
6947  do k = ks, ke
6948  frz_dqr = max( dt*(pq(k,i_lrhet)), min(0.0_rp, -rhoq(k,i_qr)-dep_dqr(k)) ) ! negative value
6949  frz_dnr(k) = max( dt*(pq(k,i_nrhet)), min(0.0_rp, -rhoq(k,i_nr)-dep_dnr(k)) ) ! negative value
6950 
6951  drhoqr(k) = drhoqr(k) + frz_dqr
6952  drhonr(k) = drhonr(k) + frz_dnr(k)
6953  drhoqg(k) = drhoqg(k) - frz_dqr
6954  drhong(k) = drhong(k) - frz_dnr(k)
6955 
6956  fac5 = ( frz_dqr -eps )/( dt*pq(k,i_lrhet)-eps )
6957  pq(k,i_lrhet) = fac5*pq(k,i_lrhet)
6958  fac6 = ( frz_dnr(k)-eps )/( dt*pq(k,i_nrhet)-eps )
6959  pq(k,i_nrhet) = fac6*pq(k,i_nrhet)
6960  end do
6961 
6962  ! water vapor change
6963 !OCL LOOP_FISSION_TARGET(LS)
6964  do k = ks, ke
6965  dep_qv = - ( dep_dqc(k) + dep_dqr(k) + dep_dqi(k) + dep_dqs(k) + dep_dqg(k) )
6966 
6967  ! limiter
6968  sw = 0.5_rp - sign(0.5_rp, abs(dep_qv) - eps) ! if |dep_qv| < eps then sw = 1
6969  fact = ( max( rhoq(k,i_qv) + dep_qv * dt, 0.0_rp ) - rhoq(k,i_qv) ) / dt / ( dep_qv + sw ) * ( 1.0_rp - sw ) &
6970  + 1.0_rp * sw
6971  fact = min( 1.0_rp, max( 0.0_rp, fact ) )
6972 
6973  dep_qv = dep_qv * fact
6974 
6975  dep_dqc(k) = dep_dqc(k) * fact
6976  dep_dnc(k) = dep_dnc(k) * fact
6977  dep_dqr(k) = dep_dqr(k) * fact
6978  dep_dnr(k) = dep_dnr(k) * fact
6979  dep_dqi(k) = dep_dqi(k) * fact
6980  dep_dni(k) = dep_dni(k) * fact
6981  dep_dqs(k) = dep_dqs(k) * fact
6982  dep_dns(k) = dep_dns(k) * fact
6983  dep_dqg(k) = dep_dqg(k) * fact
6984  dep_dng(k) = dep_dng(k) * fact
6985 
6986  drhoqv(k) = dep_qv
6987 
6988  drhoqc(k) = drhoqc(k) + dep_dqc(k)
6989  drhonc(k) = drhonc(k) + dep_dnc(k)
6990  drhoqr(k) = drhoqr(k) + dep_dqr(k)
6991  drhonr(k) = drhonr(k) + dep_dnr(k)
6992  drhoqi(k) = drhoqi(k) + dep_dqi(k)
6993  drhoni(k) = drhoni(k) + dep_dni(k)
6994  drhoqs(k) = drhoqs(k) + dep_dqs(k)
6995  drhons(k) = drhons(k) + dep_dns(k)
6996  drhoqg(k) = drhoqg(k) + dep_dqg(k)
6997  drhong(k) = drhong(k) + dep_dng(k)
6998 
6999  dz = fz(k) - fz(k-1)
7000  sl_plcdep = sl_plcdep + dep_dqc(k) * dz
7001  sl_plrdep = sl_plrdep + dep_dqr(k) * dz
7002  sl_pnrdep = sl_pnrdep + dep_dnr(k) * dz
7003  end do
7004 
7005  ! tendency
7006 !OCL LOOP_FISSION_TARGET(LS)
7007  do k = ks, ke
7008  rhoq_t(k,i_qv) = drhoqv(k) / dt
7009  rhoq_t(k,i_qc) = drhoqc(k) / dt
7010  rhoq_t(k,i_nc) = drhonc(k) / dt
7011  rhoq_t(k,i_qr) = drhoqr(k) / dt
7012  rhoq_t(k,i_nr) = drhonr(k) / dt
7013  rhoq_t(k,i_qi) = drhoqi(k) / dt
7014  rhoq_t(k,i_ni) = drhoni(k) / dt
7015  rhoq_t(k,i_qs) = drhoqs(k) / dt
7016  rhoq_t(k,i_ns) = drhons(k) / dt
7017  rhoq_t(k,i_qg) = drhoqg(k) / dt
7018  rhoq_t(k,i_ng) = drhong(k) / dt
7019 
7020  rhoe_t(k) = ( - lhv * drhoqv(k) + lhf * ( drhoqi(k) + drhoqs(k) + drhoqg(k) ) ) / dt
7021 
7022  rrho = 1.0_rp/rho(k)
7023  dqv = rrho * drhoqv(k)
7024  dql = rrho * ( drhoqc(k) + drhoqr(k) )
7025  dqi = rrho * ( drhoqi(k) + drhoqs(k) + drhoqg(k) )
7026 
7027  dcv = cv_vapor * dqv + cv_water * dql + cv_ice * dqi
7028  dcp = cp_vapor * dqv + cp_water * dql + cp_ice * dqi
7029 
7030  cvtot_t(k) = dcv/dt
7031  cptot_t(k) = dcp/dt
7032  end do
7033 
7034  !--- for Charge density
7035  if ( flg_lt ) then
7036 
7037  !--- reduce charge density of cloud and rain by evaporation
7038  do k = ks, ke
7039  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small ) !--- if NC is small, ignore charge transfer
7040  dep_dnc_crg = dep_dnc(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_nc)+sw ) * rhoq_crg(k,i_qc)
7041  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small ) !--- if NR is small, ignore charge transfer
7042  dep_dnr_crg = dep_dnr(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_nr)+sw ) * rhoq_crg(k,i_qr)
7043  !--- limiter
7044  sw = min( abs(rhoq_crg(k,i_qc)), abs(dep_dnc_crg) )
7045  dep_dnc_crg = sign( sw, dep_dnc_crg )
7046  sw = min( abs(rhoq_crg(k,i_qr)), abs(dep_dnr_crg) )
7047  dep_dnr_crg = sign( sw, dep_dnr_crg )
7048 
7049  drhoqcrg_c(k) = dep_dnc_crg
7050  drhoqcrg_r(k) = dep_dnr_crg
7051  end do
7052 
7053  do k = ks, ke
7054  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer
7055  dep_dni_crg = dep_dni(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_ni)+sw ) * rhoq_crg(k,i_qi)
7056  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer
7057  dep_dns_crg = dep_dns(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_ns)+sw ) * rhoq_crg(k,i_qs)
7058  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NG is small, ignore charge transfer
7059  dep_dng_crg = dep_dng(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_ng)+sw ) * rhoq_crg(k,i_qg)
7060  !--- limiter
7061  sw = min( abs(rhoq_crg(k,i_qi)), abs(dep_dni_crg) )
7062  dep_dni_crg = sign( sw, dep_dni_crg )
7063  sw = min( abs(rhoq_crg(k,i_qs)), abs(dep_dns_crg) )
7064  dep_dns_crg = sign( sw, dep_dns_crg )
7065  sw = min( abs(rhoq_crg(k,i_qg)), abs(dep_dng_crg) )
7066  dep_dng_crg = sign( sw, dep_dng_crg )
7067 
7068  drhoqcrg_i(k) = dep_dni_crg
7069  drhoqcrg_s(k) = dep_dns_crg
7070  drhoqcrg_g(k) = dep_dng_crg
7071  end do
7072 
7073  do k = ks, ke
7074  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nc)-small ) !--- if NC is small, ignore charge transfer
7075  frz_dnc_crg = frz_dnc(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_nc)+sw ) * rhoq_crg(k,i_qc)
7076  !--- limiter
7077  sw = min( abs(rhoq_crg(k,i_qc) + drhoqcrg_c(k)), abs(frz_dnc_crg) )
7078  frz_dnc_crg = sign( sw, frz_dnc_crg )
7079 
7080  drhoqcrg_c(k) = drhoqcrg_c(k) + frz_dnc_crg
7081  drhoqcrg_i(k) = drhoqcrg_i(k) - frz_dnc_crg
7082  end do
7083 
7084  do k = ks, ke
7085  xi = min(xi_max, max(xi_min, rhoq(k,i_qi)/(rhoq(k,i_ni)+ni_min) ))
7086  sw = 0.5_rp + sign(0.5_rp,xi-x_sep) ! if (xi>=x_sep) then sw=1 else sw=0
7087  ! sw=1: large ice crystals turn into rain by melting
7088  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ni)-small ) !--- if NI is small, ignore charge transfer ! I -> C
7089  mlt_dni_crg = mlt_dni(k) * ( 1.0_rp-sw2 ) / ( rhoq(k,i_ni)+sw2 ) * rhoq_crg(k,i_qi)
7090  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ns)-small ) !--- if NS is small, ignore charge transfer ! S -> C
7091  mlt_dns_crg = mlt_dns(k) * ( 1.0_rp-sw2 ) / ( rhoq(k,i_ns)+sw2 ) * rhoq_crg(k,i_qs)
7092  sw2 = 0.5_rp - sign( 0.5_rp, rhoq(k,i_ng)-small ) !--- if NG is small, ignore charge transfer ! G -> C
7093  mlt_dng_crg = mlt_dng(k) * ( 1.0_rp-sw2 ) / ( rhoq(k,i_ng)+sw2 ) * rhoq_crg(k,i_qg)
7094  !--- limiter (|rhoq(NC)| is already reduced by deposition (dep_dni_crg and -frz_dnc_crg) )
7095  !-- Charge abs(frz_dnc_crg) is already moved from cloud to ice
7096  sw2 = min( abs(rhoq_crg(k,i_qi) + drhoqcrg_i(k)), abs(mlt_dni_crg) )
7097  mlt_dni_crg = sign( sw2, mlt_dni_crg )
7098  sw2 = min( abs(rhoq_crg(k,i_qs) + drhoqcrg_s(k)), abs(mlt_dns_crg) )
7099  mlt_dns_crg = sign( sw2, mlt_dns_crg )
7100  sw2 = min( abs(rhoq_crg(k,i_qg) + drhoqcrg_g(k)), abs(mlt_dng_crg) )
7101  mlt_dng_crg = sign( sw2, mlt_dng_crg )
7102 
7103  drhoqcrg_c(k) = drhoqcrg_c(k) - mlt_dni_crg * (1.0_rp-sw)
7104  drhoqcrg_r(k) = drhoqcrg_r(k) - mlt_dni_crg * sw - mlt_dns_crg - mlt_dng_crg
7105  drhoqcrg_i(k) = drhoqcrg_i(k) + mlt_dni_crg
7106  drhoqcrg_s(k) = drhoqcrg_s(k) + mlt_dns_crg
7107  drhoqcrg_g(k) = drhoqcrg_g(k) + mlt_dng_crg
7108  end do
7109 
7110  do k = ks, ke
7111  sw = 0.5_rp - sign( 0.5_rp, rhoq(k,i_nr)-small ) !--- if NR is small, ignore charge transfer
7112  frz_dnr_crg = frz_dnr(k) * ( 1.0_rp-sw ) / ( rhoq(k,i_nr)+sw ) * rhoq_crg(k,i_qr)
7113  !--- limiter
7114  sw = min( abs(rhoq_crg(k,i_qr) + drhoqcrg_r(k)), abs(frz_dnr_crg) )
7115  frz_dnr_crg = sign( sw, frz_dnr_crg )
7116 
7117  drhoqcrg_r(k) = drhoqcrg_r(k) + frz_dnr_crg
7118  drhoqcrg_g(k) = drhoqcrg_g(k) - frz_dnr_crg
7119  end do
7120 
7121  ! tendency of charge density
7122  do k = ks, ke
7123  rhoqcrg_t(k,i_qc) = drhoqcrg_c(k) / dt
7124  rhoqcrg_t(k,i_qr) = drhoqcrg_r(k) / dt
7125  rhoqcrg_t(k,i_qi) = drhoqcrg_i(k) / dt
7126  rhoqcrg_t(k,i_qs) = drhoqcrg_s(k) / dt
7127  rhoqcrg_t(k,i_qg) = drhoqcrg_g(k) / dt
7128  end do
7129 
7130  end if
7131 
7132  return
7133  end subroutine update_by_phase_change
7134  !-----------------------------------------------------------------------------
7136 !OCL SERIAL
7137  subroutine cross_section( &
7138  KA, KS, KE, &
7139  QA_MP, &
7140  QTRC0, &
7141  DENS0, &
7142  Crs )
7143  implicit none
7144 
7145  integer, intent(in) :: KA, KS, KE
7146  integer, intent(in) :: QA_MP
7147  real(RP), intent(in) :: QTRC0(KA,QA_MP) ! tracer mass concentration [kg/kg]
7148  real(RP), intent(in) :: DENS0(KA) ! density [kg/m3]
7149  real(RP), intent(out) :: Crs(KA,HYDRO_MAX)! Cross section [cm]
7150 
7151  ! mass concentration[kg/m3] and mean particle mass[kg]
7152  real(RP) :: xc(KA)
7153  real(RP) :: xr(KA)
7154  real(RP) :: xi(KA)
7155  real(RP) :: xs(KA)
7156  real(RP) :: xg(KA)
7157  ! radius of average mass
7158  real(RP) :: rc, rr
7159 
7160  real(RP) :: coef_Fuetal1998
7161  ! r2m_min is minimum value(moment of 1 particle with 1 micron)
7162  real(RP), parameter :: r2m_min=1.e-12_rp
7163  real(RP), parameter :: um2cm = 100.0_rp
7164 
7165  real(RP) :: limitsw, zerosw
7166  integer :: k
7167  !---------------------------------------------------------------------------
7168 
7169  ! mean particle mass[kg]
7170  do k = ks, ke
7171  xc(k) = min( xc_max, max( xc_min, dens0(k)*qtrc0(k,i_qc)/(qtrc0(k,i_nc)+nc_min) ) )
7172  xr(k) = min( xr_max, max( xr_min, dens0(k)*qtrc0(k,i_qr)/(qtrc0(k,i_nr)+nr_min) ) )
7173  xi(k) = min( xi_max, max( xi_min, dens0(k)*qtrc0(k,i_qi)/(qtrc0(k,i_ni)+ni_min) ) )
7174  xs(k) = min( xs_max, max( xs_min, dens0(k)*qtrc0(k,i_qs)/(qtrc0(k,i_ns)+ns_min) ) )
7175  xg(k) = min( xg_max, max( xg_min, dens0(k)*qtrc0(k,i_qg)/(qtrc0(k,i_ng)+ng_min) ) )
7176  enddo
7177 
7178 
7179  do k = ks, ke
7180  crs(k,i_mp_qc) = pi * coef_r2(i_mp_qc) * qtrc0(k,i_nc) * a_rea2(i_mp_qc) * xc(k)**b_rea2(i_mp_qc)
7181  enddo
7182 
7183  do k = ks, ke
7184  crs(k,i_mp_qr) = pi * coef_r2(i_mp_qr) * qtrc0(k,i_nr) * a_rea2(i_mp_qr) * xr(k)**b_rea2(i_mp_qr)
7185  enddo
7186 
7187  do k = ks, ke
7188  crs(k,i_mp_qi) = pi * coef_rea2(i_mp_qi) * qtrc0(k,i_ni) * a_rea2(i_mp_qi) * xi(k)**b_rea2(i_mp_qi)
7189  crs(k,i_mp_qs) = pi * coef_rea2(i_mp_qs) * qtrc0(k,i_ns) * a_rea2(i_mp_qs) * xs(k)**b_rea2(i_mp_qs)
7190  crs(k,i_mp_qg) = pi * coef_rea2(i_mp_qg) * qtrc0(k,i_ng) * a_rea2(i_mp_qg) * xg(k)**b_rea2(i_mp_qg)
7191  enddo
7192 
7193  return
7194  end subroutine cross_section
7195 
7196 !OCL SERIAL
7197  subroutine get_terminal_velocity( &
7198  KA, KS, KE, &
7199  vt_xa, xq, &
7200  rhoq, &
7201  log_rho_fac_q )
7202  implicit none
7203  integer, intent(in) :: KA, KS, KE
7204  real(RP), intent(out) :: vt_xa (KA,HYDRO_MAX,2) ! terminal velocity of average mass
7205  real(RP), intent(out) :: xq (KA,HYDRO_MAX) ! Mass of mean particle [kg] SB06(94)
7206  real(RP), intent(in) :: rhoq (KA,I_QV:I_NG)
7207  real(RP), intent(in) :: log_rho_fac_q(KA,HYDRO_MAX)
7208 
7209  real(RP) :: log_xq
7210  integer :: k
7211 
7212 !OCL LOOP_FISSION_TARGET(LS)
7213  do k = ks, ke
7214 
7215  xq(k,i_mp_qc) = min(xc_max, max(xc_min, rhoq(k,i_qc)/(rhoq(k,i_nc)+nc_min) ))
7216 
7217  log_xq = log(xq(k,i_mp_qc))
7218  vt_xa(k,i_mp_qc,1) = exp( log_alpha_v(i_mp_qc,1) + log_xq * beta_v(i_mp_qc,1) + log_rho_fac_q(k,i_mp_qc) )
7219  vt_xa(k,i_mp_qc,2) = exp( log_alpha_v(i_mp_qc,2) + log_xq * beta_v(i_mp_qc,2) + log_rho_fac_q(k,i_mp_qc) )
7220 
7221  xq(k,i_mp_qr) = min(xr_max, max(xr_min, rhoq(k,i_qr)/(rhoq(k,i_nr)+nr_min) ))
7222  log_xq = log(xq(k,i_mp_qr))
7223  vt_xa(k,i_mp_qr,1) = exp( log_alpha_v(i_mp_qr,1) + log_xq * beta_v(i_mp_qr,1) + log_rho_fac_q(k,i_mp_qr) )
7224  vt_xa(k,i_mp_qr,2) = vt_xa(k,i_mp_qr,1)
7225 
7226  xq(k,i_mp_qi) = min(xi_max, max(xi_min, rhoq(k,i_qi)/(rhoq(k,i_ni)+ni_min) ))
7227  log_xq = log(xq(k,i_mp_qi))
7228  vt_xa(k,i_mp_qi,1) = exp( log_alpha_v(i_mp_qi,1) + log_xq * beta_v(i_mp_qi,1) + log_rho_fac_q(k,i_mp_qi) )
7229  vt_xa(k,i_mp_qi,2) = exp( log_alpha_v(i_mp_qi,2) + log_xq * beta_v(i_mp_qi,2) + log_rho_fac_q(k,i_mp_qi) )
7230 
7231  xq(k,i_mp_qs) = min(xs_max, max(xs_min, rhoq(k,i_qs)/(rhoq(k,i_ns)+ns_min) ))
7232  log_xq = log(xq(k,i_mp_qs))
7233  vt_xa(k,i_mp_qs,1) = exp( log_alpha_v(i_mp_qs,1) + log_xq * beta_v(i_mp_qs,1) + log_rho_fac_q(k,i_mp_qs) )
7234  vt_xa(k,i_mp_qs,2) = exp( log_alpha_v(i_mp_qs,2) + log_xq * beta_v(i_mp_qs,2) + log_rho_fac_q(k,i_mp_qs) )
7235 
7236  xq(k,i_mp_qg) = min(xg_max, max(xg_min, rhoq(k,i_qg)/(rhoq(k,i_ng)+ng_min) ))
7237  log_xq = log(xq(k,i_mp_qg))
7238  vt_xa(k,i_mp_qg,1) = exp( log_alpha_v(i_mp_qg,1) + log_xq * beta_v(i_mp_qg,1) + log_rho_fac_q(k,i_mp_qg) )
7239  vt_xa(k,i_mp_qg,2) = exp( log_alpha_v(i_mp_qg,2) + log_xq * beta_v(i_mp_qg,2) + log_rho_fac_q(k,i_mp_qg) )
7240  end do
7241 
7242  return
7243  end subroutine get_terminal_velocity
7244 
7245 !OCL SERIAL
7246  subroutine get_diamiter( &
7247  KA, KS, KE, &
7248  dq_xa, &
7249  xq )
7250  implicit none
7251  integer, intent(in) :: KA, KS, KE
7252  real(RP), intent(out) :: dq_xa(KA,HYDRO_MAX)
7253  real(RP), intent(in) :: xq (KA,HYDRO_MAX)
7254  integer :: k
7255 
7256  ! diamter of average mass
7257  ! SB06(32)
7258 !OCL LOOP_FISSION_TARGET(LS)
7259  do k = ks, ke
7260  dq_xa(k,i_mp_qc) = a_m(i_mp_qc)*xq(k,i_mp_qc)**b_m(i_mp_qc)
7261  dq_xa(k,i_mp_qr) = a_m(i_mp_qr)*xq(k,i_mp_qr)**b_m(i_mp_qr)
7262  dq_xa(k,i_mp_qi) = a_m(i_mp_qi)*xq(k,i_mp_qi)**b_m(i_mp_qi)
7263  dq_xa(k,i_mp_qs) = a_m(i_mp_qs)*xq(k,i_mp_qs)**b_m(i_mp_qs)
7264  dq_xa(k,i_mp_qg) = a_m(i_mp_qg)*xq(k,i_mp_qg)**b_m(i_mp_qg)
7265  end do
7266 
7267  return
7268  end subroutine get_diamiter
7269 
7270 end module scale_atmos_phy_mp_sn14
scale_const::const_grav
real(rp), public const_grav
standard acceleration of gravity [m/s2]
Definition: scale_const.F90:49
scale_const::const_lhv0
real(rp), parameter, public const_lhv0
latent heat of vaporizaion at 0C [J/kg]
Definition: scale_const.F90:82
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_atmos_hydrometeor::i_hr
integer, parameter, public i_hr
liquid water rain
Definition: scale_atmos_hydrometeor.F90:98
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_tracer_names
character(len=h_short), dimension(qa_mp), parameter, public atmos_phy_mp_sn14_tracer_names
Definition: scale_atmos_phy_mp_sn14.F90:115
scale_atmos_hydrometeor::cp_water
real(rp), public cp_water
CP for water [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:152
scale_atmos_hydrometeor::i_hs
integer, parameter, public i_hs
snow
Definition: scale_atmos_hydrometeor.F90:100
scale_const::const_lhs00
real(rp), public const_lhs00
latent heat of sublimation at 0K [J/kg]
Definition: scale_const.F90:85
scale_const::const_epsvap
real(rp), public const_epsvap
Rdry / Rvap.
Definition: scale_const.F90:75
scale_const::const_lhv00
real(rp), public const_lhv00
latent heat of vaporizaion at 0K [J/kg]
Definition: scale_const.F90:83
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_ntracers
integer, parameter, public atmos_phy_mp_sn14_ntracers
Definition: scale_atmos_phy_mp_sn14.F90:112
scale_const::const_undef8
real(dp), parameter, public const_undef8
undefined value (REAL8)
Definition: scale_const.F90:42
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_atmos_phy_mp_sn14::debug_tem
subroutine debug_tem(KA, KS, KE, point, i, j, tem, rho, pre, qv)
Definition: scale_atmos_phy_mp_sn14.F90:3479
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_qhyd2qtrc
subroutine, public atmos_phy_mp_sn14_qhyd2qtrc(KA, KS, KE, IA, IS, IE, JA, JS, JE, Qe, QTRC, QNUM)
Definition: scale_atmos_phy_mp_sn14.F90:1132
scale_const::const_rvap
real(rp), parameter, public const_rvap
specific gas constant (water vapor) [J/kg/K]
Definition: scale_const.F90:68
scale_const::const_emelt
real(rp), parameter, public const_emelt
Definition: scale_const.F90:79
scale_const::const_eps
real(rp), public const_eps
small number
Definition: scale_const.F90:35
scale_atmos_hydrometeor
module atmosphere / hydrometeor
Definition: scale_atmos_hydrometeor.F90:12
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_atmos_hydrometeor::i_hh
integer, parameter, public i_hh
hail
Definition: scale_atmos_hydrometeor.F90:102
scale_file_history
module file_history
Definition: scale_file_history.F90:15
scale_atmos_phy_mp_sn14
module ATMOSPHERE / Physics Cloud Microphysics
Definition: scale_atmos_phy_mp_sn14.F90:51
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_tracer_descriptions
character(len=h_mid), dimension(qa_mp), parameter, public atmos_phy_mp_sn14_tracer_descriptions
Definition: scale_atmos_phy_mp_sn14.F90:127
scale_const::const_cpvap
real(rp), parameter, public const_cpvap
specific heat (water vapor, constant pressure) [J/kg/K]
Definition: scale_const.F90:69
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_atmos_hydrometeor::cv_vapor
real(rp), public cv_vapor
CV for vapor [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:149
scale_atmos_hydrometeor::i_hi
integer, parameter, public i_hi
ice water cloud
Definition: scale_atmos_hydrometeor.F90:99
scale_atmos_phy_mp_sn14::qa_mp
integer, parameter, public qa_mp
Definition: scale_atmos_phy_mp_sn14.F90:110
scale_io
module STDIO
Definition: scale_io.F90:10
scale_atmos_phy_mp_sn14::ice_multiplication
subroutine ice_multiplication(KA, KS, KE, flg_lt, Pac, tem, rhoq, rhoq_crg, xq, PQ, Pcrg1)
Definition: scale_atmos_phy_mp_sn14.F90:4134
scale_const::const_pstd
real(rp), public const_pstd
standard pressure [Pa]
Definition: scale_const.F90:96
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_qtrc2nhyd
subroutine, public atmos_phy_mp_sn14_qtrc2nhyd(KA, KS, KE, IA, IS, IE, JA, JS, JE, QTRC0, Ne)
Calculate number concentration of each category.
Definition: scale_atmos_phy_mp_sn14.F90:1089
scale_const::const_cvdry
real(rp), public const_cvdry
specific heat (dry air,constant volume) [J/kg/K]
Definition: scale_const.F90:61
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_terminal_velocity
subroutine, public atmos_phy_mp_sn14_terminal_velocity(KA, KS, KE, DENS, TEMP, RHOQ, PRES, vterm)
ATMOS_PHY_MP_sn14_terminal_velocity Calculate terminal velocity.
Definition: scale_atmos_phy_mp_sn14.F90:1364
scale_const::const_cpdry
real(rp), public const_cpdry
specific heat (dry air,constant pressure) [J/kg/K]
Definition: scale_const.F90:60
scale_atmos_phy_mp_sn14::nucleation_ice_hom
subroutine nucleation_ice_hom(KA, KS, KE, tem, pre, rho, qd, rhoq_qv, cva, cpa, w, dTdt_rad, dTdt_dep, PLIdep, dt, PLIhom, PNIhom)
Definition: scale_atmos_phy_mp_sn14.F90:3944
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_finalize
subroutine, public atmos_phy_mp_sn14_finalize
finalize
Definition: scale_atmos_phy_mp_sn14.F90:773
scale_atmos_phy_mp_sn14::nucleation
subroutine nucleation(KA, KS, KE, cz, fz, w, rho, tem, pre, qdry, rhoq, cpa, cva, dTdt_rad, qke, CCN, nc_uplim_d, dt, dq_xa, vt_xa, PQ)
Definition: scale_atmos_phy_mp_sn14.F90:3519
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_specfunc
module SPECFUNC
Definition: scale_specfunc.F90:14
scale_const::const_psat0
real(rp), parameter, public const_psat0
saturate pressure of water vapor at 0C [Pa]
Definition: scale_const.F90:88
scale_atmos_phy_mp_sn14::mixed_phase_collection_bin
subroutine mixed_phase_collection_bin(KA, KS, KE, flg_lt, d0_crg, v0_crg, beta_crg, dqcrg, wtem, rhoq, rhoq_crg, xq, dq_xave, vt_xave, rho, PQ, Pcrg1, Pcrg2, Pac)
Definition: scale_atmos_phy_mp_sn14.F90:4909
scale_const::const_pi
real(rp), parameter, public const_pi
pi
Definition: scale_const.F90:32
scale_atmos_hydrometeor::i_hc
integer, parameter, public i_hc
liquid water cloud
Definition: scale_atmos_hydrometeor.F90:97
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_effective_radius
subroutine, public atmos_phy_mp_sn14_effective_radius(KA, KS, KE, IA, IS, IE, JA, JS, JE, DENS0, TEMP0, QTRC0, Re)
ATMOS_PHY_MP_sn14_effective_radius Calculate Effective Radius.
Definition: scale_atmos_phy_mp_sn14.F90:917
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_tendency
subroutine, public atmos_phy_mp_sn14_tendency(KA, KS, KE, IA, IS, IE, JA, JS, JE, DENS, W, QTRC, PRES, TEMP, Qdry, CPtot, CVtot, CCN, dt, cz, fz, RHOQ_t, RHOE_t, CPtot_t, CVtot_t, EVAPORATE, flg_lt, d0_crg, v0_crg, dqcrg, beta_crg, QTRC_crg, QSPLT_in, Sarea, RHOQcrg_t)
ATMOS_PHY_MP_sn14_tendency calculate tendency.
Definition: scale_atmos_phy_mp_sn14.F90:809
scale_atmos_phy_mp_sn14::aut_acc_slc_brk
subroutine aut_acc_slc_brk(KA, KS, KE, flg_lt, rhoq, rhoq_crg, xq, dq_xave, rho, PQ, Pcrg)
Definition: scale_atmos_phy_mp_sn14.F90:5805
scale_const::const_ci
real(rp), parameter, public const_ci
specific heat (ice) [J/kg/K]
Definition: scale_const.F90:72
scale_const::const_dwatr
real(rp), parameter, public const_dwatr
density of water [kg/m3]
Definition: scale_const.F90:89
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_qtrc2qhyd
subroutine, public atmos_phy_mp_sn14_qtrc2qhyd(KA, KS, KE, IA, IS, IE, JA, JS, JE, QTRC0, Qe)
ATMOS_PHY_MP_sn14_qtrc2qhyd Calculate mass ratio of each category.
Definition: scale_atmos_phy_mp_sn14.F90:1046
scale_const::const_tem00
real(rp), parameter, public const_tem00
temperature reference (0C) [K]
Definition: scale_const.F90:99
scale_atmos_phy_mp_sn14::dep_vapor_ice_wrk
subroutine dep_vapor_ice_wrk(KA, KS, KE, PLIdep_total, rho, tem, pre, qd, esi, qsi, rhoq, vt_xave, dq_xave, dt)
Definition: scale_atmos_phy_mp_sn14.F90:6159
scale_const::const_cl
real(rp), parameter, public const_cl
specific heat (liquid water) [J/kg/K]
Definition: scale_const.F90:71
scale_const::const_cvvap
real(rp), public const_cvvap
specific heat (water vapor, constant volume) [J/kg/K]
Definition: scale_const.F90:70
scale_atmos_phy_mp_sn14::freezing_water
subroutine freezing_water(KA, KS, KE, dt, rhoq, xq, tem, PQ)
Definition: scale_atmos_phy_mp_sn14.F90:6323
scale_const::const_lhf0
real(rp), public const_lhf0
latent heat of fusion at 0C [J/kg]
Definition: scale_const.F90:86
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_nices
integer, parameter, public atmos_phy_mp_sn14_nices
Definition: scale_atmos_phy_mp_sn14.F90:114
scale_atmos_phy_mp_sn14::mixed_phase_collection
subroutine mixed_phase_collection(KA, KS, KE, flg_lt, d0_crg, v0_crg, beta_crg, dqcrg, wtem, rhoq, rhoq_crg, xq, dq_xave, vt_xave, PQ, Pcrg1, Pcrg2, Pac)
Definition: scale_atmos_phy_mp_sn14.F90:4278
scale_const::const_rdry
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
Definition: scale_const.F90:59
scale_file_history::file_history_reg
subroutine, public file_history_reg(name, desc, unit, itemid, standard_name, ndims, dim_type, cell_measures, fill_halo)
Register/Append variable to history file.
Definition: scale_file_history.F90:685
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_nwaters
integer, parameter, public atmos_phy_mp_sn14_nwaters
Definition: scale_atmos_phy_mp_sn14.F90:113
scale_const::const_lhs0
real(rp), parameter, public const_lhs0
latent heat of sublimation at 0C [J/kg]
Definition: scale_const.F90:84
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_tracer_units
character(len=h_short), dimension(qa_mp), parameter, public atmos_phy_mp_sn14_tracer_units
Definition: scale_atmos_phy_mp_sn14.F90:139
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_cloud_fraction
subroutine, public atmos_phy_mp_sn14_cloud_fraction(KA, KS, KE, IA, IS, IE, JA, JS, JE, QTRC, mask_criterion, cldfrac)
ATMOS_PHY_MP_sn14_cloud_fraction Calculate Cloud Fraction.
Definition: scale_atmos_phy_mp_sn14.F90:879
scale_specfunc::sf_gamma
real(rp) function, public sf_gamma(x)
Gamma function.
Definition: scale_specfunc.F90:50
scale_atmos_phy_mp_sn14::cross_section
subroutine cross_section(KA, KS, KE, QA_MP, QTRC0, DENS0, Crs)
Calculate Cross Section.
Definition: scale_atmos_phy_mp_sn14.F90:7143
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_atmos_saturation
module atmosphere / saturation
Definition: scale_atmos_saturation.F90:12
scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_setup
subroutine, public atmos_phy_mp_sn14_setup(KA, IA, JA)
ATMOS_PHY_MP_sn14_setup setup.
Definition: scale_atmos_phy_mp_sn14.F90:716
scale_const::const_pre00
real(rp), public const_pre00
pressure reference [Pa]
Definition: scale_const.F90:97
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_atmos_hydrometeor::n_hyd
integer, parameter, public n_hyd
Definition: scale_atmos_hydrometeor.F90:95
scale_atmos_hydrometeor::cp_vapor
real(rp), public cp_vapor
CP for vapor [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:150
scale_atmos_hydrometeor::cv_water
real(rp), public cv_water
CV for water [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:151
scale_atmos_hydrometeor::cv_ice
real(rp), public cv_ice
CV for ice [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:153
scale_atmos_hydrometeor::cp_ice
real(rp), public cp_ice
CP for ice [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:154
scale_const::const_lhf00
real(rp), public const_lhf00
latent heat of fusion at 0K [J/kg]
Definition: scale_const.F90:87
scale_atmos_hydrometeor::i_hg
integer, parameter, public i_hg
graupel
Definition: scale_atmos_hydrometeor.F90:101