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

Last change on this file since 1818 was 1818, checked in by maronga, 5 years ago

last commit documented / copyright update

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