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

Last change on this file since 1 was 1, checked in by raasch, 17 years ago

Initial repository layout and content

File size: 10.7 KB
Line 
1 SUBROUTINE data_output_ptseries
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
6!
7!
8! Former revisions:
9! -----------------
10! $Log: data_output_ptseries.f90,v $
11! Revision 1.2  2006/08/22 13:51:13  raasch
12! Seperate output for particle groups
13!
14! Revision 1.1  2006/08/04 14:24:18  raasch
15! Initial revision
16!
17!
18! Description:
19! ------------
20! Output of particle data timeseries in NetCDF format.
21!------------------------------------------------------------------------------!
22#if defined( __particles )
23
24    USE control_parameters
25    USE cpulog
26    USE indices
27    USE interfaces
28    USE netcdf_control
29    USE particle_attributes
30    USE pegrid
31
32    IMPLICIT NONE
33
34
35    INTEGER ::  i, inum, j, n
36
37    REAL, DIMENSION(0:number_of_particle_groups,30) ::  pts_value, pts_value_l
38
39
40
41    CALL cpu_log( log_point(36), 'data_output_ptseries', 'start' )
42
43    IF ( myid == 0  .AND.  netcdf_output )  THEN
44!
45!--    Open file for time series output in NetCDF format
46       dopts_time_count = dopts_time_count + 1
47       CALL check_open( 109 )
48#if defined( __netcdf )
49!
50!--    Update the particle time series time axis
51       nc_stat = NF90_PUT_VAR( id_set_pts, id_var_time_pts,    &
52                               (/ simulated_time /),           &
53                               start = (/ dopts_time_count /), count = (/ 1 /) )
54       IF (nc_stat /= NF90_NOERR)  CALL handle_netcdf_error( 391 )
55#endif
56
57    ENDIF
58
59    pts_value_l = 0.0
60
61!
62!-- Calculate or collect the particle time series quantities for all particles
63!-- and seperately for each particle group (if there is more than one group)
64    DO  n = 1, number_of_particles
65
66       pts_value_l(0,1)  = number_of_particles            ! total # of particles
67       pts_value_l(0,2)  = pts_value_l(0,2) + &
68                           ( particles(n)%x - particles(n)%origin_x )  ! mean x
69       pts_value_l(0,3)  = pts_value_l(0,3) + &
70                           ( particles(n)%y - particles(n)%origin_y )  ! mean y
71       pts_value_l(0,4)  = pts_value_l(0,4) + &
72                           ( particles(n)%z - particles(n)%origin_z )  ! mean z
73       pts_value_l(0,5)  = pts_value_l(0,5) + particles(n)%z ! mean z (absolute)
74       pts_value_l(0,6)  = pts_value_l(0,6) + particles(n)%speed_x     ! mean u
75       pts_value_l(0,7)  = pts_value_l(0,7) + particles(n)%speed_y     ! mean v
76       pts_value_l(0,8)  = pts_value_l(0,8) + particles(n)%speed_z     ! mean w
77       pts_value_l(0,9)  = pts_value_l(0,9) + &
78                                            particles(n)%speed_x_sgs ! mean sgsu
79       pts_value_l(0,10) = pts_value_l(0,10) + &
80                                            particles(n)%speed_y_sgs ! mean sgsv
81       pts_value_l(0,11) = pts_value_l(0,11) + &
82                                            particles(n)%speed_z_sgs ! mean sgsw
83       IF ( particles(n)%speed_z > 0.0 )  THEN
84          pts_value_l(0,12) = pts_value_l(0,12) + 1.0  ! # of upward moving prts
85          pts_value_l(0,13) = pts_value_l(0,13) + &
86                                            particles(n)%speed_z ! mean w upw.
87       ELSE
88          pts_value_l(0,14) = pts_value_l(0,14) + &
89                                            particles(n)%speed_z ! mean w down
90       ENDIF
91       pts_value_l(0,15) = number_of_particles
92       pts_value_l(0,16) = number_of_particles
93
94!
95!--    Repeat the same for the respective particle group
96       IF ( number_of_particle_groups > 1 )  THEN
97          j = particles(n)%group
98
99          pts_value_l(j,1)  = pts_value_l(j,1)  + 1
100          pts_value_l(j,2)  = pts_value_l(j,2)  + &
101                              ( particles(n)%x - particles(n)%origin_x )
102          pts_value_l(j,3)  = pts_value_l(j,3)  + &
103                              ( particles(n)%y - particles(n)%origin_y )
104          pts_value_l(j,4)  = pts_value_l(j,4)  + &
105                              ( particles(n)%z - particles(n)%origin_z )
106          pts_value_l(j,5)  = pts_value_l(j,5)  + particles(n)%z
107          pts_value_l(j,6)  = pts_value_l(j,6)  + particles(n)%speed_x
108          pts_value_l(j,7)  = pts_value_l(j,7)  + particles(n)%speed_y
109          pts_value_l(j,8)  = pts_value_l(j,8)  + particles(n)%speed_z
110          pts_value_l(j,9)  = pts_value_l(j,9)  + particles(n)%speed_x_sgs
111          pts_value_l(j,10) = pts_value_l(j,10) + particles(n)%speed_y_sgs
112          pts_value_l(j,11) = pts_value_l(j,11) + particles(n)%speed_z_sgs
113          IF ( particles(n)%speed_z > 0.0 )  THEN
114             pts_value_l(j,12) = pts_value_l(j,12) + 1.0
115             pts_value_l(j,13) = pts_value_l(j,13) + particles(n)%speed_z
116          ELSE
117             pts_value_l(j,14) = pts_value_l(j,14) + particles(n)%speed_z
118          ENDIF
119          pts_value_l(j,15) = pts_value_l(j,15) + 1.0
120          pts_value_l(j,16) = pts_value_l(j,16) + 1.0
121
122       ENDIF
123
124    ENDDO
125
126#if defined( __parallel )
127!
128!-- Sum values of the subdomains
129    inum = number_of_particle_groups + 1
130
131    CALL MPI_ALLREDUCE( pts_value_l(0,1), pts_value(0,1), 14*inum, MPI_REAL, &
132                        MPI_SUM, comm2d, ierr )
133    CALL MPI_ALLREDUCE( pts_value_l(0,15), pts_value(0,15), inum, MPI_REAL, &
134                        MPI_MAX, comm2d, ierr )
135    CALL MPI_ALLREDUCE( pts_value_l(0,16), pts_value(0,16), inum, MPI_REAL, &
136                        MPI_MIN, comm2d, ierr )
137#else
138    pts_value(:,1:16) = pts_value_l(:,1:16)
139#endif
140
141!
142!-- Normalize the above calculated quantities with the total number of
143!-- particles
144    IF ( number_of_particle_groups > 1 )  THEN
145       inum = number_of_particle_groups
146    ELSE
147       inum = 0
148    ENDIF
149
150    DO  j = 0, inum
151
152       IF ( pts_value(j,1) > 0.0 )  THEN
153
154          pts_value(j,2:14) = pts_value(j,2:14) / pts_value(j,1)
155          IF ( pts_value(j,12) > 0.0  .AND.  pts_value(j,12) < 1.0 )  THEN
156             pts_value(j,13) = pts_value(j,13) / pts_value(j,12)
157             pts_value(j,14) = pts_value(j,14) / ( 1.0 - pts_value(j,12) )
158          ELSEIF ( pts_value(j,12) == 0.0 )  THEN
159             pts_value(j,13) = -1.0
160          ELSE
161             pts_value(j,14) = -1.0
162          ENDIF
163
164       ENDIF
165
166    ENDDO
167
168!
169!-- Calculate higher order moments of particle time series quantities,
170!-- seperately for each particle group (if there is more than one group)
171    DO  n = 1, number_of_particles
172
173       pts_value_l(0,17) = pts_value_l(0,17) + ( particles(n)%x - &
174                           particles(n)%origin_x - pts_value(0,2) )**2 ! x*2
175       pts_value_l(0,18) = pts_value_l(0,18) + ( particles(n)%y - &
176                           particles(n)%origin_y - pts_value(0,3) )**2 ! y*2
177       pts_value_l(0,19) = pts_value_l(0,19) + ( particles(n)%z - &
178                           particles(n)%origin_z - pts_value(0,4) )**2 ! z*2
179       pts_value_l(0,20) = pts_value_l(0,20) + ( particles(n)%speed_x - &
180                                               pts_value(0,6) )**2     ! u*2
181       pts_value_l(0,21) = pts_value_l(0,21) + ( particles(n)%speed_y - &
182                                               pts_value(0,7) )**2     ! v*2
183       pts_value_l(0,22) = pts_value_l(0,22) + ( particles(n)%speed_z - &
184                                               pts_value(0,8) )**2     ! w*2
185       pts_value_l(0,23) = pts_value_l(0,23) + ( particles(n)%speed_x_sgs - &
186                                               pts_value(0,9) )**2     ! u"2
187       pts_value_l(0,24) = pts_value_l(0,24) + ( particles(n)%speed_y_sgs - &
188                                               pts_value(0,10) )**2    ! v"2
189       pts_value_l(0,25) = pts_value_l(0,25) + ( particles(n)%speed_z_sgs - &
190                                               pts_value(0,11) )**2    ! w"2
191!
192!--    Repeat the same for the respective particle group
193       IF ( number_of_particle_groups > 1 )  THEN
194          j = particles(n)%group
195
196          pts_value_l(j,17) = pts_value_l(j,17) + ( particles(n)%x - &
197                              particles(n)%origin_x - pts_value(j,2) )**2
198          pts_value_l(j,18) = pts_value_l(j,18) + ( particles(n)%y - &
199                              particles(n)%origin_y - pts_value(j,3) )**2
200          pts_value_l(j,19) = pts_value_l(j,19) + ( particles(n)%z - &
201                              particles(n)%origin_z - pts_value(j,4) )**2
202          pts_value_l(j,20) = pts_value_l(j,20) + ( particles(n)%speed_x - &
203                                                  pts_value(j,6) )**2
204          pts_value_l(j,21) = pts_value_l(j,21) + ( particles(n)%speed_y - &
205                                                  pts_value(j,7) )**2
206          pts_value_l(j,22) = pts_value_l(j,22) + ( particles(n)%speed_z - &
207                                                  pts_value(j,8) )**2
208          pts_value_l(j,23) = pts_value_l(j,23) + ( particles(n)%speed_x_sgs - &
209                                                  pts_value(j,9) )**2
210          pts_value_l(j,24) = pts_value_l(j,24) + ( particles(n)%speed_y_sgs - &
211                                                  pts_value(j,10) )**2
212          pts_value_l(j,25) = pts_value_l(j,25) + ( particles(n)%speed_z_sgs - &
213                                                  pts_value(j,11) )**2
214       ENDIF
215
216    ENDDO
217
218    pts_value_l(0,26) = ( number_of_particles - pts_value(0,1) / numprocs )**2
219                                                 ! variance of particle numbers
220    IF ( number_of_particle_groups > 1 )  THEN
221       DO  j = 1, number_of_particle_groups
222          pts_value_l(j,26) = ( pts_value_l(j,1) - &
223                                pts_value(j,1) / numprocs )**2
224       ENDDO
225    ENDIF
226
227#if defined( __parallel )
228!
229!-- Sum values of the subdomains
230    inum = number_of_particle_groups + 1
231
232    CALL MPI_ALLREDUCE( pts_value_l(0,17), pts_value(0,17), inum*10, MPI_REAL, &
233                        MPI_SUM, comm2d, ierr )
234#else
235    pts_value(:,17:26) = pts_value_l(:,17:26)
236#endif
237
238!
239!-- Normalize the above calculated quantities with the total number of
240!-- particles
241    IF ( number_of_particle_groups > 1 )  THEN
242       inum = number_of_particle_groups
243    ELSE
244       inum = 0
245    ENDIF
246
247    DO  j = 0, inum
248
249       IF ( pts_value(j,1) > 0.0 )  THEN
250          pts_value(j,17:25) = pts_value(j,17:25) / pts_value(j,1)
251       ENDIF
252       pts_value(j,26) = pts_value(j,26) / numprocs
253
254    ENDDO
255
256#if defined( __netcdf )
257!
258!-- Output particle time series quantities in NetCDF format
259    IF ( myid == 0  .AND.  netcdf_output )  THEN
260       DO  j = 0, inum
261          DO  i = 1, dopts_num
262             nc_stat = NF90_PUT_VAR( id_set_pts, id_var_dopts(i,j),  &
263                                     (/ pts_value(j,i) /),           &
264                                     start = (/ dopts_time_count /), &
265                                     count = (/ 1 /) )
266             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 392 )
267          ENDDO
268       ENDDO
269    ENDIF
270#endif
271
272    CALL cpu_log( log_point(36), 'data_output_ptseries','stop', 'nobarrier' )
273
274#endif
275 END SUBROUTINE data_output_ptseries
Note: See TracBrowser for help on using the repository browser.