SUBROUTINE lpm_pack_arrays !------------------------------------------------------------------------------! ! Current revisions: ! ------------------ ! ! ! Former revisions: ! ----------------- ! $Id: lpm_pack_arrays.f90 850 2012-03-15 12:09:25Z hoffmann $ ! ! 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