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

Last change on this file since 2912 was 2718, checked in by maronga, 7 years ago

deleting of deprecated files; headers updated where needed

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