source: palm/trunk/SOURCE/init_particles.f90 @ 667

Last change on this file since 667 was 667, checked in by suehring, 14 years ago

summary:


Gryschka:

  • Coupling with different resolution and different numbers of PEs in ocean and atmosphere is available
  • Exchange of u and v from ocean surface to atmosphere surface
  • Mirror boundary condition for u and v at the bottom are replaced by dirichlet boundary conditions
  • Inflow turbulence is now defined by flucuations around spanwise mean
  • Bugfixes for cyclic_fill and constant_volume_flow

Suehring:

  • New advection added ( Wicker and Skamarock 5th order ), therefore:
    • New module advec_ws.f90
    • Modified exchange of ghost boundaries.
    • Modified evaluation of turbulent fluxes
    • New index bounds nxlg, nxrg, nysg, nyng

advec_ws.f90


Advection scheme for scalars and momentum using the flux formulation of
Wicker and Skamarock 5th order.
Additionally the module contains of a routine using for initialisation and
steering of the statical evaluation. The computation of turbulent fluxes takes
place inside the advection routines.
In case of vector architectures Dirichlet and Radiation boundary conditions are
outstanding and not available. Furthermore simulations within topography are
not possible so far. A further routine local_diss_ij is available and is used
if a control of dissipative fluxes is desired.

check_parameters.f90


Exchange of parameters between ocean and atmosphere via PE0
Check for illegal combination of ws-scheme and timestep scheme.
Check for topography and ws-scheme.
Check for not cyclic boundary conditions in combination with ws-scheme and
loop_optimization = 'vector'.
Check for call_psolver_at_all_substeps and ws-scheme for momentum_advec.

Different processor/grid topology in atmosphere and ocean is now allowed!
Bugfixes in checking for conserve_volume_flow_mode.

exchange_horiz.f90


Dynamic exchange of ghost points with nbgp_local to ensure that no useless
ghost points exchanged in case of multigrid. type_yz(0) and type_xz(0) used for
normal grid, the remaining types used for the several grid levels.
Exchange is done via MPI-Vectors with a dynamic value of ghost points which
depend on the advection scheme. Exchange of left and right PEs is 10% faster
with MPI-Vectors than without.

flow_statistics.f90


When advection is computed with ws-scheme, turbulent fluxes are already
computed in the respective advection routines and buffered in arrays
sums_xxxx_ws_l(). This is due to a consistent treatment of statistics
with the numerics and to avoid unphysical kinks near the surface. So some if-
requests has to be done to dicern between fluxes from ws-scheme other advection
schemes. Furthermore the computation of z_i is only done if the heat flux
exceeds a minimum value. This affects only simulations of a neutral boundary
layer and is due to reasons of computations in the advection scheme.

inflow_turbulence.f90


Using nbgp recycling planes for a better resolution of the turbulent flow near
the inflow.

init_grid.f90


Definition of new array bounds nxlg, nxrg, nysg, nyng on each PE.
Furthermore the allocation of arrays and steering of loops is done with these
parameters. Call of exchange_horiz are modified.
In case of dirichlet bounday condition at the bottom zu(0)=0.0
dzu_mg has to be set explicitly for a equally spaced grid near bottom.
ddzu_pres added to use a equally spaced grid near bottom.

init_pegrid.f90


Moved determination of target_id's from init_coupling
Determination of parameters needed for coupling (coupling_topology, ngp_a, ngp_o)
with different grid/processor-topology in ocean and atmosphere

Adaption of ngp_xy, ngp_y to a dynamic number of ghost points.
The maximum_grid_level changed from 1 to 0. 0 is the normal grid, 1 to
maximum_grid_level the grids for multigrid, in which 0 and 1 are normal grids.
This distinction is due to reasons of data exchange and performance for the
normal grid and grids in poismg.
The definition of MPI-Vectors adapted to a dynamic numer of ghost points.
New MPI-Vectors for data exchange between left and right boundaries added.
This is due to reasons of performance (10% faster).

ATTENTION: nnz_x undefined problem still has to be solved!!!!!!!!
TEST OUTPUT (TO BE REMOVED) logging mpi2 ierr values

parin.f90


Steering parameter dissipation_control added in inipar.

Makefile


Module advec_ws added.

Modules


Removed u_nzb_p1_for_vfc and v_nzb_p1_for_vfc

For coupling with different resolution in ocean and atmophere:
+nx_a, +nx_o, ny_a, +ny_o, ngp_a, ngp_o, +total_2d_o, +total_2d_a,
+coupling_topology

Buffer arrays for the left sided advective fluxes added in arrays_3d.
+flux_s_u, +flux_s_v, +flux_s_w, +diss_s_u, +diss_s_v, +diss_s_w,
+flux_s_pt, +diss_s_pt, +flux_s_e, +diss_s_e, +flux_s_q, +diss_s_q,
+flux_s_sa, +diss_s_sa
3d arrays for dissipation control added. (only necessary for vector arch.)
+var_x, +var_y, +var_z, +gamma_x, +gamma_y, +gamma_z
Default of momentum_advec and scalar_advec changed to 'ws-scheme' .
+exchange_mg added in control_parameters to steer the data exchange.
Parameters +nbgp, +nxlg, +nxrg, +nysg, +nyng added in indices.
flag array +boundary_flags added in indices to steer the degradation of order
of the advective fluxes when non-cyclic boundaries are used.
MPI-datatypes +type_y, +type_y_int and +type_yz for data_exchange added in
pegrid.
+sums_wsus_ws_l, +sums_wsvs_ws_l, +sums_us2_ws_l, +sums_vs2_ws_l,
+sums_ws2_ws_l, +sums_wspts_ws_l, +sums_wssas_ws_l, +sums_wsqs_ws_l
and +weight_substep added in statistics to steer the statistical evaluation
of turbulent fluxes in the advection routines.
LOGICALS +ws_scheme_sca and +ws_scheme_mom added to get a better performance
in prognostic_equations.
LOGICAL +dissipation_control control added to steer numerical dissipation
in ws-scheme.

Changed length of string run_description_header

pres.f90


New allocation of tend when ws-scheme and multigrid is used. This is due to
reasons of perforance of the data_exchange. The same is done with p after
poismg is called.
nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng when no
multigrid is used. Calls of exchange_horiz are modified.

bugfix: After pressure correction no volume flow correction in case of
non-cyclic boundary conditions
(has to be done only before pressure correction)

Call of SOR routine is referenced with ddzu_pres.

prognostic_equations.f90


Calls of the advection routines with WS5 added.
Calls of ws_statistics added to set the statistical arrays to zero after each
time step.

advec_particles.f90


Declaration of de_dx, de_dy, de_dz adapted to additional ghost points.
Furthermore the calls of exchange_horiz were modified.

asselin_filter.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

average_3d_data.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

boundary_conds.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng
Removed mirror boundary conditions for u and v at the bottom in case of
ibc_uv_b == 0. Instead, dirichelt boundary conditions (u=v=0) are set
in init_3d_model

calc_liquid_water_content.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

calc_spectra.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for
allocation of tend.

check_open.f90


Output of total array size was adapted to nbgp.

data_output_2d.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays local_2d and total_2d.
Calls of exchange_horiz are modified.

data_output_2d.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays. Calls of exchange_horiz are modified.
Skip-value skip_do_avs changed to a dynamic adaption of ghost points.

data_output_mask.f90


Calls of exchange_horiz are modified.

diffusion_e.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_s.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_u.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_v.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_w.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusivities.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusivities.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Calls of exchange_horiz are modified.

exchange_horiz_2d.f90


Dynamic exchange of ghost points with nbgp, which depends on the advection
scheme. Exchange between left and right PEs is now done with MPI-vectors.

global_min_max.f90


Adapting of the index arrays, because MINLOC assumes lowerbound
at 1 and not at nbgp.

init_3d_model.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays. Calls of exchange_horiz are modified.
Call ws_init to initialize arrays needed for statistical evaluation and
optimization when ws-scheme is used.
Initial volume flow is now calculated by using the variable hom_sum.
Therefore the correction of initial volume flow for non-flat topography
removed (removed u_nzb_p1_for_vfc and v_nzb_p1_for_vfc)
Changed surface boundary conditions for u and v in case of ibc_uv_b == 0 from
mirror bc to dirichlet boundary conditions (u=v=0), so that k=nzb is
representative for the height z0

Bugfix: type conversion of '1' to 64bit for the MAX function (ngp_3d_inner)

init_coupling.f90


determination of target_id's moved to init_pegrid

init_pt_anomaly.f90


Call of exchange_horiz are modified.

init_rankine.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Calls of exchange_horiz are modified.

init_slope.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

header.f90


Output of advection scheme.

poismg.f90


Calls of exchange_horiz are modified.

prandtl_fluxes.f90


Changed surface boundary conditions for u and v from mirror bc to dirichelt bc,
therefore u(uzb,:,:) and v(nzb,:,:) is now representative for the height z0
nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

production_e.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

read_3d_binary.f90


+/- 1 replaced with +/- nbgp when swapping and allocating variables.

sor.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Call of exchange_horiz are modified.
bug removed in declaration of ddzw(), nz replaced by nzt+1

subsidence.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

sum_up_3d_data.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

surface_coupler.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in
MPI_SEND() and MPI_RECV.
additional case for nonequivalent processor and grid topopolgy in ocean and
atmosphere added (coupling_topology = 1)

Added exchange of u and v from Ocean to Atmosphere

time_integration.f90


Calls of exchange_horiz are modified.
Adaption to slooping surface.

timestep.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

user_3d_data_averaging.f90, user_data_output_2d.f90, user_data_output_3d.f90,
user_actions.f90, user_init.f90, user_init_plant_canopy.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

user_read_restart_data.f90


Allocation with nbgp.

wall_fluxes.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

write_compressed.f90


Array bounds and nx, ny adapted with nbgp.

sor.f90


bug removed in declaration of ddzw(), nz replaced by nzt+1

  • Property svn:keywords set to Id
File size: 22.1 KB
RevLine 
[1]1 SUBROUTINE init_particles
2
3!------------------------------------------------------------------------------!
[254]4! Current revisions:
[1]5! -----------------
[667]6! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for allocation
7! of arrays.
[392]8!
9! Former revisions:
10! -----------------
11! $Id: init_particles.f90 667 2010-12-23 12:06:00Z suehring $
12!
[623]13! 622 2010-12-10 08:08:13Z raasch
14! optional barriers included in order to speed up collective operations
15!
[392]16! 336 2009-06-10 11:19:35Z raasch
[276]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
[229]20! Bugfix: arrays for tails are allocated with a minimum size of 10 tails if
21! there is no tail initially
[1]22!
[198]23! 150 2008-02-29 08:19:58Z raasch
24! Setting offset_ocean_* needed for calculating vertical indices within ocean
25! runs
26!
[139]27! 117 2007-10-11 03:27:59Z raasch
28! Sorting of particles only in case of cloud droplets
29!
[110]30! 106 2007-08-16 14:30:26Z raasch
31! variable iran replaced by iran_part
32!
[83]33! 82 2007-04-16 15:40:52Z raasch
34! Preprocessor directives for old systems removed
35!
[77]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!
[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)
[3]44! RCS Log replace by Id keyword, revision history cleaned up
45!
[1]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
[336]63    USE dvrp_variables
[1]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
[82]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
[1]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!
[150]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!
[1]108!-- Check the number of particle groups.
109    IF ( number_of_particle_groups > max_number_of_particle_groups )  THEN
[274]110       WRITE( message_string, * ) 'max_number_of_particle_groups =',      &
111                                  max_number_of_particle_groups ,         &
[254]112                                  '&number_of_particle_groups reset to ', &
113                                  max_number_of_particle_groups
114       CALL message( 'init_particles', 'PA0213', 0, 1, 0, 6, 0 )
[1]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
[274]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 ) // '"'
[254]170          CALL message( 'init_particles', 'PA0214', 1, 2, 0, 6, 0 )
[1]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
[667]188       ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),       &
189                 prt_start_index(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &
[1]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.
[667]212       ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),       &
213                 prt_start_index(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &
[1]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, &
[57]223                                  0.0, 0, 0, 0, 0 )
[1]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
[254]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 )
[1]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
[254]281                               WRITE( message_string, * ) 'number of initial', &
[274]282                                      'particles (', n, ') exceeds',           &
283                                      '&maximum_number_of_particles (',        &
284                                      maximum_number_of_particles, ') on PE ', &
[254]285                                             myid
[274]286                               CALL message( 'init_particles', 'PA0216', &
[277]287                                                                 2, 2, -1, 6, 1 )
[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
[57]293                            particles(n)%age_m         = 0.0
[1]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 )
[622]348       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[1]349       CALL MPI_ALLREDUCE( number_of_particles, total_number_of_particles, 1, &
[16]350                           MPI_INTEGER, MPI_SUM, comm2d, ierr )
[622]351       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[1]352       CALL MPI_ALLREDUCE( number_of_tails, total_number_of_tails, 1, &
[16]353                           MPI_INTEGER, MPI_SUM, comm2d, ierr )
[1]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 + &
[106]384                                 ( random_function( iran_part ) - 0.5 ) * &
[1]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 + &
[106]394                                 ( random_function( iran_part ) - 0.5 ) * &
[1]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 + &
[106]404                                 ( random_function( iran_part ) - 0.5 ) * &
[1]405                                 pdz(particles(n)%group)
406             ENDIF
407          ENDDO
408       ENDIF
409
410!
[117]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
[1]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 )
[622]444          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[1]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!
[336]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!
[1]461!--    Set the beginning of the particle tails and their age
462       IF ( use_particle_tails )  THEN
463!
[276]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
[229]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
[1]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
[254]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 )
[1]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
[254]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 )
[1]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
[254]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 )
[1]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
[254]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 )
[1]581         
582    END SELECT
583!
584!-- Formats
5858000 FORMAT (I6,1X,F7.2,4X,I6,71X,I6)
586
587 END SUBROUTINE init_particles
Note: See TracBrowser for help on using the repository browser.