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

Last change on this file since 2408 was 2312, checked in by hoffmann, 7 years ago

various improvements of the LCM

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