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

Last change on this file since 2716 was 2716, checked in by kanani, 6 years ago

Correction of "Former revisions" section

  • Property svn:keywords set to Id
File size: 7.0 KB
Line 
1!> @file lpm_read_restart_file.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! 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-2017 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_read_restart_file.f90 2716 2017-12-29 16:35:59Z kanani $
27! Corrected "Former revisions" section
28!
29! 2696 2017-12-14 17:12:51Z kanani
30! Change in file header (GPL part)
31!
32! 2606 2017-11-10 10:36:31Z schwenkel
33! Changed particle box locations: center of particle box now coincides
34! with scalar grid point of same index.
35! Renamed module and subroutines: lpm_pack_arrays_mod -> lpm_pack_and_sort_mod
36! lpm_pack_all_arrays -> lpm_sort_in_subboxes, lpm_pack_arrays -> lpm_pack
37! lpm_sort -> lpm_sort_timeloop_done
38!
39! 2312 2017-07-14 20:26:51Z hoffmann
40! Extended particle data type.
41!
42! 2305 2017-07-06 11:18:47Z hoffmann
43! Improved calculation of particle IDs.
44!
45! 2265 2017-06-08 16:58:28Z schwenkel
46! Unused variables removed.
47!
48! 2101 2017-01-05 16:42:31Z suehring
49!
50! 2000 2016-08-20 18:09:15Z knoop
51! Forced header and separation lines into 80 columns
52!
53! 1822 2016-04-07 07:49:42Z hoffmann
54! Tails removed. Unused variables removed.
55!
56! 1682 2015-10-07 23:56:08Z knoop
57! Code annotations made doxygen readable
58!
59! 1359 2014-04-11 17:15:14Z hoffmann
60! New particle structure integrated.
61!
62! 1320 2014-03-20 08:40:49Z raasch
63! ONLY-attribute added to USE-statements,
64! comment fields (!:) to be used for variable explanations added to
65! all variable declaration statements
66!
67! 1036 2012-10-22 13:43:42Z raasch
68! code put under GPL (PALM 3.9)
69!
70! 849 2012-03-15 10:35:09Z raasch
71! initial revision (former part of init_particles)
72!
73!
74! Description:
75! ------------
76!> Read particle data from the restart file.
77!------------------------------------------------------------------------------!
78 SUBROUTINE lpm_read_restart_file
79
80
81    USE control_parameters,                                                    &
82        ONLY:  message_string
83
84    USE indices,                                                               &
85        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
86
87    USE kinds
88
89    USE lpm_pack_and_sort_mod,                                                   &
90        ONLY:  lpm_sort_in_subboxes
91
92    USE particle_attributes,                                                   &
93        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
94               grid_particles, min_nr_particle, number_of_particles,           &
95               number_of_particle_groups, particle_groups, particle_type,      &
96               prt_count, time_prel, time_write_particle_data, zero_particle
97
98    USE pegrid
99
100    IMPLICIT NONE
101
102    CHARACTER (LEN=10) ::  particle_binary_version    !<
103    CHARACTER (LEN=10) ::  version_on_file            !<
104
105    INTEGER(iwp) :: alloc_size !<
106    INTEGER(iwp) :: ip         !<
107    INTEGER(iwp) :: jp         !<
108    INTEGER(iwp) :: kp         !<
109
110    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !<
111
112!
113!-- Read particle data from previous model run.
114!-- First open the input unit.
115    IF ( myid_char == '' )  THEN
116       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN'//myid_char, &
117                  FORM='UNFORMATTED' )
118    ELSE
119       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN/'//myid_char, &
120                  FORM='UNFORMATTED' )
121    ENDIF
122
123!
124!-- First compare the version numbers
125    READ ( 90 )  version_on_file
126    particle_binary_version = '4.0'
127    IF ( TRIM( version_on_file ) /= TRIM( particle_binary_version ) )  THEN
128       message_string = 'version mismatch concerning data from prior ' // &
129                        'run &version on file    = "' //                  &
130                                      TRIM( version_on_file ) //          &
131                        '&version in program = "' //                      &
132                                      TRIM( particle_binary_version ) // '"'
133       CALL message( 'lpm_read_restart_file', 'PA0214', 1, 2, 0, 6, 0 )
134    ENDIF
135
136!
137!-- If less particles are stored on the restart file than prescribed by
138!-- min_nr_particle, the remainder is initialized by zero_particle to avoid
139!-- errors.
140    zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
141                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
142                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
143                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
144                                   0, 0, 0_idp, .FALSE., -1 )
145!
146!-- Read some particle parameters and the size of the particle arrays,
147!-- allocate them and read their contents.
148    READ ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,                  &
149                 number_of_particle_groups, particle_groups, time_prel,     &
150                 time_write_particle_data
151
152    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
153              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
154
155    READ ( 90 )  prt_count
156
157    DO  ip = nxl, nxr
158       DO  jp = nys, nyn
159          DO  kp = nzb+1, nzt
160
161             number_of_particles = prt_count(kp,jp,ip)
162             IF ( number_of_particles > 0 )  THEN
163                alloc_size = MAX( INT( number_of_particles *                   &
164                             ( 1.0_wp + alloc_factor / 100.0_wp ) ),           &
165                             min_nr_particle )
166             ELSE
167                alloc_size = min_nr_particle
168             ENDIF
169
170             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
171
172             IF ( number_of_particles > 0 )  THEN
173                ALLOCATE( tmp_particles(1:number_of_particles) )
174                READ ( 90 )  tmp_particles
175                grid_particles(kp,jp,ip)%particles(1:number_of_particles) = tmp_particles
176                DEALLOCATE( tmp_particles )
177                IF ( number_of_particles < alloc_size )  THEN
178                   grid_particles(kp,jp,ip)%particles(number_of_particles+1:alloc_size) &
179                      = zero_particle
180                ENDIF
181             ELSE
182                grid_particles(kp,jp,ip)%particles(1:alloc_size) = zero_particle
183             ENDIF
184
185          ENDDO
186       ENDDO
187    ENDDO
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_sort_in_subboxes
194
195
196 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.