1 | SUBROUTINE data_output_ptseries |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: data_output_ptseries.f90 1310 2014-03-14 08:01:56Z suehring $ |
---|
27 | ! |
---|
28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
29 | ! code put under GPL (PALM 3.9) |
---|
30 | ! |
---|
31 | ! 825 2012-02-19 03:03:44Z raasch |
---|
32 | ! mean/minimum/maximum particle radius added as output quantity, |
---|
33 | ! particle attributes speed_x|y|z_sgs renamed rvar1|2|3 |
---|
34 | ! |
---|
35 | ! 622 2010-12-10 08:08:13Z raasch |
---|
36 | ! optional barriers included in order to speed up collective operations |
---|
37 | ! |
---|
38 | ! 291 2009-04-16 12:07:26Z raasch |
---|
39 | ! simulated_time in NetCDF output replaced by time_since_reference_point. |
---|
40 | ! Output of NetCDF messages with aid of message handling routine. |
---|
41 | ! |
---|
42 | ! 60 2007-03-11 11:50:04Z raasch |
---|
43 | ! Particles-package is now part of the default code. |
---|
44 | ! |
---|
45 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
46 | ! |
---|
47 | ! Revision 1.2 2006/08/22 13:51:13 raasch |
---|
48 | ! Seperate output for particle groups |
---|
49 | ! |
---|
50 | ! Revision 1.1 2006/08/04 14:24:18 raasch |
---|
51 | ! Initial revision |
---|
52 | ! |
---|
53 | ! |
---|
54 | ! Description: |
---|
55 | ! ------------ |
---|
56 | ! Output of particle data timeseries in NetCDF format. |
---|
57 | !------------------------------------------------------------------------------! |
---|
58 | |
---|
59 | USE cloud_parameters |
---|
60 | USE control_parameters |
---|
61 | USE cpulog |
---|
62 | USE indices |
---|
63 | USE interfaces |
---|
64 | USE netcdf_control |
---|
65 | USE particle_attributes |
---|
66 | USE pegrid |
---|
67 | |
---|
68 | IMPLICIT NONE |
---|
69 | |
---|
70 | |
---|
71 | INTEGER :: i, inum, j, n |
---|
72 | |
---|
73 | REAL, DIMENSION(:,:), ALLOCATABLE :: pts_value, pts_value_l |
---|
74 | |
---|
75 | |
---|
76 | CALL cpu_log( log_point(36), 'data_output_ptseries', 'start' ) |
---|
77 | |
---|
78 | IF ( myid == 0 .AND. netcdf_output ) THEN |
---|
79 | ! |
---|
80 | !-- Open file for time series output in NetCDF format |
---|
81 | dopts_time_count = dopts_time_count + 1 |
---|
82 | CALL check_open( 109 ) |
---|
83 | #if defined( __netcdf ) |
---|
84 | ! |
---|
85 | !-- Update the particle time series time axis |
---|
86 | nc_stat = NF90_PUT_VAR( id_set_pts, id_var_time_pts, & |
---|
87 | (/ time_since_reference_point /), & |
---|
88 | start = (/ dopts_time_count /), count = (/ 1 /) ) |
---|
89 | CALL handle_netcdf_error( 'data_output_ptseries', 391 ) |
---|
90 | #endif |
---|
91 | |
---|
92 | ENDIF |
---|
93 | |
---|
94 | ALLOCATE( pts_value(0:number_of_particle_groups,dopts_num), & |
---|
95 | pts_value_l(0:number_of_particle_groups,dopts_num) ) |
---|
96 | |
---|
97 | pts_value_l = 0.0 |
---|
98 | pts_value_l(:,16) = 9999999.9 ! for calculation of minimum radius |
---|
99 | |
---|
100 | ! |
---|
101 | !-- Calculate or collect the particle time series quantities for all particles |
---|
102 | !-- and seperately for each particle group (if there is more than one group) |
---|
103 | DO n = 1, number_of_particles |
---|
104 | |
---|
105 | pts_value_l(0,1) = number_of_particles ! total # of particles |
---|
106 | pts_value_l(0,2) = pts_value_l(0,2) + & |
---|
107 | ( particles(n)%x - particles(n)%origin_x ) ! mean x |
---|
108 | pts_value_l(0,3) = pts_value_l(0,3) + & |
---|
109 | ( particles(n)%y - particles(n)%origin_y ) ! mean y |
---|
110 | pts_value_l(0,4) = pts_value_l(0,4) + & |
---|
111 | ( particles(n)%z - particles(n)%origin_z ) ! mean z |
---|
112 | pts_value_l(0,5) = pts_value_l(0,5) + particles(n)%z ! mean z (absolute) |
---|
113 | pts_value_l(0,6) = pts_value_l(0,6) + particles(n)%speed_x ! mean u |
---|
114 | pts_value_l(0,7) = pts_value_l(0,7) + particles(n)%speed_y ! mean v |
---|
115 | pts_value_l(0,8) = pts_value_l(0,8) + particles(n)%speed_z ! mean w |
---|
116 | IF ( .NOT. curvature_solution_effects ) THEN |
---|
117 | pts_value_l(0,9) = pts_value_l(0,9) + particles(n)%rvar1 ! mean sgsu |
---|
118 | pts_value_l(0,10) = pts_value_l(0,10) + particles(n)%rvar2 ! mean sgsv |
---|
119 | pts_value_l(0,11) = pts_value_l(0,11) + particles(n)%rvar3 ! mean sgsw |
---|
120 | ENDIF |
---|
121 | IF ( particles(n)%speed_z > 0.0 ) THEN |
---|
122 | pts_value_l(0,12) = pts_value_l(0,12) + 1.0 ! # of upward moving prts |
---|
123 | pts_value_l(0,13) = pts_value_l(0,13) + & |
---|
124 | particles(n)%speed_z ! mean w upw. |
---|
125 | ELSE |
---|
126 | pts_value_l(0,14) = pts_value_l(0,14) + & |
---|
127 | particles(n)%speed_z ! mean w down |
---|
128 | ENDIF |
---|
129 | pts_value_l(0,15) = pts_value_l(0,15) + particles(n)%radius ! mean rad |
---|
130 | pts_value_l(0,16) = MIN( pts_value_l(0,16), particles(n)%radius ) ! minrad |
---|
131 | pts_value_l(0,17) = MAX( pts_value_l(0,17), particles(n)%radius ) ! maxrad |
---|
132 | pts_value_l(0,18) = number_of_particles |
---|
133 | pts_value_l(0,19) = number_of_particles |
---|
134 | |
---|
135 | ! |
---|
136 | !-- Repeat the same for the respective particle group |
---|
137 | IF ( number_of_particle_groups > 1 ) THEN |
---|
138 | j = particles(n)%group |
---|
139 | |
---|
140 | pts_value_l(j,1) = pts_value_l(j,1) + 1 |
---|
141 | pts_value_l(j,2) = pts_value_l(j,2) + & |
---|
142 | ( particles(n)%x - particles(n)%origin_x ) |
---|
143 | pts_value_l(j,3) = pts_value_l(j,3) + & |
---|
144 | ( particles(n)%y - particles(n)%origin_y ) |
---|
145 | pts_value_l(j,4) = pts_value_l(j,4) + & |
---|
146 | ( particles(n)%z - particles(n)%origin_z ) |
---|
147 | pts_value_l(j,5) = pts_value_l(j,5) + particles(n)%z |
---|
148 | pts_value_l(j,6) = pts_value_l(j,6) + particles(n)%speed_x |
---|
149 | pts_value_l(j,7) = pts_value_l(j,7) + particles(n)%speed_y |
---|
150 | pts_value_l(j,8) = pts_value_l(j,8) + particles(n)%speed_z |
---|
151 | IF ( .NOT. curvature_solution_effects ) THEN |
---|
152 | pts_value_l(j,9) = pts_value_l(j,9) + particles(n)%rvar1 |
---|
153 | pts_value_l(j,10) = pts_value_l(j,10) + particles(n)%rvar2 |
---|
154 | pts_value_l(j,11) = pts_value_l(j,11) + particles(n)%rvar3 |
---|
155 | ENDIF |
---|
156 | IF ( particles(n)%speed_z > 0.0 ) THEN |
---|
157 | pts_value_l(j,12) = pts_value_l(j,12) + 1.0 |
---|
158 | pts_value_l(j,13) = pts_value_l(j,13) + particles(n)%speed_z |
---|
159 | ELSE |
---|
160 | pts_value_l(j,14) = pts_value_l(j,14) + particles(n)%speed_z |
---|
161 | ENDIF |
---|
162 | pts_value_l(j,15) = pts_value_l(j,15) + particles(n)%radius |
---|
163 | pts_value_l(j,16) = MIN( pts_value(j,16), particles(n)%radius ) |
---|
164 | pts_value_l(j,17) = MAX( pts_value(j,17), particles(n)%radius ) |
---|
165 | pts_value_l(j,18) = pts_value_l(j,18) + 1.0 |
---|
166 | pts_value_l(j,19) = pts_value_l(j,19) + 1.0 |
---|
167 | |
---|
168 | ENDIF |
---|
169 | |
---|
170 | ENDDO |
---|
171 | |
---|
172 | #if defined( __parallel ) |
---|
173 | ! |
---|
174 | !-- Sum values of the subdomains |
---|
175 | inum = number_of_particle_groups + 1 |
---|
176 | |
---|
177 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
178 | CALL MPI_ALLREDUCE( pts_value_l(0,1), pts_value(0,1), 15*inum, MPI_REAL, & |
---|
179 | MPI_SUM, comm2d, ierr ) |
---|
180 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
181 | CALL MPI_ALLREDUCE( pts_value_l(0,16), pts_value(0,16), inum, MPI_REAL, & |
---|
182 | MPI_MIN, comm2d, ierr ) |
---|
183 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
184 | CALL MPI_ALLREDUCE( pts_value_l(0,17), pts_value(0,17), inum, MPI_REAL, & |
---|
185 | MPI_MAX, comm2d, ierr ) |
---|
186 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
187 | CALL MPI_ALLREDUCE( pts_value_l(0,18), pts_value(0,18), inum, MPI_REAL, & |
---|
188 | MPI_MAX, comm2d, ierr ) |
---|
189 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
190 | CALL MPI_ALLREDUCE( pts_value_l(0,19), pts_value(0,19), inum, MPI_REAL, & |
---|
191 | MPI_MIN, comm2d, ierr ) |
---|
192 | #else |
---|
193 | pts_value(:,1:19) = pts_value_l(:,1:19) |
---|
194 | #endif |
---|
195 | |
---|
196 | ! |
---|
197 | !-- Normalize the above calculated quantities (except min/max values) with the |
---|
198 | !-- total number of particles |
---|
199 | IF ( number_of_particle_groups > 1 ) THEN |
---|
200 | inum = number_of_particle_groups |
---|
201 | ELSE |
---|
202 | inum = 0 |
---|
203 | ENDIF |
---|
204 | |
---|
205 | DO j = 0, inum |
---|
206 | |
---|
207 | IF ( pts_value(j,1) > 0.0 ) THEN |
---|
208 | |
---|
209 | pts_value(j,2:15) = pts_value(j,2:15) / pts_value(j,1) |
---|
210 | IF ( pts_value(j,12) > 0.0 .AND. pts_value(j,12) < 1.0 ) THEN |
---|
211 | pts_value(j,13) = pts_value(j,13) / pts_value(j,12) |
---|
212 | pts_value(j,14) = pts_value(j,14) / ( 1.0 - pts_value(j,12) ) |
---|
213 | ELSEIF ( pts_value(j,12) == 0.0 ) THEN |
---|
214 | pts_value(j,13) = -1.0 |
---|
215 | ELSE |
---|
216 | pts_value(j,14) = -1.0 |
---|
217 | ENDIF |
---|
218 | |
---|
219 | ENDIF |
---|
220 | |
---|
221 | ENDDO |
---|
222 | |
---|
223 | ! |
---|
224 | !-- Calculate higher order moments of particle time series quantities, |
---|
225 | !-- seperately for each particle group (if there is more than one group) |
---|
226 | DO n = 1, number_of_particles |
---|
227 | |
---|
228 | pts_value_l(0,20) = pts_value_l(0,20) + ( particles(n)%x - & |
---|
229 | particles(n)%origin_x - pts_value(0,2) )**2 ! x*2 |
---|
230 | pts_value_l(0,21) = pts_value_l(0,21) + ( particles(n)%y - & |
---|
231 | particles(n)%origin_y - pts_value(0,3) )**2 ! y*2 |
---|
232 | pts_value_l(0,22) = pts_value_l(0,22) + ( particles(n)%z - & |
---|
233 | particles(n)%origin_z - pts_value(0,4) )**2 ! z*2 |
---|
234 | pts_value_l(0,23) = pts_value_l(0,23) + ( particles(n)%speed_x - & |
---|
235 | pts_value(0,6) )**2 ! u*2 |
---|
236 | pts_value_l(0,24) = pts_value_l(0,24) + ( particles(n)%speed_y - & |
---|
237 | pts_value(0,7) )**2 ! v*2 |
---|
238 | pts_value_l(0,25) = pts_value_l(0,25) + ( particles(n)%speed_z - & |
---|
239 | pts_value(0,8) )**2 ! w*2 |
---|
240 | IF ( .NOT. curvature_solution_effects ) THEN |
---|
241 | pts_value_l(0,26) = pts_value_l(0,26) + ( particles(n)%rvar1 - & |
---|
242 | pts_value(0,9) )**2 ! u"2 |
---|
243 | pts_value_l(0,27) = pts_value_l(0,27) + ( particles(n)%rvar2 - & |
---|
244 | pts_value(0,10) )**2 ! v"2 |
---|
245 | pts_value_l(0,28) = pts_value_l(0,28) + ( particles(n)%rvar3 - & |
---|
246 | pts_value(0,11) )**2 ! w"2 |
---|
247 | ENDIF |
---|
248 | ! |
---|
249 | !-- Repeat the same for the respective particle group |
---|
250 | IF ( number_of_particle_groups > 1 ) THEN |
---|
251 | j = particles(n)%group |
---|
252 | |
---|
253 | pts_value_l(j,20) = pts_value_l(j,20) + ( particles(n)%x - & |
---|
254 | particles(n)%origin_x - pts_value(j,2) )**2 |
---|
255 | pts_value_l(j,21) = pts_value_l(j,21) + ( particles(n)%y - & |
---|
256 | particles(n)%origin_y - pts_value(j,3) )**2 |
---|
257 | pts_value_l(j,22) = pts_value_l(j,22) + ( particles(n)%z - & |
---|
258 | particles(n)%origin_z - pts_value(j,4) )**2 |
---|
259 | pts_value_l(j,23) = pts_value_l(j,23) + ( particles(n)%speed_x - & |
---|
260 | pts_value(j,6) )**2 |
---|
261 | pts_value_l(j,24) = pts_value_l(j,24) + ( particles(n)%speed_y - & |
---|
262 | pts_value(j,7) )**2 |
---|
263 | pts_value_l(j,25) = pts_value_l(j,25) + ( particles(n)%speed_z - & |
---|
264 | pts_value(j,8) )**2 |
---|
265 | IF ( .NOT. curvature_solution_effects ) THEN |
---|
266 | pts_value_l(j,26) = pts_value_l(j,26) + ( particles(n)%rvar1 - & |
---|
267 | pts_value(j,9) )**2 |
---|
268 | pts_value_l(j,27) = pts_value_l(j,27) + ( particles(n)%rvar2 - & |
---|
269 | pts_value(j,10) )**2 |
---|
270 | pts_value_l(j,28) = pts_value_l(j,28) + ( particles(n)%rvar3 - & |
---|
271 | pts_value(j,11) )**2 |
---|
272 | ENDIF |
---|
273 | ENDIF |
---|
274 | |
---|
275 | ENDDO |
---|
276 | |
---|
277 | pts_value_l(0,29) = ( number_of_particles - pts_value(0,1) / numprocs )**2 |
---|
278 | ! variance of particle numbers |
---|
279 | IF ( number_of_particle_groups > 1 ) THEN |
---|
280 | DO j = 1, number_of_particle_groups |
---|
281 | pts_value_l(j,29) = ( pts_value_l(j,1) - & |
---|
282 | pts_value(j,1) / numprocs )**2 |
---|
283 | ENDDO |
---|
284 | ENDIF |
---|
285 | |
---|
286 | #if defined( __parallel ) |
---|
287 | ! |
---|
288 | !-- Sum values of the subdomains |
---|
289 | inum = number_of_particle_groups + 1 |
---|
290 | |
---|
291 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
292 | CALL MPI_ALLREDUCE( pts_value_l(0,20), pts_value(0,20), inum*10, MPI_REAL, & |
---|
293 | MPI_SUM, comm2d, ierr ) |
---|
294 | #else |
---|
295 | pts_value(:,20:29) = pts_value_l(:,20:29) |
---|
296 | #endif |
---|
297 | |
---|
298 | ! |
---|
299 | !-- Normalize the above calculated quantities with the total number of |
---|
300 | !-- particles |
---|
301 | IF ( number_of_particle_groups > 1 ) THEN |
---|
302 | inum = number_of_particle_groups |
---|
303 | ELSE |
---|
304 | inum = 0 |
---|
305 | ENDIF |
---|
306 | |
---|
307 | DO j = 0, inum |
---|
308 | |
---|
309 | IF ( pts_value(j,1) > 0.0 ) THEN |
---|
310 | pts_value(j,20:28) = pts_value(j,20:28) / pts_value(j,1) |
---|
311 | ENDIF |
---|
312 | pts_value(j,29) = pts_value(j,29) / numprocs |
---|
313 | |
---|
314 | ENDDO |
---|
315 | |
---|
316 | #if defined( __netcdf ) |
---|
317 | ! |
---|
318 | !-- Output particle time series quantities in NetCDF format |
---|
319 | IF ( myid == 0 .AND. netcdf_output ) THEN |
---|
320 | DO j = 0, inum |
---|
321 | DO i = 1, dopts_num |
---|
322 | nc_stat = NF90_PUT_VAR( id_set_pts, id_var_dopts(i,j), & |
---|
323 | (/ pts_value(j,i) /), & |
---|
324 | start = (/ dopts_time_count /), & |
---|
325 | count = (/ 1 /) ) |
---|
326 | CALL handle_netcdf_error( 'data_output_ptseries', 392 ) |
---|
327 | ENDDO |
---|
328 | ENDDO |
---|
329 | ENDIF |
---|
330 | #endif |
---|
331 | |
---|
332 | DEALLOCATE( pts_value, pts_value_l ) |
---|
333 | |
---|
334 | CALL cpu_log( log_point(36), 'data_output_ptseries','stop', 'nobarrier' ) |
---|
335 | |
---|
336 | END SUBROUTINE data_output_ptseries |
---|