1 | SUBROUTINE lpm_init |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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-2012 Leibniz University Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: lpm_init.f90 1037 2012-10-22 14:10:22Z franke $ |
---|
27 | ! |
---|
28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
29 | ! code put under GPL (PALM 3.9) |
---|
30 | ! |
---|
31 | ! 849 2012-03-15 10:35:09Z raasch |
---|
32 | ! routine renamed: init_particles -> lpm_init |
---|
33 | ! de_dx, de_dy, de_dz are allocated here (instead of automatic arrays in |
---|
34 | ! advec_particles), |
---|
35 | ! sort_particles renamed lpm_sort_arrays, user_init_particles renamed lpm_init |
---|
36 | ! |
---|
37 | ! 828 2012-02-21 12:00:36Z raasch |
---|
38 | ! call of init_kernels, particle feature color renamed class |
---|
39 | ! |
---|
40 | ! 824 2012-02-17 09:09:57Z raasch |
---|
41 | ! particle attributes speed_x|y|z_sgs renamed rvar1|2|3, |
---|
42 | ! array particles implemented as pointer |
---|
43 | ! |
---|
44 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
45 | ! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for allocation |
---|
46 | ! of arrays. |
---|
47 | ! |
---|
48 | ! 622 2010-12-10 08:08:13Z raasch |
---|
49 | ! optional barriers included in order to speed up collective operations |
---|
50 | ! |
---|
51 | ! 336 2009-06-10 11:19:35Z raasch |
---|
52 | ! Maximum number of tails is calculated from maximum number of particles and |
---|
53 | ! skip_particles_for_tail, |
---|
54 | ! output of messages replaced by message handling routine |
---|
55 | ! Bugfix: arrays for tails are allocated with a minimum size of 10 tails if |
---|
56 | ! there is no tail initially |
---|
57 | ! |
---|
58 | ! 150 2008-02-29 08:19:58Z raasch |
---|
59 | ! Setting offset_ocean_* needed for calculating vertical indices within ocean |
---|
60 | ! runs |
---|
61 | ! |
---|
62 | ! 117 2007-10-11 03:27:59Z raasch |
---|
63 | ! Sorting of particles only in case of cloud droplets |
---|
64 | ! |
---|
65 | ! 106 2007-08-16 14:30:26Z raasch |
---|
66 | ! variable iran replaced by iran_part |
---|
67 | ! |
---|
68 | ! 82 2007-04-16 15:40:52Z raasch |
---|
69 | ! Preprocessor directives for old systems removed |
---|
70 | ! |
---|
71 | ! 70 2007-03-18 23:46:30Z raasch |
---|
72 | ! displacements for mpi_particle_type changed, age_m initialized, |
---|
73 | ! particles-package is now part of the default code |
---|
74 | ! |
---|
75 | ! 16 2007-02-15 13:16:47Z raasch |
---|
76 | ! Bugfix: MPI_REAL in MPI_ALLREDUCE replaced by MPI_INTEGER |
---|
77 | ! |
---|
78 | ! r4 | raasch | 2007-02-13 12:33:16 +0100 (Tue, 13 Feb 2007) |
---|
79 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
80 | ! |
---|
81 | ! Revision 1.24 2007/02/11 13:00:17 raasch |
---|
82 | ! Bugfix: allocation of tail_mask and new_tail_id in case of restart-runs |
---|
83 | ! Bugfix: __ was missing in a cpp-directive |
---|
84 | ! |
---|
85 | ! Revision 1.1 1999/11/25 16:22:38 raasch |
---|
86 | ! Initial revision |
---|
87 | ! |
---|
88 | ! |
---|
89 | ! Description: |
---|
90 | ! ------------ |
---|
91 | ! This routine initializes a set of particles and their attributes (position, |
---|
92 | ! radius, ..) which are used by the Lagrangian particle model (see lpm). |
---|
93 | !------------------------------------------------------------------------------! |
---|
94 | |
---|
95 | USE arrays_3d |
---|
96 | USE cloud_parameters |
---|
97 | USE control_parameters |
---|
98 | USE dvrp_variables |
---|
99 | USE grid_variables |
---|
100 | USE indices |
---|
101 | USE lpm_collision_kernels_mod |
---|
102 | USE particle_attributes |
---|
103 | USE pegrid |
---|
104 | USE random_function_mod |
---|
105 | |
---|
106 | |
---|
107 | IMPLICIT NONE |
---|
108 | |
---|
109 | INTEGER :: i, j, n, nn |
---|
110 | #if defined( __parallel ) |
---|
111 | INTEGER, DIMENSION(3) :: blocklengths, displacements, types |
---|
112 | #endif |
---|
113 | LOGICAL :: uniform_particles_l |
---|
114 | REAL :: factor, pos_x, pos_y, pos_z, value |
---|
115 | |
---|
116 | |
---|
117 | #if defined( __parallel ) |
---|
118 | ! |
---|
119 | !-- Define MPI derived datatype for FORTRAN datatype particle_type (see module |
---|
120 | !-- particle_attributes). Integer length is 4 byte, Real is 8 byte |
---|
121 | blocklengths(1) = 19; blocklengths(2) = 4; blocklengths(3) = 1 |
---|
122 | displacements(1) = 0; displacements(2) = 152; displacements(3) = 168 |
---|
123 | |
---|
124 | types(1) = MPI_REAL |
---|
125 | types(2) = MPI_INTEGER |
---|
126 | types(3) = MPI_UB |
---|
127 | CALL MPI_TYPE_STRUCT( 3, blocklengths, displacements, types, & |
---|
128 | mpi_particle_type, ierr ) |
---|
129 | CALL MPI_TYPE_COMMIT( mpi_particle_type, ierr ) |
---|
130 | #endif |
---|
131 | |
---|
132 | ! |
---|
133 | !-- In case of oceans runs, the vertical index calculations need an offset, |
---|
134 | !-- because otherwise the k indices will become negative |
---|
135 | IF ( ocean ) THEN |
---|
136 | offset_ocean_nzt = nzt |
---|
137 | offset_ocean_nzt_m1 = nzt - 1 |
---|
138 | ENDIF |
---|
139 | |
---|
140 | |
---|
141 | ! |
---|
142 | !-- Check the number of particle groups. |
---|
143 | IF ( number_of_particle_groups > max_number_of_particle_groups ) THEN |
---|
144 | WRITE( message_string, * ) 'max_number_of_particle_groups =', & |
---|
145 | max_number_of_particle_groups , & |
---|
146 | '&number_of_particle_groups reset to ', & |
---|
147 | max_number_of_particle_groups |
---|
148 | CALL message( 'lpm_init', 'PA0213', 0, 1, 0, 6, 0 ) |
---|
149 | number_of_particle_groups = max_number_of_particle_groups |
---|
150 | ENDIF |
---|
151 | |
---|
152 | ! |
---|
153 | !-- Set default start positions, if necessary |
---|
154 | IF ( psl(1) == 9999999.9 ) psl(1) = -0.5 * dx |
---|
155 | IF ( psr(1) == 9999999.9 ) psr(1) = ( nx + 0.5 ) * dx |
---|
156 | IF ( pss(1) == 9999999.9 ) pss(1) = -0.5 * dy |
---|
157 | IF ( psn(1) == 9999999.9 ) psn(1) = ( ny + 0.5 ) * dy |
---|
158 | IF ( psb(1) == 9999999.9 ) psb(1) = zu(nz/2) |
---|
159 | IF ( pst(1) == 9999999.9 ) pst(1) = psb(1) |
---|
160 | |
---|
161 | IF ( pdx(1) == 9999999.9 .OR. pdx(1) == 0.0 ) pdx(1) = dx |
---|
162 | IF ( pdy(1) == 9999999.9 .OR. pdy(1) == 0.0 ) pdy(1) = dy |
---|
163 | IF ( pdz(1) == 9999999.9 .OR. pdz(1) == 0.0 ) pdz(1) = zu(2) - zu(1) |
---|
164 | |
---|
165 | DO j = 2, number_of_particle_groups |
---|
166 | IF ( psl(j) == 9999999.9 ) psl(j) = psl(j-1) |
---|
167 | IF ( psr(j) == 9999999.9 ) psr(j) = psr(j-1) |
---|
168 | IF ( pss(j) == 9999999.9 ) pss(j) = pss(j-1) |
---|
169 | IF ( psn(j) == 9999999.9 ) psn(j) = psn(j-1) |
---|
170 | IF ( psb(j) == 9999999.9 ) psb(j) = psb(j-1) |
---|
171 | IF ( pst(j) == 9999999.9 ) pst(j) = pst(j-1) |
---|
172 | IF ( pdx(j) == 9999999.9 .OR. pdx(j) == 0.0 ) pdx(j) = pdx(j-1) |
---|
173 | IF ( pdy(j) == 9999999.9 .OR. pdy(j) == 0.0 ) pdy(j) = pdy(j-1) |
---|
174 | IF ( pdz(j) == 9999999.9 .OR. pdz(j) == 0.0 ) pdz(j) = pdz(j-1) |
---|
175 | ENDDO |
---|
176 | |
---|
177 | ! |
---|
178 | !-- Allocate arrays required for calculating particle SGS velocities |
---|
179 | IF ( use_sgs_for_particles ) THEN |
---|
180 | ALLOCATE( de_dx(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
181 | de_dy(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
182 | de_dz(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
183 | ENDIF |
---|
184 | |
---|
185 | ! |
---|
186 | !-- Initialize collision kernels |
---|
187 | IF ( collision_kernel /= 'none' ) CALL init_kernels |
---|
188 | |
---|
189 | ! |
---|
190 | !-- For the first model run of a possible job chain initialize the |
---|
191 | !-- particles, otherwise read the particle data from restart file. |
---|
192 | IF ( TRIM( initializing_actions ) == 'read_restart_data' & |
---|
193 | .AND. read_particles_from_restartfile ) THEN |
---|
194 | |
---|
195 | CALL lpm_read_restart_file |
---|
196 | |
---|
197 | ELSE |
---|
198 | |
---|
199 | ! |
---|
200 | !-- Allocate particle arrays and set attributes of the initial set of |
---|
201 | !-- particles, which can be also periodically released at later times. |
---|
202 | !-- Also allocate array for particle tail coordinates, if needed. |
---|
203 | ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
204 | prt_start_index(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
205 | particle_mask(maximum_number_of_particles), & |
---|
206 | part_1(maximum_number_of_particles), & |
---|
207 | part_2(maximum_number_of_particles) ) |
---|
208 | |
---|
209 | particles => part_1 |
---|
210 | |
---|
211 | sort_count = 0 |
---|
212 | |
---|
213 | ! |
---|
214 | !-- Initialize all particles with dummy values (otherwise errors may |
---|
215 | !-- occur within restart runs). The reason for this is still not clear |
---|
216 | !-- and may be presumably caused by errors in the respective user-interface. |
---|
217 | particles = particle_type( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, & |
---|
218 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, & |
---|
219 | 0.0, 0, 0, 0, 0 ) |
---|
220 | particle_groups = particle_groups_type( 0.0, 0.0, 0.0, 0.0 ) |
---|
221 | |
---|
222 | ! |
---|
223 | !-- Set the default particle size used for dvrp plots |
---|
224 | IF ( dvrp_psize == 9999999.9 ) dvrp_psize = 0.2 * dx |
---|
225 | |
---|
226 | ! |
---|
227 | !-- Set values for the density ratio and radius for all particle |
---|
228 | !-- groups, if necessary |
---|
229 | IF ( density_ratio(1) == 9999999.9 ) density_ratio(1) = 0.0 |
---|
230 | IF ( radius(1) == 9999999.9 ) radius(1) = 0.0 |
---|
231 | DO i = 2, number_of_particle_groups |
---|
232 | IF ( density_ratio(i) == 9999999.9 ) THEN |
---|
233 | density_ratio(i) = density_ratio(i-1) |
---|
234 | ENDIF |
---|
235 | IF ( radius(i) == 9999999.9 ) radius(i) = radius(i-1) |
---|
236 | ENDDO |
---|
237 | |
---|
238 | DO i = 1, number_of_particle_groups |
---|
239 | IF ( density_ratio(i) /= 0.0 .AND. radius(i) == 0 ) THEN |
---|
240 | WRITE( message_string, * ) 'particle group #', i, 'has a', & |
---|
241 | 'density ratio /= 0 but radius = 0' |
---|
242 | CALL message( 'lpm_init', 'PA0215', 1, 2, 0, 6, 0 ) |
---|
243 | ENDIF |
---|
244 | particle_groups(i)%density_ratio = density_ratio(i) |
---|
245 | particle_groups(i)%radius = radius(i) |
---|
246 | ENDDO |
---|
247 | |
---|
248 | ! |
---|
249 | !-- Calculate particle positions and store particle attributes, if |
---|
250 | !-- particle is situated on this PE |
---|
251 | n = 0 |
---|
252 | |
---|
253 | DO i = 1, number_of_particle_groups |
---|
254 | |
---|
255 | pos_z = psb(i) |
---|
256 | |
---|
257 | DO WHILE ( pos_z <= pst(i) ) |
---|
258 | |
---|
259 | pos_y = pss(i) |
---|
260 | |
---|
261 | DO WHILE ( pos_y <= psn(i) ) |
---|
262 | |
---|
263 | IF ( pos_y >= ( nys - 0.5 ) * dy .AND. & |
---|
264 | pos_y < ( nyn + 0.5 ) * dy ) THEN |
---|
265 | |
---|
266 | pos_x = psl(i) |
---|
267 | |
---|
268 | DO WHILE ( pos_x <= psr(i) ) |
---|
269 | |
---|
270 | IF ( pos_x >= ( nxl - 0.5 ) * dx .AND. & |
---|
271 | pos_x < ( nxr + 0.5 ) * dx ) THEN |
---|
272 | |
---|
273 | DO j = 1, particles_per_point |
---|
274 | |
---|
275 | n = n + 1 |
---|
276 | IF ( n > maximum_number_of_particles ) THEN |
---|
277 | WRITE( message_string, * ) 'number of initial', & |
---|
278 | 'particles (', n, ') exceeds', & |
---|
279 | '&maximum_number_of_particles (', & |
---|
280 | maximum_number_of_particles, ') on PE ', & |
---|
281 | myid |
---|
282 | CALL message( 'lpm_init', 'PA0216', 2, 2, -1, 6,& |
---|
283 | 1 ) |
---|
284 | ENDIF |
---|
285 | particles(n)%x = pos_x |
---|
286 | particles(n)%y = pos_y |
---|
287 | particles(n)%z = pos_z |
---|
288 | particles(n)%age = 0.0 |
---|
289 | particles(n)%age_m = 0.0 |
---|
290 | particles(n)%dt_sum = 0.0 |
---|
291 | particles(n)%dvrp_psize = dvrp_psize |
---|
292 | particles(n)%e_m = 0.0 |
---|
293 | IF ( curvature_solution_effects ) THEN |
---|
294 | ! |
---|
295 | !-- Initial values (internal timesteps, derivative) |
---|
296 | !-- for Rosenbrock method |
---|
297 | particles(n)%rvar1 = 1.0E-12 |
---|
298 | particles(n)%rvar2 = 1.0E-3 |
---|
299 | particles(n)%rvar3 = -9999999.9 |
---|
300 | ELSE |
---|
301 | ! |
---|
302 | !-- Initial values for SGS velocities |
---|
303 | particles(n)%rvar1 = 0.0 |
---|
304 | particles(n)%rvar2 = 0.0 |
---|
305 | particles(n)%rvar3 = 0.0 |
---|
306 | ENDIF |
---|
307 | particles(n)%speed_x = 0.0 |
---|
308 | particles(n)%speed_y = 0.0 |
---|
309 | particles(n)%speed_z = 0.0 |
---|
310 | particles(n)%origin_x = pos_x |
---|
311 | particles(n)%origin_y = pos_y |
---|
312 | particles(n)%origin_z = pos_z |
---|
313 | particles(n)%radius = particle_groups(i)%radius |
---|
314 | particles(n)%weight_factor =initial_weighting_factor |
---|
315 | particles(n)%class = 1 |
---|
316 | particles(n)%group = i |
---|
317 | particles(n)%tailpoints = 0 |
---|
318 | IF ( use_particle_tails .AND. & |
---|
319 | MOD( n, skip_particles_for_tail ) == 0 ) THEN |
---|
320 | number_of_tails = number_of_tails + 1 |
---|
321 | ! |
---|
322 | !-- This is a temporary provisional setting (see |
---|
323 | !-- further below!) |
---|
324 | particles(n)%tail_id = number_of_tails |
---|
325 | ELSE |
---|
326 | particles(n)%tail_id = 0 |
---|
327 | ENDIF |
---|
328 | |
---|
329 | ENDDO |
---|
330 | |
---|
331 | ENDIF |
---|
332 | |
---|
333 | pos_x = pos_x + pdx(i) |
---|
334 | |
---|
335 | ENDDO |
---|
336 | |
---|
337 | ENDIF |
---|
338 | |
---|
339 | pos_y = pos_y + pdy(i) |
---|
340 | |
---|
341 | ENDDO |
---|
342 | |
---|
343 | pos_z = pos_z + pdz(i) |
---|
344 | |
---|
345 | ENDDO |
---|
346 | |
---|
347 | ENDDO |
---|
348 | |
---|
349 | number_of_initial_particles = n |
---|
350 | number_of_particles = n |
---|
351 | |
---|
352 | ! |
---|
353 | !-- Calculate the number of particles and tails of the total domain |
---|
354 | #if defined( __parallel ) |
---|
355 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
356 | CALL MPI_ALLREDUCE( number_of_particles, total_number_of_particles, 1, & |
---|
357 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
358 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
359 | CALL MPI_ALLREDUCE( number_of_tails, total_number_of_tails, 1, & |
---|
360 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
361 | #else |
---|
362 | total_number_of_particles = number_of_particles |
---|
363 | total_number_of_tails = number_of_tails |
---|
364 | #endif |
---|
365 | |
---|
366 | ! |
---|
367 | !-- Set a seed value for the random number generator to be exclusively |
---|
368 | !-- used for the particle code. The generated random numbers should be |
---|
369 | !-- different on the different PEs. |
---|
370 | iran_part = iran_part + myid |
---|
371 | |
---|
372 | ! |
---|
373 | !-- User modification of initial particles |
---|
374 | CALL user_lpm_init |
---|
375 | |
---|
376 | ! |
---|
377 | !-- Store the initial set of particles for release at later times |
---|
378 | IF ( number_of_initial_particles /= 0 ) THEN |
---|
379 | ALLOCATE( initial_particles(1:number_of_initial_particles) ) |
---|
380 | initial_particles(1:number_of_initial_particles) = & |
---|
381 | particles(1:number_of_initial_particles) |
---|
382 | ENDIF |
---|
383 | |
---|
384 | ! |
---|
385 | !-- Add random fluctuation to particle positions |
---|
386 | IF ( random_start_position ) THEN |
---|
387 | |
---|
388 | DO n = 1, number_of_initial_particles |
---|
389 | IF ( psl(particles(n)%group) /= psr(particles(n)%group) ) THEN |
---|
390 | particles(n)%x = particles(n)%x + & |
---|
391 | ( random_function( iran_part ) - 0.5 ) * & |
---|
392 | pdx(particles(n)%group) |
---|
393 | IF ( particles(n)%x <= ( nxl - 0.5 ) * dx ) THEN |
---|
394 | particles(n)%x = ( nxl - 0.4999999999 ) * dx |
---|
395 | ELSEIF ( particles(n)%x >= ( nxr + 0.5 ) * dx ) THEN |
---|
396 | particles(n)%x = ( nxr + 0.4999999999 ) * dx |
---|
397 | ENDIF |
---|
398 | ENDIF |
---|
399 | IF ( pss(particles(n)%group) /= psn(particles(n)%group) ) THEN |
---|
400 | particles(n)%y = particles(n)%y + & |
---|
401 | ( random_function( iran_part ) - 0.5 ) * & |
---|
402 | pdy(particles(n)%group) |
---|
403 | IF ( particles(n)%y <= ( nys - 0.5 ) * dy ) THEN |
---|
404 | particles(n)%y = ( nys - 0.4999999999 ) * dy |
---|
405 | ELSEIF ( particles(n)%y >= ( nyn + 0.5 ) * dy ) THEN |
---|
406 | particles(n)%y = ( nyn + 0.4999999999 ) * dy |
---|
407 | ENDIF |
---|
408 | ENDIF |
---|
409 | IF ( psb(particles(n)%group) /= pst(particles(n)%group) ) THEN |
---|
410 | particles(n)%z = particles(n)%z + & |
---|
411 | ( random_function( iran_part ) - 0.5 ) * & |
---|
412 | pdz(particles(n)%group) |
---|
413 | ENDIF |
---|
414 | ENDDO |
---|
415 | ENDIF |
---|
416 | |
---|
417 | ! |
---|
418 | !-- Sort particles in the sequence the gridboxes are stored in the memory. |
---|
419 | !-- Only required if cloud droplets are used. |
---|
420 | IF ( cloud_droplets ) CALL lpm_sort_arrays |
---|
421 | |
---|
422 | ! |
---|
423 | !-- Open file for statistical informations about particle conditions |
---|
424 | IF ( write_particle_statistics ) THEN |
---|
425 | CALL check_open( 80 ) |
---|
426 | WRITE ( 80, 8000 ) current_timestep_number, simulated_time, & |
---|
427 | number_of_initial_particles, & |
---|
428 | maximum_number_of_particles |
---|
429 | CALL close_file( 80 ) |
---|
430 | ENDIF |
---|
431 | |
---|
432 | ! |
---|
433 | !-- Check if particles are really uniform in color and radius (dvrp_size) |
---|
434 | !-- (uniform_particles is preset TRUE) |
---|
435 | IF ( uniform_particles ) THEN |
---|
436 | IF ( number_of_initial_particles == 0 ) THEN |
---|
437 | uniform_particles_l = .TRUE. |
---|
438 | ELSE |
---|
439 | n = number_of_initial_particles |
---|
440 | IF ( MINVAL( particles(1:n)%dvrp_psize ) == & |
---|
441 | MAXVAL( particles(1:n)%dvrp_psize ) .AND. & |
---|
442 | MINVAL( particles(1:n)%class ) == & |
---|
443 | MAXVAL( particles(1:n)%class ) ) THEN |
---|
444 | uniform_particles_l = .TRUE. |
---|
445 | ELSE |
---|
446 | uniform_particles_l = .FALSE. |
---|
447 | ENDIF |
---|
448 | ENDIF |
---|
449 | |
---|
450 | #if defined( __parallel ) |
---|
451 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
452 | CALL MPI_ALLREDUCE( uniform_particles_l, uniform_particles, 1, & |
---|
453 | MPI_LOGICAL, MPI_LAND, comm2d, ierr ) |
---|
454 | #else |
---|
455 | uniform_particles = uniform_particles_l |
---|
456 | #endif |
---|
457 | |
---|
458 | ENDIF |
---|
459 | |
---|
460 | ! |
---|
461 | !-- Particles will probably become none-uniform, if their size and color |
---|
462 | !-- will be determined by flow variables |
---|
463 | IF ( particle_color /= 'none' .OR. particle_dvrpsize /= 'none' ) THEN |
---|
464 | uniform_particles = .FALSE. |
---|
465 | ENDIF |
---|
466 | |
---|
467 | ! |
---|
468 | !-- Set the beginning of the particle tails and their age |
---|
469 | IF ( use_particle_tails ) THEN |
---|
470 | ! |
---|
471 | !-- Choose the maximum number of tails with respect to the maximum number |
---|
472 | !-- of particles and skip_particles_for_tail |
---|
473 | maximum_number_of_tails = maximum_number_of_particles / & |
---|
474 | skip_particles_for_tail |
---|
475 | |
---|
476 | ! |
---|
477 | !-- Create a minimum number of tails in case that there is no tail |
---|
478 | !-- initially (otherwise, index errors will occur when adressing the |
---|
479 | !-- arrays below) |
---|
480 | IF ( maximum_number_of_tails == 0 ) maximum_number_of_tails = 10 |
---|
481 | |
---|
482 | ALLOCATE( particle_tail_coordinates(maximum_number_of_tailpoints,5, & |
---|
483 | maximum_number_of_tails), & |
---|
484 | new_tail_id(maximum_number_of_tails), & |
---|
485 | tail_mask(maximum_number_of_tails) ) |
---|
486 | |
---|
487 | particle_tail_coordinates = 0.0 |
---|
488 | minimum_tailpoint_distance = minimum_tailpoint_distance**2 |
---|
489 | number_of_initial_tails = number_of_tails |
---|
490 | |
---|
491 | nn = 0 |
---|
492 | DO n = 1, number_of_particles |
---|
493 | ! |
---|
494 | !-- Only for those particles marked above with a provisional tail_id |
---|
495 | !-- tails will be created. Particles now get their final tail_id. |
---|
496 | IF ( particles(n)%tail_id /= 0 ) THEN |
---|
497 | |
---|
498 | nn = nn + 1 |
---|
499 | particles(n)%tail_id = nn |
---|
500 | |
---|
501 | particle_tail_coordinates(1,1,nn) = particles(n)%x |
---|
502 | particle_tail_coordinates(1,2,nn) = particles(n)%y |
---|
503 | particle_tail_coordinates(1,3,nn) = particles(n)%z |
---|
504 | particle_tail_coordinates(1,4,nn) = particles(n)%class |
---|
505 | particles(n)%tailpoints = 1 |
---|
506 | IF ( minimum_tailpoint_distance /= 0.0 ) THEN |
---|
507 | particle_tail_coordinates(2,1,nn) = particles(n)%x |
---|
508 | particle_tail_coordinates(2,2,nn) = particles(n)%y |
---|
509 | particle_tail_coordinates(2,3,nn) = particles(n)%z |
---|
510 | particle_tail_coordinates(2,4,nn) = particles(n)%class |
---|
511 | particle_tail_coordinates(1:2,5,nn) = 0.0 |
---|
512 | particles(n)%tailpoints = 2 |
---|
513 | ENDIF |
---|
514 | |
---|
515 | ENDIF |
---|
516 | ENDDO |
---|
517 | ENDIF |
---|
518 | |
---|
519 | ! |
---|
520 | !-- Plot initial positions of particles (only if particle advection is |
---|
521 | !-- switched on from the beginning of the simulation (t=0)) |
---|
522 | IF ( particle_advection_start == 0.0 ) CALL data_output_dvrp |
---|
523 | |
---|
524 | ENDIF |
---|
525 | |
---|
526 | ! |
---|
527 | !-- Check boundary condition and set internal variables |
---|
528 | SELECT CASE ( bc_par_b ) |
---|
529 | |
---|
530 | CASE ( 'absorb' ) |
---|
531 | ibc_par_b = 1 |
---|
532 | |
---|
533 | CASE ( 'reflect' ) |
---|
534 | ibc_par_b = 2 |
---|
535 | |
---|
536 | CASE DEFAULT |
---|
537 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
538 | 'bc_par_b = "', TRIM( bc_par_b ), '"' |
---|
539 | CALL message( 'lpm_init', 'PA0217', 1, 2, 0, 6, 0 ) |
---|
540 | |
---|
541 | END SELECT |
---|
542 | SELECT CASE ( bc_par_t ) |
---|
543 | |
---|
544 | CASE ( 'absorb' ) |
---|
545 | ibc_par_t = 1 |
---|
546 | |
---|
547 | CASE ( 'reflect' ) |
---|
548 | ibc_par_t = 2 |
---|
549 | |
---|
550 | CASE DEFAULT |
---|
551 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
552 | 'bc_par_t = "', TRIM( bc_par_t ), '"' |
---|
553 | CALL message( 'lpm_init', 'PA0218', 1, 2, 0, 6, 0 ) |
---|
554 | |
---|
555 | END SELECT |
---|
556 | SELECT CASE ( bc_par_lr ) |
---|
557 | |
---|
558 | CASE ( 'cyclic' ) |
---|
559 | ibc_par_lr = 0 |
---|
560 | |
---|
561 | CASE ( 'absorb' ) |
---|
562 | ibc_par_lr = 1 |
---|
563 | |
---|
564 | CASE ( 'reflect' ) |
---|
565 | ibc_par_lr = 2 |
---|
566 | |
---|
567 | CASE DEFAULT |
---|
568 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
569 | 'bc_par_lr = "', TRIM( bc_par_lr ), '"' |
---|
570 | CALL message( 'lpm_init', 'PA0219', 1, 2, 0, 6, 0 ) |
---|
571 | |
---|
572 | END SELECT |
---|
573 | SELECT CASE ( bc_par_ns ) |
---|
574 | |
---|
575 | CASE ( 'cyclic' ) |
---|
576 | ibc_par_ns = 0 |
---|
577 | |
---|
578 | CASE ( 'absorb' ) |
---|
579 | ibc_par_ns = 1 |
---|
580 | |
---|
581 | CASE ( 'reflect' ) |
---|
582 | ibc_par_ns = 2 |
---|
583 | |
---|
584 | CASE DEFAULT |
---|
585 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
586 | 'bc_par_ns = "', TRIM( bc_par_ns ), '"' |
---|
587 | CALL message( 'lpm_init', 'PA0220', 1, 2, 0, 6, 0 ) |
---|
588 | |
---|
589 | END SELECT |
---|
590 | ! |
---|
591 | !-- Formats |
---|
592 | 8000 FORMAT (I6,1X,F7.2,4X,I6,71X,I6) |
---|
593 | |
---|
594 | END SUBROUTINE lpm_init |
---|