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

Last change on this file since 1936 was 1823, checked in by hoffmann, 9 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 6.4 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 terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2016 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! ------------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: lpm_read_restart_file.f90 1823 2016-04-07 08:57:52Z suehring $
26!
27! 1822 2016-04-07 07:49:42Z hoffmann
28! Tails removed. Unused variables removed.
29!
30! 1682 2015-10-07 23:56:08Z knoop
31! Code annotations made doxygen readable
32!
33! 1359 2014-04-11 17:15:14Z hoffmann
34! New particle structure integrated.
35!
36! 1320 2014-03-20 08:40:49Z raasch
37! ONLY-attribute added to USE-statements,
38! comment fields (!:) to be used for variable explanations added to
39! all variable declaration statements
40!
41! 1036 2012-10-22 13:43:42Z raasch
42! code put under GPL (PALM 3.9)
43!
44! 849 2012-03-15 10:35:09Z raasch
45! initial revision (former part of init_particles)
46!
47!
48! Description:
49! ------------
50!> Read particle data from the restart file.
51!------------------------------------------------------------------------------!
52 SUBROUTINE lpm_read_restart_file
53 
54
55    USE control_parameters,                                                    &
56        ONLY:  message_string
57
58    USE indices,                                                               &
59        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
60
61    USE kinds
62
63    USE lpm_pack_arrays_mod,                                                   &
64        ONLY:  lpm_pack_all_arrays
65
66    USE particle_attributes,                                                   &
67        ONLY:  alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,         &
68               grid_particles, maximum_number_of_particles,                    &
69               min_nr_particle, number_of_particles, number_of_particle_groups,&
70               particle_groups, particle_type, prt_count, time_prel,           &
71               time_write_particle_data, uniform_particles, zero_particle
72
73    USE pegrid
74
75    IMPLICIT NONE
76
77    CHARACTER (LEN=10) ::  particle_binary_version    !<
78    CHARACTER (LEN=10) ::  version_on_file            !<
79
80    INTEGER(iwp) :: alloc_size !<
81    INTEGER(iwp) :: ip         !<
82    INTEGER(iwp) :: jp         !<
83    INTEGER(iwp) :: kp         !<
84
85    TYPE(particle_type), DIMENSION(:), ALLOCATABLE :: tmp_particles !<
86
87!
88!-- Read particle data from previous model run.
89!-- First open the input unit.
90    IF ( myid_char == '' )  THEN
91       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN'//myid_char, &
92                  FORM='UNFORMATTED' )
93    ELSE
94       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_IN/'//myid_char, &
95                  FORM='UNFORMATTED' )
96    ENDIF
97
98!
99!-- First compare the version numbers
100    READ ( 90 )  version_on_file
101    particle_binary_version = '4.0'
102    IF ( TRIM( version_on_file ) /= TRIM( particle_binary_version ) )  THEN
103       message_string = 'version mismatch concerning data from prior ' // &
104                        'run &version on file    = "' //                  &
105                                      TRIM( version_on_file ) //          &
106                        '&version in program = "' //                      &
107                                      TRIM( particle_binary_version ) // '"'
108       CALL message( 'lpm_read_restart_file', 'PA0214', 1, 2, 0, 6, 0 )
109    ENDIF
110
111!
112!-- If less particles are stored on the restart file than prescribed by
113!-- min_nr_particle, the remainder is initialized by zero_particle to avoid
114!-- errors.
115    zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
116                                   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, 0, &
119                                   0, .FALSE., -1)
120!
121!-- Read some particle parameters and the size of the particle arrays,
122!-- allocate them and read their contents.
123    READ ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,                  &
124                 number_of_particle_groups, particle_groups, time_prel,     &
125                 time_write_particle_data, uniform_particles
126
127    ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
128              grid_particles(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
129
130    READ ( 90 )  prt_count
131
132    maximum_number_of_particles = 0
133    DO  ip = nxl, nxr
134       DO  jp = nys, nyn
135          DO  kp = nzb+1, nzt
136
137             number_of_particles = prt_count(kp,jp,ip)
138             IF ( number_of_particles > 0 )  THEN
139                alloc_size = MAX( INT( number_of_particles *                   &
140                             ( 1.0_wp + alloc_factor / 100.0_wp ) ),           &
141                             min_nr_particle )
142             ELSE
143                alloc_size = min_nr_particle
144             ENDIF
145
146             ALLOCATE( grid_particles(kp,jp,ip)%particles(1:alloc_size) )
147
148             IF ( number_of_particles > 0 )  THEN
149                ALLOCATE( tmp_particles(1:number_of_particles) )
150                READ ( 90 )  tmp_particles
151                grid_particles(kp,jp,ip)%particles(1:number_of_particles) = tmp_particles
152                DEALLOCATE( tmp_particles )
153                IF ( number_of_particles < alloc_size )  THEN
154                   grid_particles(kp,jp,ip)%particles(number_of_particles+1:alloc_size) &
155                      = zero_particle
156                ENDIF
157             ELSE
158                grid_particles(kp,jp,ip)%particles(1:alloc_size) = zero_particle
159             ENDIF
160
161             maximum_number_of_particles = maximum_number_of_particles + alloc_size
162
163          ENDDO
164       ENDDO
165    ENDDO
166
167    CLOSE ( 90 )
168!
169!-- Must be called to sort particles into blocks, which is needed for a fast
170!-- interpolation of the LES fields on the particle position.
171    CALL lpm_pack_all_arrays
172
173
174 END SUBROUTINE lpm_read_restart_file
Note: See TracBrowser for help on using the repository browser.