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

Last change on this file since 2279 was 2265, checked in by schwenkel, 7 years ago

unused variables removed

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