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

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

new Lagrangian particle structure integrated

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