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

Last change on this file since 2234 was 2101, checked in by suehring, 8 years ago

last commit documented

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