[1] | 1 | SUBROUTINE data_output_3d( av ) |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
[254] | 4 | ! Current revisions: |
---|
[1] | 5 | ! ----------------- |
---|
[263] | 6 | ! Output of NetCDF messages with aid of message handling routine. |
---|
[254] | 7 | ! Output of messages replaced by message handling routine. |
---|
[1] | 8 | ! |
---|
[254] | 9 | ! |
---|
[1] | 10 | ! Former revisions: |
---|
| 11 | ! ----------------- |
---|
[3] | 12 | ! $Id: data_output_3d.f90 263 2009-03-18 12:26:04Z weinreis $ |
---|
[77] | 13 | ! |
---|
[98] | 14 | ! 96 2007-06-04 08:07:41Z raasch |
---|
| 15 | ! Output of density and salinity |
---|
| 16 | ! |
---|
[77] | 17 | ! 75 2007-03-22 09:54:05Z raasch |
---|
| 18 | ! 2nd+3rd argument removed from exchange horiz |
---|
| 19 | ! |
---|
[3] | 20 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 21 | ! |
---|
[1] | 22 | ! Revision 1.3 2006/06/02 15:18:59 raasch |
---|
| 23 | ! +argument "found", -argument grid in call of routine user_data_output_3d |
---|
| 24 | ! |
---|
| 25 | ! Revision 1.2 2006/02/23 10:23:07 raasch |
---|
| 26 | ! Former subroutine plot_3d renamed data_output_3d, pl.. renamed do.., |
---|
| 27 | ! .._anz renamed .._n, |
---|
| 28 | ! output extended to (almost) all quantities, output of user-defined quantities |
---|
| 29 | ! |
---|
| 30 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
| 31 | ! Initial revision |
---|
| 32 | ! |
---|
| 33 | ! |
---|
| 34 | ! Description: |
---|
| 35 | ! ------------ |
---|
| 36 | ! Output of the 3D-arrays in NetCDF and/or AVS format. |
---|
| 37 | !------------------------------------------------------------------------------! |
---|
| 38 | |
---|
| 39 | USE array_kind |
---|
| 40 | USE arrays_3d |
---|
| 41 | USE averaging |
---|
| 42 | USE cloud_parameters |
---|
| 43 | USE control_parameters |
---|
| 44 | USE cpulog |
---|
| 45 | USE indices |
---|
| 46 | USE interfaces |
---|
| 47 | USE netcdf_control |
---|
| 48 | USE particle_attributes |
---|
| 49 | USE pegrid |
---|
| 50 | |
---|
| 51 | IMPLICIT NONE |
---|
| 52 | |
---|
| 53 | CHARACTER (LEN=9) :: simulated_time_mod |
---|
| 54 | |
---|
| 55 | INTEGER :: av, i, if, j, k, n, pos, prec, psi |
---|
| 56 | |
---|
| 57 | LOGICAL :: found, resorted |
---|
| 58 | |
---|
| 59 | REAL :: mean_r, s_r3, s_r4 |
---|
| 60 | |
---|
| 61 | REAL(spk), DIMENSION(:,:,:), ALLOCATABLE :: local_pf |
---|
| 62 | |
---|
| 63 | REAL, DIMENSION(:,:,:), POINTER :: to_be_resorted |
---|
| 64 | |
---|
| 65 | ! |
---|
| 66 | !-- Return, if nothing to output |
---|
| 67 | IF ( do3d_no(av) == 0 ) RETURN |
---|
| 68 | |
---|
| 69 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
| 70 | |
---|
| 71 | ! |
---|
| 72 | !-- Open output file. |
---|
| 73 | !-- Also creates coordinate and fld-file for AVS. |
---|
| 74 | !-- In case of a run on more than one PE, each PE opens its own file and |
---|
| 75 | !-- writes the data of its subdomain in binary format (regardless of the format |
---|
| 76 | !-- the user has requested). After the run, these files are combined to one |
---|
| 77 | !-- file by combine_plot_fields in the format requested by the user (netcdf |
---|
| 78 | !-- and/or avs). |
---|
| 79 | IF ( avs_output .OR. ( numprocs > 1 ) ) CALL check_open( 30 ) |
---|
| 80 | |
---|
| 81 | #if defined( __netcdf ) |
---|
| 82 | IF ( myid == 0 .AND. netcdf_output ) CALL check_open( 106+av*10 ) |
---|
| 83 | #endif |
---|
| 84 | |
---|
| 85 | ! |
---|
| 86 | !-- Allocate a temporary array with the desired output dimensions. |
---|
| 87 | ALLOCATE( local_pf(nxl-1:nxr+1,nys-1:nyn+1,nzb:nz_do3d) ) |
---|
| 88 | |
---|
| 89 | ! |
---|
| 90 | !-- Update the NetCDF time axis |
---|
| 91 | #if defined( __netcdf ) |
---|
| 92 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
| 93 | IF ( myid == 0 .AND. netcdf_output ) THEN |
---|
| 94 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
| 95 | (/ simulated_time /), & |
---|
| 96 | start = (/ do3d_time_count(av) /), & |
---|
| 97 | count = (/ 1 /) ) |
---|
[263] | 98 | CALL handle_netcdf_error( 'data_output_3d', 1009 ) |
---|
[1] | 99 | ENDIF |
---|
| 100 | #endif |
---|
| 101 | |
---|
| 102 | ! |
---|
| 103 | !-- Loop over all variables to be written. |
---|
| 104 | if = 1 |
---|
| 105 | |
---|
| 106 | DO WHILE ( do3d(av,if)(1:1) /= ' ' ) |
---|
| 107 | ! |
---|
| 108 | !-- Set the precision for data compression. |
---|
| 109 | IF ( do3d_compress ) THEN |
---|
| 110 | DO i = 1, 100 |
---|
| 111 | IF ( plot_3d_precision(i)%variable == do3d(av,if) ) THEN |
---|
| 112 | prec = plot_3d_precision(i)%precision |
---|
| 113 | EXIT |
---|
| 114 | ENDIF |
---|
| 115 | ENDDO |
---|
| 116 | ENDIF |
---|
| 117 | |
---|
| 118 | ! |
---|
| 119 | !-- Store the array chosen on the temporary array. |
---|
| 120 | resorted = .FALSE. |
---|
| 121 | SELECT CASE ( TRIM( do3d(av,if) ) ) |
---|
| 122 | |
---|
| 123 | CASE ( 'e' ) |
---|
| 124 | IF ( av == 0 ) THEN |
---|
| 125 | to_be_resorted => e |
---|
| 126 | ELSE |
---|
| 127 | to_be_resorted => e_av |
---|
| 128 | ENDIF |
---|
| 129 | |
---|
| 130 | CASE ( 'p' ) |
---|
| 131 | IF ( av == 0 ) THEN |
---|
| 132 | to_be_resorted => p |
---|
| 133 | ELSE |
---|
| 134 | to_be_resorted => p_av |
---|
| 135 | ENDIF |
---|
| 136 | |
---|
| 137 | CASE ( 'pc' ) ! particle concentration (requires ghostpoint exchange) |
---|
| 138 | IF ( av == 0 ) THEN |
---|
| 139 | tend = prt_count |
---|
[75] | 140 | CALL exchange_horiz( tend ) |
---|
[1] | 141 | DO i = nxl-1, nxr+1 |
---|
| 142 | DO j = nys-1, nyn+1 |
---|
| 143 | DO k = nzb, nz_do3d |
---|
| 144 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 145 | ENDDO |
---|
| 146 | ENDDO |
---|
| 147 | ENDDO |
---|
| 148 | resorted = .TRUE. |
---|
| 149 | ELSE |
---|
[75] | 150 | CALL exchange_horiz( pc_av ) |
---|
[1] | 151 | to_be_resorted => pc_av |
---|
| 152 | ENDIF |
---|
| 153 | |
---|
| 154 | CASE ( 'pr' ) ! mean particle radius |
---|
| 155 | IF ( av == 0 ) THEN |
---|
| 156 | DO i = nxl, nxr |
---|
| 157 | DO j = nys, nyn |
---|
| 158 | DO k = nzb, nzt+1 |
---|
| 159 | psi = prt_start_index(k,j,i) |
---|
| 160 | s_r3 = 0.0 |
---|
| 161 | s_r4 = 0.0 |
---|
| 162 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
| 163 | s_r3 = s_r3 + particles(n)%radius**3 |
---|
| 164 | s_r4 = s_r4 + particles(n)%radius**4 |
---|
| 165 | ENDDO |
---|
| 166 | IF ( s_r3 /= 0.0 ) THEN |
---|
| 167 | mean_r = s_r4 / s_r3 |
---|
| 168 | ELSE |
---|
| 169 | mean_r = 0.0 |
---|
| 170 | ENDIF |
---|
| 171 | tend(k,j,i) = mean_r |
---|
| 172 | ENDDO |
---|
| 173 | ENDDO |
---|
| 174 | ENDDO |
---|
[75] | 175 | CALL exchange_horiz( tend ) |
---|
[1] | 176 | DO i = nxl-1, nxr+1 |
---|
| 177 | DO j = nys-1, nyn+1 |
---|
| 178 | DO k = nzb, nzt+1 |
---|
| 179 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 180 | ENDDO |
---|
| 181 | ENDDO |
---|
| 182 | ENDDO |
---|
| 183 | resorted = .TRUE. |
---|
| 184 | ELSE |
---|
[75] | 185 | CALL exchange_horiz( pr_av ) |
---|
[1] | 186 | to_be_resorted => pr_av |
---|
| 187 | ENDIF |
---|
| 188 | |
---|
| 189 | CASE ( 'pt' ) |
---|
| 190 | IF ( av == 0 ) THEN |
---|
| 191 | IF ( .NOT. cloud_physics ) THEN |
---|
| 192 | to_be_resorted => pt |
---|
| 193 | ELSE |
---|
| 194 | DO i = nxl-1, nxr+1 |
---|
| 195 | DO j = nys-1, nyn+1 |
---|
| 196 | DO k = nzb, nz_do3d |
---|
| 197 | local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & |
---|
| 198 | pt_d_t(k) * & |
---|
| 199 | ql(k,j,i) |
---|
| 200 | ENDDO |
---|
| 201 | ENDDO |
---|
| 202 | ENDDO |
---|
| 203 | resorted = .TRUE. |
---|
| 204 | ENDIF |
---|
| 205 | ELSE |
---|
| 206 | to_be_resorted => pt_av |
---|
| 207 | ENDIF |
---|
| 208 | |
---|
| 209 | CASE ( 'q' ) |
---|
| 210 | IF ( av == 0 ) THEN |
---|
| 211 | to_be_resorted => q |
---|
| 212 | ELSE |
---|
| 213 | to_be_resorted => q_av |
---|
| 214 | ENDIF |
---|
| 215 | |
---|
| 216 | CASE ( 'ql' ) |
---|
| 217 | IF ( av == 0 ) THEN |
---|
| 218 | to_be_resorted => ql |
---|
| 219 | ELSE |
---|
| 220 | to_be_resorted => ql_av |
---|
| 221 | ENDIF |
---|
| 222 | |
---|
| 223 | CASE ( 'ql_c' ) |
---|
| 224 | IF ( av == 0 ) THEN |
---|
| 225 | to_be_resorted => ql_c |
---|
| 226 | ELSE |
---|
| 227 | to_be_resorted => ql_c_av |
---|
| 228 | ENDIF |
---|
| 229 | |
---|
| 230 | CASE ( 'ql_v' ) |
---|
| 231 | IF ( av == 0 ) THEN |
---|
| 232 | to_be_resorted => ql_v |
---|
| 233 | ELSE |
---|
| 234 | to_be_resorted => ql_v_av |
---|
| 235 | ENDIF |
---|
| 236 | |
---|
| 237 | CASE ( 'ql_vp' ) |
---|
| 238 | IF ( av == 0 ) THEN |
---|
| 239 | to_be_resorted => ql_vp |
---|
| 240 | ELSE |
---|
| 241 | to_be_resorted => ql_vp_av |
---|
| 242 | ENDIF |
---|
| 243 | |
---|
| 244 | CASE ( 'qv' ) |
---|
| 245 | IF ( av == 0 ) THEN |
---|
| 246 | DO i = nxl-1, nxr+1 |
---|
| 247 | DO j = nys-1, nyn+1 |
---|
| 248 | DO k = nzb, nz_do3d |
---|
| 249 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
| 250 | ENDDO |
---|
| 251 | ENDDO |
---|
| 252 | ENDDO |
---|
| 253 | resorted = .TRUE. |
---|
| 254 | ELSE |
---|
| 255 | to_be_resorted => qv_av |
---|
| 256 | ENDIF |
---|
| 257 | |
---|
[96] | 258 | CASE ( 'rho' ) |
---|
| 259 | IF ( av == 0 ) THEN |
---|
| 260 | to_be_resorted => rho |
---|
| 261 | ELSE |
---|
| 262 | to_be_resorted => rho_av |
---|
| 263 | ENDIF |
---|
| 264 | |
---|
[1] | 265 | CASE ( 's' ) |
---|
| 266 | IF ( av == 0 ) THEN |
---|
| 267 | to_be_resorted => q |
---|
| 268 | ELSE |
---|
| 269 | to_be_resorted => q_av |
---|
| 270 | ENDIF |
---|
| 271 | |
---|
[96] | 272 | CASE ( 'sa' ) |
---|
| 273 | IF ( av == 0 ) THEN |
---|
| 274 | to_be_resorted => sa |
---|
| 275 | ELSE |
---|
| 276 | to_be_resorted => sa_av |
---|
| 277 | ENDIF |
---|
| 278 | |
---|
[1] | 279 | CASE ( 'u' ) |
---|
| 280 | IF ( av == 0 ) THEN |
---|
| 281 | to_be_resorted => u |
---|
| 282 | ELSE |
---|
| 283 | to_be_resorted => u_av |
---|
| 284 | ENDIF |
---|
| 285 | |
---|
| 286 | CASE ( 'v' ) |
---|
| 287 | IF ( av == 0 ) THEN |
---|
| 288 | to_be_resorted => v |
---|
| 289 | ELSE |
---|
| 290 | to_be_resorted => v_av |
---|
| 291 | ENDIF |
---|
| 292 | |
---|
| 293 | CASE ( 'vpt' ) |
---|
| 294 | IF ( av == 0 ) THEN |
---|
| 295 | to_be_resorted => vpt |
---|
| 296 | ELSE |
---|
| 297 | to_be_resorted => vpt_av |
---|
| 298 | ENDIF |
---|
| 299 | |
---|
| 300 | CASE ( 'w' ) |
---|
| 301 | IF ( av == 0 ) THEN |
---|
| 302 | to_be_resorted => w |
---|
| 303 | ELSE |
---|
| 304 | to_be_resorted => w_av |
---|
| 305 | ENDIF |
---|
| 306 | |
---|
| 307 | CASE DEFAULT |
---|
| 308 | ! |
---|
| 309 | !-- User defined quantity |
---|
| 310 | CALL user_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
| 311 | nz_do3d ) |
---|
| 312 | resorted = .TRUE. |
---|
| 313 | |
---|
[254] | 314 | IF ( .NOT. found ) THEN |
---|
| 315 | message_string = 'no output available for: ' // TRIM( do3d(av,if) ) |
---|
| 316 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
[1] | 317 | ENDIF |
---|
| 318 | |
---|
| 319 | END SELECT |
---|
| 320 | |
---|
| 321 | ! |
---|
| 322 | !-- Resort the array to be output, if not done above |
---|
| 323 | IF ( .NOT. resorted ) THEN |
---|
| 324 | DO i = nxl-1, nxr+1 |
---|
| 325 | DO j = nys-1, nyn+1 |
---|
| 326 | DO k = nzb, nz_do3d |
---|
| 327 | local_pf(i,j,k) = to_be_resorted(k,j,i) |
---|
| 328 | ENDDO |
---|
| 329 | ENDDO |
---|
| 330 | ENDDO |
---|
| 331 | ENDIF |
---|
| 332 | |
---|
| 333 | ! |
---|
| 334 | !-- Output of the volume data information for the AVS-FLD-file. |
---|
| 335 | do3d_avs_n = do3d_avs_n + 1 |
---|
| 336 | IF ( myid == 0 .AND. avs_output ) THEN |
---|
| 337 | ! |
---|
| 338 | !-- AVS-labels must not contain any colons. Hence they must be removed |
---|
| 339 | !-- from the time character string. |
---|
| 340 | simulated_time_mod = simulated_time_chr |
---|
| 341 | DO WHILE ( SCAN( simulated_time_mod, ':' ) /= 0 ) |
---|
| 342 | pos = SCAN( simulated_time_mod, ':' ) |
---|
| 343 | simulated_time_mod(pos:pos) = '/' |
---|
| 344 | ENDDO |
---|
| 345 | |
---|
| 346 | IF ( av == 0 ) THEN |
---|
| 347 | WRITE ( 33, 3300 ) do3d_avs_n, TRIM( avs_data_file ), & |
---|
| 348 | skip_do_avs, TRIM( do3d(av,if) ), & |
---|
| 349 | TRIM( simulated_time_mod ) |
---|
| 350 | ELSE |
---|
| 351 | WRITE ( 33, 3300 ) do3d_avs_n, TRIM( avs_data_file ), & |
---|
| 352 | skip_do_avs, TRIM( do3d(av,if) ) // & |
---|
| 353 | ' averaged', TRIM( simulated_time_mod ) |
---|
| 354 | ENDIF |
---|
| 355 | ! |
---|
| 356 | !-- Determine the Skip-value for the next array. Record end and start |
---|
| 357 | !-- require 4 byte each. |
---|
| 358 | skip_do_avs = skip_do_avs + ( ((nx+2)*(ny+2)*(nz_do3d+1)) * 4 + 8 ) |
---|
| 359 | ENDIF |
---|
| 360 | |
---|
| 361 | ! |
---|
| 362 | !-- Output of the 3D-array. (compressed/uncompressed) |
---|
| 363 | IF ( do3d_compress ) THEN |
---|
| 364 | ! |
---|
| 365 | !-- Compression, output of compression information on FLD-file and output |
---|
| 366 | !-- of compressed data. |
---|
| 367 | CALL write_compressed( local_pf, 30, 33, myid, nxl, nxr, nyn, nys, & |
---|
| 368 | nzb, nz_do3d, prec ) |
---|
| 369 | ELSE |
---|
| 370 | ! |
---|
| 371 | !-- Uncompressed output. |
---|
| 372 | #if defined( __parallel ) |
---|
| 373 | IF ( netcdf_output .AND. myid == 0 ) THEN |
---|
| 374 | WRITE ( 30 ) simulated_time, do3d_time_count(av), av |
---|
| 375 | ENDIF |
---|
| 376 | WRITE ( 30 ) nxl-1, nxr+1, nys-1, nyn+1, nzb, nz_do3d |
---|
| 377 | WRITE ( 30 ) local_pf |
---|
| 378 | #else |
---|
| 379 | IF ( avs_output ) THEN |
---|
| 380 | WRITE ( 30 ) local_pf(nxl:nxr+1,nys:nyn+1,:) |
---|
| 381 | ENDIF |
---|
| 382 | #if defined( __netcdf ) |
---|
| 383 | IF ( netcdf_output ) THEN |
---|
| 384 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
| 385 | local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d), & |
---|
| 386 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
| 387 | count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) ) |
---|
[263] | 388 | CALL handle_netcdf_error( 'data_output_3d', 1010 ) |
---|
[1] | 389 | ENDIF |
---|
| 390 | #endif |
---|
| 391 | #endif |
---|
| 392 | ENDIF |
---|
| 393 | |
---|
| 394 | if = if + 1 |
---|
| 395 | |
---|
| 396 | ENDDO |
---|
| 397 | |
---|
| 398 | ! |
---|
| 399 | !-- Deallocate temporary array. |
---|
| 400 | DEALLOCATE( local_pf ) |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | CALL cpu_log (log_point(14),'data_output_3d','stop','nobarrier') |
---|
| 404 | |
---|
| 405 | ! |
---|
| 406 | !-- Formats. |
---|
| 407 | 3300 FORMAT ('variable ',I4,' file=',A,' filetype=unformatted skip=',I12/ & |
---|
| 408 | 'label = ',A,A) |
---|
| 409 | |
---|
| 410 | END SUBROUTINE data_output_3d |
---|