source: palm/trunk/SOURCE/data_output_ptseries.f90 @ 1319

Last change on this file since 1319 was 1319, checked in by raasch, 10 years ago

last commit documented

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