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

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

code has been put under the GNU General Public License (v3)

  • Property svn:keywords set to Id
File size: 2.6 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-2012  Leibniz University Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_extend_particle_array.f90 1036 2012-10-22 13:43:42Z raasch $
27!
28! 849 2012-03-15 10:35:09Z raasch
29! initial revision (former part of advec_particles)
30!
31!
32! Description:
33! ------------
34! Allocates more memory for the particle array.
35!------------------------------------------------------------------------------!
36
37    USE particle_attributes
38
39    IMPLICIT NONE
40
41    INTEGER ::  new_maximum_number, number_of_new_particles
42
43    LOGICAL, DIMENSION(:), ALLOCATABLE ::  tmp_particle_mask
44
45    TYPE(particle_type), DIMENSION(:), ALLOCATABLE ::  tmp_particles
46
47
48
49    new_maximum_number = maximum_number_of_particles + &
50                   MAX( 5*number_of_new_particles, number_of_initial_particles )
51
52    IF ( write_particle_statistics )  THEN
53       CALL check_open( 80 )
54       WRITE ( 80, '(''*** Request: '', I7, '' new_maximum_number(prt)'')' ) &
55                            new_maximum_number
56       CALL close_file( 80 )
57    ENDIF
58
59    ALLOCATE( tmp_particles(maximum_number_of_particles), &
60              tmp_particle_mask(maximum_number_of_particles) )
61
62    tmp_particles     = particles
63    tmp_particle_mask = particle_mask
64
65    DEALLOCATE( particles, particle_mask )
66    ALLOCATE( particles(new_maximum_number), particle_mask(new_maximum_number) )
67
68    maximum_number_of_particles = new_maximum_number
69
70    particles(1:number_of_particles) = tmp_particles(1:number_of_particles)
71    particle_mask(1:number_of_particles) = &
72                                       tmp_particle_mask(1:number_of_particles)
73    particle_mask(number_of_particles+1:maximum_number_of_particles) = .TRUE.
74
75    DEALLOCATE( tmp_particles, tmp_particle_mask )
76
77
78 END SUBROUTINE lpm_extend_particle_array
Note: See TracBrowser for help on using the repository browser.