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

Last change on this file since 3046 was 3046, checked in by Giersch, 6 years ago

Remaining error messages revised, comments extended

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