SUBROUTINE lpm_extend_tails !--------------------------------------------------------------------------------! ! 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_extend_tails.f90 1037 2012-10-22 14:10:22Z raasch $ ! ! 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: ! ------------ ! Add the current particle positions to the particle tails. !------------------------------------------------------------------------------! USE control_parameters USE particle_attributes IMPLICIT NONE INTEGER :: i, n, nn REAL :: distance distance = 0.0 DO n = 1, number_of_particles nn = particles(n)%tail_id IF ( nn /= 0 ) THEN ! !-- Calculate the distance between the actual particle position and the !-- next tailpoint IF ( minimum_tailpoint_distance /= 0.0 ) THEN distance = ( particle_tail_coordinates(1,1,nn) - & particle_tail_coordinates(2,1,nn) )**2 + & ( particle_tail_coordinates(1,2,nn) - & particle_tail_coordinates(2,2,nn) )**2 + & ( particle_tail_coordinates(1,3,nn) - & particle_tail_coordinates(2,3,nn) )**2 ENDIF ! !-- First, increase the index of all existings tailpoints by one IF ( distance >= minimum_tailpoint_distance ) THEN DO i = particles(n)%tailpoints, 1, -1 particle_tail_coordinates(i+1,:,nn) = & particle_tail_coordinates(i,:,nn) ENDDO ! !-- Increase the counter which contains the number of tailpoints. !-- This must always be smaller than the given maximum number of !-- tailpoints because otherwise the index bounds of !-- particle_tail_coordinates would be exceeded IF ( particles(n)%tailpoints < maximum_number_of_tailpoints-1 ) & THEN particles(n)%tailpoints = particles(n)%tailpoints + 1 ENDIF ENDIF ! !-- In any case, store the new point at the beginning of the tail 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 ! !-- Increase the age of the tailpoints IF ( minimum_tailpoint_distance /= 0.0 ) THEN particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) = & particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) + dt_3d ! !-- Delete the last tailpoint, if it has exceeded its maximum age IF ( particle_tail_coordinates(particles(n)%tailpoints,5,nn) > & maximum_tailpoint_age ) THEN particles(n)%tailpoints = particles(n)%tailpoints - 1 ENDIF ENDIF ENDIF ENDDO END SUBROUTINE lpm_extend_tails