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