SUBROUTINE lpm_release_set !--------------------------------------------------------------------------------! ! This file is part of PALM. ! ! PALM is free software: you can redistribute it and/or modify it under the terms ! of the GNU General Public License as published by the Free Software Foundation, ! either version 3 of the License, or (at your option) any later version. ! ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License along with ! PALM. If not, see . ! ! Copyright 1997-2014 Leibniz Universitaet Hannover !--------------------------------------------------------------------------------! ! ! Current revisions: ! ------------------ ! ! ! Former revisions: ! ----------------- ! $Id: lpm_release_set.f90 1329 2014-03-21 11:09:15Z kanani $ ! ! 1327 2014-03-21 11:00:16Z raasch ! -netcdf output queries ! ! 1320 2014-03-20 08:40:49Z raasch ! ONLY-attribute added to USE-statements, ! kind-parameters added to all INTEGER and REAL declaration statements, ! kinds are defined in new module kinds, ! comment fields (!:) to be used for variable explanations added to ! all variable declaration statements ! ! 1036 2012-10-22 13:43:42Z raasch ! code put under GPL (PALM 3.9) ! ! 849 2012-03-15 10:35:09Z raasch ! initial revision (former part of advec_particles) ! ! ! Description: ! ------------ ! Release a new set of particles and, if required, particle tails. These ! particles/tails are added at the end of the existing arrays. Extend the ! respective particle and tail arrays, if neccessary. !------------------------------------------------------------------------------! USE control_parameters, & ONLY: iran, message_string, netcdf_data_format USE grid_variables, & ONLY: dx, dy USE indices, & ONLY: nxl, nxr, nyn, nys USE kinds USE particle_attributes, & ONLY: initial_particles, iran_part, maximum_number_of_particles, & maximum_number_of_tails, minimum_tailpoint_distance, & number_of_initial_particles, number_of_initial_tails, & number_of_particles, number_of_tails, particles, & particle_tail_coordinates, pdx, pdy, pdz, psb, psl, psn, psr, & pss, pst, random_start_position, use_particle_tails USE random_function_mod, & ONLY: random_function IMPLICIT NONE INTEGER(iwp) :: ie !: INTEGER(iwp) :: is !: INTEGER(iwp) :: n !: INTEGER(iwp) :: nn !: ! !-- Check, if particle storage must be extended IF ( number_of_particles + number_of_initial_particles > & maximum_number_of_particles ) THEN IF ( netcdf_data_format < 3 ) THEN message_string = 'maximum_number_of_particles needs to be increa' // & 'sed &but this is not allowed with netcdf_data_' // & 'format < 3' CALL message( 'lpm_release_set', 'PA0146', 2, 2, -1, 6, 1 ) ELSE CALL lpm_extend_particle_array( number_of_initial_particles ) ENDIF ENDIF ! !-- Check, if tail storage must be extended IF ( use_particle_tails ) THEN IF ( number_of_tails + number_of_initial_tails > & maximum_number_of_tails ) THEN IF ( netcdf_data_format < 3 ) THEN message_string = 'maximum_number_of_tails needs to be increas' // & 'ed &but this is not allowed with netcdf_dat' // & 'a_format < 3' CALL message( 'lpm_release_set', 'PA0147', 2, 2, -1, 6, 1 ) ELSE CALL lpm_extend_tail_array( number_of_initial_tails ) ENDIF ENDIF ENDIF IF ( number_of_initial_particles /= 0 ) THEN is = number_of_particles + 1 ie = number_of_particles + number_of_initial_particles particles(is:ie) = initial_particles(1:number_of_initial_particles) ! !-- Add random fluctuation to particle positions. Particles should !-- remain in the subdomain. IF ( random_start_position ) THEN DO n = is, ie IF ( psl(particles(n)%group) /= psr(particles(n)%group) ) THEN particles(n)%x = particles(n)%x + & ( random_function( iran_part ) - 0.5 ) * & pdx(particles(n)%group) IF ( particles(n)%x <= ( nxl - 0.5 ) * dx ) THEN particles(n)%x = ( nxl - 0.4999999999 ) * dx ELSEIF ( particles(n)%x >= ( nxr + 0.5 ) * dx ) THEN particles(n)%x = ( nxr + 0.4999999999 ) * dx ENDIF ENDIF IF ( pss(particles(n)%group) /= psn(particles(n)%group) ) THEN particles(n)%y = particles(n)%y + & ( random_function( iran_part ) - 0.5 ) * & pdy(particles(n)%group) IF ( particles(n)%y <= ( nys - 0.5 ) * dy ) THEN particles(n)%y = ( nys - 0.4999999999 ) * dy ELSEIF ( particles(n)%y >= ( nyn + 0.5 ) * dy ) THEN particles(n)%y = ( nyn + 0.4999999999 ) * dy ENDIF ENDIF IF ( psb(particles(n)%group) /= pst(particles(n)%group) ) THEN particles(n)%z = particles(n)%z + & ( random_function( iran_part ) - 0.5 ) * & pdz(particles(n)%group) ENDIF ENDDO ENDIF ! !-- Set the beginning of the new particle tails and their age IF ( use_particle_tails ) THEN DO n = is, ie ! !-- New particles which should have a tail, already have got a !-- provisional tail id unequal zero (see lpm_init) IF ( particles(n)%tail_id /= 0 ) THEN number_of_tails = number_of_tails + 1 nn = number_of_tails particles(n)%tail_id = nn ! set the final tail id particle_tail_coordinates(1,1,nn) = particles(n)%x particle_tail_coordinates(1,2,nn) = particles(n)%y particle_tail_coordinates(1,3,nn) = particles(n)%z particle_tail_coordinates(1,4,nn) = particles(n)%class particles(n)%tailpoints = 1 IF ( minimum_tailpoint_distance /= 0.0 ) THEN particle_tail_coordinates(2,1,nn) = particles(n)%x particle_tail_coordinates(2,2,nn) = particles(n)%y particle_tail_coordinates(2,3,nn) = particles(n)%z particle_tail_coordinates(2,4,nn) = particles(n)%class particle_tail_coordinates(1:2,5,nn) = 0.0 particles(n)%tailpoints = 2 ENDIF ENDIF ENDDO ENDIF number_of_particles = number_of_particles + number_of_initial_particles ENDIF END SUBROUTINE lpm_release_set