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

Last change on this file since 2606 was 2606, checked in by schwenkel, 6 years ago

Modified particle box location and further changes in particle model

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