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