source: palm/trunk/SOURCE/lpm_release_set.f90 @ 1320

Last change on this file since 1320 was 1320, checked in by raasch, 10 years ago

ONLY-attribute added to USE-statements,
kind-parameters added to all INTEGER and REAL declaration statements,
kinds are defined in new module kinds,
old module precision_kind is removed,
revision history before 2012 removed,
comment fields (!:) to be used for variable explanations added to all variable declaration statements

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1 SUBROUTINE lpm_release_set
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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22! ONLY-attribute added to USE-statements,
23! kind-parameters added to all INTEGER and REAL declaration statements,
24! kinds are defined in new module kinds,
25! comment fields (!:) to be used for variable explanations added to
26! all variable declaration statements
27!
28! Former revisions:
29! -----------------
30! $Id: lpm_release_set.f90 1320 2014-03-20 08:40:49Z raasch $
31!
32! 1036 2012-10-22 13:43:42Z raasch
33! code put under GPL (PALM 3.9)
34!
35! 849 2012-03-15 10:35:09Z raasch
36! initial revision (former part of advec_particles)
37!
38!
39! Description:
40! ------------
41! Release a new set of particles and, if required, particle tails. These
42! particles/tails are added at the end of the existing arrays. Extend the
43! respective particle and tail arrays, if neccessary.
44!------------------------------------------------------------------------------!
45
46    USE control_parameters,                                                    &
47        ONLY:  iran, message_string, netcdf_data_format, netcdf_output
48
49    USE grid_variables,                                                        &
50        ONLY:  dx, dy
51
52    USE indices,                                                               &
53        ONLY:  nxl, nxr, nyn, nys
54
55    USE kinds
56
57    USE particle_attributes,                                                   &
58        ONLY:  initial_particles, iran_part, maximum_number_of_particles,      &
59               maximum_number_of_tails, minimum_tailpoint_distance,            &
60               number_of_initial_particles, number_of_initial_tails,           &
61               number_of_particles, number_of_tails, particles,                &
62               particle_tail_coordinates, pdx, pdy, pdz, psb, psl, psn, psr,   &
63               pss, pst, random_start_position, use_particle_tails
64
65    USE random_function_mod,                                                   &
66        ONLY:  random_function
67
68    IMPLICIT NONE
69
70    INTEGER(iwp) ::  ie     !:
71    INTEGER(iwp) ::  is     !:
72    INTEGER(iwp) ::  n      !:
73    INTEGER(iwp) ::  nn     !:
74
75
76!
77!-- Check, if particle storage must be extended
78    IF ( number_of_particles + number_of_initial_particles > &
79         maximum_number_of_particles  )  THEN
80       IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
81          message_string = 'maximum_number_of_particles needs to be increa' // &
82                           'sed &but this is not allowed with netcdf_data_' // &
83                           'format < 3'
84          CALL message( 'lpm_release_set', 'PA0146', 2, 2, -1, 6, 1 )
85       ELSE
86          CALL lpm_extend_particle_array( number_of_initial_particles )
87       ENDIF
88    ENDIF
89
90!
91!-- Check, if tail storage must be extended
92    IF ( use_particle_tails )  THEN
93       IF ( number_of_tails + number_of_initial_tails > &
94            maximum_number_of_tails  )  THEN
95          IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
96             message_string = 'maximum_number_of_tails needs to be increas' // &
97                              'ed &but this is not allowed with netcdf_dat' // &
98                              'a_format < 3'
99             CALL message( 'lpm_release_set', 'PA0147', 2, 2, -1, 6, 1 )
100          ELSE
101             CALL lpm_extend_tail_array( number_of_initial_tails )
102          ENDIF
103       ENDIF
104    ENDIF
105
106    IF ( number_of_initial_particles /= 0 )  THEN
107
108       is = number_of_particles + 1
109       ie = number_of_particles + number_of_initial_particles
110       particles(is:ie) = initial_particles(1:number_of_initial_particles)
111!
112!--    Add random fluctuation to particle positions. Particles should
113!--    remain in the subdomain.
114       IF ( random_start_position )  THEN
115
116          DO  n = is, ie
117
118             IF ( psl(particles(n)%group) /= psr(particles(n)%group) )  THEN
119                particles(n)%x = particles(n)%x +                         &
120                                 ( random_function( iran_part ) - 0.5 ) * &
121                                 pdx(particles(n)%group)
122                IF ( particles(n)%x  <=  ( nxl - 0.5 ) * dx )  THEN
123                   particles(n)%x = ( nxl - 0.4999999999 ) * dx
124                ELSEIF ( particles(n)%x  >=  ( nxr + 0.5 ) * dx )  THEN
125                   particles(n)%x = ( nxr + 0.4999999999 ) * dx
126                ENDIF
127             ENDIF
128
129             IF ( pss(particles(n)%group) /= psn(particles(n)%group) )  THEN
130                particles(n)%y = particles(n)%y +                         &
131                                 ( random_function( iran_part ) - 0.5 ) * &
132                                 pdy(particles(n)%group)
133                IF ( particles(n)%y  <=  ( nys - 0.5 ) * dy )  THEN
134                   particles(n)%y = ( nys - 0.4999999999 ) * dy
135                ELSEIF ( particles(n)%y  >=  ( nyn + 0.5 ) * dy )  THEN
136                   particles(n)%y = ( nyn + 0.4999999999 ) * dy
137                ENDIF
138             ENDIF
139
140             IF ( psb(particles(n)%group) /= pst(particles(n)%group) )  THEN
141                particles(n)%z = particles(n)%z +                         &
142                                 ( random_function( iran_part ) - 0.5 ) * &
143                                 pdz(particles(n)%group)
144             ENDIF
145
146          ENDDO
147
148       ENDIF
149
150!
151!--    Set the beginning of the new particle tails and their age
152       IF ( use_particle_tails )  THEN
153
154          DO  n = is, ie
155!
156!--          New particles which should have a tail, already have got a
157!--          provisional tail id unequal zero (see lpm_init)
158             IF ( particles(n)%tail_id /= 0 )  THEN
159
160                number_of_tails = number_of_tails + 1
161                nn = number_of_tails
162                particles(n)%tail_id = nn   ! set the final tail id
163                particle_tail_coordinates(1,1,nn) = particles(n)%x
164                particle_tail_coordinates(1,2,nn) = particles(n)%y
165                particle_tail_coordinates(1,3,nn) = particles(n)%z
166                particle_tail_coordinates(1,4,nn) = particles(n)%class
167                particles(n)%tailpoints = 1
168
169                IF ( minimum_tailpoint_distance /= 0.0 )  THEN
170                   particle_tail_coordinates(2,1,nn) = particles(n)%x
171                   particle_tail_coordinates(2,2,nn) = particles(n)%y
172                   particle_tail_coordinates(2,3,nn) = particles(n)%z
173                   particle_tail_coordinates(2,4,nn) = particles(n)%class
174                   particle_tail_coordinates(1:2,5,nn) = 0.0
175                   particles(n)%tailpoints = 2
176                ENDIF
177
178             ENDIF
179
180          ENDDO
181
182       ENDIF
183
184       number_of_particles = number_of_particles + number_of_initial_particles
185
186    ENDIF
187
188 END SUBROUTINE lpm_release_set
Note: See TracBrowser for help on using the repository browser.