source: palm/trunk/SOURCE/lpm_init.f90 @ 2608

Last change on this file since 2608 was 2608, checked in by schwenkel, 6 years ago

Inital revision of diagnostic_quantities_mod allows unified calculation of magnus equation and saturion mixing ratio

  • Property svn:keywords set to Id
File size: 45.4 KB
Line 
1!> @file lpm_init.f90
2!------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2017 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_init.f90 2608 2017-11-13 14:04:26Z schwenkel $
27! Calculation of magnus equation in external module (diagnostic_quantities_mod).
28!
29! 2606 2017-11-10 10:36:31Z schwenkel
30! Changed particle box locations: center of particle box now coincides
31! with scalar grid point of same index.
32! Renamed module and subroutines: lpm_pack_arrays_mod -> lpm_pack_and_sort_mod
33! lpm_pack_all_arrays -> lpm_sort_in_subboxes, lpm_pack_arrays -> lpm_pack
34! lpm_sort -> lpm_sort_timeloop_done
35!
36! 2375 2017-08-29 14:10:28Z schwenkel
37! Initialization of chemical aerosol composition
38!
39! 2346 2017-08-09 16:39:17Z suehring
40! Bugfix, correct determination of topography top index
41!
42! 2318 2017-07-20 17:27:44Z suehring
43! Get topography top index via Function call
44!
45! 2317 2017-07-20 17:27:19Z suehring
46! Extended particle data type. Aerosol initialization improved.
47!
48! 2305 2017-07-06 11:18:47Z hoffmann
49! Improved calculation of particle IDs.
50!
51! 2274 2017-06-09 13:27:48Z Giersch
52!  Changed error messages
53!
54! 2265 2017-06-08 16:58:28Z schwenkel
55! Unused variables removed.
56!
57! 2263 2017-06-08 14:59:01Z schwenkel
58! Implemented splitting and merging algorithm
59!
60! 2233 2017-05-30 18:08:54Z suehring
61!
62! 2232 2017-05-30 17:47:52Z suehring
63! Adjustments according to new topography realization
64!
65!
66! 2223 2017-05-15 16:38:09Z suehring
67! Add check for particle release at model top
68!
69! 2182 2017-03-17 14:27:40Z schwenkel
70! Added parameters for simplified particle initialization.
71!
72! 2122 2017-01-18 12:22:54Z hoffmann
73! Improved initialization of equilibrium aerosol radii
74! Calculation of particle ID
75!
76! 2000 2016-08-20 18:09:15Z knoop
77! Forced header and separation lines into 80 columns
78!
79! 2016-06-09 16:25:25Z suehring
80! Bugfix in determining initial particle height and grid index in case of
81! seed_follows_topography.
82! Bugfix concerning random positions, ensure that particles do not move more
83! than one grid length.
84! Bugfix logarithmic interpolation.
85! Initial setting of sgs_wf_part.
86!
87! 1890 2016-04-22 08:52:11Z hoffmann
88! Initialization of aerosol equilibrium radius not possible in supersaturated
89! environments. Therefore, a maximum supersaturation of -1 % is assumed during
90! initialization.
91!
92! 1873 2016-04-18 14:50:06Z maronga
93! Module renamed (removed _mod
94!
95! 1871 2016-04-15 11:46:09Z hoffmann
96! Initialization of aerosols added.
97!
98! 1850 2016-04-08 13:29:27Z maronga
99! Module renamed
100!
101! 1831 2016-04-07 13:15:51Z hoffmann
102! curvature_solution_effects moved to particle_attributes
103!
104! 1822 2016-04-07 07:49:42Z hoffmann
105! Unused variables removed.
106!
107! 1783 2016-03-06 18:36:17Z raasch
108! netcdf module added
109!
110! 1725 2015-11-17 13:01:51Z hoffmann
111! Bugfix: Processor-dependent seed for random function is generated before it is
112! used.
113!
114! 1691 2015-10-26 16:17:44Z maronga
115! Renamed prandtl_layer to constant_flux_layer.
116!
117! 1685 2015-10-08 07:32:13Z raasch
118! bugfix concerning vertical index offset in case of ocean
119!
120! 1682 2015-10-07 23:56:08Z knoop
121! Code annotations made doxygen readable
122!
123! 1575 2015-03-27 09:56:27Z raasch
124! initial vertical particle position is allowed to follow the topography
125!
126! 1359 2014-04-11 17:15:14Z hoffmann
127! New particle structure integrated.
128! Kind definition added to all floating point numbers.
129! lpm_init changed form a subroutine to a module.
130!
131! 1327 2014-03-21 11:00:16Z raasch
132! -netcdf_output
133!
134! 1322 2014-03-20 16:38:49Z raasch
135! REAL functions provided with KIND-attribute
136!
137! 1320 2014-03-20 08:40:49Z raasch
138! ONLY-attribute added to USE-statements,
139! kind-parameters added to all INTEGER and REAL declaration statements,
140! kinds are defined in new module kinds,
141! revision history before 2012 removed,
142! comment fields (!:) to be used for variable explanations added to
143! all variable declaration statements
144! bugfix: #if defined( __parallel ) added
145!
146! 1314 2014-03-14 18:25:17Z suehring
147! Vertical logarithmic interpolation of horizontal particle speed for particles
148! between roughness height and first vertical grid level.
149!
150! 1092 2013-02-02 11:24:22Z raasch
151! unused variables removed
152!
153! 1036 2012-10-22 13:43:42Z raasch
154! code put under GPL (PALM 3.9)
155!
156! 849 2012-03-15 10:35:09Z raasch
157! routine renamed: init_particles -> lpm_init
158! de_dx, de_dy, de_dz are allocated here (instead of automatic arrays in
159! advec_particles),
160! sort_particles renamed lpm_sort_arrays, user_init_particles renamed lpm_init
161!
162! 828 2012-02-21 12:00:36Z raasch
163! call of init_kernels, particle feature color renamed class
164!
165! 824 2012-02-17 09:09:57Z raasch
166! particle attributes speed_x|y|z_sgs renamed rvar1|2|3,
167! array particles implemented as pointer
168!
169! 667 2010-12-23 12:06:00Z suehring/gryschka
170! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for allocation
171! of arrays.
172!
173! Revision 1.1  1999/11/25 16:22:38  raasch
174! Initial revision
175!
176!
177! Description:
178! ------------
179!> This routine initializes a set of particles and their attributes (position,
180!> radius, ..) which are used by the Lagrangian particle model (see lpm).
181!------------------------------------------------------------------------------!
182 MODULE lpm_init_mod
183
184    USE, INTRINSIC ::  ISO_C_BINDING
185
186    USE arrays_3d,                                                             &
187        ONLY:  de_dx, de_dy, de_dz, zu, zw
188
189    USE control_parameters,                                                    &
190        ONLY:  cloud_droplets, constant_flux_layer, current_timestep_number,   &
191               dt_3d, dz, initializing_actions, message_string, ocean,         &
192               simulated_time
193
194    USE grid_variables,                                                        &
195        ONLY:  ddx, dx, ddy, dy
196
197    USE indices,                                                               &
198        ONLY:  nx, nxl, nxlg, nxrg, nxr, ny, nyn, nys, nyng, nysg, nz, nzb,    &
199               nzt, wall_flags_0
200
201    USE kinds
202
203    USE lpm_collision_kernels_mod,                                             &
204        ONLY:  init_kernels
205
206    USE netcdf_interface,                                                      &
207        ONLY:  netcdf_data_format
208
209    USE particle_attributes,                                                   &
210        ONLY:   alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,        &
211                block_offset, block_offset_def, collision_kernel,              &
212                curvature_solution_effects, density_ratio, grid_particles,     &
213                isf,i_splitting_mode, initial_weighting_factor, ibc_par_b,     &
214                ibc_par_lr, ibc_par_ns, ibc_par_t, iran_part, log_z_z0,        &
215                max_number_of_particle_groups, min_nr_particle,                &
216                number_concentration,                                          &
217                number_particles_per_gridbox,  number_of_particles,            &
218                number_of_particle_groups, number_of_sublayers,                &
219                offset_ocean_nzt, offset_ocean_nzt_m1,                         &
220                particles, particle_advection_start, particle_groups,          &
221                particle_groups_type, particles_per_point,                     &
222                particle_type, pdx, pdy, pdz,  prt_count, psb, psl, psn, psr,  &
223                pss, pst, radius, random_start_position,                       &
224                read_particles_from_restartfile, seed_follows_topography,      &
225                sgs_wf_part, sort_count, splitting_function, splitting_mode,   &
226                total_number_of_particles, use_sgs_for_particles,              &
227                write_particle_statistics, zero_particle, z0_av_global
228
229    USE pegrid
230
231    USE random_function_mod,                                                   &
232        ONLY:  random_function
233
234    USE surface_mod,                                                           &
235        ONLY:  get_topography_top_index, surf_def_h, surf_lsm_h, surf_usm_h
236
237    IMPLICIT NONE
238
239    PRIVATE
240
241    INTEGER(iwp), PARAMETER         :: PHASE_INIT    = 1  !<
242    INTEGER(iwp), PARAMETER, PUBLIC :: PHASE_RELEASE = 2  !<
243
244    INTERFACE lpm_init
245       MODULE PROCEDURE lpm_init
246    END INTERFACE lpm_init
247
248    INTERFACE lpm_create_particle
249       MODULE PROCEDURE lpm_create_particle
250    END INTERFACE lpm_create_particle
251
252    PUBLIC lpm_init, lpm_create_particle
253
254 CONTAINS
255
256!------------------------------------------------------------------------------!
257! Description:
258! ------------
259!> @todo Missing subroutine description.
260!------------------------------------------------------------------------------!
261 SUBROUTINE lpm_init
262
263    USE lpm_collision_kernels_mod,                                             &
264        ONLY:  init_kernels
265
266    IMPLICIT NONE
267
268    INTEGER(iwp) ::  i                           !<
269    INTEGER(iwp) ::  j                           !<
270    INTEGER(iwp) ::  k                           !<
271
272    REAL(wp) ::  div                             !<
273    REAL(wp) ::  height_int                      !<
274    REAL(wp) ::  height_p                        !<
275    REAL(wp) ::  z_p                             !<
276    REAL(wp) ::  z0_av_local                     !<
277
278
279!
280!-- In case of oceans runs, the vertical index calculations need an offset,
281!-- because otherwise the k indices will become negative
282    IF ( ocean )  THEN
283       offset_ocean_nzt    = nzt
284       offset_ocean_nzt_m1 = nzt - 1
285    ENDIF
286
287!
288!-- Define block offsets for dividing a gridcell in 8 sub cells
289!-- See documentation for List of subgrid boxes
290!-- See pack_and_sort in lpm_pack_arrays.f90 for assignment of the subgrid boxes
291    block_offset(0) = block_offset_def ( 0, 0, 0)
292    block_offset(1) = block_offset_def ( 0, 0,-1)
293    block_offset(2) = block_offset_def ( 0,-1, 0)
294    block_offset(3) = block_offset_def ( 0,-1,-1)
295    block_offset(4) = block_offset_def (-1, 0, 0)
296    block_offset(5) = block_offset_def (-1, 0,-1)
297    block_offset(6) = block_offset_def (-1,-1, 0)
298    block_offset(7) = block_offset_def (-1,-1,-1)
299!
300!-- Check the number of particle groups.
301    IF ( number_of_particle_groups > max_number_of_particle_groups )  THEN
302       WRITE( message_string, * ) 'max_number_of_particle_groups =',      &
303                                  max_number_of_particle_groups ,         &
304                                  '&number_of_particle_groups reset to ', &
305                                  max_number_of_particle_groups
306       CALL message( 'lpm_init', 'PA0213', 0, 1, 0, 6, 0 )
307       number_of_particle_groups = max_number_of_particle_groups
308    ENDIF
309!
310!-- Check if downward-facing walls exist. This case, reflection boundary
311!-- conditions (as well as subgrid-scale velocities) may do not work
312!-- propably (not realized so far).
313    IF ( surf_def_h(1)%ns >= 1 )  THEN
314       WRITE( message_string, * ) 'Overhanging topography do not work '// &
315                                  'with particles'
316       CALL message( 'lpm_init', 'PA0212', 0, 1, 0, 6, 0 )
317
318    ENDIF
319
320!
321!-- Set default start positions, if necessary
322    IF ( psl(1) == 9999999.9_wp )  psl(1) = 0.0_wp
323    IF ( psr(1) == 9999999.9_wp )  psr(1) = ( nx +1 ) * dx
324    IF ( pss(1) == 9999999.9_wp )  pss(1) = 0.0_wp
325    IF ( psn(1) == 9999999.9_wp )  psn(1) = ( ny +1 ) * dy
326    IF ( psb(1) == 9999999.9_wp )  psb(1) = zu(nz/2)
327    IF ( pst(1) == 9999999.9_wp )  pst(1) = psb(1)
328
329    IF ( pdx(1) == 9999999.9_wp  .OR.  pdx(1) == 0.0_wp )  pdx(1) = dx
330    IF ( pdy(1) == 9999999.9_wp  .OR.  pdy(1) == 0.0_wp )  pdy(1) = dy
331    IF ( pdz(1) == 9999999.9_wp  .OR.  pdz(1) == 0.0_wp )  pdz(1) = zu(2) - zu(1)
332
333!
334!-- If number_particles_per_gridbox is set, the parametres pdx, pdy and pdz are
335!-- calculated diagnostically. Therfore an isotropic distribution is prescribed.
336    IF ( number_particles_per_gridbox /= -1 .AND.   &
337         number_particles_per_gridbox >= 1 )    THEN
338       pdx(1) = (( dx * dy * ( zu(2) - zu(1) ) ) /  &
339             REAL(number_particles_per_gridbox))**0.3333333_wp
340!
341!--    Ensure a smooth value (two significant digits) of distance between
342!--    particles (pdx, pdy, pdz).
343       div = 1000.0_wp
344       DO  WHILE ( pdx(1) < div )
345          div = div / 10.0_wp
346       ENDDO
347       pdx(1) = NINT( pdx(1) * 100.0_wp / div ) * div / 100.0_wp
348       pdy(1) = pdx(1)
349       pdz(1) = pdx(1)
350
351    ENDIF
352
353    DO  j = 2, number_of_particle_groups
354       IF ( psl(j) == 9999999.9_wp )  psl(j) = psl(j-1)
355       IF ( psr(j) == 9999999.9_wp )  psr(j) = psr(j-1)
356       IF ( pss(j) == 9999999.9_wp )  pss(j) = pss(j-1)
357       IF ( psn(j) == 9999999.9_wp )  psn(j) = psn(j-1)
358       IF ( psb(j) == 9999999.9_wp )  psb(j) = psb(j-1)
359       IF ( pst(j) == 9999999.9_wp )  pst(j) = pst(j-1)
360       IF ( pdx(j) == 9999999.9_wp  .OR.  pdx(j) == 0.0_wp )  pdx(j) = pdx(j-1)
361       IF ( pdy(j) == 9999999.9_wp  .OR.  pdy(j) == 0.0_wp )  pdy(j) = pdy(j-1)
362       IF ( pdz(j) == 9999999.9_wp  .OR.  pdz(j) == 0.0_wp )  pdz(j) = pdz(j-1)
363    ENDDO
364
365!
366!-- Allocate arrays required for calculating particle SGS velocities.
367!-- Initialize prefactor required for stoachastic Weil equation.
368    IF ( use_sgs_for_particles  .AND.  .NOT. cloud_droplets )  THEN
369       ALLOCATE( de_dx(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &
370                 de_dy(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &
371                 de_dz(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
372
373       sgs_wf_part = 1.0_wp / 3.0_wp
374    ENDIF
375
376!
377!-- Allocate array required for logarithmic vertical interpolation of
378!-- horizontal particle velocities between the surface and the first vertical
379!-- grid level. In order to avoid repeated CPU cost-intensive CALLS of
380!-- intrinsic FORTRAN procedure LOG(z/z0), LOG(z/z0) is precalculated for
381!-- several heights. Splitting into 20 sublayers turned out to be sufficient.
382!-- To obtain exact height levels of particles, linear interpolation is applied
383!-- (see lpm_advec.f90).
384    IF ( constant_flux_layer )  THEN
385
386       ALLOCATE ( log_z_z0(0:number_of_sublayers) )
387       z_p = zu(nzb+1) - zw(nzb)
388
389!
390!--    Calculate horizontal mean value of z0 used for logartihmic
391!--    interpolation. Note: this is not exact for heterogeneous z0.
392!--    However, sensitivity studies showed that the effect is
393!--    negligible.
394       z0_av_local  = SUM( surf_def_h(0)%z0 ) + SUM( surf_lsm_h%z0 ) +         &
395                      SUM( surf_usm_h%z0 )
396       z0_av_global = 0.0_wp
397
398#if defined( __parallel )
399       CALL MPI_ALLREDUCE(z0_av_local, z0_av_global, 1, MPI_REAL, MPI_SUM, &
400                          comm2d, ierr )
401#else
402       z0_av_global = z0_av_local
403#endif
404
405       z0_av_global = z0_av_global  / ( ( ny + 1 ) * ( nx + 1 ) )
406!
407!--    Horizontal wind speed is zero below and at z0
408       log_z_z0(0) = 0.0_wp
409!
410!--    Calculate vertical depth of the sublayers
411       height_int  = ( z_p - z0_av_global ) / REAL( number_of_sublayers, KIND=wp )
412!
413!--    Precalculate LOG(z/z0)
414       height_p    = z0_av_global
415       DO  k = 1, number_of_sublayers
416
417          height_p    = height_p + height_int
418          log_z_z0(k) = LOG( height_p / z0_av_global )
419
420       ENDDO
421
422    ENDIF
423
424!
425!-- Check boundary condition and set internal variables
426    SELECT CASE ( bc_par_b )
427
428       CASE ( 'absorb' )
429          ibc_par_b = 1
430
431       CASE ( 'reflect' )
432          ibc_par_b = 2
433
434       CASE DEFAULT
435          WRITE( message_string, * )  'unknown boundary condition ',   &
436                                       'bc_par_b = "', TRIM( bc_par_b ), '"'
437          CALL message( 'lpm_init', 'PA0217', 1, 2, 0, 6, 0 )
438
439    END SELECT
440    SELECT CASE ( bc_par_t )
441
442       CASE ( 'absorb' )
443          ibc_par_t = 1
444
445       CASE ( 'reflect' )
446          ibc_par_t = 2
447
448       CASE DEFAULT
449          WRITE( message_string, * ) 'unknown boundary condition ',   &
450                                     'bc_par_t = "', TRIM( bc_par_t ), '"'
451          CALL message( 'lpm_init', 'PA0218', 1, 2, 0, 6, 0 )
452
453    END SELECT
454    SELECT CASE ( bc_par_lr )
455
456       CASE ( 'cyclic' )
457          ibc_par_lr = 0
458
459       CASE ( 'absorb' )
460          ibc_par_lr = 1
461
462       CASE ( 'reflect' )
463          ibc_par_lr = 2
464
465       CASE DEFAULT
466          WRITE( message_string, * ) 'unknown boundary condition ',   &
467                                     'bc_par_lr = "', TRIM( bc_par_lr ), '"'
468          CALL message( 'lpm_init', 'PA0219', 1, 2, 0, 6, 0 )
469
470    END SELECT
471    SELECT CASE ( bc_par_ns )
472
473       CASE ( 'cyclic' )
474          ibc_par_ns = 0
475
476       CASE ( 'absorb' )
477          ibc_par_ns = 1
478
479       CASE ( 'reflect' )
480          ibc_par_ns = 2
481
482       CASE DEFAULT
483          WRITE( message_string, * ) 'unknown boundary condition ',   &
484                                     'bc_par_ns = "', TRIM( bc_par_ns ), '"'
485          CALL message( 'lpm_init', 'PA0220', 1, 2, 0, 6, 0 )
486
487    END SELECT
488    SELECT CASE ( splitting_mode )
489
490       CASE ( 'const' )
491          i_splitting_mode = 1
492
493       CASE ( 'cl_av' )
494          i_splitting_mode = 2
495
496       CASE ( 'gb_av' )
497          i_splitting_mode = 3
498
499       CASE DEFAULT
500          WRITE( message_string, * )  'unknown splitting condition ',   &
501                                       'splitting_mode = "', TRIM( splitting_mode ), '"'
502          CALL message( 'lpm_init', 'PA0146', 1, 2, 0, 6, 0 )
503
504    END SELECT
505    SELECT CASE ( splitting_function )
506
507       CASE ( 'gamma' )
508          isf = 1
509
510       CASE ( 'log' )
511          isf = 2
512
513       CASE ( 'exp' )
514          isf = 3
515
516       CASE DEFAULT
517          WRITE( message_string, * )  'unknown splitting function ',   &
518                                       'splitting_function = "', TRIM( splitting_function ), '"'
519          CALL message( 'lpm_init', 'PA0147', 1, 2, 0, 6, 0 )
520
521    END SELECT
522
523
524!
525!-- Initialize collision kernels
526    IF ( collision_kernel /= 'none' )  CALL init_kernels
527
528!
529!-- For the first model run of a possible job chain initialize the
530!-- particles, otherwise read the particle data from restart file.
531    IF ( TRIM( initializing_actions ) == 'read_restart_data'  &
532         .AND.  read_particles_from_restartfile )  THEN
533
534       CALL lpm_read_restart_file
535
536    ELSE
537
538!
539!--    Allocate particle arrays and set attributes of the initial set of
540!--    particles, which can be also periodically released at later times.
541       ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &
542                 grid_particles(nzb+1:nzt,nys:nyn,nxl:nxr) )
543
544       number_of_particles         = 0
545
546       sort_count = 0
547       prt_count  = 0
548
549!
550!--    initialize counter for particle IDs
551       grid_particles%id_counter = 1
552
553!
554!--    Initialize all particles with dummy values (otherwise errors may
555!--    occur within restart runs). The reason for this is still not clear
556!--    and may be presumably caused by errors in the respective user-interface.
557       zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
558                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
559                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
560                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
561                                      0, 0, 0_idp, .FALSE., -1 )
562
563       particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp )
564
565!
566!--    Set values for the density ratio and radius for all particle
567!--    groups, if necessary
568       IF ( density_ratio(1) == 9999999.9_wp )  density_ratio(1) = 0.0_wp
569       IF ( radius(1)        == 9999999.9_wp )  radius(1) = 0.0_wp
570       DO  i = 2, number_of_particle_groups
571          IF ( density_ratio(i) == 9999999.9_wp )  THEN
572             density_ratio(i) = density_ratio(i-1)
573          ENDIF
574          IF ( radius(i) == 9999999.9_wp )  radius(i) = radius(i-1)
575       ENDDO
576
577       DO  i = 1, number_of_particle_groups
578          IF ( density_ratio(i) /= 0.0_wp  .AND.  radius(i) == 0 )  THEN
579             WRITE( message_string, * ) 'particle group #', i, 'has a', &
580                                        'density ratio /= 0 but radius = 0'
581             CALL message( 'lpm_init', 'PA0215', 1, 2, 0, 6, 0 )
582          ENDIF
583          particle_groups(i)%density_ratio = density_ratio(i)
584          particle_groups(i)%radius        = radius(i)
585       ENDDO
586
587!
588!--    Set a seed value for the random number generator to be exclusively
589!--    used for the particle code. The generated random numbers should be
590!--    different on the different PEs.
591       iran_part = iran_part + myid
592
593       CALL lpm_create_particle (PHASE_INIT)
594!
595!--    User modification of initial particles
596       CALL user_lpm_init
597
598!
599!--    Open file for statistical informations about particle conditions
600       IF ( write_particle_statistics )  THEN
601          CALL check_open( 80 )
602          WRITE ( 80, 8000 )  current_timestep_number, simulated_time,         &
603                              number_of_particles
604          CALL close_file( 80 )
605       ENDIF
606
607    ENDIF
608
609!
610!-- To avoid programm abort, assign particles array to the local version of
611!-- first grid cell
612    number_of_particles = prt_count(nzb+1,nys,nxl)
613    particles => grid_particles(nzb+1,nys,nxl)%particles(1:number_of_particles)
614!
615!-- Formats
6168000 FORMAT (I6,1X,F7.2,4X,I10,71X,I10)
617
618 END SUBROUTINE lpm_init
619
620!------------------------------------------------------------------------------!
621! Description:
622! ------------
623!> @todo Missing subroutine description.
624!------------------------------------------------------------------------------!
625 SUBROUTINE lpm_create_particle (phase)
626
627    USE lpm_exchange_horiz_mod,                                                &
628        ONLY: lpm_exchange_horiz, lpm_move_particle, realloc_particles_array
629
630    USE lpm_pack_and_sort_mod,                                                   &
631        ONLY: lpm_sort_in_subboxes
632
633    USE particle_attributes,                                                   &
634        ONLY: deleted_particles
635
636    IMPLICIT  NONE
637
638    INTEGER(iwp)               ::  alloc_size  !< relative increase of allocated memory for particles
639    INTEGER(iwp)               ::  i           !< loop variable ( particle groups )
640    INTEGER(iwp)               ::  ip          !< index variable along x
641    INTEGER(iwp)               ::  j           !< loop variable ( particles per point )
642    INTEGER(iwp)               ::  jp          !< index variable along y
643    INTEGER(iwp)               ::  k           !< index variable along z
644    INTEGER(iwp)               ::  k_surf      !< index of surface grid point
645    INTEGER(iwp)               ::  kp          !< index variable along z
646    INTEGER(iwp)               ::  loop_stride !< loop variable for initialization
647    INTEGER(iwp)               ::  n           !< loop variable ( number of particles )
648    INTEGER(iwp)               ::  new_size    !< new size of allocated memory for particles
649
650    INTEGER(iwp), INTENT(IN)   ::  phase       !< mode of inititialization
651
652    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  local_count !< start address of new particle
653    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  local_start !< start address of new particle
654
655    LOGICAL                    ::  first_stride !< flag for initialization
656
657    REAL(wp)                   ::  pos_x      !< increment for particle position in x
658    REAL(wp)                   ::  pos_y      !< increment for particle position in y
659    REAL(wp)                   ::  pos_z      !< increment for particle position in z
660    REAL(wp)                   ::  rand_contr !< dummy argument for random position
661
662    TYPE(particle_type),TARGET ::  tmp_particle !< temporary particle used for initialization
663
664!
665!-- Calculate particle positions and store particle attributes, if
666!-- particle is situated on this PE
667    DO  loop_stride = 1, 2
668       first_stride = (loop_stride == 1)
669       IF ( first_stride )   THEN
670          local_count = 0           ! count number of particles
671       ELSE
672          local_count = prt_count   ! Start address of new particles
673       ENDIF
674
675!
676!--    Calculate initial_weighting_factor diagnostically
677       IF ( number_concentration /= -1.0_wp .AND. number_concentration > 0.0_wp ) THEN
678          initial_weighting_factor =  number_concentration * 1.0E6_wp *             &
679                                      pdx(1) * pdy(1) * pdz(1)
680       END IF
681
682       n = 0
683       DO  i = 1, number_of_particle_groups
684
685          pos_z = psb(i)
686
687          DO WHILE ( pos_z <= pst(i) )
688
689             IF ( pos_z >= 0.0_wp  .AND.  pos_z < zw(nzt) )  THEN
690
691
692                pos_y = pss(i)
693
694                DO WHILE ( pos_y <= psn(i) )
695
696                   IF ( pos_y >= nys * dy  .AND.                  &
697                        pos_y <  ( nyn + 1 ) * dy  ) THEN
698
699                      pos_x = psl(i)
700
701               xloop: DO WHILE ( pos_x <= psr(i) )
702
703                         IF ( pos_x >= nxl * dx  .AND.            &
704                              pos_x <  ( nxr + 1) * dx ) THEN
705
706                            DO  j = 1, particles_per_point
707
708
709                               n = n + 1
710                               tmp_particle%x             = pos_x
711                               tmp_particle%y             = pos_y
712                               tmp_particle%z             = pos_z
713                               tmp_particle%age           = 0.0_wp
714                               tmp_particle%age_m         = 0.0_wp
715                               tmp_particle%dt_sum        = 0.0_wp
716                               tmp_particle%e_m           = 0.0_wp
717                               tmp_particle%rvar1         = 0.0_wp
718                               tmp_particle%rvar2         = 0.0_wp
719                               tmp_particle%rvar3         = 0.0_wp
720                               tmp_particle%speed_x       = 0.0_wp
721                               tmp_particle%speed_y       = 0.0_wp
722                               tmp_particle%speed_z       = 0.0_wp
723                               tmp_particle%origin_x      = pos_x
724                               tmp_particle%origin_y      = pos_y
725                               tmp_particle%origin_z      = pos_z
726                               IF ( curvature_solution_effects )  THEN
727                                  tmp_particle%aux1      = 0.0_wp    ! dry aerosol radius
728                                  tmp_particle%aux2      = dt_3d     ! last Rosenbrock timestep
729                               ELSE
730                                  tmp_particle%aux1      = 0.0_wp    ! free to use
731                                  tmp_particle%aux2      = 0.0_wp    ! free to use
732                               ENDIF
733                               tmp_particle%radius        = particle_groups(i)%radius
734                               tmp_particle%weight_factor = initial_weighting_factor
735                               tmp_particle%class         = 1
736                               tmp_particle%group         = i
737                               tmp_particle%id            = 0_idp
738                               tmp_particle%particle_mask = .TRUE.
739                               tmp_particle%block_nr      = -1
740!
741!--                            Determine the grid indices of the particle position
742                               ip = tmp_particle%x * ddx
743                               jp = tmp_particle%y * ddy
744                               kp = tmp_particle%z / dz + 1 + offset_ocean_nzt
745!
746!--                            Determine surface level. Therefore, check for
747!--                            upward-facing wall on w-grid.
748                               k_surf = get_topography_top_index( jp, ip, 'w' )
749
750                               IF ( seed_follows_topography )  THEN
751!
752!--                               Particle height is given relative to topography
753                                  kp = kp + k_surf
754                                  tmp_particle%z = tmp_particle%z + zw(k_surf)
755!--                               Skip particle release if particle position is
756!--                               above model top, or within topography in case
757!--                               of overhanging structures.
758                                  IF ( kp > nzt  .OR.                          &
759                                 .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) )  THEN
760                                     pos_x = pos_x + pdx(i)
761                                     CYCLE xloop
762                                  ENDIF
763!
764!--                            Skip particle release if particle position is
765!--                            below surface, or within topography in case
766!--                            of overhanging structures.
767                               ELSEIF ( .NOT. seed_follows_topography .AND.    &
768                                         tmp_particle%z <= zw(k_surf)  .OR.    &
769                                        .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) )&
770                               THEN
771                                  pos_x = pos_x + pdx(i)
772                                  CYCLE xloop
773                               ENDIF
774
775                               local_count(kp,jp,ip) = local_count(kp,jp,ip) + 1
776
777                               IF ( .NOT. first_stride )  THEN
778                                  IF ( ip < nxl  .OR.  jp < nys  .OR.  kp < nzb+1 )  THEN
779                                     write(6,*) 'xl ',ip,jp,kp,nxl,nys,nzb+1
780                                  ENDIF
781                                  IF ( ip > nxr  .OR.  jp > nyn  .OR.  kp > nzt )  THEN
782                                     write(6,*) 'xu ',ip,jp,kp,nxr,nyn,nzt
783                                  ENDIF
784                                  grid_particles(kp,jp,ip)%particles(local_count(kp,jp,ip)) = tmp_particle
785
786                               ENDIF
787                            ENDDO
788
789                         ENDIF
790
791                         pos_x = pos_x + pdx(i)
792
793                      ENDDO xloop
794
795                   ENDIF
796
797                   pos_y = pos_y + pdy(i)
798
799                ENDDO
800
801             ENDIF
802
803             pos_z = pos_z + pdz(i)
804
805          ENDDO
806
807       ENDDO
808
809       IF ( first_stride )  THEN
810          DO  ip = nxl, nxr
811             DO  jp = nys, nyn
812                DO  kp = nzb+1, nzt
813                   IF ( phase == PHASE_INIT )  THEN
814                      IF ( local_count(kp,jp,ip) > 0 )  THEN
815                         alloc_size = MAX( INT( local_count(kp,jp,ip) *        &
816                            ( 1.0_wp + alloc_factor / 100.0_wp ) ),            &
817                            min_nr_particle )
818                      ELSE
819                         alloc_size = min_nr_particle
820                      ENDIF
821                      ALLOCATE(grid_particles(kp,jp,ip)%particles(1:alloc_size))
822                      DO  n = 1, alloc_size
823                         grid_particles(kp,jp,ip)%particles(n) = zero_particle
824                      ENDDO
825                   ELSEIF ( phase == PHASE_RELEASE )  THEN
826                      IF ( local_count(kp,jp,ip) > 0 )  THEN
827                         new_size   = local_count(kp,jp,ip) + prt_count(kp,jp,ip)
828                         alloc_size = MAX( INT( new_size * ( 1.0_wp +          &
829                            alloc_factor / 100.0_wp ) ), min_nr_particle )
830                         IF( alloc_size > SIZE( grid_particles(kp,jp,ip)%particles) )  THEN
831                            CALL realloc_particles_array(ip,jp,kp,alloc_size)
832                         ENDIF
833                      ENDIF
834                   ENDIF
835                ENDDO
836             ENDDO
837          ENDDO
838       ENDIF
839
840    ENDDO
841
842
843
844    local_start = prt_count+1
845    prt_count   = local_count
846
847!
848!-- Calculate particle IDs
849    DO  ip = nxl, nxr
850       DO  jp = nys, nyn
851          DO  kp = nzb+1, nzt
852             number_of_particles = prt_count(kp,jp,ip)
853             IF ( number_of_particles <= 0 )  CYCLE
854             particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
855
856             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles
857
858                particles(n)%id = 10000_idp**3 * grid_particles(kp,jp,ip)%id_counter + &
859                                  10000_idp**2 * kp + 10000_idp * jp + ip
860!
861!--             Count the number of particles that have been released before
862                grid_particles(kp,jp,ip)%id_counter =                          &
863                                         grid_particles(kp,jp,ip)%id_counter + 1
864
865             ENDDO
866
867          ENDDO
868       ENDDO
869    ENDDO
870
871!
872!-- Initialize aerosol background spectrum
873    IF ( curvature_solution_effects )  THEN
874       CALL lpm_init_aerosols(local_start)
875    ENDIF
876
877!
878!-- Add random fluctuation to particle positions.
879    IF ( random_start_position )  THEN
880       DO  ip = nxl, nxr
881          DO  jp = nys, nyn
882             DO  kp = nzb+1, nzt
883                number_of_particles = prt_count(kp,jp,ip)
884                IF ( number_of_particles <= 0 )  CYCLE
885                particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
886!
887!--             Move only new particles. Moreover, limit random fluctuation
888!--             in order to prevent that particles move more than one grid box,
889!--             which would lead to problems concerning particle exchange
890!--             between processors in case pdx/pdy are larger than dx/dy,
891!--             respectively.
892                DO  n = local_start(kp,jp,ip), number_of_particles
893                   IF ( psl(particles(n)%group) /= psr(particles(n)%group) )  THEN
894                      rand_contr = ( random_function( iran_part ) - 0.5_wp ) * &
895                                     pdx(particles(n)%group)
896                      particles(n)%x = particles(n)%x +                        &
897                              MERGE( rand_contr, SIGN( dx, rand_contr ),       &
898                                     ABS( rand_contr ) < dx                    &
899                                   )
900                   ENDIF
901                   IF ( pss(particles(n)%group) /= psn(particles(n)%group) )  THEN
902                      rand_contr = ( random_function( iran_part ) - 0.5_wp ) * &
903                                     pdy(particles(n)%group)
904                      particles(n)%y = particles(n)%y +                        &
905                              MERGE( rand_contr, SIGN( dy, rand_contr ),       &
906                                     ABS( rand_contr ) < dy                    &
907                                   )
908                   ENDIF
909                   IF ( psb(particles(n)%group) /= pst(particles(n)%group) )  THEN
910                      rand_contr = ( random_function( iran_part ) - 0.5_wp ) * &
911                                     pdz(particles(n)%group)
912                      particles(n)%z = particles(n)%z +                        &
913                              MERGE( rand_contr, SIGN( dz, rand_contr ),       &
914                                     ABS( rand_contr ) < dz                    &
915                                   )
916                   ENDIF
917                ENDDO
918!
919!--             Identify particles located outside the model domain and reflect
920!--             or absorb them if necessary.
921                CALL lpm_boundary_conds( 'bottom/top' )
922!
923!--             Furthermore, remove particles located in topography. Note, as
924!--             the particle speed is still zero at this point, wall
925!--             reflection boundary conditions will not work in this case.
926                particles =>                                                   &
927                       grid_particles(kp,jp,ip)%particles(1:number_of_particles)
928                DO  n = local_start(kp,jp,ip), number_of_particles
929                   i = particles(n)%x * ddx
930                   j = particles(n)%y * ddy
931                   k =   particles(n)%z / dz + 1 + offset_ocean_nzt
932!
933!--                Check if particle is within topography
934                   IF ( .NOT. BTEST( wall_flags_0(k,j,i), 0 ) )  THEN
935                      particles(n)%particle_mask = .FALSE.
936                      deleted_particles = deleted_particles + 1
937                   ENDIF
938
939                ENDDO
940             ENDDO
941          ENDDO
942       ENDDO
943!
944!--    Exchange particles between grid cells and processors
945       CALL lpm_move_particle
946       CALL lpm_exchange_horiz
947
948    ENDIF
949!
950!-- In case of random_start_position, delete particles identified by
951!-- lpm_exchange_horiz and lpm_boundary_conds. Then sort particles into blocks,
952!-- which is needed for a fast interpolation of the LES fields on the particle
953!-- position.
954    CALL lpm_sort_in_subboxes
955
956!
957!-- Determine the current number of particles
958    DO  ip = nxl, nxr
959       DO  jp = nys, nyn
960          DO  kp = nzb+1, nzt
961             number_of_particles         = number_of_particles                 &
962                                           + prt_count(kp,jp,ip)
963          ENDDO
964       ENDDO
965    ENDDO
966!
967!-- Calculate the number of particles of the total domain
968#if defined( __parallel )
969    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
970    CALL MPI_ALLREDUCE( number_of_particles, total_number_of_particles, 1, &
971    MPI_INTEGER, MPI_SUM, comm2d, ierr )
972#else
973    total_number_of_particles = number_of_particles
974#endif
975
976    RETURN
977
978 END SUBROUTINE lpm_create_particle
979
980 SUBROUTINE lpm_init_aerosols(local_start)
981
982    USE arrays_3d,                                                             &
983        ONLY: hyp, pt, q
984
985    USE cloud_parameters,                                                      &
986        ONLY: l_d_rv, molecular_weight_of_solute,                              &
987              molecular_weight_of_water, rho_l, r_v, rho_s, vanthoff
988
989    USE constants,                                                             &
990        ONLY: pi
991
992    USE diagnostic_quantities_mod,                                             &
993        ONLY:  magnus
994
995
996    USE kinds
997
998    USE particle_attributes,                                                   &
999        ONLY: aero_species, aero_type, aero_weight, log_sigma, na, rm
1000
1001    IMPLICIT NONE
1002
1003    REAL(wp)  :: afactor            !< curvature effects
1004    REAL(wp)  :: bfactor            !< solute effects
1005    REAL(wp)  :: dlogr              !< logarithmic width of radius bin
1006    REAL(wp)  :: e_a                !< vapor pressure
1007    REAL(wp)  :: e_s                !< saturation vapor pressure
1008    REAL(wp)  :: rmin = 0.005e-6_wp !< minimum aerosol radius
1009    REAL(wp)  :: rmax = 10.0e-6_wp  !< maximum aerosol radius
1010    REAL(wp)  :: r_mid              !< mean radius of bin
1011    REAL(wp)  :: r_l                !< left radius of bin
1012    REAL(wp)  :: r_r                !< right radius of bin
1013    REAL(wp)  :: sigma              !< surface tension
1014    REAL(wp)  :: t_int              !< temperature
1015
1016    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) ::  local_start !<
1017
1018    INTEGER(iwp)  :: n              !<
1019    INTEGER(iwp)  :: ip             !<
1020    INTEGER(iwp)  :: jp             !<
1021    INTEGER(iwp)  :: kp             !<
1022
1023!
1024!-- Set constants for different aerosol species
1025    IF ( TRIM(aero_species) .EQ. 'nacl' ) THEN
1026       molecular_weight_of_solute = 0.05844_wp 
1027       rho_s                      = 2165.0_wp
1028       vanthoff                   = 2.0_wp
1029    ELSEIF ( TRIM(aero_species) .EQ. 'c3h4o4' ) THEN
1030       molecular_weight_of_solute = 0.10406_wp 
1031       rho_s                      = 1600.0_wp
1032       vanthoff                   = 1.37_wp
1033    ELSEIF ( TRIM(aero_species) .EQ. 'nh4o3' ) THEN
1034       molecular_weight_of_solute = 0.08004_wp 
1035       rho_s                      = 1720.0_wp
1036       vanthoff                   = 2.31_wp
1037    ELSE
1038       WRITE( message_string, * ) 'unknown aerosol species ',   &
1039                                'aero_species = "', TRIM( aero_species ), '"'
1040       CALL message( 'lpm_init', 'PA0470', 1, 2, 0, 6, 0 )
1041    ENDIF
1042!
1043!-- The following typical aerosol spectra are taken from Jaenicke (1993):
1044!-- Tropospheric aerosols. Published in Aerosol-Cloud-Climate Interactions.
1045    IF ( TRIM(aero_type) .EQ. 'polar' )  THEN
1046       na        = (/ 2.17e1, 1.86e-1, 3.04e-4 /) * 1.0E6
1047       rm        = (/ 0.0689, 0.375, 4.29 /) * 1.0E-6
1048       log_sigma = (/ 0.245, 0.300, 0.291 /)
1049    ELSEIF ( TRIM(aero_type) .EQ. 'background' )  THEN
1050       na        = (/ 1.29e2, 5.97e1, 6.35e1 /) * 1.0E6
1051       rm        = (/ 0.0036, 0.127, 0.259 /) * 1.0E-6
1052       log_sigma = (/ 0.645, 0.253, 0.425 /)
1053    ELSEIF ( TRIM(aero_type) .EQ. 'maritime' )  THEN
1054       na        = (/ 1.33e2, 6.66e1, 3.06e0 /) * 1.0E6
1055       rm        = (/ 0.0039, 0.133, 0.29 /) * 1.0E-6
1056       log_sigma = (/ 0.657, 0.210, 0.396 /)
1057    ELSEIF ( TRIM(aero_type) .EQ. 'continental' )  THEN
1058       na        = (/ 3.20e3, 2.90e3, 3.00e-1 /) * 1.0E6
1059       rm        = (/ 0.01, 0.058, 0.9 /) * 1.0E-6
1060       log_sigma = (/ 0.161, 0.217, 0.380 /)
1061    ELSEIF ( TRIM(aero_type) .EQ. 'desert' )  THEN
1062       na        = (/ 7.26e2, 1.14e3, 1.78e-1 /) * 1.0E6
1063       rm        = (/ 0.001, 0.0188, 10.8 /) * 1.0E-6
1064       log_sigma = (/ 0.247, 0.770, 0.438 /)
1065    ELSEIF ( TRIM(aero_type) .EQ. 'rural' )  THEN
1066       na        = (/ 6.65e3, 1.47e2, 1.99e3 /) * 1.0E6
1067       rm        = (/ 0.00739, 0.0269, 0.0419 /) * 1.0E-6
1068       log_sigma = (/ 0.225, 0.557, 0.266 /)
1069    ELSEIF ( TRIM(aero_type) .EQ. 'urban' )  THEN
1070       na        = (/ 9.93e4, 1.11e3, 3.64e4 /) * 1.0E6
1071       rm        = (/ 0.00651, 0.00714, 0.0248 /) * 1.0E-6
1072       log_sigma = (/ 0.245, 0.666, 0.337 /)
1073    ELSEIF ( TRIM(aero_type) .EQ. 'user' )  THEN
1074       CONTINUE
1075    ELSE
1076       WRITE( message_string, * ) 'unknown aerosol type ',   &
1077                                'aero_type = "', TRIM( aero_type ), '"'
1078       CALL message( 'lpm_init', 'PA0459', 1, 2, 0, 6, 0 )
1079    ENDIF
1080
1081    DO  ip = nxl, nxr
1082       DO  jp = nys, nyn
1083          DO  kp = nzb+1, nzt
1084
1085             number_of_particles = prt_count(kp,jp,ip)
1086             IF ( number_of_particles <= 0 )  CYCLE
1087             particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
1088
1089             dlogr   = ( LOG10(rmax) - LOG10(rmin) ) / ( number_of_particles - local_start(kp,jp,ip) + 1 )
1090!
1091!--          Initialize the aerosols with a predefined spectral distribution
1092!--          of the dry radius (logarithmically increasing bins) and a varying
1093!--          weighting factor
1094             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles
1095
1096                r_l   = 10.0**( LOG10( rmin ) + (n-1) * dlogr )
1097                r_r   = 10.0**( LOG10( rmin ) + n * dlogr )
1098                r_mid = SQRT( r_l * r_r )
1099
1100                particles(n)%aux1          = r_mid
1101                particles(n)%weight_factor =                                           &
1102                   ( na(1) / ( SQRT( 2.0 * pi ) * log_sigma(1) ) *                     &
1103                     EXP( - LOG10( r_mid / rm(1) )**2 / ( 2.0 * log_sigma(1)**2 ) ) +  &
1104                     na(2) / ( SQRT( 2.0 * pi ) * log_sigma(2) ) *                     &
1105                     EXP( - LOG10( r_mid / rm(2) )**2 / ( 2.0 * log_sigma(2)**2 ) ) +  &
1106                     na(3) / ( SQRT( 2.0 * pi ) * log_sigma(3) ) *                     &
1107                     EXP( - LOG10( r_mid / rm(3) )**2 / ( 2.0 * log_sigma(3)**2 ) )    &
1108                   ) * ( LOG10(r_r) - LOG10(r_l) ) * ( dx * dy * dz )
1109
1110!
1111!--             Multiply weight_factor with the namelist parameter aero_weight
1112!--             to increase or decrease the number of simulated aerosols
1113                particles(n)%weight_factor = particles(n)%weight_factor * aero_weight
1114
1115                IF ( particles(n)%weight_factor - FLOOR(particles(n)%weight_factor,KIND=wp) &
1116                     .GT. random_function( iran_part ) )  THEN
1117                   particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp) + 1.0
1118                ELSE
1119                   particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp)
1120                ENDIF
1121!
1122!--             Unnecessary particles will be deleted
1123                IF ( particles(n)%weight_factor .LE. 0.0 )  particles(n)%particle_mask = .FALSE.
1124
1125             ENDDO
1126!
1127!--          Set particle radius to equilibrium radius based on the environmental
1128!--          supersaturation (Khvorostyanov and Curry, 2007, JGR). This avoids
1129!--          the sometimes lengthy growth toward their equilibrium radius within
1130!--          the simulation.
1131             t_int  = pt(kp,jp,ip) * ( hyp(kp) / 100000.0_wp )**0.286_wp
1132
1133             e_s = magnus( t_int )
1134             e_a = q(kp,jp,ip) * hyp(kp) / ( q(kp,jp,ip) + 0.622_wp )
1135
1136             sigma   = 0.0761_wp - 0.000155_wp * ( t_int - 273.15_wp )
1137             afactor = 2.0_wp * sigma / ( rho_l * r_v * t_int )
1138
1139             bfactor = vanthoff * molecular_weight_of_water *    &
1140                       rho_s / ( molecular_weight_of_solute * rho_l )
1141!
1142!--          The formula is only valid for subsaturated environments. For
1143!--          supersaturations higher than -5 %, the supersaturation is set to -5%.
1144             IF ( e_a / e_s >= 0.95_wp )  e_a = 0.95_wp * e_s
1145
1146             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles
1147!
1148!--             For details on this equation, see Eq. (14) of Khvorostyanov and
1149!--             Curry (2007, JGR)
1150                particles(n)%radius = bfactor**0.3333333_wp *                  &
1151                   particles(n)%aux1 / ( 1.0_wp - e_a / e_s )**0.3333333_wp / &
1152                   ( 1.0_wp + ( afactor / ( 3.0_wp * bfactor**0.3333333_wp *   &
1153                     particles(n)%aux1 ) ) /                                  &
1154                     ( 1.0_wp - e_a / e_s )**0.6666666_wp                      &
1155                   )
1156
1157             ENDDO
1158
1159          ENDDO
1160       ENDDO
1161    ENDDO
1162
1163 END SUBROUTINE lpm_init_aerosols
1164
1165END MODULE lpm_init_mod
Note: See TracBrowser for help on using the repository browser.