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