source: palm/trunk/SOURCE/lpm_read_restart_file.f90 @ 1558

Last change on this file since 1558 was 1360, checked in by hoffmann, 11 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1 SUBROUTINE lpm_read_restart_file
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_read_restart_file.f90 1360 2014-04-11 17:20:32Z suehring $
27!
28! 1359 2014-04-11 17:15:14Z hoffmann
29! New particle structure integrated.
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! ONLY-attribute added to USE-statements,
33! comment fields (!:) to be used for variable explanations added to
34! all variable declaration statements
35!
36! 1036 2012-10-22 13:43:42Z raasch
37! code put under GPL (PALM 3.9)
38!
39! 849 2012-03-15 10:35:09Z raasch
40! initial revision (former part of init_particles)
41!
42!
43! Description:
44! ------------
45! Read particle data from the restart file.
46!------------------------------------------------------------------------------!
47
48    USE control_parameters,                                                    &
49        ONLY:  message_string
50
51    USE indices,                                                               &
52        ONLY:  nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, nzb, nzt
53
54    USE kinds
55
56    USE lpm_pack_arrays_mod,                                                   &
57        ONLY:  lpm_pack_all_arrays
58
59    USE particle_attributes,                                                   &
60        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
61               grid_particles, maximum_number_of_particles,                    &
62               maximum_number_of_tailpoints, maximum_number_of_tails,          &
63               min_nr_particle, new_tail_id, number_of_particles,              &
64               number_of_particle_groups, number_of_tails, particles,          &
65               particle_groups, particle_tail_coordinates, particle_type,      &
66               prt_count, sort_count, tail_mask, time_prel,                    &
67               time_write_particle_data, uniform_particles,                    &
68               use_particle_tails, zero_particle
69
70    USE pegrid
71
72    IMPLICIT NONE
73
74    CHARACTER (LEN=10) ::  particle_binary_version    !:
75    CHARACTER (LEN=10) ::  version_on_file            !:
76
77    INTEGER(iwp) :: alloc_size !:
78    INTEGER(iwp) :: ip         !:
79    INTEGER(iwp) :: jp         !:
80    INTEGER(iwp) :: kp         !:
81
82    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !:
83
84!
85!-- Read particle data from previous model run.
86!-- First open the input unit.
87    IF ( myid_char == '' )  THEN
88       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN'//myid_char, &
89                  FORM='UNFORMATTED' )
90    ELSE
91       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN/'//myid_char, &
92                  FORM='UNFORMATTED' )
93    ENDIF
94
95!
96!-- First compare the version numbers
97    READ ( 90 )  version_on_file
98    particle_binary_version = '3.2'
99    IF ( TRIM( version_on_file ) /= TRIM( particle_binary_version ) )  THEN
100       message_string = 'version mismatch concerning data from prior ' // &
101                        'run &version on file    = "' //                  &
102                                      TRIM( version_on_file ) //          &
103                        '&version in program = "' //                      &
104                                      TRIM( particle_binary_version ) // '"'
105       CALL message( 'lpm_read_restart_file', 'PA0214', 1, 2, 0, 6, 0 )
106    ENDIF
107
108!
109!-- If less particles are stored on the restart file than prescribed by
110!-- min_nr_particle, the remainder is initialized by zero_particle to avoid
111!-- errors.
112#if defined( __twocachelines )
113    zero_particle = particle_type( 0.0_wp, 0.0_sp, 0.0_sp, 0.0_sp, 0.0_sp,  &
114                                   0.0_sp, 0.0_sp, 0.0_wp, 0.0_wp, 0.0_wp,  &
115                                   0, .FALSE., 0.0_wp, 0.0_wp, 0.0_wp,      &
116                                   0.0_sp, 0.0_sp, 0.0_sp, 0.0_sp, 0.0_sp,  &
117                                   0.0_sp, 0, 0, 0, -1)
118#else
119    zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
120                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
121                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
122                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0, 0, 0, &
123                                   0, .FALSE., -1)
124#endif
125
126!
127!-- Read some particle parameters and the size of the particle arrays,
128!-- allocate them and read their contents.
129    READ ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,                  &
130                 maximum_number_of_tailpoints, maximum_number_of_tails,     &
131                 number_of_particle_groups, number_of_tails,                &
132                 particle_groups, time_prel, time_write_particle_data,      &
133                 uniform_particles
134
135    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
136              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
137
138    READ ( 90 )  prt_count
139
140    maximum_number_of_particles = 0
141    DO  ip = nxl, nxr
142       DO  jp = nys, nyn
143          DO  kp = nzb+1, nzt
144
145             number_of_particles = prt_count(kp,jp,ip)
146             IF ( number_of_particles > 0 )  THEN
147                alloc_size = MAX( INT( number_of_particles *                   &
148                             ( 1.0_wp + alloc_factor / 100.0_wp ) ),           &
149                             min_nr_particle )
150             ELSE
151                alloc_size = min_nr_particle
152             ENDIF
153
154             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
155
156             IF ( number_of_particles > 0 )  THEN
157                ALLOCATE( tmp_particles(1:number_of_particles) )
158                READ ( 90 )  tmp_particles
159                grid_particles(kp,jp,ip)%particles(1:number_of_particles) = tmp_particles
160                DEALLOCATE( tmp_particles )
161                IF ( number_of_particles < alloc_size )  THEN
162                   grid_particles(kp,jp,ip)%particles(number_of_particles+1:alloc_size) &
163                      = zero_particle
164                ENDIF
165             ELSE
166                grid_particles(kp,jp,ip)%particles(1:alloc_size) = zero_particle
167             ENDIF
168
169             maximum_number_of_particles = maximum_number_of_particles + alloc_size
170
171          ENDDO
172       ENDDO
173    ENDDO
174
175!
176!-- particle tails currently not available
177!    IF ( use_particle_tails )  THEN
178!       ALLOCATE( particle_tail_coordinates(maximum_number_of_tailpoints,5, &
179!                 maximum_number_of_tails),                                 &
180!                 new_tail_id(maximum_number_of_tails),                     &
181!                 tail_mask(maximum_number_of_tails) )
182!       READ ( 90 )  particle_tail_coordinates
183!    ENDIF
184
185    CLOSE ( 90 )
186!
187!-- Must be called to sort particles into blocks, which is needed for a fast
188!-- interpolation of the LES fields on the particle position.
189    CALL lpm_pack_all_arrays
190
191
192 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.