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-2012 Leibniz University Hannover !--------------------------------------------------------------------------------! ! ! Current revisions: ! ------------------ ! ! ! Former revisions: ! ----------------- ! $Id: lpm_pack_arrays.f90 1037 2012-10-22 14:10:22Z fricke $ ! ! 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 particle_attributes IMPLICIT NONE INTEGER :: n, nd, 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