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