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