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

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

Modified particle box location and further changes in particle model

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