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