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

Last change on this file since 2000 was 2000, checked in by knoop, 8 years ago

Forced header and separation lines into 80 columns

  • 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!
[1818]17! Copyright 1997-2016 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[849]20! Current revisions:
21! ------------------
[2000]22! Forced header and separation lines into 80 columns
[1360]23!
[849]24! Former revisions:
25! -----------------
26! $Id: lpm_read_restart_file.f90 2000 2016-08-20 18:09:15Z knoop $
27!
[1823]28! 1822 2016-04-07 07:49:42Z hoffmann
29! Tails removed. Unused variables removed.
30!
[1683]31! 1682 2015-10-07 23:56:08Z knoop
32! Code annotations made doxygen readable
33!
[1360]34! 1359 2014-04-11 17:15:14Z hoffmann
35! New particle structure integrated.
36!
[1321]37! 1320 2014-03-20 08:40:49Z raasch
38! ONLY-attribute added to USE-statements,
39! comment fields (!:) to be used for variable explanations added to
40! all variable declaration statements
41!
[1037]42! 1036 2012-10-22 13:43:42Z raasch
43! code put under GPL (PALM 3.9)
44!
[850]45! 849 2012-03-15 10:35:09Z raasch
46! initial revision (former part of init_particles)
[849]47!
[850]48!
[849]49! Description:
50! ------------
[1682]51!> Read particle data from the restart file.
[849]52!------------------------------------------------------------------------------!
[1682]53 SUBROUTINE lpm_read_restart_file
54 
[849]55
[1320]56    USE control_parameters,                                                    &
57        ONLY:  message_string
58
59    USE indices,                                                               &
[1822]60        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
[1320]61
[1359]62    USE kinds
63
64    USE lpm_pack_arrays_mod,                                                   &
65        ONLY:  lpm_pack_all_arrays
66
[1320]67    USE particle_attributes,                                                   &
[1359]68        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
69               grid_particles, maximum_number_of_particles,                    &
[1822]70               min_nr_particle, number_of_particles, number_of_particle_groups,&
71               particle_groups, particle_type, prt_count, time_prel,           &
72               time_write_particle_data, uniform_particles, zero_particle
[1320]73
[849]74    USE pegrid
75
76    IMPLICIT NONE
77
[1682]78    CHARACTER (LEN=10) ::  particle_binary_version    !<
79    CHARACTER (LEN=10) ::  version_on_file            !<
[849]80
[1682]81    INTEGER(iwp) :: alloc_size !<
82    INTEGER(iwp) :: ip         !<
83    INTEGER(iwp) :: jp         !<
84    INTEGER(iwp) :: kp         !<
[1359]85
[1682]86    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !<
[1359]87
[849]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
[1822]102    particle_binary_version = '4.0'
[849]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!
[1359]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    zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
117                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
118                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
119                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0, 0, 0, &
120                                   0, .FALSE., -1)
121!
[849]122!-- Read some particle parameters and the size of the particle arrays,
123!-- allocate them and read their contents.
124    READ ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,                  &
[1822]125                 number_of_particle_groups, particle_groups, time_prel,     &
126                 time_write_particle_data, uniform_particles
[849]127
[1359]128    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
129              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[849]130
[1359]131    READ ( 90 )  prt_count
[849]132
[1359]133    maximum_number_of_particles = 0
134    DO  ip = nxl, nxr
135       DO  jp = nys, nyn
136          DO  kp = nzb+1, nzt
[849]137
[1359]138             number_of_particles = prt_count(kp,jp,ip)
139             IF ( number_of_particles > 0 )  THEN
140                alloc_size = MAX( INT( number_of_particles *                   &
141                             ( 1.0_wp + alloc_factor / 100.0_wp ) ),           &
142                             min_nr_particle )
143             ELSE
144                alloc_size = min_nr_particle
145             ENDIF
[849]146
[1359]147             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
[849]148
[1359]149             IF ( number_of_particles > 0 )  THEN
150                ALLOCATE( tmp_particles(1:number_of_particles) )
151                READ ( 90 )  tmp_particles
152                grid_particles(kp,jp,ip)%particles(1:number_of_particles) = tmp_particles
153                DEALLOCATE( tmp_particles )
154                IF ( number_of_particles < alloc_size )  THEN
155                   grid_particles(kp,jp,ip)%particles(number_of_particles+1:alloc_size) &
156                      = zero_particle
157                ENDIF
158             ELSE
159                grid_particles(kp,jp,ip)%particles(1:alloc_size) = zero_particle
160             ENDIF
[849]161
[1359]162             maximum_number_of_particles = maximum_number_of_particles + alloc_size
[849]163
[1359]164          ENDDO
165       ENDDO
166    ENDDO
[849]167
168    CLOSE ( 90 )
[1359]169!
170!-- Must be called to sort particles into blocks, which is needed for a fast
171!-- interpolation of the LES fields on the particle position.
172    CALL lpm_pack_all_arrays
[849]173
174
175 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.