SUBROUTINE lpm_pack_arrays !--------------------------------------------------------------------------------! ! 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_pack_arrays.f90 1321 2014-03-20 09:40:40Z maronga $ ! ! 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: ! ------------ ! Pack particle and tail arrays, which means eliminate those elements marked for ! deletion and move data with higher index values to these free indices. ! Determine the new number of particles. !------------------------------------------------------------------------------! USE kinds USE particle_attributes, & ONLY: deleted_particles, deleted_tails, new_tail_id, & number_of_particles, number_of_tails, particles, particle_mask, & particle_tail_coordinates, tail_mask, use_particle_tails IMPLICIT NONE INTEGER(iwp) :: n !: INTEGER(iwp) :: nd !: INTEGER(iwp) :: nn !: ! !-- Find out elements marked for deletion and move data with higher index !-- values to these free indices nn = 0 nd = 0 DO n = 1, number_of_particles IF ( particle_mask(n) ) THEN nn = nn + 1 particles(nn) = particles(n) ELSE nd = nd + 1 ENDIF ENDDO ! !-- The number of deleted particles has been determined in routines !-- lpm_boundary_conds, lpm_droplet_collision, and lpm_exchange_horiz number_of_particles = number_of_particles - deleted_particles ! !-- Handle tail array in the same way, store the new tail ids and re-assign it !-- to the respective particles IF ( use_particle_tails ) THEN nn = 0 nd = 0 DO n = 1, number_of_tails IF ( tail_mask(n) ) THEN nn = nn + 1 particle_tail_coordinates(:,:,nn) = & particle_tail_coordinates(:,:,n) new_tail_id(n) = nn ELSE nd = nd + 1 ENDIF ENDDO DO n = 1, number_of_particles IF ( particles(n)%tail_id /= 0 ) THEN particles(n)%tail_id = new_tail_id(particles(n)%tail_id) ENDIF ENDDO ENDIF ! !-- The number of deleted tails has been determined in routines !-- lpm_boundary_conds and lpm_exchange_horiz number_of_tails = number_of_tails - deleted_tails END SUBROUTINE lpm_pack_arrays