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