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