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