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

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

Forced header and separation lines into 80 columns

  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1!> @file lpm_read_restart_file.f90
2!------------------------------------------------------------------------------!
3! This file is part of PALM.
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-2016 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22! Forced header and separation lines into 80 columns
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_read_restart_file.f90 2000 2016-08-20 18:09:15Z knoop $
27!
28! 1822 2016-04-07 07:49:42Z hoffmann
29! Tails removed. Unused variables removed.
30!
31! 1682 2015-10-07 23:56:08Z knoop
32! Code annotations made doxygen readable
33!
34! 1359 2014-04-11 17:15:14Z hoffmann
35! New particle structure integrated.
36!
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!
42! 1036 2012-10-22 13:43:42Z raasch
43! code put under GPL (PALM 3.9)
44!
45! 849 2012-03-15 10:35:09Z raasch
46! initial revision (former part of init_particles)
47!
48!
49! Description:
50! ------------
51!> Read particle data from the restart file.
52!------------------------------------------------------------------------------!
53 SUBROUTINE lpm_read_restart_file
54 
55
56    USE control_parameters,                                                    &
57        ONLY:  message_string
58
59    USE indices,                                                               &
60        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
61
62    USE kinds
63
64    USE lpm_pack_arrays_mod,                                                   &
65        ONLY:  lpm_pack_all_arrays
66
67    USE particle_attributes,                                                   &
68        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
69               grid_particles, maximum_number_of_particles,                    &
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
73
74    USE pegrid
75
76    IMPLICIT NONE
77
78    CHARACTER (LEN=10) ::  particle_binary_version    !<
79    CHARACTER (LEN=10) ::  version_on_file            !<
80
81    INTEGER(iwp) :: alloc_size !<
82    INTEGER(iwp) :: ip         !<
83    INTEGER(iwp) :: jp         !<
84    INTEGER(iwp) :: kp         !<
85
86    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !<
87
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
102    particle_binary_version = '4.0'
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!
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!
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,                  &
125                 number_of_particle_groups, particle_groups, time_prel,     &
126                 time_write_particle_data, uniform_particles
127
128    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
129              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
130
131    READ ( 90 )  prt_count
132
133    maximum_number_of_particles = 0
134    DO  ip = nxl, nxr
135       DO  jp = nys, nyn
136          DO  kp = nzb+1, nzt
137
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
146
147             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
148
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
161
162             maximum_number_of_particles = maximum_number_of_particles + alloc_size
163
164          ENDDO
165       ENDDO
166    ENDDO
167
168    CLOSE ( 90 )
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
173
174
175 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.