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

Last change on this file since 2477 was 2375, checked in by schwenkel, 7 years ago

improved aerosol initialization for bulk microphysics

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