source: palm/trunk/SOURCE/lpm_extend_particle_array.f90 @ 1322

Last change on this file since 1322 was 1321, checked in by raasch, 10 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1 SUBROUTINE lpm_extend_particle_array( number_of_new_particles )
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_particle_array.f90 1321 2014-03-20 09:40:40Z raasch $
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! Allocates more memory for the particle array.
45!------------------------------------------------------------------------------!
46
47    USE kinds
48
49    USE particle_attributes,                                                   &
50        ONLY:  number_of_initial_particles, number_of_particles,               &
51               maximum_number_of_particles, particles, particle_mask,          &
52               particle_type, write_particle_statistics
53
54    IMPLICIT NONE
55
56    INTEGER(iwp) ::  new_maximum_number                              !:
57    INTEGER(iwp) ::  number_of_new_particles                         !:
58
59
60    LOGICAL, DIMENSION(:), ALLOCATABLE ::  tmp_particle_mask         !:
61
62    TYPE(particle_type), DIMENSION(:), ALLOCATABLE ::  tmp_particles !:
63
64
65
66    new_maximum_number = maximum_number_of_particles + &
67                   MAX( 5*number_of_new_particles, number_of_initial_particles )
68
69    IF ( write_particle_statistics )  THEN
70       CALL check_open( 80 )
71       WRITE ( 80, '(''*** Request: '', I7, '' new_maximum_number(prt)'')' ) &
72                            new_maximum_number
73       CALL close_file( 80 )
74    ENDIF
75
76    ALLOCATE( tmp_particles(maximum_number_of_particles), &
77              tmp_particle_mask(maximum_number_of_particles) )
78
79    tmp_particles     = particles
80    tmp_particle_mask = particle_mask
81
82    DEALLOCATE( particles, particle_mask )
83    ALLOCATE( particles(new_maximum_number), particle_mask(new_maximum_number) )
84
85    maximum_number_of_particles = new_maximum_number
86
87    particles(1:number_of_particles) = tmp_particles(1:number_of_particles)
88    particle_mask(1:number_of_particles) = &
89                                       tmp_particle_mask(1:number_of_particles)
90    particle_mask(number_of_particles+1:maximum_number_of_particles) = .TRUE.
91
92    DEALLOCATE( tmp_particles, tmp_particle_mask )
93
94
95 END SUBROUTINE lpm_extend_particle_array
Note: See TracBrowser for help on using the repository browser.