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