1 | !> @file lagrangian_particle_model_mod.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-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: lagrangian_particle_model_mod.f90 4276 2019-10-28 16:03:29Z schwenkel $ |
---|
27 | ! Modularize lpm: Move conditions in time intergration to module |
---|
28 | ! |
---|
29 | ! 4275 2019-10-28 15:34:55Z schwenkel |
---|
30 | ! Change call of simple predictor corrector method, i.e. two divergence free |
---|
31 | ! velocitiy fields are now used. |
---|
32 | ! |
---|
33 | ! 4232 2019-09-20 09:34:22Z knoop |
---|
34 | ! Removed INCLUDE "mpif.h", as it is not needed because of USE pegrid |
---|
35 | ! |
---|
36 | ! 4195 2019-08-28 13:44:27Z schwenkel |
---|
37 | ! Bugfix for simple_corrector interpolation method in case of ocean runs and |
---|
38 | ! output particle advection interpolation method into header |
---|
39 | ! |
---|
40 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
41 | ! Corrected "Former revisions" section |
---|
42 | ! |
---|
43 | ! 4168 2019-08-16 13:50:17Z suehring |
---|
44 | ! Replace function get_topography_top_index by topo_top_ind |
---|
45 | ! |
---|
46 | ! 4145 2019-08-06 09:55:22Z schwenkel |
---|
47 | ! Some reformatting |
---|
48 | ! |
---|
49 | ! 4144 2019-08-06 09:11:47Z raasch |
---|
50 | ! relational operators .EQ., .NE., etc. replaced by ==, /=, etc. |
---|
51 | ! |
---|
52 | ! 4143 2019-08-05 15:14:53Z schwenkel |
---|
53 | ! Rename variable and change select case to if statement |
---|
54 | ! |
---|
55 | ! 4122 2019-07-26 13:11:56Z schwenkel |
---|
56 | ! Implement reset method as bottom boundary condition |
---|
57 | ! |
---|
58 | ! 4121 2019-07-26 10:01:22Z schwenkel |
---|
59 | ! Implementation of an simple method for interpolating the velocities to |
---|
60 | ! particle position |
---|
61 | ! |
---|
62 | ! 4114 2019-07-23 14:09:27Z schwenkel |
---|
63 | ! Bugfix: Added working precision for if statement |
---|
64 | ! |
---|
65 | ! 4054 2019-06-27 07:42:18Z raasch |
---|
66 | ! bugfix for calculating the minimum particle time step |
---|
67 | ! |
---|
68 | ! 4044 2019-06-19 12:28:27Z schwenkel |
---|
69 | ! Bugfix in case of grid strecting: corrected calculation of k-Index |
---|
70 | ! |
---|
71 | ! 4043 2019-06-18 16:59:00Z schwenkel |
---|
72 | ! Remove min_nr_particle, Add lpm_droplet_interactions_ptq into module |
---|
73 | ! |
---|
74 | ! 4028 2019-06-13 12:21:37Z schwenkel |
---|
75 | ! Further modularization of particle code components |
---|
76 | ! |
---|
77 | ! 4020 2019-06-06 14:57:48Z schwenkel |
---|
78 | ! Removing submodules |
---|
79 | ! |
---|
80 | ! 4018 2019-06-06 13:41:50Z eckhard |
---|
81 | ! Bugfix for former revision |
---|
82 | ! |
---|
83 | ! 4017 2019-06-06 12:16:46Z schwenkel |
---|
84 | ! Modularization of all lagrangian particle model code components |
---|
85 | ! |
---|
86 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
87 | ! bugfix to guarantee correct particle releases in case that the release |
---|
88 | ! interval is smaller than the model timestep |
---|
89 | ! |
---|
90 | ! Revision 1.1 1999/11/25 16:16:06 raasch |
---|
91 | ! Initial revision |
---|
92 | ! |
---|
93 | ! |
---|
94 | ! Description: |
---|
95 | ! ------------ |
---|
96 | !> The embedded LPM allows for studying transport and dispersion processes within |
---|
97 | !> turbulent flows. This model including passive particles that do not show any |
---|
98 | !> feedback on the turbulent flow. Further also particles with inertia and |
---|
99 | !> cloud droplets ca be simulated explicitly. |
---|
100 | !> |
---|
101 | !> @todo test lcm |
---|
102 | !> implement simple interpolation method for subgrid scale velocites |
---|
103 | !> @note <Enter notes on the module> |
---|
104 | !> @bug <Enter bug on the module> |
---|
105 | !------------------------------------------------------------------------------! |
---|
106 | MODULE lagrangian_particle_model_mod |
---|
107 | |
---|
108 | USE, INTRINSIC :: ISO_C_BINDING |
---|
109 | |
---|
110 | USE arrays_3d, & |
---|
111 | ONLY: de_dx, de_dy, de_dz, dzw, zu, zw, ql_c, ql_v, ql_vp, hyp, & |
---|
112 | pt, q, exner, ql, diss, e, u, v, w, km, ql_1, ql_2, pt_p, q_p, & |
---|
113 | d_exner |
---|
114 | |
---|
115 | USE averaging, & |
---|
116 | ONLY: ql_c_av, pr_av, pc_av, ql_vp_av, ql_v_av |
---|
117 | |
---|
118 | USE basic_constants_and_equations_mod, & |
---|
119 | ONLY: molecular_weight_of_solute, molecular_weight_of_water, magnus, & |
---|
120 | pi, rd_d_rv, rho_l, r_v, rho_s, vanthoff, l_v, kappa, g, lv_d_cp |
---|
121 | |
---|
122 | USE control_parameters, & |
---|
123 | ONLY: bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r, bc_dirichlet_s, & |
---|
124 | cloud_droplets, constant_flux_layer, current_timestep_number, & |
---|
125 | dt_3d, dt_3d_reached, humidity, & |
---|
126 | dt_3d_reached_l, dt_dopts, dz, initializing_actions, & |
---|
127 | intermediate_timestep_count, intermediate_timestep_count_max, & |
---|
128 | message_string, molecular_viscosity, ocean_mode, & |
---|
129 | particle_maximum_age, iran, & |
---|
130 | simulated_time, topography, dopts_time_count, & |
---|
131 | time_since_reference_point, rho_surface, u_gtrans, v_gtrans, & |
---|
132 | dz_stretch_level, dz_stretch_level_start |
---|
133 | |
---|
134 | USE cpulog, & |
---|
135 | ONLY: cpu_log, log_point, log_point_s |
---|
136 | |
---|
137 | USE indices, & |
---|
138 | ONLY: nx, nxl, nxlg, nxrg, nxr, ny, nyn, nys, nyng, nysg, nz, nzb, & |
---|
139 | nzb_max, nzt,nbgp, ngp_2dh_outer, & |
---|
140 | topo_top_ind, & |
---|
141 | wall_flags_0 |
---|
142 | |
---|
143 | USE kinds |
---|
144 | |
---|
145 | USE pegrid |
---|
146 | |
---|
147 | USE particle_attributes |
---|
148 | |
---|
149 | USE pmc_particle_interface, & |
---|
150 | ONLY: pmcp_c_get_particle_from_parent, pmcp_p_fill_particle_win, & |
---|
151 | pmcp_c_send_particle_to_parent, pmcp_p_empty_particle_win, & |
---|
152 | pmcp_p_delete_particles_in_fine_grid_area, pmcp_g_init, & |
---|
153 | pmcp_g_print_number_of_particles |
---|
154 | |
---|
155 | USE pmc_interface, & |
---|
156 | ONLY: nested_run |
---|
157 | |
---|
158 | USE grid_variables, & |
---|
159 | ONLY: ddx, dx, ddy, dy |
---|
160 | |
---|
161 | USE netcdf_interface, & |
---|
162 | ONLY: netcdf_data_format, netcdf_deflate, dopts_num, id_set_pts, & |
---|
163 | id_var_dopts, id_var_time_pts, nc_stat, & |
---|
164 | netcdf_handle_error |
---|
165 | |
---|
166 | USE random_function_mod, & |
---|
167 | ONLY: random_function |
---|
168 | |
---|
169 | USE statistics, & |
---|
170 | ONLY: hom |
---|
171 | |
---|
172 | USE surface_mod, & |
---|
173 | ONLY: bc_h, & |
---|
174 | surf_def_h, & |
---|
175 | surf_lsm_h, & |
---|
176 | surf_usm_h |
---|
177 | |
---|
178 | #if defined( __parallel ) && !defined( __mpifh ) |
---|
179 | USE MPI |
---|
180 | #endif |
---|
181 | |
---|
182 | #if defined( __netcdf ) |
---|
183 | USE NETCDF |
---|
184 | #endif |
---|
185 | |
---|
186 | IMPLICIT NONE |
---|
187 | |
---|
188 | CHARACTER(LEN=15) :: aero_species = 'nacl' !< aerosol species |
---|
189 | CHARACTER(LEN=15) :: aero_type = 'maritime' !< aerosol type |
---|
190 | CHARACTER(LEN=15) :: bc_par_lr = 'cyclic' !< left/right boundary condition |
---|
191 | CHARACTER(LEN=15) :: bc_par_ns = 'cyclic' !< north/south boundary condition |
---|
192 | CHARACTER(LEN=15) :: bc_par_b = 'reflect' !< bottom boundary condition |
---|
193 | CHARACTER(LEN=15) :: bc_par_t = 'absorb' !< top boundary condition |
---|
194 | CHARACTER(LEN=15) :: collision_kernel = 'none' !< collision kernel |
---|
195 | |
---|
196 | CHARACTER(LEN=5) :: splitting_function = 'gamma' !< function for calculation critical weighting factor |
---|
197 | CHARACTER(LEN=5) :: splitting_mode = 'const' !< splitting mode |
---|
198 | |
---|
199 | CHARACTER(LEN=25) :: particle_advection_interpolation = 'trilinear' !< interpolation method for calculatin the particle |
---|
200 | |
---|
201 | INTEGER(iwp) :: deleted_particles = 0 !< number of deleted particles per time step |
---|
202 | INTEGER(iwp) :: i_splitting_mode !< dummy for splitting mode |
---|
203 | INTEGER(iwp) :: iran_part = -1234567 !< number for random generator |
---|
204 | INTEGER(iwp) :: max_number_particles_per_gridbox = 100 !< namelist parameter (see documentation) |
---|
205 | INTEGER(iwp) :: isf !< dummy for splitting function |
---|
206 | INTEGER(iwp) :: number_particles_per_gridbox = -1 !< namelist parameter (see documentation) |
---|
207 | INTEGER(iwp) :: number_of_sublayers = 20 !< number of sublayers for particle velocities betwenn surface and first grid level |
---|
208 | INTEGER(iwp) :: offset_ocean_nzt = 0 !< in case of oceans runs, the vertical index calculations need an offset |
---|
209 | INTEGER(iwp) :: offset_ocean_nzt_m1 = 0 !< in case of oceans runs, the vertical index calculations need an offset |
---|
210 | INTEGER(iwp) :: particles_per_point = 1 !< namelist parameter (see documentation) |
---|
211 | INTEGER(iwp) :: radius_classes = 20 !< namelist parameter (see documentation) |
---|
212 | INTEGER(iwp) :: splitting_factor = 2 !< namelist parameter (see documentation) |
---|
213 | INTEGER(iwp) :: splitting_factor_max = 5 !< namelist parameter (see documentation) |
---|
214 | INTEGER(iwp) :: step_dealloc = 100 !< namelist parameter (see documentation) |
---|
215 | INTEGER(iwp) :: total_number_of_particles !< total number of particles in the whole model domain |
---|
216 | INTEGER(iwp) :: trlp_count_sum !< parameter for particle exchange of PEs |
---|
217 | INTEGER(iwp) :: trlp_count_recv_sum !< parameter for particle exchange of PEs |
---|
218 | INTEGER(iwp) :: trrp_count_sum !< parameter for particle exchange of PEs |
---|
219 | INTEGER(iwp) :: trrp_count_recv_sum !< parameter for particle exchange of PEs |
---|
220 | INTEGER(iwp) :: trsp_count_sum !< parameter for particle exchange of PEs |
---|
221 | INTEGER(iwp) :: trsp_count_recv_sum !< parameter for particle exchange of PEs |
---|
222 | INTEGER(iwp) :: trnp_count_sum !< parameter for particle exchange of PEs |
---|
223 | INTEGER(iwp) :: trnp_count_recv_sum !< parameter for particle exchange of PEs |
---|
224 | |
---|
225 | LOGICAL :: lagrangian_particle_model = .FALSE. !< namelist parameter (see documentation) |
---|
226 | LOGICAL :: curvature_solution_effects = .FALSE. !< namelist parameter (see documentation) |
---|
227 | LOGICAL :: deallocate_memory = .TRUE. !< namelist parameter (see documentation) |
---|
228 | LOGICAL :: hall_kernel = .FALSE. !< flag for collision kernel |
---|
229 | LOGICAL :: merging = .FALSE. !< namelist parameter (see documentation) |
---|
230 | LOGICAL :: random_start_position = .FALSE. !< namelist parameter (see documentation) |
---|
231 | LOGICAL :: read_particles_from_restartfile = .TRUE. !< namelist parameter (see documentation) |
---|
232 | LOGICAL :: seed_follows_topography = .FALSE. !< namelist parameter (see documentation) |
---|
233 | LOGICAL :: splitting = .FALSE. !< namelist parameter (see documentation) |
---|
234 | LOGICAL :: use_kernel_tables = .FALSE. !< parameter, which turns on the use of precalculated collision kernels |
---|
235 | LOGICAL :: write_particle_statistics = .FALSE. !< namelist parameter (see documentation) |
---|
236 | LOGICAL :: interpolation_simple_predictor = .FALSE. !< flag for simple particle advection interpolation with predictor step |
---|
237 | LOGICAL :: interpolation_simple_corrector = .FALSE. !< flag for simple particle advection interpolation with corrector step |
---|
238 | LOGICAL :: interpolation_trilinear = .FALSE. !< flag for trilinear particle advection interpolation |
---|
239 | |
---|
240 | LOGICAL, DIMENSION(max_number_of_particle_groups) :: vertical_particle_advection = .TRUE. !< Switch for vertical particle transport |
---|
241 | |
---|
242 | REAL(wp) :: aero_weight = 1.0_wp !< namelist parameter (see documentation) |
---|
243 | REAL(wp) :: dt_min_part = 0.0002_wp !< minimum particle time step when SGS velocities are used (s) |
---|
244 | REAL(wp) :: dt_prel = 9999999.9_wp !< namelist parameter (see documentation) |
---|
245 | REAL(wp) :: dt_write_particle_data = 9999999.9_wp !< namelist parameter (see documentation) |
---|
246 | REAL(wp) :: end_time_prel = 9999999.9_wp !< namelist parameter (see documentation) |
---|
247 | REAL(wp) :: initial_weighting_factor = 1.0_wp !< namelist parameter (see documentation) |
---|
248 | REAL(wp) :: last_particle_release_time = 0.0_wp !< last time of particle release |
---|
249 | REAL(wp) :: log_sigma(3) = 1.0_wp !< namelist parameter (see documentation) |
---|
250 | REAL(wp) :: na(3) = 0.0_wp !< namelist parameter (see documentation) |
---|
251 | REAL(wp) :: number_concentration = -1.0_wp !< namelist parameter (see documentation) |
---|
252 | REAL(wp) :: radius_merge = 1.0E-7_wp !< namelist parameter (see documentation) |
---|
253 | REAL(wp) :: radius_split = 40.0E-6_wp !< namelist parameter (see documentation) |
---|
254 | REAL(wp) :: rm(3) = 1.0E-6_wp !< namelist parameter (see documentation) |
---|
255 | REAL(wp) :: sgs_wf_part !< parameter for sgs |
---|
256 | REAL(wp) :: time_write_particle_data = 0.0_wp !< write particle data at current time on file |
---|
257 | REAL(wp) :: weight_factor_merge = -1.0_wp !< namelist parameter (see documentation) |
---|
258 | REAL(wp) :: weight_factor_split = -1.0_wp !< namelist parameter (see documentation) |
---|
259 | REAL(wp) :: z0_av_global !< horizontal mean value of z0 |
---|
260 | |
---|
261 | REAL(wp) :: rclass_lbound !< |
---|
262 | REAL(wp) :: rclass_ubound !< |
---|
263 | |
---|
264 | REAL(wp), PARAMETER :: c_0 = 3.0_wp !< parameter for lagrangian timescale |
---|
265 | |
---|
266 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: density_ratio = 9999999.9_wp !< namelist parameter (see documentation) |
---|
267 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: pdx = 9999999.9_wp !< namelist parameter (see documentation) |
---|
268 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: pdy = 9999999.9_wp !< namelist parameter (see documentation) |
---|
269 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: pdz = 9999999.9_wp !< namelist parameter (see documentation) |
---|
270 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: psb = 9999999.9_wp !< namelist parameter (see documentation) |
---|
271 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: psl = 9999999.9_wp !< namelist parameter (see documentation) |
---|
272 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: psn = 9999999.9_wp !< namelist parameter (see documentation) |
---|
273 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: psr = 9999999.9_wp !< namelist parameter (see documentation) |
---|
274 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: pss = 9999999.9_wp !< namelist parameter (see documentation) |
---|
275 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: pst = 9999999.9_wp !< namelist parameter (see documentation). |
---|
276 | REAL(wp), DIMENSION(max_number_of_particle_groups) :: radius = 9999999.9_wp !< namelist parameter (see documentation) |
---|
277 | |
---|
278 | REAL(wp), DIMENSION(:), ALLOCATABLE :: log_z_z0 !< Precalculate LOG(z/z0) |
---|
279 | |
---|
280 | INTEGER(iwp), PARAMETER :: NR_2_direction_move = 10000 !< |
---|
281 | INTEGER(iwp) :: nr_move_north !< |
---|
282 | INTEGER(iwp) :: nr_move_south !< |
---|
283 | |
---|
284 | TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: move_also_north |
---|
285 | TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: move_also_south |
---|
286 | |
---|
287 | REAL(wp) :: epsilon_collision !< |
---|
288 | REAL(wp) :: urms !< |
---|
289 | |
---|
290 | REAL(wp), DIMENSION(:), ALLOCATABLE :: epsclass !< dissipation rate class |
---|
291 | REAL(wp), DIMENSION(:), ALLOCATABLE :: radclass !< radius class |
---|
292 | REAL(wp), DIMENSION(:), ALLOCATABLE :: winf !< |
---|
293 | |
---|
294 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ec !< |
---|
295 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ecf !< |
---|
296 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: gck !< |
---|
297 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: hkernel !< |
---|
298 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: hwratio !< |
---|
299 | |
---|
300 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ckernel !< |
---|
301 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_t !< u value of old timelevel t |
---|
302 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_t !< v value of old timelevel t |
---|
303 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_t !< w value of old timelevel t |
---|
304 | |
---|
305 | |
---|
306 | INTEGER(iwp), PARAMETER :: PHASE_INIT = 1 !< |
---|
307 | INTEGER(iwp), PARAMETER, PUBLIC :: PHASE_RELEASE = 2 !< |
---|
308 | |
---|
309 | SAVE |
---|
310 | |
---|
311 | PRIVATE |
---|
312 | |
---|
313 | PUBLIC lpm_parin, & |
---|
314 | lpm_header, & |
---|
315 | lpm_init_arrays,& |
---|
316 | lpm_init, & |
---|
317 | lpm_actions, & |
---|
318 | lpm_data_output_ptseries, & |
---|
319 | lpm_interaction_droplets_ptq, & |
---|
320 | lpm_rrd_local_particles, & |
---|
321 | lpm_wrd_local, & |
---|
322 | lpm_rrd_global, & |
---|
323 | lpm_wrd_global, & |
---|
324 | lpm_rrd_local, & |
---|
325 | lpm_check_parameters |
---|
326 | |
---|
327 | PUBLIC lagrangian_particle_model |
---|
328 | |
---|
329 | INTERFACE lpm_check_parameters |
---|
330 | MODULE PROCEDURE lpm_check_parameters |
---|
331 | END INTERFACE lpm_check_parameters |
---|
332 | |
---|
333 | INTERFACE lpm_parin |
---|
334 | MODULE PROCEDURE lpm_parin |
---|
335 | END INTERFACE lpm_parin |
---|
336 | |
---|
337 | INTERFACE lpm_header |
---|
338 | MODULE PROCEDURE lpm_header |
---|
339 | END INTERFACE lpm_header |
---|
340 | |
---|
341 | INTERFACE lpm_init_arrays |
---|
342 | MODULE PROCEDURE lpm_init_arrays |
---|
343 | END INTERFACE lpm_init_arrays |
---|
344 | |
---|
345 | INTERFACE lpm_init |
---|
346 | MODULE PROCEDURE lpm_init |
---|
347 | END INTERFACE lpm_init |
---|
348 | |
---|
349 | INTERFACE lpm_actions |
---|
350 | MODULE PROCEDURE lpm_actions |
---|
351 | END INTERFACE lpm_actions |
---|
352 | |
---|
353 | INTERFACE lpm_data_output_ptseries |
---|
354 | MODULE PROCEDURE lpm_data_output_ptseries |
---|
355 | END INTERFACE |
---|
356 | |
---|
357 | INTERFACE lpm_rrd_local_particles |
---|
358 | MODULE PROCEDURE lpm_rrd_local_particles |
---|
359 | END INTERFACE lpm_rrd_local_particles |
---|
360 | |
---|
361 | INTERFACE lpm_rrd_global |
---|
362 | MODULE PROCEDURE lpm_rrd_global |
---|
363 | END INTERFACE lpm_rrd_global |
---|
364 | |
---|
365 | INTERFACE lpm_rrd_local |
---|
366 | MODULE PROCEDURE lpm_rrd_local |
---|
367 | END INTERFACE lpm_rrd_local |
---|
368 | |
---|
369 | INTERFACE lpm_wrd_local |
---|
370 | MODULE PROCEDURE lpm_wrd_local |
---|
371 | END INTERFACE lpm_wrd_local |
---|
372 | |
---|
373 | INTERFACE lpm_wrd_global |
---|
374 | MODULE PROCEDURE lpm_wrd_global |
---|
375 | END INTERFACE lpm_wrd_global |
---|
376 | |
---|
377 | INTERFACE lpm_advec |
---|
378 | MODULE PROCEDURE lpm_advec |
---|
379 | END INTERFACE lpm_advec |
---|
380 | |
---|
381 | INTERFACE lpm_calc_liquid_water_content |
---|
382 | MODULE PROCEDURE lpm_calc_liquid_water_content |
---|
383 | END INTERFACE |
---|
384 | |
---|
385 | INTERFACE lpm_interaction_droplets_ptq |
---|
386 | MODULE PROCEDURE lpm_interaction_droplets_ptq |
---|
387 | MODULE PROCEDURE lpm_interaction_droplets_ptq_ij |
---|
388 | END INTERFACE lpm_interaction_droplets_ptq |
---|
389 | |
---|
390 | INTERFACE lpm_boundary_conds |
---|
391 | MODULE PROCEDURE lpm_boundary_conds |
---|
392 | END INTERFACE lpm_boundary_conds |
---|
393 | |
---|
394 | INTERFACE lpm_droplet_condensation |
---|
395 | MODULE PROCEDURE lpm_droplet_condensation |
---|
396 | END INTERFACE |
---|
397 | |
---|
398 | INTERFACE lpm_droplet_collision |
---|
399 | MODULE PROCEDURE lpm_droplet_collision |
---|
400 | END INTERFACE lpm_droplet_collision |
---|
401 | |
---|
402 | INTERFACE lpm_init_kernels |
---|
403 | MODULE PROCEDURE lpm_init_kernels |
---|
404 | END INTERFACE lpm_init_kernels |
---|
405 | |
---|
406 | INTERFACE lpm_splitting |
---|
407 | MODULE PROCEDURE lpm_splitting |
---|
408 | END INTERFACE lpm_splitting |
---|
409 | |
---|
410 | INTERFACE lpm_merging |
---|
411 | MODULE PROCEDURE lpm_merging |
---|
412 | END INTERFACE lpm_merging |
---|
413 | |
---|
414 | INTERFACE lpm_exchange_horiz |
---|
415 | MODULE PROCEDURE lpm_exchange_horiz |
---|
416 | END INTERFACE lpm_exchange_horiz |
---|
417 | |
---|
418 | INTERFACE lpm_move_particle |
---|
419 | MODULE PROCEDURE lpm_move_particle |
---|
420 | END INTERFACE lpm_move_particle |
---|
421 | |
---|
422 | INTERFACE realloc_particles_array |
---|
423 | MODULE PROCEDURE realloc_particles_array |
---|
424 | END INTERFACE realloc_particles_array |
---|
425 | |
---|
426 | INTERFACE dealloc_particles_array |
---|
427 | MODULE PROCEDURE dealloc_particles_array |
---|
428 | END INTERFACE dealloc_particles_array |
---|
429 | |
---|
430 | INTERFACE lpm_sort_and_delete |
---|
431 | MODULE PROCEDURE lpm_sort_and_delete |
---|
432 | END INTERFACE lpm_sort_and_delete |
---|
433 | |
---|
434 | INTERFACE lpm_sort_timeloop_done |
---|
435 | MODULE PROCEDURE lpm_sort_timeloop_done |
---|
436 | END INTERFACE lpm_sort_timeloop_done |
---|
437 | |
---|
438 | INTERFACE lpm_pack |
---|
439 | MODULE PROCEDURE lpm_pack |
---|
440 | END INTERFACE lpm_pack |
---|
441 | |
---|
442 | CONTAINS |
---|
443 | |
---|
444 | |
---|
445 | !------------------------------------------------------------------------------! |
---|
446 | ! Description: |
---|
447 | ! ------------ |
---|
448 | !> Parin for &particle_parameters for the Lagrangian particle model |
---|
449 | !------------------------------------------------------------------------------! |
---|
450 | SUBROUTINE lpm_parin |
---|
451 | |
---|
452 | CHARACTER (LEN=80) :: line !< |
---|
453 | |
---|
454 | NAMELIST /particles_par/ & |
---|
455 | aero_species, & |
---|
456 | aero_type, & |
---|
457 | aero_weight, & |
---|
458 | alloc_factor, & |
---|
459 | bc_par_b, & |
---|
460 | bc_par_lr, & |
---|
461 | bc_par_ns, & |
---|
462 | bc_par_t, & |
---|
463 | collision_kernel, & |
---|
464 | curvature_solution_effects, & |
---|
465 | deallocate_memory, & |
---|
466 | density_ratio, & |
---|
467 | dissipation_classes, & |
---|
468 | dt_dopts, & |
---|
469 | dt_min_part, & |
---|
470 | dt_prel, & |
---|
471 | dt_write_particle_data, & |
---|
472 | end_time_prel, & |
---|
473 | initial_weighting_factor, & |
---|
474 | log_sigma, & |
---|
475 | max_number_particles_per_gridbox, & |
---|
476 | merging, & |
---|
477 | na, & |
---|
478 | number_concentration, & |
---|
479 | number_of_particle_groups, & |
---|
480 | number_particles_per_gridbox, & |
---|
481 | particles_per_point, & |
---|
482 | particle_advection_start, & |
---|
483 | particle_advection_interpolation, & |
---|
484 | particle_maximum_age, & |
---|
485 | pdx, & |
---|
486 | pdy, & |
---|
487 | pdz, & |
---|
488 | psb, & |
---|
489 | psl, & |
---|
490 | psn, & |
---|
491 | psr, & |
---|
492 | pss, & |
---|
493 | pst, & |
---|
494 | radius, & |
---|
495 | radius_classes, & |
---|
496 | radius_merge, & |
---|
497 | radius_split, & |
---|
498 | random_start_position, & |
---|
499 | read_particles_from_restartfile, & |
---|
500 | rm, & |
---|
501 | seed_follows_topography, & |
---|
502 | splitting, & |
---|
503 | splitting_factor, & |
---|
504 | splitting_factor_max, & |
---|
505 | splitting_function, & |
---|
506 | splitting_mode, & |
---|
507 | step_dealloc, & |
---|
508 | use_sgs_for_particles, & |
---|
509 | vertical_particle_advection, & |
---|
510 | weight_factor_merge, & |
---|
511 | weight_factor_split, & |
---|
512 | write_particle_statistics |
---|
513 | |
---|
514 | NAMELIST /particle_parameters/ & |
---|
515 | aero_species, & |
---|
516 | aero_type, & |
---|
517 | aero_weight, & |
---|
518 | alloc_factor, & |
---|
519 | bc_par_b, & |
---|
520 | bc_par_lr, & |
---|
521 | bc_par_ns, & |
---|
522 | bc_par_t, & |
---|
523 | collision_kernel, & |
---|
524 | curvature_solution_effects, & |
---|
525 | deallocate_memory, & |
---|
526 | density_ratio, & |
---|
527 | dissipation_classes, & |
---|
528 | dt_dopts, & |
---|
529 | dt_min_part, & |
---|
530 | dt_prel, & |
---|
531 | dt_write_particle_data, & |
---|
532 | end_time_prel, & |
---|
533 | initial_weighting_factor, & |
---|
534 | log_sigma, & |
---|
535 | max_number_particles_per_gridbox, & |
---|
536 | merging, & |
---|
537 | na, & |
---|
538 | number_concentration, & |
---|
539 | number_of_particle_groups, & |
---|
540 | number_particles_per_gridbox, & |
---|
541 | particles_per_point, & |
---|
542 | particle_advection_start, & |
---|
543 | particle_advection_interpolation, & |
---|
544 | particle_maximum_age, & |
---|
545 | pdx, & |
---|
546 | pdy, & |
---|
547 | pdz, & |
---|
548 | psb, & |
---|
549 | psl, & |
---|
550 | psn, & |
---|
551 | psr, & |
---|
552 | pss, & |
---|
553 | pst, & |
---|
554 | radius, & |
---|
555 | radius_classes, & |
---|
556 | radius_merge, & |
---|
557 | radius_split, & |
---|
558 | random_start_position, & |
---|
559 | read_particles_from_restartfile, & |
---|
560 | rm, & |
---|
561 | seed_follows_topography, & |
---|
562 | splitting, & |
---|
563 | splitting_factor, & |
---|
564 | splitting_factor_max, & |
---|
565 | splitting_function, & |
---|
566 | splitting_mode, & |
---|
567 | step_dealloc, & |
---|
568 | use_sgs_for_particles, & |
---|
569 | vertical_particle_advection, & |
---|
570 | weight_factor_merge, & |
---|
571 | weight_factor_split, & |
---|
572 | write_particle_statistics |
---|
573 | |
---|
574 | ! |
---|
575 | !-- Position the namelist-file at the beginning (it was already opened in |
---|
576 | !-- parin), search for the namelist-group of the package and position the |
---|
577 | !-- file at this line. Do the same for each optionally used package. |
---|
578 | line = ' ' |
---|
579 | |
---|
580 | ! |
---|
581 | !-- Try to find particles package |
---|
582 | REWIND ( 11 ) |
---|
583 | line = ' ' |
---|
584 | DO WHILE ( INDEX( line, '&particle_parameters' ) == 0 ) |
---|
585 | READ ( 11, '(A)', END=12 ) line |
---|
586 | ENDDO |
---|
587 | BACKSPACE ( 11 ) |
---|
588 | ! |
---|
589 | !-- Read user-defined namelist |
---|
590 | READ ( 11, particle_parameters, ERR = 10 ) |
---|
591 | ! |
---|
592 | !-- Set flag that indicates that particles are switched on |
---|
593 | particle_advection = .TRUE. |
---|
594 | |
---|
595 | GOTO 14 |
---|
596 | |
---|
597 | 10 BACKSPACE( 11 ) |
---|
598 | READ( 11 , '(A)') line |
---|
599 | CALL parin_fail_message( 'particle_parameters', line ) |
---|
600 | ! |
---|
601 | !-- Try to find particles package (old namelist) |
---|
602 | 12 REWIND ( 11 ) |
---|
603 | line = ' ' |
---|
604 | DO WHILE ( INDEX( line, '&particles_par' ) == 0 ) |
---|
605 | READ ( 11, '(A)', END=14 ) line |
---|
606 | ENDDO |
---|
607 | BACKSPACE ( 11 ) |
---|
608 | ! |
---|
609 | !-- Read user-defined namelist |
---|
610 | READ ( 11, particles_par, ERR = 13, END = 14 ) |
---|
611 | |
---|
612 | message_string = 'namelist particles_par is deprecated and will be ' // & |
---|
613 | 'removed in near future. Please use namelist ' // & |
---|
614 | 'particle_parameters instead' |
---|
615 | CALL message( 'package_parin', 'PA0487', 0, 1, 0, 6, 0 ) |
---|
616 | |
---|
617 | ! |
---|
618 | !-- Set flag that indicates that particles are switched on |
---|
619 | particle_advection = .TRUE. |
---|
620 | |
---|
621 | GOTO 14 |
---|
622 | |
---|
623 | 13 BACKSPACE( 11 ) |
---|
624 | READ( 11 , '(A)') line |
---|
625 | CALL parin_fail_message( 'particles_par', line ) |
---|
626 | |
---|
627 | 14 CONTINUE |
---|
628 | |
---|
629 | END SUBROUTINE lpm_parin |
---|
630 | |
---|
631 | !------------------------------------------------------------------------------! |
---|
632 | ! Description: |
---|
633 | ! ------------ |
---|
634 | !> Writes used particle attributes in header file. |
---|
635 | !------------------------------------------------------------------------------! |
---|
636 | SUBROUTINE lpm_header ( io ) |
---|
637 | |
---|
638 | CHARACTER (LEN=40) :: output_format !< netcdf format |
---|
639 | |
---|
640 | INTEGER(iwp) :: i !< |
---|
641 | INTEGER(iwp), INTENT(IN) :: io !< Unit of the output file |
---|
642 | |
---|
643 | |
---|
644 | IF ( humidity .AND. cloud_droplets ) THEN |
---|
645 | WRITE ( io, 433 ) |
---|
646 | IF ( curvature_solution_effects ) WRITE ( io, 434 ) |
---|
647 | IF ( collision_kernel /= 'none' ) THEN |
---|
648 | WRITE ( io, 435 ) TRIM( collision_kernel ) |
---|
649 | IF ( collision_kernel(6:9) == 'fast' ) THEN |
---|
650 | WRITE ( io, 436 ) radius_classes, dissipation_classes |
---|
651 | ENDIF |
---|
652 | ELSE |
---|
653 | WRITE ( io, 437 ) |
---|
654 | ENDIF |
---|
655 | ENDIF |
---|
656 | |
---|
657 | IF ( particle_advection ) THEN |
---|
658 | ! |
---|
659 | !-- Particle attributes |
---|
660 | WRITE ( io, 480 ) particle_advection_start, TRIM(particle_advection_interpolation), & |
---|
661 | dt_prel, bc_par_lr, & |
---|
662 | bc_par_ns, bc_par_b, bc_par_t, particle_maximum_age, & |
---|
663 | end_time_prel |
---|
664 | IF ( use_sgs_for_particles ) WRITE ( io, 488 ) dt_min_part |
---|
665 | IF ( random_start_position ) WRITE ( io, 481 ) |
---|
666 | IF ( seed_follows_topography ) WRITE ( io, 496 ) |
---|
667 | IF ( particles_per_point > 1 ) WRITE ( io, 489 ) particles_per_point |
---|
668 | WRITE ( io, 495 ) total_number_of_particles |
---|
669 | IF ( dt_write_particle_data /= 9999999.9_wp ) THEN |
---|
670 | WRITE ( io, 485 ) dt_write_particle_data |
---|
671 | IF ( netcdf_data_format > 1 ) THEN |
---|
672 | output_format = 'netcdf (64 bit offset) and binary' |
---|
673 | ELSE |
---|
674 | output_format = 'netcdf and binary' |
---|
675 | ENDIF |
---|
676 | IF ( netcdf_deflate == 0 ) THEN |
---|
677 | WRITE ( io, 344 ) output_format |
---|
678 | ELSE |
---|
679 | WRITE ( io, 354 ) TRIM( output_format ), netcdf_deflate |
---|
680 | ENDIF |
---|
681 | ENDIF |
---|
682 | IF ( dt_dopts /= 9999999.9_wp ) WRITE ( io, 494 ) dt_dopts |
---|
683 | IF ( write_particle_statistics ) WRITE ( io, 486 ) |
---|
684 | |
---|
685 | WRITE ( io, 487 ) number_of_particle_groups |
---|
686 | |
---|
687 | DO i = 1, number_of_particle_groups |
---|
688 | IF ( i == 1 .AND. density_ratio(i) == 9999999.9_wp ) THEN |
---|
689 | WRITE ( io, 490 ) i, 0.0_wp |
---|
690 | WRITE ( io, 492 ) |
---|
691 | ELSE |
---|
692 | WRITE ( io, 490 ) i, radius(i) |
---|
693 | IF ( density_ratio(i) /= 0.0_wp ) THEN |
---|
694 | WRITE ( io, 491 ) density_ratio(i) |
---|
695 | ELSE |
---|
696 | WRITE ( io, 492 ) |
---|
697 | ENDIF |
---|
698 | ENDIF |
---|
699 | WRITE ( io, 493 ) psl(i), psr(i), pss(i), psn(i), psb(i), pst(i), & |
---|
700 | pdx(i), pdy(i), pdz(i) |
---|
701 | IF ( .NOT. vertical_particle_advection(i) ) WRITE ( io, 482 ) |
---|
702 | ENDDO |
---|
703 | |
---|
704 | ENDIF |
---|
705 | |
---|
706 | 344 FORMAT (' Output format: ',A/) |
---|
707 | 354 FORMAT (' Output format: ',A, ' compressed with level: ',I1/) |
---|
708 | |
---|
709 | 433 FORMAT (' Cloud droplets treated explicitly using the Lagrangian part', & |
---|
710 | 'icle model') |
---|
711 | 434 FORMAT (' Curvature and solution effecs are considered for growth of', & |
---|
712 | ' droplets < 1.0E-6 m') |
---|
713 | 435 FORMAT (' Droplet collision is handled by ',A,'-kernel') |
---|
714 | 436 FORMAT (' Fast kernel with fixed radius- and dissipation classes ', & |
---|
715 | 'are used'/ & |
---|
716 | ' number of radius classes: ',I3,' interval ', & |
---|
717 | '[1.0E-6,2.0E-4] m'/ & |
---|
718 | ' number of dissipation classes: ',I2,' interval ', & |
---|
719 | '[0,1000] cm**2/s**3') |
---|
720 | 437 FORMAT (' Droplet collision is switched off') |
---|
721 | |
---|
722 | 480 FORMAT (' Particles:'/ & |
---|
723 | ' ---------'// & |
---|
724 | ' Particle advection is active (switched on at t = ', F7.1, & |
---|
725 | ' s)'/ & |
---|
726 | ' Interpolation of particle velocities is done by using ', A, & |
---|
727 | ' method'/ & |
---|
728 | ' Start of new particle generations every ',F6.1,' s'/ & |
---|
729 | ' Boundary conditions: left/right: ', A, ' north/south: ', A/& |
---|
730 | ' bottom: ', A, ' top: ', A/& |
---|
731 | ' Maximum particle age: ',F9.1,' s'/ & |
---|
732 | ' Advection stopped at t = ',F9.1,' s'/) |
---|
733 | 481 FORMAT (' Particles have random start positions'/) |
---|
734 | 482 FORMAT (' Particles are advected only horizontally'/) |
---|
735 | 485 FORMAT (' Particle data are written on file every ', F9.1, ' s') |
---|
736 | 486 FORMAT (' Particle statistics are written on file'/) |
---|
737 | 487 FORMAT (' Number of particle groups: ',I2/) |
---|
738 | 488 FORMAT (' SGS velocity components are used for particle advection'/ & |
---|
739 | ' minimum timestep for advection:', F8.5/) |
---|
740 | 489 FORMAT (' Number of particles simultaneously released at each ', & |
---|
741 | 'point: ', I5/) |
---|
742 | 490 FORMAT (' Particle group ',I2,':'/ & |
---|
743 | ' Particle radius: ',E10.3, 'm') |
---|
744 | 491 FORMAT (' Particle inertia is activated'/ & |
---|
745 | ' density_ratio (rho_fluid/rho_particle) =',F6.3/) |
---|
746 | 492 FORMAT (' Particles are advected only passively (no inertia)'/) |
---|
747 | 493 FORMAT (' Boundaries of particle source: x:',F8.1,' - ',F8.1,' m'/& |
---|
748 | ' y:',F8.1,' - ',F8.1,' m'/& |
---|
749 | ' z:',F8.1,' - ',F8.1,' m'/& |
---|
750 | ' Particle distances: dx = ',F8.1,' m dy = ',F8.1, & |
---|
751 | ' m dz = ',F8.1,' m'/) |
---|
752 | 494 FORMAT (' Output of particle time series in NetCDF format every ', & |
---|
753 | F8.2,' s'/) |
---|
754 | 495 FORMAT (' Number of particles in total domain: ',I10/) |
---|
755 | 496 FORMAT (' Initial vertical particle positions are interpreted ', & |
---|
756 | 'as relative to the given topography') |
---|
757 | |
---|
758 | END SUBROUTINE lpm_header |
---|
759 | |
---|
760 | !------------------------------------------------------------------------------! |
---|
761 | ! Description: |
---|
762 | ! ------------ |
---|
763 | !> Writes used particle attributes in header file. |
---|
764 | !------------------------------------------------------------------------------! |
---|
765 | SUBROUTINE lpm_check_parameters |
---|
766 | |
---|
767 | ! |
---|
768 | !-- Collision kernels: |
---|
769 | SELECT CASE ( TRIM( collision_kernel ) ) |
---|
770 | |
---|
771 | CASE ( 'hall', 'hall_fast' ) |
---|
772 | hall_kernel = .TRUE. |
---|
773 | |
---|
774 | CASE ( 'wang', 'wang_fast' ) |
---|
775 | wang_kernel = .TRUE. |
---|
776 | |
---|
777 | CASE ( 'none' ) |
---|
778 | |
---|
779 | |
---|
780 | CASE DEFAULT |
---|
781 | message_string = 'unknown collision kernel: collision_kernel = "' // & |
---|
782 | TRIM( collision_kernel ) // '"' |
---|
783 | CALL message( 'lpm_check_parameters', 'PA0350', 1, 2, 0, 6, 0 ) |
---|
784 | |
---|
785 | END SELECT |
---|
786 | IF ( collision_kernel(6:9) == 'fast' ) use_kernel_tables = .TRUE. |
---|
787 | |
---|
788 | ! |
---|
789 | !-- Subgrid scale velocites with the simple interpolation method for resolved |
---|
790 | !-- velocites is not implemented for passive particles. However, for cloud |
---|
791 | !-- it can be combined as the sgs-velocites for active particles are |
---|
792 | !-- calculated differently, i.e. no subboxes are needed. |
---|
793 | IF ( .NOT. TRIM( particle_advection_interpolation ) == 'trilinear' .AND. & |
---|
794 | use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
795 | message_string = 'subrgrid scale velocities in combination with ' // & |
---|
796 | 'simple interpolation method is not ' // & |
---|
797 | 'implemented' |
---|
798 | CALL message( 'lpm_check_parameters', 'PA0659', 1, 2, 0, 6, 0 ) |
---|
799 | ENDIF |
---|
800 | |
---|
801 | IF ( nested_run .AND. cloud_droplets ) THEN |
---|
802 | message_string = 'nested runs in combination with cloud droplets ' // & |
---|
803 | 'is not implemented' |
---|
804 | CALL message( 'lpm_check_parameters', 'PA0687', 1, 2, 0, 6, 0 ) |
---|
805 | ENDIF |
---|
806 | |
---|
807 | |
---|
808 | END SUBROUTINE lpm_check_parameters |
---|
809 | |
---|
810 | !------------------------------------------------------------------------------! |
---|
811 | ! Description: |
---|
812 | ! ------------ |
---|
813 | !> Initialize arrays for lpm |
---|
814 | !------------------------------------------------------------------------------! |
---|
815 | SUBROUTINE lpm_init_arrays |
---|
816 | |
---|
817 | IF ( cloud_droplets ) THEN |
---|
818 | ! |
---|
819 | !-- Liquid water content, change in liquid water content |
---|
820 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
821 | ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
822 | ! |
---|
823 | !-- Real volume of particles (with weighting), volume of particles |
---|
824 | ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
825 | ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
826 | ENDIF |
---|
827 | |
---|
828 | |
---|
829 | ALLOCATE( u_t(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
830 | v_t(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
831 | w_t(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
832 | ! |
---|
833 | !-- Initialize values with current time step |
---|
834 | u_t = u |
---|
835 | v_t = v |
---|
836 | w_t = w |
---|
837 | ! |
---|
838 | !-- Initial assignment of the pointers |
---|
839 | IF ( cloud_droplets ) THEN |
---|
840 | ql => ql_1 |
---|
841 | ql_c => ql_2 |
---|
842 | ENDIF |
---|
843 | |
---|
844 | END SUBROUTINE lpm_init_arrays |
---|
845 | |
---|
846 | !------------------------------------------------------------------------------! |
---|
847 | ! Description: |
---|
848 | ! ------------ |
---|
849 | !> Initialize Lagrangian particle model |
---|
850 | !------------------------------------------------------------------------------! |
---|
851 | SUBROUTINE lpm_init |
---|
852 | |
---|
853 | INTEGER(iwp) :: i !< |
---|
854 | INTEGER(iwp) :: j !< |
---|
855 | INTEGER(iwp) :: k !< |
---|
856 | |
---|
857 | REAL(wp) :: div !< |
---|
858 | REAL(wp) :: height_int !< |
---|
859 | REAL(wp) :: height_p !< |
---|
860 | REAL(wp) :: z_p !< |
---|
861 | REAL(wp) :: z0_av_local !< |
---|
862 | |
---|
863 | ! |
---|
864 | !-- In case of oceans runs, the vertical index calculations need an offset, |
---|
865 | !-- because otherwise the k indices will become negative |
---|
866 | IF ( ocean_mode ) THEN |
---|
867 | offset_ocean_nzt = nzt |
---|
868 | offset_ocean_nzt_m1 = nzt - 1 |
---|
869 | ENDIF |
---|
870 | |
---|
871 | ! |
---|
872 | !-- Define block offsets for dividing a gridcell in 8 sub cells |
---|
873 | !-- See documentation for List of subgrid boxes |
---|
874 | !-- See pack_and_sort in lpm_pack_arrays.f90 for assignment of the subgrid boxes |
---|
875 | block_offset(0) = block_offset_def ( 0, 0, 0) |
---|
876 | block_offset(1) = block_offset_def ( 0, 0,-1) |
---|
877 | block_offset(2) = block_offset_def ( 0,-1, 0) |
---|
878 | block_offset(3) = block_offset_def ( 0,-1,-1) |
---|
879 | block_offset(4) = block_offset_def (-1, 0, 0) |
---|
880 | block_offset(5) = block_offset_def (-1, 0,-1) |
---|
881 | block_offset(6) = block_offset_def (-1,-1, 0) |
---|
882 | block_offset(7) = block_offset_def (-1,-1,-1) |
---|
883 | ! |
---|
884 | !-- Check the number of particle groups. |
---|
885 | IF ( number_of_particle_groups > max_number_of_particle_groups ) THEN |
---|
886 | WRITE( message_string, * ) 'max_number_of_particle_groups =', & |
---|
887 | max_number_of_particle_groups , & |
---|
888 | '&number_of_particle_groups reset to ', & |
---|
889 | max_number_of_particle_groups |
---|
890 | CALL message( 'lpm_init', 'PA0213', 0, 1, 0, 6, 0 ) |
---|
891 | number_of_particle_groups = max_number_of_particle_groups |
---|
892 | ENDIF |
---|
893 | ! |
---|
894 | !-- Check if downward-facing walls exist. This case, reflection boundary |
---|
895 | !-- conditions (as well as subgrid-scale velocities) may do not work |
---|
896 | !-- propably (not realized so far). |
---|
897 | IF ( surf_def_h(1)%ns >= 1 ) THEN |
---|
898 | WRITE( message_string, * ) 'Overhanging topography do not work '// & |
---|
899 | 'with particles' |
---|
900 | CALL message( 'lpm_init', 'PA0212', 0, 1, 0, 6, 0 ) |
---|
901 | |
---|
902 | ENDIF |
---|
903 | |
---|
904 | ! |
---|
905 | !-- Set default start positions, if necessary |
---|
906 | IF ( psl(1) == 9999999.9_wp ) psl(1) = 0.0_wp |
---|
907 | IF ( psr(1) == 9999999.9_wp ) psr(1) = ( nx +1 ) * dx |
---|
908 | IF ( pss(1) == 9999999.9_wp ) pss(1) = 0.0_wp |
---|
909 | IF ( psn(1) == 9999999.9_wp ) psn(1) = ( ny +1 ) * dy |
---|
910 | IF ( psb(1) == 9999999.9_wp ) psb(1) = zu(nz/2) |
---|
911 | IF ( pst(1) == 9999999.9_wp ) pst(1) = psb(1) |
---|
912 | |
---|
913 | IF ( pdx(1) == 9999999.9_wp .OR. pdx(1) == 0.0_wp ) pdx(1) = dx |
---|
914 | IF ( pdy(1) == 9999999.9_wp .OR. pdy(1) == 0.0_wp ) pdy(1) = dy |
---|
915 | IF ( pdz(1) == 9999999.9_wp .OR. pdz(1) == 0.0_wp ) pdz(1) = zu(2) - zu(1) |
---|
916 | |
---|
917 | ! |
---|
918 | !-- If number_particles_per_gridbox is set, the parametres pdx, pdy and pdz are |
---|
919 | !-- calculated diagnostically. Therfore an isotropic distribution is prescribed. |
---|
920 | IF ( number_particles_per_gridbox /= -1 .AND. & |
---|
921 | number_particles_per_gridbox >= 1 ) THEN |
---|
922 | pdx(1) = (( dx * dy * ( zu(2) - zu(1) ) ) / & |
---|
923 | REAL(number_particles_per_gridbox))**0.3333333_wp |
---|
924 | ! |
---|
925 | !-- Ensure a smooth value (two significant digits) of distance between |
---|
926 | !-- particles (pdx, pdy, pdz). |
---|
927 | div = 1000.0_wp |
---|
928 | DO WHILE ( pdx(1) < div ) |
---|
929 | div = div / 10.0_wp |
---|
930 | ENDDO |
---|
931 | pdx(1) = NINT( pdx(1) * 100.0_wp / div ) * div / 100.0_wp |
---|
932 | pdy(1) = pdx(1) |
---|
933 | pdz(1) = pdx(1) |
---|
934 | |
---|
935 | ENDIF |
---|
936 | |
---|
937 | DO j = 2, number_of_particle_groups |
---|
938 | IF ( psl(j) == 9999999.9_wp ) psl(j) = psl(j-1) |
---|
939 | IF ( psr(j) == 9999999.9_wp ) psr(j) = psr(j-1) |
---|
940 | IF ( pss(j) == 9999999.9_wp ) pss(j) = pss(j-1) |
---|
941 | IF ( psn(j) == 9999999.9_wp ) psn(j) = psn(j-1) |
---|
942 | IF ( psb(j) == 9999999.9_wp ) psb(j) = psb(j-1) |
---|
943 | IF ( pst(j) == 9999999.9_wp ) pst(j) = pst(j-1) |
---|
944 | IF ( pdx(j) == 9999999.9_wp .OR. pdx(j) == 0.0_wp ) pdx(j) = pdx(j-1) |
---|
945 | IF ( pdy(j) == 9999999.9_wp .OR. pdy(j) == 0.0_wp ) pdy(j) = pdy(j-1) |
---|
946 | IF ( pdz(j) == 9999999.9_wp .OR. pdz(j) == 0.0_wp ) pdz(j) = pdz(j-1) |
---|
947 | ENDDO |
---|
948 | |
---|
949 | ! |
---|
950 | !-- Allocate arrays required for calculating particle SGS velocities. |
---|
951 | !-- Initialize prefactor required for stoachastic Weil equation. |
---|
952 | IF ( use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
953 | ALLOCATE( de_dx(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
954 | de_dy(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
955 | de_dz(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
956 | |
---|
957 | de_dx = 0.0_wp |
---|
958 | de_dy = 0.0_wp |
---|
959 | de_dz = 0.0_wp |
---|
960 | |
---|
961 | sgs_wf_part = 1.0_wp / 3.0_wp |
---|
962 | ENDIF |
---|
963 | |
---|
964 | ! |
---|
965 | !-- Allocate array required for logarithmic vertical interpolation of |
---|
966 | !-- horizontal particle velocities between the surface and the first vertical |
---|
967 | !-- grid level. In order to avoid repeated CPU cost-intensive CALLS of |
---|
968 | !-- intrinsic FORTRAN procedure LOG(z/z0), LOG(z/z0) is precalculated for |
---|
969 | !-- several heights. Splitting into 20 sublayers turned out to be sufficient. |
---|
970 | !-- To obtain exact height levels of particles, linear interpolation is applied |
---|
971 | !-- (see lpm_advec.f90). |
---|
972 | IF ( constant_flux_layer ) THEN |
---|
973 | |
---|
974 | ALLOCATE ( log_z_z0(0:number_of_sublayers) ) |
---|
975 | z_p = zu(nzb+1) - zw(nzb) |
---|
976 | |
---|
977 | ! |
---|
978 | !-- Calculate horizontal mean value of z0 used for logartihmic |
---|
979 | !-- interpolation. Note: this is not exact for heterogeneous z0. |
---|
980 | !-- However, sensitivity studies showed that the effect is |
---|
981 | !-- negligible. |
---|
982 | z0_av_local = SUM( surf_def_h(0)%z0 ) + SUM( surf_lsm_h%z0 ) + & |
---|
983 | SUM( surf_usm_h%z0 ) |
---|
984 | z0_av_global = 0.0_wp |
---|
985 | |
---|
986 | #if defined( __parallel ) |
---|
987 | CALL MPI_ALLREDUCE(z0_av_local, z0_av_global, 1, MPI_REAL, MPI_SUM, & |
---|
988 | comm2d, ierr ) |
---|
989 | #else |
---|
990 | z0_av_global = z0_av_local |
---|
991 | #endif |
---|
992 | |
---|
993 | z0_av_global = z0_av_global / ( ( ny + 1 ) * ( nx + 1 ) ) |
---|
994 | ! |
---|
995 | !-- Horizontal wind speed is zero below and at z0 |
---|
996 | log_z_z0(0) = 0.0_wp |
---|
997 | ! |
---|
998 | !-- Calculate vertical depth of the sublayers |
---|
999 | height_int = ( z_p - z0_av_global ) / REAL( number_of_sublayers, KIND=wp ) |
---|
1000 | ! |
---|
1001 | !-- Precalculate LOG(z/z0) |
---|
1002 | height_p = z0_av_global |
---|
1003 | DO k = 1, number_of_sublayers |
---|
1004 | |
---|
1005 | height_p = height_p + height_int |
---|
1006 | log_z_z0(k) = LOG( height_p / z0_av_global ) |
---|
1007 | |
---|
1008 | ENDDO |
---|
1009 | |
---|
1010 | ENDIF |
---|
1011 | |
---|
1012 | ! |
---|
1013 | !-- Check which particle interpolation method should be used |
---|
1014 | IF ( TRIM( particle_advection_interpolation ) == 'trilinear' ) THEN |
---|
1015 | interpolation_simple_corrector = .FALSE. |
---|
1016 | interpolation_simple_predictor = .FALSE. |
---|
1017 | interpolation_trilinear = .TRUE. |
---|
1018 | ELSEIF ( TRIM( particle_advection_interpolation ) == 'simple_corrector' ) THEN |
---|
1019 | interpolation_simple_corrector = .TRUE. |
---|
1020 | interpolation_simple_predictor = .FALSE. |
---|
1021 | interpolation_trilinear = .FALSE. |
---|
1022 | ELSEIF ( TRIM( particle_advection_interpolation ) == 'simple_predictor' ) THEN |
---|
1023 | interpolation_simple_corrector = .FALSE. |
---|
1024 | interpolation_simple_predictor = .TRUE. |
---|
1025 | interpolation_trilinear = .FALSE. |
---|
1026 | ENDIF |
---|
1027 | |
---|
1028 | ! |
---|
1029 | !-- Check boundary condition and set internal variables |
---|
1030 | SELECT CASE ( bc_par_b ) |
---|
1031 | |
---|
1032 | CASE ( 'absorb' ) |
---|
1033 | ibc_par_b = 1 |
---|
1034 | |
---|
1035 | CASE ( 'reflect' ) |
---|
1036 | ibc_par_b = 2 |
---|
1037 | |
---|
1038 | CASE ( 'reset' ) |
---|
1039 | ibc_par_b = 3 |
---|
1040 | |
---|
1041 | CASE DEFAULT |
---|
1042 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
1043 | 'bc_par_b = "', TRIM( bc_par_b ), '"' |
---|
1044 | CALL message( 'lpm_init', 'PA0217', 1, 2, 0, 6, 0 ) |
---|
1045 | |
---|
1046 | END SELECT |
---|
1047 | SELECT CASE ( bc_par_t ) |
---|
1048 | |
---|
1049 | CASE ( 'absorb' ) |
---|
1050 | ibc_par_t = 1 |
---|
1051 | |
---|
1052 | CASE ( 'reflect' ) |
---|
1053 | ibc_par_t = 2 |
---|
1054 | |
---|
1055 | CASE ( 'nested' ) |
---|
1056 | ibc_par_t = 3 |
---|
1057 | |
---|
1058 | CASE DEFAULT |
---|
1059 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
1060 | 'bc_par_t = "', TRIM( bc_par_t ), '"' |
---|
1061 | CALL message( 'lpm_init', 'PA0218', 1, 2, 0, 6, 0 ) |
---|
1062 | |
---|
1063 | END SELECT |
---|
1064 | SELECT CASE ( bc_par_lr ) |
---|
1065 | |
---|
1066 | CASE ( 'cyclic' ) |
---|
1067 | ibc_par_lr = 0 |
---|
1068 | |
---|
1069 | CASE ( 'absorb' ) |
---|
1070 | ibc_par_lr = 1 |
---|
1071 | |
---|
1072 | CASE ( 'reflect' ) |
---|
1073 | ibc_par_lr = 2 |
---|
1074 | |
---|
1075 | CASE ( 'nested' ) |
---|
1076 | ibc_par_lr = 3 |
---|
1077 | |
---|
1078 | CASE DEFAULT |
---|
1079 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
1080 | 'bc_par_lr = "', TRIM( bc_par_lr ), '"' |
---|
1081 | CALL message( 'lpm_init', 'PA0219', 1, 2, 0, 6, 0 ) |
---|
1082 | |
---|
1083 | END SELECT |
---|
1084 | SELECT CASE ( bc_par_ns ) |
---|
1085 | |
---|
1086 | CASE ( 'cyclic' ) |
---|
1087 | ibc_par_ns = 0 |
---|
1088 | |
---|
1089 | CASE ( 'absorb' ) |
---|
1090 | ibc_par_ns = 1 |
---|
1091 | |
---|
1092 | CASE ( 'reflect' ) |
---|
1093 | ibc_par_ns = 2 |
---|
1094 | |
---|
1095 | CASE ( 'nested' ) |
---|
1096 | ibc_par_ns = 3 |
---|
1097 | |
---|
1098 | CASE DEFAULT |
---|
1099 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
1100 | 'bc_par_ns = "', TRIM( bc_par_ns ), '"' |
---|
1101 | CALL message( 'lpm_init', 'PA0220', 1, 2, 0, 6, 0 ) |
---|
1102 | |
---|
1103 | END SELECT |
---|
1104 | SELECT CASE ( splitting_mode ) |
---|
1105 | |
---|
1106 | CASE ( 'const' ) |
---|
1107 | i_splitting_mode = 1 |
---|
1108 | |
---|
1109 | CASE ( 'cl_av' ) |
---|
1110 | i_splitting_mode = 2 |
---|
1111 | |
---|
1112 | CASE ( 'gb_av' ) |
---|
1113 | i_splitting_mode = 3 |
---|
1114 | |
---|
1115 | CASE DEFAULT |
---|
1116 | WRITE( message_string, * ) 'unknown splitting_mode = "', & |
---|
1117 | TRIM( splitting_mode ), '"' |
---|
1118 | CALL message( 'lpm_init', 'PA0146', 1, 2, 0, 6, 0 ) |
---|
1119 | |
---|
1120 | END SELECT |
---|
1121 | SELECT CASE ( splitting_function ) |
---|
1122 | |
---|
1123 | CASE ( 'gamma' ) |
---|
1124 | isf = 1 |
---|
1125 | |
---|
1126 | CASE ( 'log' ) |
---|
1127 | isf = 2 |
---|
1128 | |
---|
1129 | CASE ( 'exp' ) |
---|
1130 | isf = 3 |
---|
1131 | |
---|
1132 | CASE DEFAULT |
---|
1133 | WRITE( message_string, * ) 'unknown splitting function = "', & |
---|
1134 | TRIM( splitting_function ), '"' |
---|
1135 | CALL message( 'lpm_init', 'PA0147', 1, 2, 0, 6, 0 ) |
---|
1136 | |
---|
1137 | END SELECT |
---|
1138 | ! |
---|
1139 | !-- Initialize collision kernels |
---|
1140 | IF ( collision_kernel /= 'none' ) CALL lpm_init_kernels |
---|
1141 | ! |
---|
1142 | !-- For the first model run of a possible job chain initialize the |
---|
1143 | !-- particles, otherwise read the particle data from restart file. |
---|
1144 | IF ( TRIM( initializing_actions ) == 'read_restart_data' & |
---|
1145 | .AND. read_particles_from_restartfile ) THEN |
---|
1146 | CALL lpm_rrd_local_particles |
---|
1147 | ELSE |
---|
1148 | ! |
---|
1149 | !-- Allocate particle arrays and set attributes of the initial set of |
---|
1150 | !-- particles, which can be also periodically released at later times. |
---|
1151 | ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1152 | grid_particles(nzb+1:nzt,nys:nyn,nxl:nxr) ) |
---|
1153 | |
---|
1154 | number_of_particles = 0 |
---|
1155 | prt_count = 0 |
---|
1156 | ! |
---|
1157 | !-- initialize counter for particle IDs |
---|
1158 | grid_particles%id_counter = 1 |
---|
1159 | ! |
---|
1160 | !-- Initialize all particles with dummy values (otherwise errors may |
---|
1161 | !-- occur within restart runs). The reason for this is still not clear |
---|
1162 | !-- and may be presumably caused by errors in the respective user-interface. |
---|
1163 | zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
1164 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
1165 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
1166 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
1167 | 0, 0, 0_idp, .FALSE., -1 ) |
---|
1168 | |
---|
1169 | particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
1170 | ! |
---|
1171 | !-- Set values for the density ratio and radius for all particle |
---|
1172 | !-- groups, if necessary |
---|
1173 | IF ( density_ratio(1) == 9999999.9_wp ) density_ratio(1) = 0.0_wp |
---|
1174 | IF ( radius(1) == 9999999.9_wp ) radius(1) = 0.0_wp |
---|
1175 | DO i = 2, number_of_particle_groups |
---|
1176 | IF ( density_ratio(i) == 9999999.9_wp ) THEN |
---|
1177 | density_ratio(i) = density_ratio(i-1) |
---|
1178 | ENDIF |
---|
1179 | IF ( radius(i) == 9999999.9_wp ) radius(i) = radius(i-1) |
---|
1180 | ENDDO |
---|
1181 | |
---|
1182 | DO i = 1, number_of_particle_groups |
---|
1183 | IF ( density_ratio(i) /= 0.0_wp .AND. radius(i) == 0 ) THEN |
---|
1184 | WRITE( message_string, * ) 'particle group #', i, ' has a', & |
---|
1185 | 'density ratio /= 0 but radius = 0' |
---|
1186 | CALL message( 'lpm_init', 'PA0215', 1, 2, 0, 6, 0 ) |
---|
1187 | ENDIF |
---|
1188 | particle_groups(i)%density_ratio = density_ratio(i) |
---|
1189 | particle_groups(i)%radius = radius(i) |
---|
1190 | ENDDO |
---|
1191 | ! |
---|
1192 | !-- Set a seed value for the random number generator to be exclusively |
---|
1193 | !-- used for the particle code. The generated random numbers should be |
---|
1194 | !-- different on the different PEs. |
---|
1195 | iran_part = iran_part + myid |
---|
1196 | ! |
---|
1197 | !-- Create the particle set, and set the initial particles |
---|
1198 | CALL lpm_create_particle( phase_init ) |
---|
1199 | last_particle_release_time = particle_advection_start |
---|
1200 | ! |
---|
1201 | !-- User modification of initial particles |
---|
1202 | CALL user_lpm_init |
---|
1203 | ! |
---|
1204 | !-- Open file for statistical informations about particle conditions |
---|
1205 | IF ( write_particle_statistics ) THEN |
---|
1206 | CALL check_open( 80 ) |
---|
1207 | WRITE ( 80, 8000 ) current_timestep_number, simulated_time, & |
---|
1208 | number_of_particles |
---|
1209 | CALL close_file( 80 ) |
---|
1210 | ENDIF |
---|
1211 | |
---|
1212 | ENDIF |
---|
1213 | |
---|
1214 | IF ( nested_run ) CALL pmcp_g_init |
---|
1215 | ! |
---|
1216 | !-- To avoid programm abort, assign particles array to the local version of |
---|
1217 | !-- first grid cell |
---|
1218 | number_of_particles = prt_count(nzb+1,nys,nxl) |
---|
1219 | particles => grid_particles(nzb+1,nys,nxl)%particles(1:number_of_particles) |
---|
1220 | ! |
---|
1221 | !-- Formats |
---|
1222 | 8000 FORMAT (I6,1X,F7.2,4X,I10,71X,I10) |
---|
1223 | |
---|
1224 | END SUBROUTINE lpm_init |
---|
1225 | |
---|
1226 | !------------------------------------------------------------------------------! |
---|
1227 | ! Description: |
---|
1228 | ! ------------ |
---|
1229 | !> Create Lagrangian particles |
---|
1230 | !------------------------------------------------------------------------------! |
---|
1231 | SUBROUTINE lpm_create_particle (phase) |
---|
1232 | |
---|
1233 | INTEGER(iwp) :: alloc_size !< relative increase of allocated memory for particles |
---|
1234 | INTEGER(iwp) :: i !< loop variable ( particle groups ) |
---|
1235 | INTEGER(iwp) :: ip !< index variable along x |
---|
1236 | INTEGER(iwp) :: j !< loop variable ( particles per point ) |
---|
1237 | INTEGER(iwp) :: jp !< index variable along y |
---|
1238 | INTEGER(iwp) :: k !< index variable along z |
---|
1239 | INTEGER(iwp) :: k_surf !< index of surface grid point |
---|
1240 | INTEGER(iwp) :: kp !< index variable along z |
---|
1241 | INTEGER(iwp) :: loop_stride !< loop variable for initialization |
---|
1242 | INTEGER(iwp) :: n !< loop variable ( number of particles ) |
---|
1243 | INTEGER(iwp) :: new_size !< new size of allocated memory for particles |
---|
1244 | |
---|
1245 | INTEGER(iwp), INTENT(IN) :: phase !< mode of inititialization |
---|
1246 | |
---|
1247 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: local_count !< start address of new particle |
---|
1248 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: local_start !< start address of new particle |
---|
1249 | |
---|
1250 | LOGICAL :: first_stride !< flag for initialization |
---|
1251 | |
---|
1252 | REAL(wp) :: pos_x !< increment for particle position in x |
---|
1253 | REAL(wp) :: pos_y !< increment for particle position in y |
---|
1254 | REAL(wp) :: pos_z !< increment for particle position in z |
---|
1255 | REAL(wp) :: rand_contr !< dummy argument for random position |
---|
1256 | |
---|
1257 | TYPE(particle_type),TARGET :: tmp_particle !< temporary particle used for initialization |
---|
1258 | |
---|
1259 | |
---|
1260 | ! |
---|
1261 | !-- Calculate particle positions and store particle attributes, if |
---|
1262 | !-- particle is situated on this PE |
---|
1263 | DO loop_stride = 1, 2 |
---|
1264 | first_stride = (loop_stride == 1) |
---|
1265 | IF ( first_stride ) THEN |
---|
1266 | local_count = 0 ! count number of particles |
---|
1267 | ELSE |
---|
1268 | local_count = prt_count ! Start address of new particles |
---|
1269 | ENDIF |
---|
1270 | |
---|
1271 | ! |
---|
1272 | !-- Calculate initial_weighting_factor diagnostically |
---|
1273 | IF ( number_concentration /= -1.0_wp .AND. number_concentration > 0.0_wp ) THEN |
---|
1274 | initial_weighting_factor = number_concentration * & |
---|
1275 | pdx(1) * pdy(1) * pdz(1) |
---|
1276 | END IF |
---|
1277 | |
---|
1278 | n = 0 |
---|
1279 | DO i = 1, number_of_particle_groups |
---|
1280 | pos_z = psb(i) |
---|
1281 | DO WHILE ( pos_z <= pst(i) ) |
---|
1282 | IF ( pos_z >= zw(0) .AND. pos_z < zw(nzt) ) THEN |
---|
1283 | pos_y = pss(i) |
---|
1284 | DO WHILE ( pos_y <= psn(i) ) |
---|
1285 | IF ( pos_y >= nys * dy .AND. & |
---|
1286 | pos_y < ( nyn + 1 ) * dy ) THEN |
---|
1287 | pos_x = psl(i) |
---|
1288 | xloop: DO WHILE ( pos_x <= psr(i) ) |
---|
1289 | IF ( pos_x >= nxl * dx .AND. & |
---|
1290 | pos_x < ( nxr + 1) * dx ) THEN |
---|
1291 | DO j = 1, particles_per_point |
---|
1292 | n = n + 1 |
---|
1293 | tmp_particle%x = pos_x |
---|
1294 | tmp_particle%y = pos_y |
---|
1295 | tmp_particle%z = pos_z |
---|
1296 | tmp_particle%age = 0.0_wp |
---|
1297 | tmp_particle%age_m = 0.0_wp |
---|
1298 | tmp_particle%dt_sum = 0.0_wp |
---|
1299 | tmp_particle%e_m = 0.0_wp |
---|
1300 | tmp_particle%rvar1 = 0.0_wp |
---|
1301 | tmp_particle%rvar2 = 0.0_wp |
---|
1302 | tmp_particle%rvar3 = 0.0_wp |
---|
1303 | tmp_particle%speed_x = 0.0_wp |
---|
1304 | tmp_particle%speed_y = 0.0_wp |
---|
1305 | tmp_particle%speed_z = 0.0_wp |
---|
1306 | tmp_particle%origin_x = pos_x |
---|
1307 | tmp_particle%origin_y = pos_y |
---|
1308 | tmp_particle%origin_z = pos_z |
---|
1309 | IF ( curvature_solution_effects ) THEN |
---|
1310 | tmp_particle%aux1 = 0.0_wp ! dry aerosol radius |
---|
1311 | tmp_particle%aux2 = dt_3d ! last Rosenbrock timestep |
---|
1312 | ELSE |
---|
1313 | tmp_particle%aux1 = 0.0_wp ! free to use |
---|
1314 | tmp_particle%aux2 = 0.0_wp ! free to use |
---|
1315 | ENDIF |
---|
1316 | tmp_particle%radius = particle_groups(i)%radius |
---|
1317 | tmp_particle%weight_factor = initial_weighting_factor |
---|
1318 | tmp_particle%class = 1 |
---|
1319 | tmp_particle%group = i |
---|
1320 | tmp_particle%id = 0_idp |
---|
1321 | tmp_particle%particle_mask = .TRUE. |
---|
1322 | tmp_particle%block_nr = -1 |
---|
1323 | ! |
---|
1324 | !-- Determine the grid indices of the particle position |
---|
1325 | ip = INT( tmp_particle%x * ddx ) |
---|
1326 | jp = INT( tmp_particle%y * ddy ) |
---|
1327 | ! |
---|
1328 | !-- In case of stretching the actual k index is found iteratively |
---|
1329 | IF ( dz_stretch_level /= -9999999.9_wp .OR. & |
---|
1330 | dz_stretch_level_start(1) /= -9999999.9_wp ) THEN |
---|
1331 | kp = MINLOC( ABS( tmp_particle%z - zu ), DIM = 1 ) - 1 |
---|
1332 | ELSE |
---|
1333 | kp = INT( tmp_particle%z / dz(1) + 1 + offset_ocean_nzt ) |
---|
1334 | ENDIF |
---|
1335 | ! |
---|
1336 | !-- Determine surface level. Therefore, check for |
---|
1337 | !-- upward-facing wall on w-grid. |
---|
1338 | k_surf = topo_top_ind(jp,ip,3) |
---|
1339 | IF ( seed_follows_topography ) THEN |
---|
1340 | ! |
---|
1341 | !-- Particle height is given relative to topography |
---|
1342 | kp = kp + k_surf |
---|
1343 | tmp_particle%z = tmp_particle%z + zw(k_surf) |
---|
1344 | !-- Skip particle release if particle position is |
---|
1345 | !-- above model top, or within topography in case |
---|
1346 | !-- of overhanging structures. |
---|
1347 | IF ( kp > nzt .OR. & |
---|
1348 | .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) ) THEN |
---|
1349 | pos_x = pos_x + pdx(i) |
---|
1350 | CYCLE xloop |
---|
1351 | ENDIF |
---|
1352 | ! |
---|
1353 | !-- Skip particle release if particle position is |
---|
1354 | !-- below surface, or within topography in case |
---|
1355 | !-- of overhanging structures. |
---|
1356 | ELSEIF ( .NOT. seed_follows_topography .AND. & |
---|
1357 | tmp_particle%z <= zw(k_surf) .OR. & |
---|
1358 | .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) )& |
---|
1359 | THEN |
---|
1360 | pos_x = pos_x + pdx(i) |
---|
1361 | CYCLE xloop |
---|
1362 | ENDIF |
---|
1363 | |
---|
1364 | local_count(kp,jp,ip) = local_count(kp,jp,ip) + 1 |
---|
1365 | |
---|
1366 | IF ( .NOT. first_stride ) THEN |
---|
1367 | IF ( ip < nxl .OR. jp < nys .OR. kp < nzb+1 ) THEN |
---|
1368 | write(6,*) 'xl ',ip,jp,kp,nxl,nys,nzb+1 |
---|
1369 | ENDIF |
---|
1370 | IF ( ip > nxr .OR. jp > nyn .OR. kp > nzt ) THEN |
---|
1371 | write(6,*) 'xu ',ip,jp,kp,nxr,nyn,nzt |
---|
1372 | ENDIF |
---|
1373 | grid_particles(kp,jp,ip)%particles(local_count(kp,jp,ip)) = tmp_particle |
---|
1374 | ENDIF |
---|
1375 | ENDDO |
---|
1376 | ENDIF |
---|
1377 | pos_x = pos_x + pdx(i) |
---|
1378 | ENDDO xloop |
---|
1379 | ENDIF |
---|
1380 | pos_y = pos_y + pdy(i) |
---|
1381 | ENDDO |
---|
1382 | ENDIF |
---|
1383 | |
---|
1384 | pos_z = pos_z + pdz(i) |
---|
1385 | ENDDO |
---|
1386 | ENDDO |
---|
1387 | |
---|
1388 | IF ( first_stride ) THEN |
---|
1389 | DO ip = nxl, nxr |
---|
1390 | DO jp = nys, nyn |
---|
1391 | DO kp = nzb+1, nzt |
---|
1392 | IF ( phase == PHASE_INIT ) THEN |
---|
1393 | IF ( local_count(kp,jp,ip) > 0 ) THEN |
---|
1394 | alloc_size = MAX( INT( local_count(kp,jp,ip) * & |
---|
1395 | ( 1.0_wp + alloc_factor / 100.0_wp ) ), & |
---|
1396 | 1 ) |
---|
1397 | ELSE |
---|
1398 | alloc_size = 1 |
---|
1399 | ENDIF |
---|
1400 | ALLOCATE(grid_particles(kp,jp,ip)%particles(1:alloc_size)) |
---|
1401 | DO n = 1, alloc_size |
---|
1402 | grid_particles(kp,jp,ip)%particles(n) = zero_particle |
---|
1403 | ENDDO |
---|
1404 | ELSEIF ( phase == PHASE_RELEASE ) THEN |
---|
1405 | IF ( local_count(kp,jp,ip) > 0 ) THEN |
---|
1406 | new_size = local_count(kp,jp,ip) + prt_count(kp,jp,ip) |
---|
1407 | alloc_size = MAX( INT( new_size * ( 1.0_wp + & |
---|
1408 | alloc_factor / 100.0_wp ) ), 1 ) |
---|
1409 | IF( alloc_size > SIZE( grid_particles(kp,jp,ip)%particles) ) THEN |
---|
1410 | CALL realloc_particles_array( ip, jp, kp, alloc_size ) |
---|
1411 | ENDIF |
---|
1412 | ENDIF |
---|
1413 | ENDIF |
---|
1414 | ENDDO |
---|
1415 | ENDDO |
---|
1416 | ENDDO |
---|
1417 | ENDIF |
---|
1418 | |
---|
1419 | ENDDO |
---|
1420 | |
---|
1421 | local_start = prt_count+1 |
---|
1422 | prt_count = local_count |
---|
1423 | ! |
---|
1424 | !-- Calculate particle IDs |
---|
1425 | DO ip = nxl, nxr |
---|
1426 | DO jp = nys, nyn |
---|
1427 | DO kp = nzb+1, nzt |
---|
1428 | number_of_particles = prt_count(kp,jp,ip) |
---|
1429 | IF ( number_of_particles <= 0 ) CYCLE |
---|
1430 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
1431 | |
---|
1432 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
1433 | |
---|
1434 | particles(n)%id = 10000_idp**3 * grid_particles(kp,jp,ip)%id_counter + & |
---|
1435 | 10000_idp**2 * kp + 10000_idp * jp + ip |
---|
1436 | ! |
---|
1437 | !-- Count the number of particles that have been released before |
---|
1438 | grid_particles(kp,jp,ip)%id_counter = & |
---|
1439 | grid_particles(kp,jp,ip)%id_counter + 1 |
---|
1440 | |
---|
1441 | ENDDO |
---|
1442 | |
---|
1443 | ENDDO |
---|
1444 | ENDDO |
---|
1445 | ENDDO |
---|
1446 | ! |
---|
1447 | !-- Initialize aerosol background spectrum |
---|
1448 | IF ( curvature_solution_effects ) THEN |
---|
1449 | CALL lpm_init_aerosols( local_start ) |
---|
1450 | ENDIF |
---|
1451 | ! |
---|
1452 | !-- Add random fluctuation to particle positions. |
---|
1453 | IF ( random_start_position ) THEN |
---|
1454 | DO ip = nxl, nxr |
---|
1455 | DO jp = nys, nyn |
---|
1456 | DO kp = nzb+1, nzt |
---|
1457 | number_of_particles = prt_count(kp,jp,ip) |
---|
1458 | IF ( number_of_particles <= 0 ) CYCLE |
---|
1459 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
1460 | ! |
---|
1461 | !-- Move only new particles. Moreover, limit random fluctuation |
---|
1462 | !-- in order to prevent that particles move more than one grid box, |
---|
1463 | !-- which would lead to problems concerning particle exchange |
---|
1464 | !-- between processors in case pdx/pdy are larger than dx/dy, |
---|
1465 | !-- respectively. |
---|
1466 | DO n = local_start(kp,jp,ip), number_of_particles |
---|
1467 | IF ( psl(particles(n)%group) /= psr(particles(n)%group) ) THEN |
---|
1468 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
1469 | pdx(particles(n)%group) |
---|
1470 | particles(n)%x = particles(n)%x + & |
---|
1471 | MERGE( rand_contr, SIGN( dx, rand_contr ), & |
---|
1472 | ABS( rand_contr ) < dx & |
---|
1473 | ) |
---|
1474 | ENDIF |
---|
1475 | IF ( pss(particles(n)%group) /= psn(particles(n)%group) ) THEN |
---|
1476 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
1477 | pdy(particles(n)%group) |
---|
1478 | particles(n)%y = particles(n)%y + & |
---|
1479 | MERGE( rand_contr, SIGN( dy, rand_contr ), & |
---|
1480 | ABS( rand_contr ) < dy & |
---|
1481 | ) |
---|
1482 | ENDIF |
---|
1483 | IF ( psb(particles(n)%group) /= pst(particles(n)%group) ) THEN |
---|
1484 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
1485 | pdz(particles(n)%group) |
---|
1486 | particles(n)%z = particles(n)%z + & |
---|
1487 | MERGE( rand_contr, SIGN( dzw(kp), rand_contr ), & |
---|
1488 | ABS( rand_contr ) < dzw(kp) & |
---|
1489 | ) |
---|
1490 | ENDIF |
---|
1491 | ENDDO |
---|
1492 | ! |
---|
1493 | !-- Identify particles located outside the model domain and reflect |
---|
1494 | !-- or absorb them if necessary. |
---|
1495 | CALL lpm_boundary_conds( 'bottom/top', i, j, k ) |
---|
1496 | ! |
---|
1497 | !-- Furthermore, remove particles located in topography. Note, as |
---|
1498 | !-- the particle speed is still zero at this point, wall |
---|
1499 | !-- reflection boundary conditions will not work in this case. |
---|
1500 | particles => & |
---|
1501 | grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
1502 | DO n = local_start(kp,jp,ip), number_of_particles |
---|
1503 | i = particles(n)%x * ddx |
---|
1504 | j = particles(n)%y * ddy |
---|
1505 | k = particles(n)%z / dz(1) + 1 + offset_ocean_nzt |
---|
1506 | DO WHILE( zw(k) < particles(n)%z ) |
---|
1507 | k = k + 1 |
---|
1508 | ENDDO |
---|
1509 | DO WHILE( zw(k-1) > particles(n)%z ) |
---|
1510 | k = k - 1 |
---|
1511 | ENDDO |
---|
1512 | ! |
---|
1513 | !-- Check if particle is within topography |
---|
1514 | IF ( .NOT. BTEST( wall_flags_0(k,j,i), 0 ) ) THEN |
---|
1515 | particles(n)%particle_mask = .FALSE. |
---|
1516 | deleted_particles = deleted_particles + 1 |
---|
1517 | ENDIF |
---|
1518 | |
---|
1519 | ENDDO |
---|
1520 | ENDDO |
---|
1521 | ENDDO |
---|
1522 | ENDDO |
---|
1523 | ! |
---|
1524 | !-- Exchange particles between grid cells and processors |
---|
1525 | CALL lpm_move_particle |
---|
1526 | CALL lpm_exchange_horiz |
---|
1527 | |
---|
1528 | ENDIF |
---|
1529 | ! |
---|
1530 | !-- In case of random_start_position, delete particles identified by |
---|
1531 | !-- lpm_exchange_horiz and lpm_boundary_conds. Then sort particles into blocks, |
---|
1532 | !-- which is needed for a fast interpolation of the LES fields on the particle |
---|
1533 | !-- position. |
---|
1534 | CALL lpm_sort_and_delete |
---|
1535 | ! |
---|
1536 | !-- Determine the current number of particles |
---|
1537 | DO ip = nxl, nxr |
---|
1538 | DO jp = nys, nyn |
---|
1539 | DO kp = nzb+1, nzt |
---|
1540 | number_of_particles = number_of_particles & |
---|
1541 | + prt_count(kp,jp,ip) |
---|
1542 | ENDDO |
---|
1543 | ENDDO |
---|
1544 | ENDDO |
---|
1545 | ! |
---|
1546 | !-- Calculate the number of particles of the total domain |
---|
1547 | #if defined( __parallel ) |
---|
1548 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1549 | CALL MPI_ALLREDUCE( number_of_particles, total_number_of_particles, 1, & |
---|
1550 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1551 | #else |
---|
1552 | total_number_of_particles = number_of_particles |
---|
1553 | #endif |
---|
1554 | |
---|
1555 | RETURN |
---|
1556 | |
---|
1557 | END SUBROUTINE lpm_create_particle |
---|
1558 | |
---|
1559 | |
---|
1560 | !------------------------------------------------------------------------------! |
---|
1561 | ! Description: |
---|
1562 | ! ------------ |
---|
1563 | !> This routine initialize the particles as aerosols with physio-chemical |
---|
1564 | !> properties. |
---|
1565 | !------------------------------------------------------------------------------! |
---|
1566 | SUBROUTINE lpm_init_aerosols(local_start) |
---|
1567 | |
---|
1568 | REAL(wp) :: afactor !< curvature effects |
---|
1569 | REAL(wp) :: bfactor !< solute effects |
---|
1570 | REAL(wp) :: dlogr !< logarithmic width of radius bin |
---|
1571 | REAL(wp) :: e_a !< vapor pressure |
---|
1572 | REAL(wp) :: e_s !< saturation vapor pressure |
---|
1573 | REAL(wp) :: rmin = 0.005e-6_wp !< minimum aerosol radius |
---|
1574 | REAL(wp) :: rmax = 10.0e-6_wp !< maximum aerosol radius |
---|
1575 | REAL(wp) :: r_mid !< mean radius of bin |
---|
1576 | REAL(wp) :: r_l !< left radius of bin |
---|
1577 | REAL(wp) :: r_r !< right radius of bin |
---|
1578 | REAL(wp) :: sigma !< surface tension |
---|
1579 | REAL(wp) :: t_int !< temperature |
---|
1580 | |
---|
1581 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) :: local_start !< |
---|
1582 | |
---|
1583 | INTEGER(iwp) :: n !< |
---|
1584 | INTEGER(iwp) :: ip !< |
---|
1585 | INTEGER(iwp) :: jp !< |
---|
1586 | INTEGER(iwp) :: kp !< |
---|
1587 | |
---|
1588 | ! |
---|
1589 | !-- Set constants for different aerosol species |
---|
1590 | IF ( TRIM( aero_species ) == 'nacl' ) THEN |
---|
1591 | molecular_weight_of_solute = 0.05844_wp |
---|
1592 | rho_s = 2165.0_wp |
---|
1593 | vanthoff = 2.0_wp |
---|
1594 | ELSEIF ( TRIM( aero_species ) == 'c3h4o4' ) THEN |
---|
1595 | molecular_weight_of_solute = 0.10406_wp |
---|
1596 | rho_s = 1600.0_wp |
---|
1597 | vanthoff = 1.37_wp |
---|
1598 | ELSEIF ( TRIM( aero_species ) == 'nh4o3' ) THEN |
---|
1599 | molecular_weight_of_solute = 0.08004_wp |
---|
1600 | rho_s = 1720.0_wp |
---|
1601 | vanthoff = 2.31_wp |
---|
1602 | ELSE |
---|
1603 | WRITE( message_string, * ) 'unknown aerosol species ', & |
---|
1604 | 'aero_species = "', TRIM( aero_species ), '"' |
---|
1605 | CALL message( 'lpm_init', 'PA0470', 1, 2, 0, 6, 0 ) |
---|
1606 | ENDIF |
---|
1607 | ! |
---|
1608 | !-- The following typical aerosol spectra are taken from Jaenicke (1993): |
---|
1609 | !-- Tropospheric aerosols. Published in Aerosol-Cloud-Climate Interactions. |
---|
1610 | IF ( TRIM( aero_type ) == 'polar' ) THEN |
---|
1611 | na = (/ 2.17e1, 1.86e-1, 3.04e-4 /) * 1.0E6_wp |
---|
1612 | rm = (/ 0.0689, 0.375, 4.29 /) * 1.0E-6_wp |
---|
1613 | log_sigma = (/ 0.245, 0.300, 0.291 /) |
---|
1614 | ELSEIF ( TRIM( aero_type ) == 'background' ) THEN |
---|
1615 | na = (/ 1.29e2, 5.97e1, 6.35e1 /) * 1.0E6_wp |
---|
1616 | rm = (/ 0.0036, 0.127, 0.259 /) * 1.0E-6_wp |
---|
1617 | log_sigma = (/ 0.645, 0.253, 0.425 /) |
---|
1618 | ELSEIF ( TRIM( aero_type ) == 'maritime' ) THEN |
---|
1619 | na = (/ 1.33e2, 6.66e1, 3.06e0 /) * 1.0E6_wp |
---|
1620 | rm = (/ 0.0039, 0.133, 0.29 /) * 1.0E-6_wp |
---|
1621 | log_sigma = (/ 0.657, 0.210, 0.396 /) |
---|
1622 | ELSEIF ( TRIM( aero_type ) == 'continental' ) THEN |
---|
1623 | na = (/ 3.20e3, 2.90e3, 3.00e-1 /) * 1.0E6_wp |
---|
1624 | rm = (/ 0.01, 0.058, 0.9 /) * 1.0E-6_wp |
---|
1625 | log_sigma = (/ 0.161, 0.217, 0.380 /) |
---|
1626 | ELSEIF ( TRIM( aero_type ) == 'desert' ) THEN |
---|
1627 | na = (/ 7.26e2, 1.14e3, 1.78e-1 /) * 1.0E6_wp |
---|
1628 | rm = (/ 0.001, 0.0188, 10.8 /) * 1.0E-6_wp |
---|
1629 | log_sigma = (/ 0.247, 0.770, 0.438 /) |
---|
1630 | ELSEIF ( TRIM( aero_type ) == 'rural' ) THEN |
---|
1631 | na = (/ 6.65e3, 1.47e2, 1.99e3 /) * 1.0E6_wp |
---|
1632 | rm = (/ 0.00739, 0.0269, 0.0419 /) * 1.0E-6_wp |
---|
1633 | log_sigma = (/ 0.225, 0.557, 0.266 /) |
---|
1634 | ELSEIF ( TRIM( aero_type ) == 'urban' ) THEN |
---|
1635 | na = (/ 9.93e4, 1.11e3, 3.64e4 /) * 1.0E6_wp |
---|
1636 | rm = (/ 0.00651, 0.00714, 0.0248 /) * 1.0E-6_wp |
---|
1637 | log_sigma = (/ 0.245, 0.666, 0.337 /) |
---|
1638 | ELSEIF ( TRIM( aero_type ) == 'user' ) THEN |
---|
1639 | CONTINUE |
---|
1640 | ELSE |
---|
1641 | WRITE( message_string, * ) 'unknown aerosol type ', & |
---|
1642 | 'aero_type = "', TRIM( aero_type ), '"' |
---|
1643 | CALL message( 'lpm_init', 'PA0459', 1, 2, 0, 6, 0 ) |
---|
1644 | ENDIF |
---|
1645 | |
---|
1646 | DO ip = nxl, nxr |
---|
1647 | DO jp = nys, nyn |
---|
1648 | DO kp = nzb+1, nzt |
---|
1649 | |
---|
1650 | number_of_particles = prt_count(kp,jp,ip) |
---|
1651 | IF ( number_of_particles <= 0 ) CYCLE |
---|
1652 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
1653 | |
---|
1654 | dlogr = ( LOG10(rmax) - LOG10(rmin) ) / ( number_of_particles - local_start(kp,jp,ip) + 1 ) |
---|
1655 | ! |
---|
1656 | !-- Initialize the aerosols with a predefined spectral distribution |
---|
1657 | !-- of the dry radius (logarithmically increasing bins) and a varying |
---|
1658 | !-- weighting factor |
---|
1659 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
1660 | |
---|
1661 | r_l = 10.0**( LOG10( rmin ) + (n-1) * dlogr ) |
---|
1662 | r_r = 10.0**( LOG10( rmin ) + n * dlogr ) |
---|
1663 | r_mid = SQRT( r_l * r_r ) |
---|
1664 | |
---|
1665 | particles(n)%aux1 = r_mid |
---|
1666 | particles(n)%weight_factor = & |
---|
1667 | ( na(1) / ( SQRT( 2.0_wp * pi ) * log_sigma(1) ) * & |
---|
1668 | EXP( - LOG10( r_mid / rm(1) )**2 / ( 2.0_wp * log_sigma(1)**2 ) ) + & |
---|
1669 | na(2) / ( SQRT( 2.0_wp * pi ) * log_sigma(2) ) * & |
---|
1670 | EXP( - LOG10( r_mid / rm(2) )**2 / ( 2.0_wp * log_sigma(2)**2 ) ) + & |
---|
1671 | na(3) / ( SQRT( 2.0_wp * pi ) * log_sigma(3) ) * & |
---|
1672 | EXP( - LOG10( r_mid / rm(3) )**2 / ( 2.0_wp * log_sigma(3)**2 ) ) & |
---|
1673 | ) * ( LOG10(r_r) - LOG10(r_l) ) * ( dx * dy * dzw(kp) ) |
---|
1674 | |
---|
1675 | ! |
---|
1676 | !-- Multiply weight_factor with the namelist parameter aero_weight |
---|
1677 | !-- to increase or decrease the number of simulated aerosols |
---|
1678 | particles(n)%weight_factor = particles(n)%weight_factor * aero_weight |
---|
1679 | |
---|
1680 | IF ( particles(n)%weight_factor - FLOOR(particles(n)%weight_factor,KIND=wp) & |
---|
1681 | > random_function( iran_part ) ) THEN |
---|
1682 | particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp) + 1.0_wp |
---|
1683 | ELSE |
---|
1684 | particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp) |
---|
1685 | ENDIF |
---|
1686 | ! |
---|
1687 | !-- Unnecessary particles will be deleted |
---|
1688 | IF ( particles(n)%weight_factor <= 0.0_wp ) particles(n)%particle_mask = .FALSE. |
---|
1689 | |
---|
1690 | ENDDO |
---|
1691 | ! |
---|
1692 | !-- Set particle radius to equilibrium radius based on the environmental |
---|
1693 | !-- supersaturation (Khvorostyanov and Curry, 2007, JGR). This avoids |
---|
1694 | !-- the sometimes lengthy growth toward their equilibrium radius within |
---|
1695 | !-- the simulation. |
---|
1696 | t_int = pt(kp,jp,ip) * exner(kp) |
---|
1697 | |
---|
1698 | e_s = magnus( t_int ) |
---|
1699 | e_a = q(kp,jp,ip) * hyp(kp) / ( q(kp,jp,ip) + rd_d_rv ) |
---|
1700 | |
---|
1701 | sigma = 0.0761_wp - 0.000155_wp * ( t_int - 273.15_wp ) |
---|
1702 | afactor = 2.0_wp * sigma / ( rho_l * r_v * t_int ) |
---|
1703 | |
---|
1704 | bfactor = vanthoff * molecular_weight_of_water * & |
---|
1705 | rho_s / ( molecular_weight_of_solute * rho_l ) |
---|
1706 | ! |
---|
1707 | !-- The formula is only valid for subsaturated environments. For |
---|
1708 | !-- supersaturations higher than -5 %, the supersaturation is set to -5%. |
---|
1709 | IF ( e_a / e_s >= 0.95_wp ) e_a = 0.95_wp * e_s |
---|
1710 | |
---|
1711 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
1712 | ! |
---|
1713 | !-- For details on this equation, see Eq. (14) of Khvorostyanov and |
---|
1714 | !-- Curry (2007, JGR) |
---|
1715 | particles(n)%radius = bfactor**0.3333333_wp * & |
---|
1716 | particles(n)%aux1 / ( 1.0_wp - e_a / e_s )**0.3333333_wp / & |
---|
1717 | ( 1.0_wp + ( afactor / ( 3.0_wp * bfactor**0.3333333_wp * & |
---|
1718 | particles(n)%aux1 ) ) / & |
---|
1719 | ( 1.0_wp - e_a / e_s )**0.6666666_wp & |
---|
1720 | ) |
---|
1721 | |
---|
1722 | ENDDO |
---|
1723 | |
---|
1724 | ENDDO |
---|
1725 | ENDDO |
---|
1726 | ENDDO |
---|
1727 | |
---|
1728 | END SUBROUTINE lpm_init_aerosols |
---|
1729 | |
---|
1730 | |
---|
1731 | !------------------------------------------------------------------------------! |
---|
1732 | ! Description: |
---|
1733 | ! ------------ |
---|
1734 | !> Calculates quantities required for considering the SGS velocity fluctuations |
---|
1735 | !> in the particle transport by a stochastic approach. The respective |
---|
1736 | !> quantities are: SGS-TKE gradients and horizontally averaged profiles of the |
---|
1737 | !> SGS TKE and the resolved-scale velocity variances. |
---|
1738 | !------------------------------------------------------------------------------! |
---|
1739 | SUBROUTINE lpm_init_sgs_tke |
---|
1740 | |
---|
1741 | USE statistics, & |
---|
1742 | ONLY: flow_statistics_called, hom, sums, sums_l |
---|
1743 | |
---|
1744 | INTEGER(iwp) :: i !< index variable along x |
---|
1745 | INTEGER(iwp) :: j !< index variable along y |
---|
1746 | INTEGER(iwp) :: k !< index variable along z |
---|
1747 | INTEGER(iwp) :: m !< running index for the surface elements |
---|
1748 | |
---|
1749 | REAL(wp) :: flag1 !< flag to mask topography |
---|
1750 | |
---|
1751 | ! |
---|
1752 | !-- TKE gradient along x and y |
---|
1753 | DO i = nxl, nxr |
---|
1754 | DO j = nys, nyn |
---|
1755 | DO k = nzb, nzt+1 |
---|
1756 | |
---|
1757 | IF ( .NOT. BTEST( wall_flags_0(k,j,i-1), 0 ) .AND. & |
---|
1758 | BTEST( wall_flags_0(k,j,i), 0 ) .AND. & |
---|
1759 | BTEST( wall_flags_0(k,j,i+1), 0 ) ) & |
---|
1760 | THEN |
---|
1761 | de_dx(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1762 | ( e(k,j,i+1) - e(k,j,i) ) * ddx |
---|
1763 | ELSEIF ( BTEST( wall_flags_0(k,j,i-1), 0 ) .AND. & |
---|
1764 | BTEST( wall_flags_0(k,j,i), 0 ) .AND. & |
---|
1765 | .NOT. BTEST( wall_flags_0(k,j,i+1), 0 ) ) & |
---|
1766 | THEN |
---|
1767 | de_dx(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1768 | ( e(k,j,i) - e(k,j,i-1) ) * ddx |
---|
1769 | ELSEIF ( .NOT. BTEST( wall_flags_0(k,j,i), 22 ) .AND. & |
---|
1770 | .NOT. BTEST( wall_flags_0(k,j,i+1), 22 ) ) & |
---|
1771 | THEN |
---|
1772 | de_dx(k,j,i) = 0.0_wp |
---|
1773 | ELSEIF ( .NOT. BTEST( wall_flags_0(k,j,i-1), 22 ) .AND. & |
---|
1774 | .NOT. BTEST( wall_flags_0(k,j,i), 22 ) ) & |
---|
1775 | THEN |
---|
1776 | de_dx(k,j,i) = 0.0_wp |
---|
1777 | ELSE |
---|
1778 | de_dx(k,j,i) = sgs_wf_part * ( e(k,j,i+1) - e(k,j,i-1) ) * ddx |
---|
1779 | ENDIF |
---|
1780 | |
---|
1781 | IF ( .NOT. BTEST( wall_flags_0(k,j-1,i), 0 ) .AND. & |
---|
1782 | BTEST( wall_flags_0(k,j,i), 0 ) .AND. & |
---|
1783 | BTEST( wall_flags_0(k,j+1,i), 0 ) ) & |
---|
1784 | THEN |
---|
1785 | de_dy(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1786 | ( e(k,j+1,i) - e(k,j,i) ) * ddy |
---|
1787 | ELSEIF ( BTEST( wall_flags_0(k,j-1,i), 0 ) .AND. & |
---|
1788 | BTEST( wall_flags_0(k,j,i), 0 ) .AND. & |
---|
1789 | .NOT. BTEST( wall_flags_0(k,j+1,i), 0 ) ) & |
---|
1790 | THEN |
---|
1791 | de_dy(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1792 | ( e(k,j,i) - e(k,j-1,i) ) * ddy |
---|
1793 | ELSEIF ( .NOT. BTEST( wall_flags_0(k,j,i), 22 ) .AND. & |
---|
1794 | .NOT. BTEST( wall_flags_0(k,j+1,i), 22 ) ) & |
---|
1795 | THEN |
---|
1796 | de_dy(k,j,i) = 0.0_wp |
---|
1797 | ELSEIF ( .NOT. BTEST( wall_flags_0(k,j-1,i), 22 ) .AND. & |
---|
1798 | .NOT. BTEST( wall_flags_0(k,j,i), 22 ) ) & |
---|
1799 | THEN |
---|
1800 | de_dy(k,j,i) = 0.0_wp |
---|
1801 | ELSE |
---|
1802 | de_dy(k,j,i) = sgs_wf_part * ( e(k,j+1,i) - e(k,j-1,i) ) * ddy |
---|
1803 | ENDIF |
---|
1804 | |
---|
1805 | ENDDO |
---|
1806 | ENDDO |
---|
1807 | ENDDO |
---|
1808 | |
---|
1809 | ! |
---|
1810 | !-- TKE gradient along z at topograhy and including bottom and top boundary conditions |
---|
1811 | DO i = nxl, nxr |
---|
1812 | DO j = nys, nyn |
---|
1813 | DO k = nzb+1, nzt-1 |
---|
1814 | ! |
---|
1815 | !-- Flag to mask topography |
---|
1816 | flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
1817 | |
---|
1818 | de_dz(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1819 | ( e(k+1,j,i) - e(k-1,j,i) ) / ( zu(k+1) - zu(k-1) ) & |
---|
1820 | * flag1 |
---|
1821 | ENDDO |
---|
1822 | ! |
---|
1823 | !-- upward-facing surfaces |
---|
1824 | DO m = bc_h(0)%start_index(j,i), bc_h(0)%end_index(j,i) |
---|
1825 | k = bc_h(0)%k(m) |
---|
1826 | de_dz(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1827 | ( e(k+1,j,i) - e(k,j,i) ) / ( zu(k+1) - zu(k) ) |
---|
1828 | ENDDO |
---|
1829 | ! |
---|
1830 | !-- downward-facing surfaces |
---|
1831 | DO m = bc_h(1)%start_index(j,i), bc_h(1)%end_index(j,i) |
---|
1832 | k = bc_h(1)%k(m) |
---|
1833 | de_dz(k,j,i) = 2.0_wp * sgs_wf_part * & |
---|
1834 | ( e(k,j,i) - e(k-1,j,i) ) / ( zu(k) - zu(k-1) ) |
---|
1835 | ENDDO |
---|
1836 | |
---|
1837 | de_dz(nzb,j,i) = 0.0_wp |
---|
1838 | de_dz(nzt,j,i) = 0.0_wp |
---|
1839 | de_dz(nzt+1,j,i) = 0.0_wp |
---|
1840 | ENDDO |
---|
1841 | ENDDO |
---|
1842 | ! |
---|
1843 | !-- Ghost point exchange |
---|
1844 | CALL exchange_horiz( de_dx, nbgp ) |
---|
1845 | CALL exchange_horiz( de_dy, nbgp ) |
---|
1846 | CALL exchange_horiz( de_dz, nbgp ) |
---|
1847 | CALL exchange_horiz( diss, nbgp ) |
---|
1848 | ! |
---|
1849 | !-- Set boundary conditions at non-periodic boundaries. Note, at non-period |
---|
1850 | !-- boundaries zero-gradient boundary conditions are set for the subgrid TKE. |
---|
1851 | !-- Thus, TKE gradients normal to the respective lateral boundaries are zero, |
---|
1852 | !-- while tangetial TKE gradients then must be the same as within the prognostic |
---|
1853 | !-- domain. |
---|
1854 | IF ( bc_dirichlet_l ) THEN |
---|
1855 | de_dx(:,:,-1) = 0.0_wp |
---|
1856 | de_dy(:,:,-1) = de_dy(:,:,0) |
---|
1857 | de_dz(:,:,-1) = de_dz(:,:,0) |
---|
1858 | ENDIF |
---|
1859 | IF ( bc_dirichlet_r ) THEN |
---|
1860 | de_dx(:,:,nxr+1) = 0.0_wp |
---|
1861 | de_dy(:,:,nxr+1) = de_dy(:,:,nxr) |
---|
1862 | de_dz(:,:,nxr+1) = de_dz(:,:,nxr) |
---|
1863 | ENDIF |
---|
1864 | IF ( bc_dirichlet_n ) THEN |
---|
1865 | de_dx(:,nyn+1,:) = de_dx(:,nyn,:) |
---|
1866 | de_dy(:,nyn+1,:) = 0.0_wp |
---|
1867 | de_dz(:,nyn+1,:) = de_dz(:,nyn,:) |
---|
1868 | ENDIF |
---|
1869 | IF ( bc_dirichlet_s ) THEN |
---|
1870 | de_dx(:,nys-1,:) = de_dx(:,nys,:) |
---|
1871 | de_dy(:,nys-1,:) = 0.0_wp |
---|
1872 | de_dz(:,nys-1,:) = de_dz(:,nys,:) |
---|
1873 | ENDIF |
---|
1874 | ! |
---|
1875 | !-- Calculate the horizontally averaged profiles of SGS TKE and resolved |
---|
1876 | !-- velocity variances (they may have been already calculated in routine |
---|
1877 | !-- flow_statistics). |
---|
1878 | IF ( .NOT. flow_statistics_called ) THEN |
---|
1879 | |
---|
1880 | ! |
---|
1881 | !-- First calculate horizontally averaged profiles of the horizontal |
---|
1882 | !-- velocities. |
---|
1883 | sums_l(:,1,0) = 0.0_wp |
---|
1884 | sums_l(:,2,0) = 0.0_wp |
---|
1885 | |
---|
1886 | DO i = nxl, nxr |
---|
1887 | DO j = nys, nyn |
---|
1888 | DO k = nzb, nzt+1 |
---|
1889 | ! |
---|
1890 | !-- Flag indicating vicinity of wall |
---|
1891 | flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 24 ) ) |
---|
1892 | |
---|
1893 | sums_l(k,1,0) = sums_l(k,1,0) + u(k,j,i) * flag1 |
---|
1894 | sums_l(k,2,0) = sums_l(k,2,0) + v(k,j,i) * flag1 |
---|
1895 | ENDDO |
---|
1896 | ENDDO |
---|
1897 | ENDDO |
---|
1898 | |
---|
1899 | #if defined( __parallel ) |
---|
1900 | ! |
---|
1901 | !-- Compute total sum from local sums |
---|
1902 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1903 | CALL MPI_ALLREDUCE( sums_l(nzb,1,0), sums(nzb,1), nzt+2-nzb, & |
---|
1904 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1905 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1906 | CALL MPI_ALLREDUCE( sums_l(nzb,2,0), sums(nzb,2), nzt+2-nzb, & |
---|
1907 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1908 | #else |
---|
1909 | sums(:,1) = sums_l(:,1,0) |
---|
1910 | sums(:,2) = sums_l(:,2,0) |
---|
1911 | #endif |
---|
1912 | |
---|
1913 | ! |
---|
1914 | !-- Final values are obtained by division by the total number of grid |
---|
1915 | !-- points used for the summation. |
---|
1916 | hom(:,1,1,0) = sums(:,1) / ngp_2dh_outer(:,0) ! u |
---|
1917 | hom(:,1,2,0) = sums(:,2) / ngp_2dh_outer(:,0) ! v |
---|
1918 | |
---|
1919 | ! |
---|
1920 | !-- Now calculate the profiles of SGS TKE and the resolved-scale |
---|
1921 | !-- velocity variances |
---|
1922 | sums_l(:,8,0) = 0.0_wp |
---|
1923 | sums_l(:,30,0) = 0.0_wp |
---|
1924 | sums_l(:,31,0) = 0.0_wp |
---|
1925 | sums_l(:,32,0) = 0.0_wp |
---|
1926 | DO i = nxl, nxr |
---|
1927 | DO j = nys, nyn |
---|
1928 | DO k = nzb, nzt+1 |
---|
1929 | ! |
---|
1930 | !-- Flag indicating vicinity of wall |
---|
1931 | flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 24 ) ) |
---|
1932 | |
---|
1933 | sums_l(k,8,0) = sums_l(k,8,0) + e(k,j,i) * flag1 |
---|
1934 | sums_l(k,30,0) = sums_l(k,30,0) + ( u(k,j,i) - hom(k,1,1,0) )**2 * flag1 |
---|
1935 | sums_l(k,31,0) = sums_l(k,31,0) + ( v(k,j,i) - hom(k,1,2,0) )**2 * flag1 |
---|
1936 | sums_l(k,32,0) = sums_l(k,32,0) + w(k,j,i)**2 * flag1 |
---|
1937 | ENDDO |
---|
1938 | ENDDO |
---|
1939 | ENDDO |
---|
1940 | |
---|
1941 | #if defined( __parallel ) |
---|
1942 | ! |
---|
1943 | !-- Compute total sum from local sums |
---|
1944 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1945 | CALL MPI_ALLREDUCE( sums_l(nzb,8,0), sums(nzb,8), nzt+2-nzb, & |
---|
1946 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1947 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1948 | CALL MPI_ALLREDUCE( sums_l(nzb,30,0), sums(nzb,30), nzt+2-nzb, & |
---|
1949 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1950 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1951 | CALL MPI_ALLREDUCE( sums_l(nzb,31,0), sums(nzb,31), nzt+2-nzb, & |
---|
1952 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1953 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1954 | CALL MPI_ALLREDUCE( sums_l(nzb,32,0), sums(nzb,32), nzt+2-nzb, & |
---|
1955 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1956 | |
---|
1957 | #else |
---|
1958 | sums(:,8) = sums_l(:,8,0) |
---|
1959 | sums(:,30) = sums_l(:,30,0) |
---|
1960 | sums(:,31) = sums_l(:,31,0) |
---|
1961 | sums(:,32) = sums_l(:,32,0) |
---|
1962 | #endif |
---|
1963 | |
---|
1964 | ! |
---|
1965 | !-- Final values are obtained by division by the total number of grid |
---|
1966 | !-- points used for the summation. |
---|
1967 | hom(:,1,8,0) = sums(:,8) / ngp_2dh_outer(:,0) ! e |
---|
1968 | hom(:,1,30,0) = sums(:,30) / ngp_2dh_outer(:,0) ! u*2 |
---|
1969 | hom(:,1,31,0) = sums(:,31) / ngp_2dh_outer(:,0) ! v*2 |
---|
1970 | hom(:,1,32,0) = sums(:,32) / ngp_2dh_outer(:,0) ! w*2 |
---|
1971 | |
---|
1972 | ENDIF |
---|
1973 | |
---|
1974 | END SUBROUTINE lpm_init_sgs_tke |
---|
1975 | |
---|
1976 | |
---|
1977 | !------------------------------------------------------------------------------! |
---|
1978 | ! Description: |
---|
1979 | ! ------------ |
---|
1980 | !> Sobroutine control lpm actions, i.e. all actions during one time step. |
---|
1981 | !------------------------------------------------------------------------------! |
---|
1982 | SUBROUTINE lpm_actions( location ) |
---|
1983 | |
---|
1984 | CHARACTER (LEN=*), INTENT(IN) :: location !< call location string |
---|
1985 | |
---|
1986 | INTEGER(iwp) :: i !< |
---|
1987 | INTEGER(iwp) :: ie !< |
---|
1988 | INTEGER(iwp) :: is !< |
---|
1989 | INTEGER(iwp) :: j !< |
---|
1990 | INTEGER(iwp) :: je !< |
---|
1991 | INTEGER(iwp) :: js !< |
---|
1992 | INTEGER(iwp), SAVE :: lpm_count = 0 !< |
---|
1993 | INTEGER(iwp) :: k !< |
---|
1994 | INTEGER(iwp) :: ke !< |
---|
1995 | INTEGER(iwp) :: ks !< |
---|
1996 | INTEGER(iwp) :: m !< |
---|
1997 | INTEGER(iwp), SAVE :: steps = 0 !< |
---|
1998 | |
---|
1999 | LOGICAL :: first_loop_stride !< |
---|
2000 | |
---|
2001 | |
---|
2002 | SELECT CASE ( location ) |
---|
2003 | |
---|
2004 | CASE ( 'after_pressure_solver' ) |
---|
2005 | ! |
---|
2006 | !-- The particle model is executed if particle advection start is reached and only at the end |
---|
2007 | !-- of the intermediate time step loop. |
---|
2008 | IF ( time_since_reference_point >= particle_advection_start & |
---|
2009 | .AND. intermediate_timestep_count == intermediate_timestep_count_max ) & |
---|
2010 | THEN |
---|
2011 | CALL cpu_log( log_point(25), 'lpm', 'start' ) |
---|
2012 | ! |
---|
2013 | !-- Write particle data at current time on file. |
---|
2014 | !-- This has to be done here, before particles are further processed, |
---|
2015 | !-- because they may be deleted within this timestep (in case that |
---|
2016 | !-- dt_write_particle_data = dt_prel = particle_maximum_age). |
---|
2017 | time_write_particle_data = time_write_particle_data + dt_3d |
---|
2018 | IF ( time_write_particle_data >= dt_write_particle_data ) THEN |
---|
2019 | |
---|
2020 | CALL lpm_data_output_particles |
---|
2021 | ! |
---|
2022 | !-- The MOD function allows for changes in the output interval with restart |
---|
2023 | !-- runs. |
---|
2024 | time_write_particle_data = MOD( time_write_particle_data, & |
---|
2025 | MAX( dt_write_particle_data, dt_3d ) ) |
---|
2026 | ENDIF |
---|
2027 | |
---|
2028 | ! |
---|
2029 | !-- Initialize arrays for marking those particles to be deleted after the |
---|
2030 | !-- (sub-) timestep |
---|
2031 | deleted_particles = 0 |
---|
2032 | |
---|
2033 | ! |
---|
2034 | !-- Initialize variables used for accumulating the number of particles |
---|
2035 | !-- xchanged between the subdomains during all sub-timesteps (if sgs |
---|
2036 | !-- velocities are included). These data are output further below on the |
---|
2037 | !-- particle statistics file. |
---|
2038 | trlp_count_sum = 0 |
---|
2039 | trlp_count_recv_sum = 0 |
---|
2040 | trrp_count_sum = 0 |
---|
2041 | trrp_count_recv_sum = 0 |
---|
2042 | trsp_count_sum = 0 |
---|
2043 | trsp_count_recv_sum = 0 |
---|
2044 | trnp_count_sum = 0 |
---|
2045 | trnp_count_recv_sum = 0 |
---|
2046 | ! |
---|
2047 | !-- Calculate exponential term used in case of particle inertia for each |
---|
2048 | !-- of the particle groups |
---|
2049 | DO m = 1, number_of_particle_groups |
---|
2050 | IF ( particle_groups(m)%density_ratio /= 0.0_wp ) THEN |
---|
2051 | particle_groups(m)%exp_arg = & |
---|
2052 | 4.5_wp * particle_groups(m)%density_ratio * & |
---|
2053 | molecular_viscosity / ( particle_groups(m)%radius )**2 |
---|
2054 | |
---|
2055 | particle_groups(m)%exp_term = EXP( -particle_groups(m)%exp_arg * & |
---|
2056 | dt_3d ) |
---|
2057 | ENDIF |
---|
2058 | ENDDO |
---|
2059 | ! |
---|
2060 | !-- If necessary, release new set of particles |
---|
2061 | IF ( ( simulated_time - last_particle_release_time ) >= dt_prel .AND. & |
---|
2062 | end_time_prel > simulated_time ) THEN |
---|
2063 | DO WHILE ( ( simulated_time - last_particle_release_time ) >= dt_prel ) |
---|
2064 | CALL lpm_create_particle( PHASE_RELEASE ) |
---|
2065 | last_particle_release_time = last_particle_release_time + dt_prel |
---|
2066 | ENDDO |
---|
2067 | ENDIF |
---|
2068 | ! |
---|
2069 | !-- Reset summation arrays |
---|
2070 | IF ( cloud_droplets ) THEN |
---|
2071 | ql_c = 0.0_wp |
---|
2072 | ql_v = 0.0_wp |
---|
2073 | ql_vp = 0.0_wp |
---|
2074 | ENDIF |
---|
2075 | |
---|
2076 | first_loop_stride = .TRUE. |
---|
2077 | grid_particles(:,:,:)%time_loop_done = .TRUE. |
---|
2078 | ! |
---|
2079 | !-- Timestep loop for particle advection. |
---|
2080 | !-- This loop has to be repeated until the advection time of every particle |
---|
2081 | !-- (within the total domain!) has reached the LES timestep (dt_3d). |
---|
2082 | !-- In case of including the SGS velocities, the particle timestep may be |
---|
2083 | !-- smaller than the LES timestep (because of the Lagrangian timescale |
---|
2084 | !-- restriction) and particles may require to undergo several particle |
---|
2085 | !-- timesteps, before the LES timestep is reached. Because the number of these |
---|
2086 | !-- particle timesteps to be carried out is unknown at first, these steps are |
---|
2087 | !-- carried out in the following infinite loop with exit condition. |
---|
2088 | DO |
---|
2089 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'start' ) |
---|
2090 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'pause' ) |
---|
2091 | |
---|
2092 | ! |
---|
2093 | !-- If particle advection includes SGS velocity components, calculate the |
---|
2094 | !-- required SGS quantities (i.e. gradients of the TKE, as well as |
---|
2095 | !-- horizontally averaged profiles of the SGS TKE and the resolved-scale |
---|
2096 | !-- velocity variances) |
---|
2097 | IF ( use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
2098 | CALL lpm_init_sgs_tke |
---|
2099 | ENDIF |
---|
2100 | ! |
---|
2101 | !-- In case SGS-particle speed is considered, particles may carry out |
---|
2102 | !-- several particle timesteps. In order to prevent unnecessary |
---|
2103 | !-- treatment of particles that already reached the final time level, |
---|
2104 | !-- particles are sorted into contiguous blocks of finished and |
---|
2105 | !-- not-finished particles, in addition to their already sorting |
---|
2106 | !-- according to their sub-boxes. |
---|
2107 | IF ( .NOT. first_loop_stride .AND. use_sgs_for_particles ) & |
---|
2108 | CALL lpm_sort_timeloop_done |
---|
2109 | DO i = nxl, nxr |
---|
2110 | DO j = nys, nyn |
---|
2111 | DO k = nzb+1, nzt |
---|
2112 | |
---|
2113 | number_of_particles = prt_count(k,j,i) |
---|
2114 | ! |
---|
2115 | !-- If grid cell gets empty, flag must be true |
---|
2116 | IF ( number_of_particles <= 0 ) THEN |
---|
2117 | grid_particles(k,j,i)%time_loop_done = .TRUE. |
---|
2118 | CYCLE |
---|
2119 | ENDIF |
---|
2120 | |
---|
2121 | IF ( .NOT. first_loop_stride .AND. & |
---|
2122 | grid_particles(k,j,i)%time_loop_done ) CYCLE |
---|
2123 | |
---|
2124 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
2125 | |
---|
2126 | particles(1:number_of_particles)%particle_mask = .TRUE. |
---|
2127 | ! |
---|
2128 | !-- Initialize the variable storing the total time that a particle |
---|
2129 | !-- has advanced within the timestep procedure |
---|
2130 | IF ( first_loop_stride ) THEN |
---|
2131 | particles(1:number_of_particles)%dt_sum = 0.0_wp |
---|
2132 | ENDIF |
---|
2133 | ! |
---|
2134 | !-- Particle (droplet) growth by condensation/evaporation and |
---|
2135 | !-- collision |
---|
2136 | IF ( cloud_droplets .AND. first_loop_stride) THEN |
---|
2137 | ! |
---|
2138 | !-- Droplet growth by condensation / evaporation |
---|
2139 | CALL lpm_droplet_condensation(i,j,k) |
---|
2140 | ! |
---|
2141 | !-- Particle growth by collision |
---|
2142 | IF ( collision_kernel /= 'none' ) THEN |
---|
2143 | CALL lpm_droplet_collision(i,j,k) |
---|
2144 | ENDIF |
---|
2145 | |
---|
2146 | ENDIF |
---|
2147 | ! |
---|
2148 | !-- Initialize the switch used for the loop exit condition checked |
---|
2149 | !-- at the end of this loop. If at least one particle has failed to |
---|
2150 | !-- reach the LES timestep, this switch will be set false in |
---|
2151 | !-- lpm_advec. |
---|
2152 | dt_3d_reached_l = .TRUE. |
---|
2153 | |
---|
2154 | ! |
---|
2155 | !-- Particle advection |
---|
2156 | CALL lpm_advec( i, j, k ) |
---|
2157 | ! |
---|
2158 | !-- Particle reflection from walls. Only applied if the particles |
---|
2159 | !-- are in the vertical range of the topography. (Here, some |
---|
2160 | !-- optimization is still possible.) |
---|
2161 | IF ( topography /= 'flat' .AND. k < nzb_max + 2 ) THEN |
---|
2162 | CALL lpm_boundary_conds( 'walls', i, j, k ) |
---|
2163 | ENDIF |
---|
2164 | ! |
---|
2165 | !-- User-defined actions after the calculation of the new particle |
---|
2166 | !-- position |
---|
2167 | CALL user_lpm_advec( i, j, k ) |
---|
2168 | ! |
---|
2169 | !-- Apply boundary conditions to those particles that have crossed |
---|
2170 | !-- the top or bottom boundary and delete those particles, which are |
---|
2171 | !-- older than allowed |
---|
2172 | CALL lpm_boundary_conds( 'bottom/top', i, j, k ) |
---|
2173 | ! |
---|
2174 | !--- If not all particles of the actual grid cell have reached the |
---|
2175 | !-- LES timestep, this cell has to do another loop iteration. Due to |
---|
2176 | !-- the fact that particles can move into neighboring grid cells, |
---|
2177 | !-- these neighbor cells also have to perform another loop iteration. |
---|
2178 | !-- Please note, this realization does not work properly if |
---|
2179 | !-- particles move into another subdomain. |
---|
2180 | IF ( .NOT. dt_3d_reached_l ) THEN |
---|
2181 | ks = MAX(nzb+1,k-1) |
---|
2182 | ke = MIN(nzt,k+1) |
---|
2183 | js = MAX(nys,j-1) |
---|
2184 | je = MIN(nyn,j+1) |
---|
2185 | is = MAX(nxl,i-1) |
---|
2186 | ie = MIN(nxr,i+1) |
---|
2187 | grid_particles(ks:ke,js:je,is:ie)%time_loop_done = .FALSE. |
---|
2188 | ELSE |
---|
2189 | grid_particles(k,j,i)%time_loop_done = .TRUE. |
---|
2190 | ENDIF |
---|
2191 | |
---|
2192 | ENDDO |
---|
2193 | ENDDO |
---|
2194 | ENDDO |
---|
2195 | steps = steps + 1 |
---|
2196 | dt_3d_reached_l = ALL(grid_particles(:,:,:)%time_loop_done) |
---|
2197 | ! |
---|
2198 | !-- Find out, if all particles on every PE have completed the LES timestep |
---|
2199 | !-- and set the switch corespondingly |
---|
2200 | #if defined( __parallel ) |
---|
2201 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2202 | CALL MPI_ALLREDUCE( dt_3d_reached_l, dt_3d_reached, 1, MPI_LOGICAL, & |
---|
2203 | MPI_LAND, comm2d, ierr ) |
---|
2204 | #else |
---|
2205 | dt_3d_reached = dt_3d_reached_l |
---|
2206 | #endif |
---|
2207 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'stop' ) |
---|
2208 | |
---|
2209 | ! |
---|
2210 | !-- Apply splitting and merging algorithm |
---|
2211 | IF ( cloud_droplets ) THEN |
---|
2212 | IF ( splitting ) THEN |
---|
2213 | CALL lpm_splitting |
---|
2214 | ENDIF |
---|
2215 | IF ( merging ) THEN |
---|
2216 | CALL lpm_merging |
---|
2217 | ENDIF |
---|
2218 | ENDIF |
---|
2219 | ! |
---|
2220 | !-- Move Particles local to PE to a different grid cell |
---|
2221 | CALL lpm_move_particle |
---|
2222 | ! |
---|
2223 | !-- Horizontal boundary conditions including exchange between subdmains |
---|
2224 | CALL lpm_exchange_horiz |
---|
2225 | |
---|
2226 | ! |
---|
2227 | !-- IF .FALSE., lpm_sort_and_delete is done inside pcmp |
---|
2228 | IF ( .NOT. dt_3d_reached .OR. .NOT. nested_run ) THEN |
---|
2229 | ! |
---|
2230 | !-- Pack particles (eliminate those marked for deletion), |
---|
2231 | !-- determine new number of particles |
---|
2232 | CALL lpm_sort_and_delete |
---|
2233 | |
---|
2234 | !-- Initialize variables for the next (sub-) timestep, i.e., for marking |
---|
2235 | !-- those particles to be deleted after the timestep |
---|
2236 | deleted_particles = 0 |
---|
2237 | ENDIF |
---|
2238 | |
---|
2239 | IF ( dt_3d_reached ) EXIT |
---|
2240 | |
---|
2241 | first_loop_stride = .FALSE. |
---|
2242 | ENDDO ! timestep loop |
---|
2243 | ! |
---|
2244 | !-- in case of nested runs do the transfer of particles after every full model time step |
---|
2245 | IF ( nested_run ) THEN |
---|
2246 | CALL particles_from_parent_to_child |
---|
2247 | CALL particles_from_child_to_parent |
---|
2248 | CALL pmcp_p_delete_particles_in_fine_grid_area |
---|
2249 | |
---|
2250 | CALL lpm_sort_and_delete |
---|
2251 | |
---|
2252 | deleted_particles = 0 |
---|
2253 | ENDIF |
---|
2254 | |
---|
2255 | ! |
---|
2256 | !-- Calculate the new liquid water content for each grid box |
---|
2257 | IF ( cloud_droplets ) CALL lpm_calc_liquid_water_content |
---|
2258 | |
---|
2259 | ! |
---|
2260 | !-- At the end all arrays are exchanged |
---|
2261 | IF ( cloud_droplets ) THEN |
---|
2262 | CALL exchange_horiz( ql, nbgp ) |
---|
2263 | CALL exchange_horiz( ql_c, nbgp ) |
---|
2264 | CALL exchange_horiz( ql_v, nbgp ) |
---|
2265 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
2266 | ENDIF |
---|
2267 | |
---|
2268 | ! |
---|
2269 | !-- Deallocate unused memory |
---|
2270 | IF ( deallocate_memory .AND. lpm_count == step_dealloc ) THEN |
---|
2271 | CALL dealloc_particles_array |
---|
2272 | lpm_count = 0 |
---|
2273 | ELSEIF ( deallocate_memory ) THEN |
---|
2274 | lpm_count = lpm_count + 1 |
---|
2275 | ENDIF |
---|
2276 | |
---|
2277 | ! |
---|
2278 | !-- Write particle statistics (in particular the number of particles |
---|
2279 | !-- exchanged between the subdomains) on file |
---|
2280 | IF ( write_particle_statistics ) CALL lpm_write_exchange_statistics |
---|
2281 | ! |
---|
2282 | !-- Execute Interactions of condnesation and evaporation to humidity and |
---|
2283 | !-- temperature field |
---|
2284 | IF ( cloud_droplets ) THEN |
---|
2285 | CALL lpm_interaction_droplets_ptq |
---|
2286 | CALL exchange_horiz( pt, nbgp ) |
---|
2287 | CALL exchange_horiz( q, nbgp ) |
---|
2288 | ENDIF |
---|
2289 | |
---|
2290 | CALL cpu_log( log_point(25), 'lpm', 'stop' ) |
---|
2291 | |
---|
2292 | ! ! |
---|
2293 | ! !-- Output of particle time series |
---|
2294 | ! IF ( particle_advection ) THEN |
---|
2295 | ! IF ( time_dopts >= dt_dopts .OR. & |
---|
2296 | ! ( time_since_reference_point >= particle_advection_start .AND. & |
---|
2297 | ! first_call_lpm ) ) THEN |
---|
2298 | ! CALL lpm_data_output_ptseries |
---|
2299 | ! time_dopts = MOD( time_dopts, MAX( dt_dopts, dt_3d ) ) |
---|
2300 | ! ENDIF |
---|
2301 | ! ENDIF |
---|
2302 | |
---|
2303 | ! |
---|
2304 | !-- Set this switch to .false. @todo: maybe find better solution. |
---|
2305 | first_call_lpm = .FALSE. |
---|
2306 | ENDIF! ENDIF statement of lpm_actions('after_pressure_solver') |
---|
2307 | |
---|
2308 | CASE ( 'after_integration' ) |
---|
2309 | ! |
---|
2310 | !-- Call at the end of timestep routine to save particle velocities fields |
---|
2311 | !-- for the next timestep |
---|
2312 | CALL lpm_swap_timelevel_for_particle_advection |
---|
2313 | |
---|
2314 | CASE DEFAULT |
---|
2315 | CONTINUE |
---|
2316 | |
---|
2317 | END SELECT |
---|
2318 | |
---|
2319 | END SUBROUTINE lpm_actions |
---|
2320 | |
---|
2321 | |
---|
2322 | !------------------------------------------------------------------------------! |
---|
2323 | ! Description: |
---|
2324 | ! ------------ |
---|
2325 | ! |
---|
2326 | !------------------------------------------------------------------------------! |
---|
2327 | SUBROUTINE particles_from_parent_to_child |
---|
2328 | IMPLICIT NONE |
---|
2329 | |
---|
2330 | CALL pmcp_c_get_particle_from_parent ! Child actions |
---|
2331 | CALL pmcp_p_fill_particle_win ! Parent actions |
---|
2332 | |
---|
2333 | RETURN |
---|
2334 | END SUBROUTINE particles_from_parent_to_child |
---|
2335 | |
---|
2336 | |
---|
2337 | !------------------------------------------------------------------------------! |
---|
2338 | ! Description: |
---|
2339 | ! ------------ |
---|
2340 | ! |
---|
2341 | !------------------------------------------------------------------------------! |
---|
2342 | SUBROUTINE particles_from_child_to_parent |
---|
2343 | IMPLICIT NONE |
---|
2344 | |
---|
2345 | CALL pmcp_c_send_particle_to_parent ! Child actions |
---|
2346 | CALL pmcp_p_empty_particle_win ! Parent actions |
---|
2347 | |
---|
2348 | RETURN |
---|
2349 | END SUBROUTINE particles_from_child_to_parent |
---|
2350 | |
---|
2351 | !------------------------------------------------------------------------------! |
---|
2352 | ! Description: |
---|
2353 | ! ------------ |
---|
2354 | !> This routine write exchange statistics of the lpm in a ascii file. |
---|
2355 | !------------------------------------------------------------------------------! |
---|
2356 | SUBROUTINE lpm_write_exchange_statistics |
---|
2357 | |
---|
2358 | INTEGER(iwp) :: ip !< |
---|
2359 | INTEGER(iwp) :: jp !< |
---|
2360 | INTEGER(iwp) :: kp !< |
---|
2361 | INTEGER(iwp) :: tot_number_of_particles !< |
---|
2362 | |
---|
2363 | ! |
---|
2364 | !-- Determine the current number of particles |
---|
2365 | number_of_particles = 0 |
---|
2366 | DO ip = nxl, nxr |
---|
2367 | DO jp = nys, nyn |
---|
2368 | DO kp = nzb+1, nzt |
---|
2369 | number_of_particles = number_of_particles & |
---|
2370 | + prt_count(kp,jp,ip) |
---|
2371 | ENDDO |
---|
2372 | ENDDO |
---|
2373 | ENDDO |
---|
2374 | |
---|
2375 | CALL check_open( 80 ) |
---|
2376 | #if defined( __parallel ) |
---|
2377 | WRITE ( 80, 8000 ) current_timestep_number+1, simulated_time+dt_3d, & |
---|
2378 | number_of_particles, pleft, trlp_count_sum, & |
---|
2379 | trlp_count_recv_sum, pright, trrp_count_sum, & |
---|
2380 | trrp_count_recv_sum, psouth, trsp_count_sum, & |
---|
2381 | trsp_count_recv_sum, pnorth, trnp_count_sum, & |
---|
2382 | trnp_count_recv_sum |
---|
2383 | #else |
---|
2384 | WRITE ( 80, 8000 ) current_timestep_number+1, simulated_time+dt_3d, & |
---|
2385 | number_of_particles |
---|
2386 | #endif |
---|
2387 | CALL close_file( 80 ) |
---|
2388 | |
---|
2389 | IF ( number_of_particles > 0 ) THEN |
---|
2390 | WRITE(9,*) 'number_of_particles ', number_of_particles, & |
---|
2391 | current_timestep_number + 1, simulated_time + dt_3d |
---|
2392 | ENDIF |
---|
2393 | |
---|
2394 | #if defined( __parallel ) |
---|
2395 | CALL MPI_ALLREDUCE( number_of_particles, tot_number_of_particles, 1, & |
---|
2396 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
2397 | #else |
---|
2398 | tot_number_of_particles = number_of_particles |
---|
2399 | #endif |
---|
2400 | |
---|
2401 | IF ( nested_run ) THEN |
---|
2402 | CALL pmcp_g_print_number_of_particles( simulated_time+dt_3d, & |
---|
2403 | tot_number_of_particles) |
---|
2404 | ENDIF |
---|
2405 | |
---|
2406 | ! |
---|
2407 | !-- Formats |
---|
2408 | 8000 FORMAT (I6,1X,F7.2,4X,I10,5X,4(I3,1X,I4,'/',I4,2X),6X,I10) |
---|
2409 | |
---|
2410 | |
---|
2411 | END SUBROUTINE lpm_write_exchange_statistics |
---|
2412 | |
---|
2413 | |
---|
2414 | !------------------------------------------------------------------------------! |
---|
2415 | ! Description: |
---|
2416 | ! ------------ |
---|
2417 | !> Write particle data in FORTRAN binary and/or netCDF format |
---|
2418 | !------------------------------------------------------------------------------! |
---|
2419 | SUBROUTINE lpm_data_output_particles |
---|
2420 | |
---|
2421 | INTEGER(iwp) :: ip !< |
---|
2422 | INTEGER(iwp) :: jp !< |
---|
2423 | INTEGER(iwp) :: kp !< |
---|
2424 | |
---|
2425 | CALL cpu_log( log_point_s(40), 'lpm_data_output', 'start' ) |
---|
2426 | |
---|
2427 | ! |
---|
2428 | !-- Attention: change version number for unit 85 (in routine check_open) |
---|
2429 | !-- whenever the output format for this unit is changed! |
---|
2430 | CALL check_open( 85 ) |
---|
2431 | |
---|
2432 | WRITE ( 85 ) simulated_time |
---|
2433 | WRITE ( 85 ) prt_count |
---|
2434 | |
---|
2435 | DO ip = nxl, nxr |
---|
2436 | DO jp = nys, nyn |
---|
2437 | DO kp = nzb+1, nzt |
---|
2438 | number_of_particles = prt_count(kp,jp,ip) |
---|
2439 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
2440 | IF ( number_of_particles <= 0 ) CYCLE |
---|
2441 | WRITE ( 85 ) particles |
---|
2442 | ENDDO |
---|
2443 | ENDDO |
---|
2444 | ENDDO |
---|
2445 | |
---|
2446 | CALL close_file( 85 ) |
---|
2447 | |
---|
2448 | |
---|
2449 | #if defined( __netcdf ) |
---|
2450 | ! ! |
---|
2451 | ! !-- Output in netCDF format |
---|
2452 | ! CALL check_open( 108 ) |
---|
2453 | ! |
---|
2454 | ! ! |
---|
2455 | ! !-- Update the NetCDF time axis |
---|
2456 | ! prt_time_count = prt_time_count + 1 |
---|
2457 | ! |
---|
2458 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_time_prt, & |
---|
2459 | ! (/ simulated_time /), & |
---|
2460 | ! start = (/ prt_time_count /), count = (/ 1 /) ) |
---|
2461 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 1 ) |
---|
2462 | ! |
---|
2463 | ! ! |
---|
2464 | ! !-- Output the real number of particles used |
---|
2465 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_rnop_prt, & |
---|
2466 | ! (/ number_of_particles /), & |
---|
2467 | ! start = (/ prt_time_count /), count = (/ 1 /) ) |
---|
2468 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 2 ) |
---|
2469 | ! |
---|
2470 | ! ! |
---|
2471 | ! !-- Output all particle attributes |
---|
2472 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(1), particles%age, & |
---|
2473 | ! start = (/ 1, prt_time_count /), & |
---|
2474 | ! count = (/ maximum_number_of_particles /) ) |
---|
2475 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 3 ) |
---|
2476 | ! |
---|
2477 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%user, & |
---|
2478 | ! start = (/ 1, prt_time_count /), & |
---|
2479 | ! count = (/ maximum_number_of_particles /) ) |
---|
2480 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 4 ) |
---|
2481 | ! |
---|
2482 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(3), particles%origin_x, & |
---|
2483 | ! start = (/ 1, prt_time_count /), & |
---|
2484 | ! count = (/ maximum_number_of_particles /) ) |
---|
2485 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 5 ) |
---|
2486 | ! |
---|
2487 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(4), particles%origin_y, & |
---|
2488 | ! start = (/ 1, prt_time_count /), & |
---|
2489 | ! count = (/ maximum_number_of_particles /) ) |
---|
2490 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 6 ) |
---|
2491 | ! |
---|
2492 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(5), particles%origin_z, & |
---|
2493 | ! start = (/ 1, prt_time_count /), & |
---|
2494 | ! count = (/ maximum_number_of_particles /) ) |
---|
2495 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 7 ) |
---|
2496 | ! |
---|
2497 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(6), particles%radius, & |
---|
2498 | ! start = (/ 1, prt_time_count /), & |
---|
2499 | ! count = (/ maximum_number_of_particles /) ) |
---|
2500 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 8 ) |
---|
2501 | ! |
---|
2502 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(7), particles%speed_x, & |
---|
2503 | ! start = (/ 1, prt_time_count /), & |
---|
2504 | ! count = (/ maximum_number_of_particles /) ) |
---|
2505 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 9 ) |
---|
2506 | ! |
---|
2507 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(8), particles%speed_y, & |
---|
2508 | ! start = (/ 1, prt_time_count /), & |
---|
2509 | ! count = (/ maximum_number_of_particles /) ) |
---|
2510 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 10 ) |
---|
2511 | ! |
---|
2512 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(9), particles%speed_z, & |
---|
2513 | ! start = (/ 1, prt_time_count /), & |
---|
2514 | ! count = (/ maximum_number_of_particles /) ) |
---|
2515 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 11 ) |
---|
2516 | ! |
---|
2517 | ! nc_stat = NF90_PUT_VAR( id_set_prt,id_var_prt(10), & |
---|
2518 | ! particles%weight_factor, & |
---|
2519 | ! start = (/ 1, prt_time_count /), & |
---|
2520 | ! count = (/ maximum_number_of_particles /) ) |
---|
2521 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 12 ) |
---|
2522 | ! |
---|
2523 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(11), particles%x, & |
---|
2524 | ! start = (/ 1, prt_time_count /), & |
---|
2525 | ! count = (/ maximum_number_of_particles /) ) |
---|
2526 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 13 ) |
---|
2527 | ! |
---|
2528 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(12), particles%y, & |
---|
2529 | ! start = (/ 1, prt_time_count /), & |
---|
2530 | ! count = (/ maximum_number_of_particles /) ) |
---|
2531 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 14 ) |
---|
2532 | ! |
---|
2533 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(13), particles%z, & |
---|
2534 | ! start = (/ 1, prt_time_count /), & |
---|
2535 | ! count = (/ maximum_number_of_particles /) ) |
---|
2536 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 15 ) |
---|
2537 | ! |
---|
2538 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(14), particles%class, & |
---|
2539 | ! start = (/ 1, prt_time_count /), & |
---|
2540 | ! count = (/ maximum_number_of_particles /) ) |
---|
2541 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 16 ) |
---|
2542 | ! |
---|
2543 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(15), particles%group, & |
---|
2544 | ! start = (/ 1, prt_time_count /), & |
---|
2545 | ! count = (/ maximum_number_of_particles /) ) |
---|
2546 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 17 ) |
---|
2547 | ! |
---|
2548 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(16), & |
---|
2549 | ! particles%id2, & |
---|
2550 | ! start = (/ 1, prt_time_count /), & |
---|
2551 | ! count = (/ maximum_number_of_particles /) ) |
---|
2552 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 18 ) |
---|
2553 | ! |
---|
2554 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%id1, & |
---|
2555 | ! start = (/ 1, prt_time_count /), & |
---|
2556 | ! count = (/ maximum_number_of_particles /) ) |
---|
2557 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 19 ) |
---|
2558 | ! |
---|
2559 | #endif |
---|
2560 | |
---|
2561 | CALL cpu_log( log_point_s(40), 'lpm_data_output', 'stop' ) |
---|
2562 | |
---|
2563 | END SUBROUTINE lpm_data_output_particles |
---|
2564 | |
---|
2565 | !------------------------------------------------------------------------------! |
---|
2566 | ! Description: |
---|
2567 | ! ------------ |
---|
2568 | !> This routine calculates and provide particle timeseries output. |
---|
2569 | !------------------------------------------------------------------------------! |
---|
2570 | SUBROUTINE lpm_data_output_ptseries |
---|
2571 | |
---|
2572 | INTEGER(iwp) :: i !< |
---|
2573 | INTEGER(iwp) :: inum !< |
---|
2574 | INTEGER(iwp) :: j !< |
---|
2575 | INTEGER(iwp) :: jg !< |
---|
2576 | INTEGER(iwp) :: k !< |
---|
2577 | INTEGER(iwp) :: n !< |
---|
2578 | |
---|
2579 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: pts_value !< |
---|
2580 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: pts_value_l !< |
---|
2581 | |
---|
2582 | |
---|
2583 | CALL cpu_log( log_point(36), 'data_output_ptseries', 'start' ) |
---|
2584 | |
---|
2585 | IF ( myid == 0 ) THEN |
---|
2586 | ! |
---|
2587 | !-- Open file for time series output in NetCDF format |
---|
2588 | dopts_time_count = dopts_time_count + 1 |
---|
2589 | CALL check_open( 109 ) |
---|
2590 | #if defined( __netcdf ) |
---|
2591 | ! |
---|
2592 | !-- Update the particle time series time axis |
---|
2593 | nc_stat = NF90_PUT_VAR( id_set_pts, id_var_time_pts, & |
---|
2594 | (/ time_since_reference_point /), & |
---|
2595 | start = (/ dopts_time_count /), count = (/ 1 /) ) |
---|
2596 | CALL netcdf_handle_error( 'data_output_ptseries', 391 ) |
---|
2597 | #endif |
---|
2598 | |
---|
2599 | ENDIF |
---|
2600 | |
---|
2601 | ALLOCATE( pts_value(0:number_of_particle_groups,dopts_num), & |
---|
2602 | pts_value_l(0:number_of_particle_groups,dopts_num) ) |
---|
2603 | |
---|
2604 | pts_value_l = 0.0_wp |
---|
2605 | pts_value_l(:,16) = 9999999.9_wp ! for calculation of minimum radius |
---|
2606 | |
---|
2607 | ! |
---|
2608 | !-- Calculate or collect the particle time series quantities for all particles |
---|
2609 | !-- and seperately for each particle group (if there is more than one group) |
---|
2610 | DO i = nxl, nxr |
---|
2611 | DO j = nys, nyn |
---|
2612 | DO k = nzb, nzt |
---|
2613 | number_of_particles = prt_count(k,j,i) |
---|
2614 | IF (number_of_particles <= 0) CYCLE |
---|
2615 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
2616 | DO n = 1, number_of_particles |
---|
2617 | |
---|
2618 | IF ( particles(n)%particle_mask ) THEN ! Restrict analysis to active particles |
---|
2619 | |
---|
2620 | pts_value_l(0,1) = pts_value_l(0,1) + 1.0_wp ! total # of particles |
---|
2621 | pts_value_l(0,2) = pts_value_l(0,2) + & |
---|
2622 | ( particles(n)%x - particles(n)%origin_x ) ! mean x |
---|
2623 | pts_value_l(0,3) = pts_value_l(0,3) + & |
---|
2624 | ( particles(n)%y - particles(n)%origin_y ) ! mean y |
---|
2625 | pts_value_l(0,4) = pts_value_l(0,4) + & |
---|
2626 | ( particles(n)%z - particles(n)%origin_z ) ! mean z |
---|
2627 | pts_value_l(0,5) = pts_value_l(0,5) + particles(n)%z ! mean z (absolute) |
---|
2628 | pts_value_l(0,6) = pts_value_l(0,6) + particles(n)%speed_x ! mean u |
---|
2629 | pts_value_l(0,7) = pts_value_l(0,7) + particles(n)%speed_y ! mean v |
---|
2630 | pts_value_l(0,8) = pts_value_l(0,8) + particles(n)%speed_z ! mean w |
---|
2631 | pts_value_l(0,9) = pts_value_l(0,9) + particles(n)%rvar1 ! mean sgsu |
---|
2632 | pts_value_l(0,10) = pts_value_l(0,10) + particles(n)%rvar2 ! mean sgsv |
---|
2633 | pts_value_l(0,11) = pts_value_l(0,11) + particles(n)%rvar3 ! mean sgsw |
---|
2634 | IF ( particles(n)%speed_z > 0.0_wp ) THEN |
---|
2635 | pts_value_l(0,12) = pts_value_l(0,12) + 1.0_wp ! # of upward moving prts |
---|
2636 | pts_value_l(0,13) = pts_value_l(0,13) + & |
---|
2637 | particles(n)%speed_z ! mean w upw. |
---|
2638 | ELSE |
---|
2639 | pts_value_l(0,14) = pts_value_l(0,14) + & |
---|
2640 | particles(n)%speed_z ! mean w down |
---|
2641 | ENDIF |
---|
2642 | pts_value_l(0,15) = pts_value_l(0,15) + particles(n)%radius ! mean rad |
---|
2643 | pts_value_l(0,16) = MIN( pts_value_l(0,16), particles(n)%radius ) ! minrad |
---|
2644 | pts_value_l(0,17) = MAX( pts_value_l(0,17), particles(n)%radius ) ! maxrad |
---|
2645 | pts_value_l(0,18) = pts_value_l(0,18) + 1.0_wp |
---|
2646 | pts_value_l(0,19) = pts_value_l(0,18) + 1.0_wp |
---|
2647 | ! |
---|
2648 | !-- Repeat the same for the respective particle group |
---|
2649 | IF ( number_of_particle_groups > 1 ) THEN |
---|
2650 | jg = particles(n)%group |
---|
2651 | |
---|
2652 | pts_value_l(jg,1) = pts_value_l(jg,1) + 1.0_wp |
---|
2653 | pts_value_l(jg,2) = pts_value_l(jg,2) + & |
---|
2654 | ( particles(n)%x - particles(n)%origin_x ) |
---|
2655 | pts_value_l(jg,3) = pts_value_l(jg,3) + & |
---|
2656 | ( particles(n)%y - particles(n)%origin_y ) |
---|
2657 | pts_value_l(jg,4) = pts_value_l(jg,4) + & |
---|
2658 | ( particles(n)%z - particles(n)%origin_z ) |
---|
2659 | pts_value_l(jg,5) = pts_value_l(jg,5) + particles(n)%z |
---|
2660 | pts_value_l(jg,6) = pts_value_l(jg,6) + particles(n)%speed_x |
---|
2661 | pts_value_l(jg,7) = pts_value_l(jg,7) + particles(n)%speed_y |
---|
2662 | pts_value_l(jg,8) = pts_value_l(jg,8) + particles(n)%speed_z |
---|
2663 | pts_value_l(jg,9) = pts_value_l(jg,9) + particles(n)%rvar1 |
---|
2664 | pts_value_l(jg,10) = pts_value_l(jg,10) + particles(n)%rvar2 |
---|
2665 | pts_value_l(jg,11) = pts_value_l(jg,11) + particles(n)%rvar3 |
---|
2666 | IF ( particles(n)%speed_z > 0.0_wp ) THEN |
---|
2667 | pts_value_l(jg,12) = pts_value_l(jg,12) + 1.0_wp |
---|
2668 | pts_value_l(jg,13) = pts_value_l(jg,13) + particles(n)%speed_z |
---|
2669 | ELSE |
---|
2670 | pts_value_l(jg,14) = pts_value_l(jg,14) + particles(n)%speed_z |
---|
2671 | ENDIF |
---|
2672 | pts_value_l(jg,15) = pts_value_l(jg,15) + particles(n)%radius |
---|
2673 | pts_value_l(jg,16) = MIN( pts_value(jg,16), particles(n)%radius ) |
---|
2674 | pts_value_l(jg,17) = MAX( pts_value(jg,17), particles(n)%radius ) |
---|
2675 | pts_value_l(jg,18) = pts_value_l(jg,18) + 1.0_wp |
---|
2676 | pts_value_l(jg,19) = pts_value_l(jg,19) + 1.0_wp |
---|
2677 | ENDIF |
---|
2678 | |
---|
2679 | ENDIF |
---|
2680 | |
---|
2681 | ENDDO |
---|
2682 | |
---|
2683 | ENDDO |
---|
2684 | ENDDO |
---|
2685 | ENDDO |
---|
2686 | |
---|
2687 | |
---|
2688 | #if defined( __parallel ) |
---|
2689 | ! |
---|
2690 | !-- Sum values of the subdomains |
---|
2691 | inum = number_of_particle_groups + 1 |
---|
2692 | |
---|
2693 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2694 | CALL MPI_ALLREDUCE( pts_value_l(0,1), pts_value(0,1), 15*inum, MPI_REAL, & |
---|
2695 | MPI_SUM, comm2d, ierr ) |
---|
2696 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2697 | CALL MPI_ALLREDUCE( pts_value_l(0,16), pts_value(0,16), inum, MPI_REAL, & |
---|
2698 | MPI_MIN, comm2d, ierr ) |
---|
2699 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2700 | CALL MPI_ALLREDUCE( pts_value_l(0,17), pts_value(0,17), inum, MPI_REAL, & |
---|
2701 | MPI_MAX, comm2d, ierr ) |
---|
2702 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2703 | CALL MPI_ALLREDUCE( pts_value_l(0,18), pts_value(0,18), inum, MPI_REAL, & |
---|
2704 | MPI_MAX, comm2d, ierr ) |
---|
2705 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2706 | CALL MPI_ALLREDUCE( pts_value_l(0,19), pts_value(0,19), inum, MPI_REAL, & |
---|
2707 | MPI_MIN, comm2d, ierr ) |
---|
2708 | #else |
---|
2709 | pts_value(:,1:19) = pts_value_l(:,1:19) |
---|
2710 | #endif |
---|
2711 | |
---|
2712 | ! |
---|
2713 | !-- Normalize the above calculated quantities (except min/max values) with the |
---|
2714 | !-- total number of particles |
---|
2715 | IF ( number_of_particle_groups > 1 ) THEN |
---|
2716 | inum = number_of_particle_groups |
---|
2717 | ELSE |
---|
2718 | inum = 0 |
---|
2719 | ENDIF |
---|
2720 | |
---|
2721 | DO j = 0, inum |
---|
2722 | |
---|
2723 | IF ( pts_value(j,1) > 0.0_wp ) THEN |
---|
2724 | |
---|
2725 | pts_value(j,2:15) = pts_value(j,2:15) / pts_value(j,1) |
---|
2726 | IF ( pts_value(j,12) > 0.0_wp .AND. pts_value(j,12) < 1.0_wp ) THEN |
---|
2727 | pts_value(j,13) = pts_value(j,13) / pts_value(j,12) |
---|
2728 | pts_value(j,14) = pts_value(j,14) / ( 1.0_wp - pts_value(j,12) ) |
---|
2729 | ELSEIF ( pts_value(j,12) == 0.0_wp ) THEN |
---|
2730 | pts_value(j,13) = -1.0_wp |
---|
2731 | ELSE |
---|
2732 | pts_value(j,14) = -1.0_wp |
---|
2733 | ENDIF |
---|
2734 | |
---|
2735 | ENDIF |
---|
2736 | |
---|
2737 | ENDDO |
---|
2738 | |
---|
2739 | ! |
---|
2740 | !-- Calculate higher order moments of particle time series quantities, |
---|
2741 | !-- seperately for each particle group (if there is more than one group) |
---|
2742 | DO i = nxl, nxr |
---|
2743 | DO j = nys, nyn |
---|
2744 | DO k = nzb, nzt |
---|
2745 | number_of_particles = prt_count(k,j,i) |
---|
2746 | IF (number_of_particles <= 0) CYCLE |
---|
2747 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
2748 | DO n = 1, number_of_particles |
---|
2749 | |
---|
2750 | pts_value_l(0,20) = pts_value_l(0,20) + ( particles(n)%x - & |
---|
2751 | particles(n)%origin_x - pts_value(0,2) )**2 ! x*2 |
---|
2752 | pts_value_l(0,21) = pts_value_l(0,21) + ( particles(n)%y - & |
---|
2753 | particles(n)%origin_y - pts_value(0,3) )**2 ! y*2 |
---|
2754 | pts_value_l(0,22) = pts_value_l(0,22) + ( particles(n)%z - & |
---|
2755 | particles(n)%origin_z - pts_value(0,4) )**2 ! z*2 |
---|
2756 | pts_value_l(0,23) = pts_value_l(0,23) + ( particles(n)%speed_x - & |
---|
2757 | pts_value(0,6) )**2 ! u*2 |
---|
2758 | pts_value_l(0,24) = pts_value_l(0,24) + ( particles(n)%speed_y - & |
---|
2759 | pts_value(0,7) )**2 ! v*2 |
---|
2760 | pts_value_l(0,25) = pts_value_l(0,25) + ( particles(n)%speed_z - & |
---|
2761 | pts_value(0,8) )**2 ! w*2 |
---|
2762 | pts_value_l(0,26) = pts_value_l(0,26) + ( particles(n)%rvar1 - & |
---|
2763 | pts_value(0,9) )**2 ! u"2 |
---|
2764 | pts_value_l(0,27) = pts_value_l(0,27) + ( particles(n)%rvar2 - & |
---|
2765 | pts_value(0,10) )**2 ! v"2 |
---|
2766 | pts_value_l(0,28) = pts_value_l(0,28) + ( particles(n)%rvar3 - & |
---|
2767 | pts_value(0,11) )**2 ! w"2 |
---|
2768 | ! |
---|
2769 | !-- Repeat the same for the respective particle group |
---|
2770 | IF ( number_of_particle_groups > 1 ) THEN |
---|
2771 | jg = particles(n)%group |
---|
2772 | |
---|
2773 | pts_value_l(jg,20) = pts_value_l(jg,20) + ( particles(n)%x - & |
---|
2774 | particles(n)%origin_x - pts_value(jg,2) )**2 |
---|
2775 | pts_value_l(jg,21) = pts_value_l(jg,21) + ( particles(n)%y - & |
---|
2776 | particles(n)%origin_y - pts_value(jg,3) )**2 |
---|
2777 | pts_value_l(jg,22) = pts_value_l(jg,22) + ( particles(n)%z - & |
---|
2778 | particles(n)%origin_z - pts_value(jg,4) )**2 |
---|
2779 | pts_value_l(jg,23) = pts_value_l(jg,23) + ( particles(n)%speed_x - & |
---|
2780 | pts_value(jg,6) )**2 |
---|
2781 | pts_value_l(jg,24) = pts_value_l(jg,24) + ( particles(n)%speed_y - & |
---|
2782 | pts_value(jg,7) )**2 |
---|
2783 | pts_value_l(jg,25) = pts_value_l(jg,25) + ( particles(n)%speed_z - & |
---|
2784 | pts_value(jg,8) )**2 |
---|
2785 | pts_value_l(jg,26) = pts_value_l(jg,26) + ( particles(n)%rvar1 - & |
---|
2786 | pts_value(jg,9) )**2 |
---|
2787 | pts_value_l(jg,27) = pts_value_l(jg,27) + ( particles(n)%rvar2 - & |
---|
2788 | pts_value(jg,10) )**2 |
---|
2789 | pts_value_l(jg,28) = pts_value_l(jg,28) + ( particles(n)%rvar3 - & |
---|
2790 | pts_value(jg,11) )**2 |
---|
2791 | ENDIF |
---|
2792 | |
---|
2793 | ENDDO |
---|
2794 | ENDDO |
---|
2795 | ENDDO |
---|
2796 | ENDDO |
---|
2797 | |
---|
2798 | pts_value_l(0,29) = ( number_of_particles - pts_value(0,1) / numprocs )**2 |
---|
2799 | ! variance of particle numbers |
---|
2800 | IF ( number_of_particle_groups > 1 ) THEN |
---|
2801 | DO j = 1, number_of_particle_groups |
---|
2802 | pts_value_l(j,29) = ( pts_value_l(j,1) - & |
---|
2803 | pts_value(j,1) / numprocs )**2 |
---|
2804 | ENDDO |
---|
2805 | ENDIF |
---|
2806 | |
---|
2807 | #if defined( __parallel ) |
---|
2808 | ! |
---|
2809 | !-- Sum values of the subdomains |
---|
2810 | inum = number_of_particle_groups + 1 |
---|
2811 | |
---|
2812 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2813 | CALL MPI_ALLREDUCE( pts_value_l(0,20), pts_value(0,20), inum*10, MPI_REAL, & |
---|
2814 | MPI_SUM, comm2d, ierr ) |
---|
2815 | #else |
---|
2816 | pts_value(:,20:29) = pts_value_l(:,20:29) |
---|
2817 | #endif |
---|
2818 | |
---|
2819 | ! |
---|
2820 | !-- Normalize the above calculated quantities with the total number of |
---|
2821 | !-- particles |
---|
2822 | IF ( number_of_particle_groups > 1 ) THEN |
---|
2823 | inum = number_of_particle_groups |
---|
2824 | ELSE |
---|
2825 | inum = 0 |
---|
2826 | ENDIF |
---|
2827 | |
---|
2828 | DO j = 0, inum |
---|
2829 | |
---|
2830 | IF ( pts_value(j,1) > 0.0_wp ) THEN |
---|
2831 | pts_value(j,20:28) = pts_value(j,20:28) / pts_value(j,1) |
---|
2832 | ENDIF |
---|
2833 | pts_value(j,29) = pts_value(j,29) / numprocs |
---|
2834 | |
---|
2835 | ENDDO |
---|
2836 | |
---|
2837 | #if defined( __netcdf ) |
---|
2838 | ! |
---|
2839 | !-- Output particle time series quantities in NetCDF format |
---|
2840 | IF ( myid == 0 ) THEN |
---|
2841 | DO j = 0, inum |
---|
2842 | DO i = 1, dopts_num |
---|
2843 | nc_stat = NF90_PUT_VAR( id_set_pts, id_var_dopts(i,j), & |
---|
2844 | (/ pts_value(j,i) /), & |
---|
2845 | start = (/ dopts_time_count /), & |
---|
2846 | count = (/ 1 /) ) |
---|
2847 | CALL netcdf_handle_error( 'data_output_ptseries', 392 ) |
---|
2848 | ENDDO |
---|
2849 | ENDDO |
---|
2850 | ENDIF |
---|
2851 | #endif |
---|
2852 | |
---|
2853 | DEALLOCATE( pts_value, pts_value_l ) |
---|
2854 | |
---|
2855 | CALL cpu_log( log_point(36), 'data_output_ptseries', 'stop' ) |
---|
2856 | |
---|
2857 | END SUBROUTINE lpm_data_output_ptseries |
---|
2858 | |
---|
2859 | |
---|
2860 | !------------------------------------------------------------------------------! |
---|
2861 | ! Description: |
---|
2862 | ! ------------ |
---|
2863 | !> This routine reads the respective restart data for the lpm. |
---|
2864 | !------------------------------------------------------------------------------! |
---|
2865 | SUBROUTINE lpm_rrd_local_particles |
---|
2866 | |
---|
2867 | CHARACTER (LEN=10) :: particle_binary_version !< |
---|
2868 | CHARACTER (LEN=10) :: version_on_file !< |
---|
2869 | |
---|
2870 | INTEGER(iwp) :: alloc_size !< |
---|
2871 | INTEGER(iwp) :: ip !< |
---|
2872 | INTEGER(iwp) :: jp !< |
---|
2873 | INTEGER(iwp) :: kp !< |
---|
2874 | |
---|
2875 | TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !< |
---|
2876 | |
---|
2877 | ! |
---|
2878 | !-- Read particle data from previous model run. |
---|
2879 | !-- First open the input unit. |
---|
2880 | IF ( myid_char == '' ) THEN |
---|
2881 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN'//myid_char, & |
---|
2882 | FORM='UNFORMATTED' ) |
---|
2883 | ELSE |
---|
2884 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN/'//myid_char, & |
---|
2885 | FORM='UNFORMATTED' ) |
---|
2886 | ENDIF |
---|
2887 | |
---|
2888 | ! |
---|
2889 | !-- First compare the version numbers |
---|
2890 | READ ( 90 ) version_on_file |
---|
2891 | particle_binary_version = '4.0' |
---|
2892 | IF ( TRIM( version_on_file ) /= TRIM( particle_binary_version ) ) THEN |
---|
2893 | message_string = 'version mismatch concerning data from prior ' // & |
---|
2894 | 'run &version on file = "' // & |
---|
2895 | TRIM( version_on_file ) // & |
---|
2896 | '&version in program = "' // & |
---|
2897 | TRIM( particle_binary_version ) // '"' |
---|
2898 | CALL message( 'lpm_read_restart_file', 'PA0214', 1, 2, 0, 6, 0 ) |
---|
2899 | ENDIF |
---|
2900 | |
---|
2901 | ! |
---|
2902 | !-- If less particles are stored on the restart file than prescribed by |
---|
2903 | !-- 1, the remainder is initialized by zero_particle to avoid |
---|
2904 | !-- errors. |
---|
2905 | zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
2906 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
2907 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
2908 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
2909 | 0, 0, 0_idp, .FALSE., -1 ) |
---|
2910 | ! |
---|
2911 | !-- Read some particle parameters and the size of the particle arrays, |
---|
2912 | !-- allocate them and read their contents. |
---|
2913 | READ ( 90 ) bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, & |
---|
2914 | last_particle_release_time, number_of_particle_groups, & |
---|
2915 | particle_groups, time_write_particle_data |
---|
2916 | |
---|
2917 | ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
2918 | grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
2919 | |
---|
2920 | READ ( 90 ) prt_count |
---|
2921 | |
---|
2922 | DO ip = nxl, nxr |
---|
2923 | DO jp = nys, nyn |
---|
2924 | DO kp = nzb+1, nzt |
---|
2925 | |
---|
2926 | number_of_particles = prt_count(kp,jp,ip) |
---|
2927 | IF ( number_of_particles > 0 ) THEN |
---|
2928 | alloc_size = MAX( INT( number_of_particles * & |
---|
2929 | ( 1.0_wp + alloc_factor / 100.0_wp ) ), & |
---|
2930 | 1 ) |
---|
2931 | ELSE |
---|
2932 | alloc_size = 1 |
---|
2933 | ENDIF |
---|
2934 | |
---|
2935 | ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) ) |
---|
2936 | |
---|
2937 | IF ( number_of_particles > 0 ) THEN |
---|
2938 | ALLOCATE( tmp_particles(1:number_of_particles) ) |
---|
2939 | READ ( 90 ) tmp_particles |
---|
2940 | grid_particles(kp,jp,ip)%particles(1:number_of_particles) = tmp_particles |
---|
2941 | DEALLOCATE( tmp_particles ) |
---|
2942 | IF ( number_of_particles < alloc_size ) THEN |
---|
2943 | grid_particles(kp,jp,ip)%particles(number_of_particles+1:alloc_size) & |
---|
2944 | = zero_particle |
---|
2945 | ENDIF |
---|
2946 | ELSE |
---|
2947 | grid_particles(kp,jp,ip)%particles(1:alloc_size) = zero_particle |
---|
2948 | ENDIF |
---|
2949 | |
---|
2950 | ENDDO |
---|
2951 | ENDDO |
---|
2952 | ENDDO |
---|
2953 | |
---|
2954 | CLOSE ( 90 ) |
---|
2955 | ! |
---|
2956 | !-- Must be called to sort particles into blocks, which is needed for a fast |
---|
2957 | !-- interpolation of the LES fields on the particle position. |
---|
2958 | CALL lpm_sort_and_delete |
---|
2959 | |
---|
2960 | |
---|
2961 | END SUBROUTINE lpm_rrd_local_particles |
---|
2962 | |
---|
2963 | |
---|
2964 | SUBROUTINE lpm_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & |
---|
2965 | nxr_on_file, nynf, nync, nyn_on_file, nysf, & |
---|
2966 | nysc, nys_on_file, tmp_3d, found ) |
---|
2967 | |
---|
2968 | |
---|
2969 | USE control_parameters, & |
---|
2970 | ONLY: length, restart_string |
---|
2971 | |
---|
2972 | INTEGER(iwp) :: k !< |
---|
2973 | INTEGER(iwp) :: nxlc !< |
---|
2974 | INTEGER(iwp) :: nxlf !< |
---|
2975 | INTEGER(iwp) :: nxl_on_file !< |
---|
2976 | INTEGER(iwp) :: nxrc !< |
---|
2977 | INTEGER(iwp) :: nxrf !< |
---|
2978 | INTEGER(iwp) :: nxr_on_file !< |
---|
2979 | INTEGER(iwp) :: nync !< |
---|
2980 | INTEGER(iwp) :: nynf !< |
---|
2981 | INTEGER(iwp) :: nyn_on_file !< |
---|
2982 | INTEGER(iwp) :: nysc !< |
---|
2983 | INTEGER(iwp) :: nysf !< |
---|
2984 | INTEGER(iwp) :: nys_on_file !< |
---|
2985 | |
---|
2986 | LOGICAL, INTENT(OUT) :: found |
---|
2987 | |
---|
2988 | REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d !< |
---|
2989 | |
---|
2990 | |
---|
2991 | found = .TRUE. |
---|
2992 | |
---|
2993 | SELECT CASE ( restart_string(1:length) ) |
---|
2994 | |
---|
2995 | CASE ( 'iran' ) ! matching random numbers is still unresolved issue |
---|
2996 | IF ( k == 1 ) READ ( 13 ) iran, iran_part |
---|
2997 | |
---|
2998 | CASE ( 'pc_av' ) |
---|
2999 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
3000 | ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
3001 | ENDIF |
---|
3002 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
3003 | pc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
3004 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
3005 | |
---|
3006 | CASE ( 'pr_av' ) |
---|
3007 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
3008 | ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
3009 | ENDIF |
---|
3010 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
3011 | pr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
3012 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
3013 | |
---|
3014 | CASE ( 'ql_c_av' ) |
---|
3015 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
3016 | ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
3017 | ENDIF |
---|
3018 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
3019 | ql_c_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
3020 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
3021 | |
---|
3022 | CASE ( 'ql_v_av' ) |
---|
3023 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
3024 | ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
3025 | ENDIF |
---|
3026 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
3027 | ql_v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
3028 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
3029 | |
---|
3030 | CASE ( 'ql_vp_av' ) |
---|
3031 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
3032 | ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
3033 | ENDIF |
---|
3034 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
3035 | ql_vp_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
3036 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
3037 | |
---|
3038 | CASE DEFAULT |
---|
3039 | |
---|
3040 | found = .FALSE. |
---|
3041 | |
---|
3042 | END SELECT |
---|
3043 | |
---|
3044 | |
---|
3045 | END SUBROUTINE lpm_rrd_local |
---|
3046 | |
---|
3047 | !------------------------------------------------------------------------------! |
---|
3048 | ! Description: |
---|
3049 | ! ------------ |
---|
3050 | !> This routine writes the respective restart data for the lpm. |
---|
3051 | !------------------------------------------------------------------------------! |
---|
3052 | SUBROUTINE lpm_wrd_local |
---|
3053 | |
---|
3054 | CHARACTER (LEN=10) :: particle_binary_version !< |
---|
3055 | |
---|
3056 | INTEGER(iwp) :: ip !< |
---|
3057 | INTEGER(iwp) :: jp !< |
---|
3058 | INTEGER(iwp) :: kp !< |
---|
3059 | ! |
---|
3060 | !-- First open the output unit. |
---|
3061 | IF ( myid_char == '' ) THEN |
---|
3062 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT'//myid_char, & |
---|
3063 | FORM='UNFORMATTED') |
---|
3064 | ELSE |
---|
3065 | IF ( myid == 0 ) CALL local_system( 'mkdir PARTICLE_RESTART_DATA_OUT' ) |
---|
3066 | #if defined( __parallel ) |
---|
3067 | ! |
---|
3068 | !-- Set a barrier in order to allow that thereafter all other processors |
---|
3069 | !-- in the directory created by PE0 can open their file |
---|
3070 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
3071 | #endif |
---|
3072 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT/'//myid_char, & |
---|
3073 | FORM='UNFORMATTED' ) |
---|
3074 | ENDIF |
---|
3075 | |
---|
3076 | ! |
---|
3077 | !-- Write the version number of the binary format. |
---|
3078 | !-- Attention: After changes to the following output commands the version |
---|
3079 | !-- --------- number of the variable particle_binary_version must be |
---|
3080 | !-- changed! Also, the version number and the list of arrays |
---|
3081 | !-- to be read in lpm_read_restart_file must be adjusted |
---|
3082 | !-- accordingly. |
---|
3083 | particle_binary_version = '4.0' |
---|
3084 | WRITE ( 90 ) particle_binary_version |
---|
3085 | |
---|
3086 | ! |
---|
3087 | !-- Write some particle parameters, the size of the particle arrays |
---|
3088 | WRITE ( 90 ) bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, & |
---|
3089 | last_particle_release_time, number_of_particle_groups, & |
---|
3090 | particle_groups, time_write_particle_data |
---|
3091 | |
---|
3092 | WRITE ( 90 ) prt_count |
---|
3093 | |
---|
3094 | DO ip = nxl, nxr |
---|
3095 | DO jp = nys, nyn |
---|
3096 | DO kp = nzb+1, nzt |
---|
3097 | number_of_particles = prt_count(kp,jp,ip) |
---|
3098 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
3099 | IF ( number_of_particles <= 0 ) CYCLE |
---|
3100 | WRITE ( 90 ) particles |
---|
3101 | ENDDO |
---|
3102 | ENDDO |
---|
3103 | ENDDO |
---|
3104 | |
---|
3105 | CLOSE ( 90 ) |
---|
3106 | |
---|
3107 | #if defined( __parallel ) |
---|
3108 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
3109 | #endif |
---|
3110 | |
---|
3111 | CALL wrd_write_string( 'iran' ) |
---|
3112 | WRITE ( 14 ) iran, iran_part |
---|
3113 | |
---|
3114 | |
---|
3115 | END SUBROUTINE lpm_wrd_local |
---|
3116 | |
---|
3117 | |
---|
3118 | !------------------------------------------------------------------------------! |
---|
3119 | ! Description: |
---|
3120 | ! ------------ |
---|
3121 | !> This routine writes the respective restart data for the lpm. |
---|
3122 | !------------------------------------------------------------------------------! |
---|
3123 | SUBROUTINE lpm_wrd_global |
---|
3124 | |
---|
3125 | CALL wrd_write_string( 'curvature_solution_effects' ) |
---|
3126 | WRITE ( 14 ) curvature_solution_effects |
---|
3127 | |
---|
3128 | CALL wrd_write_string( 'interpolation_simple_corrector' ) |
---|
3129 | WRITE ( 14 ) interpolation_simple_corrector |
---|
3130 | |
---|
3131 | CALL wrd_write_string( 'interpolation_simple_predictor' ) |
---|
3132 | WRITE ( 14 ) interpolation_simple_predictor |
---|
3133 | |
---|
3134 | CALL wrd_write_string( 'interpolation_trilinear' ) |
---|
3135 | WRITE ( 14 ) interpolation_trilinear |
---|
3136 | |
---|
3137 | END SUBROUTINE lpm_wrd_global |
---|
3138 | |
---|
3139 | |
---|
3140 | !------------------------------------------------------------------------------! |
---|
3141 | ! Description: |
---|
3142 | ! ------------ |
---|
3143 | !> This routine writes the respective restart data for the lpm. |
---|
3144 | !------------------------------------------------------------------------------! |
---|
3145 | SUBROUTINE lpm_rrd_global( found ) |
---|
3146 | |
---|
3147 | USE control_parameters, & |
---|
3148 | ONLY: length, restart_string |
---|
3149 | |
---|
3150 | LOGICAL, INTENT(OUT) :: found |
---|
3151 | |
---|
3152 | found = .TRUE. |
---|
3153 | |
---|
3154 | SELECT CASE ( restart_string(1:length) ) |
---|
3155 | |
---|
3156 | CASE ( 'curvature_solution_effects' ) |
---|
3157 | READ ( 13 ) curvature_solution_effects |
---|
3158 | |
---|
3159 | CASE ( 'interpolation_simple_corrector' ) |
---|
3160 | READ ( 13 ) interpolation_simple_corrector |
---|
3161 | |
---|
3162 | CASE ( 'interpolation_simple_predictor' ) |
---|
3163 | READ ( 13 ) interpolation_simple_predictor |
---|
3164 | |
---|
3165 | CASE ( 'interpolation_trilinear' ) |
---|
3166 | READ ( 13 ) interpolation_trilinear |
---|
3167 | |
---|
3168 | ! CASE ( 'global_paramter' ) |
---|
3169 | ! READ ( 13 ) global_parameter |
---|
3170 | ! CASE ( 'global_array' ) |
---|
3171 | ! IF ( .NOT. ALLOCATED( global_array ) ) ALLOCATE( global_array(1:10) ) |
---|
3172 | ! READ ( 13 ) global_array |
---|
3173 | |
---|
3174 | CASE DEFAULT |
---|
3175 | |
---|
3176 | found = .FALSE. |
---|
3177 | |
---|
3178 | END SELECT |
---|
3179 | |
---|
3180 | END SUBROUTINE lpm_rrd_global |
---|
3181 | |
---|
3182 | |
---|
3183 | !------------------------------------------------------------------------------! |
---|
3184 | ! Description: |
---|
3185 | ! ------------ |
---|
3186 | !> This is a submodule of the lagrangian particle model. It contains all |
---|
3187 | !> dynamic processes of the lpm. This includes the advection (resolved and sub- |
---|
3188 | !> grid scale) as well as the boundary conditions of particles. As a next step |
---|
3189 | !> this submodule should be excluded as an own file. |
---|
3190 | !------------------------------------------------------------------------------! |
---|
3191 | SUBROUTINE lpm_advec (ip,jp,kp) |
---|
3192 | |
---|
3193 | LOGICAL :: subbox_at_wall !< flag to see if the current subgridbox is adjacent to a wall |
---|
3194 | |
---|
3195 | INTEGER(iwp) :: i !< index variable along x |
---|
3196 | INTEGER(iwp) :: i_next !< index variable along x |
---|
3197 | INTEGER(iwp) :: ip !< index variable along x |
---|
3198 | INTEGER(iwp) :: iteration_steps = 1 !< amount of iterations steps for corrector step |
---|
3199 | INTEGER(iwp) :: j !< index variable along y |
---|
3200 | INTEGER(iwp) :: j_next !< index variable along y |
---|
3201 | INTEGER(iwp) :: jp !< index variable along y |
---|
3202 | INTEGER(iwp) :: k !< index variable along z |
---|
3203 | INTEGER(iwp) :: k_wall !< vertical index of topography top |
---|
3204 | INTEGER(iwp) :: kp !< index variable along z |
---|
3205 | INTEGER(iwp) :: k_next !< index variable along z |
---|
3206 | INTEGER(iwp) :: kw !< index variable along z |
---|
3207 | INTEGER(iwp) :: kkw !< index variable along z |
---|
3208 | INTEGER(iwp) :: n !< loop variable over all particles in a grid box |
---|
3209 | INTEGER(iwp) :: nb !< block number particles are sorted in |
---|
3210 | INTEGER(iwp) :: particle_end !< end index for partilce loop |
---|
3211 | INTEGER(iwp) :: particle_start !< start index for particle loop |
---|
3212 | INTEGER(iwp) :: surf_start !< Index on surface data-type for current grid box |
---|
3213 | INTEGER(iwp) :: subbox_end !< end index for loop over subboxes in particle advection |
---|
3214 | INTEGER(iwp) :: subbox_start !< start index for loop over subboxes in particle advection |
---|
3215 | INTEGER(iwp) :: nn !< loop variable over iterations steps |
---|
3216 | |
---|
3217 | INTEGER(iwp), DIMENSION(0:7) :: start_index !< start particle index for current block |
---|
3218 | INTEGER(iwp), DIMENSION(0:7) :: end_index !< start particle index for current block |
---|
3219 | |
---|
3220 | REAL(wp) :: aa !< dummy argument for horizontal particle interpolation |
---|
3221 | REAL(wp) :: alpha !< interpolation facor for x-direction |
---|
3222 | |
---|
3223 | REAL(wp) :: bb !< dummy argument for horizontal particle interpolation |
---|
3224 | REAL(wp) :: beta !< interpolation facor for y-direction |
---|
3225 | REAL(wp) :: cc !< dummy argument for horizontal particle interpolation |
---|
3226 | REAL(wp) :: d_z_p_z0 !< inverse of interpolation length for logarithmic interpolation |
---|
3227 | REAL(wp) :: dd !< dummy argument for horizontal particle interpolation |
---|
3228 | REAL(wp) :: de_dx_int_l !< x/y-interpolated TKE gradient (x) at particle position at lower vertical level |
---|
3229 | REAL(wp) :: de_dx_int_u !< x/y-interpolated TKE gradient (x) at particle position at upper vertical level |
---|
3230 | REAL(wp) :: de_dy_int_l !< x/y-interpolated TKE gradient (y) at particle position at lower vertical level |
---|
3231 | REAL(wp) :: de_dy_int_u !< x/y-interpolated TKE gradient (y) at particle position at upper vertical level |
---|
3232 | REAL(wp) :: de_dt !< temporal derivative of TKE experienced by the particle |
---|
3233 | REAL(wp) :: de_dt_min !< lower level for temporal TKE derivative |
---|
3234 | REAL(wp) :: de_dz_int_l !< x/y-interpolated TKE gradient (z) at particle position at lower vertical level |
---|
3235 | REAL(wp) :: de_dz_int_u !< x/y-interpolated TKE gradient (z) at particle position at upper vertical level |
---|
3236 | REAL(wp) :: diameter !< diamter of droplet |
---|
3237 | REAL(wp) :: diss_int_l !< x/y-interpolated dissipation at particle position at lower vertical level |
---|
3238 | REAL(wp) :: diss_int_u !< x/y-interpolated dissipation at particle position at upper vertical level |
---|
3239 | REAL(wp) :: dt_particle_m !< previous particle time step |
---|
3240 | REAL(wp) :: dz_temp !< dummy for the vertical grid spacing |
---|
3241 | REAL(wp) :: e_int_l !< x/y-interpolated TKE at particle position at lower vertical level |
---|
3242 | REAL(wp) :: e_int_u !< x/y-interpolated TKE at particle position at upper vertical level |
---|
3243 | REAL(wp) :: e_mean_int !< horizontal mean TKE at particle height |
---|
3244 | REAL(wp) :: exp_arg !< argument in the exponent - particle radius |
---|
3245 | REAL(wp) :: exp_term !< exponent term |
---|
3246 | REAL(wp) :: gamma !< interpolation facor for z-direction |
---|
3247 | REAL(wp) :: gg !< dummy argument for horizontal particle interpolation |
---|
3248 | REAL(wp) :: height_p !< dummy argument for logarithmic interpolation |
---|
3249 | REAL(wp) :: log_z_z0_int !< logarithmus used for surface_layer interpolation |
---|
3250 | REAL(wp) :: random_gauss !< Gaussian-distributed random number used for SGS particle advection |
---|
3251 | REAL(wp) :: RL !< Lagrangian autocorrelation coefficient |
---|
3252 | REAL(wp) :: rg1 !< Gaussian distributed random number |
---|
3253 | REAL(wp) :: rg2 !< Gaussian distributed random number |
---|
3254 | REAL(wp) :: rg3 !< Gaussian distributed random number |
---|
3255 | REAL(wp) :: sigma !< velocity standard deviation |
---|
3256 | REAL(wp) :: u_int_l !< x/y-interpolated u-component at particle position at lower vertical level |
---|
3257 | REAL(wp) :: u_int_u !< x/y-interpolated u-component at particle position at upper vertical level |
---|
3258 | REAL(wp) :: unext !< calculated particle u-velocity of corrector step |
---|
3259 | REAL(wp) :: us_int !< friction velocity at particle grid box |
---|
3260 | REAL(wp) :: usws_int !< surface momentum flux (u component) at particle grid box |
---|
3261 | REAL(wp) :: v_int_l !< x/y-interpolated v-component at particle position at lower vertical level |
---|
3262 | REAL(wp) :: v_int_u !< x/y-interpolated v-component at particle position at upper vertical level |
---|
3263 | REAL(wp) :: vsws_int !< surface momentum flux (u component) at particle grid box |
---|
3264 | REAL(wp) :: vnext !< calculated particle v-velocity of corrector step |
---|
3265 | REAL(wp) :: vv_int !< dummy to compute interpolated mean SGS TKE, used to scale SGS advection |
---|
3266 | REAL(wp) :: w_int_l !< x/y-interpolated w-component at particle position at lower vertical level |
---|
3267 | REAL(wp) :: w_int_u !< x/y-interpolated w-component at particle position at upper vertical level |
---|
3268 | REAL(wp) :: wnext !< calculated particle w-velocity of corrector step |
---|
3269 | REAL(wp) :: w_s !< terminal velocity of droplets |
---|
3270 | REAL(wp) :: x !< dummy argument for horizontal particle interpolation |
---|
3271 | REAL(wp) :: xp !< calculated particle position in x of predictor step |
---|
3272 | REAL(wp) :: y !< dummy argument for horizontal particle interpolation |
---|
3273 | REAL(wp) :: yp !< calculated particle position in y of predictor step |
---|
3274 | REAL(wp) :: z_p !< surface layer height (0.5 dz) |
---|
3275 | REAL(wp) :: zp !< calculated particle position in z of predictor step |
---|
3276 | |
---|
3277 | REAL(wp), PARAMETER :: a_rog = 9.65_wp !< parameter for fall velocity |
---|
3278 | REAL(wp), PARAMETER :: b_rog = 10.43_wp !< parameter for fall velocity |
---|
3279 | REAL(wp), PARAMETER :: c_rog = 0.6_wp !< parameter for fall velocity |
---|
3280 | REAL(wp), PARAMETER :: k_cap_rog = 4.0_wp !< parameter for fall velocity |
---|
3281 | REAL(wp), PARAMETER :: k_low_rog = 12.0_wp !< parameter for fall velocity |
---|
3282 | REAL(wp), PARAMETER :: d0_rog = 0.745_wp !< separation diameter |
---|
3283 | |
---|
3284 | REAL(wp), DIMENSION(number_of_particles) :: term_1_2 !< flag to communicate whether a particle is near topography or not |
---|
3285 | REAL(wp), DIMENSION(number_of_particles) :: dens_ratio !< ratio between the density of the fluid and the density of the particles |
---|
3286 | REAL(wp), DIMENSION(number_of_particles) :: de_dx_int !< horizontal TKE gradient along x at particle position |
---|
3287 | REAL(wp), DIMENSION(number_of_particles) :: de_dy_int !< horizontal TKE gradient along y at particle position |
---|
3288 | REAL(wp), DIMENSION(number_of_particles) :: de_dz_int !< horizontal TKE gradient along z at particle position |
---|
3289 | REAL(wp), DIMENSION(number_of_particles) :: diss_int !< dissipation at particle position |
---|
3290 | REAL(wp), DIMENSION(number_of_particles) :: dt_gap !< remaining time until particle time integration reaches LES time |
---|
3291 | REAL(wp), DIMENSION(number_of_particles) :: dt_particle !< particle time step |
---|
3292 | REAL(wp), DIMENSION(number_of_particles) :: e_int !< TKE at particle position |
---|
3293 | REAL(wp), DIMENSION(number_of_particles) :: fs_int !< weighting factor for subgrid-scale particle speed |
---|
3294 | REAL(wp), DIMENSION(number_of_particles) :: lagr_timescale !< Lagrangian timescale |
---|
3295 | REAL(wp), DIMENSION(number_of_particles) :: rvar1_temp !< SGS particle velocity - u-component |
---|
3296 | REAL(wp), DIMENSION(number_of_particles) :: rvar2_temp !< SGS particle velocity - v-component |
---|
3297 | REAL(wp), DIMENSION(number_of_particles) :: rvar3_temp !< SGS particle velocity - w-component |
---|
3298 | REAL(wp), DIMENSION(number_of_particles) :: u_int !< u-component of particle speed |
---|
3299 | REAL(wp), DIMENSION(number_of_particles) :: v_int !< v-component of particle speed |
---|
3300 | REAL(wp), DIMENSION(number_of_particles) :: w_int !< w-component of particle speed |
---|
3301 | REAL(wp), DIMENSION(number_of_particles) :: xv !< x-position |
---|
3302 | REAL(wp), DIMENSION(number_of_particles) :: yv !< y-position |
---|
3303 | REAL(wp), DIMENSION(number_of_particles) :: zv !< z-position |
---|
3304 | |
---|
3305 | REAL(wp), DIMENSION(number_of_particles, 3) :: rg !< vector of Gaussian distributed random numbers |
---|
3306 | |
---|
3307 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'continue' ) |
---|
3308 | ! |
---|
3309 | !-- Determine height of Prandtl layer and distance between Prandtl-layer |
---|
3310 | !-- height and horizontal mean roughness height, which are required for |
---|
3311 | !-- vertical logarithmic interpolation of horizontal particle speeds |
---|
3312 | !-- (for particles below first vertical grid level). |
---|
3313 | z_p = zu(nzb+1) - zw(nzb) |
---|
3314 | d_z_p_z0 = 1.0_wp / ( z_p - z0_av_global ) |
---|
3315 | |
---|
3316 | xv = particles(1:number_of_particles)%x |
---|
3317 | yv = particles(1:number_of_particles)%y |
---|
3318 | zv = particles(1:number_of_particles)%z |
---|
3319 | dt_particle = dt_3d |
---|
3320 | |
---|
3321 | ! |
---|
3322 | !-- This case uses a simple interpolation method for the particle velocites, |
---|
3323 | !-- and applying a predictor-corrector method. @note the current time divergence |
---|
3324 | !-- free time step is denoted with u_t etc.; the velocities of the time level of |
---|
3325 | !-- t+1 wit u,v, and w, as the model is called after swap timelevel |
---|
3326 | !-- @attention: for the corrector step the velocities of t(n+1) are required. |
---|
3327 | !-- Therefore the particle code is executed at the end of the time intermediate |
---|
3328 | !-- timestep routine. This interpolation method is described in more detail |
---|
3329 | !-- in Grabowski et al., 2018 (GMD). |
---|
3330 | IF ( interpolation_simple_corrector ) THEN |
---|
3331 | ! |
---|
3332 | !-- Predictor step |
---|
3333 | kkw = kp - 1 |
---|
3334 | DO n = 1, number_of_particles |
---|
3335 | |
---|
3336 | alpha = MAX( MIN( ( particles(n)%x - ip * dx ) * ddx, 1.0_wp ), 0.0_wp ) |
---|
3337 | u_int(n) = u_t(kp,jp,ip) * ( 1.0_wp - alpha ) + u_t(kp,jp,ip+1) * alpha |
---|
3338 | |
---|
3339 | beta = MAX( MIN( ( particles(n)%y - jp * dy ) * ddy, 1.0_wp ), 0.0_wp ) |
---|
3340 | v_int(n) = v_t(kp,jp,ip) * ( 1.0_wp - beta ) + v_t(kp,jp+1,ip) * beta |
---|
3341 | |
---|
3342 | gamma = MAX( MIN( ( particles(n)%z - zw(kkw) ) / & |
---|
3343 | ( zw(kkw+1) - zw(kkw) ), 1.0_wp ), 0.0_wp ) |
---|
3344 | w_int(n) = w_t(kkw,jp,ip) * ( 1.0_wp - gamma ) + w_t(kkw+1,jp,ip) * gamma |
---|
3345 | |
---|
3346 | ENDDO |
---|
3347 | ! |
---|
3348 | !-- Corrector step |
---|
3349 | DO n = 1, number_of_particles |
---|
3350 | |
---|
3351 | IF ( .NOT. particles(n)%particle_mask ) CYCLE |
---|
3352 | |
---|
3353 | DO nn = 1, iteration_steps |
---|
3354 | |
---|
3355 | ! |
---|
3356 | !-- Guess new position |
---|
3357 | xp = particles(n)%x + u_int(n) * dt_particle(n) |
---|
3358 | yp = particles(n)%y + v_int(n) * dt_particle(n) |
---|
3359 | zp = particles(n)%z + w_int(n) * dt_particle(n) |
---|
3360 | ! |
---|
3361 | !-- x direction |
---|
3362 | i_next = FLOOR( xp * ddx , KIND=iwp) |
---|
3363 | alpha = MAX( MIN( ( xp - i_next * dx ) * ddx, 1.0_wp ), 0.0_wp ) |
---|
3364 | ! |
---|
3365 | !-- y direction |
---|
3366 | j_next = FLOOR( yp * ddy ) |
---|
3367 | beta = MAX( MIN( ( yp - j_next * dy ) * ddy, 1.0_wp ), 0.0_wp ) |
---|
3368 | ! |
---|
3369 | !-- z_direction |
---|
3370 | k_next = MAX( MIN( FLOOR( zp / (zw(kkw+1)-zw(kkw)) + offset_ocean_nzt ), nzt ), 0) |
---|
3371 | gamma = MAX( MIN( ( zp - zw(k_next) ) / & |
---|
3372 | ( zw(k_next+1) - zw(k_next) ), 1.0_wp ), 0.0_wp ) |
---|
3373 | ! |
---|
3374 | !-- Calculate part of the corrector step |
---|
3375 | unext = u(k_next+1, j_next, i_next) * ( 1.0_wp - alpha ) + & |
---|
3376 | u(k_next+1, j_next, i_next+1) * alpha |
---|
3377 | |
---|
3378 | vnext = v(k_next+1, j_next, i_next) * ( 1.0_wp - beta ) + & |
---|
3379 | v(k_next+1, j_next+1, i_next ) * beta |
---|
3380 | |
---|
3381 | wnext = w(k_next, j_next, i_next) * ( 1.0_wp - gamma ) + & |
---|
3382 | w(k_next+1, j_next, i_next ) * gamma |
---|
3383 | |
---|
3384 | ! |
---|
3385 | !-- Calculate interpolated particle velocity with predictor |
---|
3386 | !-- corrector step. u_int, v_int and w_int describes the part of |
---|
3387 | !-- the predictor step. unext, vnext and wnext is the part of the |
---|
3388 | !-- corrector step. The resulting new position is set below. The |
---|
3389 | !-- implementation is based on Grabowski et al., 2018 (GMD). |
---|
3390 | u_int(n) = 0.5_wp * ( u_int(n) + unext ) |
---|
3391 | v_int(n) = 0.5_wp * ( v_int(n) + vnext ) |
---|
3392 | w_int(n) = 0.5_wp * ( w_int(n) + wnext ) |
---|
3393 | |
---|
3394 | ENDDO |
---|
3395 | ENDDO |
---|
3396 | ! |
---|
3397 | !-- This case uses a simple interpolation method for the particle velocites, |
---|
3398 | !-- and applying a predictor. |
---|
3399 | ELSEIF ( interpolation_simple_predictor ) THEN |
---|
3400 | ! |
---|
3401 | !-- The particle position for the w velociy is based on the value of kp and kp-1 |
---|
3402 | kkw = kp - 1 |
---|
3403 | DO n = 1, number_of_particles |
---|
3404 | IF ( .NOT. particles(n)%particle_mask ) CYCLE |
---|
3405 | |
---|
3406 | alpha = MAX( MIN( ( particles(n)%x - ip * dx ) * ddx, 1.0_wp ), 0.0_wp ) |
---|
3407 | u_int(n) = u(kp,jp,ip) * ( 1.0_wp - alpha ) + u(kp,jp,ip+1) * alpha |
---|
3408 | |
---|
3409 | beta = MAX( MIN( ( particles(n)%y - jp * dy ) * ddy, 1.0_wp ), 0.0_wp ) |
---|
3410 | v_int(n) = v(kp,jp,ip) * ( 1.0_wp - beta ) + v(kp,jp+1,ip) * beta |
---|
3411 | |
---|
3412 | gamma = MAX( MIN( ( particles(n)%z - zw(kkw) ) / & |
---|
3413 | ( zw(kkw+1) - zw(kkw) ), 1.0_wp ), 0.0_wp ) |
---|
3414 | w_int(n) = w(kkw,jp,ip) * ( 1.0_wp - gamma ) + w(kkw+1,jp,ip) * gamma |
---|
3415 | ENDDO |
---|
3416 | ! |
---|
3417 | !-- The trilinear interpolation. |
---|
3418 | ELSEIF ( interpolation_trilinear ) THEN |
---|
3419 | |
---|
3420 | start_index = grid_particles(kp,jp,ip)%start_index |
---|
3421 | end_index = grid_particles(kp,jp,ip)%end_index |
---|
3422 | |
---|
3423 | DO nb = 0, 7 |
---|
3424 | ! |
---|
3425 | !-- Interpolate u velocity-component |
---|
3426 | i = ip |
---|
3427 | j = jp + block_offset(nb)%j_off |
---|
3428 | k = kp + block_offset(nb)%k_off |
---|
3429 | |
---|
3430 | DO n = start_index(nb), end_index(nb) |
---|
3431 | ! |
---|
3432 | !-- Interpolation of the u velocity component onto particle position. |
---|
3433 | !-- Particles are interpolation bi-linearly in the horizontal and a |
---|
3434 | !-- linearly in the vertical. An exception is made for particles below |
---|
3435 | !-- the first vertical grid level in case of a prandtl layer. In this |
---|
3436 | !-- case the horizontal particle velocity components are determined using |
---|
3437 | !-- Monin-Obukhov relations (if branch). |
---|
3438 | !-- First, check if particle is located below first vertical grid level |
---|
3439 | !-- above topography (Prandtl-layer height) |
---|
3440 | !-- Determine vertical index of topography top |
---|
3441 | k_wall = topo_top_ind(jp,ip,0) |
---|
3442 | |
---|
3443 | IF ( constant_flux_layer .AND. zv(n) - zw(k_wall) < z_p ) THEN |
---|
3444 | ! |
---|
3445 | !-- Resolved-scale horizontal particle velocity is zero below z0. |
---|
3446 | IF ( zv(n) - zw(k_wall) < z0_av_global ) THEN |
---|
3447 | u_int(n) = 0.0_wp |
---|
3448 | ELSE |
---|
3449 | ! |
---|
3450 | !-- Determine the sublayer. Further used as index. |
---|
3451 | height_p = ( zv(n) - zw(k_wall) - z0_av_global ) & |
---|
3452 | * REAL( number_of_sublayers, KIND=wp ) & |
---|
3453 | * d_z_p_z0 |
---|
3454 | ! |
---|
3455 | !-- Calculate LOG(z/z0) for exact particle height. Therefore, |
---|
3456 | !-- interpolate linearly between precalculated logarithm. |
---|
3457 | log_z_z0_int = log_z_z0(INT(height_p)) & |
---|
3458 | + ( height_p - INT(height_p) ) & |
---|
3459 | * ( log_z_z0(INT(height_p)+1) & |
---|
3460 | - log_z_z0(INT(height_p)) & |
---|
3461 | ) |
---|
3462 | ! |
---|
3463 | !-- Get friction velocity and momentum flux from new surface data |
---|
3464 | !-- types. |
---|
3465 | IF ( surf_def_h(0)%start_index(jp,ip) <= & |
---|
3466 | surf_def_h(0)%end_index(jp,ip) ) THEN |
---|
3467 | surf_start = surf_def_h(0)%start_index(jp,ip) |
---|
3468 | !-- Limit friction velocity. In narrow canyons or holes the |
---|
3469 | !-- friction velocity can become very small, resulting in a too |
---|
3470 | !-- large particle speed. |
---|
3471 | us_int = MAX( surf_def_h(0)%us(surf_start), 0.01_wp ) |
---|
3472 | usws_int = surf_def_h(0)%usws(surf_start) |
---|
3473 | ELSEIF ( surf_lsm_h%start_index(jp,ip) <= & |
---|
3474 | surf_lsm_h%end_index(jp,ip) ) THEN |
---|
3475 | surf_start = surf_lsm_h%start_index(jp,ip) |
---|
3476 | us_int = MAX( surf_lsm_h%us(surf_start), 0.01_wp ) |
---|
3477 | usws_int = surf_lsm_h%usws(surf_start) |
---|
3478 | ELSEIF ( surf_usm_h%start_index(jp,ip) <= & |
---|
3479 | surf_usm_h%end_index(jp,ip) ) THEN |
---|
3480 | surf_start = surf_usm_h%start_index(jp,ip) |
---|
3481 | us_int = MAX( surf_usm_h%us(surf_start), 0.01_wp ) |
---|
3482 | usws_int = surf_usm_h%usws(surf_start) |
---|
3483 | ENDIF |
---|
3484 | ! |
---|
3485 | !-- Neutral solution is applied for all situations, e.g. also for |
---|
3486 | !-- unstable and stable situations. Even though this is not exact |
---|
3487 | !-- this saves a lot of CPU time since several calls of intrinsic |
---|
3488 | !-- FORTRAN procedures (LOG, ATAN) are avoided, This is justified |
---|
3489 | !-- as sensitivity studies revealed no significant effect of |
---|
3490 | !-- using the neutral solution also for un/stable situations. |
---|
3491 | u_int(n) = -usws_int / ( us_int * kappa + 1E-10_wp ) & |
---|
3492 | * log_z_z0_int - u_gtrans |
---|
3493 | ENDIF |
---|
3494 | ! |
---|
3495 | !-- Particle above the first grid level. Bi-linear interpolation in the |
---|
3496 | !-- horizontal and linear interpolation in the vertical direction. |
---|
3497 | ELSE |
---|
3498 | x = xv(n) - i * dx |
---|
3499 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
3500 | aa = x**2 + y**2 |
---|
3501 | bb = ( dx - x )**2 + y**2 |
---|
3502 | cc = x**2 + ( dy - y )**2 |
---|
3503 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
3504 | gg = aa + bb + cc + dd |
---|
3505 | |
---|
3506 | u_int_l = ( ( gg - aa ) * u(k,j,i) + ( gg - bb ) * u(k,j,i+1) & |
---|
3507 | + ( gg - cc ) * u(k,j+1,i) + ( gg - dd ) * & |
---|
3508 | u(k,j+1,i+1) ) / ( 3.0_wp * gg ) - u_gtrans |
---|
3509 | |
---|
3510 | IF ( k == nzt ) THEN |
---|
3511 | u_int(n) = u_int_l |
---|
3512 | ELSE |
---|
3513 | u_int_u = ( ( gg-aa ) * u(k+1,j,i) + ( gg-bb ) * u(k+1,j,i+1) & |
---|
3514 | + ( gg-cc ) * u(k+1,j+1,i) + ( gg-dd ) * & |
---|
3515 | u(k+1,j+1,i+1) ) / ( 3.0_wp * gg ) - u_gtrans |
---|
3516 | u_int(n) = u_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3517 | ( u_int_u - u_int_l ) |
---|
3518 | ENDIF |
---|
3519 | ENDIF |
---|
3520 | ENDDO |
---|
3521 | ! |
---|
3522 | !-- Same procedure for interpolation of the v velocity-component |
---|
3523 | i = ip + block_offset(nb)%i_off |
---|
3524 | j = jp |
---|
3525 | k = kp + block_offset(nb)%k_off |
---|
3526 | |
---|
3527 | DO n = start_index(nb), end_index(nb) |
---|
3528 | ! |
---|
3529 | !-- Determine vertical index of topography top |
---|
3530 | k_wall = topo_top_ind(jp,ip,0) |
---|
3531 | |
---|
3532 | IF ( constant_flux_layer .AND. zv(n) - zw(k_wall) < z_p ) THEN |
---|
3533 | IF ( zv(n) - zw(k_wall) < z0_av_global ) THEN |
---|
3534 | ! |
---|
3535 | !-- Resolved-scale horizontal particle velocity is zero below z0. |
---|
3536 | v_int(n) = 0.0_wp |
---|
3537 | ELSE |
---|
3538 | ! |
---|
3539 | !-- Determine the sublayer. Further used as index. Please note, |
---|
3540 | !-- logarithmus can not be reused from above, as in in case of |
---|
3541 | !-- topography particle on u-grid can be above surface-layer height, |
---|
3542 | !-- whereas it can be below on v-grid. |
---|
3543 | height_p = ( zv(n) - zw(k_wall) - z0_av_global ) & |
---|
3544 | * REAL( number_of_sublayers, KIND=wp ) & |
---|
3545 | * d_z_p_z0 |
---|
3546 | ! |
---|
3547 | !-- Calculate LOG(z/z0) for exact particle height. Therefore, |
---|
3548 | !-- interpolate linearly between precalculated logarithm. |
---|
3549 | log_z_z0_int = log_z_z0(INT(height_p)) & |
---|
3550 | + ( height_p - INT(height_p) ) & |
---|
3551 | * ( log_z_z0(INT(height_p)+1) & |
---|
3552 | - log_z_z0(INT(height_p)) & |
---|
3553 | ) |
---|
3554 | ! |
---|
3555 | !-- Get friction velocity and momentum flux from new surface data |
---|
3556 | !-- types. |
---|
3557 | IF ( surf_def_h(0)%start_index(jp,ip) <= & |
---|
3558 | surf_def_h(0)%end_index(jp,ip) ) THEN |
---|
3559 | surf_start = surf_def_h(0)%start_index(jp,ip) |
---|
3560 | !-- Limit friction velocity. In narrow canyons or holes the |
---|
3561 | !-- friction velocity can become very small, resulting in a too |
---|
3562 | !-- large particle speed. |
---|
3563 | us_int = MAX( surf_def_h(0)%us(surf_start), 0.01_wp ) |
---|
3564 | vsws_int = surf_def_h(0)%vsws(surf_start) |
---|
3565 | ELSEIF ( surf_lsm_h%start_index(jp,ip) <= & |
---|
3566 | surf_lsm_h%end_index(jp,ip) ) THEN |
---|
3567 | surf_start = surf_lsm_h%start_index(jp,ip) |
---|
3568 | us_int = MAX( surf_lsm_h%us(surf_start), 0.01_wp ) |
---|
3569 | vsws_int = surf_lsm_h%vsws(surf_start) |
---|
3570 | ELSEIF ( surf_usm_h%start_index(jp,ip) <= & |
---|
3571 | surf_usm_h%end_index(jp,ip) ) THEN |
---|
3572 | surf_start = surf_usm_h%start_index(jp,ip) |
---|
3573 | us_int = MAX( surf_usm_h%us(surf_start), 0.01_wp ) |
---|
3574 | vsws_int = surf_usm_h%vsws(surf_start) |
---|
3575 | ENDIF |
---|
3576 | ! |
---|
3577 | !-- Neutral solution is applied for all situations, e.g. also for |
---|
3578 | !-- unstable and stable situations. Even though this is not exact |
---|
3579 | !-- this saves a lot of CPU time since several calls of intrinsic |
---|
3580 | !-- FORTRAN procedures (LOG, ATAN) are avoided, This is justified |
---|
3581 | !-- as sensitivity studies revealed no significant effect of |
---|
3582 | !-- using the neutral solution also for un/stable situations. |
---|
3583 | v_int(n) = -vsws_int / ( us_int * kappa + 1E-10_wp ) & |
---|
3584 | * log_z_z0_int - v_gtrans |
---|
3585 | |
---|
3586 | ENDIF |
---|
3587 | ELSE |
---|
3588 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
3589 | y = yv(n) - j * dy |
---|
3590 | aa = x**2 + y**2 |
---|
3591 | bb = ( dx - x )**2 + y**2 |
---|
3592 | cc = x**2 + ( dy - y )**2 |
---|
3593 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
3594 | gg = aa + bb + cc + dd |
---|
3595 | |
---|
3596 | v_int_l = ( ( gg - aa ) * v(k,j,i) + ( gg - bb ) * v(k,j,i+1) & |
---|
3597 | + ( gg - cc ) * v(k,j+1,i) + ( gg - dd ) * v(k,j+1,i+1) & |
---|
3598 | ) / ( 3.0_wp * gg ) - v_gtrans |
---|
3599 | |
---|
3600 | IF ( k == nzt ) THEN |
---|
3601 | v_int(n) = v_int_l |
---|
3602 | ELSE |
---|
3603 | v_int_u = ( ( gg-aa ) * v(k+1,j,i) + ( gg-bb ) * v(k+1,j,i+1) & |
---|
3604 | + ( gg-cc ) * v(k+1,j+1,i) + ( gg-dd ) * v(k+1,j+1,i+1) & |
---|
3605 | ) / ( 3.0_wp * gg ) - v_gtrans |
---|
3606 | v_int(n) = v_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3607 | ( v_int_u - v_int_l ) |
---|
3608 | ENDIF |
---|
3609 | ENDIF |
---|
3610 | ENDDO |
---|
3611 | ! |
---|
3612 | !-- Same procedure for interpolation of the w velocity-component |
---|
3613 | i = ip + block_offset(nb)%i_off |
---|
3614 | j = jp + block_offset(nb)%j_off |
---|
3615 | k = kp - 1 |
---|
3616 | |
---|
3617 | DO n = start_index(nb), end_index(nb) |
---|
3618 | IF ( vertical_particle_advection(particles(n)%group) ) THEN |
---|
3619 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
3620 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
3621 | aa = x**2 + y**2 |
---|
3622 | bb = ( dx - x )**2 + y**2 |
---|
3623 | cc = x**2 + ( dy - y )**2 |
---|
3624 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
3625 | gg = aa + bb + cc + dd |
---|
3626 | |
---|
3627 | w_int_l = ( ( gg - aa ) * w(k,j,i) + ( gg - bb ) * w(k,j,i+1) & |
---|
3628 | + ( gg - cc ) * w(k,j+1,i) + ( gg - dd ) * w(k,j+1,i+1) & |
---|
3629 | ) / ( 3.0_wp * gg ) |
---|
3630 | |
---|
3631 | IF ( k == nzt ) THEN |
---|
3632 | w_int(n) = w_int_l |
---|
3633 | ELSE |
---|
3634 | w_int_u = ( ( gg-aa ) * w(k+1,j,i) + & |
---|
3635 | ( gg-bb ) * w(k+1,j,i+1) + & |
---|
3636 | ( gg-cc ) * w(k+1,j+1,i) + & |
---|
3637 | ( gg-dd ) * w(k+1,j+1,i+1) & |
---|
3638 | ) / ( 3.0_wp * gg ) |
---|
3639 | w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) * & |
---|
3640 | ( w_int_u - w_int_l ) |
---|
3641 | ENDIF |
---|
3642 | ELSE |
---|
3643 | w_int(n) = 0.0_wp |
---|
3644 | ENDIF |
---|
3645 | ENDDO |
---|
3646 | ENDDO |
---|
3647 | ENDIF |
---|
3648 | |
---|
3649 | !-- Interpolate and calculate quantities needed for calculating the SGS |
---|
3650 | !-- velocities |
---|
3651 | IF ( use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
3652 | |
---|
3653 | DO nb = 0,7 |
---|
3654 | |
---|
3655 | subbox_at_wall = .FALSE. |
---|
3656 | ! |
---|
3657 | !-- In case of topography check if subbox is adjacent to a wall |
---|
3658 | IF ( .NOT. topography == 'flat' ) THEN |
---|
3659 | i = ip + MERGE( -1_iwp , 1_iwp, BTEST( nb, 2 ) ) |
---|
3660 | j = jp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 1 ) ) |
---|
3661 | k = kp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 0 ) ) |
---|
3662 | IF ( .NOT. BTEST(wall_flags_0(k, jp, ip), 0) .OR. & |
---|
3663 | .NOT. BTEST(wall_flags_0(kp, j, ip), 0) .OR. & |
---|
3664 | .NOT. BTEST(wall_flags_0(kp, jp, i ), 0) ) & |
---|
3665 | THEN |
---|
3666 | subbox_at_wall = .TRUE. |
---|
3667 | ENDIF |
---|
3668 | ENDIF |
---|
3669 | IF ( subbox_at_wall ) THEN |
---|
3670 | e_int(start_index(nb):end_index(nb)) = e(kp,jp,ip) |
---|
3671 | diss_int(start_index(nb):end_index(nb)) = diss(kp,jp,ip) |
---|
3672 | de_dx_int(start_index(nb):end_index(nb)) = de_dx(kp,jp,ip) |
---|
3673 | de_dy_int(start_index(nb):end_index(nb)) = de_dy(kp,jp,ip) |
---|
3674 | de_dz_int(start_index(nb):end_index(nb)) = de_dz(kp,jp,ip) |
---|
3675 | ! |
---|
3676 | !-- Set flag for stochastic equation. |
---|
3677 | term_1_2(start_index(nb):end_index(nb)) = 0.0_wp |
---|
3678 | ELSE |
---|
3679 | i = ip + block_offset(nb)%i_off |
---|
3680 | j = jp + block_offset(nb)%j_off |
---|
3681 | k = kp + block_offset(nb)%k_off |
---|
3682 | |
---|
3683 | DO n = start_index(nb), end_index(nb) |
---|
3684 | ! |
---|
3685 | !-- Interpolate TKE |
---|
3686 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
3687 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
3688 | aa = x**2 + y**2 |
---|
3689 | bb = ( dx - x )**2 + y**2 |
---|
3690 | cc = x**2 + ( dy - y )**2 |
---|
3691 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
3692 | gg = aa + bb + cc + dd |
---|
3693 | |
---|
3694 | e_int_l = ( ( gg-aa ) * e(k,j,i) + ( gg-bb ) * e(k,j,i+1) & |
---|
3695 | + ( gg-cc ) * e(k,j+1,i) + ( gg-dd ) * e(k,j+1,i+1) & |
---|
3696 | ) / ( 3.0_wp * gg ) |
---|
3697 | |
---|
3698 | IF ( k+1 == nzt+1 ) THEN |
---|
3699 | e_int(n) = e_int_l |
---|
3700 | ELSE |
---|
3701 | e_int_u = ( ( gg - aa ) * e(k+1,j,i) + & |
---|
3702 | ( gg - bb ) * e(k+1,j,i+1) + & |
---|
3703 | ( gg - cc ) * e(k+1,j+1,i) + & |
---|
3704 | ( gg - dd ) * e(k+1,j+1,i+1) & |
---|
3705 | ) / ( 3.0_wp * gg ) |
---|
3706 | e_int(n) = e_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3707 | ( e_int_u - e_int_l ) |
---|
3708 | ENDIF |
---|
3709 | ! |
---|
3710 | !-- Needed to avoid NaN particle velocities (this might not be |
---|
3711 | !-- required any more) |
---|
3712 | IF ( e_int(n) <= 0.0_wp ) THEN |
---|
3713 | e_int(n) = 1.0E-20_wp |
---|
3714 | ENDIF |
---|
3715 | ! |
---|
3716 | !-- Interpolate the TKE gradient along x (adopt incides i,j,k and |
---|
3717 | !-- all position variables from above (TKE)) |
---|
3718 | de_dx_int_l = ( ( gg - aa ) * de_dx(k,j,i) + & |
---|
3719 | ( gg - bb ) * de_dx(k,j,i+1) + & |
---|
3720 | ( gg - cc ) * de_dx(k,j+1,i) + & |
---|
3721 | ( gg - dd ) * de_dx(k,j+1,i+1) & |
---|
3722 | ) / ( 3.0_wp * gg ) |
---|
3723 | |
---|
3724 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
3725 | de_dx_int(n) = de_dx_int_l |
---|
3726 | ELSE |
---|
3727 | de_dx_int_u = ( ( gg - aa ) * de_dx(k+1,j,i) + & |
---|
3728 | ( gg - bb ) * de_dx(k+1,j,i+1) + & |
---|
3729 | ( gg - cc ) * de_dx(k+1,j+1,i) + & |
---|
3730 | ( gg - dd ) * de_dx(k+1,j+1,i+1) & |
---|
3731 | ) / ( 3.0_wp * gg ) |
---|
3732 | de_dx_int(n) = de_dx_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3733 | ( de_dx_int_u - de_dx_int_l ) |
---|
3734 | ENDIF |
---|
3735 | ! |
---|
3736 | !-- Interpolate the TKE gradient along y |
---|
3737 | de_dy_int_l = ( ( gg - aa ) * de_dy(k,j,i) + & |
---|
3738 | ( gg - bb ) * de_dy(k,j,i+1) + & |
---|
3739 | ( gg - cc ) * de_dy(k,j+1,i) + & |
---|
3740 | ( gg - dd ) * de_dy(k,j+1,i+1) & |
---|
3741 | ) / ( 3.0_wp * gg ) |
---|
3742 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
3743 | de_dy_int(n) = de_dy_int_l |
---|
3744 | ELSE |
---|
3745 | de_dy_int_u = ( ( gg - aa ) * de_dy(k+1,j,i) + & |
---|
3746 | ( gg - bb ) * de_dy(k+1,j,i+1) + & |
---|
3747 | ( gg - cc ) * de_dy(k+1,j+1,i) + & |
---|
3748 | ( gg - dd ) * de_dy(k+1,j+1,i+1) & |
---|
3749 | ) / ( 3.0_wp * gg ) |
---|
3750 | de_dy_int(n) = de_dy_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3751 | ( de_dy_int_u - de_dy_int_l ) |
---|
3752 | ENDIF |
---|
3753 | |
---|
3754 | ! |
---|
3755 | !-- Interpolate the TKE gradient along z |
---|
3756 | IF ( zv(n) < 0.5_wp * dz(1) ) THEN |
---|
3757 | de_dz_int(n) = 0.0_wp |
---|
3758 | ELSE |
---|
3759 | de_dz_int_l = ( ( gg - aa ) * de_dz(k,j,i) + & |
---|
3760 | ( gg - bb ) * de_dz(k,j,i+1) + & |
---|
3761 | ( gg - cc ) * de_dz(k,j+1,i) + & |
---|
3762 | ( gg - dd ) * de_dz(k,j+1,i+1) & |
---|
3763 | ) / ( 3.0_wp * gg ) |
---|
3764 | |
---|
3765 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
3766 | de_dz_int(n) = de_dz_int_l |
---|
3767 | ELSE |
---|
3768 | de_dz_int_u = ( ( gg - aa ) * de_dz(k+1,j,i) + & |
---|
3769 | ( gg - bb ) * de_dz(k+1,j,i+1) + & |
---|
3770 | ( gg - cc ) * de_dz(k+1,j+1,i) + & |
---|
3771 | ( gg - dd ) * de_dz(k+1,j+1,i+1) & |
---|
3772 | ) / ( 3.0_wp * gg ) |
---|
3773 | de_dz_int(n) = de_dz_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3774 | ( de_dz_int_u - de_dz_int_l ) |
---|
3775 | ENDIF |
---|
3776 | ENDIF |
---|
3777 | |
---|
3778 | ! |
---|
3779 | !-- Interpolate the dissipation of TKE |
---|
3780 | diss_int_l = ( ( gg - aa ) * diss(k,j,i) + & |
---|
3781 | ( gg - bb ) * diss(k,j,i+1) + & |
---|
3782 | ( gg - cc ) * diss(k,j+1,i) + & |
---|
3783 | ( gg - dd ) * diss(k,j+1,i+1) & |
---|
3784 | ) / ( 3.0_wp * gg ) |
---|
3785 | |
---|
3786 | IF ( k == nzt ) THEN |
---|
3787 | diss_int(n) = diss_int_l |
---|
3788 | ELSE |
---|
3789 | diss_int_u = ( ( gg - aa ) * diss(k+1,j,i) + & |
---|
3790 | ( gg - bb ) * diss(k+1,j,i+1) + & |
---|
3791 | ( gg - cc ) * diss(k+1,j+1,i) + & |
---|
3792 | ( gg - dd ) * diss(k+1,j+1,i+1) & |
---|
3793 | ) / ( 3.0_wp * gg ) |
---|
3794 | diss_int(n) = diss_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
3795 | ( diss_int_u - diss_int_l ) |
---|
3796 | ENDIF |
---|
3797 | |
---|
3798 | ! |
---|
3799 | !-- Set flag for stochastic equation. |
---|
3800 | term_1_2(n) = 1.0_wp |
---|
3801 | ENDDO |
---|
3802 | ENDIF |
---|
3803 | ENDDO |
---|
3804 | |
---|
3805 | DO nb = 0,7 |
---|
3806 | i = ip + block_offset(nb)%i_off |
---|
3807 | j = jp + block_offset(nb)%j_off |
---|
3808 | k = kp + block_offset(nb)%k_off |
---|
3809 | |
---|
3810 | DO n = start_index(nb), end_index(nb) |
---|
3811 | ! |
---|
3812 | !-- Vertical interpolation of the horizontally averaged SGS TKE and |
---|
3813 | !-- resolved-scale velocity variances and use the interpolated values |
---|
3814 | !-- to calculate the coefficient fs, which is a measure of the ratio |
---|
3815 | !-- of the subgrid-scale turbulent kinetic energy to the total amount |
---|
3816 | !-- of turbulent kinetic energy. |
---|
3817 | IF ( k == 0 ) THEN |
---|
3818 | e_mean_int = hom(0,1,8,0) |
---|
3819 | ELSE |
---|
3820 | e_mean_int = hom(k,1,8,0) + & |
---|
3821 | ( hom(k+1,1,8,0) - hom(k,1,8,0) ) / & |
---|
3822 | ( zu(k+1) - zu(k) ) * & |
---|
3823 | ( zv(n) - zu(k) ) |
---|
3824 | ENDIF |
---|
3825 | |
---|
3826 | kw = kp - 1 |
---|
3827 | |
---|
3828 | IF ( k == 0 ) THEN |
---|
3829 | aa = hom(k+1,1,30,0) * ( zv(n) / & |
---|
3830 | ( 0.5_wp * ( zu(k+1) - zu(k) ) ) ) |
---|
3831 | bb = hom(k+1,1,31,0) * ( zv(n) / & |
---|
3832 | ( 0.5_wp * ( zu(k+1) - zu(k) ) ) ) |
---|
3833 | cc = hom(kw+1,1,32,0) * ( zv(n) / & |
---|
3834 | ( 1.0_wp * ( zw(kw+1) - zw(kw) ) ) ) |
---|
3835 | ELSE |
---|
3836 | aa = hom(k,1,30,0) + ( hom(k+1,1,30,0) - hom(k,1,30,0) ) * & |
---|
3837 | ( ( zv(n) - zu(k) ) / ( zu(k+1) - zu(k) ) ) |
---|
3838 | bb = hom(k,1,31,0) + ( hom(k+1,1,31,0) - hom(k,1,31,0) ) * & |
---|
3839 | ( ( zv(n) - zu(k) ) / ( zu(k+1) - zu(k) ) ) |
---|
3840 | cc = hom(kw,1,32,0) + ( hom(kw+1,1,32,0)-hom(kw,1,32,0) ) * & |
---|
3841 | ( ( zv(n) - zw(kw) ) / ( zw(kw+1)-zw(kw) ) ) |
---|
3842 | ENDIF |
---|
3843 | |
---|
3844 | vv_int = ( 1.0_wp / 3.0_wp ) * ( aa + bb + cc ) |
---|
3845 | ! |
---|
3846 | !-- Needed to avoid NaN particle velocities. The value of 1.0 is just |
---|
3847 | !-- an educated guess for the given case. |
---|
3848 | IF ( vv_int + ( 2.0_wp / 3.0_wp ) * e_mean_int == 0.0_wp ) THEN |
---|
3849 | fs_int(n) = 1.0_wp |
---|
3850 | ELSE |
---|
3851 | fs_int(n) = ( 2.0_wp / 3.0_wp ) * e_mean_int / & |
---|
3852 | ( vv_int + ( 2.0_wp / 3.0_wp ) * e_mean_int ) |
---|
3853 | ENDIF |
---|
3854 | |
---|
3855 | ENDDO |
---|
3856 | ENDDO |
---|
3857 | |
---|
3858 | DO nb = 0, 7 |
---|
3859 | DO n = start_index(nb), end_index(nb) |
---|
3860 | rg(n,1) = random_gauss( iran_part, 5.0_wp ) |
---|
3861 | rg(n,2) = random_gauss( iran_part, 5.0_wp ) |
---|
3862 | rg(n,3) = random_gauss( iran_part, 5.0_wp ) |
---|
3863 | ENDDO |
---|
3864 | ENDDO |
---|
3865 | |
---|
3866 | DO nb = 0, 7 |
---|
3867 | DO n = start_index(nb), end_index(nb) |
---|
3868 | |
---|
3869 | ! |
---|
3870 | !-- Calculate the Lagrangian timescale according to Weil et al. (2004). |
---|
3871 | lagr_timescale(n) = ( 4.0_wp * e_int(n) + 1E-20_wp ) / & |
---|
3872 | ( 3.0_wp * fs_int(n) * c_0 * diss_int(n) + 1E-20_wp ) |
---|
3873 | |
---|
3874 | ! |
---|
3875 | !-- Calculate the next particle timestep. dt_gap is the time needed to |
---|
3876 | !-- complete the current LES timestep. |
---|
3877 | dt_gap(n) = dt_3d - particles(n)%dt_sum |
---|
3878 | dt_particle(n) = MIN( dt_3d, 0.025_wp * lagr_timescale(n), dt_gap(n) ) |
---|
3879 | particles(n)%aux1 = lagr_timescale(n) |
---|
3880 | particles(n)%aux2 = dt_gap(n) |
---|
3881 | ! |
---|
3882 | !-- The particle timestep should not be too small in order to prevent |
---|
3883 | !-- the number of particle timesteps of getting too large |
---|
3884 | IF ( dt_particle(n) < dt_min_part ) THEN |
---|
3885 | IF ( dt_min_part < dt_gap(n) ) THEN |
---|
3886 | dt_particle(n) = dt_min_part |
---|
3887 | ELSE |
---|
3888 | dt_particle(n) = dt_gap(n) |
---|
3889 | ENDIF |
---|
3890 | ENDIF |
---|
3891 | rvar1_temp(n) = particles(n)%rvar1 |
---|
3892 | rvar2_temp(n) = particles(n)%rvar2 |
---|
3893 | rvar3_temp(n) = particles(n)%rvar3 |
---|
3894 | ! |
---|
3895 | !-- Calculate the SGS velocity components |
---|
3896 | IF ( particles(n)%age == 0.0_wp ) THEN |
---|
3897 | ! |
---|
3898 | !-- For new particles the SGS components are derived from the SGS |
---|
3899 | !-- TKE. Limit the Gaussian random number to the interval |
---|
3900 | !-- [-5.0*sigma, 5.0*sigma] in order to prevent the SGS velocities |
---|
3901 | !-- from becoming unrealistically large. |
---|
3902 | rvar1_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
3903 | + 1E-20_wp ) * ( rg(n,1) - 1.0_wp ) |
---|
3904 | rvar2_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
3905 | + 1E-20_wp ) * ( rg(n,2) - 1.0_wp ) |
---|
3906 | rvar3_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
3907 | + 1E-20_wp ) * ( rg(n,3) - 1.0_wp ) |
---|
3908 | |
---|
3909 | ELSE |
---|
3910 | ! |
---|
3911 | !-- Restriction of the size of the new timestep: compared to the |
---|
3912 | !-- previous timestep the increase must not exceed 200%. First, |
---|
3913 | !-- check if age > age_m, in order to prevent that particles get zero |
---|
3914 | !-- timestep. |
---|
3915 | dt_particle_m = MERGE( dt_particle(n), & |
---|
3916 | particles(n)%age - particles(n)%age_m, & |
---|
3917 | particles(n)%age - particles(n)%age_m < & |
---|
3918 | 1E-8_wp ) |
---|
3919 | IF ( dt_particle(n) > 2.0_wp * dt_particle_m ) THEN |
---|
3920 | dt_particle(n) = 2.0_wp * dt_particle_m |
---|
3921 | ENDIF |
---|
3922 | |
---|
3923 | !-- For old particles the SGS components are correlated with the |
---|
3924 | !-- values from the previous timestep. Random numbers have also to |
---|
3925 | !-- be limited (see above). |
---|
3926 | !-- As negative values for the subgrid TKE are not allowed, the |
---|
3927 | !-- change of the subgrid TKE with time cannot be smaller than |
---|
3928 | !-- -e_int(n)/dt_particle. This value is used as a lower boundary |
---|
3929 | !-- value for the change of TKE |
---|
3930 | de_dt_min = - e_int(n) / dt_particle(n) |
---|
3931 | |
---|
3932 | de_dt = ( e_int(n) - particles(n)%e_m ) / dt_particle_m |
---|
3933 | |
---|
3934 | IF ( de_dt < de_dt_min ) THEN |
---|
3935 | de_dt = de_dt_min |
---|
3936 | ENDIF |
---|
3937 | |
---|
3938 | CALL weil_stochastic_eq( rvar1_temp(n), fs_int(n), e_int(n), & |
---|
3939 | de_dx_int(n), de_dt, diss_int(n), & |
---|
3940 | dt_particle(n), rg(n,1), term_1_2(n) ) |
---|
3941 | |
---|
3942 | CALL weil_stochastic_eq( rvar2_temp(n), fs_int(n), e_int(n), & |
---|
3943 | de_dy_int(n), de_dt, diss_int(n), & |
---|
3944 | dt_particle(n), rg(n,2), term_1_2(n) ) |
---|
3945 | |
---|
3946 | CALL weil_stochastic_eq( rvar3_temp(n), fs_int(n), e_int(n), & |
---|
3947 | de_dz_int(n), de_dt, diss_int(n), & |
---|
3948 | dt_particle(n), rg(n,3), term_1_2(n) ) |
---|
3949 | |
---|
3950 | ENDIF |
---|
3951 | |
---|
3952 | ENDDO |
---|
3953 | ENDDO |
---|
3954 | ! |
---|
3955 | !-- Check if the added SGS velocities result in a violation of the CFL- |
---|
3956 | !-- criterion. If yes choose a smaller timestep based on the new velocities |
---|
3957 | !-- and calculate SGS velocities again |
---|
3958 | dz_temp = zw(kp)-zw(kp-1) |
---|
3959 | |
---|
3960 | DO nb = 0, 7 |
---|
3961 | DO n = start_index(nb), end_index(nb) |
---|
3962 | IF ( .NOT. particles(n)%age == 0.0_wp .AND. & |
---|
3963 | (ABS( u_int(n) + rvar1_temp(n) ) > (dx/dt_particle(n)) .OR. & |
---|
3964 | ABS( v_int(n) + rvar2_temp(n) ) > (dy/dt_particle(n)) .OR. & |
---|
3965 | ABS( w_int(n) + rvar3_temp(n) ) > (dz_temp/dt_particle(n)))) THEN |
---|
3966 | |
---|
3967 | dt_particle(n) = 0.9_wp * MIN( & |
---|
3968 | ( dx / ABS( u_int(n) + rvar1_temp(n) ) ), & |
---|
3969 | ( dy / ABS( v_int(n) + rvar2_temp(n) ) ), & |
---|
3970 | ( dz_temp / ABS( w_int(n) + rvar3_temp(n) ) ) ) |
---|
3971 | |
---|
3972 | ! |
---|
3973 | !-- Reset temporary SGS velocites to "current" ones |
---|
3974 | rvar1_temp(n) = particles(n)%rvar1 |
---|
3975 | rvar2_temp(n) = particles(n)%rvar2 |
---|
3976 | rvar3_temp(n) = particles(n)%rvar3 |
---|
3977 | |
---|
3978 | de_dt_min = - e_int(n) / dt_particle(n) |
---|
3979 | |
---|
3980 | de_dt = ( e_int(n) - particles(n)%e_m ) / dt_particle_m |
---|
3981 | |
---|
3982 | IF ( de_dt < de_dt_min ) THEN |
---|
3983 | de_dt = de_dt_min |
---|
3984 | ENDIF |
---|
3985 | |
---|
3986 | CALL weil_stochastic_eq( rvar1_temp(n), fs_int(n), e_int(n), & |
---|
3987 | de_dx_int(n), de_dt, diss_int(n), & |
---|
3988 | dt_particle(n), rg(n,1), term_1_2(n) ) |
---|
3989 | |
---|
3990 | CALL weil_stochastic_eq( rvar2_temp(n), fs_int(n), e_int(n), & |
---|
3991 | de_dy_int(n), de_dt, diss_int(n), & |
---|
3992 | dt_particle(n), rg(n,2), term_1_2(n) ) |
---|
3993 | |
---|
3994 | CALL weil_stochastic_eq( rvar3_temp(n), fs_int(n), e_int(n), & |
---|
3995 | de_dz_int(n), de_dt, diss_int(n), & |
---|
3996 | dt_particle(n), rg(n,3), term_1_2(n) ) |
---|
3997 | ENDIF |
---|
3998 | |
---|
3999 | ! |
---|
4000 | !-- Update particle velocites |
---|
4001 | particles(n)%rvar1 = rvar1_temp(n) |
---|
4002 | particles(n)%rvar2 = rvar2_temp(n) |
---|
4003 | particles(n)%rvar3 = rvar3_temp(n) |
---|
4004 | u_int(n) = u_int(n) + particles(n)%rvar1 |
---|
4005 | v_int(n) = v_int(n) + particles(n)%rvar2 |
---|
4006 | w_int(n) = w_int(n) + particles(n)%rvar3 |
---|
4007 | ! |
---|
4008 | !-- Store the SGS TKE of the current timelevel which is needed for |
---|
4009 | !-- for calculating the SGS particle velocities at the next timestep |
---|
4010 | particles(n)%e_m = e_int(n) |
---|
4011 | ENDDO |
---|
4012 | ENDDO |
---|
4013 | |
---|
4014 | ELSE |
---|
4015 | ! |
---|
4016 | !-- If no SGS velocities are used, only the particle timestep has to |
---|
4017 | !-- be set |
---|
4018 | dt_particle = dt_3d |
---|
4019 | |
---|
4020 | ENDIF |
---|
4021 | |
---|
4022 | dens_ratio = particle_groups(particles(1:number_of_particles)%group)%density_ratio |
---|
4023 | IF ( ANY( dens_ratio == 0.0_wp ) ) THEN |
---|
4024 | ! |
---|
4025 | !-- Decide whether the particle loop runs over the subboxes or only over 1, |
---|
4026 | !-- number_of_particles. This depends on the selected interpolation method. |
---|
4027 | !-- If particle interpolation method is not trilinear, then the sorting within |
---|
4028 | !-- subboxes is not required. However, therefore the index start_index(nb) and |
---|
4029 | !-- end_index(nb) are not defined and the loops are still over |
---|
4030 | !-- number_of_particles. @todo find a more generic way to write this loop or |
---|
4031 | !-- delete trilinear interpolation |
---|
4032 | IF ( interpolation_trilinear ) THEN |
---|
4033 | subbox_start = 0 |
---|
4034 | subbox_end = 7 |
---|
4035 | ELSE |
---|
4036 | subbox_start = 1 |
---|
4037 | subbox_end = 1 |
---|
4038 | ENDIF |
---|
4039 | ! |
---|
4040 | !-- loop over subboxes. In case of simple interpolation scheme no subboxes |
---|
4041 | !-- are introduced, as they are not required. Accordingly, this loops goes |
---|
4042 | !-- from 1 to 1. |
---|
4043 | DO nb = subbox_start, subbox_end |
---|
4044 | IF ( interpolation_trilinear ) THEN |
---|
4045 | particle_start = start_index(nb) |
---|
4046 | particle_end = end_index(nb) |
---|
4047 | ELSE |
---|
4048 | particle_start = 1 |
---|
4049 | particle_end = number_of_particles |
---|
4050 | ENDIF |
---|
4051 | ! |
---|
4052 | !-- Loop from particle start to particle end |
---|
4053 | DO n = particle_start, particle_end |
---|
4054 | |
---|
4055 | ! |
---|
4056 | !-- Particle advection |
---|
4057 | IF ( dens_ratio(n) == 0.0_wp ) THEN |
---|
4058 | ! |
---|
4059 | !-- Pure passive transport (without particle inertia) |
---|
4060 | particles(n)%x = xv(n) + u_int(n) * dt_particle(n) |
---|
4061 | particles(n)%y = yv(n) + v_int(n) * dt_particle(n) |
---|
4062 | |
---|