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