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

Last change on this file since 2310 was 2305, checked in by hoffmann, 7 years ago

Improved calculation of particle IDs.

  • Property svn:keywords set to Id
File size: 6.5 KB
RevLine 
[1682]1!> @file lpm_read_restart_file.f90
[2000]2!------------------------------------------------------------------------------!
[1036]3! This file is part of PALM.
4!
[2000]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.
[1036]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!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[849]20! Current revisions:
21! ------------------
[1360]22!
[2001]23!
[849]24! Former revisions:
25! -----------------
26! $Id: lpm_read_restart_file.f90 2305 2017-07-06 11:18:47Z gronemeier $
[2305]27! Improved calculation of particle IDs.
28!
29! 2265 2017-06-08 16:58:28Z schwenkel
[2265]30! Unused variables removed.
31!
32! 2101 2017-01-05 16:42:31Z suehring
[849]33!
[2001]34! 2000 2016-08-20 18:09:15Z knoop
35! Forced header and separation lines into 80 columns
36!
[1823]37! 1822 2016-04-07 07:49:42Z hoffmann
38! Tails removed. Unused variables removed.
39!
[1683]40! 1682 2015-10-07 23:56:08Z knoop
41! Code annotations made doxygen readable
42!
[1360]43! 1359 2014-04-11 17:15:14Z hoffmann
44! New particle structure integrated.
45!
[1321]46! 1320 2014-03-20 08:40:49Z raasch
47! ONLY-attribute added to USE-statements,
48! comment fields (!:) to be used for variable explanations added to
49! all variable declaration statements
50!
[1037]51! 1036 2012-10-22 13:43:42Z raasch
52! code put under GPL (PALM 3.9)
53!
[850]54! 849 2012-03-15 10:35:09Z raasch
55! initial revision (former part of init_particles)
[849]56!
[850]57!
[849]58! Description:
59! ------------
[1682]60!> Read particle data from the restart file.
[849]61!------------------------------------------------------------------------------!
[1682]62 SUBROUTINE lpm_read_restart_file
63 
[849]64
[1320]65    USE control_parameters,                                                    &
66        ONLY:  message_string
67
68    USE indices,                                                               &
[1822]69        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
[1320]70
[1359]71    USE kinds
72
73    USE lpm_pack_arrays_mod,                                                   &
74        ONLY:  lpm_pack_all_arrays
75
[1320]76    USE particle_attributes,                                                   &
[1359]77        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
[2265]78               grid_particles, min_nr_particle, number_of_particles,           &
79               number_of_particle_groups, particle_groups, particle_type,      &
80               prt_count, time_prel, time_write_particle_data, zero_particle
[1320]81
[849]82    USE pegrid
83
84    IMPLICIT NONE
85
[1682]86    CHARACTER (LEN=10) ::  particle_binary_version    !<
87    CHARACTER (LEN=10) ::  version_on_file            !<
[849]88
[1682]89    INTEGER(iwp) :: alloc_size !<
90    INTEGER(iwp) :: ip         !<
91    INTEGER(iwp) :: jp         !<
92    INTEGER(iwp) :: kp         !<
[1359]93
[1682]94    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !<
[1359]95
[849]96!
97!-- Read particle data from previous model run.
98!-- First open the input unit.
99    IF ( myid_char == '' )  THEN
100       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN'//myid_char, &
101                  FORM='UNFORMATTED' )
102    ELSE
103       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN/'//myid_char, &
104                  FORM='UNFORMATTED' )
105    ENDIF
106
107!
108!-- First compare the version numbers
109    READ ( 90 )  version_on_file
[1822]110    particle_binary_version = '4.0'
[849]111    IF ( TRIM( version_on_file ) /= TRIM( particle_binary_version ) )  THEN
112       message_string = 'version mismatch concerning data from prior ' // &
113                        'run &version on file    = "' //                  &
114                                      TRIM( version_on_file ) //          &
115                        '&version in program = "' //                      &
116                                      TRIM( particle_binary_version ) // '"'
117       CALL message( 'lpm_read_restart_file', 'PA0214', 1, 2, 0, 6, 0 )
118    ENDIF
119
120!
[1359]121!-- If less particles are stored on the restart file than prescribed by
122!-- min_nr_particle, the remainder is initialized by zero_particle to avoid
123!-- errors.
124    zero_particle = particle_type( 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_wp,  &
[2305]127                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,          &
128                                   0, 0, 0_idp, .FALSE., -1 )
[1359]129!
[849]130!-- Read some particle parameters and the size of the particle arrays,
131!-- allocate them and read their contents.
132    READ ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,                  &
[1822]133                 number_of_particle_groups, particle_groups, time_prel,     &
[2265]134                 time_write_particle_data
[849]135
[1359]136    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
137              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[849]138
[1359]139    READ ( 90 )  prt_count
[849]140
[1359]141    DO  ip = nxl, nxr
142       DO  jp = nys, nyn
143          DO  kp = nzb+1, nzt
[849]144
[1359]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
[849]153
[1359]154             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
[849]155
[1359]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
[849]168
[1359]169          ENDDO
170       ENDDO
171    ENDDO
[849]172
173    CLOSE ( 90 )
[1359]174!
175!-- Must be called to sort particles into blocks, which is needed for a fast
176!-- interpolation of the LES fields on the particle position.
177    CALL lpm_pack_all_arrays
[849]178
179
180 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.