SCALE-RM
scale_atmos_phy_mp_sn14.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
52 !-------------------------------------------------------------------------------
53 
54 #ifdef PROFILE_FAPP
55 #define PROFILE_START(name) call fapp_start(name, 1, 1)
56 #define PROFILE_STOP(name) call fapp_stop (name, 1, 1)
57 #elif defined(PROFILE_FINEPA)
58 #define PROFILE_START(name) call start_collection(name)
59 #define PROFILE_STOP(name) call stop_collection (name)
60 #else
61 #define PROFILE_START(name)
62 #define PROFILE_STOP(name)
63 #endif
64 
65 #include "macro_thermodyn.h"
67  !-----------------------------------------------------------------------------
68  !
69  !++ used modules
70  !
71  use scale_precision
72  use scale_stdio
73  use scale_prof
75 
77  use scale_tracer, only: qa
78  use scale_const, only: &
79  grav => const_grav, &
80  pi => const_pi, &
81  undef8 => const_undef8, &
82  rdry => const_rdry, &
83  cpdry => const_cpdry, &
84  cvdry => const_cvdry, &
85  p00 => const_pre00, &
86  t00 => const_tem00, &
87  rvap => const_rvap, &
88  cpvap => const_cpvap, &
89  cvvap => const_cvvap, &
90  cl => const_cl, &
91  ci => const_ci, &
92  lhv => const_lhv00, &
93  lhf => const_lhf00, &
94  lhv0 => const_lhv0, &
95  lhf0 => const_lhf0, &
96  lhs0 => const_lhs0, &
97  lhv00 => const_lhv00, &
98  lhf00 => const_lhf00, &
99  psat0 => const_psat0, &
100  emelt => const_emelt, &
101  dwatr => const_dwatr
102  !-----------------------------------------------------------------------------
103  implicit none
104  private
105  !-----------------------------------------------------------------------------
106  !
107  !++ Public procedure
108  !
109  public :: atmos_phy_mp_sn14_setup
110  public :: atmos_phy_mp_sn14
114 
115  !-----------------------------------------------------------------------------
116  !
117  !++ Public parameters & variables
118  !
119  real(RP), public, target :: atmos_phy_mp_dens(mp_qa) ! hydrometeor density [kg/m3]=[g/L]
120 
121  !-----------------------------------------------------------------------------
122  !
123  !++ Private procedure
124  !
125  private :: mp_sn14_init
126  private :: mp_sn14
127  private :: mp_terminal_velocity
128 
129  !-----------------------------------------------------------------------------
130  !
131  !++ Private parameters
132  !
133  integer, parameter :: hydro_max = 6 ! total number of mixing ratio of water
134  integer, parameter :: i_c = 1
135  integer, parameter :: i_r = 2
136  integer, parameter :: i_i = 3
137  integer, parameter :: i_s = 4
138  integer, parameter :: i_g = 5
139 
140  ! production rate
141  ! nucleation
142  integer, parameter :: i_lcccn = 1
143  integer, parameter :: i_ncccn = 2
144  integer, parameter :: i_liccn = 3
145  integer, parameter :: i_niccn = 4
146  ! freezing
147  integer, parameter :: i_lchom = 5
148  integer, parameter :: i_nchom = 6
149  integer, parameter :: i_lchet = 7
150  integer, parameter :: i_nchet = 8
151  integer, parameter :: i_lrhet = 9
152  integer, parameter :: i_nrhet = 10
153  ! melting
154  integer, parameter :: i_limlt = 11
155  integer, parameter :: i_nimlt = 12
156  integer, parameter :: i_lsmlt = 13
157  integer, parameter :: i_nsmlt = 14
158  integer, parameter :: i_lgmlt = 15
159  integer, parameter :: i_ngmlt = 16
160  ! vapor deposition
161  integer, parameter :: i_lrdep = 17
162  integer, parameter :: i_nrdep = 18
163  integer, parameter :: i_lidep = 19
164  integer, parameter :: i_nidep = 20
165  integer, parameter :: i_lsdep = 21
166  integer, parameter :: i_nsdep = 22
167  integer, parameter :: i_lgdep = 23
168  integer, parameter :: i_ngdep = 24
169  integer, parameter :: i_lcdep = 25
170 ! integer, parameter :: I_NCdep = 26
171  ! warm collection process
172  ! auto-conversion
173  integer, parameter :: i_lcaut = 26
174  integer, parameter :: i_ncaut = 27
175  integer, parameter :: i_nraut = 28
176  ! accretion
177  integer, parameter :: i_lcacc = 29
178  integer, parameter :: i_ncacc = 30
179  ! self-colletion, break-up
180  integer, parameter :: i_nrslc = 31
181  integer, parameter :: i_nrbrk = 32
182 
183  ! partial conversion(ice, snow => graupel)
184  integer, parameter :: i_licon = 33
185  integer, parameter :: i_nicon = 34
186  integer, parameter :: i_lscon = 35
187  integer, parameter :: i_nscon = 36
188  ! enhanced melting due to
189  integer, parameter :: i_liacm = 37 ! ice-cloud
190  integer, parameter :: i_niacm = 38
191  integer, parameter :: i_liarm = 39 ! ice-rain
192  integer, parameter :: i_niarm = 40
193  integer, parameter :: i_lsacm = 41 ! snow-cloud
194  integer, parameter :: i_nsacm = 42
195  integer, parameter :: i_lsarm = 43 ! snow-rain
196  integer, parameter :: i_nsarm = 44
197  integer, parameter :: i_lgacm = 45 ! graupel-cloud
198  integer, parameter :: i_ngacm = 46
199  integer, parameter :: i_lgarm = 47 ! graupel-rain
200  integer, parameter :: i_ngarm = 48
201  ! ice multiplication by splintering
202  integer, parameter :: i_lgspl = 49
203  integer, parameter :: i_lsspl = 50
204  integer, parameter :: i_nispl = 51
205 
206  integer, parameter :: pq_max = 51
207 
208  ! production rate of mixed-phase collection process
209  ! PXXacYY2ZZ means XX collect YY produce ZZ
210  integer, parameter :: i_liaclc2li = 1 ! cloud-ice
211  integer, parameter :: i_niacnc2ni = 2
212  integer, parameter :: i_lsaclc2ls = 3 ! cloud-snow(cloud change)
213  integer, parameter :: i_nsacnc2ns = 4
214  integer, parameter :: i_lgaclc2lg = 5 ! cloud-graupel
215  integer, parameter :: i_ngacnc2ng = 6
216  integer, parameter :: i_lracli2lg_i = 7 ! rain-ice(ice change)
217  integer, parameter :: i_nracni2ng_i = 8
218  integer, parameter :: i_lracli2lg_r = 9 ! rain-ice(rain change)
219  integer, parameter :: i_nracni2ng_r = 10
220  integer, parameter :: i_lracls2lg_s = 11 ! rain-snow(snow change)
221  integer, parameter :: i_nracns2ng_s = 12
222  integer, parameter :: i_lracls2lg_r = 13 ! rain-snow(rain change)
223  integer, parameter :: i_nracns2ng_r = 14
224  integer, parameter :: i_lraclg2lg = 15 ! rain-graupel(rain change)
225  integer, parameter :: i_nracng2ng = 16
226  integer, parameter :: i_liacli2ls = 17 ! ice-ice
227  integer, parameter :: i_niacni2ns = 18
228  integer, parameter :: i_liacls2ls = 19 ! ice-snow(ice change)
229  integer, parameter :: i_niacns2ns = 20
230  integer, parameter :: i_nsacns2ns = 21 ! snow-snow
231  integer, parameter :: i_ngacng2ng = 22 ! graupel-graupel
232  integer, parameter :: i_lgacls2lg = 23 ! snow-graupel
233  integer, parameter :: i_ngacns2ng = 24
234 
235  integer, parameter :: pac_max = 24
236 
237 
238 
239  character(len=H_SHORT), save :: wlabel(11)
240 
241  ! empirical value from Meyers etal.(1991), 1[/liter] = 1.d3[/m3]
242  real(RP), private, parameter :: nqmin(6) = (/ 0.0_rp, 1.e+4_rp, 1.0_rp, 1.0_rp, 1.e-4_rp, 1.e-4_rp /) ! [1/m3]
243  ! refer to Seifert(2002) (Dr. Thesis, Table.5.1)
244  ! max mass, for D_min=79um, 2mm, 5mm, 1cm, 1cm
245  real(RP), private, parameter :: xqmax(6) = (/ 0.0_rp, 2.6e-10_rp, 5.0e-6_rp, 1.377e-6_rp, 7.519e-6_rp, 4.90e-5_rp /)! [kg]
246  ! SB06, Table 1.
247  ! min mass, for D_min=2um, 79um, 10um, 20um, 100um
248  real(RP), private, parameter :: xqmin(6) = (/ 0.0_rp, 4.20e-15_rp, 2.60e-10_rp, 3.382e-13_rp, 1.847e-12_rp, 1.230e-10_rp /)! [kg]
249 
250 
251 
252  ! for all processes
253  ! SB06, Table 1.
254  real(RP), private, parameter :: xc_min = 4.20e-15_rp ! [kg] : min mass, D_min=2um
255  real(RP), private, parameter :: xr_min = 2.60e-10_rp ! [kg] : min mass, D_min=79um
256  real(RP), private, parameter :: xi_min = 3.382e-13_rp ! [kg] : min mass, D_min=10um
257  real(RP), private, parameter :: xs_min = 1.847e-12_rp ! [kg] : min mass, D_min=20um
258  real(RP), private, parameter :: xg_min = 1.230e-10_rp ! [kg] : min mass, D_min=100um
259  ! refer to Seifert(2002) (Dr. Thesis, Table.5.1)
260  real(RP), private, parameter :: xc_max = 2.6e-10_rp ! [kg] : max, D_max=79um
261  real(RP), private, parameter :: xr_max = 5.00e-6_rp ! [kg] : max, D_max=2mm
262  real(RP), private, parameter :: xi_max = 1.377e-6_rp ! [kg] : max, D_max=5mm
263  real(RP), private, parameter :: xs_max = 7.519e-6_rp ! [kg] : max, D_max=1cm
264  real(RP), private, parameter :: xg_max = 4.900e-5_rp ! [kg] : max, D_max=1cm
265  ! filter similar to Ikawa et al.(1991) sec.3.5
266  real(RP), private, parameter :: xmin_filter= xc_min
267  ! filter of effective radius(1 micron)
268  real(RP), private, parameter :: rmin_re= 1.e-6_rp
269  !
270  ! SB06(95),(96)
271  real(RP), private, parameter :: n0r_min= 2.5e+5_rp ! [m-4]: min intercept parameter of rain
272  real(RP), private, parameter :: n0r_max= 2.0e+7_rp ! [m-4]: max
273  real(RP), private, parameter :: lambdar_min= 1.e+3_rp ! [m-1]: min slope parameter of rain
274  real(RP), private, parameter :: lambdar_max= 1.e+4_rp ! [m-1]: max
275  ! empirical value from Meyers etal.(1991), 1[/liter] = 1.d3[/m3]
276  real(RP), private, parameter :: nc_min = 1.e+4_rp ! [m-3] empirical T.Mitsui
277  real(RP), private, parameter :: nr_min = 1.0_rp ! [m-3] 1/1000 [/liter]
278  real(RP), private, parameter :: ni_min = 1.0_rp ! [m-3]
279  real(RP), private, parameter :: ns_min = 1.e-4_rp ! [m-3]
280  real(RP), private, parameter :: ng_min = 1.e-4_rp ! [m-3]
281  ! empirical filter
282  real(RP), private, parameter :: lc_min = xc_min*nc_min
283  real(RP), private, parameter :: lr_min = xr_min*nr_min
284  real(RP), private, parameter :: li_min = xi_min*ni_min
285  real(RP), private, parameter :: ls_min = xs_min*ns_min
286  real(RP), private, parameter :: lg_min = xg_min*ng_min
287  !
288  real(RP), private, parameter :: x_sep = 2.6e-10_rp ! boundary mass between cloud and rain
289  !
290  real(RP), private, parameter :: tem_min=100.0_rp
291  real(RP), private, parameter :: rho_min=1.e-5_rp ! 3.e-3 is lower limit recognized in many experiments.
292  real(RP), private, parameter :: rhoi = 916.70_rp
293  ! for Seifert(2008)
294  ! work parameter for gamma function, imported from MISC_gammafunc
295  real(RP), private, parameter :: gfac_coef(6)=(/&
296  +76.180091729471460_rp, -86.505320329416770_rp, +24.014098240830910_rp,&
297  -1.2317395724501550_rp, +0.1208650973866179e-2_rp, -0.5395239384953e-5_rp /)
298  real(RP), private, parameter :: gfac_ser0=1.000000000190015_rp
299  !
300  integer, private, save :: ntmax_phase_change = 1
301  integer, private, save :: ntmax_collection = 1
302  integer, private, save :: mp_ntmax_sedimentation= 1 ! 10/08/03 [Add] T.Mitsui
303  !
304  !--- standard density
305  real(RP), private, parameter :: rho_0 = 1.280_rp
306  !--- max number of Nc( activatable aerosol number concentration )
307  real(RP), allocatable, private, save :: nc_uplim_d(:,:,:)
308  !
309  !--- thermal conductivity of air
310  real(RP), private, parameter :: ka0 = 2.428e-2_rp
311 
312  real(RP), private, parameter :: dka_dt = 7.47e-5_rp
313 
314  !====== Ka = Ka0 + temc*dKa_dT
315  !
316  !--- Dynamic viscosity
317  real(RP), private, parameter :: mua0 = 1.718e-5_rp
318 
319  real(RP), private, parameter :: dmua_dt = 5.28e-8_rp
320 
321  !====== mua = mua0 + temc*dmua_dT
322  !
323  real(RP), private, save :: xc_ccn = 1.e-12_rp ! [kg]
324  real(RP), private, save :: xi_ccn = 1.e-12_rp ! [kg] ! [move] 11/08/30 T.Mitsui
325  !
326  ! capacity of diffusional growth
327  ! ( dependent of their geometries )
328  real(RP), private, save :: cap(hydro_max)
329  !
330  ! constants for Diameter-Mass relation
331  ! D = a * x^b
332  real(RP), private, save :: a_m(hydro_max)
333  real(RP), private, save :: b_m(hydro_max)
334  ! constants for Terminal velocity-Mass relation
335  ! vt = alpha * x^beta * f
336  real(RP), private, save :: alpha_v(hydro_max,2)
337  real(RP), private, save :: beta_v(hydro_max,2)
338  real(RP), private, save :: alpha_vn(hydro_max,2) !
339  real(RP), private, save :: beta_vn(hydro_max,2) !
340  real(RP), private, save :: gamma_v(hydro_max)
341  ! Aerodynamical factor for correction of terminal velocity.(Heymsfield and Iaquinta, 2000)
342  ! vt(tem,pre) = vt0 * (pre/pre0)**a_pre0 * (tem/tem0)**a_tem0
343  real(RP), private, parameter :: pre0_vt = 300.e+2_rp ! 300hPa
344  real(RP), private, parameter :: tem0_vt = 233.0_rp ! -40degC
345  real(RP), private, parameter :: a_pre0_vt = -0.1780_rp
346  real(RP), private, parameter :: a_tem0_vt = -0.3940_rp
347  ! Parameters to determine Droplet Size Distribution
348  ! as a General Gamma Distribution
349  ! f(x) = A x^nu exp(-lambda x^mu )
350  ! for Marshall Palmer Distribution ( popular for rain )
351  ! mu=1/3, nu=-2/3
352  ! for Gamma Distribution ( popular for cloud )
353  ! mu=1
354  real(RP), private, save :: nu(hydro_max)
355  real(RP), private, save :: mu(hydro_max)
356  ! Mitchell(1996), JAS, vol.53, No.12, pp.1710-1723
357  ! area = a_area*D^b_area
358  ! area = ax_area*x^bx_area
359  ! Auer and Veal(1970), JAS, vol.27, pp.919-pp.926
360  ! height = a_h*x^b_h( based on h=a_ar*D^b_ar, ar:aspect ratio)
361  real(RP), private, save :: a_area(hydro_max) !
362  real(RP), private, save :: b_area(hydro_max) !
363  real(RP), private, save :: ax_area(hydro_max) !
364  real(RP), private, save :: bx_area(hydro_max) !
365  ! parameters for radius of equivalent area
366  ! r_ea = a_rea*x**b_rea
367  real(RP), private, save :: a_rea(hydro_max) !
368  real(RP), private, save :: b_rea(hydro_max) !
369  real(RP), private, save :: a_rea2(hydro_max) !
370  real(RP), private, save :: b_rea2(hydro_max) !
371  real(RP), private, save :: a_rea3(hydro_max) !
372  real(RP), private, save :: b_rea3(hydro_max) !
373  !
374  real(RP), private, save :: a_d2vt(hydro_max) !
375  real(RP), private, save :: b_d2vt(hydro_max) !
376  ! coefficient of x^2 moment of DSD
377  ! Z = integral x*x*f(x) dx
378  ! = coef_m2*N*(L/N)^2
379  real(RP), private, save :: coef_m2(hydro_max)
380  ! radar reflectivity coefficient defined by diameter
381  real(RP), private, save :: coef_d6(hydro_max) !
382  ! volume coefficient defined by diameter
383  real(RP), private, save :: coef_d3(hydro_max) !
384  ! coefficient of weighted mean diameter
385  real(RP), private, save :: coef_d(hydro_max)
386  ! coefficient of weighted mean d*d*v
387  real(RP), private, save :: coef_d2v(hydro_max) !
388  ! coefficient of moment of d*d*v
389  real(RP), private, save :: coef_md2v(hydro_max) !
390  !
391  ! for effective radius(spherical particle)
392  real(RP), private, save :: coef_r2(hydro_max)
393  real(RP), private, save :: coef_r3(hydro_max)
394  real(RP), private, save :: coef_re(hydro_max)
395  ! for effective radius(hexagonal plate)
396  real(RP), private, save :: coef_rea2(hydro_max) !
397  real(RP), private, save :: coef_rea3(hydro_max) !
398  logical, private, save :: opt_m96_ice=.true. !
399  logical, private, save :: opt_m96_column_ice=.false. !
400  !
401  ! coefficeint of weighted mean terminal velocity
402  ! vt0 is number weighted and
403  ! vt1 is mass weighted.
404  real(RP), private, save :: coef_vt0(hydro_max,2)
405  real(RP), private, save :: coef_vt1(hydro_max,2)
406  real(RP), private, save :: coef_deplc
407  real(RP), private, save :: coef_dave_n(hydro_max) !
408  real(RP), private, save :: coef_dave_l(hydro_max) !
409  ! diameter of terminal velocity branch
410  !
411  real(RP), private, save :: d0_ni=261.76e-6_rp !
412  real(RP), private, save :: d0_li=398.54e-6_rp
413  real(RP), private, parameter :: d0_ns=270.03e-6_rp !
414  real(RP), private, parameter :: d0_ls=397.47e-6_rp !
415  real(RP), private, parameter :: d0_ng=269.08e-6_rp !
416  real(RP), private, parameter :: d0_lg=376.36e-6_rp !
417  !
418  real(RP), private, parameter :: coef_vtr_ar1=9.65_rp ! coef. for large branch
419  ! original parameter of Rogers etal.(1993)
420  real(RP), private, parameter :: coef_vtr_br1=10.43_rp ! ...
421  real(RP), private, parameter :: coef_vtr_cr1=600.0_rp ! ...
422  real(RP), private, parameter :: coef_vtr_ar2=4.e+3_rp ! coef. for small branch
423  real(RP), private, parameter :: coef_vtr_br2=12.e+3_rp ! ...
424  real(RP), private, parameter :: d_vtr_branch=0.745e-3_rp ! 0.745 mm (diameter dividing 2-branches)
425  ! equilibrium diameter of rain break-up
426  real(RP), private, parameter :: dr_eq = 1.10e-3_rp ! eqilibrium diameter, Seifert 2008(36)
427  ! coefficient of General Gamma.
428  ! f(x) = A x^nu exp(-lambda x^mu )
429  ! lambda = coef_lambda * (L/N)^{-mu}
430  ! A = coef_A*N*lambda^slope_A
431  real(RP), private, save :: coef_a(hydro_max)
432  real(RP), private, save :: coef_lambda(hydro_max)
433 ! real(RP), private, save :: slope_A(HYDRO_MAX)
434  ! coefficeint of weighted ventilation effect.
435  ! large, and small branch is by PK97(13-60),(13-61),(13-88),(13-89)
436  real(RP), private, save :: ah_vent (hydro_max,2) !
437  real(RP), private, save :: bh_vent (hydro_max,2) !
438  real(RP), private, save :: ah_vent0 (hydro_max,2) !
439  real(RP), private, save :: bh_vent0 (hydro_max,2) !
440  real(RP), private, save :: ah_vent1 (hydro_max,2) !
441  real(RP), private, save :: bh_vent1 (hydro_max,2) !
442  ! coefficient of collision growth
443  real(RP), private, save :: delta_b0 (hydro_max)
444  real(RP), private, save :: delta_b1 (hydro_max)
445  real(RP), private, save :: delta_ab0(hydro_max,hydro_max)
446  real(RP), private, save :: delta_ab1(hydro_max,hydro_max)
447  !
448  real(RP), private, save :: theta_b0 (hydro_max)
449  real(RP), private, save :: theta_b1 (hydro_max)
450  real(RP), private, save :: theta_ab0(hydro_max,hydro_max)
451  real(RP), private, save :: theta_ab1(hydro_max,hydro_max)
452  !
453  logical, private, save :: opt_debug=.false.
454  !
455  logical, private, save :: opt_debug_tem=.false.
456  logical, private, save :: opt_debug_inc=.true.
457  logical, private, save :: opt_debug_act=.true.
458  logical, private, save :: opt_debug_ree=.true.
459  logical, private, save :: opt_debug_bcs=.true.
460 
461  integer, private, save :: mp_nstep_sedimentation
462  real(RP), private, save :: mp_rnstep_sedimentation
463  real(DP), private, save :: mp_dtsec_sedimentation
464 
465  !
466  ! metrics of vertical coordinate
467  ! not used in SCALE-RM
468  !
469  real(RP), private, allocatable, save :: gsgam2_d (:,:,:)
470  real(RP), private, allocatable, save :: gsgam2h_d(:,:,:)
471  real(RP), private, allocatable, save :: gam2_d (:,:,:)
472  real(RP), private, allocatable, save :: gam2h_d (:,:,:)
473  real(RP), private, allocatable, save :: rgsgam2_d(:,:,:)
474  real(RP), private, allocatable, save :: rgs_d (:,:,:)
475  real(RP), private, allocatable, save :: rgsh_d (:,:,:)
476 
477  logical, private, save :: mp_doautoconversion = .true.
478  logical, private, save :: mp_doprecipitation = .true.
479  logical, private, save :: mp_couple_aerosol = .false. ! apply CCN effect?
480  real(RP), private, save :: mp_ssw_lim = 1.e+1_rp
481 
482 
483  !-----------------------------------------------------------------------------
484 contains
485  !-----------------------------------------------------------------------------
487  subroutine atmos_phy_mp_sn14_setup( MP_TYPE )
488  use scale_process, only: &
490  use scale_grid, only: &
491  cdz => grid_cdz
492  use scale_const, only: &
493  const_dwatr, &
494  const_dice
495  use scale_time, only: &
497  implicit none
498 
499  character(len=*), intent(in) :: MP_TYPE
500 
501  namelist / param_atmos_phy_mp / &
502  mp_doautoconversion, &
503  mp_doprecipitation, &
504  mp_ssw_lim, &
505  mp_couple_aerosol, &
506  mp_ntmax_sedimentation
507 
508  real(RP), parameter :: max_term_vel = 10.0_rp !-- terminal velocity for calculate dt of sedimentation
509  integer :: nstep_max
510  integer :: ierr
511  !---------------------------------------------------------------------------
512 
513  if( io_l ) write(io_fid_log,*)
514  if( io_l ) write(io_fid_log,*) '+++ Module[Cloud Microphisics]/Categ[ATMOS]'
515  if( io_l ) write(io_fid_log,*) '*** Wrapper for SN14'
516 
517  if ( mp_type /= 'SN14' ) then
518  write(*,*) 'xxx ATMOS_PHY_MP_TYPE is not SN14. Check!'
519  call prc_mpistop
520  end if
521 
522  if ( i_qv <= 0 &
523  .OR. i_qc <= 0 &
524  .OR. i_qr <= 0 &
525  .OR. i_qi <= 0 &
526  .OR. i_qs <= 0 &
527  .OR. i_qg <= 0 &
528  .OR. i_nc <= 0 &
529  .OR. i_nr <= 0 &
530  .OR. i_ni <= 0 &
531  .OR. i_ns <= 0 &
532  .OR. i_ng <= 0 ) then
533  write(*,*) 'xxx SN14 needs QV/C/R/I/S/G and NC/R/I/S/G tracer. Check!'
534  call prc_mpistop
535  endif
536 
537  !--- read namelist
538  rewind(io_fid_conf)
539  read(io_fid_conf,nml=param_atmos_phy_mp,iostat=ierr)
540  if( ierr < 0 ) then !--- missing
541  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
542  elseif( ierr > 0 ) then !--- fatal error
543  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_MP. Check!'
544  call prc_mpistop
545  endif
546  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_mp)
547 
548  atmos_phy_mp_dens(i_mp_qc) = const_dwatr
549  atmos_phy_mp_dens(i_mp_qr) = const_dwatr
550  atmos_phy_mp_dens(i_mp_qi) = const_dice
551  atmos_phy_mp_dens(i_mp_qs) = const_dice
552  atmos_phy_mp_dens(i_mp_qg) = const_dice
553 
554  wlabel( 1) = "VAPOR"
555  wlabel( 2) = "CLOUD"
556  wlabel( 3) = "RAIN"
557  wlabel( 4) = "ICE"
558  wlabel( 5) = "SNOW"
559  wlabel( 6) = "GRAUPEL"
560  wlabel( 7) = "CLOUD_NUM"
561  wlabel( 8) = "RAIN_NUM"
562  wlabel( 9) = "ICE_NUM"
563  wlabel(10) = "SNOW_NUM"
564  wlabel(11) = "GRAUPEL_NUM"
565 
566  call mp_sn14_init
567 
568  allocate(nc_uplim_d(1,ia,ja))
569  nc_uplim_d(:,:,:) = 150.e6_rp
570 
571  nstep_max = int( ( time_dtsec_atmos_phy_mp * max_term_vel ) / minval( cdz ) )
572  mp_ntmax_sedimentation = max( mp_ntmax_sedimentation, nstep_max )
573 
574  mp_nstep_sedimentation = mp_ntmax_sedimentation
575  mp_rnstep_sedimentation = 1.0_rp / real(mp_ntmax_sedimentation,kind=rp)
576  mp_dtsec_sedimentation = time_dtsec_atmos_phy_mp * mp_rnstep_sedimentation
577 
578  if ( io_l ) write(io_fid_log,*)
579  if ( io_l ) write(io_fid_log,*) '*** Timestep of sedimentation is divided into : ', mp_ntmax_sedimentation, ' step'
580  if ( io_l ) write(io_fid_log,*) '*** DT of sedimentation is : ', mp_dtsec_sedimentation, '[s]'
581 
582  !--- For kij
583  allocate( gsgam2_d(ka,ia,ja) )
584  allocate( gsgam2h_d(ka,ia,ja) )
585  allocate( gam2_d(ka,ia,ja) )
586  allocate( gam2h_d(ka,ia,ja) )
587  allocate( rgsgam2_d(ka,ia,ja) )
588  allocate( rgs_d(ka,ia,ja) )
589  allocate( rgsh_d(ka,ia,ja) )
590  gsgam2_d(:,:,:) = 1.0_rp
591  gsgam2h_d(:,:,:) = 1.0_rp
592  gam2_d(:,:,:) = 1.0_rp
593  gam2h_d(:,:,:) = 1.0_rp
594  rgsgam2_d(:,:,:) = 1.0_rp
595  rgs_d(:,:,:) = 1.0_rp
596  rgsh_d(:,:,:) = 1.0_rp
597 
598  return
599  end subroutine atmos_phy_mp_sn14_setup
600 
601  !-----------------------------------------------------------------------------
603  !-----------------------------------------------------------------------------
604  subroutine atmos_phy_mp_sn14( &
605  DENS, &
606  MOMZ, &
607  MOMX, &
608  MOMY, &
609  RHOT, &
610  QTRC, &
611  CCN, &
612  EVAPORATE, &
613  SFLX_rain, &
614  SFLX_snow )
616  use scale_tracer, only: &
617  qad => qa, &
618  mp_qad => mp_qa
619  implicit none
620 
621  real(RP), intent(inout) :: dens(ka,ia,ja)
622  real(RP), intent(inout) :: MOMZ(ka,ia,ja)
623  real(RP), intent(inout) :: MOMX(ka,ia,ja)
624  real(RP), intent(inout) :: MOMY(ka,ia,ja)
625  real(RP), intent(inout) :: RHOT(ka,ia,ja)
626  real(RP), intent(inout) :: QTRC(ka,ia,ja,qad)
627  real(RP), intent(in) :: CCN(ka,ia,ja)
628  real(RP), intent(out) :: EVAPORATE(ka,ia,ja)
629  real(RP), intent(out) :: SFLX_rain(ia,ja)
630  real(RP), intent(out) :: SFLX_snow(ia,ja)
631  !---------------------------------------------------------------------------
632 
633  if( io_l ) write(io_fid_log,*) '*** Physics step: Cloud microphysics(SN14)'
634 
635 #ifdef PROFILE_FIPP
636  call fipp_start()
637 #endif
638 
639  call mp_negativefilter( dens, qtrc )
640 
641  call mp_sn14( dens, & ! [INOUT]
642  momz, & ! [INOUT]
643  momx, & ! [INOUT]
644  momy, & ! [INOUT]
645  rhot, & ! [INOUT]
646  qtrc, & ! [INOUT]
647  ccn, & ! [IN]
648  evaporate, & ! [OUT]
649  sflx_rain, & ! [OUT]
650  sflx_snow ) ! [OUT]
651 
652  call mp_negativefilter( dens, qtrc )
653 
654 #ifdef PROFILE_FIPP
655  call fipp_stop()
656 #endif
657 
658  return
659  end subroutine atmos_phy_mp_sn14
660 
661  !-----------------------------------------------------------------------------
662  subroutine mp_sn14_init
663  use scale_process, only: &
665  use scale_specfunc, only: &
666  gammafunc => sf_gamma
667  implicit none
668 
669  real(RP), allocatable :: w1(:),w2(:),w3(:),w4(:),w5(:),w6(:),w7(:),w8(:)
670  ! work for calculation of capacity, Mitchell and Arnott (1994) , eq.(9)
671  real(RP) :: ar_ice_fix = 0.7_rp
672  real(RP) :: wcap1, wcap2
673  ! work for ventilation coefficient
674  logical :: flag_vent0(hydro_max), flag_vent1(hydro_max)
675  integer :: ierr
676  integer :: iw, ia, ib
677  integer :: n
678  !
679  namelist /nm_mp_sn14_init/ &
680  opt_debug, &
681  opt_debug_tem, &
682  opt_debug_inc, &
683  opt_debug_act, &
684  opt_debug_ree, &
685  opt_debug_bcs, &
686  ntmax_phase_change, &
687  ntmax_collection
688  !
689  namelist /nm_mp_sn14_particles/ &
690  a_m, b_m, alpha_v, beta_v, gamma_v, &
691  alpha_vn, beta_vn, &
692  a_area, b_area, cap, &
693  nu, mu, &
694  opt_m96_column_ice, &
695  opt_m96_ice, &
696  ar_ice_fix
697  real(RP), parameter :: eps_gamma=1.e-30_rp
698 
699  a_m(:) = undef8
700  b_m(:) = undef8
701  alpha_v(:,:) = undef8
702  beta_v(:,:) = undef8
703  alpha_vn(:,:) = undef8
704  beta_vn(:,:) = undef8
705  gamma_v(:) = undef8
706  a_d2vt(:) = undef8
707  b_d2vt(:) = undef8
708  a_area(:) = undef8
709  b_area(:) = undef8
710  ax_area(:) = undef8
711  bx_area(:) = undef8
712  a_rea(:) = undef8
713  b_rea(:) = undef8
714  a_rea2(:) = undef8
715  b_rea2(:) = undef8
716  a_rea3(:) = undef8
717  b_rea3(:) = undef8
718  nu(:) = undef8
719  mu(:) = undef8
720  cap(:) = undef8
721  coef_m2(:) = undef8
722  coef_dave_n(:) = undef8
723  coef_dave_l(:) = undef8
724  coef_d(:) = undef8
725  coef_d3(:) = undef8
726  coef_d6(:) = undef8
727  coef_d2v(:) = undef8
728  coef_md2v(:) = undef8
729  coef_r2(:) = undef8
730  coef_r3(:) = undef8
731  coef_re(:) = undef8
732  coef_rea2(:) = undef8
733  coef_rea3(:) = undef8
734  coef_a(:) = undef8
735 ! slope_A(:) = UNDEF8
736  coef_lambda(:) = undef8
737  coef_vt0(:,:) = undef8
738  coef_vt1(:,:) = undef8
739  delta_b0(:) = undef8
740  delta_b1(:) = undef8
741  delta_ab0(:,:) = undef8
742  delta_ab1(:,:) = undef8
743  theta_b0(:) = undef8
744  theta_b1(:) = undef8
745  theta_ab0(:,:) = undef8
746  theta_ab1(:,:) = undef8
747  !
748  ah_vent(:,:) = undef8
749  ah_vent0(:,:) = undef8
750  ah_vent1(:,:) = undef8
751  bh_vent(:,:) = undef8
752  bh_vent0(:,:) = undef8
753  bh_vent1(:,:) = undef8
754  !
755 
756  if( io_l ) write(io_fid_log,*)
757  if( io_l ) write(io_fid_log,*) '+++ Module[SN14]/Categ[ATMOS]'
758 
759  !--- read namelist
760  rewind(io_fid_conf)
761  read(io_fid_conf,nml=nm_mp_sn14_init,iostat=ierr)
762 
763  if( ierr < 0 ) then !--- missing
764  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
765  elseif( ierr > 0 ) then !--- fatal error
766  write(*,*) 'xxx Not appropriate names in namelist nm_mp_sn14_init. Check!'
767  call prc_mpistop
768  endif
769  if( io_l ) write(io_fid_log,nml=nm_mp_sn14_init)
770 
771  !
772  ! default setting
773  !
774  ! Area parameters with mks unit originated by Mitchell(1996)
775  a_area(i_qc) = pi/4.0_rp ! sphere
776  a_area(i_qr) = pi/4.0_rp ! sphere
777  a_area(i_qi) = 0.65_rp*1.e-4_rp*100.0_rp**(2.00_rp) ! Mitchell(1996), Hexagonal Plate
778  a_area(i_qs) = 0.2285_rp*1.e-4_rp*100.0_rp**(1.88_rp) ! Mitchell(1996), Aggregates
779  a_area(i_qg) = 0.50_rp*1.e-4_rp*100.0_rp**(2.0_rp) ! Mitchell(1996), Lump Graupel
780  b_area(i_qc) = 2.0_rp
781  b_area(i_qr) = 2.0_rp
782  b_area(i_qi) = 2.0_rp
783  b_area(i_qs) = 1.88_rp
784  b_area(i_qg) = 2.0_rp
785  !
786  ! Seifert and Beheng(2006), Table. 1 or List of symbols
787  !----------------------------------------------------------
788  ! Diameter-Mass relationship
789  ! D = a * x^b
790  a_m(i_qc) = 0.124_rp
791  a_m(i_qr) = 0.124_rp
792  a_m(i_qi) = 0.217_rp
793  a_m(i_qs) = 8.156_rp
794  a_m(i_qg) = 0.190_rp
795  b_m(i_qc) = 1.0_rp/3.0_rp
796  b_m(i_qr) = 1.0_rp/3.0_rp
797  b_m(i_qi) = 0.302_rp
798  b_m(i_qs) = 0.526_rp
799  b_m(i_qg) = 0.323_rp
800  !----------------------------------------------------------
801  ! Terminal velocity-Mass relationship
802  ! vt = alpha * x^beta * (rho0/rho)^gamma
803  alpha_v(i_qc,:)= 3.75e+5_rp
804  alpha_v(i_qr,:)= 159.0_rp ! not for sedimantation
805  alpha_v(i_qi,:)= 317.0_rp
806  alpha_v(i_qs,:)= 27.70_rp
807  alpha_v(i_qg,:)= 40.0_rp
808  beta_v(i_qc,:) = 2.0_rp/3.0_rp
809  beta_v(i_qr,:) = 0.266_rp ! not for sedimantation
810  beta_v(i_qi,:) = 0.363_rp
811  beta_v(i_qs,:) = 0.216_rp
812  beta_v(i_qg,:) = 0.230_rp
813  gamma_v(i_qc) = 1.0_rp
814  ! This is high Reynolds number limit(Beard 1980)
815  gamma_v(i_qr) = 1.0_rp/2.0_rp
816  gamma_v(i_qi) = 1.0_rp/2.0_rp
817  gamma_v(i_qs) = 1.0_rp/2.0_rp
818  gamma_v(i_qg) = 1.0_rp/2.0_rp
819  !----------------------------------------------------------
820  ! DSD parameters
821  ! f(x) = A x^nu exp( -lambda x^mu )
822  ! Gamma Disribution : mu=1 , nu:arbitrary
823  ! Marshall-Palmer Distribution: mu=1/3, nu:-2/3
824  ! In the case of MP, f(D) dD = f(x)dx
825  ! f(x) = c * f(D)/D^2 (c:coefficient)
826  nu(i_qc) = 1.0_rp ! arbitrary for Gamma
827  nu(i_qr) = -1.0_rp/3.0_rp ! nu(diameter)=1, equilibrium condition.
828  nu(i_qi) = 1.0_rp !
829  nu(i_qs) = 1.0_rp !
830  nu(i_qg) = 1.0_rp !
831  !
832  mu(i_qc) = 1.0_rp ! Gamma
833  mu(i_qr) = 1.0_rp/3.0_rp ! Marshall Palmer
834  mu(i_qi) = 1.0_rp/3.0_rp !
835  mu(i_qs) = 1.0_rp/3.0_rp !
836  mu(i_qg) = 1.0_rp/3.0_rp !
837  !----------------------------------------------------------
838  ! Geomeries for diffusion growth
839  ! Pruppacher and Klett(1997), (13-77)-(13-80) and
840  ! originally derived by McDonald(1963b)
841  ! sphere: cap=2
842  ! plate : cap=pi
843  ! needle with aspect ratio a/b
844  ! : cap=log(2*a/b)
845  cap(i_qc) = 2.0_rp ! sphere
846  cap(i_qr) = 2.0_rp ! sphere
847  cap(i_qi) = pi ! hexagonal plate
848  cap(i_qs) = 2.0_rp ! mix aggregates
849  cap(i_qg) = 2.0_rp ! lump
850  !
851  alpha_vn(:,:) = alpha_v(:,:)
852  beta_vn(:,:) = beta_v(:,:)
853  !------------------------------------------------------------------------
854  !
855  ! additional setting
856  !
857 
858  !--- read namelist
859  rewind(io_fid_conf)
860  read(io_fid_conf,nml=nm_mp_sn14_particles,iostat=ierr)
861 
862  if( ierr < 0 ) then !--- missing
863  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
864  elseif( ierr > 0 ) then !--- fatal error
865  write(*,*) 'xxx Not appropriate names in namelist nm_mp_sn14_particles. Check!'
866  call prc_mpistop
867  endif
868  if( io_l ) write(io_fid_log,nml=nm_mp_sn14_particles)
869 
870  ! [Add] 10/08/03 T.Mitsui
871  ! particles shapes are
872  if( opt_m96_ice ) then
873  ! ice is randomly oriented Hexagonal plate (Auer and Veal 1970, Takano and Liou 1995, Mitchell 1996)
874  ! snow is assemblages of planar polycrystals(Mitchell 1996)
875  ! graupel is Lump graupel(R4b) is assumed(Mitchell 1996)
876  a_area(i_qi) = 0.120284936_rp
877  a_area(i_qs) = 0.131488_rp
878  a_area(i_qg) = 0.5_rp
879  b_area(i_qi) = 1.850000_rp
880  b_area(i_qs) = 1.880000_rp
881  b_area(i_qg) = 2.0_rp
882  a_m(i_qi) = 1.23655360084766_rp
883  a_m(i_qs) = a_m(i_qi)
884  a_m(i_qg) = 0.346111225718402_rp
885  b_m(i_qi) = 0.408329930583912_rp
886  b_m(i_qs) = b_m(i_qi)
887  b_m(i_qg) = 0.357142857142857_rp
888  !
889  if( opt_m96_column_ice )then
890  d0_ni=240.49e-6_rp ! this is column
891  d0_li=330.09e-6_rp ! this is column
892  a_area(i_qi)= (0.684_rp*1.e-4_rp)*10.0_rp**(2.0_rp*2.00_rp)
893  b_area(i_qi)= 2.0_rp
894  a_m(i_qi) = 0.19834046116844_rp
895  b_m(i_qi) = 0.343642611683849_rp
896  ! [Add] 11/08/30 T.Mitsui
897  ! approximated by the capacity for prolate spheroid with constant aspect ratio
898  wcap1 = sqrt(1.0_rp-ar_ice_fix**2)
899  wcap2 = log( (1.0_rp+wcap1)/ar_ice_fix )
900  cap(i_qi) = 2.0_rp*wcap2/wcap1
901  !
902  end if
903  !
904  ! These value are derived by least-square fitting in the range
905  ! qi [100um:1000um] in diameter
906  ! qs [100um:1000um] in diameter
907  ! qg [200um:2000um] in diameter
908  ! small branch , large branch
909  alpha_v(i_qi,:) =(/ 5798.60107421875_rp, 167.347076416016_rp/)
910  alpha_vn(i_qi,:) =(/ 12408.177734375_rp, 421.799865722656_rp/)
911  if( opt_m96_column_ice )then
912  alpha_v(i_qi,:) = (/2901.0_rp, 32.20_rp/)
913  alpha_vn(i_qi,:) = (/9675.2_rp, 64.16_rp/)
914  end if
915  alpha_v(i_qs,:) =(/ 15173.3916015625_rp, 305.678619384766_rp/)
916  alpha_vn(i_qs,:) =(/ 29257.1601562500_rp, 817.985717773438_rp/)
917  alpha_v(i_qg,:) =(/ 15481.6904296875_rp, 311.642242431641_rp/)
918  alpha_vn(i_qg,:) =(/ 27574.6562500000_rp, 697.536132812500_rp/)
919  !
920  beta_v(i_qi,:) =(/ 0.504873454570770_rp, 0.324817866086960_rp/)
921  beta_vn(i_qi,:) =(/ 0.548495233058929_rp, 0.385287821292877_rp/)
922  if( opt_m96_column_ice )then
923  beta_v(i_qi,:) =(/ 0.465552181005478_rp, 0.223826110363007_rp/)
924  beta_vn(i_qi,:) =(/ 0.530453503131866_rp, 0.273761242628098_rp/)
925  end if
926  beta_v(i_qs,:) =(/ 0.528109610080719_rp, 0.329863965511322_rp/)
927  beta_vn(i_qs,:) =(/ 0.567154467105865_rp, 0.393876969814301_rp/)
928  beta_v(i_qg,:) =(/ 0.534656763076782_rp, 0.330253750085831_rp/)
929  beta_vn(i_qg,:) =(/ 0.570551633834839_rp, 0.387124240398407_rp/)
930  end if
931  !
932  ! area-diameter relation => area-mass relation
933  ax_area(i_qc:i_qg) = a_area(i_qc:i_qg)*a_m(i_qc:i_qg)**b_area(i_qc:i_qg)
934  bx_area(i_qc:i_qg) = b_area(i_qc:i_qg)*b_m(i_qc:i_qg)
935  !
936  ! radius of equivalent area - m ass relation
937  ! pi*rea**2 = ax_area*x**bx_area
938  a_rea(i_qc:i_qg) = sqrt(ax_area(i_qc:i_qg)/pi)
939  b_rea(i_qc:i_qg) = bx_area(i_qc:i_qg)/2.0_rp
940  a_rea2(i_qc:i_qg) = a_rea(i_qc:i_qg)**2
941  b_rea2(i_qc:i_qg) = b_rea(i_qc:i_qg)*2.0_rp
942  a_rea3(i_qc:i_qg) = a_rea(i_qc:i_qg)**3
943  b_rea3(i_qc:i_qg) = b_rea(i_qc:i_qg)*3.0_rp
944  !
945  a_d2vt(i_qc:i_qg)=alpha_v(i_qc:i_qg,2)*(1.0_rp/alpha_v(i_qc:i_qg,2))**(beta_v(i_qc:i_qg,2)/b_m(i_qc:i_qg))
946  b_d2vt(i_qc:i_qg)=(beta_v(i_qc:i_qg,2)/b_m(i_qc:i_qg))
947  !
948  ! Calculation of Moment Coefficient
949  !
950  allocate( w1(i_qc:i_qg), w2(i_qc:i_qg), w3(i_qc:i_qg), w4(i_qc:i_qg) )
951  allocate( w5(i_qc:i_qg), w6(i_qc:i_qg), w7(i_qc:i_qg), w8(i_qc:i_qg) )
952  w1(:) = 0.0_rp
953  w2(:) = 0.0_rp
954  w3(:) = 0.0_rp
955  w4(:) = 0.0_rp
956  w5(:) = 0.0_rp
957  w6(:) = 0.0_rp
958  w7(:) = 0.0_rp
959  w8(:) = 0.0_rp
960  !-------------------------------------------------------
961  ! moment coefficient
962  ! SB06 (82)
963  ! M^n = coef_mn * N * (L/N)**n
964  ! M^2 = Z = coef_m2 * N *(L/N)**2
965  ! a*M^b = a*integral x^b f(x) dx = ave D
966  do iw=i_qc,i_qg
967  n = 2
968  w1(iw) = gammafunc( (n+nu(iw)+1.0_rp)/mu(iw) )
969  w2(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
970  w3(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
971  coef_m2(iw) = w1(iw)/w2(iw)*( w2(iw)/w3(iw) )**n
972  !
973  w4(iw) = gammafunc( (b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
974  coef_d(iw) = a_m(iw) * w4(iw)/w2(iw)*( w2(iw)/w3(iw) )**b_m(iw)
975  w5(iw) = gammafunc( (2.0_rp*b_m(iw)+beta_v(iw,2)+nu(iw)+1.0_rp)/mu(iw) )
976  w6(iw) = gammafunc( (3.0_rp*b_m(iw)+beta_v(iw,2)+nu(iw)+1.0_rp)/mu(iw) )
977  coef_d2v(iw) = a_m(iw) * w6(iw)/w5(iw)* ( w2(iw)/w3(iw) )**b_m(iw)
978  coef_md2v(iw)= w5(iw)/w2(iw)* ( w2(iw)/w3(iw) )**(2.0_rp*b_m(iw)+beta_v(iw,2))
979  ! 09/04/14 [Add] T.Mitsui, volume and radar reflectivity
980  w7(iw) = gammafunc( (3.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
981  coef_d3(iw) = a_m(iw)**3 * w7(iw)/w2(iw)*( w2(iw)/w3(iw) )**(3.0_rp*b_m(iw))
982  w8(iw) = gammafunc( (6.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
983  coef_d6(iw) = a_m(iw)**6 * w8(iw)/w2(iw)*( w2(iw)/w3(iw) )**(6.0_rp*b_m(iw))
984  end do
985  !
986  coef_deplc = coef_d(i_qc)/a_m(i_qc)
987  !-------------------------------------------------------
988  ! coefficient of 2nd and 3rd moments for effective radius
989  ! for spherical particle
990  do iw=i_qc,i_qg
991  ! integ r^2 f(x)dx
992  w1(iw) = gammafunc( (2.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
993  w2(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
994  w3(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
995  ! integ r^3 f(x)dx
996  w4(iw) = gammafunc( (3.0_rp*b_m(iw)+nu(iw)+1.0_rp)/mu(iw) )
997  !
998  coef_r2(iw)=w1(iw)/w2(iw)*( w2(iw)/w3(iw) )**(2.0_rp*b_m(iw))
999  coef_r3(iw)=w4(iw)/w2(iw)*( w2(iw)/w3(iw) )**(3.0_rp*b_m(iw))
1000  coef_re(iw)=coef_r3(iw)/coef_r2(iw)
1001  !
1002  end do
1003  !-------------------------------------------------------
1004  ! coefficient for effective radius of equivalent area and
1005  ! coefficient for volume of equivalent area
1006  do iw=i_qc,i_qg
1007  w1(iw) = gammafunc( (nu(iw)+1.0_rp)/mu(iw) )
1008  w2(iw) = gammafunc( (nu(iw)+2.0_rp)/mu(iw) )
1009  w3(iw) = gammafunc( (b_rea2(iw)+nu(iw)+1.0_rp)/mu(iw) )
1010  w4(iw) = gammafunc( (b_rea3(iw)+nu(iw)+1.0_rp)/mu(iw) )
1011  !
1012  coef_rea2(iw) = w3(iw)/w1(iw)*( w1(iw)/w2(iw) )**b_rea2(iw)
1013  coef_rea3(iw) = w4(iw)/w1(iw)*( w1(iw)/w2(iw) )**b_rea3(iw)
1014  end do
1015  !-------------------------------------------------------
1016  ! coefficient of gamma-distribution
1017  ! SB06(80)
1018  do iw=i_qc,i_qg
1019  w1(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1020  w2(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1021  coef_a(iw) = mu(iw)/w1(iw)
1022 ! slope_A(iw) = w1(iw)
1023  coef_lambda(iw) = (w1(iw)/w2(iw))**(-mu(iw))
1024  end do
1025  !-------------------------------------------------------
1026  ! coefficient for terminal velocity in sedimentation
1027  ! SB06(78)
1028  do ia=1,2
1029  do iw=i_qc,i_qg
1030  n = 0
1031  w1(iw) = gammafunc( (beta_vn(iw,ia) + nu(iw) + 1.0_rp + n)/mu(iw) )
1032  w2(iw) = gammafunc( ( nu(iw) + 1.0_rp + n)/mu(iw) )
1033  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1034  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1035  ! coefficient of terminal velocity for number
1036  coef_vt0(iw,ia)=alpha_vn(iw,ia)*w1(iw)/w2(iw)*(w3(iw)/w4(iw))**beta_vn(iw,ia)
1037  n = 1
1038  w1(iw) = gammafunc( (beta_v(iw,ia) + nu(iw) + 1.0_rp + n)/mu(iw) )
1039  w2(iw) = gammafunc( ( nu(iw) + 1.0_rp + n)/mu(iw) )
1040  ! coefficient of terminal velocity for mass
1041  coef_vt1(iw,ia)=alpha_v(iw,ia)*w1(iw)/w2(iw)*(w3(iw)/w4(iw))**beta_v(iw,ia)
1042  end do
1043  end do
1044  ! coefficient for weighted diameter used in calculation of terminal velocity
1045  do iw=i_qc,i_qg
1046  w1(iw) = gammafunc( ( b_m(iw) + nu(iw) + 1.0_rp)/mu(iw) )
1047  w2(iw) = gammafunc( (1.0_rp + b_m(iw) + nu(iw) + 1.0_rp)/mu(iw) )
1048  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1049  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1050  coef_dave_n(iw) = (w1(iw)/w3(iw))*(w3(iw)/w4(iw))** b_m(iw)
1051  coef_dave_l(iw) = (w2(iw)/w3(iw))*(w3(iw)/w4(iw))**(1.0_rp+b_m(iw))
1052  end do
1053  !-------------------------------------------------------
1054  !
1055  ah_vent(i_qc,1:2) = (/1.0000_rp,1.0000_rp/) ! no effect
1056  ah_vent(i_qr,1:2) = (/1.0000_rp,0.780_rp/)
1057  ah_vent(i_qi,1:2) = (/1.0000_rp,0.860_rp/)
1058  ah_vent(i_qs,1:2) = (/1.0000_rp,0.780_rp/)
1059  ah_vent(i_qg,1:2) = (/1.0000_rp,0.780_rp/)
1060  bh_vent(i_qc,1:2) = (/0.0000_rp,0.0000_rp/)
1061  bh_vent(i_qr,1:2) = (/0.108_rp,0.308_rp/)
1062  bh_vent(i_qi,1:2) = (/0.140_rp,0.280_rp/)
1063  bh_vent(i_qs,1:2) = (/0.108_rp,0.308_rp/)
1064  bh_vent(i_qg,1:2) = (/0.108_rp,0.308_rp/)
1065  !
1066  do iw=i_qc,i_qg
1067  n = 0
1068  if( (nu(iw) + b_m(iw) + n) > eps_gamma )then
1069  w1(iw) = gammafunc( (nu(iw) + b_m(iw) + n)/mu(iw) )
1070  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1071  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1072  ah_vent0(iw,1)= ah_vent(iw,1)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1073  ah_vent0(iw,2)= ah_vent(iw,2)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1074  flag_vent0(iw)=.true.
1075  else
1076  ah_vent0(iw,1)= 1.0_rp
1077  ah_vent0(iw,2)= 1.0_rp
1078  flag_vent0(iw)=.false.
1079  end if
1080  n = 1
1081  if( (nu(iw) + b_m(iw) + n) > eps_gamma )then
1082  w1(iw) = gammafunc( (nu(iw) + b_m(iw) + n)/mu(iw) )
1083  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1084  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1085  ah_vent1(iw,1)= ah_vent(iw,1)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1086  ah_vent1(iw,2)= ah_vent(iw,2)*(w1(iw)/w2(iw))*(w2(iw)/w3(iw))**(b_m(iw)+n-1.0_rp)
1087  flag_vent1(iw)=.true.
1088  else
1089  ah_vent1(iw,1)= 1.0_rp
1090  ah_vent1(iw,2)= 1.0_rp
1091  flag_vent1(iw)=.true.
1092  end if
1093  end do
1094  do iw=i_qc,i_qg
1095  n = 0
1096  if( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n) < eps_gamma )then
1097  flag_vent0(iw)=.false.
1098  end if
1099  if(flag_vent0(iw))then
1100  w1(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n)/mu(iw) )
1101  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1102  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1103  ! [Add] 11/08/30 T.Mitsui
1104  w4(iw) = gammafunc( (nu(iw) + 2.0_rp*b_m(iw) + beta_v(iw,1) + n)/mu(iw) )
1105  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)
1106  w5(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,2) + n)/mu(iw) )
1107  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)
1108  else
1109  bh_vent0(iw,1) = 0.0_rp
1110  bh_vent0(iw,2) = 0.0_rp
1111  end if
1112  !
1113  n = 1
1114  if( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n) < eps_gamma )then
1115  flag_vent1(iw)=.false.
1116  end if
1117  if(flag_vent1(iw))then
1118  w1(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,1) + n)/mu(iw) )
1119  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1120  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1121  ! [Add] 11/08/30 T.Mitsui
1122  w4(iw) = gammafunc( (nu(iw) + 2.0_rp*b_m(iw) + beta_v(iw,1) + n)/mu(iw) )
1123  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)
1124  !
1125  w5(iw) = gammafunc( (nu(iw) + 1.5_rp*b_m(iw) + 0.5_rp*beta_v(iw,2) + n)/mu(iw) )
1126  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)
1127  else
1128  bh_vent1(iw,1) = 0.0_rp
1129  bh_vent1(iw,2) = 0.0_rp
1130  end if
1131  end do
1132  !-------------------------------------------------------
1133  ! coefficient for collision process
1134  ! stochastic coefficient for collision cross section
1135  ! sb06 (90) -- self collection
1136  do iw=i_qc,i_qg
1137  n = 0
1138  w1(iw) = gammafunc( (2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1139  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1140  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1141  delta_b0(iw) = w1(iw)/w2(iw) &
1142  *( w2(iw)/w3(iw) )**(2.0_rp*b_rea(iw) + n)
1143  n = 1
1144  w1(iw) = gammafunc( (2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1145  delta_b1(iw) = w1(iw)/w2(iw) &
1146  *( w2(iw)/w3(iw) )**(2.0_rp*b_rea(iw) + n)
1147  end do
1148  ! stochastic coefficient for collision cross section
1149  ! sb06(91) -- riming( collide with others )
1150  do iw=i_qc,i_qg
1151  n = 0
1152  w1(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1153  w2(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1154  w3(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1155  w4(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
1156  n = 1
1157  w5(iw) = gammafunc( (b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1158  end do
1159  ! ia > ib ( larger particles "a" catch smaller particles "b" )
1160  do ia=i_qc,i_qg
1161  do ib=i_qc,i_qg
1162  n=0 !
1163  ! NOTE, collected particle has a moment of n.
1164  ! collecting particle has only number(n=0).
1165  delta_ab0(ia,ib) = 2.0_rp*(w1(ib)/w2(ib))*(w4(ia)/w2(ia)) &
1166  * ( w2(ib)/w3(ib) )**(b_rea(ib)+n) &
1167  * ( w2(ia)/w3(ia) )**(b_rea(ia) )
1168  n=1 !
1169  delta_ab1(ia,ib) = 2.0_rp*(w5(ib)/w2(ib))*(w4(ia)/w2(ia)) &
1170  * ( w2(ib)/w3(ib) )**(b_rea(ib)+n) &
1171  * ( w2(ia)/w3(ia) )**(b_rea(ia) )
1172  end do
1173  end do
1174  ! stochastic coefficient for terminal velocity
1175  ! sb06(92) -- self collection
1176  ! assuming equivalent area circle.
1177  do iw=i_qc,i_qg
1178  n = 0
1179  w1(iw) = gammafunc( (2.0_rp*beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1180  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1181  w3(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1182  w4(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1183  theta_b0(iw) = w1(iw)/w2(iw) * ( w3(iw)/w4(iw) )**(2.0_rp*beta_v(iw,2))
1184  n = 1
1185  w1(iw) = gammafunc( (2.0_rp*beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1186  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1187  theta_b1(iw) = w1(iw)/w2(iw) * ( w3(iw)/w4(iw) )**(2.0_rp*beta_v(iw,2))
1188  end do
1189  !
1190  ! stochastic coefficient for terminal velocity
1191  ! sb06(93) -- riming( collide with others )
1192  do iw=i_qc,i_qg
1193  n = 0
1194  w1(iw) = gammafunc( (beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1195  w2(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1196  w3(iw) = gammafunc( (beta_v(iw,2) + 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
1197  w4(iw) = gammafunc( ( 2.0_rp*b_rea(iw) + nu(iw) + 1.0_rp )/mu(iw) )
1198  !
1199  w5(iw) = gammafunc( (nu(iw) + 1.0_rp)/mu(iw) )
1200  w6(iw) = gammafunc( (nu(iw) + 2.0_rp)/mu(iw) )
1201  n = 1
1202  w7(iw) = gammafunc( (beta_v(iw,2) + b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1203  w8(iw) = gammafunc( ( b_rea(iw) + nu(iw) + 1.0_rp + n)/mu(iw) )
1204  end do
1205  ! ia > ib ( larger particles "a" catch smaller particles "b" )
1206  do ia=i_qc,i_qg
1207  do ib=i_qc,i_qg
1208  theta_ab0(ia,ib) = 2.0_rp * (w1(ib)/w2(ib))*(w3(ia)/w4(ia)) &
1209  * (w5(ia)/w6(ia))**beta_v(ia,2) &
1210  * (w5(ib)/w6(ib))**beta_v(ib,2)
1211  theta_ab1(ia,ib) = 2.0_rp * (w7(ib)/w8(ib))*(w3(ia)/w4(ia)) &
1212  * (w5(ia)/w6(ia))**beta_v(ia,2) &
1213  * (w5(ib)/w6(ib))**beta_v(ib,2)
1214  end do
1215  end do
1216 
1217  deallocate(w1,w2,w3,w4,w5,w6,w7,w8)
1218 
1219  if( io_l ) write(io_fid_log,'(100a16)') "LABEL ",wlabel(:)
1220  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "capacity ",cap(:) ! [Add] 11/08/30 T.Mitsui
1221  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_m2 ",coef_m2(:)
1222  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_d ",coef_d(:)
1223  !
1224  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_d3 ",coef_d3(:)
1225  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_d6 ",coef_d6(:)
1226  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_d2v ",coef_d2v(:)
1227  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_md2v ",coef_md2v(:)
1228  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "a_d2vt ",a_d2vt(:)
1229  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "b_d2vt ",b_d2vt(:)
1230  !
1231  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_r2 ",coef_r2(:)
1232  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_r3 ",coef_r3(:)
1233  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_re ",coef_re(:)
1234  !
1235  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "a_area ",a_area(:)
1236  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "b_area ",b_area(:)
1237  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "ax_area ",ax_area(:)
1238  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "bx_area ",bx_area(:)
1239  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "a_rea ",a_rea(:)
1240  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "b_rea ",b_rea(:)
1241  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "a_rea3 ",a_rea3(:)
1242  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "b_rea3 ",b_rea3(:)
1243  !
1244  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_rea2 ",coef_rea2(:)
1245  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_rea3 ",coef_rea3(:)
1246  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_vt0 ",coef_vt0(:,1)
1247  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_vt1 ",coef_vt1(:,1)
1248  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_A ",coef_a(:)
1249  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "coef_lambda ",coef_lambda(:)
1250 
1251  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "ah_vent0 sml",ah_vent0(:,1)
1252  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "ah_vent0 lrg",ah_vent0(:,2)
1253  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "ah_vent1 sml",ah_vent1(:,1)
1254  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "ah_vent1 lrg",ah_vent1(:,2)
1255  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "bh_vent0 sml",bh_vent0(:,1)
1256  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "bh_vent0 lrg",bh_vent0(:,2)
1257  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "bh_vent1 sml",bh_vent1(:,1)
1258  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "bh_vent1 lrg",bh_vent1(:,2)
1259 
1260  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "delta_b0 ",delta_b0(:)
1261  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "delta_b1 ",delta_b1(:)
1262  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "theta_b0 ",theta_b0(:)
1263  if( io_l ) write(io_fid_log,'(a,100ES16.6)') "theta_b1 ",theta_b1(:)
1264 
1265  do ia=qqs,qqe
1266  if( io_l ) write(io_fid_log,'(a,a10,a,100ES16.6)') "delta0(a,b)=(",trim(wlabel(ia)),",b)=",(delta_ab0(ia,ib),ib=qqs,qqe)
1267  enddo
1268  do ia=qqs,qqe
1269  if( io_l ) write(io_fid_log,'(a,a10,a,100ES16.6)') "delta1(a,b)=(",trim(wlabel(ia)),",b)=",(delta_ab1(ia,ib),ib=qqs,qqe)
1270  enddo
1271  do ia=qqs,qqe
1272  if( io_l ) write(io_fid_log,'(a,a10,a,100ES16.6)') "theta0(a,b)=(",trim(wlabel(ia)),",b)=",(theta_ab0(ia,ib),ib=qqs,qqe)
1273  enddo
1274  do ia=qqs,qqe
1275  if( io_l ) write(io_fid_log,'(a,a10,a,100ES16.6)') "theta1(a,b)=(",trim(wlabel(ia)),",b)=",(theta_ab1(ia,ib),ib=qqs,qqe)
1276  enddo
1277 
1278  return
1279  end subroutine mp_sn14_init
1280  !-----------------------------------------------------------------------------
1281  subroutine mp_sn14 ( &
1282  DENS, &
1283  MOMZ, &
1284  MOMX, &
1285  MOMY, &
1286  RHOT, &
1287  QTRC, &
1288  CCN, &
1289  EVAPORATE, &
1290  SFLX_rain, &
1291  SFLX_snow )
1292  use scale_time, only: &
1294  use scale_grid, only: &
1295  z => grid_cz, &
1296  dz => grid_cdz
1297  use scale_atmos_phy_mp_common, only: &
1298  mp_precipitation => atmos_phy_mp_precipitation
1299  use scale_atmos_thermodyn, only: &
1300  aq_cv, &
1301  aq_cp
1302  use scale_atmos_saturation, only: &
1303  moist_psat_liq => atmos_saturation_psat_liq, &
1304  moist_psat_ice => atmos_saturation_psat_ice
1305  implicit none
1306 
1307  real(RP), intent(inout) :: DENS(ka,ia,ja)
1308  real(RP), intent(inout) :: MOMZ(ka,ia,ja)
1309  real(RP), intent(inout) :: MOMX(ka,ia,ja)
1310  real(RP), intent(inout) :: MOMY(ka,ia,ja)
1311  real(RP), intent(inout) :: RHOT(ka,ia,ja)
1312  real(RP), intent(inout) :: QTRC(ka,ia,ja,qa)
1313  real(RP), intent(in) :: CCN(ka,ia,ja)
1314  real(RP), intent(out) :: EVAPORATE(ka,ia,ja)
1315  real(RP), intent(out) :: SFLX_rain(ia,ja)
1316  real(RP), intent(out) :: SFLX_snow(ia,ja)
1317 
1318  !
1319  ! primary variables
1320  !
1321  real(RP) :: rhoq(qa,ka,ia,ja)
1322  real(RP) :: pott (ka,ia,ja)
1323  !
1324  ! diagnostic variables
1325  !
1326  real(RP) :: qdry(ka,ia,ja)
1327  real(RP) :: temp(ka,ia,ja)
1328  real(RP) :: pres(ka,ia,ja)
1329  real(RP) :: rhoe(ka,ia,ja)
1330  real(RP) :: velz(ka,ia,ja)
1331  !
1332  real(RP) :: rhoq2(qa,ka,ia,ja)
1333  !
1334  real(RP) :: xq(5,ka,ia,ja)
1335  !
1336  real(RP) :: dq_xa(5,ka,ia,ja)
1337  real(RP) :: vt_xa(5,2,ka,ia,ja) ! terminal velocity
1338 
1339  real(RP) :: wtemp(ka,ia,ja) ! filtered temperature
1340  real(RP) :: esw(ka,ia,ja) ! saturated vapor pressure(water)
1341  real(RP) :: esi(ka,ia,ja) ! saturated vapor pressure(ice)
1342  !
1343  real(RP) :: rho_fac
1344  real(RP) :: rho_fac_q(5,ka,ia,ja) ! factor for tracers, 1:cloud, 2:rain, 3:ice, 4: snow, 5:graupel
1345  real(RP) :: cva(ka,ia,ja) !
1346  real(RP) :: cpa(ka,ia,ja) ! [Add] 09/08/18 T.Mitsui
1347  !
1348  real(RP) :: drhogqv ! d (rho*qv*gsgam2)
1349  real(RP) :: drhogqc, drhognc ! qc, nc
1350  real(RP) :: drhogqr, drhognr ! qr, nr
1351  real(RP) :: drhogqi, drhogni ! qi, ni
1352  real(RP) :: drhogqs, drhogns ! qs, ns
1353  real(RP) :: drhogqg, drhogng ! qg, ng
1354 
1355  ! production rate
1356  real(RP) :: PQ(pq_max,ka,ia,ja)
1357 
1358  real(RP) :: wrm_dqc, wrm_dnc
1359  real(RP) :: wrm_dqr, wrm_dnr
1360 
1361  ! production rate of mixed-phase collection process
1362  real(RP) :: Pac(pac_max,ka,ia,ja)
1363 
1364  real(RP) :: gc_dqc, gc_dnc
1365  real(RP) :: sc_dqc, sc_dnc
1366  real(RP) :: ic_dqc, ic_dnc
1367  real(RP) :: rg_dqg, rg_dng
1368  real(RP) :: rg_dqr, rg_dnr
1369  real(RP) :: rs_dqr, rs_dnr, rs_dqs, rs_dns
1370  real(RP) :: ri_dqr, ri_dnr
1371  real(RP) :: ri_dqi, ri_dni
1372  real(RP) :: ii_dqi, ii_dni
1373  real(RP) :: is_dqi, is_dni, ss_dns
1374  real(RP) :: gs_dqs, gs_dns, gg_dng
1375  ! mixed-phase collection process total plus(clp_), total minus(clm_)
1376  real(RP) :: clp_dqc, clp_dnc, clm_dqc, clm_dnc
1377  real(RP) :: clp_dqr, clp_dnr, clm_dqr, clm_dnr
1378  real(RP) :: clp_dqi, clp_dni, clm_dqi, clm_dni
1379  real(RP) :: clp_dqs, clp_dns, clm_dqs, clm_dns
1380  real(RP) :: clp_dqg, clp_dng, clm_dqg, clm_dng
1381  real(RP) :: fac1, fac3, fac4, fac6, fac7, fac9, fac10
1382  ! production rate of partial conversion(ice, snow => graupel)
1383  real(RP) :: pco_dqi, pco_dni
1384  real(RP) :: pco_dqs, pco_dns
1385  real(RP) :: pco_dqg, pco_dng
1386  ! production rate of enhanced melting due to
1387  real(RP) :: eml_dqc, eml_dnc
1388  real(RP) :: eml_dqr, eml_dnr
1389  real(RP) :: eml_dqi, eml_dni
1390  real(RP) :: eml_dqs, eml_dns
1391  real(RP) :: eml_dqg, eml_dng
1392  ! production rate of ice multiplication by splintering
1393  real(RP) :: spl_dqi, spl_dni
1394  real(RP) :: spl_dqg, spl_dqs
1395 
1396  real(RP) :: rrho(ka,ia,ja)
1397 
1398  !-----------------------------------------------
1399  ! work for explicit supersaturation modeling
1400  !-----------------------------------------------
1401  real(RP) :: dTdt_equiv_d(ka,ia,ja) !
1402  !--------------------------------------------------
1403  !
1404  ! variables for output
1405  !
1406  !--------------------------------------------------
1407  ! work for column production term
1408  real(RP) :: sl_PLCdep(ia,ja)
1409  real(RP) :: sl_PLRdep(ia,ja), sl_PNRdep(ia,ja) !
1410  !--------------------------------------------------
1411  real(RP) :: qke_d(ka,ia,ja)
1412 
1413  real(RP), parameter :: eps = 1.e-19_rp
1414  real(RP), parameter :: eps_qv = 1.e-19_rp
1415  real(RP), parameter :: eps_rhoge = 1.e-19_rp
1416  real(RP), parameter :: eps_rhog = 1.e-19_rp
1417  integer :: ntdiv
1418 
1419  real(RP) :: Rmoist
1420 
1421  real(RP) :: velw(ka,ia,ja,qa)
1422  real(RP) :: FLX_rain (ka,ia,ja)
1423  real(RP) :: FLX_snow (ka,ia,ja)
1424  real(RP) :: FLX_tot (ka,ia,ja)
1425  real(RP) :: wflux_rain(ka,ia,ja)
1426  real(RP) :: wflux_snow(ka,ia,ja)
1427  integer :: step
1428 
1429  real(RP) :: sw
1430 
1431  integer :: k, i, j, iq
1432  !---------------------------------------------------------------------------
1433 
1434  !============================================================================
1435  !
1436  !-- Each process is integrated sequentially.
1437  ! 1. Nucleation and filter
1438  ! 2. Phase change
1439  ! 3. Collection
1440  ! 4. Saturation adjustment( only for qc, nc )
1441  ! 5. Sedimentation
1442  ! 6. filter( keep non-negative value for radiation scheme )
1443  ! 0. calculation of optical moments
1444  !
1445  !============================================================================
1446  !----------------------------------------------------------------------------
1447  !
1448  ! 1.Nucleation of cloud water and cloud ice
1449  !
1450  !----------------------------------------------------------------------------
1451  call prof_rapstart('MP_Preprocess', 3)
1452 
1453  do j = js, je
1454  do i = is, ie
1455  do k = ks, ke
1456  do iq = 1, qa
1457  rhoq(iq,k,i,j) = dens(k,i,j) * qtrc(k,i,j,iq)
1458  enddo
1459  rhoq2(i_qv,k,i,j) = dens(k,i,j)*qtrc(k,i,j,i_qv)
1460  rhoq2(i_ni,k,i,j) = max( 0.0_rp, dens(k,i,j)*qtrc(k,i,j,i_ni) )
1461  rhoq2(i_nc,k,i,j) = max( 0.0_rp, dens(k,i,j)*qtrc(k,i,j,i_nc) )
1462  enddo
1463  enddo
1464  enddo
1465 
1466  do j = js, je
1467  do i = is, ie
1468  velz(ks-1,i,j) = 0.0_rp
1469  do k = ks, ke-1
1470  velz(k,i,j) = momz(k,i,j) / ( dens(k,i,j) + dens(k+1,i,j) ) * 2.0_rp
1471  enddo
1472  velz(ke,i,j) = 0.0_rp
1473  end do
1474  end do
1475 
1476  do j = js, je
1477  do i = is, ie
1478  do k = ks, ke
1479  rrho(k,i,j) = 1.0_rp / dens(k,i,j)
1480  pott(k,i,j) = rhot(k,i,j) * rrho(k,i,j)
1481  calc_qdry( qdry(k,i,j), qtrc, k, i, j, iq )
1482  calc_cv( cva(k,i,j), qdry(k,i,j), qtrc, k, i, j, iq, cvdry, aq_cv )
1483  calc_r( rmoist, qtrc(k,i,j,i_qv), qdry(k,i,j), rdry, rvap )
1484  cpa(k,i,j) = cva(k,i,j) + rmoist
1485  calc_pre( pres(k,i,j), dens(k,i,j), pott(k,i,j), rmoist, cpa(k,i,j), p00 )
1486  temp(k,i,j) = pres(k,i,j) / ( dens(k,i,j) * rmoist )
1487  rhoe(k,i,j) = dens(k,i,j) * temp(k,i,j) * cva(k,i,j)
1488  wtemp(k,i,j) = max(temp(k,i,j), tem_min)
1489  enddo
1490  enddo
1491  enddo
1492 
1493  if( opt_debug_tem ) call debug_tem_kij( 1, temp(:,:,:), dens(:,:,:), pres(:,:,:), qtrc(:,:,:,i_qv) )
1494 
1495  do j = js, je
1496  do i = is, ie
1497  do k = ks, ke
1498  rho_fac = rho_0 / max(dens(k,i,j),rho_min)
1499  rho_fac_q(i_c,k,i,j) = rho_fac**gamma_v(i_qc)
1500  rho_fac_q(i_r,k,i,j) = rho_fac**gamma_v(i_qr)
1501  rho_fac_q(i_i,k,i,j) = (pres(k,i,j)/pre0_vt)**a_pre0_vt * (temp(k,i,j)/tem0_vt)**a_tem0_vt
1502  rho_fac_q(i_s,k,i,j) = rho_fac_q(i_i,k,i,j)
1503  rho_fac_q(i_g,k,i,j) = rho_fac_q(i_i,k,i,j)
1504  enddo
1505  enddo
1506  enddo
1507 
1508 !OCL XFILL
1509  do j = js, je
1510  do i = is, ie
1511  sl_plcdep(i,j) = 0.0_rp
1512  sl_plrdep(i,j) = 0.0_rp
1513  sl_pnrdep(i,j) = 0.0_rp
1514  end do
1515  end do
1516 
1517 !OCL XFILL
1518  do j = js, je
1519  do i = is, ie
1520  do k = ks, ke
1521  qke_d(k,i,j) = 0.0_rp ! 2*TKE
1522  enddo
1523  enddo
1524  enddo
1525 
1526 !OCL XFILL
1527  do j = js, je
1528  do i = is, ie
1529  do k = ks, ke
1530  dtdt_equiv_d(k,i,j) = 0.0_rp
1531  enddo
1532  enddo
1533  enddo
1534 
1535  call prof_rapend ('MP_Preprocess', 3)
1536 
1537  call prof_rapstart('MP_Nucleation', 3)
1538 
1539  call nucleation_kij( &
1540  z, velz, & ! in
1541  dens, wtemp, pres, & ! in
1542  rhoq2, & ! (in)
1543  pq, & ! out
1544  cpa, & ! in
1545  dtdt_equiv_d, & ! in
1546  qke_d, & ! in
1547  ccn, & ! in
1548  dt ) ! in
1549 
1550  do j = js, je
1551  do i = is, ie
1552  do k = ks, ke
1553  ! nucleation
1554  drhogqc = dt * pq(i_lcccn,k,i,j)
1555  drhognc = dt * pq(i_ncccn,k,i,j)
1556  drhogqi = dt * pq(i_liccn,k,i,j)
1557  drhogni = dt * pq(i_niccn,k,i,j)
1558  drhogqv = max( -rhoq(i_qv,k,i,j), -drhogqc-drhogqi )
1559  fac1 = drhogqv / min( -drhogqc-drhogqi, -eps ) ! limiting coefficient
1560 
1561  rhoq(i_qv,k,i,j) = rhoq(i_qv,k,i,j) + drhogqv
1562  rhoq(i_qc,k,i,j) = max(0.0_rp, rhoq(i_qc,k,i,j) + drhogqc*fac1)
1563  rhoq(i_qi,k,i,j) = max(0.0_rp, rhoq(i_qi,k,i,j) + drhogqi*fac1)
1564  rhoq(i_nc,k,i,j) = max(0.0_rp, rhoq(i_nc,k,i,j) + drhognc)
1565  rhoq(i_ni,k,i,j) = max(0.0_rp, rhoq(i_ni,k,i,j) + drhogni)
1566 
1567  ! cloud number concentration filter
1568  rhoq(i_nc,k,i,j) = min( rhoq(i_nc,k,i,j), nc_uplim_d(1,i,j) )
1569 
1570  rhoe(k,i,j) = rhoe(k,i,j) - lhv * drhogqv + lhf * drhogqi*fac1
1571 
1572  qtrc(k,i,j,i_qv) = rhoq(i_qv,k,i,j) * rrho(k,i,j)
1573  qtrc(k,i,j,i_qc) = rhoq(i_qc,k,i,j) * rrho(k,i,j)
1574  qtrc(k,i,j,i_qi) = rhoq(i_qi,k,i,j) * rrho(k,i,j)
1575  qtrc(k,i,j,i_nc) = rhoq(i_nc,k,i,j) * rrho(k,i,j)
1576  qtrc(k,i,j,i_ni) = rhoq(i_ni,k,i,j) * rrho(k,i,j)
1577 
1578  calc_qdry( qdry(k,i,j), qtrc, k, i, j, iq )
1579  calc_cv( cva(k,i,j), qdry(k,i,j), qtrc, k, i, j, iq, cvdry, aq_cv )
1580  calc_r( rmoist, qtrc(k,i,j,i_qv), qdry(k,i,j), rdry, rvap )
1581  temp(k,i,j) = rhoe(k,i,j) / ( dens(k,i,j) * cva(k,i,j) )
1582  pres(k,i,j) = dens(k,i,j) * rmoist * temp(k,i,j)
1583  wtemp(k,i,j) = max( temp(k,i,j), tem_min )
1584  enddo
1585  enddo
1586  enddo
1587 
1588 ! if( opt_debug ) call debugreport_nucleation
1589  if( opt_debug_tem ) call debug_tem_kij( 2, temp(:,:,:), dens(:,:,:), pres(:,:,:), qtrc(:,:,:,i_qv) )
1590 
1591 
1592  call prof_rapend ('MP_Nucleation', 3)
1593  !----------------------------------------------------------------------------
1594  !
1595  ! 2.Phase change: Freezing, Melting, Vapor deposition
1596  !
1597  !----------------------------------------------------------------------------
1598  call prof_rapstart('MP_Phase_change', 3)
1599 
1600  do j = js, je
1601  do i = is, ie
1602  do k = ks, ke
1603  rhoq2(i_qr,k,i,j) = rhoq(i_qr,k,i,j)
1604  rhoq2(i_nr,k,i,j) = rhoq(i_nr,k,i,j)
1605  xq(i_r,k,i,j) = max(xr_min, min(xr_max, rhoq2(i_qr,k,i,j)/(rhoq2(i_nr,k,i,j)+nr_min) ))
1606 
1607  dq_xa(i_r,k,i,j) = a_m(i_qr)*xq(i_r,k,i,j)**b_m(i_qr)
1608  vt_xa(i_r,1,k,i,j) = alpha_v(i_qr,1)*(xq(i_r,k,i,j)**beta_v(i_qr,1))*rho_fac_q(i_r,k,i,j)
1609  vt_xa(i_r,2,k,i,j) = vt_xa(i_r,1,k,i,j)
1610 
1611  !! Following values shoud be already filtered to be non-zero before sbroutine was called.
1612  ! Mass concentration [kg/m3]
1613  rhoq2(i_qv,k,i,j) = rhoq(i_qv,k,i,j)
1614  rhoq2(i_qc,k,i,j) = rhoq(i_qc,k,i,j)
1615  rhoq2(i_qi,k,i,j) = rhoq(i_qi,k,i,j)
1616  rhoq2(i_qs,k,i,j) = rhoq(i_qs,k,i,j)
1617  rhoq2(i_qg,k,i,j) = rhoq(i_qg,k,i,j)
1618  ! Number concentration[/m3] (should be filtered to avoid zero division.)
1619  rhoq2(i_nc,k,i,j) = rhoq(i_nc,k,i,j)
1620  rhoq2(i_ni,k,i,j) = rhoq(i_ni,k,i,j)
1621  rhoq2(i_ns,k,i,j) = rhoq(i_ns,k,i,j)
1622  rhoq2(i_ng,k,i,j) = rhoq(i_ng,k,i,j)
1623 
1624  ! Mass of mean particle [kg]
1625  ! SB06(94)
1626  !
1627  xq(i_c,k,i,j) = min(xc_max, max(xc_min, rhoq2(i_qc,k,i,j)/(rhoq2(i_nc,k,i,j)+nc_min) ))
1628  xq(i_i,k,i,j) = min(xi_max, max(xi_min, rhoq2(i_qi,k,i,j)/(rhoq2(i_ni,k,i,j)+ni_min) ))
1629  xq(i_s,k,i,j) = min(xs_max, max(xs_min, rhoq2(i_qs,k,i,j)/(rhoq2(i_ns,k,i,j)+ns_min) ))
1630  xq(i_g,k,i,j) = min(xg_max, max(xg_min, rhoq2(i_qg,k,i,j)/(rhoq2(i_ng,k,i,j)+ng_min) ))
1631  ! diamter of average mass
1632  ! SB06(32)
1633  dq_xa(i_c,k,i,j) = a_m(i_qc)*xq(i_c,k,i,j)**b_m(i_qc)
1634  dq_xa(i_i,k,i,j) = a_m(i_qi)*xq(i_i,k,i,j)**b_m(i_qi)
1635  dq_xa(i_s,k,i,j) = a_m(i_qs)*xq(i_s,k,i,j)**b_m(i_qs)
1636  dq_xa(i_g,k,i,j) = a_m(i_qg)*xq(i_g,k,i,j)**b_m(i_qg)
1637 
1638  ! terminal velocity of average mass
1639  vt_xa(i_c,1,k,i,j) = alpha_v(i_qc,1)*(xq(i_c,k,i,j)**beta_v(i_qc,1))*rho_fac_q(i_c,k,i,j)
1640  vt_xa(i_i,1,k,i,j) = alpha_v(i_qi,1)*(xq(i_i,k,i,j)**beta_v(i_qi,1))*rho_fac_q(i_i,k,i,j)
1641  vt_xa(i_s,1,k,i,j) = alpha_v(i_qs,1)*(xq(i_s,k,i,j)**beta_v(i_qs,1))*rho_fac_q(i_s,k,i,j)
1642  vt_xa(i_g,1,k,i,j) = alpha_v(i_qg,1)*(xq(i_g,k,i,j)**beta_v(i_qg,1))*rho_fac_q(i_g,k,i,j)
1643  vt_xa(i_c,2,k,i,j) = alpha_v(i_qc,2)*(xq(i_c,k,i,j)**beta_v(i_qc,2))*rho_fac_q(i_c,k,i,j)
1644  vt_xa(i_i,2,k,i,j) = alpha_v(i_qi,2)*(xq(i_i,k,i,j)**beta_v(i_qi,2))*rho_fac_q(i_i,k,i,j)
1645  vt_xa(i_s,2,k,i,j) = alpha_v(i_qs,2)*(xq(i_s,k,i,j)**beta_v(i_qs,2))*rho_fac_q(i_s,k,i,j)
1646  vt_xa(i_g,2,k,i,j) = alpha_v(i_qg,2)*(xq(i_g,k,i,j)**beta_v(i_qg,2))*rho_fac_q(i_g,k,i,j)
1647 
1648  end do
1649  end do
1650  end do
1651 
1652  call moist_psat_liq( esw, wtemp )
1653  call moist_psat_ice( esi, wtemp )
1654 
1655  call freezing_water_kij( &
1656  dt, & ! in
1657  pq, & ! out
1658  rhoq2, xq, temp ) ! in
1659 
1660  call dep_vapor_melt_ice_kij( &
1661  pq, & ! out
1662  dens, wtemp, pres, qdry, & ! in
1663  rhoq2, & ! in
1664  esw, esi, & ! in
1665  xq, & ! in
1666  vt_xa, & ! in
1667  dq_xa ) ! in
1668 
1669  !
1670  ! update subroutine
1671  !
1673  ntdiv, ntmax_phase_change, & ! in
1674  dt, & ! in
1675  gsgam2_d, & ! in
1676  z, & ! in
1677  dz, & ! in
1678  velz, & ! in
1679  dtdt_equiv_d, & ! in
1680  dens, & ! in
1681  rhoe, & ! inout
1682  rhoq, qtrc, & ! inout
1683  temp, pres, & ! inout
1684  cva, & ! out
1685  esw, esi, rhoq2, & ! in
1686  pq, & ! inout
1687  evaporate, & ! out
1688  sl_plcdep, & ! inout
1689  sl_plrdep, sl_pnrdep ) ! inout
1690 
1691 ! if( opt_debug ) call debugreport_phasechange
1692  if( opt_debug_tem ) call debug_tem_kij( 3, temp(:,:,:), dens(:,:,:), pres(:,:,:), qtrc(:,:,:,i_qv) )
1693 
1694  call prof_rapend ('MP_Phase_change', 3)
1695 
1696  !---------------------------------------------------------------------------
1697  !
1698  ! 3.Collection process
1699  !
1700  !---------------------------------------------------------------------------
1701  call prof_rapstart('MP_Collection', 3)
1702 
1703  ! parameter setting
1704  do j = js, je
1705  do i = is, ie
1706  do k = ks, ke
1707  ! Mass concentration [kg/m3]
1708  rhoq2(i_qv,k,i,j) = rhoq(i_qv,k,i,j)
1709  rhoq2(i_qc,k,i,j) = rhoq(i_qc,k,i,j)
1710  rhoq2(i_qr,k,i,j) = rhoq(i_qr,k,i,j)
1711  rhoq2(i_qi,k,i,j) = rhoq(i_qi,k,i,j)
1712  rhoq2(i_qs,k,i,j) = rhoq(i_qs,k,i,j)
1713  rhoq2(i_qg,k,i,j) = rhoq(i_qg,k,i,j)
1714  ! Number concentration[/m3]
1715  rhoq2(i_nc,k,i,j) = rhoq(i_nc,k,i,j)
1716  rhoq2(i_nr,k,i,j) = rhoq(i_nr,k,i,j)
1717  rhoq2(i_ni,k,i,j) = rhoq(i_ni,k,i,j)
1718  rhoq2(i_ns,k,i,j) = rhoq(i_ns,k,i,j)
1719  rhoq2(i_ng,k,i,j) = rhoq(i_ng,k,i,j)
1720 
1721  ! Mass of mean particle [kg]
1722  xq(i_c,k,i,j) = min(xc_max, max(xc_min, rhoq2(i_qc,k,i,j)/(rhoq2(i_nc,k,i,j)+nc_min) ) )
1723  xq(i_r,k,i,j) = min(xr_max, max(xr_min, rhoq2(i_qr,k,i,j)/(rhoq2(i_nr,k,i,j)+nr_min) ) )
1724  xq(i_i,k,i,j) = min(xi_max, max(xi_min, rhoq2(i_qi,k,i,j)/(rhoq2(i_ni,k,i,j)+ni_min) ) )
1725  xq(i_s,k,i,j) = min(xs_max, max(xs_min, rhoq2(i_qs,k,i,j)/(rhoq2(i_ns,k,i,j)+ns_min) ) )
1726  xq(i_g,k,i,j) = min(xg_max, max(xg_min, rhoq2(i_qg,k,i,j)/(rhoq2(i_ng,k,i,j)+ng_min) ) )
1727 
1728  ! effective cross section is assume as area equivalent circle
1729  dq_xa(i_c,k,i,j) = 2.0_rp*a_rea(i_qc)*xq(i_c,k,i,j)**b_rea(i_qc)
1730  dq_xa(i_r,k,i,j) = 2.0_rp*a_rea(i_qr)*xq(i_r,k,i,j)**b_rea(i_qr)
1731  dq_xa(i_i,k,i,j) = 2.0_rp*a_rea(i_qi)*xq(i_i,k,i,j)**b_rea(i_qi)
1732  dq_xa(i_s,k,i,j) = 2.0_rp*a_rea(i_qs)*xq(i_s,k,i,j)**b_rea(i_qs)
1733  dq_xa(i_g,k,i,j) = 2.0_rp*a_rea(i_qg)*xq(i_g,k,i,j)**b_rea(i_qg)
1734 
1735  ! terminal velocity of average mass
1736  ! SB06(33)
1737  vt_xa(i_c,2,k,i,j) = alpha_v(i_qc,2)*(xq(i_c,k,i,j)**beta_v(i_qc,2))*rho_fac_q(i_c,k,i,j)
1738  vt_xa(i_r,2,k,i,j) = alpha_v(i_qr,2)*(xq(i_r,k,i,j)**beta_v(i_qr,2))*rho_fac_q(i_r,k,i,j)
1739  vt_xa(i_i,2,k,i,j) = alpha_v(i_qi,2)*(xq(i_i,k,i,j)**beta_v(i_qi,2))*rho_fac_q(i_i,k,i,j)
1740  vt_xa(i_s,2,k,i,j) = alpha_v(i_qs,2)*(xq(i_s,k,i,j)**beta_v(i_qs,2))*rho_fac_q(i_s,k,i,j)
1741  vt_xa(i_g,2,k,i,j) = alpha_v(i_qg,2)*(xq(i_g,k,i,j)**beta_v(i_qg,2))*rho_fac_q(i_g,k,i,j)
1742  enddo
1743  enddo
1744  enddo
1745 
1746  ! Auto-conversion, Accretion, Self-collection, Break-up
1747  ! [Mod] T.Seiki
1748  if ( mp_doautoconversion ) then
1749  call aut_acc_slc_brk_kij( &
1750  pq, &
1751  rhoq2, xq, dq_xa, &
1752  dens )
1753  else
1754 !OCL XFILL
1755  do j = js, je
1756  do i = is, ie
1757  do k = ks, ke
1758  pq(i_lcaut,k,i,j) = 0.0_rp
1759  pq(i_ncaut,k,i,j) = 0.0_rp
1760  pq(i_nraut,k,i,j) = 0.0_rp
1761  pq(i_lcacc,k,i,j) = 0.0_rp
1762  pq(i_ncacc,k,i,j) = 0.0_rp
1763  pq(i_nrslc,k,i,j) = 0.0_rp
1764  pq(i_nrbrk,k,i,j) = 0.0_rp
1765  end do
1766  end do
1767  end do
1768  endif
1769 
1771  ! collection process
1772  pac, pq, & ! out
1773  temp, rhoq2, & ! in
1774  xq, dq_xa, vt_xa ) ! in
1775 ! DENS(:,:,:), ) ! in
1776 
1777  call ice_multiplication_kij( &
1778  pq, & ! out
1779  pac, & ! in
1780  temp, rhoq2, xq ) ! in
1781 
1782  !
1783  ! update
1784  ! rhogq = l*gsgam
1785  !
1786  profile_start("sn14_update_rhoq")
1787  do j = js, je
1788  do i = is, ie
1789  do k = ks, ke
1790 
1791  ! warm collection process
1792  wrm_dqc = max( dt*( pq(i_lcaut,k,i,j)+pq(i_lcacc,k,i,j) ), -rhoq2(i_qc,k,i,j) )
1793  wrm_dnc = max( dt*( pq(i_ncaut,k,i,j)+pq(i_ncacc,k,i,j) ), -rhoq2(i_nc,k,i,j) )
1794  wrm_dnr = max( dt*( pq(i_nraut,k,i,j)+pq(i_nrslc,k,i,j)+pq(i_nrbrk,k,i,j) ), -rhoq2(i_nr,k,i,j) )
1795  wrm_dqr = -wrm_dqc
1796  ! mixed phase collection
1797  ! Pxxacyy2zz xx and yy decrease and zz increase .
1798  !
1799  ! At first fixer is applied to decreasing particles.
1800  ! order of fixer: graupel-cloud, snow-cloud, ice-cloud, graupel-rain, snow-rain, ice-rain,
1801  ! snow-ice, ice-ice, graupel-snow, snow-snow
1802  ! cloud mass decrease
1803  gc_dqc = max( dt*pac(i_lgaclc2lg,k,i,j) , min(0.0_rp, -rhoq2(i_qc,k,i,j)-wrm_dqc )) ! => dqg
1804  sc_dqc = max( dt*pac(i_lsaclc2ls,k,i,j) , min(0.0_rp, -rhoq2(i_qc,k,i,j)-wrm_dqc-gc_dqc )) ! => dqs
1805  ic_dqc = max( dt*pac(i_liaclc2li,k,i,j) , min(0.0_rp, -rhoq2(i_qc,k,i,j)-wrm_dqc-gc_dqc-sc_dqc )) ! => dqi
1806  ! cloud num. decrease
1807  gc_dnc = max( dt*pac(i_ngacnc2ng,k,i,j) , min(0.0_rp, -rhoq2(i_nc,k,i,j)-wrm_dnc )) ! => dnc:minus
1808  sc_dnc = max( dt*pac(i_nsacnc2ns,k,i,j) , min(0.0_rp, -rhoq2(i_nc,k,i,j)-wrm_dnc-gc_dnc )) ! => dnc:minus
1809  ic_dnc = max( dt*pac(i_niacnc2ni,k,i,j) , min(0.0_rp, -rhoq2(i_nc,k,i,j)-wrm_dnc-gc_dnc-sc_dnc )) ! => dnc:minus
1810 
1811  ! rain mass decrease ( tem < 273.15K)
1812  sw = sign(0.5_rp, t00-temp(k,i,j)) + 0.5_rp ! if( temp(k,i,j) <= T00 )then sw=1, else sw=0
1813  rg_dqr = max( dt*pac(i_lraclg2lg, k,i,j), min(0.0_rp, -rhoq2(i_qr,k,i,j)-wrm_dqr )) * sw
1814  rg_dqg = max( dt*pac(i_lraclg2lg, k,i,j), min(0.0_rp, -rhoq2(i_qg,k,i,j) )) * ( 1.0_rp - sw )
1815  rs_dqr = max( dt*pac(i_lracls2lg_r,k,i,j), min(0.0_rp, -rhoq2(i_qr,k,i,j)-wrm_dqr-rg_dqr )) * sw
1816  ri_dqr = max( dt*pac(i_lracli2lg_r,k,i,j), min(0.0_rp, -rhoq2(i_qr,k,i,j)-wrm_dqr-rg_dqr-rs_dqr )) * sw
1817  ! rain num. decrease
1818  rg_dnr = max( dt*pac(i_nracng2ng, k,i,j), min(0.0_rp, -rhoq2(i_nr,k,i,j)-wrm_dnr )) * sw
1819  rg_dng = max( dt*pac(i_nracng2ng, k,i,j), min(0.0_rp, -rhoq2(i_ng,k,i,j) )) * ( 1.0_rp - sw )
1820  rs_dnr = max( dt*pac(i_nracns2ng_r,k,i,j), min(0.0_rp, -rhoq2(i_nr,k,i,j)-wrm_dnr-rg_dnr )) * sw
1821  ri_dnr = max( dt*pac(i_nracni2ng_r,k,i,j), min(0.0_rp, -rhoq2(i_nr,k,i,j)-wrm_dnr-rg_dnr-rs_dnr )) * sw
1822 
1823  ! ice mass decrease
1824  fac1 = (ri_dqr-eps)/ (dt*pac(i_lracli2lg_r,k,i,j)-eps) ! suppress factor by filter of rain
1825  ri_dqi = max( dt*pac(i_lracli2lg_i,k,i,j)*fac1, min(0.0_rp, -rhoq2(i_qi,k,i,j)+ic_dqc )) ! => dqg
1826  ii_dqi = max( dt*pac(i_liacli2ls,k,i,j) , min(0.0_rp, -rhoq2(i_qi,k,i,j)+ic_dqc-ri_dqi )) ! => dqs
1827  is_dqi = max( dt*pac(i_liacls2ls,k,i,j) , min(0.0_rp, -rhoq2(i_qi,k,i,j)+ic_dqc-ri_dqi-ii_dqi )) ! => dqs
1828  ! ice num. decrease
1829  fac4 = (ri_dnr-eps)/ (dt*pac(i_nracni2ng_r,k,i,j)-eps) ! suppress factor by filter of rain
1830  ri_dni = max( dt*pac(i_nracni2ng_i,k,i,j)*fac4, min(0.0_rp, -rhoq2(i_ni,k,i,j) )) ! => dni:minus
1831  ii_dni = max( dt*pac(i_niacni2ns,k,i,j) , min(0.0_rp, -rhoq2(i_ni,k,i,j)-ri_dni )) ! => dni:minus,dns:plus(*0.5)
1832  is_dni = max( dt*pac(i_niacns2ns,k,i,j) , min(0.0_rp, -rhoq2(i_ni,k,i,j)-ri_dni-ii_dni )) ! => dni:minus,dns:plus
1833  ! snow mass decrease
1834  fac3 = (rs_dqr-eps)/(dt*pac(i_lracls2lg_r,k,i,j)-eps) ! suppress factor by filter of rain
1835  rs_dqs = max( dt*pac(i_lracls2lg_s,k,i,j)*fac3, min(0.0_rp, -rhoq2(i_qs,k,i,j)+sc_dqc+ii_dqi+is_dqi )) ! => dqg
1836  gs_dqs = max( dt*pac(i_lgacls2lg,k,i,j) , min(0.0_rp, -rhoq2(i_qs,k,i,j)+sc_dqc+ii_dqi+is_dqi-rs_dqs )) ! => dqg
1837  ! snow num. decrease
1838  fac6 = (rs_dnr-eps)/(dt*pac(i_nracns2ng_r,k,i,j)-eps) ! suppress factor by filter of rain
1839 ! fac7 = (is_dni-eps)/(dt*Pac(I_NIacNS2NS, k,i,j)-eps) ! suppress factor by filter of ice
1840  rs_dns = max( dt*pac(i_nracns2ng_s,k,i,j)*fac6, min(0.0_rp, -rhoq2(i_ns,k,i,j)+0.50_rp*ii_dni+is_dni )) ! => dns:minus
1841  gs_dns = max( dt*pac(i_ngacns2ng,k,i,j) , min(0.0_rp, -rhoq2(i_ns,k,i,j)+0.50_rp*ii_dni+is_dni-rs_dns )) ! => dns:minus
1842  ss_dns = max( dt*pac(i_nsacns2ns,k,i,j) , min(0.0_rp, -rhoq2(i_ns,k,i,j)+0.50_rp*ii_dni+is_dni-rs_dns-gs_dns ))
1843  !
1844  gg_dng = max( dt*pac(i_ngacng2ng,k,i,j) , min(0.0_rp, -rhoq2(i_ng,k,i,j) ))
1845  !
1846  ! total plus in mixed phase collection(clp_)
1847  ! mass
1848  ! if( temp(k,i,j) <= T00 )then sw=1, else sw=0
1849  clp_dqc = 0.0_rp
1850  clp_dqr = (-rg_dqg-rs_dqs-ri_dqi) * (1.0_rp-sw)
1851  clp_dqi = -ic_dqc
1852  clp_dqs = -sc_dqc-ii_dqi-is_dqi
1853  clp_dqg = -gc_dqc -gs_dqs + (-rg_dqr-rs_dqr-rs_dqs-ri_dqr-ri_dqi) * sw
1854  ! num.( number only increase when a+b=>c, dnc=-dna)
1855  clp_dnc = 0.0_rp
1856  clp_dnr = 0.0_rp
1857  clp_dni = 0.0_rp
1858  clp_dns = -ii_dni*0.5_rp
1859  clp_dng = (-rs_dnr-ri_dnr) * sw
1860  ! total minus in mixed phase collection(clm_)
1861  ! mass
1862  clm_dqc = gc_dqc+sc_dqc+ic_dqc
1863  clm_dqr = (rg_dqr+rs_dqr+ri_dqr) * sw
1864  clm_dqi = ri_dqi+ii_dqi+is_dqi
1865  clm_dqs = rs_dqs+gs_dqs
1866  clm_dqg = rg_dqg * (1.0_rp-sw)
1867  ! num.
1868  clm_dnc = gc_dnc+sc_dnc+ic_dnc
1869  clm_dnr = (rg_dnr+rs_dnr+ri_dnr) * sw
1870  clm_dni = ri_dni+ii_dni+is_dni
1871  clm_dns = rs_dns+ss_dns+gs_dns
1872  clm_dng = gg_dng + rg_dng * (1.0_rp-sw)
1873 
1874  ! partial conversion
1875  ! 08/05/08 [Mod] T.Mitsui
1876  pco_dqi = max( dt*pq(i_licon,k,i,j), -clp_dqi )
1877  pco_dqs = max( dt*pq(i_lscon,k,i,j), -clp_dqs )
1878  pco_dqg = -pco_dqi-pco_dqs
1879  ! 08/05/08 [Mod] T.Mitsui
1880  pco_dni = max( dt*pq(i_nicon,k,i,j), -clp_dni )
1881  pco_dns = max( dt*pq(i_nscon,k,i,j), -clp_dns )
1882  pco_dng = -pco_dni-pco_dns
1883  ! enhanced melting ( always negative value )
1884  ! ice-cloud melting produces cloud, others produce rain
1885  eml_dqi = max( dt*pq(i_liacm,k,i,j), min(0.0_rp, -rhoq2(i_qi,k,i,j)-(clp_dqi+clm_dqi)-pco_dqi ))
1886  eml_dqs = max( dt*pq(i_lsacm,k,i,j), min(0.0_rp, -rhoq2(i_qs,k,i,j)-(clp_dqs+clm_dqs)-pco_dqs ))
1887  eml_dqg = max( dt*(pq(i_lgacm,k,i,j)+pq(i_lgarm,k,i,j)+pq(i_lsarm,k,i,j)+pq(i_liarm,k,i,j)), &
1888  min(0.0_rp, -rhoq2(i_qg,k,i,j)-(clp_dqg+clm_dqg)-pco_dqg ))
1889  eml_dqc = -eml_dqi
1890  eml_dqr = -eml_dqs-eml_dqg
1891  !
1892  eml_dni = max( dt*pq(i_niacm,k,i,j), min(0.0_rp, -rhoq2(i_ni,k,i,j)-(clp_dni+clm_dni)-pco_dni ))
1893  eml_dns = max( dt*pq(i_nsacm,k,i,j), min(0.0_rp, -rhoq2(i_ns,k,i,j)-(clp_dns+clm_dns)-pco_dns ))
1894  eml_dng = max( dt*(pq(i_ngacm,k,i,j)+pq(i_ngarm,k,i,j)+pq(i_nsarm,k,i,j)+pq(i_niarm,k,i,j)), &
1895  min(0.0_rp, -rhoq2(i_ng,k,i,j)-(clp_dng+clm_dng)-pco_dng ))
1896  eml_dnc = -eml_dni
1897  eml_dnr = -eml_dns-eml_dng
1898  !
1899  ! ice multiplication
1900  spl_dqg = max( dt*pq(i_lgspl,k,i,j), min(0.0_rp, -rhoq2(i_qg,k,i,j)-(clp_dqg+clm_dqg)-pco_dqg-eml_dqg ))
1901  spl_dqs = max( dt*pq(i_lsspl,k,i,j), min(0.0_rp, -rhoq2(i_qs,k,i,j)-(clp_dqs+clm_dqs)-pco_dqs-eml_dqs ))
1902  spl_dqi = -spl_dqg-spl_dqs
1903  fac9 = (spl_dqg-eps)/(dt*pq(i_lgspl,k,i,j)-eps)
1904  fac10 = (spl_dqs-eps)/(dt*pq(i_lsspl,k,i,j)-eps)
1905  spl_dni = dt*pq(i_nispl,k,i,j)*fac9*fac10
1906  !
1907  ! total cloud change
1908  drhogqc = (wrm_dqc + clp_dqc + clm_dqc + eml_dqc )
1909  drhognc = (wrm_dnc + clp_dnc + clm_dnc + eml_dnc )
1910  ! total rain change
1911  drhogqr = (wrm_dqr + clp_dqr + clm_dqr + eml_dqr )
1912  drhognr = (wrm_dnr + clp_dnr + clm_dnr + eml_dnr )
1913  ! total ice change
1914  drhogqi = ( clp_dqi + clm_dqi + pco_dqi + eml_dqi + spl_dqi)
1915  drhogni = ( clp_dni + clm_dni + pco_dni + eml_dni + spl_dni)
1916  ! total snow change
1917  drhogqs = ( clp_dqs + clm_dqs + pco_dqs + eml_dqs + spl_dqs)
1918  drhogns = ( clp_dns + clm_dns + pco_dns + eml_dns )
1919  ! total graupel change
1920  drhogqg = ( clp_dqg + clm_dqg + pco_dqg + eml_dqg + spl_dqg)
1921  drhogng = ( clp_dng + clm_dng + pco_dng + eml_dng )
1922  !
1923  !--- update
1924  !
1925  rhoq(i_qc,k,i,j) = max(0.0_rp, rhoq(i_qc,k,i,j) + drhogqc )
1926  rhoq(i_nc,k,i,j) = max(0.0_rp, rhoq(i_nc,k,i,j) + drhognc )
1927  rhoq(i_qr,k,i,j) = max(0.0_rp, rhoq(i_qr,k,i,j) + drhogqr )
1928  rhoq(i_nr,k,i,j) = max(0.0_rp, rhoq(i_nr,k,i,j) + drhognr )
1929  rhoq(i_qi,k,i,j) = max(0.0_rp, rhoq(i_qi,k,i,j) + drhogqi )
1930  rhoq(i_ni,k,i,j) = max(0.0_rp, rhoq(i_ni,k,i,j) + drhogni )
1931  rhoq(i_qs,k,i,j) = max(0.0_rp, rhoq(i_qs,k,i,j) + drhogqs )
1932  rhoq(i_ns,k,i,j) = max(0.0_rp, rhoq(i_ns,k,i,j) + drhogns )
1933  rhoq(i_qg,k,i,j) = max(0.0_rp, rhoq(i_qg,k,i,j) + drhogqg )
1934  rhoq(i_ng,k,i,j) = max(0.0_rp, rhoq(i_ng,k,i,j) + drhogng )
1935  !
1936  ! update
1937  ! rhogq = l*gsgam
1938  rhoe(k,i,j) = rhoe(k,i,j) + lhf * ( drhogqi + drhogqs + drhogqg )
1939  enddo
1940  enddo
1941  enddo
1942  profile_stop("sn14_update_rhoq")
1943 
1944  call prof_rapend ('MP_Collection', 3)
1945 
1946  call prof_rapstart('MP_Postprocess', 3)
1947 
1948  !--- update mixing ratio
1949  do j = js, je
1950  do i = is, ie
1951  do k = ks, ke
1952  do iq = 1, qa
1953  qtrc(k,i,j,iq) = rhoq(iq,k,i,j) * rrho(k,i,j)
1954  enddo
1955 
1956  calc_qdry( qdry(k,i,j), qtrc, k, i, j, iq )
1957  calc_cv( cva(k,i,j), qdry(k,i,j), qtrc, k, i, j, iq, cvdry, aq_cv )
1958  calc_r( rmoist, qtrc(k,i,j,i_qv), qdry(k,i,j), rdry, rvap )
1959  cpa(k,i,j) = cva(k,i,j) + rmoist
1960  temp(k,i,j) = rhoe(k,i,j) / ( dens(k,i,j) * cva(k,i,j) )
1961  pres(k,i,j) = dens(k,i,j) * rmoist * temp(k,i,j)
1962  rhot(k,i,j) = temp(k,i,j) * ( p00 / pres(k,i,j) )**(rmoist/cpa(k,i,j)) &
1963  * dens(k,i,j)
1964  enddo
1965  enddo
1966  enddo
1967 
1968 ! if( opt_debug ) call debugreport_collection
1969  if( opt_debug_tem ) call debug_tem_kij( 4, temp(:,:,:), dens(:,:,:), pres(:,:,:), qtrc(:,:,:,i_qv) )
1970 
1971  do iq = 1, qa
1972  do j = js, je
1973  do i = is, ie
1974  do k = ks, ke
1975  qtrc(k,i,j,iq) = rhoq(iq,k,i,j) * rrho(k,i,j)
1976  enddo
1977  enddo
1978  enddo
1979  enddo
1980 
1981  call prof_rapend ('MP_Postprocess', 3)
1982 
1983  !----------------------------------------------------------------------------
1984  !
1985  ! 4.Saturation adjustment
1986  !
1987  !----------------------------------------------------------------------------
1988  call prof_rapstart('MP_Saturation_adjustment', 3)
1989  ! nothing to do
1990  call prof_rapend ('MP_Saturation_adjustment', 3)
1991  !----------------------------------------------------------------------------
1992  !
1993  ! 5. Sedimentation ( terminal velocity must be negative )
1994  !
1995  !----------------------------------------------------------------------------
1996  call prof_rapstart('MP_Sedimentation', 3)
1997 
1998  if ( mp_doprecipitation ) then
1999 
2000  do j = js, je
2001  do i = is, ie
2002  do k = ks-1, ke
2003  flx_rain(k,i,j) = 0.0_rp
2004  flx_snow(k,i,j) = 0.0_rp
2005  enddo
2006  enddo
2007  enddo
2008 
2009  velw(:,:,:,:) = 0.0_rp
2010 
2011  do step = 1, mp_nstep_sedimentation
2012 
2013  call mp_terminal_velocity( velw(:,:,:,:), & ! [OUT]
2014  rhoq(:,:,:,:), & ! [IN]
2015  dens(:,:,:), & ! [IN]
2016  temp(:,:,:), & ! [IN]
2017  pres(:,:,:) ) ! [IN]
2018 
2019  call mp_precipitation( wflux_rain(:,:,:), & ! [OUT]
2020  wflux_snow(:,:,:), & ! [OUT]
2021  dens(:,:,:), & ! [INOUT]
2022  momz(:,:,:), & ! [INOUT]
2023  momx(:,:,:), & ! [INOUT]
2024  momy(:,:,:), & ! [INOUT]
2025  rhoe(:,:,:), & ! [INOUT]
2026  qtrc(:,:,:,:), & ! [INOUT]
2027  velw(:,:,:,:), & ! [IN]
2028  temp(:,:,:), & ! [IN]
2029  mp_dtsec_sedimentation ) ! [IN]
2030 
2031  do j = js, je
2032  do i = is, ie
2033  do k = ks-1, ke
2034  flx_rain(k,i,j) = flx_rain(k,i,j) + wflux_rain(k,i,j) * mp_rnstep_sedimentation
2035  flx_snow(k,i,j) = flx_snow(k,i,j) + wflux_snow(k,i,j) * mp_rnstep_sedimentation
2036  enddo
2037  enddo
2038  enddo
2039 
2040  enddo
2041 
2042  endif
2043 
2044  do j = js, je
2045  do i = is, ie
2046  sflx_rain(i,j) = flx_rain(ks-1,i,j)
2047  sflx_snow(i,j) = flx_snow(ks-1,i,j)
2048  end do
2049  end do
2050 
2051  call prof_rapend ('MP_Sedimentation', 3)
2052 
2053  return
2054  end subroutine mp_sn14
2055 
2056  !-----------------------------------------------------------------------------
2057  subroutine debug_tem_kij( &
2058  point, &
2059  tem, &
2060  rho, &
2061  pre, &
2062  qv )
2063  use scale_process, only: &
2064  prc_myrank
2065  implicit none
2066 
2067  integer, intent(in) :: point
2068  real(RP), intent(in) :: tem(ka,ia,ja)
2069  real(RP), intent(in) :: rho(ka,ia,ja)
2070  real(RP), intent(in) :: pre(ka,ia,ja)
2071  real(RP), intent(in) :: qv (ka,ia,ja)
2072 
2073  integer :: k ,i, j
2074  !---------------------------------------------------------------------------
2075 
2076  do j = js, je
2077  do i = is, ie
2078  do k = ks, ke
2079  if ( tem(k,i,j) < tem_min &
2080  .OR. rho(k,i,j) < rho_min &
2081  .OR. pre(k,i,j) < 1.0_rp ) then
2082 
2083  if( io_l ) write(io_fid_log,'(A,I3,A,4(F16.5),3(I6))') &
2084  "*** point: ", point, " low tem,rho,pre:", tem(k,i,j), rho(k,i,j), pre(k,i,j), qv(k,i,j), k, i, j, prc_myrank
2085  endif
2086  enddo
2087  enddo
2088  enddo
2089 
2090  return
2091  end subroutine debug_tem_kij
2092 
2093  subroutine nucleation_kij( &
2094  z, velz, &
2095  rho, tem, pre, &
2096  rhoq, &
2097  PQ, &
2098  cpa, & ! in
2099  dTdt_rad, & ! in
2100  qke, & ! in
2101  CCN, & ! in
2102  dt ) ! in
2103  use scale_process, only: &
2104  prc_mpistop
2105  use scale_atmos_saturation, only: &
2106  moist_psat_liq => atmos_saturation_psat_liq, &
2107  moist_psat_ice => atmos_saturation_psat_ice, &
2108  moist_pres2qsat_liq => atmos_saturation_pres2qsat_liq, &
2109  moist_pres2qsat_ice => atmos_saturation_pres2qsat_ice, &
2110  moist_dqsi_dtem_rho => atmos_saturation_dqsi_dtem_rho
2111  implicit none
2112 
2113  real(RP), intent(in) :: z(ka) !
2114  real(RP), intent(in) :: velz(ka,ia,ja) ! w of half point
2115  real(RP), intent(in) :: rho(ka,ia,ja) ! [Add] 09/08/18 T.Mitsui
2116  real(RP), intent(in) :: tem(ka,ia,ja) ! [Add] 09/08/18 T.Mitsui
2117  real(RP), intent(in) :: pre(ka,ia,ja) ! [Add] 09/08/18 T.Mitsui
2118  !
2119  real(RP), intent(in) :: rhoq(qa,ka,ia,ja) !
2120  real(RP), intent(out) :: PQ(pq_max,ka,ia,ja)
2121  !
2122  real(RP), intent(in) :: cpa(ka,ia,ja) ! in 09/08/18 [Add] T.Mitsui
2123  real(RP), intent(in) :: dTdt_rad(ka,ia,ja) ! 09/08/18 T.Mitsui
2124  real(RP), intent(in) :: qke(ka,ia,ja) ! 09/08/18 T.Mitsui
2125  real(DP), intent(in) :: dt
2126  real(RP), intent(in) :: CCN(ka,ia,ja)
2127  !
2128  ! namelist variables
2129  !
2130  ! total aerosol number concentration [/m3]
2131  real(RP), parameter :: c_ccn_ocean= 1.00e+8_rp
2132  real(RP), parameter :: c_ccn_land = 1.26e+9_rp
2133  real(RP), save :: c_ccn = 1.00e+8_rp
2134  ! aerosol activation factor
2135  real(RP), parameter :: kappa_ocean= 0.462_rp
2136  real(RP), parameter :: kappa_land = 0.308_rp
2137  real(RP), save :: kappa = 0.462_rp
2138  real(RP), save :: c_in = 1.0_rp
2139  ! SB06 (36)
2140  real(RP), save :: nm_M92 = 1.e+3_rp
2141  real(RP), save :: am_M92 = -0.639_rp
2142  real(RP), save :: bm_M92 = 12.96_rp
2143  !
2144  real(RP), save :: in_max = 1000.e+3_rp ! max num. of Ice-Nuclei [num/m3]
2145  real(RP), save :: ssi_max= 0.60_rp
2146  real(RP), save :: ssw_max= 1.1_rp ! [%]
2147  !
2148  logical, save :: flag_first = .true.
2149  real(RP), save :: qke_min = 0.03_rp ! sigma=0.1[m/s], 09/08/18 T.Mitsui
2150  real(RP), save :: tem_ccn_low=233.150_rp ! = -40 degC ! [Add] 10/08/03 T.Mitsui
2151  real(RP), save :: tem_in_low =173.150_rp ! = -100 degC ! [Add] 10/08/03 T.Mitsui
2152  logical, save :: nucl_twomey = .false.
2153  logical, save :: inucl_w = .false.
2154  !
2155  namelist /nm_mp_sn14_nucleation/ &
2156  in_max, & !
2157  c_ccn, kappa, & ! cloud nucleation
2158  nm_m92, am_m92, bm_m92, & ! ice nucleation
2159  xc_ccn, xi_ccn, &
2160  tem_ccn_low, & ! [Add] 10/08/03 T.Mitsui
2161  tem_in_low, & ! [Add] 10/08/03 T.Mitsui
2162  ssw_max, ssi_max, &
2163  nucl_twomey, inucl_w ! [Add] 13/01/30 Y.Sato
2164  !
2165 ! real(RP) :: c_ccn_map(1,IA,JA) ! c_ccn horizontal distribution
2166 ! real(RP) :: kappa_map(1,IA,JA) ! kappa horizontal distribution
2167 ! real(RP) :: c_in_map(1,IA,JA) ! c_in horizontal distribution ! [Add] 11/08/30 T.Mitsui
2168  real(RP) :: esw(ka,ia,ja) ! saturation vapor pressure, water
2169  real(RP) :: esi(ka,ia,ja) ! ice
2170  real(RP) :: ssw(ka,ia,ja) ! super saturation (water)
2171  real(RP) :: ssi(ka,ia,ja) ! super saturation (ice)
2172 ! real(RP) :: w_dsswdz(KA,IA,JA) ! w*(d_ssw/ d_z) super saturation(water) flux
2173  real(RP) :: w_dssidz(ka,ia,ja) ! w*(d_ssi/ d_z), 09/04/14 T.Mitsui
2174 ! real(RP) :: ssw_below(KA,IA,JA)! ssw(k-1)
2175  real(RP) :: ssi_below(ka,ia,ja)! ssi(k-1), 09/04/14 T.Mitsui
2176  real(RP) :: z_below(ka,ia,ja) ! z(k-1)
2177  real(RP) :: dz ! z(k)-z(k-1)
2178  real(RP) :: pv ! vapor pressure
2179  ! work variables for Twomey Equation.
2180  real(RP) :: qsw(ka,ia,ja)
2181  real(RP) :: qsi(ka,ia,ja)
2182  real(RP) :: dqsidtem_rho(ka,ia,ja)
2183  real(RP) :: dssidt_rad(ka,ia,ja)
2184 ! real(RP) :: dni_ratio(KA,IA,JA)
2185  real(RP) :: wssi, wdssi
2186  !
2187 ! real(RP) :: xi_nuc(1,IA,JA) ! xi use the value @ cloud base
2188 ! real(RP) :: alpha_nuc(1,IA,JA) ! alpha_nuc
2189 ! real(RP) :: eta_nuc(1,IA,JA) ! xi use the value @ cloud base
2190  !
2191  real(RP) :: sigma_w(ka,ia,ja)
2192  real(RP) :: weff(ka,ia,ja)
2193  real(RP) :: weff_max(ka,ia,ja)
2194  !
2195  real(RP) :: coef_ccn(ia,ja)
2196  real(RP) :: slope_ccn(ia,ja)
2197  real(RP) :: nc_new(ka,ia,ja)
2198  real(RP) :: nc_new_below(ka,ia,ja)
2199  real(RP) :: dnc_new
2200  real(RP) :: nc_new_max ! Lohmann (2002),
2201  real(RP) :: a_max
2202  real(RP) :: b_max
2203  logical :: flag_nucleation(ka,ia,ja)
2204  !
2205  real(RP) :: r_gravity
2206  real(RP), parameter :: r_sqrt3=0.577350269_rp ! = sqrt(1.d0/3.d0)
2207  real(RP), parameter :: eps=1.e-30_rp
2208  !====> ! 09/08/18
2209  !
2210  real(RP) :: dlcdt_max, dli_max ! defined by supersaturation
2211  real(RP) :: dncdt_max, dni_max ! defined by supersaturation
2212  real(RP) :: rdt
2213  !
2214  integer :: i, j, k
2215  !
2216  if( flag_first )then
2217  rewind(io_fid_conf)
2218  read(io_fid_conf, nml=nm_mp_sn14_nucleation, end=100)
2219 100 if( io_l ) write(io_fid_log, nml=nm_mp_sn14_nucleation)
2220  flag_first=.false.
2221  if( mp_couple_aerosol .AND. nucl_twomey ) then
2222  write(io_fid_log,*) "nucl_twomey should be false when MP_couple_aerosol is true, stop"
2223  call prc_mpistop
2224  endif
2225  endif
2226  !
2227 ! c_ccn_map(1,:,:) = c_ccn
2228 ! kappa_map(1,:,:) = kappa
2229 ! c_in_map(1,:,:) = c_in
2230  !
2231 ! nc_uplim_d(1,:,:) = c_ccn_map(1,:,:)*1.5_RP
2232  do j = js, je
2233  do i = is, ie
2234  nc_uplim_d(1,i,j) = c_ccn*1.5_rp
2235  end do
2236  end do
2237  !
2238  rdt = 1.0_rp/dt
2239  r_gravity = 1.0_rp/grav
2240  !
2241  call moist_psat_liq ( esw, tem )
2242  call moist_psat_ice ( esi, tem )
2243  call moist_pres2qsat_liq( qsw, tem, pre )
2244  call moist_pres2qsat_ice( qsi, tem, pre )
2245  call moist_dqsi_dtem_rho( dqsidtem_rho, tem, rho )
2246  !
2247  ! Lohmann (2002),JAS, eq.(1) but changing unit [cm-3] => [m-3]
2248  a_max = 1.e+6_rp*0.1_rp*(1.e-6_rp)**1.27_rp
2249  b_max = 1.27_rp
2250  !
2251  ssi_max = 1.0_rp
2252 
2253  do j = js, je
2254  do i = is, ie
2255  do k = ks, ke
2256  pv = rhoq(i_qv,k,i,j)*rvap*tem(k,i,j)
2257  ssw(k,i,j) = min( mp_ssw_lim, ( pv/esw(k,i,j)-1.0_rp ) )*100.0_rp
2258  ssi(k,i,j) = (pv/esi(k,i,j) - 1.00_rp)
2259 ! ssw_below(k+1,i,j) = ssw(k,i,j)
2260  ssi_below(k+1,i,j) = ssi(k,i,j)
2261  z_below(k+1,i,j) = z(k)
2262  end do
2263 ! ssw_below(KS,i,j) = ssw(KS,i,j)
2264  ssi_below(ks,i,j) = ssi(ks,i,j)
2265  z_below(ks,i,j) = z(ks-1)
2266 
2267  ! dS/dz is evaluated by first order upstream difference
2268  !*** Solution for Twomey Equation ***
2269 ! coef_ccn(i,j) = 1.E+6_RP*0.88_RP*(c_ccn_map(1,i,j)*1.E-6_RP)**(2.0_RP/(kappa_map(1,i,j) + 2.0_RP)) * &
2270  coef_ccn(i,j) = 1.e+6_rp*0.88_rp*(c_ccn*1.e-6_rp)**(2.0_rp/(kappa + 2.0_rp)) &
2271 ! * (70.0_RP)**(kappa_map(1,i,j)/(kappa_map(1,i,j) + 2.0_RP))
2272  * (70.0_rp)**(kappa/(kappa + 2.0_rp))
2273 ! slope_ccn(i,j) = 1.5_RP*kappa_map(1,i,j)/(kappa_map(1,i,j) + 2.0_RP)
2274  slope_ccn(i,j) = 1.5_rp*kappa/(kappa + 2.0_rp)
2275  !
2276  do k=ks, ke
2277  sigma_w(k,i,j) = r_sqrt3*sqrt(max(qke(k,i,j),qke_min))
2278  end do
2279  sigma_w(ks-1,i,j) = sigma_w(ks,i,j)
2280  sigma_w(ke+1,i,j) = sigma_w(ke,i,j)
2281  ! effective vertical velocity
2282  do k=ks, ke-1
2283  weff(k,i,j) = 0.5_rp*(velz(k,i,j) + velz(k+1,i,j)) - cpa(k,i,j)*r_gravity*dtdt_rad(k,i,j)
2284  end do
2285  weff(ks-1,i,j) = weff(ks,i,j)
2286  weff(ke,i,j) = weff(ke-1,i,j)
2287 
2288  end do
2289  end do
2290  !
2291  if( mp_couple_aerosol ) then
2292 
2293  do j = js, je
2294  do i = is, ie
2295  do k = ks, ke
2296  if( ssw(k,i,j) > 1.e-10_rp .AND. pre(k,i,j) > 300.e+2_rp ) then
2297  nc_new(k,i,j) = max( ccn(k,i,j), c_ccn )
2298  else
2299  nc_new(k,i,j) = 0.0_rp
2300  endif
2301  enddo
2302  enddo
2303  enddo
2304 
2305  else
2306 
2307  if( nucl_twomey ) then
2308  ! diagnose cloud condensation nuclei
2309 
2310  do j = js, je
2311  do i = is, ie
2312  do k = ks, ke
2313  ! effective vertical velocity (maximum vertical velocity in turbulent flow)
2314  weff_max(k,i,j) = weff(k,i,j) + sigma_w(k,i,j)
2315  ! large scale upward motion region and saturated
2316  if( (weff(k,i,j) > 1.e-8_rp) .AND. (ssw(k,i,j) > 1.e-10_rp) .AND. pre(k,i,j) > 300.e+2_rp )then
2317  ! Lohmann (2002), eq.(1)
2318  nc_new_max = coef_ccn(i,j)*weff_max(k,i,j)**slope_ccn(i,j)
2319  nc_new(k,i,j) = a_max*nc_new_max**b_max
2320  else
2321  nc_new(k,i,j) = 0.0_rp
2322  end if
2323  end do
2324  end do
2325  end do
2326  else
2327  ! calculate cloud condensation nuclei
2328  do j = js, je
2329  do i = is, ie
2330  do k = ks, ke
2331  if( ssw(k,i,j) > 1.e-10_rp .AND. pre(k,i,j) > 300.e+2_rp ) then
2332  nc_new(k,i,j) = c_ccn*ssw(k,i,j)**kappa
2333  else
2334  nc_new(k,i,j) = 0.0_rp
2335  endif
2336  enddo
2337  enddo
2338  enddo
2339  endif
2340 
2341  endif
2342 
2343  do j = js, je
2344  do i = is, ie
2345  do k = ks, ke
2346  ! nc_new is bound by upper limit
2347  if( nc_new(k,i,j) > nc_uplim_d(1,i,j) )then ! no more CCN
2348  flag_nucleation(k,i,j) = .false.
2349  nc_new_below(k+1,i,j) = 1.e+30_rp
2350  else if( nc_new(k,i,j) > eps )then ! nucleation can occur
2351  flag_nucleation(k,i,j) = .true.
2352  nc_new_below(k+1,i,j) = nc_new(k,i,j)
2353  else ! nucleation cannot occur(unsaturated or negative w)
2354  flag_nucleation(k,i,j) = .false.
2355  nc_new_below(k+1,i,j) = 0.0_rp
2356  end if
2357  end do
2358  nc_new_below(ks,i,j) = 0.0_rp
2359 ! do k=KS, KE
2360  ! search maximum value of nc_new
2361 ! if( ( nc_new(k,i,j) < nc_new_below(k,i,j) ) .OR. &
2362 ! ( nc_new_below(k,i,j) > c_ccn_map(1,i,j)*0.05_RP ) )then ! 5% of c_ccn
2363 ! ( nc_new_below(k,i,j) > c_ccn*0.05_RP ) )then ! 5% of c_ccn
2364 ! flag_nucleation(k,i,j) = .false.
2365 ! end if
2366 ! end do
2367 
2368  end do
2369  end do
2370 
2371  if( mp_couple_aerosol ) then
2372 
2373  do j = js, je
2374  do i = is, ie
2375  do k = ks, ke
2376  ! nucleation occurs at only cloud base.
2377  ! if CCN is more than below parcel, nucleation newly occurs
2378  ! effective vertical velocity
2379  if ( flag_nucleation(k,i,j) .AND. & ! large scale upward motion region and saturated
2380  tem(k,i,j) > tem_ccn_low ) then
2381  dlcdt_max = (rhoq(i_qv,k,i,j) - esw(k,i,j)/(rvap*tem(k,i,j)))*rdt
2382  dncdt_max = dlcdt_max/xc_min
2383 ! dnc_new = nc_new(k,i,j)-rhoq(I_NC,k,i,j)
2384  dnc_new = nc_new(k,i,j)
2385  pq(i_ncccn,k,i,j) = min( dncdt_max, dnc_new*rdt )
2386  pq(i_lcccn,k,i,j) = min( dlcdt_max, xc_min*pq(i_ncccn,k,i,j) )
2387  else
2388  pq(i_ncccn,k,i,j) = 0.0_rp
2389  pq(i_lcccn,k,i,j) = 0.0_rp
2390  end if
2391  end do
2392  end do
2393  end do
2394 
2395  else
2396 
2397  if( nucl_twomey ) then
2398  do j = js, je
2399  do i = is, ie
2400  do k = ks, ke
2401  ! nucleation occurs at only cloud base.
2402  ! if CCN is more than below parcel, nucleation newly occurs
2403  ! effective vertical velocity
2404  if ( flag_nucleation(k,i,j) .AND. & ! large scale upward motion region and saturated
2405  tem(k,i,j) > tem_ccn_low .AND. &
2406  nc_new(k,i,j) > rhoq(i_nc,k,i,j) ) then
2407  dlcdt_max = (rhoq(i_qv,k,i,j) - esw(k,i,j)/(rvap*tem(k,i,j)))*rdt
2408  dncdt_max = dlcdt_max/xc_min
2409  dnc_new = nc_new(k,i,j)-rhoq(i_nc,k,i,j)
2410  pq(i_ncccn,k,i,j) = min( dncdt_max, dnc_new*rdt )
2411  pq(i_lcccn,k,i,j) = min( dlcdt_max, xc_min*pq(i_ncccn,k,i,j) )
2412  else
2413  pq(i_ncccn,k,i,j) = 0.0_rp
2414  pq(i_lcccn,k,i,j) = 0.0_rp
2415  end if
2416  end do
2417  end do
2418  end do
2419  else
2420  do j = js, je
2421  do i = is, ie
2422  do k = ks, ke
2423  ! effective vertical velocity
2424  if( tem(k,i,j) > tem_ccn_low .AND. &
2425  nc_new(k,i,j) > rhoq(i_nc,k,i,j) ) then
2426  dlcdt_max = (rhoq(i_qv,k,i,j) - esw(k,i,j)/(rvap*tem(k,i,j)))*rdt
2427  dncdt_max = dlcdt_max/xc_min
2428  dnc_new = nc_new(k,i,j)-rhoq(i_nc,k,i,j)
2429  pq(i_ncccn,k,i,j) = min( dncdt_max, dnc_new*rdt )
2430  pq(i_lcccn,k,i,j) = min( dlcdt_max, xc_min*pq(i_ncccn,k,i,j) )
2431  else
2432  pq(i_ncccn,k,i,j) = 0.0_rp
2433  pq(i_lcccn,k,i,j) = 0.0_rp
2434  end if
2435  end do
2436  end do
2437  end do
2438  endif
2439  endif
2440 
2441  !
2442  ! ice nucleation
2443  !
2444  ! +++ NOTE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2445  ! Based on Phillips etal.(2006).
2446  ! However this approach doesn't diagnose Ni itself but diagnose tendency.
2447  ! Original approach adjust Ni instantaneously .
2448  ! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2449  do j = js, je
2450  do i = is, ie
2451  do k = ks, ke
2452  dz = z(k) - z_below(k,i,j)
2453  w_dssidz(k,i,j) = velz(k,i,j)*(ssi(k,i,j) - ssi_below(k,i,j))/dz ! 09/04/14 [Add] T.Mitsui
2454  dssidt_rad(k,i,j) = -rhoq(i_qv,k,i,j)/(rho(k,i,j)*qsi(k,i,j)*qsi(k,i,j))*dqsidtem_rho(k,i,j)*dtdt_rad(k,i,j)
2455  dli_max = (rhoq(i_qv,k,i,j) - esi(k,i,j)/(rvap*tem(k,i,j)))*rdt
2456  dni_max = min( dli_max/xi_ccn, (in_max-rhoq(i_ni,k,i,j))*rdt )
2457  wdssi = min( w_dssidz(k,i,j)+dssidt_rad(k,i,j), 0.01_rp)
2458  wssi = min( ssi(k,i,j), ssi_max)
2459  ! SB06(34),(35)
2460  if( ( wdssi > eps ) .AND. & !
2461  (tem(k,i,j) < 273.15_rp ) .AND. & !
2462  (rhoq(i_ni,k,i,j) < in_max ) .AND. &
2463  (wssi >= eps ) )then !
2464 ! PNIccn(k,i,j) = min(dni_max, c_in_map(1,i,j)*bm_M92*nm_M92*0.3_RP*exp(0.3_RP*bm_M92*(wssi-0.1_RP))*wdssi)
2465  if( inucl_w ) then
2466  pq(i_niccn,k,i,j) = min(dni_max, c_in*bm_m92*nm_m92*0.3_rp*exp(0.3_rp*bm_m92*(wssi-0.1_rp))*wdssi)
2467  else
2468  pq(i_niccn,k,i,j) = min(dni_max, max(c_in*nm_m92*exp(0.3_rp*bm_m92*(wssi-0.1_rp) )-rhoq(i_ni,k,i,j),0.0_rp )*rdt )
2469  endif
2470  pq(i_liccn,k,i,j) = min(dli_max, pq(i_niccn,k,i,j)*xi_ccn )
2471  ! only for output
2472 ! dni_ratio(k,i,j) = dssidt_rad(k,i,j)/( w_dssidz(k,i,j)+dssidt_rad(k,i,j) )
2473  else
2474  pq(i_niccn,k,i,j) = 0.0_rp
2475  pq(i_liccn,k,i,j) = 0.0_rp
2476  end if
2477  end do
2478  end do
2479  end do
2480 
2481  return
2482  end subroutine nucleation_kij
2483  !----------------------------
2484  subroutine ice_multiplication_kij( &
2485  PQ, & ! out
2486  Pac, & ! in
2487  tem, rhoq, xq ) ! in
2489  ! ice multiplication by splintering
2490  ! we consider Hallet-Mossop process
2491  use scale_specfunc, only: &
2492  gammafunc => sf_gamma
2493  implicit none
2494  real(RP), intent(out):: PQ(pq_max,ka,ia,ja)
2495  !
2496  real(RP), intent(in) :: Pac(pac_max,ka,ia,ja)
2497  real(RP), intent(in) :: tem(ka,ia,ja)
2498  real(RP), intent(in) :: rhoq(qa,ka,ia,ja)
2499  real(RP), intent(in) :: xq(5,ka,ia,ja)
2500  !
2501  logical, save :: flag_first = .true.
2502  ! production of (350.d3 ice particles)/(cloud riming [g]) => 350*d6 [/kg]
2503  real(RP), parameter :: pice = 350.0e+6_rp
2504  ! production of (1 ice particle)/(250 cloud particles riming)
2505  real(RP), parameter :: pnc = 250.0_rp
2506  real(RP), parameter :: rc_cr= 12.e-6_rp ! critical size[micron]
2507  ! temperature factor
2508  real(RP) :: fp
2509  ! work for incomplete gamma function
2510  real(RP), save :: xc_cr ! mass[kg] of cloud with r=critical size[micron]
2511  real(RP), save :: alpha ! slope parameter of gamma function
2512  real(RP), save :: gm, lgm ! gamma(alpha), log(gamma(alpha))
2513  real(RP) :: igm ! in complete gamma(x,alpha)
2514  real(RP) :: x
2515  ! coefficient of expansion using in calculation of igm
2516  real(RP) :: a0,a1,a2,a3,a4,a5
2517  real(RP) :: a6,a7,a8,a9,a10
2518  real(RP) :: an1,an2,b0,b1,b2,c0,c1,c2
2519  real(RP) :: d0,d1,d2,e1,e2,h0,h1,h2
2520  real(RP), parameter :: eps=1.0e-30_rp
2521  ! number of cloud droplets larger than 12 micron(radius).
2522  real(RP) :: n12
2523  !
2524  real(RP) :: wn, wni, wns, wng
2525  integer :: i, j, k
2526  !
2527  if( flag_first )then
2528  flag_first = .false.
2529  ! work for Incomplete Gamma function
2530  xc_cr = (2.0_rp*rc_cr/a_m(i_qc))**(1.0_rp/b_m(i_qc))
2531  alpha = (nu(i_qc)+1.0_rp)/mu(i_qc)
2532  gm = gammafunc(alpha)
2533  lgm = log(gm)
2534  end if
2535  !
2536  do j = js, je
2537  do i = is, ie
2538  do k = ks, ke
2539  ! Here we assume particle temperature is same as environment temperature.
2540  ! If you want to treat in a better manner,
2541  ! you can diagnose with eq.(64) in CT(86)
2542  if (tem(k,i,j) > 270.16_rp)then
2543  fp = 0.0_rp
2544  else if(tem(k,i,j) >= 268.16_rp)then
2545  fp = (270.16_rp-tem(k,i,j))*0.5_rp
2546  else if(tem(k,i,j) >= 265.16_rp)then
2547  fp = (tem(k,i,j)-265.16_rp)*0.333333333_rp
2548  else
2549  fp = 0.0_rp
2550  end if
2551  ! Approximation of Incomplete Gamma function
2552  ! Here we calculate with algorithm by Numerical Recipes.
2553  ! This approach is based on eq.(78) in Cotton etal.(1986),
2554  ! but more accurate and expanded for Generalized Gamma Distribution.
2555  x = coef_lambda(i_qc)*(xc_cr/xq(i_c,k,i,j))**mu(i_qc)
2556  !
2557  if(x<1.e-2_rp*alpha)then ! negligible
2558  igm = 0.0_rp
2559  else if(x<alpha+1.0_rp)then ! series expansion
2560  ! 10th-truncation is enough for cloud droplet.
2561  a0 = 1.0_rp/alpha ! n=0
2562  a1 = a0*x/(alpha+1.0_rp) ! n=1
2563  a2 = a1*x/(alpha+2.0_rp) ! n=2
2564  a3 = a2*x/(alpha+3.0_rp) ! n=3
2565  a4 = a3*x/(alpha+4.0_rp) ! n=4
2566  a5 = a4*x/(alpha+5.0_rp) ! n=5
2567  a6 = a5*x/(alpha+6.0_rp) ! n=6
2568  a7 = a6*x/(alpha+7.0_rp) ! n=7
2569  a8 = a7*x/(alpha+8.0_rp) ! n=8
2570  a9 = a8*x/(alpha+9.0_rp) ! n=9
2571  a10 = a9*x/(alpha+10.0_rp) ! n=10
2572  igm = (a0+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10)*exp( -x + alpha*log(x) - lgm )
2573  else if(x<alpha*1.d2) then ! continued fraction expansion
2574  ! 2nd-truncation is enough for cloud droplet.
2575  ! setup
2576  b0 = x+1.0_rp-alpha
2577  c0 = 1.0_rp/eps
2578  d0 = 1.0_rp/b0
2579  h0 = d0
2580  ! n=1
2581  an1 = -(1.0_rp-alpha)
2582  b1 = b0 + 2.0_rp
2583  d1 = 1.0_rp/(an1*d0+b1)
2584  c1 = b1+an1/c0
2585  e1 = d1*c1
2586  h1 = h0*e1
2587  ! n=2
2588  an2 = -2.0_rp*(2.0_rp-alpha)
2589  b2 = b1 + 2.0_rp
2590  d2 = 1.0_rp/(an2*d1+b2)
2591  c2 = b2+an2/c1
2592  e2 = d2*c2
2593  h2 = h1*e2
2594  !
2595  igm = 1.0_rp - exp( -x + alpha*log(x) - lgm )*h2
2596  else ! negligible
2597  igm = 1.0_rp
2598  end if
2599  ! n12 is number of cloud droplets larger than 12 micron.
2600  n12 = rhoq(i_nc,k,i,j)*(1.0_rp-igm)
2601  ! eq.(82) CT(86)
2602  wn = (pice + n12/((rhoq(i_qc,k,i,j)+xc_min)*pnc) )*fp ! filtered by xc_min
2603  wni = wn*(-pac(i_liaclc2li,k,i,j) ) ! riming production rate is all negative
2604  wns = wn*(-pac(i_lsaclc2ls,k,i,j) )
2605  wng = wn*(-pac(i_lgaclc2lg,k,i,j) )
2606  pq(i_nispl,k,i,j) = wni+wns+wng
2607  !
2608  pq(i_lsspl,k,i,j) = - wns*xq(i_i,k,i,j) ! snow => ice
2609  pq(i_lgspl,k,i,j) = - wng*xq(i_i,k,i,j) ! graupel => ice
2610  !
2611  end do
2612  end do
2613  end do
2614  !
2615  return
2616  end subroutine ice_multiplication_kij
2617  !----------------------------
2618  subroutine mixed_phase_collection_kij( &
2619  ! collection process
2620  Pac, PQ, & ! out
2621  wtem, rhoq, & ! in
2622  xq, dq_xave, vt_xave ) ! in
2623 ! rho ) ! [Add] 11/08/30
2624  use scale_atmos_saturation, only: &
2625  moist_psat_ice => atmos_saturation_psat_ice
2626  implicit none
2627 
2628  !--- mixed-phase collection process
2629  ! And all we set all production term as a negative sign to avoid confusion.
2630  !
2631  real(RP), intent(out):: Pac(pac_max,ka,ia,ja)
2632  !--- partial conversion
2633  real(RP), intent(out):: PQ(pq_max,ka,ia,ja)
2634  !
2635  real(RP), intent(in) :: wtem(ka,ia,ja)
2636  !--- mass/number concentration[kg/m3]
2637  real(RP), intent(in) :: rhoq(qa,ka,ia,ja)
2638  ! necessary ?
2639  real(RP), intent(in) :: xq(5,ka,ia,ja)
2640  !--- diameter of averaged mass( D(ave x) )
2641  real(RP), intent(in) :: dq_xave(5,ka,ia,ja)
2642  !--- terminal velocity of averaged mass( vt(ave x) )
2643  real(RP), intent(in) :: vt_xave(5,2,ka,ia,ja)
2644  ! [Add] 11/08/30 T.Mitsui, for autoconversion of ice
2645 ! real(RP), intent(in) :: rho(KA,IA,JA)
2646  !
2647  ! namelist variables
2648  !=== for collection
2649  !--- threshold of diameters to collide with others
2650  real(RP), save :: dc0 = 15.0e-6_rp ! lower threshold of cloud
2651  real(RP), save :: dc1 = 40.0e-6_rp ! upper threshold of cloud
2652  real(RP), save :: di0 = 150.0e-6_rp ! lower threshold of cloud
2653  real(RP), save :: ds0 = 150.0e-6_rp ! lower threshold of cloud
2654  real(RP), save :: dg0 = 150.0e-6_rp ! lower threshold of cloud
2655  !--- standard deviation of terminal velocity[m/s]
2656  real(RP), save :: sigma_c=0.00_rp ! cloud
2657  real(RP), save :: sigma_r=0.00_rp ! rain
2658  real(RP), save :: sigma_i=0.2_rp ! ice
2659  real(RP), save :: sigma_s=0.2_rp ! snow
2660  real(RP), save :: sigma_g=0.00_rp ! graupel
2661  !--- max collection efficiency for cloud
2662  real(RP), save :: E_im = 0.80_rp ! ice max
2663  real(RP), save :: E_sm = 0.80_rp ! snow max
2664  real(RP), save :: E_gm = 1.00_rp ! graupel max
2665  !--- collection efficiency between 2 species
2666  real(RP), save :: E_ir=1.0_rp ! ice x rain
2667  real(RP), save :: E_sr=1.0_rp ! snow x rain
2668  real(RP), save :: E_gr=1.0_rp ! graupel x rain
2669  real(RP), save :: E_ii=1.0_rp ! ice x ice
2670  real(RP), save :: E_si=1.0_rp ! snow x ice
2671  real(RP), save :: E_gi=1.0_rp ! graupel x ice
2672  real(RP), save :: E_ss=1.0_rp ! snow x snow
2673  real(RP), save :: E_gs=1.0_rp ! graupel x snow
2674  real(RP), save :: E_gg=1.0_rp ! graupel x graupel
2675  !=== for partial conversion
2676  !--- flag: 1=> partial conversion to graupel, 0=> no conversion
2677  integer, save :: i_iconv2g=1 ! ice => graupel
2678  integer, save :: i_sconv2g=1 ! snow => graupel
2679  !--- bulk density of graupel
2680  real(RP), save :: rho_g = 900.0_rp ! [kg/m3]
2681  !--- space filling coefficient [%]
2682  real(RP), save :: cfill_i = 0.68_rp ! ice
2683  real(RP), save :: cfill_s = 0.01_rp ! snow
2684  !--- critical diameter for ice conversion
2685  real(RP), save :: di_cri = 500.e-6_rp ! [m]
2686  ! [Add] 10/08/03 T.Mitsui
2687  logical, save :: opt_stick_KS96=.false.
2688  logical, save :: opt_stick_CO86=.false.
2689  real(RP), parameter :: a_dec = 0.883_rp
2690  real(RP), parameter :: b_dec = 0.093_rp
2691  real(RP), parameter :: c_dec = 0.00348_rp
2692  real(RP), parameter :: d_dec = 4.5185e-5_rp
2693  !
2694  logical, save :: flag_first = .true.
2695  namelist /nm_mp_sn14_collection/ &
2696  dc0, dc1, di0, ds0, dg0, &
2697  sigma_c, sigma_r, sigma_i, sigma_s, sigma_g, &
2698  opt_stick_ks96, &
2699  opt_stick_co86, &
2700  e_im, e_sm, e_gm, &
2701  e_ir, e_sr, e_gr, e_ii, e_si, e_gi, e_ss, e_gs, e_gg, &
2702  i_iconv2g, i_sconv2g, rho_g, cfill_i, cfill_s, di_cri
2703  !
2704  real(RP) :: tem(ka,ia,ja)
2705  !
2706  !--- collection efficency of each specie
2707  real(RP) :: E_c, E_r, E_i, E_s, E_g !
2708  real(RP) :: E_ic, E_sc, E_gc !
2709  !--- sticking efficiency
2710  real(RP) :: E_stick(ka,ia,ja)
2711  ! [Add] 10/08/03 T.Mitsui
2712  real(RP) :: temc, temc2, temc3
2713  real(RP) :: E_dec
2714  real(RP) :: esi_rat
2715  real(RP) :: esi(ka,ia,ja)
2716  !
2717  real(RP) :: temc_p, temc_m ! celcius tem.
2718  ! [Add] 11/08/30 T.Mitsui, estimation of autoconversion time
2719 ! real(RP) :: ci_aut(KA,IA,JA)
2720 ! real(RP) :: taui_aut(KA,IA,JA)
2721 ! real(RP) :: tau_sce(KA,IA,JA)
2722  !--- DSD averaged diameter for each species
2723  real(RP) :: ave_dc ! cloud
2724 ! real(RP) :: ave_dr ! rain
2725  real(RP) :: ave_di ! ice
2726  real(RP) :: ave_ds ! snow
2727  real(RP) :: ave_dg ! graupel
2728  !--- coefficient of collection equations(L:mass, N:number)
2729  real(RP) :: coef_acc_LCI, coef_acc_NCI ! cloud - cloud ice
2730  real(RP) :: coef_acc_LCS, coef_acc_NCS ! cloud - snow
2731  !
2732  real(RP) :: coef_acc_LCG, coef_acc_NCG ! cloud - graupel
2733  real(RP) :: coef_acc_LRI_I, coef_acc_NRI_I ! rain - cloud ice
2734  real(RP) :: coef_acc_LRI_R, coef_acc_NRI_R ! rain - cloud ice
2735  real(RP) :: coef_acc_LRS_S, coef_acc_NRS_S ! rain - snow
2736  real(RP) :: coef_acc_LRS_R, coef_acc_NRS_R ! rain - snow
2737  real(RP) :: coef_acc_LRG, coef_acc_NRG ! rain - graupel
2738  real(RP) :: coef_acc_LII, coef_acc_NII ! cloud ice - cloud ice
2739  real(RP) :: coef_acc_LIS, coef_acc_NIS ! cloud ice - snow
2740  real(RP) :: coef_acc_NSS ! snow - snow
2741  real(RP) :: coef_acc_NGG ! grauepl - graupel
2742  real(RP) :: coef_acc_LSG, coef_acc_NSG ! snow - graupel
2743  !--- (diameter) x (diameter)
2744  real(RP) :: dcdc, dcdi, dcds, dcdg
2745  real(RP) :: drdr, drdi, drds, drdg
2746  real(RP) :: didi, dids, didg
2747  real(RP) :: dsds, dsdg
2748  real(RP) :: dgdg
2749  !--- (terminal velocity) x (terminal velocity)
2750  real(RP) :: vcvc, vcvi, vcvs, vcvg
2751  real(RP) :: vrvr, vrvi, vrvs, vrvg
2752  real(RP) :: vivi, vivs, vivg
2753  real(RP) :: vsvs, vsvg
2754  real(RP) :: vgvg
2755  !
2756  real(RP) :: wx_cri, wx_crs
2757  real(RP) :: coef_emelt
2758  real(RP) :: w1
2759 
2760  real(RP) :: sw
2761  !
2762  integer :: i, j, k
2763  !
2764  if( flag_first )then
2765  rewind( io_fid_conf )
2766  read( io_fid_conf, nml=nm_mp_sn14_collection, end=100 )
2767 100 if( io_l ) write( io_fid_log, nml=nm_mp_sn14_collection )
2768  flag_first = .false.
2769  end if
2770  !
2771  ! [Add] 10/08/03 T.Mitsui
2772  do j = js, je
2773  do i = is, ie
2774  do k = ks, ke
2775  tem(k,i,j) = max( wtem(k,i,j), tem_min ) ! 11/08/30 T.Mitsui
2776  end do
2777  end do
2778  end do
2779 
2780  call moist_psat_ice( esi, tem )
2781 
2782  if( opt_stick_ks96 )then
2783  do j = js, je
2784  do i = is, ie
2785  do k = ks, ke
2786  ! Khain and Sednev (1996), eq.(3.15)
2787  temc = tem(k,i,j) - t00
2788  temc2 = temc*temc
2789  temc3 = temc2*temc
2790  e_dec = max(0.0_rp, a_dec + b_dec*temc + c_dec*temc2 + d_dec*temc3 )
2791  esi_rat = rhoq(i_qv,k,i,j)*rvap*tem(k,i,j)/esi(k,i,j)
2792  e_stick(k,i,j) = min(1.0_rp, e_dec*esi_rat)
2793  end do
2794  end do
2795  end do
2796  else if( opt_stick_co86 )then
2797  do j = js, je
2798  do i = is, ie
2799  do k = ks, ke
2800  ! [Add] 11/08/30 T.Mitsui, Cotton et al. (1986)
2801  temc = min(tem(k,i,j) - t00,0.0_rp)
2802  w1 = 0.035_rp*temc-0.7_rp
2803  e_stick(k,i,j) = 10._rp**w1
2804  end do
2805  end do
2806  end do
2807  else
2808  do j = js, je
2809  do i = is, ie
2810  do k = ks, ke
2811  ! Lin et al. (1983)
2812  temc_m = min(tem(k,i,j) - t00,0.0_rp) ! T < 273.15
2813  e_stick(k,i,j) = exp(0.09_rp*temc_m)
2814  end do
2815  end do
2816  end do
2817  end if
2818  !
2819  profile_start("sn14_collection")
2820 !OCL NOSIMD
2821  do j = js, je
2822  do i = is, ie
2823  do k = ks, ke
2824  !
2825 ! temc_m = min(tem(k,i,j) - T00,0.0_RP) ! T < 273.15
2826  temc_p = max(tem(k,i,j) - t00,0.0_rp) ! T > 273.15
2827  ! averaged diameter using SB06(82)
2828  ave_dc = coef_d(i_qc)*xq(i_c,k,i,j)**b_m(i_qc)
2829  ave_di = coef_d(i_qi)*xq(i_i,k,i,j)**b_m(i_qi)
2830  ave_ds = coef_d(i_qs)*xq(i_s,k,i,j)**b_m(i_qs)
2831  ave_dg = coef_d(i_qg)*xq(i_g,k,i,j)**b_m(i_qg)
2832  !------------------------------------------------------------------------
2833  ! coellection efficiency are given as follows
2834  e_c = max(0.0_rp, min(1.0_rp, (ave_dc-dc0)/(dc1-dc0) ))
2835  sw = 0.5_rp - sign(0.5_rp, di0-ave_di) ! if(ave_di>di0)then sw=1
2836  e_i = e_im * sw
2837  sw = 0.5_rp - sign(0.5_rp, ds0-ave_ds) ! if(ave_ds>ds0)then sw=1
2838  e_s = e_sm * sw
2839  sw = 0.5_rp - sign(0.5_rp, dg0-ave_dg) ! if(ave_dg>dg0)then sw=1
2840  e_g = e_gm * sw
2841  e_ic = e_i*e_c
2842  e_sc = e_s*e_c
2843  e_gc = e_g*e_c
2844  !------------------------------------------------------------------------
2845  ! Collection: a collects b ( assuming particle size a>b )
2846  dcdc = dq_xave(i_c,k,i,j) * dq_xave(i_c,k,i,j)
2847  drdr = dq_xave(i_r,k,i,j) * dq_xave(i_r,k,i,j)
2848  didi = dq_xave(i_i,k,i,j) * dq_xave(i_i,k,i,j)
2849  dsds = dq_xave(i_s,k,i,j) * dq_xave(i_s,k,i,j)
2850  dgdg = dq_xave(i_g,k,i,j) * dq_xave(i_g,k,i,j)
2851  dcdi = dq_xave(i_c,k,i,j) * dq_xave(i_i,k,i,j)
2852  dcds = dq_xave(i_c,k,i,j) * dq_xave(i_s,k,i,j)
2853  dcdg = dq_xave(i_c,k,i,j) * dq_xave(i_g,k,i,j)
2854  drdi = dq_xave(i_r,k,i,j) * dq_xave(i_i,k,i,j)
2855  drds = dq_xave(i_r,k,i,j) * dq_xave(i_s,k,i,j)
2856  drdg = dq_xave(i_r,k,i,j) * dq_xave(i_g,k,i,j)
2857  dids = dq_xave(i_i,k,i,j) * dq_xave(i_s,k,i,j)
2858 ! didg = dq_xave(I_I,k,i,j) * dq_xave(I_G,k,i,j)
2859  dsdg = dq_xave(i_s,k,i,j) * dq_xave(i_g,k,i,j)
2860  !
2861  vcvc = vt_xave(i_c,2,k,i,j)* vt_xave(i_c,2,k,i,j)
2862  vrvr = vt_xave(i_r,2,k,i,j)* vt_xave(i_r,2,k,i,j)
2863  vivi = vt_xave(i_i,2,k,i,j)* vt_xave(i_i,2,k,i,j)
2864  vsvs = vt_xave(i_s,2,k,i,j)* vt_xave(i_s,2,k,i,j)
2865  vgvg = vt_xave(i_g,2,k,i,j)* vt_xave(i_g,2,k,i,j)
2866  vcvi = vt_xave(i_c,2,k,i,j)* vt_xave(i_i,2,k,i,j)
2867  vcvs = vt_xave(i_c,2,k,i,j)* vt_xave(i_s,2,k,i,j)
2868  vcvg = vt_xave(i_c,2,k,i,j)* vt_xave(i_g,2,k,i,j)
2869  vrvi = vt_xave(i_r,2,k,i,j)* vt_xave(i_i,2,k,i,j)
2870  vrvs = vt_xave(i_r,2,k,i,j)* vt_xave(i_s,2,k,i,j)
2871  vrvg = vt_xave(i_r,2,k,i,j)* vt_xave(i_g,2,k,i,j)
2872  vivs = vt_xave(i_i,2,k,i,j)* vt_xave(i_s,2,k,i,j)
2873 ! vivg = vt_xave(I_I,2,k,i,j)* vt_xave(I_G,2,k,i,j)
2874  vsvg = vt_xave(i_s,2,k,i,j)* vt_xave(i_g,2,k,i,j)
2875  !------------------------------------------------------------------------
2876  !
2877  !+++ pattern 1: a + b => a (a>b)
2878  ! (i-c, s-c, g-c, s-i, g-r, s-g)
2879  !------------------------------------------------------------------------
2880  ! cloud-ice => ice
2881  ! reduction term of cloud
2882  coef_acc_lci = &
2883  ( delta_b1(i_qc)*dcdc + delta_ab1(i_qi,i_qc)*dcdi + delta_b0(i_qi)*didi ) &
2884  * ( theta_b1(i_qc)*vcvc - theta_ab1(i_qi,i_qc)*vcvi + theta_b0(i_qi)*vivi &
2885  + sigma_i + sigma_c )**0.5_rp
2886  coef_acc_nci = &
2887  ( delta_b0(i_qc)*dcdc + delta_ab0(i_qi,i_qc)*dcdi + delta_b0(i_qi)*didi ) &
2888  * ( theta_b0(i_qc)*vcvc - theta_ab0(i_qi,i_qc)*vcvi + theta_b0(i_qi)*vivi &
2889  + sigma_i + sigma_c )**0.5_rp
2890  pac(i_liaclc2li,k,i,j)= -0.25_rp*pi*e_ic*rhoq(i_ni,k,i,j)*rhoq(i_qc,k,i,j)*coef_acc_lci
2891  pac(i_niacnc2ni,k,i,j)= -0.25_rp*pi*e_ic*rhoq(i_ni,k,i,j)*rhoq(i_nc,k,i,j)*coef_acc_nci
2892  ! cloud-snow => snow
2893  ! reduction term of cloud
2894  coef_acc_lcs = &
2895  ( delta_b1(i_qc)*dcdc + delta_ab1(i_qs,i_qc)*dcds + delta_b0(i_qs)*dsds ) &
2896  * ( theta_b1(i_qc)*vcvc - theta_ab1(i_qs,i_qc)*vcvs + theta_b0(i_qs)*vsvs &
2897  + sigma_s + sigma_c )**0.5_rp
2898  coef_acc_ncs = &
2899  ( delta_b0(i_qc)*dcdc + delta_ab0(i_qs,i_qc)*dcds + delta_b0(i_qs)*dsds ) &
2900  * ( theta_b0(i_qc)*vcvc - theta_ab0(i_qs,i_qc)*vcvs + theta_b0(i_qs)*vsvs &
2901  + sigma_s + sigma_c )**0.5_rp
2902  pac(i_lsaclc2ls,k,i,j)= -0.25_rp*pi*e_sc*rhoq(i_ns,k,i,j)*rhoq(i_qc,k,i,j)*coef_acc_lcs
2903  pac(i_nsacnc2ns,k,i,j)= -0.25_rp*pi*e_sc*rhoq(i_ns,k,i,j)*rhoq(i_nc,k,i,j)*coef_acc_ncs
2904  ! cloud-graupel => graupel
2905  ! reduction term of cloud
2906  coef_acc_lcg = &
2907  ( delta_b1(i_qc)*dcdc + delta_ab1(i_qg,i_qc)*dcdg + delta_b0(i_qg)*dgdg ) &
2908  * ( theta_b1(i_qc)*vcvc - theta_ab1(i_qg,i_qc)*vcvg + theta_b0(i_qg)*vgvg &
2909  + sigma_g + sigma_c )**0.5_rp
2910  coef_acc_ncg = &
2911  ( delta_b0(i_qc)*dcdc + delta_ab0(i_qg,i_qc)*dcdg + delta_b0(i_qg)*dgdg ) &
2912  * ( theta_b0(i_qc)*vcvc - theta_ab0(i_qg,i_qc)*vcvg + theta_b0(i_qg)*vgvg &
2913  + sigma_g + sigma_c )**0.5_rp
2914  pac(i_lgaclc2lg,k,i,j)= -0.25_rp*pi*e_gc*rhoq(i_ng,k,i,j)*rhoq(i_qc,k,i,j)*coef_acc_lcg
2915  pac(i_ngacnc2ng,k,i,j)= -0.25_rp*pi*e_gc*rhoq(i_ng,k,i,j)*rhoq(i_nc,k,i,j)*coef_acc_ncg
2916  ! snow-graupel => graupel
2917  coef_acc_lsg = &
2918  ( delta_b1(i_qs)*dsds + delta_ab1(i_qg,i_qs)*dsdg + delta_b0(i_qg)*dgdg ) &
2919  * ( theta_b1(i_qs)*vsvs - theta_ab1(i_qg,i_qs)*vsvg + theta_b0(i_qg)*vgvg &
2920  + sigma_g + sigma_s )**0.5_rp
2921  coef_acc_nsg = &
2922  ( delta_b0(i_qs)*dsds + delta_ab0(i_qg,i_qs)*dsdg + delta_b0(i_qg)*dgdg ) &
2923  ! [fix] T.Mitsui 08/05/08
2924  * ( theta_b0(i_qs)*vsvs - theta_ab0(i_qg,i_qs)*vsvg + theta_b0(i_qg)*vgvg &
2925  + sigma_g + sigma_s )**0.5_rp
2926  pac(i_lgacls2lg,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_gs*rhoq(i_ng,k,i,j)*rhoq(i_qs,k,i,j)*coef_acc_lsg
2927  pac(i_ngacns2ng,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_gs*rhoq(i_ng,k,i,j)*rhoq(i_ns,k,i,j)*coef_acc_nsg
2928  !------------------------------------------------------------------------
2929  ! ice-snow => snow
2930  ! reduction term of ice
2931  coef_acc_lis = &
2932  ( delta_b1(i_qi)*didi + delta_ab1(i_qs,i_qi)*dids + delta_b0(i_qs)*dsds ) &
2933  * ( theta_b1(i_qi)*vivi - theta_ab1(i_qs,i_qi)*vivs + theta_b0(i_qs)*vsvs &
2934  + sigma_i + sigma_s )**0.5_rp
2935  coef_acc_nis = &
2936  ( delta_b0(i_qi)*didi + delta_ab0(i_qs,i_qi)*dids + delta_b0(i_qs)*dsds ) &
2937  * ( theta_b0(i_qi)*vivi - theta_ab0(i_qs,i_qi)*vivs + theta_b0(i_qs)*vsvs &
2938  + sigma_i + sigma_s )**0.5_rp
2939  pac(i_liacls2ls,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_si*rhoq(i_ns,k,i,j)*rhoq(i_qi,k,i,j)*coef_acc_lis
2940  pac(i_niacns2ns,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_si*rhoq(i_ns,k,i,j)*rhoq(i_ni,k,i,j)*coef_acc_nis
2941  !
2942  sw = sign(0.5_rp, t00-tem(k,i,j)) + 0.5_rp
2943  ! if ( tem(k,i,j) <= T00 )then
2944  ! rain-graupel => graupel
2945  ! reduction term of rain
2946  ! sw = 1
2947  ! else
2948  ! rain-graupel => rain
2949  ! reduction term of graupel
2950  ! sw = 0
2951  coef_acc_lrg = &
2952  ( ( delta_b1(i_qr)*drdr + delta_ab1(i_qg,i_qr)*drdg + delta_b0(i_qg)*dgdg ) * sw &
2953  + ( delta_b1(i_qg)*dgdg + delta_ab1(i_qr,i_qg)*drdg + delta_b0(i_qr)*drdr ) * (1.0_rp-sw) ) &
2954  * sqrt( ( theta_b1(i_qr)*vrvr - theta_ab1(i_qg,i_qr)*vrvg + theta_b0(i_qg)*vgvg ) * sw &
2955  + ( theta_b1(i_qg)*vgvg - theta_ab1(i_qr,i_qg)*vrvg + theta_b0(i_qr)*vrvr ) * (1.0_rp-sw) &
2956  + sigma_r + sigma_g )
2957  pac(i_lraclg2lg,k,i,j) = -0.25_rp*pi*e_gr*coef_acc_lrg &
2958  * ( rhoq(i_ng,k,i,j)*rhoq(i_qr,k,i,j) * sw &
2959  + rhoq(i_nr,k,i,j)*rhoq(i_qg,k,i,j) * (1.0_rp-sw) )
2960  coef_acc_nrg = &
2961  ( delta_b0(i_qr)*drdr + delta_ab0(i_qg,i_qr)*drdg + delta_b0(i_qg)*dgdg ) &
2962  * ( theta_b0(i_qr)*vrvr - theta_ab0(i_qg,i_qr)*vrvg + theta_b0(i_qg)*vgvg &
2963  + sigma_r + sigma_g )**0.5_rp
2964  pac(i_nracng2ng,k,i,j) = -0.25_rp*pi*e_gr*rhoq(i_ng,k,i,j)*rhoq(i_nr,k,i,j)*coef_acc_nrg
2965  !
2966  !------------------------------------------------------------------------
2967  !
2968  !+++ pattern 2: a + b => c (a>b)
2969  ! (r-i,r-s)
2970  !------------------------------------------------------------------------
2971  ! rain-ice => graupel
2972  ! reduction term of ice
2973  coef_acc_lri_i = &
2974  ( delta_b1(i_qi)*didi + delta_ab1(i_qr,i_qi)*drdi + delta_b0(i_qr)*drdr ) &
2975  * ( theta_b1(i_qi)*vivi - theta_ab1(i_qr,i_qi)*vrvi + theta_b0(i_qr)*vrvr &
2976  + sigma_r + sigma_i )**0.5_rp
2977  coef_acc_nri_i = &
2978  ( delta_b0(i_qi)*didi + delta_ab0(i_qr,i_qi)*drdi + delta_b0(i_qr)*drdr ) &
2979  * ( theta_b0(i_qi)*vivi - theta_ab0(i_qr,i_qi)*vrvi + theta_b0(i_qr)*vrvr &
2980  + sigma_r + sigma_i )**0.5_rp
2981  pac(i_lracli2lg_i,k,i,j)= -0.25_rp*pi*e_ir*rhoq(i_nr,k,i,j)*rhoq(i_qi,k,i,j)*coef_acc_lri_i
2982  pac(i_nracni2ng_i,k,i,j)= -0.25_rp*pi*e_ir*rhoq(i_nr,k,i,j)*rhoq(i_ni,k,i,j)*coef_acc_nri_i
2983  ! reduction term of rain
2984  coef_acc_lri_r = &
2985  ( delta_b1(i_qr)*drdr + delta_ab1(i_qi,i_qr)*drdi + delta_b0(i_qi)*didi ) &
2986  * ( theta_b1(i_qr)*vrvr - theta_ab1(i_qi,i_qr)*vrvi + theta_b0(i_qi)*vivi &
2987  + sigma_r + sigma_i )**0.5_rp
2988  coef_acc_nri_r = &
2989  ( delta_b0(i_qr)*drdr + delta_ab0(i_qi,i_qr)*drdi + delta_b0(i_qi)*didi ) &
2990  * ( theta_b0(i_qr)*vrvr - theta_ab0(i_qi,i_qr)*vrvi + theta_b0(i_qi)*vivi &
2991  + sigma_r + sigma_i )**0.5_rp
2992  pac(i_lracli2lg_r,k,i,j)= -0.25_rp*pi*e_ir*rhoq(i_ni,k,i,j)*rhoq(i_qr,k,i,j)*coef_acc_lri_r
2993  pac(i_nracni2ng_r,k,i,j)= -0.25_rp*pi*e_ir*rhoq(i_ni,k,i,j)*rhoq(i_nr,k,i,j)*coef_acc_nri_r
2994  ! rain-snow => graupel
2995  ! reduction term of snow
2996  coef_acc_lrs_s = &
2997  ( delta_b1(i_qs)*dsds + delta_ab1(i_qr,i_qs)*drds + delta_b0(i_qr)*drdr ) &
2998  * ( theta_b1(i_qs)*vsvs - theta_ab1(i_qr,i_qs)*vrvs + theta_b0(i_qr)*vrvr &
2999  + sigma_r + sigma_s )**0.5_rp
3000  coef_acc_nrs_s = &
3001  ( delta_b0(i_qs)*dsds + delta_ab0(i_qr,i_qs)*drds + delta_b0(i_qr)*drdr ) &
3002  * ( theta_b0(i_qs)*vsvs - theta_ab0(i_qr,i_qs)*vrvs + theta_b0(i_qr)*vrvr &
3003  + sigma_r + sigma_s )**0.5_rp
3004  pac(i_lracls2lg_s,k,i,j)= -0.25_rp*pi*e_sr*rhoq(i_nr,k,i,j)*rhoq(i_qs,k,i,j)*coef_acc_lrs_s
3005  pac(i_nracns2ng_s,k,i,j)= -0.25_rp*pi*e_sr*rhoq(i_nr,k,i,j)*rhoq(i_ns,k,i,j)*coef_acc_nrs_s
3006  ! reduction term of rain
3007  coef_acc_lrs_r = &
3008  ( delta_b1(i_qr)*drdr + delta_ab1(i_qs,i_qr)*drds + delta_b0(i_qs)*dsds ) &
3009  * ( theta_b1(i_qr)*vrvr - theta_ab1(i_qs,i_qr)*vrvs + theta_b0(i_qs)*vsvs &
3010  + sigma_r + sigma_s )**0.5_rp
3011  coef_acc_nrs_r = &
3012  ( delta_b0(i_qr)*drdr + delta_ab0(i_qs,i_qr)*drds + delta_b0(i_qs)*dsds ) &
3013  * ( theta_b0(i_qr)*vrvr - theta_ab0(i_qs,i_qr)*vrvs + theta_b0(i_qs)*vsvs &
3014  + sigma_r + sigma_s )**0.5_rp
3015  pac(i_lracls2lg_r,k,i,j)= -0.25_rp*pi*e_sr*rhoq(i_ns,k,i,j)*rhoq(i_qr,k,i,j)*coef_acc_lrs_r
3016  pac(i_nracns2ng_r,k,i,j)= -0.25_rp*pi*e_sr*rhoq(i_ns,k,i,j)*rhoq(i_nr,k,i,j)*coef_acc_nrs_r
3017  !------------------------------------------------------------------------
3018  !
3019  !+++ pattern 3: a + a => b (i-i)
3020  !
3021  !------------------------------------------------------------------------
3022  ! ice-ice ( reduction is double, but includes double-count)
3023  coef_acc_lii = &
3024  ( delta_b0(i_qi)*didi + delta_ab1(i_qi,i_qi)*didi + delta_b1(i_qi)*didi ) &
3025  * ( theta_b0(i_qi)*vivi - theta_ab1(i_qi,i_qi)*vivi + theta_b1(i_qi)*vivi &
3026  + sigma_i + sigma_i )**0.5_rp
3027  coef_acc_nii = &
3028  ( delta_b0(i_qi)*didi + delta_ab0(i_qi,i_qi)*didi + delta_b0(i_qi)*didi ) &
3029  * ( theta_b0(i_qi)*vivi - theta_ab0(i_qi,i_qi)*vivi + theta_b0(i_qi)*vivi &
3030  + sigma_i + sigma_i )**0.5_rp
3031  pac(i_liacli2ls,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_ii*rhoq(i_ni,k,i,j)*rhoq(i_qi,k,i,j)*coef_acc_lii
3032  pac(i_niacni2ns,k,i,j)= -0.25_rp*pi*e_stick(k,i,j)*e_ii*rhoq(i_ni,k,i,j)*rhoq(i_ni,k,i,j)*coef_acc_nii
3033  !
3034 ! ci_aut(k,i,j) = 0.25_RP*pi*E_ii*rhoq(I_NI,k,i,j)*coef_acc_LII
3035 ! taui_aut(k,i,j) = 1._RP/max(E_stick(k,i,j)*ci_aut(k,i,j),1.E-10_RP)
3036 ! tau_sce(k,i,j) = rhoq(I_QI,k,i,j)/max(rhoq(I_QI,k,i,j)+rhoq(I_QS,k,i,j),1.E-10_RP)
3037  !------------------------------------------------------------------------
3038  !
3039  !+++ pattern 4: a + a => a (s-s)
3040  !
3041  !------------------------------------------------------------------------
3042  ! snow-snow => snow
3043  coef_acc_nss = &
3044  ( delta_b0(i_qs)*dsds + delta_ab0(i_qs,i_qs)*dsds + delta_b0(i_qs)*dsds ) &
3045  * ( theta_b0(i_qs)*vsvs - theta_ab0(i_qs,i_qs)*vsvs + theta_b0(i_qs)*vsvs &
3046  + sigma_s + sigma_s )**0.5_rp
3047  pac(i_nsacns2ns,k,i,j)= -0.125_rp*pi*e_stick(k,i,j)*e_ss*rhoq(i_ns,k,i,j)*rhoq(i_ns,k,i,j)*coef_acc_nss
3048  !
3049  ! graupel-grauple => graupel
3050  coef_acc_ngg = &
3051  ( delta_b0(i_qg)*dgdg + delta_ab0(i_qg,i_qg)*dgdg + delta_b0(i_qg)*dgdg ) &
3052  * ( theta_b0(i_qg)*vgvg - theta_ab0(i_qg,i_qg)*vgvg + theta_b0(i_qg)*vgvg &
3053  + sigma_g + sigma_g )**0.5_rp
3054  pac(i_ngacng2ng,k,i,j)= -0.125_rp*pi*e_stick(k,i,j)*e_gg*rhoq(i_ng,k,i,j)*rhoq(i_ng,k,i,j)*coef_acc_ngg
3055  !
3056  !------------------------------------------------------------------------
3057  !--- Partial conversion
3058  ! SB06(70),(71)
3059  ! i_iconv2g: option whether partial conversions work or not
3060  ! ice-cloud => graupel
3061  sw = 0.5_rp - sign(0.5_rp,di_cri-ave_di) ! if( ave_di > di_cri )then sw=1
3062  wx_cri = cfill_i*dwatr/rho_g*( pi/6.0_rp*rho_g*ave_di*ave_di*ave_di/xq(i_i,k,i,j) - 1.0_rp ) * sw
3063  pq(i_licon,k,i,j) = i_iconv2g * pac(i_liaclc2li,k,i,j)/max(1.0_rp, wx_cri) * sw
3064  pq(i_nicon,k,i,j) = i_iconv2g * pq(i_licon,k,i,j)/xq(i_i,k,i,j) * sw
3065 
3066  ! snow-cloud => graupel
3067  wx_crs = cfill_s*dwatr/rho_g*( pi/6.0_rp*rho_g*ave_ds*ave_ds*ave_ds/xq(i_s,k,i,j) - 1.0_rp )
3068  pq(i_lscon,k,i,j) = i_sconv2g * (pac(i_lsaclc2ls,k,i,j))/max(1.0_rp, wx_crs)
3069  pq(i_nscon,k,i,j) = i_sconv2g * pq(i_lscon,k,i,j)/xq(i_s,k,i,j)
3070  !------------------------------------------------------------------------
3071  !--- enhanced melting( due to collection-freezing of water droplets )
3072  ! originally from Rutledge and Hobbs(1984). eq.(A.21)
3073  ! if T > 273.15 then temc_p=T-273.15, else temc_p=0
3074  ! 08/05/08 [fix] T.Mitsui LHF00 => LHF0
3075  ! melting occurs around T=273K, so LHF0 is suitable both SIMPLE and EXACT,
3076  ! otherwise LHF can have sign both negative(EXACT) and positive(SIMPLE).
3077 !!$ coef_emelt = -CL/LHF00*temc_p
3078  coef_emelt = cl/lhf0*temc_p
3079  ! cloud-graupel
3080  pq(i_lgacm,k,i,j) = coef_emelt*pac(i_lgaclc2lg,k,i,j)
3081  pq(i_ngacm,k,i,j) = pq(i_lgacm,k,i,j)/xq(i_g,k,i,j)
3082  ! rain-graupel
3083  pq(i_lgarm,k,i,j) = coef_emelt*pac(i_lraclg2lg,k,i,j)
3084  pq(i_ngarm,k,i,j) = pq(i_lgarm,k,i,j)/xq(i_g,k,i,j)
3085  ! cloud-snow
3086  pq(i_lsacm,k,i,j) = coef_emelt*(pac(i_lsaclc2ls,k,i,j))
3087  pq(i_nsacm,k,i,j) = pq(i_lsacm,k,i,j)/xq(i_s,k,i,j)
3088  ! rain-snow
3089  pq(i_lsarm,k,i,j) = coef_emelt*(pac(i_lracls2lg_r,k,i,j)+pac(i_lracls2lg_s,k,i,j))
3090  pq(i_nsarm,k,i,j) = pq(i_lsarm,k,i,j)/xq(i_g,k,i,j) ! collect? might be I_S
3091  ! cloud-ice
3092  pq(i_liacm,k,i,j) = coef_emelt*pac(i_liaclc2li,k,i,j)
3093  pq(i_niacm,k,i,j) = pq(i_liacm,k,i,j)/xq(i_i,k,i,j)
3094  ! rain-ice
3095  pq(i_liarm,k,i,j) = coef_emelt*(pac(i_lracli2lg_r,k,i,j)+pac(i_lracli2lg_i,k,i,j))
3096  pq(i_niarm,k,i,j) = pq(i_liarm,k,i,j)/xq(i_g,k,i,j) ! collect? might be I_I
3097  end do
3098  end do
3099  end do
3100  profile_stop("sn14_collection")
3101 
3102  !
3103  return
3104  end subroutine mixed_phase_collection_kij
3105  !----------------------------
3106  ! Auto-conversion, Accretion, Self-collection, Break-up
3107  subroutine aut_acc_slc_brk_kij( &
3108  PQ, &
3109  rhoq, xq, dq_xave, &
3110  rho )
3111  implicit none
3112 
3113  real(RP), intent(out) :: PQ(pq_max,ka,ia,ja)
3114  !
3115  real(RP), intent(in) :: rhoq(qa,ka,ia,ja)
3116  real(RP), intent(in) :: xq(5,ka,ia,ja)
3117  real(RP), intent(in) :: dq_xave(5,ka,ia,ja)
3118  real(RP), intent(in) :: rho(ka,ia,ja)
3119  !
3120  ! parameter for autoconversion
3121  real(RP), parameter :: kcc = 4.44e+9_rp ! collision efficiency [m3/kg2/sec]
3122  real(RP), parameter :: tau_min = 1.e-20_rp ! empirical filter by T.Mitsui
3123  real(RP), parameter :: rx_sep = 1.0_rp/x_sep ! 1/x_sep, 10/08/03 [Add] T.Mitsui
3124  !
3125  ! parameter for accretion
3126  real(RP), parameter :: kcr = 5.8_rp ! collision efficiency [m3/kg2/sec]
3127  real(RP), parameter :: thr_acc = 5.e-5_rp ! threshold for universal function original
3128  !
3129  ! parameter for self collection and collison break-up
3130  real(RP), parameter :: krr = 4.33_rp ! k_rr, S08 (35)
3131  real(RP), parameter :: kaprr = 60.7_rp ! kappa_rr, SB06(11)
3132  real(RP), parameter :: kbr = 1000._rp ! k_br, SB06(14)
3133  real(RP), parameter :: kapbr = 2.3e+3_rp ! kappa_br, SB06(15)
3134  real(RP), parameter :: dr_min = 0.35e-3_rp ! minimum diameter, SB06(13)-(15)
3135  !
3136  ! work variables
3137  real(RP) :: coef_nuc0 ! coefficient of number for Auto-conversion
3138  real(RP) :: coef_nuc1 ! mass
3139  real(RP) :: coef_aut0 ! number
3140  real(RP) :: coef_aut1 ! mass
3141  real(RP) :: lwc ! lc+lr
3142  real(RP) :: tau ! conversion ratio: qr/(qc+qr) ranges [0:1]
3143  real(RP) :: rho_fac ! factor of air density
3144  real(RP) :: psi_aut ! Universal function of Auto-conversion
3145  real(RP) :: psi_acc ! Universal function of Accretion
3146  real(RP) :: psi_brk ! Universal function of Breakup
3147  real(RP) :: ddr ! diameter difference from equilibrium
3148  !
3149  integer :: i, j, k
3150  !
3151  coef_nuc0 = (nu(i_qc)+2.0_rp)/(nu(i_qc)+1.0_rp)
3152  coef_nuc1 = (nu(i_qc)+2.0_rp)*(nu(i_qc)+4.0_rp)/(nu(i_qc)+1.0_rp)/(nu(i_qc)+1.0_rp)
3153  coef_aut0 = -kcc*coef_nuc0
3154  coef_aut1 = -kcc/x_sep/20._rp*coef_nuc1
3155  !
3156  do j = js, je
3157  do i = is, ie
3158  do k = ks, ke
3159  lwc = rhoq(i_qr,k,i,j)+rhoq(i_qc,k,i,j)
3160  if( lwc > xc_min )then
3161  tau = max(tau_min, rhoq(i_qr,k,i,j)/lwc)
3162  else
3163  tau = tau_min
3164  end if
3165  rho_fac = sqrt(rho_0/max(rho(k,i,j),rho_min))
3166  !
3167  ! Auto-conversion ( cloud-cloud => rain )
3168  psi_aut = 400._rp*(tau**0.7_rp)*(1.0_rp - (tau**0.7_rp))**3 ! (6) SB06
3169  pq(i_ncaut,k,i,j) = coef_aut0*rhoq(i_qc,k,i,j)*rhoq(i_qc,k,i,j)*rho_fac*rho_fac ! (9) SB06 sc+aut
3170  ! lc = lwc*(1-tau), lr = lwc*tau
3171  pq(i_lcaut,k,i,j) = coef_aut1*lwc*lwc*xq(i_c,k,i,j)*xq(i_c,k,i,j) & ! (4) SB06
3172  *((1.0_rp-tau)*(1.0_rp-tau) + psi_aut)*rho_fac*rho_fac !
3173  pq(i_nraut,k,i,j) = -rx_sep*pq(i_lcaut,k,i,j) ! (A7) SB01
3174  !
3175  ! Accretion ( cloud-rain => rain )
3176  psi_acc =(tau/(tau+thr_acc))**4 ! (8) SB06
3177  pq(i_lcacc,k,i,j) = -kcr*rhoq(i_qc,k,i,j)*rhoq(i_qr,k,i,j)*rho_fac*psi_acc ! (7) SB06
3178  pq(i_ncacc,k,i,j) = -kcr*rhoq(i_nc,k,i,j)*rhoq(i_qr,k,i,j)*rho_fac*psi_acc ! (A6) SB01
3179  !
3180  ! Self-collection ( rain-rain => rain )
3181  pq(i_nrslc,k,i,j) = -krr*rhoq(i_nr,k,i,j)*rhoq(i_qr,k,i,j)*rho_fac ! (A.8) SB01
3182  !
3183  ! Collisional breakup of rain
3184  ddr = min(1.e-3_rp, dq_xave(i_r,k,i,j) - dr_eq )
3185  if (dq_xave(i_r,k,i,j) < dr_min )then ! negligible
3186  psi_brk = -1.0_rp
3187  pq(i_nrbrk,k,i,j) = 0.0_rp
3188  else if (dq_xave(i_r,k,i,j) <= dr_eq )then
3189  psi_brk = kbr*ddr + 1.0_rp ! (14) SB06 (+1 is necessary)
3190  pq(i_nrbrk,k,i,j) = - (psi_brk + 1.0_rp)*pq(i_nrslc,k,i,j) ! (13) SB06
3191  else
3192  psi_brk = 2.0_rp*exp(kapbr*ddr) - 1.0_rp ! (15) SB06
3193  pq(i_nrbrk,k,i,j) = - (psi_brk + 1.0_rp)*pq(i_nrslc,k,i,j) ! (13) SB06
3194  end if
3195  !
3196  end do
3197  end do
3198  end do
3199  !
3200  return
3201  end subroutine aut_acc_slc_brk_kij
3202  ! Vapor Deposition, Ice Melting
3203  subroutine dep_vapor_melt_ice_kij( &
3204  PQ, & ! out
3205  rho, tem, pre, qd, & ! in
3206  rhoq, & ! in
3207  esw, esi, & ! in
3208  xq, vt_xave, dq_xave ) ! in
3209  use scale_const, only: &
3210  eps => const_eps
3211  implicit none
3212 
3213  ! Diffusion growth or Evaporation, Sublimation
3214  real(RP), intent(out) :: PQ(pq_max,ka,ia,ja) ! mass change for cloud, [Add] 09/08/18 T.Mitsui
3215 
3216  real(RP), intent(in) :: rho(ka,ia,ja) ! air density
3217  real(RP), intent(in) :: tem(ka,ia,ja) ! air temperature
3218  real(RP), intent(in) :: pre(ka,ia,ja) ! air pressure
3219  real(RP), intent(in) :: qd(ka,ia,ja) ! mixing ratio of dry air
3220  real(RP), intent(in) :: esw(ka,ia,ja) ! saturation vapor pressure(liquid water)
3221  real(RP), intent(in) :: esi(ka,ia,ja) ! saturation vapor pressure(solid water)
3222  real(RP), intent(in) :: rhoq(qa,ka,ia,ja)
3223  real(RP), intent(in) :: xq(5,ka,ia,ja) ! mean mass
3224  ! Notice following values differ from mean terminal velocity or diameter.
3225  ! mean(vt(x)) /= vt(mean(x)) and mean(D(x)) /= D(mean(x))
3226  ! Following ones are vt(mean(x)) and D(mean(x)).
3227  real(RP), intent(in) :: vt_xave(5,2,ka,ia,ja) ! terminal velocity of mean cloud 09/08/18 [Add], T.Mitsui
3228  !
3229  real(RP), intent(in) :: dq_xave(5,ka,ia,ja) ! diameter
3230  !
3231  real(RP) :: rho_lim ! limited density 09/08/18 T.Mitsui
3232  real(RP) :: temc_lim ! limited temperature[celsius] 09/08/18 T.Mitsui
3233  real(RP) :: pre_lim ! limited density 09/08/18 T.Mitsui
3234  real(RP) :: temc ! temperature[celsius]
3235 ! real(RP) :: pv ! vapor pressure
3236  real(RP) :: qv ! mixing ratio of water vapor [Add] 09/08/18
3237 ! real(RP) :: ssw ! super saturation ratio(liquid water)
3238 ! real(RP) :: ssi ! super saturation ratio(ice water)
3239  real(RP) :: nua, r_nua ! kinematic viscosity of air
3240  real(RP) :: mua ! viscosity of air
3241  real(RP) :: Kalfa ! thermal conductance
3242  real(RP) :: Dw ! diffusivity of water vapor
3243  real(RP) :: Dt ! diffusivity of heat
3244  real(RP) :: Gw, Gi ! diffusion factor by balance between heat and vapor
3245  real(RP) :: Gwr, Gii, Gis, Gig ! for rain, ice, snow and graupel.
3246  real(RP) :: Gm ! melting factor by balance between heat and vapor
3247  real(RP) :: Nsc_r3 !
3248  ! [Mod] 11/08/30 T.Mitsui, considering large and small branches
3249 ! real(RP) :: Nrecs_r2 ! 09/08/18 [Add] T.Mitsui
3250  real(RP) :: Nrers_r2, Nreis_r2 !
3251  real(RP) :: Nress_r2, Nregs_r2 !
3252 ! real(RP) :: Nrecl_r2 ! 09/08/18 [Add] T.Mitsui
3253  real(RP) :: Nrerl_r2, Nreil_r2 !
3254  real(RP) :: Nresl_r2, Nregl_r2 !
3255  real(RP) :: NscNrer_s, NscNrer_l
3256  real(RP) :: NscNrei_s, NscNrei_l
3257  real(RP) :: NscNres_s, NscNres_l
3258  real(RP) :: NscNreg_s, NscNreg_l
3259  real(RP) :: ventLR_s, ventLR_l
3260  real(RP) :: ventNI_s, ventNI_l, ventLI_s, ventLI_l
3261  real(RP) :: ventNS_s, ventNS_l, ventLS_s, ventLS_l
3262  real(RP) :: ventNG_s, ventNG_l, ventLG_s, ventLG_l
3263  !
3264  real(RP) :: wtr, wti, wts, wtg
3265  real(RP), parameter :: r_14=1.0_rp/1.4_rp
3266  real(RP), parameter :: r_15=1.0_rp/1.5_rp
3267  !
3268  real(RP) :: ventLR
3269  real(RP) :: ventNI, ventLI
3270  real(RP) :: ventNS, ventLS
3271  real(RP) :: ventNG, ventLG
3272  !
3273  real(RP), parameter :: Re_max=1.e+3_rp
3274  real(RP), parameter :: Re_min=1.e-4_rp
3275 
3276  real(RP) :: sw
3277  !
3278  integer :: i, j, k
3279  !
3280  ! Notice,T.Mitsui
3281  ! Vapor deposition and melting would not be solved iteratively to reach equilibrium.
3282  ! Because following phenomena are not adjustment but transition.
3283  ! Just time-scales differ among them.
3284  ! If we would treat more appropreately, there would be time-splitting method to solve each ones.
3285 
3286  profile_start("sn14_dep_vapor")
3287  do j = js, je
3288  do i = is, ie
3289  do k = ks, ke
3290  temc = tem(k,i,j) - t00 ! degC
3291  temc_lim= max(temc, -40._rp ) ! [Add] 09/08/18 T.Mitsui, Pruppacher and Klett(1997),(13-3)
3292  rho_lim = max(rho(k,i,j),rho_min) ! [Add] 09/08/18 T.Mitsui
3293  qv = rhoq(i_qv,k,i,j)/rho_lim
3294  pre_lim = rho_lim*(qd(k,i,j)*rdry + qv*rvap)*(temc_lim+t00) ![Add] 09/08/18 T.Mitsui
3295  !--------------------------------------------------------------------
3296  ! Diffusion growth part is described in detail
3297  ! by Pruppacher and Klett (1997) Sec. 13.2(liquid) and 13.3(solid)
3298  !
3299  ! G:factor of thermal diffusion(1st.term) and vapor diffusion(2nd. term)
3300  ! SB06(23),(38), Lin et al(31),(52) or others
3301  ! Dw is introduced by Pruppacher and Klett(1997),(13-3)
3302  dw = 0.211e-4_rp* (((temc_lim+t00)/t00)**1.94_rp) *(p00/pre_lim)
3303  kalfa = ka0 + temc_lim*dka_dt
3304  mua = mua0 + temc_lim*dmua_dt
3305  nua = mua/rho_lim
3306  r_nua = 1.0_rp/nua
3307  gw = (lhv0/kalfa/tem(k,i,j))*(lhv0/rvap/tem(k,i,j)-1.0_rp)+(rvap*tem(k,i,j)/dw/esw(k,i,j))
3308  gi = (lhs0/kalfa/tem(k,i,j))*(lhs0/rvap/tem(k,i,j)-1.0_rp)+(rvap*tem(k,i,j)/dw/esi(k,i,j))
3309  ! capacities account for their surface geometries
3310  gwr = 4.0_rp*pi/cap(i_qr)/gw
3311  gii = 4.0_rp*pi/cap(i_qi)/gi
3312  gis = 4.0_rp*pi/cap(i_qs)/gi
3313  gig = 4.0_rp*pi/cap(i_qg)/gi
3314  ! vent: ventilation effect( asymmetry vapor field around particles due to aerodynamic )
3315  ! SB06 (30),(31) and each coefficient is by (88),(89)
3316  nsc_r3 = (nua/dw)**(0.33333333_rp) ! (Schmidt number )^(1/3)
3317  !
3318 ! Nrecs_r2 = sqrt(max(Re_min,min(Re_max,vt_xave(I_C,1,k,i,j)*dq_xave(I_C,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) cloud
3319  nrers_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_r,1,k,i,j)*dq_xave(i_r,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) rain
3320  nreis_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_i,1,k,i,j)*dq_xave(i_i,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
3321  nress_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_s,1,k,i,j)*dq_xave(i_s,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) snow
3322  nregs_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_g,1,k,i,j)*dq_xave(i_g,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) graupel
3323  !
3324 ! Nrecl_r2 = sqrt(max(Re_min,min(Re_max,vt_xave(I_C,2,k,i,j)*dq_xave(I_C,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) cloud
3325  nrerl_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_r,2,k,i,j)*dq_xave(i_r,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) rain
3326  nreil_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_i,2,k,i,j)*dq_xave(i_i,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) cloud ice
3327  nresl_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_s,2,k,i,j)*dq_xave(i_s,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) snow
3328  nregl_r2 = sqrt(max(re_min,min(re_max,vt_xave(i_g,2,k,i,j)*dq_xave(i_g,k,i,j)*r_nua))) ! (Reynolds number)^(1/2) graupel
3329  nscnrer_s=nsc_r3*nrers_r2 ! small rain
3330  nscnrer_l=nsc_r3*nrerl_r2 ! large rain
3331  !
3332  nscnrei_s=nsc_r3*nreis_r2 ! small ice
3333  nscnrei_l=nsc_r3*nreil_r2 ! large ice
3334  !
3335  nscnres_s=nsc_r3*nress_r2 ! small snow
3336  nscnres_l=nsc_r3*nresl_r2 ! large snow
3337  !
3338  nscnreg_s=nsc_r3*nregs_r2 ! small snow
3339  nscnreg_l=nsc_r3*nregl_r2 ! large snow
3340  !
3341  ventlr_s = ah_vent1(i_qr,1) + bh_vent1(i_qr,1)*nscnrer_s
3342  ventlr_l = ah_vent1(i_qr,2) + bh_vent1(i_qr,2)*nscnrer_l
3343  !
3344  ventni_s = ah_vent0(i_qi,1) + bh_vent0(i_qi,1)*nscnrei_s
3345  ventni_l = ah_vent0(i_qi,2) + bh_vent0(i_qi,2)*nscnrei_l
3346  ventli_s = ah_vent1(i_qi,1) + bh_vent1(i_qi,1)*nscnrei_s
3347  ventli_l = ah_vent1(i_qi,2) + bh_vent1(i_qi,2)*nscnrei_l
3348  !
3349  ventns_s = ah_vent0(i_qs,1) + bh_vent0(i_qs,1)*nscnres_s
3350  ventns_l = ah_vent0(i_qs,2) + bh_vent0(i_qs,2)*nscnres_l
3351  ventls_s = ah_vent1(i_qs,1) + bh_vent1(i_qs,1)*nscnres_s
3352  ventls_l = ah_vent1(i_qs,2) + bh_vent1(i_qs,2)*nscnres_l
3353  !
3354  ventng_s = ah_vent0(i_qg,1) + bh_vent0(i_qg,1)*nscnreg_s
3355  ventng_l = ah_vent0(i_qg,2) + bh_vent0(i_qg,2)*nscnreg_l
3356  ventlg_s = ah_vent1(i_qg,1) + bh_vent1(i_qg,1)*nscnreg_s
3357  ventlg_l = ah_vent1(i_qg,2) + bh_vent1(i_qg,2)*nscnreg_l
3358  !
3359  ! branch is 1.4 for rain, snow, graupel; is 1.0 for ice (PK97, 13-60,-61,-88,-89).
3360  !
3361  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
3362  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
3363  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
3364  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
3365  ! interpolation between two branches
3366  ventni = (1.0_rp-wti)*ventni_s + wti*ventni_l
3367  ventns = (1.0_rp-wts)*ventns_s + wts*ventns_l
3368  ventng = (1.0_rp-wtg)*ventng_s + wtg*ventng_l
3369  !
3370  ventlr = (1.0_rp-wtr)*ventlr_s + wtr*ventlr_l
3371  ventli = (1.0_rp-wti)*ventli_s + wti*ventli_l
3372  ventls = (1.0_rp-wts)*ventls_s + wts*ventls_l
3373  ventlg = (1.0_rp-wtg)*ventlg_s + wtg*ventlg_l
3374  !
3375  ! SB06(29)
3376  ! [Mod] 08/05/08 T.Mitsui, recover PNXdep, and rain is only evaporation.
3377  ! Ni, Ns, Ng should decrease in nature so we add this term.
3378  ! And vapor deposition never occur unless number exist.
3379  ! [Add comment] 09/08/18
3380  ! recover condensation/evaporation of rain,
3381  ! and ventilation effects are not taken into account for cloud.
3382  !
3383 !!$***************************************************************************
3384 !!$ NOTICE:
3385 !!$ 09/08/18 [Mod] Hereafter PLxdep means inverse of timescale.
3386 !!$***************************************************************************
3387 !!$ PQ(I_LCdep,k,i,j) = Gwr*ssw*rhoq(I_NC,k,i,j)*dq_xave(I_C,k,i,j)*coef_deplc
3388 !!$ PQ(I_LRdep,k,i,j) = Gwr*ssw*rhoq(I_NR,k,i,j)*dq_xave(I_R,k,i,j)*ventLR
3389 !!$ PQ(I_LIdep,k,i,j) = Gii*ssi*rhoq(I_NI,k,i,j)*dq_xave(I_I,k,i,j)*ventLI
3390 !!$ PQ(I_LSdep,k,i,j) = Gis*ssi*rhoq(I_NS,k,i,j)*dq_xave(I_S,k,i,j)*ventLS
3391 !!$ PQ(I_LGdep,k,i,j) = Gig*ssi*rhoq(I_NG,k,i,j)*dq_xave(I_G,k,i,j)*ventLG
3392  pq(i_lcdep,k,i,j) = gwr*rhoq(i_nc,k,i,j)*dq_xave(i_c,k,i,j)*coef_deplc
3393  pq(i_lrdep,k,i,j) = gwr*rhoq(i_nr,k,i,j)*dq_xave(i_r,k,i,j)*ventlr
3394  pq(i_lidep,k,i,j) = gii*rhoq(i_ni,k,i,j)*dq_xave(i_i,k,i,j)*ventli
3395  pq(i_lsdep,k,i,j) = gis*rhoq(i_ns,k,i,j)*dq_xave(i_s,k,i,j)*ventls
3396  pq(i_lgdep,k,i,j) = gig*rhoq(i_ng,k,i,j)*dq_xave(i_g,k,i,j)*ventlg
3397  pq(i_nrdep,k,i,j) = pq(i_lrdep,k,i,j)/xq(i_r,k,i,j)
3398  pq(i_nidep,k,i,j) = 0.0_rp
3399  pq(i_nsdep,k,i,j) = pq(i_lsdep,k,i,j)/xq(i_s,k,i,j)
3400  pq(i_ngdep,k,i,j) = pq(i_lgdep,k,i,j)/xq(i_g,k,i,j)
3401  !
3402  !------------------------------------------------------------------------
3403  ! Melting part is described by Pruppacher and Klett (1997) Sec.16.3.1
3404  ! Here we omit "Shedding" of snow-flakes and ice-particles.
3405  ! "Shedding" may be applicative if you refer
3406  ! eq.(38) in Cotton etal.(1986) Jour. Clim. Appl. Meteor. p.1658-1680.
3407  ! SB06(73)
3408  dt = kalfa/(cpvap*rho_0)
3409  ! Gm: factor caused by balance between
3410  ! "water evaporation cooling(1st.)" and "fusion heating(2nd.)"
3411  ! SB06(76)
3412  ! [fix] 08/05/08 T.Mitsui LHF00 => EMELT and esw => PSAT0
3413  ! LHS0 is more suitable than LHS because melting occurs around 273.15 K.
3414  gm = 2.0_rp*pi/emelt&
3415  * ( (kalfa*dt/dw)*(temc) + (dw*lhs0/rvap)*(esi(k,i,j)/tem(k,i,j)-psat0/t00) )
3416  ! SB06(76)
3417  ! Notice! melting only occurs where T > 273.15 K else doesn't.
3418  ! [fix] 08/05/08 T.Mitsui, Gm could be both positive and negative value.
3419  ! See Pruppacher and Klett(1997) eq.(16-79) or Rasmussen and Pruppacher(1982)
3420  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
3421  ! if Gm==0 then rh and tem is critical value for melting process.
3422  ! 08/05/16 [Mod] T.Mitsui, change term of PLimlt. N_i => L_i/ (limited x_i)
3423  ! because melting never occur when N_i=0.
3424  pq(i_limlt,k,i,j) = - gm * rhoq(i_qi,k,i,j)*dq_xave(i_i,k,i,j)*ventli/xq(i_i,k,i,j) * sw
3425  ! [Mod] 08/08/23 T.Mitsui for Seifert(2008)
3426  pq(i_nimlt,k,i,j) = - gm * rhoq(i_ni,k,i,j)*dq_xave(i_i,k,i,j)*ventni/xq(i_i,k,i,j) * sw ! 09/08/18 [Mod] recover, T.Mitsui
3427  pq(i_lsmlt,k,i,j) = - gm * rhoq(i_qs,k,i,j)*dq_xave(i_s,k,i,j)*ventls/xq(i_s,k,i,j) * sw
3428  ! [Mod] 08/08/23 T.Mitsui for Seifert(2008)
3429  pq(i_nsmlt,k,i,j) = - gm * rhoq(i_ns,k,i,j)*dq_xave(i_s,k,i,j)*ventns/xq(i_s,k,i,j) * sw ! 09/08/18 [Mod] recover, T.Mitsui
3430  pq(i_lgmlt,k,i,j) = - gm * rhoq(i_qg,k,i,j)*dq_xave(i_g,k,i,j)*ventlg/xq(i_g,k,i,j) * sw
3431  ! [Mod] 08/08/23 T.Mitsui for Seifert(2008)
3432  pq(i_ngmlt,k,i,j) = - gm * rhoq(i_ng,k,i,j)*dq_xave(i_g,k,i,j)*ventng/xq(i_g,k,i,j) * sw ! 09/08/18 [Mod] recover, T.Mitsui
3433 
3434  end do
3435  end do
3436  end do
3437  profile_stop("sn14_dep_vapor")
3438  !
3439  return
3440  end subroutine dep_vapor_melt_ice_kij
3441  !-----------------------------------------------------------------------------
3442  subroutine freezing_water_kij( &
3443  dt, &
3444  PQ, &
3445  rhoq, xq, tem )
3446  !
3447  ! In this subroutine,
3448  ! We assumed surface temperature of droplets are same as environment.
3449  implicit none
3450 
3451  real(DP), intent(in) :: dt
3452  real(RP), intent(out):: PQ(pq_max,ka,ia,ja)
3453  !
3454  real(RP), intent(in) :: tem(ka,ia,ja)
3455  !
3456  real(RP), intent(in) :: rhoq(qa,ka,ia,ja)
3457  real(RP), intent(in) :: xq(5,ka,ia,ja)
3458  !
3459  real(RP), parameter :: temc_min = -65.0_rp
3460  real(RP), parameter :: a_het = 0.2_rp ! SB06 (44)
3461  real(RP), parameter :: b_het = 0.65_rp ! SB06 (44)
3462  !
3463  real(RP) :: coef_m2_c
3464  real(RP) :: coef_m2_r
3465  ! temperature [celsius]
3466  real(RP) :: temc, temc2, temc3, temc4
3467  ! temperature function of homegenous/heterogenous freezing
3468  real(RP) :: Jhom, Jhet
3469  real(RP) :: rdt
3470  !
3471  integer :: i,j,k
3472  !
3473  rdt = 1.0_rp/dt
3474  !
3475  coef_m2_c = coef_m2(i_qc)
3476  coef_m2_r = coef_m2(i_qr)
3477  !
3478  profile_start("sn14_freezing")
3479  do j = js, je
3480  do i = is, ie
3481  do k = ks, ke
3482  temc = max( tem(k,i,j) - t00, temc_min )
3483  ! These cause from aerosol-droplet interaction.
3484  ! Bigg(1953) formula, Khain etal.(2000) eq.(4.5), Pruppacher and Klett(1997) eq.(9-48)
3485  jhet = a_het*exp( -b_het*temc - 1.0_rp )
3486  ! These cause in nature.
3487  ! Cotton and Field 2002, QJRMS. (12)
3488  if( temc < -65.0_rp )then
3489  jhom = 10.0_rp**(24.37236_rp)*1.e+3_rp
3490  jhet = a_het*exp( 65.0_rp*b_het - 1.0_rp ) ! 09/04/14 [Add], fixer T.Mitsui
3491  else if( temc < -30.0_rp ) then
3492  temc2 = temc*temc
3493  temc3 = temc*temc2
3494  temc4 = temc2*temc2
3495  jhom = 10.0_rp**(&
3496  - 243.40_rp - 14.75_rp*temc - 0.307_rp*temc2 &
3497  - 0.00287_rp*temc3 - 0.0000102_rp*temc4 ) *1.e+3_rp
3498  else if( temc < 0.0_rp) then
3499  jhom = 10._rp**(-7.63_rp-2.996_rp*(temc+30.0_rp))*1.e+3_rp
3500  else
3501  jhom = 0.0_rp
3502  jhet = 0.0_rp
3503  end if
3504  ! Note, xc should be limited in range[xc_min:xc_max].
3505  ! and PNChom need to be calculated by NC
3506  ! because reduction rate of Nc need to be bound by NC.
3507  ! For the same reason PLChom also bound by LC and xc.
3508  ! Basically L and N should be independent
3509  ! but average particle mass x should be in suitable range.
3510  ! Homogenous Freezing
3511  pq(i_lchom,k,i,j) = 0.0_rp
3512  pq(i_nchom,k,i,j) = 0.0_rp
3513  ! Heterogenous Freezing
3514  pq(i_lchet,k,i,j) = -rdt*rhoq(i_qc,k,i,j)*( 1.0_rp - exp( -coef_m2_c*xq(i_c,k,i,j)*(jhet+jhom)*dt ) )
3515  pq(i_nchet,k,i,j) = -rdt*rhoq(i_nc,k,i,j)*( 1.0_rp - exp( - xq(i_c,k,i,j)*(jhet+jhom)*dt ) )
3516  pq(i_lrhet,k,i,j) = -rdt*rhoq(i_qr,k,i,j)*( 1.0_rp - exp( -coef_m2_r*xq(i_r,k,i,j)*(jhet+jhom)*dt ) )
3517  pq(i_nrhet,k,i,j) = -rdt*rhoq(i_nr,k,i,j)*( 1.0_rp - exp( - xq(i_r,k,i,j)*(jhet+jhom)*dt ) )
3518  end do
3519  end do
3520  end do
3521  profile_stop("sn14_freezing")
3522  !
3523  return
3524  end subroutine freezing_water_kij
3525  !-----------------------------------------------------------------------------
3526  subroutine mp_terminal_velocity( &
3527  velw, &
3528  rhoq, &
3529  DENS, &
3530  temp, &
3531  pres )
3532  use scale_const, only: &
3533  const_undef
3534  implicit none
3535 
3536  real(RP), intent(out) :: velw(ka,ia,ja,qa) ! terminal velocity of cloud mass
3537  real(RP), intent(in) :: rhoq(qa,ka,ia,ja) ! rho * q
3538  real(RP), intent(in) :: DENS(ka,ia,ja) ! rho
3539  real(RP), intent(in) :: temp(ka,ia,ja) ! temperature
3540  real(RP), intent(in) :: pres(ka,ia,ja) ! pressure
3541 
3542  real(RP) :: xq ! average mass of 1 particle( mass/number )
3543 
3544  real(RP) :: rhofac ! density factor for terminal velocity( air friction )
3545  real(RP) :: rhofac_q(5)
3546 
3547  real(RP) :: rlambdar ! work for diagnosis of Rain DSD ( Seifert, 2008 )
3548  real(RP) :: mud_r
3549  real(RP) :: dq, dql ! weigthed diameter. Improved Rogers etal. (1993) formula by T.Mitsui
3550 
3551 
3552  real(RP) :: weight ! weighting coefficient for 2-branches is determined by ratio between 0.745mm and weighted diameter. SB06 Table.1
3553  real(RP) :: velq_s ! terminal velocity for small branch of Rogers formula
3554  real(RP) :: velq_l ! terminal velocity for large branch of Rogers formula
3555 
3556  real(RP) :: tmp
3557  integer :: k, i, j, iq
3558  !---------------------------------------------------------------------------
3559 
3560  profile_start("sn14_terminal_vel")
3561 
3562  mud_r = 3.0_rp * nu(i_qr) + 2.0_rp
3563 
3564 !OCL XFILL
3565  do j = js, je
3566  do i = is, ie
3567  do k = 1, ka
3568  velw(k,i,j,i_qv) = const_undef
3569  end do
3570  end do
3571  end do
3572 
3573  do j = js, je
3574  do i = is, ie
3575  do k = ks, ke
3576  rhofac = rho_0 / max( dens(k,i,j), rho_min )
3577 
3578  ! QC
3579  rhofac_q(i_c) = rhofac ** gamma_v(i_qc)
3580  xq = max( xqmin(i_qc), min( xqmax(i_qc), rhoq(i_qc,k,i,j) / ( rhoq(i_nc,k,i,j) + nqmin(i_qc) ) ) )
3581 
3582  velw(k,i,j,i_qc) = -rhofac_q(i_c) * coef_vt1(i_qc,1) * xq**beta_v(i_qc,1)
3583  ! NC
3584  velw(k,i,j,i_nc) = -rhofac_q(i_c) * coef_vt0(i_qc,1) * xq**beta_vn(i_qc,1)
3585 
3586  ! QR
3587  rhofac_q(i_r) = rhofac ** gamma_v(i_qr)
3588  xq = max( xqmin(i_qr), min( xqmax(i_qr), rhoq(i_qr,k,i,j) / ( rhoq(i_nr,k,i,j) + nqmin(i_qr) ) ) )
3589 
3590  rlambdar = a_m(i_qr) * xq**b_m(i_qr) &
3591  * ( (mud_r+3.0_rp) * (mud_r+2.0_rp) * (mud_r+1.0_rp) )**(-0.333333333_rp)
3592  dq = ( 4.0_rp + mud_r ) * rlambdar ! D^(3)+mu weighted mean diameter
3593  dql = dq
3594  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + tanh( pi * log( dq/d_vtr_branch ) ) ) ) )
3595 
3596  velq_s = coef_vtr_ar2 * dq &
3597  * ( 1.0_rp - ( 1.0_rp + coef_vtr_br2*rlambdar )**(-5.0_rp-mud_r) )
3598  velq_l = coef_vtr_ar1 - coef_vtr_br1 &
3599  * ( 1.0_rp + coef_vtr_cr1*rlambdar )**(-4.0_rp-mud_r)
3600  velw(k,i,j,i_qr) = -rhofac_q(i_r) &
3601  * ( velq_l * ( weight ) &
3602  + velq_s * ( 1.0_rp - weight ) )
3603  ! NR
3604  dq = ( 1.0_rp + mud_r ) * rlambdar
3605  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + tanh( pi * log( dq/d_vtr_branch ) ) ) ) )
3606 
3607  velq_s = coef_vtr_ar2 * dql &
3608  * ( 1.0_rp - ( 1.0_rp + coef_vtr_br2*rlambdar )**(-2.0_rp-mud_r) )
3609  velq_l = coef_vtr_ar1 - coef_vtr_br1 &
3610  * ( 1.0_rp + coef_vtr_cr1*rlambdar )**(-1.0_rp-mud_r)
3611  velw(k,i,j,i_nr) = -rhofac_q(i_r) &
3612  * ( velq_l * ( weight ) &
3613  + velq_s * ( 1.0_rp - weight ) )
3614 
3615  ! QI
3616  rhofac_q(i_i) = ( pres(k,i,j)/pre0_vt )**a_pre0_vt * ( temp(k,i,j)/tem0_vt )**a_tem0_vt
3617  xq = max( xqmin(i_qi), min( xqmax(i_qi), rhoq(i_qi,k,i,j) / ( rhoq(i_ni,k,i,j) + nqmin(i_qi) ) ) )
3618 
3619  tmp = a_m(i_qi) * xq**b_m(i_qi)
3620  dq = coef_dave_l(i_qi) * tmp
3621  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_li ) ) ) )
3622 
3623  velq_s = coef_vt1(i_qi,1) * xq**beta_v(i_qi,1)
3624  velq_l = coef_vt1(i_qi,2) * xq**beta_v(i_qi,2)
3625  velw(k,i,j,i_qi) = -rhofac_q(i_i) &
3626  * ( velq_l * ( weight ) &
3627  + velq_s * ( 1.0_rp - weight ) )
3628  ! NI
3629  dq = coef_dave_n(i_qi) * tmp
3630  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_ni ) ) ) )
3631 
3632  velq_s = coef_vt0(i_qi,1) * xq**beta_vn(i_qi,1)
3633  velq_l = coef_vt0(i_qi,2) * xq**beta_vn(i_qi,2)
3634  velw(k,i,j,i_ni) = -rhofac_q(i_i) &
3635  * ( velq_l * ( weight ) &
3636  + velq_s * ( 1.0_rp - weight ) )
3637 
3638  ! QS
3639  rhofac_q(i_s) = rhofac_q(i_i)
3640  xq = max( xqmin(i_qs), min( xqmax(i_qs), rhoq(i_qs,k,i,j) / ( rhoq(i_ns,k,i,j) + nqmin(i_qs) ) ) )
3641 
3642  tmp = a_m(i_qs) * xq**b_m(i_qs)
3643  dq = coef_dave_l(i_qs) * tmp
3644  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_ls ) ) ) )
3645 
3646  velq_s = coef_vt1(i_qs,1) * xq**beta_v(i_qs,1)
3647  velq_l = coef_vt1(i_qs,2) * xq**beta_v(i_qs,2)
3648  velw(k,i,j,i_qs) = -rhofac_q(i_s) &
3649  * ( velq_l * ( weight ) &
3650  + velq_s * ( 1.0_rp - weight ) )
3651  ! NS
3652  dq = coef_dave_n(i_qs) * tmp
3653  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_ns ) ) ) )
3654 
3655  velq_s = coef_vt0(i_qs,1) * xq**beta_vn(i_qs,1)
3656  velq_l = coef_vt0(i_qs,2) * xq**beta_vn(i_qs,2)
3657  velw(k,i,j,i_ns) = -rhofac_q(i_s) &
3658  * ( velq_l * ( weight ) &
3659  + velq_s * ( 1.0_rp - weight ) )
3660 
3661  ! QG
3662  rhofac_q(i_g) = rhofac_q(i_i)
3663  xq = max( xqmin(i_qg), min( xqmax(i_qg), rhoq(i_qg,k,i,j) / ( rhoq(i_ng,k,i,j) + nqmin(i_qg) ) ) )
3664 
3665  tmp = a_m(i_qg) * xq**b_m(i_qg)
3666  dq = coef_dave_l(i_qg) * tmp
3667  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_lg ) ) ) )
3668 
3669  velq_s = coef_vt1(i_qg,1) * xq**beta_v(i_qg,1)
3670  velq_l = coef_vt1(i_qg,2) * xq**beta_v(i_qg,2)
3671  velw(k,i,j,i_qg) = -rhofac_q(i_g) &
3672  * ( velq_l * ( weight ) &
3673  + velq_s * ( 1.0_rp - weight ) )
3674  ! NG
3675  dq = coef_dave_n(i_qg) * tmp
3676  weight = min( 1.0_rp, max( 0.0_rp, 0.5_rp * ( 1.0_rp + log( dq/d0_ng ) ) ) )
3677 
3678  velq_s = coef_vt0(i_qg,1) * xq**beta_vn(i_qg,1)
3679  velq_l = coef_vt0(i_qg,2) * xq**beta_vn(i_qg,2)
3680  velw(k,i,j,i_ng) = -rhofac_q(i_g) &
3681  * ( velq_l * ( weight ) &
3682  + velq_s * ( 1.0_rp - weight ) )
3683  enddo
3684  enddo
3685  enddo
3686 
3687  do iq = i_qc, i_ng
3688  do j = js, je
3689  do i = is, ie
3690  velw(1:ks-2,i,j,iq) = const_undef
3691  velw(ks-1,i,j,iq) = velw(ks,i,j,iq)
3692  velw(ke+1:ka,i,j,iq) = const_undef
3693  enddo
3694  enddo
3695  enddo
3696 
3697  profile_stop("sn14_terminal_vel")
3698 
3699  return
3700  end subroutine mp_terminal_velocity
3701  !----------------------------------------------------------------
3702  subroutine update_by_phase_change_kij( &
3703  ntdiv, ntmax, & ! in [Add] 10/08/03
3704  dt, & ! in
3705  gsgam2, & ! in
3706  z, & ! in
3707  dz, & ! in
3708  velz, & ! in
3709  dTdt_rad, & ! in
3710  rho, & ! in
3711  rhoe, & ! inout
3712  rhoq, q, & ! inout
3713  tem, pre, & ! inout
3714  cva, & ! out
3715  esw, esi, rhoq2, & ! in
3716  PQ, & ! in
3717  qc_evaporate, & ! in
3718  sl_PLCdep, &
3719  sl_PLRdep, sl_PNRdep )
3721  aq_cv, &
3722  aq_cp
3723  use scale_atmos_saturation, only: &
3724  moist_pres2qsat_liq => atmos_saturation_pres2qsat_liq, &
3725  moist_pres2qsat_ice => atmos_saturation_pres2qsat_ice, &
3726  moist_dqsw_dtem_rho => atmos_saturation_dqsw_dtem_rho, &
3727  moist_dqsi_dtem_rho => atmos_saturation_dqsi_dtem_rho, &
3728  moist_dqsw_dtem_dpre => atmos_saturation_dqsw_dtem_dpre, &
3729  moist_dqsi_dtem_dpre => atmos_saturation_dqsi_dtem_dpre
3730  implicit none
3731 
3732  integer, intent(in) :: ntdiv ! [Add] 10/08/03
3733  integer, intent(in) :: ntmax ! [Add] 10/08/03
3734  !
3735  real(DP), intent(in) :: dt ! time step[s]
3736  real(RP), intent(in) :: gsgam2(ka,ia,ja) ! metric
3737  real(RP), intent(in) :: z(ka) ! altitude [m]
3738  real(RP), intent(in) :: dz(ka) ! altitude [m]
3739  real(RP), intent(in) :: velz(ka,ia,ja) ! vertical velocity @ half point[m/s]
3740  real(RP), intent(in) :: dTdt_rad(ka,ia,ja) ! temperture tendency by radiation[K/s]
3741  real(RP), intent(in) :: rho(ka,ia,ja) ! density[kg/m3]
3742  real(RP), intent(inout) :: rhoe(ka,ia,ja) ! internal energy[J/m3]
3743  real(RP), intent(inout) :: rhoq(qa,ka,ia,ja) ! tracers[kg/m3]
3744  real(RP), intent(inout) :: q(ka,ia,ja,qa) ! tracers mixing ratio[kg/kg]
3745  real(RP), intent(inout) :: tem(ka,ia,ja) ! temperature[K]
3746  real(RP), intent(inout) :: pre(ka,ia,ja) ! pressure[Pa]
3747  real(RP), intent(out) :: cva(ka,ia,ja) ! specific heat at constant volume
3748  real(RP), intent(in) :: esw(ka,ia,ja) ! saturated vapor pressure for liquid
3749  real(RP), intent(in) :: esi(ka,ia,ja) ! for ice
3750  real(RP), intent(in) :: rhoq2(qa,ka,ia,ja)
3751  !+++ tendency[kg/m3/s]
3752  real(RP), intent(inout) :: PQ(pq_max,ka,ia,ja)
3753  real(RP), intent(out) :: qc_evaporate(ka,ia,ja)
3754  !+++ Column integrated tendency[kg/m2/s]
3755  real(RP), intent(inout) :: sl_PLCdep(ia,ja)
3756  real(RP), intent(inout) :: sl_PLRdep(ia,ja), sl_PNRdep(ia,ja)
3757  !
3758  real(RP) :: Rmoist
3759  !
3760  real(RP) :: xi ! mean mass of ice particles
3761  real(RP) :: rrho ! 1/rho
3762  real(RP) :: wtem(ka,ia,ja) ! temperature[K]
3763  real(RP) :: qdry ! mixing ratio of dry air
3764  !
3765  real(RP) :: r_cva ! specific heat at constant volume
3766  real(RP) :: r_cpa ! specific heat at constant pressure
3767  real(RP) :: qsw(ka,ia,ja) ! saturated mixing ratio for liquid
3768  real(RP) :: qsi(ka,ia,ja) ! saturated mixing ratio for solid
3769  real(RP) :: dqswdtem_rho(ka,ia,ja) ! (dqsw/dtem)_rho
3770  real(RP) :: dqsidtem_rho(ka,ia,ja) ! (dqsi/dtem)_rho
3771  real(RP) :: dqswdtem_pre(ka,ia,ja) ! (dqsw/dtem)_pre
3772  real(RP) :: dqsidtem_pre(ka,ia,ja) ! (dqsi/dtem)_pre
3773  real(RP) :: dqswdpre_tem(ka,ia,ja) ! (dqsw/dpre)_tem
3774  real(RP) :: dqsidpre_tem(ka,ia,ja) ! (dqsi/dpre)_tem
3775  !
3776  real(RP) :: w ! vetical velocity[m/s]
3777  real(RP) :: Acnd ! Pdynliq + Bergeron-Findeisen
3778  real(RP) :: Adep ! Pdyndep + Bergeron-Findeisen
3779  real(RP) :: aliqliq, asolliq
3780  real(RP) :: aliqsol, asolsol
3781  real(RP) :: Pdynliq ! production term of ssw by vertical motion
3782  real(RP) :: Pdynsol ! production term of ssi by vertical motion
3783  real(RP) :: Pradliq ! production term of ssw by radiation
3784  real(RP) :: Pradsol ! production term of ssi by radiation
3785  real(RP) :: taucnd, r_taucnd ! time scale of ssw change by MP
3786  real(RP) :: taudep, r_taudep ! time scale of ssi change by MP
3787  real(RP) :: taucnd_c(ka,ia,ja), r_taucnd_c ! by cloud
3788  real(RP) :: taucnd_r(ka,ia,ja), r_taucnd_r ! by rain
3789  real(RP) :: taudep_i(ka,ia,ja), r_taudep_i ! by ice
3790  real(RP) :: taudep_s(ka,ia,ja), r_taudep_s ! by snow
3791  real(RP) :: taudep_g(ka,ia,ja), r_taudep_g ! by graupel
3792  ! alternative tendency through changing ssw and ssi
3793  real(RP) :: PNCdep ! [Add] 11/08/30 T.Mitsui
3794  real(RP) :: PLR2NR, PLI2NI, PLS2NS, PLG2NG
3795  real(RP) :: coef_a_cnd, coef_b_cnd
3796  real(RP) :: coef_a_dep, coef_b_dep
3797  !
3798  real(RP) :: frz_dqc
3799  real(RP) :: frz_dnc
3800  real(RP) :: frz_dqr
3801  real(RP) :: frz_dnr
3802  real(RP) :: mlt_dqi
3803  real(RP) :: mlt_dni
3804  real(RP) :: mlt_dqs
3805  real(RP) :: mlt_dns
3806  real(RP) :: mlt_dqg
3807  real(RP) :: mlt_dng
3808  real(RP) :: dep_dqi
3809  real(RP) :: dep_dni
3810  real(RP) :: dep_dqs
3811  real(RP) :: dep_dns
3812  real(RP) :: dep_dqg
3813  real(RP) :: dep_dng
3814  real(RP) :: dep_dqr
3815  real(RP) :: dep_dnr
3816  real(RP) :: dep_dqc
3817  real(RP) :: dep_dnc ! 11/08/30 [Add] T.Mitsui, dep_dnc
3818  real(RP) :: r_xc_ccn, r_xi_ccn ! 11/08/30 [Add] T.Mitsui
3819  !
3820  real(RP) :: drhoqv
3821  real(RP) :: drhoqc, drhoqr, drhoqi, drhoqs, drhoqg
3822  real(RP) :: drhonc, drhonr, drhoni, drhons, drhong
3823  !
3824  real(RP) :: fac1, fac2, fac3, fac4, fac5, fac6
3825  real(RP) :: r_rvaptem ! 1/(Rvap*tem)
3826  real(RP) :: pv ! vapor pressure
3827  real(RP) :: lvsw, lvsi ! saturated vapor density
3828  real(RP) :: dlvsw, dlvsi !
3829  ! [Add] 11/08/30 T.Mitsui
3830  real(RP) :: dcnd, ddep ! total cndensation/deposition
3831  real(RP) :: uplim_cnd ! upper limit of condensation
3832  real(RP) :: lowlim_cnd ! lower limit of evaporation
3833  ! [Add] 11/08/30 T.Mitsui
3834  real(RP) :: uplim_dep ! upper limit of condensation
3835  real(RP) :: lowlim_dep ! lower limit of evaporation
3836  real(RP) :: ssw, ssi ! supersaturation ratio
3837  real(RP) :: r_esw, r_esi ! 1/esw, 1/esi
3838  real(RP) :: r_lvsw, r_lvsi ! 1/(lvsw*ssw), 1/(lvsi*ssi)
3839  real(RP) :: r_dt ! 1/dt
3840  real(RP) :: ssw_o, ssi_o
3841 ! real(RP) :: dt_dyn
3842 ! real(RP) :: dt_mp
3843  !
3844 ! real(RP) :: tem_lh(KA,IA,JA)
3845 ! real(RP) :: dtemdt_lh(KA,IA,JA)
3846  real(RP), save :: fac_cndc = 1.0_rp
3847  logical, save :: opt_fix_taucnd_c=.false.
3848  logical, save :: flag_first =.true.
3849  !
3850  namelist /nm_mp_sn14_condensation/ &
3851  opt_fix_taucnd_c, fac_cndc
3852 
3853  real(RP) :: fac_cndc_wrk
3854  !
3855  real(RP), parameter :: tau100day = 1.e+7_rp
3856  real(RP), parameter :: r_tau100day = 1.e-7_rp
3857  real(RP), parameter :: eps=1.e-30_rp
3858  !
3859  integer :: i,j,k,iqw
3860  real(RP) :: sw
3861  !
3862 
3863  ! [Add] 11/08/30 T.Mitsui
3864  if( flag_first )then
3865  flag_first = .false.
3866  rewind(io_fid_conf)
3867  read (io_fid_conf,nml=nm_mp_sn14_condensation, end=100)
3868 100 if( io_l ) write (io_fid_log,nml=nm_mp_sn14_condensation)
3869  end if
3870  !
3871 ! dt_dyn = dt*ntmax
3872 ! dt_mp = dt*(ntdiv-1)
3873  !
3874  r_dt = 1.0_rp/dt
3875  !
3876  r_xc_ccn=1.0_rp/xc_ccn
3877 ! r_xi_ccn=1.0_RP/xi_ccn
3878  !
3879  if( opt_fix_taucnd_c )then
3880  fac_cndc_wrk = fac_cndc**(1.0_rp-b_m(i_qc))
3881  do j = js, je
3882  do i = is, ie
3883  do k = ks, ke
3884  pq(i_lcdep,k,i,j) = pq(i_lcdep,k,i,j)*fac_cndc_wrk
3885  end do
3886  end do
3887  end do
3888  if( io_l ) write(io_fid_log,*) "taucnd:fac_cndc_wrk=",fac_cndc_wrk
3889  end if
3890 
3891 !OCL XFILL
3892  do j = js, je
3893  do i = is, ie
3894  do k = ks, ke
3895  ! Temperature lower limit is only used for saturation condition.
3896  ! On the other hand original "tem" is used for calculation of latent heat or energy equation.
3897  wtem(k,i,j) = max( tem(k,i,j), tem_min )
3898  end do
3899  end do
3900  end do
3901 
3902  call moist_pres2qsat_liq ( qsw, wtem, pre )
3903  call moist_pres2qsat_ice ( qsi, wtem, pre )
3904  call moist_dqsw_dtem_rho ( dqswdtem_rho, wtem, rho )
3905  call moist_dqsi_dtem_rho ( dqsidtem_rho, wtem, rho )
3906  call moist_dqsw_dtem_dpre( dqswdtem_pre, dqswdpre_tem, wtem, pre )
3907  call moist_dqsi_dtem_dpre( dqsidtem_pre, dqsidpre_tem, wtem, pre )
3908 
3909  profile_start("sn14_update")
3910  do j = js, je
3911  do i = is, ie
3912  do k = ks, ke
3913  if( z(k) <= 25000.0_rp )then
3914  w = 0.5_rp*(velz(k,i,j) + velz(k+1,i,j))
3915  else
3916  w = 0.0_rp
3917  end if
3918  if( pre(k,i,j) < esw(k,i,j)+1.e-10_rp )then
3919  qsw(k,i,j) = 1.0_rp
3920  dqswdtem_rho(k,i,j) = 0.0_rp
3921  dqswdtem_pre(k,i,j) = 0.0_rp
3922  dqswdpre_tem(k,i,j) = 0.0_rp
3923  end if
3924  if( pre(k,i,j) < esi(k,i,j)+1.e-10_rp )then
3925  qsi(k,i,j) = 1.0_rp
3926  dqsidtem_rho(k,i,j) = 0.0_rp
3927  dqsidtem_pre(k,i,j) = 0.0_rp
3928  dqsidpre_tem(k,i,j) = 0.0_rp
3929  end if
3930 
3931  r_rvaptem = 1.0_rp/(rvap*wtem(k,i,j))
3932  lvsw = esw(k,i,j)*r_rvaptem ! rho=p/(Rv*T)
3933  lvsi = esi(k,i,j)*r_rvaptem !
3934  pv = rhoq2(i_qv,k,i,j)*rvap*tem(k,i,j)
3935  r_esw = 1.0_rp/esw(k,i,j)
3936  r_esi = 1.0_rp/esi(k,i,j)
3937  ssw = min( mp_ssw_lim, ( pv*r_esw-1.0_rp ) )
3938  ssi = pv*r_esi - 1.0_rp
3939  r_lvsw = 1.0_rp/lvsw
3940  r_lvsi = 1.0_rp/lvsi
3941  r_taucnd_c = pq(i_lcdep,k,i,j)*r_lvsw
3942  r_taucnd_r = pq(i_lrdep,k,i,j)*r_lvsw
3943  r_taudep_i = pq(i_lidep,k,i,j)*r_lvsi
3944  r_taudep_s = pq(i_lsdep,k,i,j)*r_lvsi
3945  r_taudep_g = pq(i_lgdep,k,i,j)*r_lvsi
3946 ! taucnd_c(k,i,j) = 1.0_RP/(r_taucnd_c+r_tau100day)
3947 ! taucnd_r(k,i,j) = 1.0_RP/(r_taucnd_r+r_tau100day)
3948 ! taudep_i(k,i,j) = 1.0_RP/(r_taudep_i+r_tau100day)
3949 ! taudep_s(k,i,j) = 1.0_RP/(r_taudep_s+r_tau100day)
3950 ! taudep_g(k,i,j) = 1.0_RP/(r_taudep_g+r_tau100day)
3951 
3952  calc_qdry( qdry, q, k, i, j, iqw )
3953  calc_cv( cva(k,i,j), qdry, q, k, i, j, iqw, cvdry, aq_cv )
3954  calc_r( rmoist, q(k,i,j,i_qv), qdry, rdry, rvap )
3955  r_cva = 1.0_rp / cva(k,i,j)
3956  r_cpa = 1.0_rp / (cva(k,i,j) + rmoist)
3957 
3958  ! Coefficient of latent heat release for ssw change by PLCdep and PLRdep
3959  aliqliq = 1.0_rp &
3960  + r_cva*( lhv00 + (cvvap-cl)*tem(k,i,j) )*dqswdtem_rho(k,i,j)
3961  ! Coefficient of latent heat release for ssw change by PLIdep, PLSdep and PLGdep
3962  asolliq = 1.0_rp &
3963  + r_cva*( lhv00 + lhf00 + (cvvap-ci)*tem(k,i,j) )*dqswdtem_rho(k,i,j)
3964  ! Coefficient of latent heat release for ssi change by PLCdep and PLRdep
3965  aliqsol = 1.0_rp &
3966  + r_cva*( lhv00 + (cvvap-cl)*tem(k,i,j) )*dqsidtem_rho(k,i,j)
3967  ! Coefficient of latent heat release for ssi change by PLIdep, PLSdep and PLGdep
3968  asolsol = 1.0_rp &
3969  + r_cva*( lhv00 + lhf00 + (cvvap-ci)*tem(k,i,j) )*dqsidtem_rho(k,i,j)
3970  pdynliq = w * grav * ( r_cpa*dqswdtem_pre(k,i,j) + rho(k,i,j)*dqswdpre_tem(k,i,j) )
3971  pdynsol = w * grav * ( r_cpa*dqsidtem_pre(k,i,j) + rho(k,i,j)*dqsidpre_tem(k,i,j) )
3972  pradliq = -dtdt_rad(k,i,j) * dqswdtem_rho(k,i,j)
3973  pradsol = -dtdt_rad(k,i,j) * dqsidtem_rho(k,i,j)
3974 
3975  ssw_o = ssw
3976  ssi_o = ssi
3977 ! ssw_o = ssw - Pdynliq*(dt_dyn-dt_mp)/qsw(k,i,j) + Pradliq*r_qsw*dt_mp
3978 ! ssi_o = ssi - Pdynsol*(dt_dyn-dt_mp)/qsi(k,i,j) + Pradsol*r_qsi*dt_mp
3979 
3980  acnd = pdynliq + pradliq &
3981  - ( r_taudep_i+r_taudep_s+r_taudep_g ) * ( qsw(k,i,j) - qsi(k,i,j) )
3982  adep = pdynsol + pradsol &
3983  + ( r_taucnd_c+r_taucnd_r ) * ( qsw(k,i,j) - qsi(k,i,j) )
3984  r_taucnd = &
3985  + aliqliq*( r_taucnd_c+r_taucnd_r ) &
3986  + asolliq*( r_taudep_i+r_taudep_s+r_taudep_g )
3987  r_taudep = &
3988  + aliqsol*( r_taucnd_c+r_taucnd_r )&
3989  + asolsol*( r_taudep_i+r_taudep_s+r_taudep_g )
3990 
3991  uplim_cnd = max( rho(k,i,j)*ssw_o*qsw(k,i,j)*r_dt, 0.0_rp )
3992  lowlim_cnd = min( rho(k,i,j)*ssw_o*qsw(k,i,j)*r_dt, 0.0_rp )
3993  if( r_taucnd < r_tau100day )then
3994 ! taucnd = tau100day
3995  pq(i_lcdep,k,i,j) = max(lowlim_cnd, min(uplim_cnd, pq(i_lcdep,k,i,j)*ssw_o ))
3996  pq(i_lrdep,k,i,j) = max(lowlim_cnd, min(uplim_cnd, pq(i_lrdep,k,i,j)*ssw_o ))
3997  pq(i_nrdep,k,i,j) = min(0.0_rp, pq(i_nrdep,k,i,j)*ssw_o )
3998 ! PLR2NR = 0.0_RP
3999  else
4000  taucnd = 1.0_rp/r_taucnd
4001  ! Production term for liquid water content
4002  coef_a_cnd = rho(k,i,j)*acnd*taucnd
4003  coef_b_cnd = rho(k,i,j)*taucnd*r_dt*(ssw_o*qsw(k,i,j)-acnd*taucnd) * ( exp(-dt*r_taucnd) - 1.0_rp )
4004  pq(i_lcdep,k,i,j) = coef_a_cnd*r_taucnd_c - coef_b_cnd*r_taucnd_c
4005  plr2nr = pq(i_nrdep,k,i,j)/(pq(i_lrdep,k,i,j)+1.e-30_rp)
4006  pq(i_lrdep,k,i,j) = coef_a_cnd*r_taucnd_r - coef_b_cnd*r_taucnd_r
4007  pq(i_nrdep,k,i,j) = min(0.0_rp, pq(i_lrdep,k,i,j)*plr2nr )
4008  end if
4009 
4010  uplim_dep = max( rho(k,i,j)*ssi_o*qsi(k,i,j)*r_dt, 0.0_rp )
4011  lowlim_dep = min( rho(k,i,j)*ssi_o*qsi(k,i,j)*r_dt, 0.0_rp )
4012  if( r_taudep < r_tau100day )then
4013 ! taudep = tau100day
4014  pq(i_lidep,k,i,j) = max(lowlim_dep, min(uplim_dep, pq(i_lidep,k,i,j)*ssi_o ))
4015  pq(i_lsdep,k,i,j) = max(lowlim_dep, min(uplim_dep, pq(i_lsdep,k,i,j)*ssi_o ))
4016  pq(i_lgdep,k,i,j) = max(lowlim_dep, min(uplim_dep, pq(i_lgdep,k,i,j)*ssi_o ))
4017  pq(i_nidep,k,i,j) = min(0.0_rp, pq(i_nidep,k,i,j)*ssi_o )
4018  pq(i_nsdep,k,i,j) = min(0.0_rp, pq(i_nsdep,k,i,j)*ssi_o )
4019  pq(i_ngdep,k,i,j) = min(0.0_rp, pq(i_ngdep,k,i,j)*ssi_o )
4020  else
4021  taudep = 1.0_rp/r_taudep
4022  ! Production term for ice water content
4023  coef_a_dep = rho(k,i,j)*adep*taudep
4024  coef_b_dep = rho(k,i,j)*taudep*r_dt*(ssi_o*qsi(k,i,j)-adep*taudep) * ( exp(-dt*r_taudep) - 1.0_rp )
4025  pli2ni = pq(i_nidep,k,i,j)/max(pq(i_lidep,k,i,j),1.e-30_rp)
4026  pls2ns = pq(i_nsdep,k,i,j)/max(pq(i_lsdep,k,i,j),1.e-30_rp)
4027  plg2ng = pq(i_ngdep,k,i,j)/max(pq(i_lgdep,k,i,j),1.e-30_rp)
4028  pq(i_lidep,k,i,j) = coef_a_dep*r_taudep_i - coef_b_dep*r_taudep_i
4029  pq(i_lsdep,k,i,j) = coef_a_dep*r_taudep_s - coef_b_dep*r_taudep_s
4030  pq(i_lgdep,k,i,j) = coef_a_dep*r_taudep_g - coef_b_dep*r_taudep_g
4031  pq(i_nidep,k,i,j) = min(0.0_rp, pq(i_lidep,k,i,j)*pli2ni )
4032  pq(i_nsdep,k,i,j) = min(0.0_rp, pq(i_lsdep,k,i,j)*pls2ns )
4033  pq(i_ngdep,k,i,j) = min(0.0_rp, pq(i_lgdep,k,i,j)*plg2ng )
4034  end if
4035 
4036  sw = 0.5_rp - sign(0.5_rp, pq(i_lcdep,k,i,j)+eps) != 1 for PLCdep<=-eps
4037  pncdep = min(0.0_rp, ((rhoq2(i_qc,k,i,j)+pq(i_lcdep,k,i,j)*dt)*r_xc_ccn - rhoq2(i_nc,k,i,j))*r_dt ) * sw
4038 ! if( PQ(I_LCdep,k,i,j) < -eps )then
4039 ! PNCdep = min(0.0_RP, ((rhoq2(I_QC,k,i,j)+PQ(I_LCdep,k,i,j)*dt)*r_xc_ccn - rhoq2(I_NC,k,i,j))*r_dt )
4040 ! else
4041 ! PNCdep = 0.0_RP
4042 ! end if
4043 ! if( PQ(I_LIdep,k,i,j) < -eps )then
4044 ! PQ(I_NIdep,k,i,j) = min(0.0_RP, ((li(k,i,j)+PQ(I_LIdep,k,i,j)*dt)*r_xi_ccn - rhoq2(I_NI,k,i,j))*r_dt )
4045 ! else
4046 ! PQ(I_NIdep,k,i,j) = 0.0_RP
4047 ! end if
4048 
4049  !--- evaporation/condensation
4050  r_rvaptem = 1.0_rp/(rvap*wtem(k,i,j))
4051  lvsw = esw(k,i,j)*r_rvaptem
4052  dlvsw = rhoq2(i_qv,k,i,j)-lvsw
4053  dcnd = dt*(pq(i_lcdep,k,i,j)+pq(i_lrdep,k,i,j))
4054 
4055  sw = ( sign(0.5_rp,dcnd) + sign(0.5_rp,dlvsw) ) &
4056  * ( 0.5_rp + sign(0.5_rp,abs(dcnd)-eps) ) ! to avoid zero division
4057  ! sw= 1: always supersaturated
4058  ! sw=-1: always unsaturated
4059  ! sw= 0: partially unsaturated during timestep
4060  fac1 = min(dlvsw*sw,dcnd*sw)*sw / (abs(sw)-1.0_rp+dcnd) & ! sw=1,-1
4061  + 1.0_rp - abs(sw) ! sw=0
4062  dep_dqc = max( dt*pq(i_lcdep,k,i,j)*fac1, &
4063  -rhoq2(i_qc,k,i,j) - 1e30_rp*(sw+1.0_rp) )*abs(sw) != -lc for sw=-1, -inf for sw=1
4064  dep_dqr = max( dt*pq(i_lrdep,k,i,j)*fac1, &
4065  -rhoq2(i_qr,k,i,j) - 1e30_rp*(sw+1.0_rp) )*abs(sw) != -lr for sw=-1, -inf for sw=1
4066 ! if ( (dcnd > eps) .AND. (dlvsw > eps) )then
4067 ! ! always supersaturated
4068 ! fac1 = min(dlvsw,dcnd)/dcnd
4069 ! dep_dqc = dt*PQ(I_LCdep,k,i,j)*fac1
4070 ! dep_dqr = dt*PQ(I_LRdep,k,i,j)*fac1
4071 ! else if( (dcnd < -eps) .AND. (dlvsw < -eps) )then
4072 ! ! always unsaturated
4073 ! fac1 = max( dlvsw,dcnd )/dcnd
4074 ! dep_dqc = max( dt*PQ(I_LCdep,k,i,j)*fac1, -rhoq2(I_QC,k,i,j) )
4075 ! dep_dqr = max( dt*PQ(I_LRdep,k,i,j)*fac1, -rhoq2(I_QR,k,i,j) )
4076 ! else
4077 ! ! partially unsaturated during timestep
4078 ! fac1 = 1.0_RP
4079 ! dep_dqc = 0.0_RP
4080 ! dep_dqr = 0.0_RP
4081 ! end if
4082 
4083  ! evaporation always lose number(always negative).
4084  dep_dnc = max( dt*pncdep*fac1, -rhoq2(i_nc,k,i,j) ) ! ss>0 dep=0, ss<0 dep<0 ! [Add] 11/08/30 T.Mitsui
4085  dep_dnr = max( dt*pq(i_nrdep,k,i,j)*fac1, -rhoq2(i_nr,k,i,j) ) ! ss>0 dep=0, ss<0 dep<0
4086 
4087  qc_evaporate(k,i,j) = - dep_dnc ! [Add] Y.Sato 15/09/08
4088 
4089  !--- deposition/sublimation
4090  lvsi = esi(k,i,j)*r_rvaptem
4091  ddep = dt*(pq(i_lidep,k,i,j)+pq(i_lsdep,k,i,j)+pq(i_lgdep,k,i,j))
4092  dlvsi = rhoq2(i_qv,k,i,j)-lvsi ! limiter for esi>1.d0
4093 
4094  sw = ( sign(0.5_rp,ddep) + sign(0.5_rp,dlvsi) ) &
4095  * ( 0.5_rp + sign(0.5_rp,abs(ddep)-eps) ) ! to avoid zero division
4096  ! sw= 1: always supersaturated
4097  ! sw=-1: always unsaturated
4098  ! sw= 0: partially unsaturated during timestep
4099  fac2 = min(dlvsi*sw,ddep*sw)*sw / (abs(sw)-1.0_rp+ddep) & ! sw=1,-1
4100  + 1.0_rp - abs(sw) ! sw=0
4101  dep_dqi = max( dt*pq(i_lidep,k,i,j) &
4102  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
4103  -rhoq2(i_qi,k,i,j) - 1e30_rp*(sw+1.0_rp) ) != -li for sw=-1, -inf for sw=0,1
4104  dep_dqs = max( dt*pq(i_lsdep,k,i,j) &
4105  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
4106  -rhoq2(i_qs,k,i,j) - 1e30_rp*(sw+1.0_rp) ) != -ls for sw=-1, -inf for sw=0,1
4107  dep_dqg = max( dt*pq(i_lgdep,k,i,j) &
4108  * ( 1.0_rp-abs(sw) + fac2*abs(sw) ), & != fac2 for sw=-1,1, 1 for sw=0
4109  -rhoq2(i_qg,k,i,j) - 1e30_rp*(sw+1.0_rp) ) != -lg for sw=-1, -inf for sw=0,1
4110 ! if ( (ddep > eps) .AND. (dlvsi > eps) )then
4111 ! ! always supersaturated
4112 ! fac2 = min(dlvsi,ddep)/ddep
4113 ! dep_dqi = dt*PQ(I_LIdep,k,i,j)*fac2
4114 ! dep_dqs = dt*PQ(I_LSdep,k,i,j)*fac2
4115 ! dep_dqg = dt*PQ(I_LGdep,k,i,j)*fac2
4116 ! else if ( (ddep < -eps) .AND. (dlvsi < -eps) )then
4117 ! ! always unsaturated
4118 ! fac2 = max(dlvsi,ddep)/ddep
4119 ! dep_dqi = max(dt*PQ(I_LIdep,k,i,j)*fac2, -rhoq2(I_QI,k,i,j) )
4120 ! dep_dqs = max(dt*PQ(I_LSdep,k,i,j)*fac2, -rhoq2(I_QS,k,i,j) )
4121 ! dep_dqg = max(dt*PQ(I_LGdep,k,i,j)*fac2, -rhoq2(I_QG,k,i,j) )
4122 ! else
4123 ! ! partially unsaturated during timestep
4124 ! fac2 = 1.0_RP
4125 ! dep_dqi = dt*PQ(I_LIdep,k,i,j)
4126 ! dep_dqs = dt*PQ(I_LSdep,k,i,j)
4127 ! dep_dqg = dt*PQ(I_LGdep,k,i,j)
4128 ! end if
4129 
4130  ! evaporation always lose number(always negative).
4131  dep_dni = max( dt*pq(i_nidep,k,i,j)*fac2, -rhoq2(i_ni,k,i,j) ) ! ss>0 dep=0, ss<0 dep<0
4132  dep_dns = max( dt*pq(i_nsdep,k,i,j)*fac2, -rhoq2(i_ns,k,i,j) ) ! ss>0 dep=0, ss<0 dep<0
4133  dep_dng = max( dt*pq(i_ngdep,k,i,j)*fac2, -rhoq2(i_ng,k,i,j) ) ! ss>0 dep=0, ss<0 dep<0
4134 
4135  !--- freezing of cloud drop
4136  frz_dqc = max( dt*(pq(i_lchom,k,i,j)+pq(i_lchet,k,i,j)), -rhoq2(i_qc,k,i,j)-dep_dqc ) ! negative value
4137  frz_dnc = max( dt*(pq(i_nchom,k,i,j)+pq(i_nchet,k,i,j)), -rhoq2(i_nc,k,i,j)-dep_dnc ) ! negative value
4138  fac3 = ( frz_dqc-eps )/( dt*(pq(i_lchom,k,i,j)+pq(i_lchet,k,i,j))-eps )
4139  fac4 = ( frz_dnc-eps )/( dt*(pq(i_nchom,k,i,j)+pq(i_nchet,k,i,j))-eps )
4140  pq(i_lchom,k,i,j) = fac3*pq(i_lchom,k,i,j)
4141  pq(i_lchet,k,i,j) = fac3*pq(i_lchet,k,i,j)
4142  pq(i_nchom,k,i,j) = fac4*pq(i_nchom,k,i,j)
4143  pq(i_nchet,k,i,j) = fac4*pq(i_nchet,k,i,j)
4144 
4145  !--- melting
4146  ! ice change
4147  mlt_dqi = max( dt*pq(i_limlt,k,i,j), -rhoq2(i_qi,k,i,j)-dep_dqi ) ! negative value
4148  mlt_dni = max( dt*pq(i_nimlt,k,i,j), -rhoq2(i_ni,k,i,j)-dep_dni ) ! negative value
4149  ! snow change
4150  mlt_dqs = max( dt*pq(i_lsmlt,k,i,j), -rhoq2(i_qs,k,i,j)-dep_dqs ) ! negative value
4151  mlt_dns = max( dt*pq(i_nsmlt,k,i,j), -rhoq2(i_ns,k,i,j)-dep_dns ) ! negative value
4152  ! graupel change
4153  mlt_dqg = max( dt*pq(i_lgmlt,k,i,j), -rhoq2(i_qg,k,i,j)-dep_dqg ) ! negative value
4154  mlt_dng = max( dt*pq(i_ngmlt,k,i,j), -rhoq2(i_ng,k,i,j)-dep_dng ) ! negative value
4155 
4156  !--- freezing of larger droplets
4157  frz_dqr = max( dt*(pq(i_lrhet,k,i,j)), min(0.0_rp, -rhoq2(i_qr,k,i,j)-dep_dqr) ) ! negative value
4158  frz_dnr = max( dt*(pq(i_nrhet,k,i,j)), min(0.0_rp, -rhoq2(i_nr,k,i,j)-dep_dnr) ) ! negative value
4159 
4160  fac5 = ( frz_dqr-eps )/( dt*pq(i_lrhet,k,i,j)-eps )
4161  pq(i_lrhet,k,i,j) = fac5*pq(i_lrhet,k,i,j)
4162  fac6 = ( frz_dnr-eps )/( dt*pq(i_nrhet,k,i,j)-eps )
4163  pq(i_nrhet,k,i,j) = fac6*pq(i_nrhet,k,i,j)
4164 
4165  ! water vapor change
4166  drhoqv = -(dep_dqc+dep_dqi+dep_dqs+dep_dqg+dep_dqr)
4167 
4168  rhoq(i_qv,k,i,j) = max(0.0_rp, rhoq(i_qv,k,i,j) + drhoqv )
4169 
4170  rhoe(k,i,j) = rhoe(k,i,j) - lhv * drhoqv
4171 
4172  xi = min(xi_max, max(xi_min, rhoq2(i_qi,k,i,j)/(rhoq2(i_ni,k,i,j)+ni_min) ))
4173  sw = 0.5_rp + sign(0.5_rp,xi-x_sep) ! if (xi>=x_sep) then sw=1 else sw=0
4174  ! sw=1: large ice crystals turn into rain by melting
4175 
4176  ! total cloud change
4177  drhoqc = ( frz_dqc - mlt_dqi*(1.0_rp-sw) + dep_dqc )
4178  drhonc = ( frz_dnc - mlt_dni*(1.0_rp-sw) + dep_dnc )
4179  ! total rain change
4180  drhoqr = ( frz_dqr - mlt_dqg - mlt_dqs - mlt_dqi*sw + dep_dqr )
4181  drhonr = ( frz_dnr - mlt_dng - mlt_dns - mlt_dni*sw + dep_dnr )
4182 
4183  rhoq(i_qc,k,i,j) = max(0.0_rp, rhoq(i_qc,k,i,j) + drhoqc )
4184  rhoq(i_nc,k,i,j) = max(0.0_rp, rhoq(i_nc,k,i,j) + drhonc )
4185  rhoq(i_qr,k,i,j) = max(0.0_rp, rhoq(i_qr,k,i,j) + drhoqr )
4186  rhoq(i_nr,k,i,j) = max(0.0_rp, rhoq(i_nr,k,i,j) + drhonr )
4187 
4188  ! total ice change
4189  drhoqi = (-frz_dqc + mlt_dqi + dep_dqi )
4190  drhoni = (-frz_dnc + mlt_dni + dep_dni )
4191 
4192  rhoq(i_qi,k,i,j) = max(0.0_rp, rhoq(i_qi,k,i,j) + drhoqi )
4193  rhoq(i_ni,k,i,j) = max(0.0_rp, rhoq(i_ni,k,i,j) + drhoni )
4194 
4195  rhoe(k,i,j) = rhoe(k,i,j) + lhf * drhoqi
4196 
4197  ! total snow change
4198  drhoqs = ( mlt_dqs + dep_dqs )
4199  drhons = ( mlt_dns + dep_dns )
4200 
4201  rhoq(i_qs,k,i,j) = max(0.0_rp, rhoq(i_qs,k,i,j) + drhoqs )
4202  rhoq(i_ns,k,i,j) = max(0.0_rp, rhoq(i_ns,k,i,j) + drhons )
4203 
4204  rhoe(k,i,j) = rhoe(k,i,j) + lhf * drhoqs
4205 
4206  ! total graupel change
4207  drhoqg = (-frz_dqr + mlt_dqg + dep_dqg )
4208  drhong = (-frz_dnr + mlt_dng + dep_dng )
4209 
4210  rhoq(i_qg,k,i,j) = max(0.0_rp, rhoq(i_qg,k,i,j) + drhoqg )
4211  rhoq(i_ng,k,i,j) = max(0.0_rp, rhoq(i_ng,k,i,j) + drhong )
4212 
4213  rhoe(k,i,j) = rhoe(k,i,j) + lhf * drhoqg
4214 
4215  !--- update mixing ratio
4216  rrho = 1.0_rp/rho(k,i,j)
4217 
4218  q(k,i,j,i_qv) = rhoq(i_qv,k,i,j) * rrho
4219  q(k,i,j,i_qc) = rhoq(i_qc,k,i,j) * rrho
4220  q(k,i,j,i_qr) = rhoq(i_qr,k,i,j) * rrho
4221  q(k,i,j,i_qi) = rhoq(i_qi,k,i,j) * rrho
4222  q(k,i,j,i_qs) = rhoq(i_qs,k,i,j) * rrho
4223  q(k,i,j,i_qg) = rhoq(i_qg,k,i,j) * rrho
4224  q(k,i,j,i_nc) = rhoq(i_nc,k,i,j) * rrho
4225  q(k,i,j,i_nr) = rhoq(i_nr,k,i,j) * rrho
4226  q(k,i,j,i_ni) = rhoq(i_ni,k,i,j) * rrho
4227  q(k,i,j,i_ns) = rhoq(i_ns,k,i,j) * rrho
4228  q(k,i,j,i_ng) = rhoq(i_ng,k,i,j) * rrho
4229 
4230  calc_qdry( qdry, q, k, i, j, iqw )
4231  calc_cv( cva(k,i,j), qdry, q, k, i, j, iqw, cvdry, aq_cv )
4232  calc_r( rmoist, q(k,i,j,i_qv), qdry, rdry, rvap )
4233  tem(k,i,j) = rhoe(k,i,j) / ( rho(k,i,j) * cva(k,i,j) )
4234  pre(k,i,j) = rho(k,i,j) * rmoist * tem(k,i,j)
4235 
4236  sl_plcdep(i,j) = sl_plcdep(i,j) + dep_dqc*dz(k)*gsgam2(k,i,j)
4237  sl_plrdep(i,j) = sl_plrdep(i,j) + dep_dqr*dz(k)*gsgam2(k,i,j)
4238  sl_pnrdep(i,j) = sl_pnrdep(i,j) + dep_dnr*dz(k)*gsgam2(k,i,j)
4239  end do
4240  end do
4241  end do
4242  profile_stop("sn14_update")
4243 
4244  return
4245  end subroutine update_by_phase_change_kij
4246  !-------------------------------------------------------------------------------
4247  subroutine mp_negativefilter( &
4248  DENS, &
4249  QTRC )
4250  implicit none
4251  real(RP), intent(inout) :: DENS(ka,ia,ja)
4252  real(RP), intent(inout) :: QTRC(ka,ia,ja,qa)
4253 
4254  real(RP) :: diffq(ka,ia,ja)
4255  real(RP) :: r_xmin
4256 
4257  integer :: k, i, j, iq
4258  !---------------------------------------------------------------------------
4259 
4260  call prof_rapstart('MP_filter', 3)
4261 
4262  r_xmin = 1.0_rp / xmin_filter
4263 
4264  ! total hydrometeor (before correction)
4265  do j = js, je
4266  do i = is, ie
4267 
4268  do k = ks, ke
4269  diffq(k,i,j) = qtrc(k,i,j,i_qv) &
4270  + qtrc(k,i,j,i_qc) &
4271  + qtrc(k,i,j,i_qr) &
4272  + qtrc(k,i,j,i_qi) &
4273  + qtrc(k,i,j,i_qs) &
4274  + qtrc(k,i,j,i_qg)
4275  enddo
4276 
4277  ! remove negative value of hydrometeor (mass, number)
4278  do iq = 1, qa
4279  do k = ks, ke
4280  qtrc(k,i,j,iq) = max(0.0_rp, qtrc(k,i,j,iq))
4281  enddo
4282  enddo
4283 
4284  ! apply correction of hydrometeor to total density
4285  ! [note] mass conservation is broken here to fill rounding error.
4286  do k = ks, ke
4287  dens(k,i,j) = dens(k,i,j) &
4288  * ( 1.0_rp &
4289  + qtrc(k,i,j,i_qv) &
4290  + qtrc(k,i,j,i_qc) &
4291  + qtrc(k,i,j,i_qr) &
4292  + qtrc(k,i,j,i_qi) &
4293  + qtrc(k,i,j,i_qs) &
4294  + qtrc(k,i,j,i_qg) &
4295  - diffq(k,i,j) ) ! after-before
4296  enddo
4297 
4298  ! avoid unrealistical value of number concentration
4299  ! due to numerical diffusion in advection
4300 
4301  do k = ks, ke
4302  if ( qtrc(k,i,j,i_nc) > qtrc(k,i,j,i_qc)*r_xmin ) then
4303  qtrc(k,i,j,i_nc) = qtrc(k,i,j,i_qc)*r_xmin
4304  endif
4305  enddo
4306  do k = ks, ke
4307  if ( qtrc(k,i,j,i_nr) > qtrc(k,i,j,i_qr)*r_xmin ) then
4308  qtrc(k,i,j,i_nr) = qtrc(k,i,j,i_qr)*r_xmin
4309  endif
4310  enddo
4311  do k = ks, ke
4312  if ( qtrc(k,i,j,i_ni) > qtrc(k,i,j,i_qi)*r_xmin ) then
4313  qtrc(k,i,j,i_ni) = qtrc(k,i,j,i_qi)*r_xmin
4314  endif
4315  enddo
4316  do k = ks, ke
4317  if ( qtrc(k,i,j,i_ns) > qtrc(k,i,j,i_qs)*r_xmin ) then
4318  qtrc(k,i,j,i_ns) = qtrc(k,i,j,i_qs)*r_xmin
4319  endif
4320  enddo
4321  do k = ks, ke
4322  if ( qtrc(k,i,j,i_ng) > qtrc(k,i,j,i_qg)*r_xmin ) then
4323  qtrc(k,i,j,i_ng) = qtrc(k,i,j,i_qg)*r_xmin
4324  endif
4325  enddo
4326 
4327  enddo
4328  enddo
4329 
4330  call prof_rapend('MP_filter', 3)
4331 
4332  return
4333  end subroutine mp_negativefilter
4334  !-------------------------------------------------------------------------------
4335 
4336  !-----------------------------------------------------------------------------
4338  subroutine atmos_phy_mp_sn14_cloudfraction( &
4339  cldfrac, &
4340  QTRC, &
4341  mask_criterion )
4343  use scale_tracer, only: &
4344  qad => qa
4345  implicit none
4346 
4347  real(RP), intent(out) :: cldfrac(ka,ia,ja)
4348  real(RP), intent(in) :: QTRC (ka,ia,ja,qad)
4349  real(RP), intent(in) :: mask_criterion
4350 
4351  real(RP) :: qhydro
4352  integer :: k, i, j, iq
4353  !---------------------------------------------------------------------------
4354 
4355  do j = js, je
4356  do i = is, ie
4357  do k = ks, ke
4358  qhydro = 0.0_rp
4359  do iq = 1, mp_qa
4360  qhydro = qhydro + qtrc(k,i,j,i_mp2all(iq))
4361  enddo
4362  cldfrac(k,i,j) = 0.5_rp + sign(0.5_rp,qhydro-mask_criterion)
4363  enddo
4364  enddo
4365  enddo
4366 
4367  return
4368  end subroutine atmos_phy_mp_sn14_cloudfraction
4369 
4370  !-----------------------------------------------------------------------------
4372  subroutine atmos_phy_mp_sn14_effectiveradius( &
4373  Re, &
4374  QTRC0, &
4375  DENS0, &
4376  TEMP0 )
4378  use scale_tracer, only: &
4379  qad => qa, &
4380  mp_qad => mp_qa
4381  implicit none
4382 
4383  real(RP), intent(out) :: Re (ka,ia,ja,mp_qad) ! effective radius [cm]
4384  real(RP), intent(in) :: QTRC0(ka,ia,ja,qad) ! tracer mass concentration [kg/kg]
4385  real(RP), intent(in) :: DENS0(ka,ia,ja) ! density [kg/m3]
4386  real(RP), intent(in) :: TEMP0(ka,ia,ja) ! temperature [K]
4387 
4388  ! mass concentration[kg/m3] and mean particle mass[kg]
4389  real(RP) :: xc(ka,ia,ja)
4390  real(RP) :: xr(ka,ia,ja)
4391  real(RP) :: xi(ka,ia,ja)
4392  real(RP) :: xs(ka,ia,ja)
4393  real(RP) :: xg(ka,ia,ja)
4394  ! diameter of average mass[kg/m3]
4395  real(RP) :: dc_ave(ka,ia,ja)
4396  real(RP) :: dr_ave(ka,ia,ja)
4397  ! radius of average mass
4398  real(RP) :: rc, rr
4399  ! 2nd. and 3rd. order moment of DSD
4400  real(RP) :: ri2m(ka,ia,ja), ri3m(ka,ia,ja)
4401  real(RP) :: rs2m(ka,ia,ja), rs3m(ka,ia,ja)
4402  real(RP) :: rg2m(ka,ia,ja), rg3m(ka,ia,ja)
4403 
4404  real(RP) :: coef_Fuetal1998
4405  ! r2m_min is minimum value(moment of 1 particle with 1 micron)
4406  real(RP), parameter :: r2m_min=1.e-12_rp
4407  real(RP), parameter :: um2cm = 100.0_rp
4408 
4409  real(RP) :: limitsw, zerosw
4410  integer :: k, i, j
4411  !---------------------------------------------------------------------------
4412 
4413  ! mean particle mass[kg]
4414  do j = js, je
4415  do i = is, ie
4416  do k = ks, ke
4417  xc(k,i,j) = min( xc_max, max( xc_min, dens0(k,i,j)*qtrc0(k,i,j,i_qc)/(qtrc0(k,i,j,i_nc)+nc_min) ) )
4418  xr(k,i,j) = min( xr_max, max( xr_min, dens0(k,i,j)*qtrc0(k,i,j,i_qr)/(qtrc0(k,i,j,i_nr)+nr_min) ) )
4419  xi(k,i,j) = min( xi_max, max( xi_min, dens0(k,i,j)*qtrc0(k,i,j,i_qi)/(qtrc0(k,i,j,i_ni)+ni_min) ) )
4420  xs(k,i,j) = min( xs_max, max( xs_min, dens0(k,i,j)*qtrc0(k,i,j,i_qs)/(qtrc0(k,i,j,i_ns)+ns_min) ) )
4421  xg(k,i,j) = min( xg_max, max( xg_min, dens0(k,i,j)*qtrc0(k,i,j,i_qg)/(qtrc0(k,i,j,i_ng)+ng_min) ) )
4422  enddo
4423  enddo
4424  enddo
4425 
4426  ! diameter of average mass : SB06 eq.(32)
4427  do j = js, je
4428  do i = is, ie
4429  do k = ks, ke
4430  dc_ave(k,i,j) = a_m(i_qc) * xc(k,i,j)**b_m(i_qc)
4431  dr_ave(k,i,j) = a_m(i_qr) * xr(k,i,j)**b_m(i_qr)
4432  enddo
4433  enddo
4434  enddo
4435 
4436  ! cloud effective radius
4437  do j = js, je
4438  do i = is, ie
4439  do k = ks, ke
4440  rc = 0.5_rp * dc_ave(k,i,j)
4441  limitsw = 0.5_rp + sign(0.5_rp, rc-rmin_re )
4442  re(k,i,j,i_mp_qc) = coef_re(i_qc) * rc * limitsw * um2cm
4443  enddo
4444  enddo
4445  enddo
4446 
4447  ! rain effective radius
4448  do j = js, je
4449  do i = is, ie
4450  do k = ks, ke
4451  rr = 0.5_rp * dr_ave(k,i,j)
4452  limitsw = 0.5_rp + sign(0.5_rp, rr-rmin_re )
4453  re(k,i,j,i_mp_qr) = coef_re(i_qr) * rr * limitsw * um2cm
4454  enddo
4455  enddo
4456  enddo
4457 
4458  do j = js, je
4459  do i = is, ie
4460  do k = ks, ke
4461  ri2m(k,i,j) = pi * coef_rea2(i_qi) * qtrc0(k,i,j,i_ni) * a_rea2(i_qi) * xi(k,i,j)**b_rea2(i_qi)
4462  rs2m(k,i,j) = pi * coef_rea2(i_qs) * qtrc0(k,i,j,i_ns) * a_rea2(i_qs) * xs(k,i,j)**b_rea2(i_qs)
4463  rg2m(k,i,j) = pi * coef_rea2(i_qg) * qtrc0(k,i,j,i_ng) * a_rea2(i_qg) * xg(k,i,j)**b_rea2(i_qg)
4464  enddo
4465  enddo
4466  enddo
4467 
4468  ! Fu(1996), eq.(3.11) or Fu et al.(1998), eq.(2.5)
4469  coef_fuetal1998 = 3.0_rp / (4.0_rp*rhoi)
4470  do j = js, je
4471  do i = is, ie
4472  do k = ks, ke
4473  ri3m(k,i,j) = coef_fuetal1998 * qtrc0(k,i,j,i_ni) * xi(k,i,j)
4474  rs3m(k,i,j) = coef_fuetal1998 * qtrc0(k,i,j,i_ns) * xs(k,i,j)
4475  rg3m(k,i,j) = coef_fuetal1998 * qtrc0(k,i,j,i_ng) * xg(k,i,j)
4476  enddo
4477  enddo
4478  enddo
4479 
4480  ! ice effective radius
4481  do j = js, je
4482  do i = is, ie
4483  do k = ks, ke
4484  zerosw = 0.5_rp - sign(0.5_rp, ri2m(k,i,j) - r2m_min )
4485  re(k,i,j,i_mp_qi) = ri3m(k,i,j) / ( ri2m(k,i,j) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
4486  enddo
4487  enddo
4488  enddo
4489 
4490  ! snow effective radius
4491  do j = js, je
4492  do i = is, ie
4493  do k = ks, ke
4494  zerosw = 0.5_rp - sign(0.5_rp, rs2m(k,i,j) - r2m_min )
4495  re(k,i,j,i_mp_qs) = rs3m(k,i,j) / ( rs2m(k,i,j) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
4496  enddo
4497  enddo
4498  enddo
4499 
4500  ! graupel effective radius
4501  do j = js, je
4502  do i = is, ie
4503  do k = ks, ke
4504  zerosw = 0.5_rp - sign(0.5_rp, rg2m(k,i,j) - r2m_min )
4505  re(k,i,j,i_mp_qg) = rg3m(k,i,j) / ( rg2m(k,i,j) + zerosw ) * ( 1.0_rp - zerosw ) * um2cm
4506  enddo
4507  enddo
4508  enddo
4509 
4510  return
4511  end subroutine atmos_phy_mp_sn14_effectiveradius
4512  !-----------------------------------------------------------------------------
4514  subroutine atmos_phy_mp_sn14_mixingratio( &
4515  Qe, &
4516  QTRC0 )
4518  use scale_tracer, only: &
4519  qad => qa, &
4520  mp_qad => mp_qa
4521  implicit none
4522 
4523  real(RP), intent(out) :: Qe (ka,ia,ja,mp_qad) ! mixing ratio of each cateory [kg/kg]
4524  real(RP), intent(in) :: QTRC0(ka,ia,ja,qad) ! tracer mass concentration [kg/kg]
4525 
4526  integer :: ihydro
4527  !---------------------------------------------------------------------------
4528 
4529  do ihydro = 1, mp_qa
4530  qe(:,:,:,ihydro) = qtrc0(:,:,:,i_mp2all(ihydro))
4531  enddo
4532 
4533  return
4534  end subroutine atmos_phy_mp_sn14_mixingratio
4535 
4536 end module scale_atmos_phy_mp_sn14
integer, public is
start point of inner domain: x, local
subroutine nucleation_kij(z, velz, rho, tem, pre, rhoq, PQ, cpa, dTdt_rad, qke, CCN, dt)
subroutine, public atmos_phy_mp_sn14_effectiveradius(Re, QTRC0, DENS0, TEMP0)
Calculate Effective Radius.
real(rp), public const_cvdry
specific heat (dry air,constant volume) [J/kg/K]
Definition: scale_const.F90:59
real(rp), parameter, public const_psat0
saturate pressure of water vapor at 0C [Pa]
Definition: scale_const.F90:86
integer, public je
end point of inner domain: y, local
real(rp), public const_cpdry
specific heat (dry air,constant pressure) [J/kg/K]
Definition: scale_const.F90:58
module ATMOSPHERE / Saturation adjustment
subroutine, public prc_mpistop
Abort MPI.
module ATMOSPHERE / Physics Cloud Microphysics
subroutine, public atmos_phy_mp_precipitation(flux_rain, flux_snow, DENS, MOMZ, MOMX, MOMY, RHOE, QTRC, vterm, temp, dt)
precipitation transport
real(rp), parameter, public const_ci
specific heat (ice) [J/kg/K]
Definition: scale_const.F90:69
real(rp), parameter, public const_dwatr
density of water [kg/m3]
Definition: scale_const.F90:87
module TRACER / sn14
real(rp), dimension(:), allocatable, public aq_cp
CP for each hydrometeors [J/kg/K].
real(dp), public time_dtsec_atmos_phy_mp
time interval of physics(microphysics) [sec]
Definition: scale_time.F90:41
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
real(rp) function, public sf_gamma(x)
Gamma function.
real(rp), dimension(:), allocatable, public grid_cz
center coordinate [m]: z, local=global
real(rp), parameter, public const_cl
specific heat (liquid water) [J/kg/K]
Definition: scale_const.F90:68
subroutine freezing_water_kij(dt, PQ, rhoq, xq, tem)
module STDIO
Definition: scale_stdio.F90:12
integer, public ke
end point of inner domain: z, local
subroutine ice_multiplication_kij(PQ, Pac, tem, rhoq, xq)
real(rp), parameter, public const_tem00
temperature reference (0C) [K]
Definition: scale_const.F90:95
integer, public qa
real(rp), public const_cvvap
specific heat (water vapor, constant volume) [J/kg/K]
Definition: scale_const.F90:67
real(rp), public const_lhf0
latent heat of fusion at 0C [J/kg]
Definition: scale_const.F90:84
real(rp), parameter, public const_dice
density of ice [kg/m3]
Definition: scale_const.F90:88
subroutine, public atmos_saturation_dqsw_dtem_rho(dqsdtem, temp, dens)
subroutine, public atmos_saturation_dqsw_dtem_dpre(dqsdtem, dqsdpre, temp, pres)
real(rp), public dz
length in the main region [m]: z
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
Definition: scale_const.F90:57
real(rp), public const_undef
Definition: scale_const.F90:43
subroutine mixed_phase_collection_kij(Pac, PQ, wtem, rhoq, xq, dq_xave, vt_xave)
real(rp), parameter, public const_lhs0
latent heat of sublimation at 0C [J/kg]
Definition: scale_const.F90:82
subroutine, public atmos_phy_mp_sn14_cloudfraction(cldfrac, QTRC, mask_criterion)
Calculate Cloud Fraction.
module ATMOSPHERE / Physics Cloud Microphysics - Common
module grid index
subroutine, public atmos_saturation_dqsi_dtem_rho(dqsdtem, temp, dens)
subroutine debug_tem_kij(point, tem, rho, pre, qv)
module TRACER
integer, public ia
of x whole cells (local, with HALO)
integer, public mp_qa
integer, public ka
of z whole cells (local, with HALO)
real(rp), parameter, public const_lhv0
latent heat of vaporizaion at 0C [J/kg]
Definition: scale_const.F90:80
real(rp), public const_pre00
pressure reference [Pa]
Definition: scale_const.F90:93
real(rp), public const_lhf00
latent heat of fusion at 0K [J/kg]
Definition: scale_const.F90:85
real(rp), public const_grav
standard acceleration of gravity [m/s2]
Definition: scale_const.F90:48
integer, public js
start point of inner domain: y, local
module TIME
Definition: scale_time.F90:15
module PROCESS
subroutine update_by_phase_change_kij(ntdiv, ntmax, dt, gsgam2, z, dz, velz, dTdt_rad, rho, rhoe, rhoq, q, tem, pre, cva, esw, esi, rhoq2, PQ, qc_evaporate, sl_PLCdep, sl_PLRdep, sl_PNRdep)
real(rp), public const_lhv00
latent heat of vaporizaion at 0K [J/kg]
Definition: scale_const.F90:81
module SPECFUNC
subroutine, public log(type, message)
Definition: dc_log.f90:133
real(rp), parameter, public const_rvap
specific gas constant (water vapor) [J/kg/K]
Definition: scale_const.F90:65
subroutine, public atmos_saturation_dqsi_dtem_dpre(dqsdtem, dqsdpre, temp, pres)
module CONSTANT
Definition: scale_const.F90:14
real(rp), dimension(:), allocatable, public aq_cv
CV for each hydrometeors [J/kg/K].
integer, public ks
start point of inner domain: z, local
real(rp), parameter, public const_emelt
Definition: scale_const.F90:74
integer, public prc_myrank
process num in local communicator
module GRID (cartesian)
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:132
real(dp), parameter, public const_undef8
undefined value (REAL8)
Definition: scale_const.F90:42
subroutine, public atmos_phy_mp_sn14_mixingratio(Qe, QTRC0)
Calculate mixing ratio of each category.
subroutine, public atmos_phy_mp_sn14(DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, CCN, EVAPORATE, SFLX_rain, SFLX_snow)
Cloud Microphysics.
subroutine aut_acc_slc_brk_kij(PQ, rhoq, xq, dq_xave, rho)
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
Definition: scale_const.F90:36
module ATMOSPHERE / Thermodynamics
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
real(rp), dimension(:), allocatable, public grid_cdz
z-length of control volume [m]
real(rp), dimension(mp_qa), target, public atmos_phy_mp_dens
real(rp), public const_pi
pi
Definition: scale_const.F90:34
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
subroutine, public atmos_phy_mp_sn14_setup(MP_TYPE)
Setup Cloud Microphysics.
real(rp), parameter, public const_cpvap
specific heat (water vapor, constant pressure) [J/kg/K]
Definition: scale_const.F90:66
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:178
integer, parameter, public rp
subroutine mp_negativefilter(DENS, QTRC)
integer, public ja
of y whole cells (local, with HALO)