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

Last change on this file since 1822 was 1822, checked in by hoffmann, 8 years ago

changes in LPM and bulk cloud microphysics

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