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