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