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

Last change on this file since 1682 was 1682, checked in by knoop, 9 years ago

Code annotations made doxygen readable

  • Property svn:keywords set to Id
File size: 16.4 KB
RevLine 
[1682]1!> @file data_output_ptseries.f90
[1036]2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
[1310]16! Copyright 1997-2014 Leibniz Universitaet Hannover
[1036]17!--------------------------------------------------------------------------------!
18!
[263]19! Current revisions:
[1]20! -----------------
[1682]21! Code annotations made doxygen readable
[1329]22!
[1321]23! Former revisions:
24! -----------------
25! $Id: data_output_ptseries.f90 1682 2015-10-07 23:56:08Z knoop $
26!
[1360]27! 1359 2014-04-11 17:15:14Z hoffmann
28! New particle structure integrated.
29!
[1354]30! 1353 2014-04-08 15:21:23Z heinze
31! REAL constants provided with KIND-attribute
32!
[1329]33! 1327 2014-03-21 11:00:16Z raasch
34! -netcdf output queries
35!
[1321]36! 1320 2014-03-20 08:40:49Z raasch
[1320]37! ONLY-attribute added to USE-statements,
38! kind-parameters added to all INTEGER and REAL declaration statements,
39! kinds are defined in new module kinds,
40! revision history before 2012 removed,
41! comment fields (!:) to be used for variable explanations added to
42! all variable declaration statements
[1]43!
[1319]44! 1318 2014-03-17 13:35:16Z raasch
45! barrier argument removed from cpu_log,
46! module interfaces removed
47!
[1037]48! 1036 2012-10-22 13:43:42Z raasch
49! code put under GPL (PALM 3.9)
50!
[826]51! 825 2012-02-19 03:03:44Z raasch
52! mean/minimum/maximum particle radius added as output quantity,
53! particle attributes speed_x|y|z_sgs renamed rvar1|2|3
54!
[1]55! Revision 1.1  2006/08/04 14:24:18  raasch
56! Initial revision
57!
58!
59! Description:
60! ------------
[1682]61!> Output of particle data timeseries in NetCDF format.
[1]62!------------------------------------------------------------------------------!
[1682]63 SUBROUTINE data_output_ptseries
64 
[1]65
[1320]66    USE cloud_parameters,                                                      &
67        ONLY:  curvature_solution_effects
68
69    USE control_parameters,                                                    &
[1327]70        ONLY:  dopts_time_count, time_since_reference_point
[1320]71
72    USE cpulog,                                                                &
73        ONLY:  cpu_log, log_point
74
75    USE indices,                                                               &
[1359]76        ONLY: nxl, nxr, nys, nyn, nzb, nzt
[1320]77
78    USE kinds
79
[1]80    USE netcdf_control
[1320]81
82    USE particle_attributes,                                                   &
[1359]83        ONLY:  grid_particles, number_of_particles, number_of_particle_groups, &
84               particles, prt_count
[1320]85
[1]86    USE pegrid
87
88    IMPLICIT NONE
89
90
[1682]91    INTEGER(iwp) ::  i    !<
92    INTEGER(iwp) ::  inum !<
93    INTEGER(iwp) ::  j    !<
94    INTEGER(iwp) ::  jg   !<
95    INTEGER(iwp) ::  k    !<
96    INTEGER(iwp) ::  n    !<
[1]97
[1682]98    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  pts_value   !<
99    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  pts_value_l !<
[1]100
101
102    CALL cpu_log( log_point(36), 'data_output_ptseries', 'start' )
103
[1327]104    IF ( myid == 0 )  THEN
[1]105!
106!--    Open file for time series output in NetCDF format
107       dopts_time_count = dopts_time_count + 1
108       CALL check_open( 109 )
109#if defined( __netcdf )
110!
111!--    Update the particle time series time axis
[291]112       nc_stat = NF90_PUT_VAR( id_set_pts, id_var_time_pts,      &
113                               (/ time_since_reference_point /), &
[1]114                               start = (/ dopts_time_count /), count = (/ 1 /) )
[263]115       CALL handle_netcdf_error( 'data_output_ptseries', 391 )
[1]116#endif
117
118    ENDIF
119
[825]120    ALLOCATE( pts_value(0:number_of_particle_groups,dopts_num), &
121              pts_value_l(0:number_of_particle_groups,dopts_num) )
122
[1353]123    pts_value_l = 0.0_wp
124    pts_value_l(:,16) = 9999999.9_wp    ! for calculation of minimum radius
[1]125
126!
127!-- Calculate or collect the particle time series quantities for all particles
128!-- and seperately for each particle group (if there is more than one group)
[1359]129    DO  i = nxl, nxr
130       DO  j = nys, nyn
131          DO  k = nzb, nzt
132             number_of_particles = prt_count(k,j,i)
133             IF (number_of_particles <= 0)  CYCLE
134             particles => grid_particles(k,j,i)%particles(1:number_of_particles)
135             DO  n = 1, number_of_particles
[1]136
[1359]137                IF ( particles(n)%particle_mask )  THEN  ! Restrict analysis to active particles
[1]138
[1359]139                   pts_value_l(0,1)  = pts_value_l(0,1) + 1.0_wp  ! total # of particles
140                   pts_value_l(0,2)  = pts_value_l(0,2) +                      &
141                          ( particles(n)%x - particles(n)%origin_x )  ! mean x
142                   pts_value_l(0,3)  = pts_value_l(0,3) +                      &
143                          ( particles(n)%y - particles(n)%origin_y )  ! mean y
144                   pts_value_l(0,4)  = pts_value_l(0,4) +                      &
145                          ( particles(n)%z - particles(n)%origin_z )  ! mean z
146                   pts_value_l(0,5)  = pts_value_l(0,5) + particles(n)%z        ! mean z (absolute)
147                   pts_value_l(0,6)  = pts_value_l(0,6) + particles(n)%speed_x  ! mean u
148                   pts_value_l(0,7)  = pts_value_l(0,7) + particles(n)%speed_y  ! mean v
149                   pts_value_l(0,8)  = pts_value_l(0,8) + particles(n)%speed_z  ! mean w
150                   IF ( .NOT. curvature_solution_effects )  THEN
151                      pts_value_l(0,9)  = pts_value_l(0,9)  + particles(n)%rvar1 ! mean sgsu
152                      pts_value_l(0,10) = pts_value_l(0,10) + particles(n)%rvar2 ! mean sgsv
153                      pts_value_l(0,11) = pts_value_l(0,11) + particles(n)%rvar3 ! mean sgsw
154                   ENDIF
155                   IF ( particles(n)%speed_z > 0.0_wp )  THEN
156                      pts_value_l(0,12) = pts_value_l(0,12) + 1.0_wp  ! # of upward moving prts
157                      pts_value_l(0,13) = pts_value_l(0,13) +                  &
158                                              particles(n)%speed_z ! mean w upw.
159                   ELSE
160                      pts_value_l(0,14) = pts_value_l(0,14) +                  &
161                                              particles(n)%speed_z ! mean w down
162                   ENDIF
163                   pts_value_l(0,15) = pts_value_l(0,15) + particles(n)%radius ! mean rad
164                   pts_value_l(0,16) = MIN( pts_value_l(0,16), particles(n)%radius ) ! minrad
165                   pts_value_l(0,17) = MAX( pts_value_l(0,17), particles(n)%radius ) ! maxrad
166                   pts_value_l(0,18) = pts_value_l(0,18) + 1.0_wp
167                   pts_value_l(0,19) = pts_value_l(0,18) + 1.0_wp
[1]168!
[1359]169!--                Repeat the same for the respective particle group
170                   IF ( number_of_particle_groups > 1 )  THEN
171                      jg = particles(n)%group
[1]172
[1359]173                      pts_value_l(jg,1)  = pts_value_l(jg,1) + 1.0_wp
174                      pts_value_l(jg,2)  = pts_value_l(jg,2) +                   &
175                           ( particles(n)%x - particles(n)%origin_x )
176                      pts_value_l(jg,3)  = pts_value_l(jg,3) +                   &
177                           ( particles(n)%y - particles(n)%origin_y )
178                      pts_value_l(jg,4)  = pts_value_l(jg,4) +                   &
179                           ( particles(n)%z - particles(n)%origin_z )
180                      pts_value_l(jg,5)  = pts_value_l(jg,5) + particles(n)%z
181                      pts_value_l(jg,6)  = pts_value_l(jg,6) + particles(n)%speed_x
182                      pts_value_l(jg,7)  = pts_value_l(jg,7) + particles(n)%speed_y
183                      pts_value_l(jg,8)  = pts_value_l(jg,8) + particles(n)%speed_z
184                      IF ( .NOT. curvature_solution_effects )  THEN
185                         pts_value_l(jg,9)  = pts_value_l(jg,9)  + particles(n)%rvar1
186                         pts_value_l(jg,10) = pts_value_l(jg,10) + particles(n)%rvar2
187                         pts_value_l(jg,11) = pts_value_l(jg,11) + particles(n)%rvar3
188                      ENDIF
189                      IF ( particles(n)%speed_z > 0.0_wp )  THEN
190                         pts_value_l(jg,12) = pts_value_l(jg,12) + 1.0_wp
191                         pts_value_l(jg,13) = pts_value_l(jg,13) + particles(n)%speed_z
192                      ELSE
193                         pts_value_l(jg,14) = pts_value_l(jg,14) + particles(n)%speed_z
194                      ENDIF
195                      pts_value_l(jg,15) = pts_value_l(jg,15) + particles(n)%radius
196                      pts_value_l(jg,16) = MIN( pts_value(jg,16), particles(n)%radius )
197                      pts_value_l(jg,17) = MAX( pts_value(jg,17), particles(n)%radius )
198                      pts_value_l(jg,18) = pts_value_l(jg,18) + 1.0_wp
199                      pts_value_l(jg,19) = pts_value_l(jg,19) + 1.0_wp
200                   ENDIF
[1]201
[1359]202                ENDIF
[1]203
[1359]204             ENDDO
205
206          ENDDO
207       ENDDO
[1]208    ENDDO
209
[1359]210
[1]211#if defined( __parallel )
212!
213!-- Sum values of the subdomains
214    inum = number_of_particle_groups + 1
215
[622]216    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[824]217    CALL MPI_ALLREDUCE( pts_value_l(0,1), pts_value(0,1), 15*inum, MPI_REAL, &
[1]218                        MPI_SUM, comm2d, ierr )
[622]219    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[824]220    CALL MPI_ALLREDUCE( pts_value_l(0,16), pts_value(0,16), inum, MPI_REAL, &
[825]221                        MPI_MIN, comm2d, ierr )
222    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
223    CALL MPI_ALLREDUCE( pts_value_l(0,17), pts_value(0,17), inum, MPI_REAL, &
[1]224                        MPI_MAX, comm2d, ierr )
[622]225    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[825]226    CALL MPI_ALLREDUCE( pts_value_l(0,18), pts_value(0,18), inum, MPI_REAL, &
227                        MPI_MAX, comm2d, ierr )
228    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
229    CALL MPI_ALLREDUCE( pts_value_l(0,19), pts_value(0,19), inum, MPI_REAL, &
[1]230                        MPI_MIN, comm2d, ierr )
231#else
[825]232    pts_value(:,1:19) = pts_value_l(:,1:19)
[1]233#endif
234
235!
[825]236!-- Normalize the above calculated quantities (except min/max values) with the
237!-- total number of particles
[1]238    IF ( number_of_particle_groups > 1 )  THEN
239       inum = number_of_particle_groups
240    ELSE
241       inum = 0
242    ENDIF
243
244    DO  j = 0, inum
245
[1353]246       IF ( pts_value(j,1) > 0.0_wp )  THEN
[1]247
[824]248          pts_value(j,2:15) = pts_value(j,2:15) / pts_value(j,1)
[1353]249          IF ( pts_value(j,12) > 0.0_wp  .AND.  pts_value(j,12) < 1.0_wp )  THEN
[1]250             pts_value(j,13) = pts_value(j,13) / pts_value(j,12)
[1353]251             pts_value(j,14) = pts_value(j,14) / ( 1.0_wp - pts_value(j,12) )
252          ELSEIF ( pts_value(j,12) == 0.0_wp )  THEN
253             pts_value(j,13) = -1.0_wp
[1]254          ELSE
[1353]255             pts_value(j,14) = -1.0_wp
[1]256          ENDIF
257
258       ENDIF
259
260    ENDDO
261
262!
263!-- Calculate higher order moments of particle time series quantities,
264!-- seperately for each particle group (if there is more than one group)
[1359]265    DO  i = nxl, nxr
266       DO  j = nys, nyn
267          DO  k = nzb, nzt
268             number_of_particles = prt_count(k,j,i)
269             IF (number_of_particles <= 0)  CYCLE
270             particles => grid_particles(k,j,i)%particles(1:number_of_particles)
271             DO  n = 1, number_of_particles
[1]272
[1359]273                pts_value_l(0,20) = pts_value_l(0,20) + ( particles(n)%x - &
274                                    particles(n)%origin_x - pts_value(0,2) )**2 ! x*2
275                pts_value_l(0,21) = pts_value_l(0,21) + ( particles(n)%y - &
276                                    particles(n)%origin_y - pts_value(0,3) )**2 ! y*2
277                pts_value_l(0,22) = pts_value_l(0,22) + ( particles(n)%z - &
278                                    particles(n)%origin_z - pts_value(0,4) )**2 ! z*2
279                pts_value_l(0,23) = pts_value_l(0,23) + ( particles(n)%speed_x - &
280                                                         pts_value(0,6) )**2   ! u*2
281                pts_value_l(0,24) = pts_value_l(0,24) + ( particles(n)%speed_y - &
282                                                          pts_value(0,7) )**2   ! v*2
283                pts_value_l(0,25) = pts_value_l(0,25) + ( particles(n)%speed_z - &
284                                                          pts_value(0,8) )**2   ! w*2
285                IF ( .NOT. curvature_solution_effects )  THEN
286                   pts_value_l(0,26) = pts_value_l(0,26) + ( particles(n)%rvar1 - &
287                                                             pts_value(0,9) )**2   ! u"2
288                   pts_value_l(0,27) = pts_value_l(0,27) + ( particles(n)%rvar2 - &
289                                                             pts_value(0,10) )**2  ! v"2
290                   pts_value_l(0,28) = pts_value_l(0,28) + ( particles(n)%rvar3 - &
291                                                             pts_value(0,11) )**2  ! w"2
292                ENDIF
[1]293!
[1359]294!--             Repeat the same for the respective particle group
295                IF ( number_of_particle_groups > 1 )  THEN
296                   jg = particles(n)%group
[1]297
[1359]298                   pts_value_l(jg,20) = pts_value_l(jg,20) + ( particles(n)%x - &
299                                       particles(n)%origin_x - pts_value(jg,2) )**2
300                   pts_value_l(jg,21) = pts_value_l(jg,21) + ( particles(n)%y - &
301                                       particles(n)%origin_y - pts_value(jg,3) )**2
302                   pts_value_l(jg,22) = pts_value_l(jg,22) + ( particles(n)%z - &
303                                       particles(n)%origin_z - pts_value(jg,4) )**2
304                   pts_value_l(jg,23) = pts_value_l(jg,23) + ( particles(n)%speed_x - &
305                                                             pts_value(jg,6) )**2
306                   pts_value_l(jg,24) = pts_value_l(jg,24) + ( particles(n)%speed_y - &
307                                                             pts_value(jg,7) )**2
308                   pts_value_l(jg,25) = pts_value_l(jg,25) + ( particles(n)%speed_z - &
309                                                             pts_value(jg,8) )**2
310                   IF ( .NOT. curvature_solution_effects )  THEN
311                      pts_value_l(jg,26) = pts_value_l(jg,26) + ( particles(n)%rvar1 - &
312                                                                pts_value(jg,9) )**2
313                      pts_value_l(jg,27) = pts_value_l(jg,27) + ( particles(n)%rvar2 - &
314                                                                pts_value(jg,10) )**2
315                      pts_value_l(jg,28) = pts_value_l(jg,28) + ( particles(n)%rvar3 - &
316                                                                pts_value(jg,11) )**2
317                   ENDIF
318                ENDIF
[1]319
[1359]320             ENDDO
321          ENDDO
322       ENDDO
[1]323    ENDDO
324
[825]325    pts_value_l(0,29) = ( number_of_particles - pts_value(0,1) / numprocs )**2
[1]326                                                 ! variance of particle numbers
327    IF ( number_of_particle_groups > 1 )  THEN
328       DO  j = 1, number_of_particle_groups
[825]329          pts_value_l(j,29) = ( pts_value_l(j,1) - &
[1]330                                pts_value(j,1) / numprocs )**2
331       ENDDO
332    ENDIF
333
334#if defined( __parallel )
335!
336!-- Sum values of the subdomains
337    inum = number_of_particle_groups + 1
338
[622]339    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[825]340    CALL MPI_ALLREDUCE( pts_value_l(0,20), pts_value(0,20), inum*10, MPI_REAL, &
[1]341                        MPI_SUM, comm2d, ierr )
342#else
[825]343    pts_value(:,20:29) = pts_value_l(:,20:29)
[1]344#endif
345
346!
347!-- Normalize the above calculated quantities with the total number of
348!-- particles
349    IF ( number_of_particle_groups > 1 )  THEN
350       inum = number_of_particle_groups
351    ELSE
352       inum = 0
353    ENDIF
354
355    DO  j = 0, inum
356
[1353]357       IF ( pts_value(j,1) > 0.0_wp )  THEN
[825]358          pts_value(j,20:28) = pts_value(j,20:28) / pts_value(j,1)
[1]359       ENDIF
[825]360       pts_value(j,29) = pts_value(j,29) / numprocs
[1]361
362    ENDDO
363
364#if defined( __netcdf )
365!
366!-- Output particle time series quantities in NetCDF format
[1327]367    IF ( myid == 0 )  THEN
[1]368       DO  j = 0, inum
369          DO  i = 1, dopts_num
370             nc_stat = NF90_PUT_VAR( id_set_pts, id_var_dopts(i,j),  &
371                                     (/ pts_value(j,i) /),           &
372                                     start = (/ dopts_time_count /), &
373                                     count = (/ 1 /) )
[263]374             CALL handle_netcdf_error( 'data_output_ptseries', 392 )
[1]375          ENDDO
376       ENDDO
377    ENDIF
378#endif
379
[825]380    DEALLOCATE( pts_value, pts_value_l )
381
[1318]382    CALL cpu_log( log_point(36), 'data_output_ptseries', 'stop' )
[1]383
384 END SUBROUTINE data_output_ptseries
Note: See TracBrowser for help on using the repository browser.