source: palm/trunk/SOURCE/lpm_extend_tails.f90 @ 1350

Last change on this file since 1350 was 1321, checked in by raasch, 11 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1 SUBROUTINE lpm_extend_tails
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_extend_tails.f90 1321 2014-03-20 09:40:40Z maronga $
27!
28! 1320 2014-03-20 08:40:49Z raasch
29! ONLY-attribute added to USE-statements,
30! kind-parameters added to all INTEGER and REAL declaration statements,
31! kinds are defined in new module kinds,
32! comment fields (!:) to be used for variable explanations added to
33! all variable declaration statements
34!
35! 1036 2012-10-22 13:43:42Z raasch
36! code put under GPL (PALM 3.9)
37!
38! 849 2012-03-15 10:35:09Z raasch
39! initial revision (former part of advec_particles)
40!
41!
42! Description:
43! ------------
44! Add the current particle positions to the particle tails.
45!------------------------------------------------------------------------------!
46
47    USE control_parameters,                                                    &
48        ONLY:  dt_3d
49
50    USE kinds
51
52    USE particle_attributes,                                                   &
53        ONLY:  maximum_number_of_tailpoints, maximum_tailpoint_age,            &
54               minimum_tailpoint_distance, number_of_particles, particles,     &
55               particle_tail_coordinates
56
57    IMPLICIT NONE
58
59    INTEGER(iwp) ::  i       !:
60    INTEGER(iwp) ::  n       !:
61    INTEGER(iwp) ::  nn      !:
62
63    REAL(wp) ::  distance    !:
64
65
66    distance = 0.0
67
68    DO  n = 1, number_of_particles
69
70       nn = particles(n)%tail_id
71
72       IF ( nn /= 0 )  THEN
73!
74!--       Calculate the distance between the actual particle position and the
75!--       next tailpoint
76          IF ( minimum_tailpoint_distance /= 0.0 )  THEN
77             distance = ( particle_tail_coordinates(1,1,nn) -      &
78                          particle_tail_coordinates(2,1,nn) )**2 + &
79                        ( particle_tail_coordinates(1,2,nn) -      &
80                          particle_tail_coordinates(2,2,nn) )**2 + &
81                        ( particle_tail_coordinates(1,3,nn) -      &
82                          particle_tail_coordinates(2,3,nn) )**2
83          ENDIF
84
85!
86!--       First, increase the index of all existings tailpoints by one
87          IF ( distance >= minimum_tailpoint_distance )  THEN
88
89             DO  i = particles(n)%tailpoints, 1, -1
90                particle_tail_coordinates(i+1,:,nn) = &
91                                               particle_tail_coordinates(i,:,nn)
92             ENDDO
93!
94!--          Increase the counter which contains the number of tailpoints.
95!--          This must always be smaller than the given maximum number of
96!--          tailpoints because otherwise the index bounds of
97!--          particle_tail_coordinates would be exceeded
98             IF ( particles(n)%tailpoints < maximum_number_of_tailpoints-1 ) &
99             THEN
100                particles(n)%tailpoints = particles(n)%tailpoints + 1
101             ENDIF
102          ENDIF
103!
104!--       In any case, store the new point at the beginning of the tail
105          particle_tail_coordinates(1,1,nn) = particles(n)%x
106          particle_tail_coordinates(1,2,nn) = particles(n)%y
107          particle_tail_coordinates(1,3,nn) = particles(n)%z
108          particle_tail_coordinates(1,4,nn) = particles(n)%class
109!
110!--       Increase the age of the tailpoints
111          IF ( minimum_tailpoint_distance /= 0.0 )  THEN
112             particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) =    &
113               particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) + dt_3d
114!
115!--          Delete the last tailpoint, if it has exceeded its maximum age
116             IF ( particle_tail_coordinates(particles(n)%tailpoints,5,nn) > &
117                  maximum_tailpoint_age )  THEN
118                particles(n)%tailpoints = particles(n)%tailpoints - 1
119             ENDIF
120          ENDIF
121
122       ENDIF
123
124    ENDDO
125
126
127 END SUBROUTINE lpm_extend_tails
Note: See TracBrowser for help on using the repository browser.