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