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