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

Last change on this file since 3291 was 3049, checked in by Giersch, 6 years ago

Revision history corrected

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