[1] | 1 | SUBROUTINE data_output_3d( av ) |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[1106] | 21 | ! ------------------ |
---|
[1585] | 22 | ! Added support for RRTMG |
---|
[1552] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: data_output_3d.f90 1585 2015-04-30 07:05:52Z maronga $ |
---|
| 27 | ! |
---|
| 28 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
[1551] | 29 | ! Added suppport for land surface model and radiation model output. In the course |
---|
| 30 | ! of this action, the limits for vertical loops have been changed (from nzb and |
---|
| 31 | ! nzt+1 to nzb_do and nzt_do, respectively in order to allow soil model output). |
---|
| 32 | ! Moreover, a new vertical grid zs was introduced. |
---|
[1329] | 33 | ! |
---|
[1360] | 34 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 35 | ! New particle structure integrated. |
---|
| 36 | ! |
---|
[1354] | 37 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 38 | ! REAL constants provided with KIND-attribute |
---|
| 39 | ! |
---|
[1329] | 40 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
| 41 | ! parts concerning avs output removed, |
---|
| 42 | ! -netcdf output queries |
---|
| 43 | ! |
---|
[1321] | 44 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 45 | ! ONLY-attribute added to USE-statements, |
---|
| 46 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 47 | ! kinds are defined in new module kinds, |
---|
| 48 | ! old module precision_kind is removed, |
---|
| 49 | ! revision history before 2012 removed, |
---|
| 50 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 51 | ! all variable declaration statements |
---|
[674] | 52 | ! |
---|
[1319] | 53 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 54 | ! barrier argument removed from cpu_log, |
---|
| 55 | ! module interfaces removed |
---|
| 56 | ! |
---|
[1309] | 57 | ! 1308 2014-03-13 14:58:42Z fricke |
---|
| 58 | ! Check, if the limit of the time dimension is exceeded for parallel output |
---|
| 59 | ! To increase the performance for parallel output, the following is done: |
---|
| 60 | ! - Update of time axis is only done by PE0 |
---|
| 61 | ! |
---|
[1245] | 62 | ! 1244 2013-10-31 08:16:56Z raasch |
---|
| 63 | ! Bugfix for index bounds in case of 3d-parallel output |
---|
| 64 | ! |
---|
[1116] | 65 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 66 | ! ql is calculated by calc_liquid_water_content |
---|
| 67 | ! |
---|
[1107] | 68 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
| 69 | ! array_kind renamed precision_kind |
---|
| 70 | ! |
---|
[1077] | 71 | ! 1076 2012-12-05 08:30:18Z hoffmann |
---|
| 72 | ! Bugfix in output of ql |
---|
| 73 | ! |
---|
[1054] | 74 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 75 | ! +nr, qr, prr, qc and averaged quantities |
---|
| 76 | ! |
---|
[1037] | 77 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 78 | ! code put under GPL (PALM 3.9) |
---|
| 79 | ! |
---|
[1035] | 80 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
| 81 | ! netCDF4 without parallel file support implemented |
---|
| 82 | ! |
---|
[1008] | 83 | ! 1007 2012-09-19 14:30:36Z franke |
---|
| 84 | ! Bugfix: missing calculation of ql_vp added |
---|
| 85 | ! |
---|
[1] | 86 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
| 87 | ! Initial revision |
---|
| 88 | ! |
---|
| 89 | ! |
---|
| 90 | ! Description: |
---|
| 91 | ! ------------ |
---|
[1031] | 92 | ! Output of the 3D-arrays in netCDF and/or AVS format. |
---|
[1] | 93 | !------------------------------------------------------------------------------! |
---|
| 94 | |
---|
[1320] | 95 | USE arrays_3d, & |
---|
| 96 | ONLY: e, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, rho, sa, tend, u, v, & |
---|
| 97 | vpt, w |
---|
| 98 | |
---|
[1] | 99 | USE averaging |
---|
[1320] | 100 | |
---|
| 101 | USE cloud_parameters, & |
---|
| 102 | ONLY: l_d_cp, prr, pt_d_t |
---|
| 103 | |
---|
| 104 | USE control_parameters, & |
---|
[1327] | 105 | ONLY: avs_data_file, cloud_physics, do3d, do3d_avs_n, & |
---|
| 106 | do3d_no, do3d_time_count, io_blocks, io_group, & |
---|
| 107 | message_string, netcdf_data_format, ntdim_3d, & |
---|
[1320] | 108 | nz_do3d, plot_3d_precision, psolver, simulated_time, & |
---|
| 109 | simulated_time_chr, skip_do_avs, time_since_reference_point |
---|
| 110 | |
---|
| 111 | USE cpulog, & |
---|
| 112 | ONLY: log_point, cpu_log |
---|
| 113 | |
---|
| 114 | USE indices, & |
---|
| 115 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzt, & |
---|
| 116 | nzb |
---|
| 117 | |
---|
| 118 | USE kinds |
---|
| 119 | |
---|
[1551] | 120 | USE land_surface_model_mod, & |
---|
| 121 | ONLY: m_soil, m_soil_av, nzb_soil, nzt_soil, t_soil, t_soil_av |
---|
| 122 | |
---|
[1] | 123 | USE netcdf_control |
---|
[1320] | 124 | |
---|
| 125 | USE particle_attributes, & |
---|
[1359] | 126 | ONLY: grid_particles, number_of_particles, particles, & |
---|
| 127 | particle_advection_start, prt_count |
---|
[1320] | 128 | |
---|
[1] | 129 | USE pegrid |
---|
| 130 | |
---|
[1585] | 131 | USE radiation_model_mod, & |
---|
| 132 | ONLY: rad_lw_in, rad_lw_in_av, rad_lw_out, rad_lw_out_av, & |
---|
| 133 | rad_sw_in, rad_sw_in_av, rad_sw_out, rad_sw_out_av |
---|
| 134 | |
---|
| 135 | |
---|
[1] | 136 | IMPLICIT NONE |
---|
| 137 | |
---|
[1320] | 138 | CHARACTER (LEN=9) :: simulated_time_mod !: |
---|
[1] | 139 | |
---|
[1320] | 140 | INTEGER(iwp) :: av !: |
---|
| 141 | INTEGER(iwp) :: i !: |
---|
| 142 | INTEGER(iwp) :: if !: |
---|
| 143 | INTEGER(iwp) :: j !: |
---|
| 144 | INTEGER(iwp) :: k !: |
---|
| 145 | INTEGER(iwp) :: n !: |
---|
[1551] | 146 | INTEGER(iwp) :: nzb_do !: vertical lower limit for data output |
---|
| 147 | INTEGER(iwp) :: nzt_do !: vertical upper limit for data output |
---|
[1320] | 148 | INTEGER(iwp) :: pos !: |
---|
| 149 | INTEGER(iwp) :: prec !: |
---|
| 150 | INTEGER(iwp) :: psi !: |
---|
[1] | 151 | |
---|
[1320] | 152 | LOGICAL :: found !: |
---|
| 153 | LOGICAL :: resorted !: |
---|
[1] | 154 | |
---|
[1320] | 155 | REAL(wp) :: mean_r !: |
---|
[1359] | 156 | REAL(wp) :: s_r2 !: |
---|
[1320] | 157 | REAL(wp) :: s_r3 !: |
---|
[1] | 158 | |
---|
[1320] | 159 | REAL(sp), DIMENSION(:,:,:), ALLOCATABLE :: local_pf !: |
---|
[1] | 160 | |
---|
[1320] | 161 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !: |
---|
[1] | 162 | |
---|
| 163 | ! |
---|
| 164 | !-- Return, if nothing to output |
---|
| 165 | IF ( do3d_no(av) == 0 ) RETURN |
---|
[1308] | 166 | ! |
---|
| 167 | !-- For parallel netcdf output the time axis must be limited. Return, if this |
---|
| 168 | !-- limit is exceeded. This could be the case, if the simulated time exceeds |
---|
| 169 | !-- the given end time by the length of the given output interval. |
---|
| 170 | IF ( netcdf_data_format > 4 ) THEN |
---|
| 171 | IF ( do3d_time_count(av) + 1 > ntdim_3d(av) ) THEN |
---|
| 172 | WRITE ( message_string, * ) 'Output of 3d data is not given at t=', & |
---|
| 173 | simulated_time, '&because the maximum ', & |
---|
| 174 | 'number of output time levels is ', & |
---|
| 175 | 'exceeded.' |
---|
| 176 | CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 ) |
---|
| 177 | RETURN |
---|
| 178 | ENDIF |
---|
| 179 | ENDIF |
---|
[1] | 180 | |
---|
| 181 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
| 182 | |
---|
| 183 | ! |
---|
| 184 | !-- Open output file. |
---|
| 185 | !-- Also creates coordinate and fld-file for AVS. |
---|
[1031] | 186 | !-- For classic or 64bit netCDF output or output of other (old) data formats, |
---|
[493] | 187 | !-- for a run on more than one PE, each PE opens its own file and |
---|
[1] | 188 | !-- writes the data of its subdomain in binary format (regardless of the format |
---|
| 189 | !-- the user has requested). After the run, these files are combined to one |
---|
| 190 | !-- file by combine_plot_fields in the format requested by the user (netcdf |
---|
[493] | 191 | !-- and/or avs). |
---|
[1031] | 192 | !-- For netCDF4/HDF5 output, data is written in parallel into one file. |
---|
[1327] | 193 | IF ( netcdf_data_format < 5 ) THEN |
---|
| 194 | CALL check_open( 30 ) |
---|
| 195 | IF ( myid == 0 ) CALL check_open( 106+av*10 ) |
---|
[493] | 196 | ELSE |
---|
[1327] | 197 | CALL check_open( 106+av*10 ) |
---|
[493] | 198 | ENDIF |
---|
[1] | 199 | |
---|
| 200 | ! |
---|
[1031] | 201 | !-- Update the netCDF time axis |
---|
[1308] | 202 | !-- In case of parallel output, this is only done by PE0 to increase the |
---|
| 203 | !-- performance. |
---|
[1] | 204 | #if defined( __netcdf ) |
---|
[1308] | 205 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
| 206 | IF ( myid == 0 ) THEN |
---|
[1327] | 207 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
| 208 | (/ time_since_reference_point /), & |
---|
| 209 | start = (/ do3d_time_count(av) /), & |
---|
| 210 | count = (/ 1 /) ) |
---|
| 211 | CALL handle_netcdf_error( 'data_output_3d', 376 ) |
---|
[1] | 212 | ENDIF |
---|
| 213 | #endif |
---|
| 214 | |
---|
| 215 | ! |
---|
| 216 | !-- Loop over all variables to be written. |
---|
| 217 | if = 1 |
---|
| 218 | |
---|
| 219 | DO WHILE ( do3d(av,if)(1:1) /= ' ' ) |
---|
| 220 | ! |
---|
| 221 | !-- Store the array chosen on the temporary array. |
---|
| 222 | resorted = .FALSE. |
---|
[1551] | 223 | nzb_do = nzb |
---|
| 224 | nzt_do = nz_do3d |
---|
| 225 | |
---|
| 226 | ! |
---|
| 227 | !-- Allocate a temporary array with the desired output dimensions. |
---|
| 228 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 229 | |
---|
[1] | 230 | SELECT CASE ( TRIM( do3d(av,if) ) ) |
---|
| 231 | |
---|
| 232 | CASE ( 'e' ) |
---|
| 233 | IF ( av == 0 ) THEN |
---|
| 234 | to_be_resorted => e |
---|
| 235 | ELSE |
---|
| 236 | to_be_resorted => e_av |
---|
| 237 | ENDIF |
---|
| 238 | |
---|
[771] | 239 | CASE ( 'lpt' ) |
---|
| 240 | IF ( av == 0 ) THEN |
---|
| 241 | to_be_resorted => pt |
---|
| 242 | ELSE |
---|
| 243 | to_be_resorted => lpt_av |
---|
| 244 | ENDIF |
---|
| 245 | |
---|
[1551] | 246 | CASE ( 'm_soil' ) |
---|
| 247 | nzb_do = nzb_soil |
---|
| 248 | nzt_do = nzt_soil |
---|
| 249 | ! |
---|
| 250 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 251 | DEALLOCATE ( local_pf ) |
---|
| 252 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 253 | |
---|
| 254 | IF ( av == 0 ) THEN |
---|
| 255 | to_be_resorted => m_soil |
---|
| 256 | ELSE |
---|
| 257 | to_be_resorted => m_soil_av |
---|
| 258 | ENDIF |
---|
| 259 | |
---|
[1053] | 260 | CASE ( 'nr' ) |
---|
| 261 | IF ( av == 0 ) THEN |
---|
| 262 | to_be_resorted => nr |
---|
| 263 | ELSE |
---|
| 264 | to_be_resorted => nr_av |
---|
| 265 | ENDIF |
---|
| 266 | |
---|
[1] | 267 | CASE ( 'p' ) |
---|
| 268 | IF ( av == 0 ) THEN |
---|
[727] | 269 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p, nbgp ) |
---|
[1] | 270 | to_be_resorted => p |
---|
| 271 | ELSE |
---|
[727] | 272 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p_av, nbgp ) |
---|
[1] | 273 | to_be_resorted => p_av |
---|
| 274 | ENDIF |
---|
| 275 | |
---|
| 276 | CASE ( 'pc' ) ! particle concentration (requires ghostpoint exchange) |
---|
| 277 | IF ( av == 0 ) THEN |
---|
[1359] | 278 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 279 | tend = prt_count |
---|
| 280 | CALL exchange_horiz( tend, nbgp ) |
---|
| 281 | ELSE |
---|
| 282 | tend = 0.0_wp |
---|
| 283 | ENDIF |
---|
[667] | 284 | DO i = nxlg, nxrg |
---|
| 285 | DO j = nysg, nyng |
---|
[1551] | 286 | DO k = nzb_do, nzt_do |
---|
[1] | 287 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 288 | ENDDO |
---|
| 289 | ENDDO |
---|
| 290 | ENDDO |
---|
| 291 | resorted = .TRUE. |
---|
| 292 | ELSE |
---|
[667] | 293 | CALL exchange_horiz( pc_av, nbgp ) |
---|
[1] | 294 | to_be_resorted => pc_av |
---|
| 295 | ENDIF |
---|
| 296 | |
---|
[1359] | 297 | CASE ( 'pr' ) ! mean particle radius (effective radius) |
---|
[1] | 298 | IF ( av == 0 ) THEN |
---|
[1359] | 299 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 300 | DO i = nxl, nxr |
---|
| 301 | DO j = nys, nyn |
---|
[1551] | 302 | DO k = nzb_do, nzt_do |
---|
[1359] | 303 | number_of_particles = prt_count(k,j,i) |
---|
| 304 | IF (number_of_particles <= 0) CYCLE |
---|
| 305 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 306 | s_r2 = 0.0_wp |
---|
| 307 | s_r3 = 0.0_wp |
---|
| 308 | DO n = 1, number_of_particles |
---|
| 309 | IF ( particles(n)%particle_mask ) THEN |
---|
| 310 | s_r2 = s_r2 + particles(n)%radius**2 * & |
---|
| 311 | particles(n)%weight_factor |
---|
| 312 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
| 313 | particles(n)%weight_factor |
---|
| 314 | ENDIF |
---|
| 315 | ENDDO |
---|
| 316 | IF ( s_r2 > 0.0_wp ) THEN |
---|
| 317 | mean_r = s_r3 / s_r2 |
---|
| 318 | ELSE |
---|
| 319 | mean_r = 0.0_wp |
---|
| 320 | ENDIF |
---|
| 321 | tend(k,j,i) = mean_r |
---|
[1] | 322 | ENDDO |
---|
| 323 | ENDDO |
---|
| 324 | ENDDO |
---|
[1359] | 325 | CALL exchange_horiz( tend, nbgp ) |
---|
| 326 | ELSE |
---|
| 327 | tend = 0.0_wp |
---|
| 328 | ENDIF |
---|
[667] | 329 | DO i = nxlg, nxrg |
---|
| 330 | DO j = nysg, nyng |
---|
[1551] | 331 | DO k = nzb_do, nzt_do |
---|
[1] | 332 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 333 | ENDDO |
---|
| 334 | ENDDO |
---|
| 335 | ENDDO |
---|
| 336 | resorted = .TRUE. |
---|
| 337 | ELSE |
---|
[667] | 338 | CALL exchange_horiz( pr_av, nbgp ) |
---|
[1] | 339 | to_be_resorted => pr_av |
---|
| 340 | ENDIF |
---|
| 341 | |
---|
[1053] | 342 | CASE ( 'prr' ) |
---|
| 343 | IF ( av == 0 ) THEN |
---|
| 344 | CALL exchange_horiz( prr, nbgp ) |
---|
| 345 | DO i = nxlg, nxrg |
---|
| 346 | DO j = nysg, nyng |
---|
| 347 | DO k = nzb, nzt+1 |
---|
| 348 | local_pf(i,j,k) = prr(k,j,i) |
---|
| 349 | ENDDO |
---|
| 350 | ENDDO |
---|
| 351 | ENDDO |
---|
| 352 | ELSE |
---|
| 353 | CALL exchange_horiz( prr_av, nbgp ) |
---|
| 354 | DO i = nxlg, nxrg |
---|
| 355 | DO j = nysg, nyng |
---|
| 356 | DO k = nzb, nzt+1 |
---|
| 357 | local_pf(i,j,k) = prr_av(k,j,i) |
---|
| 358 | ENDDO |
---|
| 359 | ENDDO |
---|
| 360 | ENDDO |
---|
| 361 | ENDIF |
---|
| 362 | resorted = .TRUE. |
---|
| 363 | |
---|
[1] | 364 | CASE ( 'pt' ) |
---|
| 365 | IF ( av == 0 ) THEN |
---|
| 366 | IF ( .NOT. cloud_physics ) THEN |
---|
| 367 | to_be_resorted => pt |
---|
| 368 | ELSE |
---|
[667] | 369 | DO i = nxlg, nxrg |
---|
| 370 | DO j = nysg, nyng |
---|
[1551] | 371 | DO k = nzb_do, nzt_do |
---|
[1320] | 372 | local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & |
---|
| 373 | pt_d_t(k) * & |
---|
[1] | 374 | ql(k,j,i) |
---|
| 375 | ENDDO |
---|
| 376 | ENDDO |
---|
| 377 | ENDDO |
---|
| 378 | resorted = .TRUE. |
---|
| 379 | ENDIF |
---|
| 380 | ELSE |
---|
| 381 | to_be_resorted => pt_av |
---|
| 382 | ENDIF |
---|
| 383 | |
---|
| 384 | CASE ( 'q' ) |
---|
| 385 | IF ( av == 0 ) THEN |
---|
| 386 | to_be_resorted => q |
---|
| 387 | ELSE |
---|
| 388 | to_be_resorted => q_av |
---|
| 389 | ENDIF |
---|
[691] | 390 | |
---|
[1053] | 391 | CASE ( 'qc' ) |
---|
[1] | 392 | IF ( av == 0 ) THEN |
---|
[1115] | 393 | to_be_resorted => qc |
---|
[1] | 394 | ELSE |
---|
[1115] | 395 | to_be_resorted => qc_av |
---|
[1] | 396 | ENDIF |
---|
| 397 | |
---|
[1053] | 398 | CASE ( 'ql' ) |
---|
| 399 | IF ( av == 0 ) THEN |
---|
[1115] | 400 | to_be_resorted => ql |
---|
[1053] | 401 | ELSE |
---|
[1115] | 402 | to_be_resorted => ql_av |
---|
[1053] | 403 | ENDIF |
---|
| 404 | |
---|
[1] | 405 | CASE ( 'ql_c' ) |
---|
| 406 | IF ( av == 0 ) THEN |
---|
| 407 | to_be_resorted => ql_c |
---|
| 408 | ELSE |
---|
| 409 | to_be_resorted => ql_c_av |
---|
| 410 | ENDIF |
---|
| 411 | |
---|
| 412 | CASE ( 'ql_v' ) |
---|
| 413 | IF ( av == 0 ) THEN |
---|
| 414 | to_be_resorted => ql_v |
---|
| 415 | ELSE |
---|
| 416 | to_be_resorted => ql_v_av |
---|
| 417 | ENDIF |
---|
| 418 | |
---|
| 419 | CASE ( 'ql_vp' ) |
---|
| 420 | IF ( av == 0 ) THEN |
---|
[1359] | 421 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 422 | DO i = nxl, nxr |
---|
| 423 | DO j = nys, nyn |
---|
[1551] | 424 | DO k = nzb_do, nzt_do |
---|
[1359] | 425 | number_of_particles = prt_count(k,j,i) |
---|
| 426 | IF (number_of_particles <= 0) CYCLE |
---|
| 427 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 428 | DO n = 1, number_of_particles |
---|
| 429 | IF ( particles(n)%particle_mask ) THEN |
---|
| 430 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 431 | particles(n)%weight_factor / & |
---|
| 432 | prt_count(k,j,i) |
---|
| 433 | ENDIF |
---|
| 434 | ENDDO |
---|
[1007] | 435 | ENDDO |
---|
| 436 | ENDDO |
---|
| 437 | ENDDO |
---|
[1359] | 438 | CALL exchange_horiz( tend, nbgp ) |
---|
| 439 | ELSE |
---|
| 440 | tend = 0.0_wp |
---|
| 441 | ENDIF |
---|
[1007] | 442 | DO i = nxlg, nxrg |
---|
| 443 | DO j = nysg, nyng |
---|
[1551] | 444 | DO k = nzb_do, nzt_do |
---|
[1007] | 445 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 446 | ENDDO |
---|
| 447 | ENDDO |
---|
| 448 | ENDDO |
---|
| 449 | resorted = .TRUE. |
---|
[1] | 450 | ELSE |
---|
[1007] | 451 | CALL exchange_horiz( ql_vp_av, nbgp ) |
---|
[1] | 452 | to_be_resorted => ql_vp_av |
---|
| 453 | ENDIF |
---|
| 454 | |
---|
[1053] | 455 | CASE ( 'qr' ) |
---|
| 456 | IF ( av == 0 ) THEN |
---|
| 457 | to_be_resorted => qr |
---|
| 458 | ELSE |
---|
| 459 | to_be_resorted => qr_av |
---|
| 460 | ENDIF |
---|
| 461 | |
---|
[1] | 462 | CASE ( 'qv' ) |
---|
| 463 | IF ( av == 0 ) THEN |
---|
[667] | 464 | DO i = nxlg, nxrg |
---|
| 465 | DO j = nysg, nyng |
---|
[1551] | 466 | DO k = nzb_do, nzt_do |
---|
[1] | 467 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
| 468 | ENDDO |
---|
| 469 | ENDDO |
---|
| 470 | ENDDO |
---|
| 471 | resorted = .TRUE. |
---|
| 472 | ELSE |
---|
| 473 | to_be_resorted => qv_av |
---|
| 474 | ENDIF |
---|
| 475 | |
---|
[1585] | 476 | CASE ( 'rad_sw_in' ) |
---|
| 477 | IF ( av == 0 ) THEN |
---|
| 478 | to_be_resorted => rad_sw_in |
---|
| 479 | ELSE |
---|
| 480 | to_be_resorted => rad_sw_in_av |
---|
| 481 | ENDIF |
---|
| 482 | |
---|
| 483 | CASE ( 'rad_sw_out' ) |
---|
| 484 | IF ( av == 0 ) THEN |
---|
| 485 | to_be_resorted => rad_sw_out |
---|
| 486 | ELSE |
---|
| 487 | to_be_resorted => rad_sw_out_av |
---|
| 488 | ENDIF |
---|
| 489 | |
---|
| 490 | CASE ( 'rad_lw_in' ) |
---|
| 491 | IF ( av == 0 ) THEN |
---|
| 492 | to_be_resorted => rad_lw_in |
---|
| 493 | ELSE |
---|
| 494 | to_be_resorted => rad_lw_in_av |
---|
| 495 | ENDIF |
---|
| 496 | |
---|
| 497 | CASE ( 'rad_lw_out' ) |
---|
| 498 | IF ( av == 0 ) THEN |
---|
| 499 | to_be_resorted => rad_lw_out |
---|
| 500 | ELSE |
---|
| 501 | to_be_resorted => rad_lw_out_av |
---|
| 502 | ENDIF |
---|
| 503 | |
---|
[96] | 504 | CASE ( 'rho' ) |
---|
| 505 | IF ( av == 0 ) THEN |
---|
| 506 | to_be_resorted => rho |
---|
| 507 | ELSE |
---|
| 508 | to_be_resorted => rho_av |
---|
| 509 | ENDIF |
---|
[691] | 510 | |
---|
[1] | 511 | CASE ( 's' ) |
---|
| 512 | IF ( av == 0 ) THEN |
---|
| 513 | to_be_resorted => q |
---|
| 514 | ELSE |
---|
[355] | 515 | to_be_resorted => s_av |
---|
[1] | 516 | ENDIF |
---|
[691] | 517 | |
---|
[96] | 518 | CASE ( 'sa' ) |
---|
| 519 | IF ( av == 0 ) THEN |
---|
| 520 | to_be_resorted => sa |
---|
| 521 | ELSE |
---|
| 522 | to_be_resorted => sa_av |
---|
| 523 | ENDIF |
---|
[691] | 524 | |
---|
[1551] | 525 | CASE ( 't_soil' ) |
---|
| 526 | nzb_do = nzb_soil |
---|
| 527 | nzt_do = nzt_soil |
---|
| 528 | ! |
---|
| 529 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 530 | DEALLOCATE ( local_pf ) |
---|
| 531 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 532 | |
---|
| 533 | IF ( av == 0 ) THEN |
---|
| 534 | to_be_resorted => t_soil |
---|
| 535 | ELSE |
---|
| 536 | to_be_resorted => t_soil_av |
---|
| 537 | ENDIF |
---|
| 538 | |
---|
[1] | 539 | CASE ( 'u' ) |
---|
| 540 | IF ( av == 0 ) THEN |
---|
| 541 | to_be_resorted => u |
---|
| 542 | ELSE |
---|
| 543 | to_be_resorted => u_av |
---|
| 544 | ENDIF |
---|
| 545 | |
---|
| 546 | CASE ( 'v' ) |
---|
| 547 | IF ( av == 0 ) THEN |
---|
| 548 | to_be_resorted => v |
---|
| 549 | ELSE |
---|
| 550 | to_be_resorted => v_av |
---|
| 551 | ENDIF |
---|
| 552 | |
---|
| 553 | CASE ( 'vpt' ) |
---|
| 554 | IF ( av == 0 ) THEN |
---|
| 555 | to_be_resorted => vpt |
---|
| 556 | ELSE |
---|
| 557 | to_be_resorted => vpt_av |
---|
| 558 | ENDIF |
---|
| 559 | |
---|
| 560 | CASE ( 'w' ) |
---|
| 561 | IF ( av == 0 ) THEN |
---|
| 562 | to_be_resorted => w |
---|
| 563 | ELSE |
---|
| 564 | to_be_resorted => w_av |
---|
| 565 | ENDIF |
---|
| 566 | |
---|
| 567 | CASE DEFAULT |
---|
| 568 | ! |
---|
| 569 | !-- User defined quantity |
---|
[1320] | 570 | CALL user_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
[1551] | 571 | nzb_do, nzt_do ) |
---|
[1] | 572 | resorted = .TRUE. |
---|
| 573 | |
---|
[254] | 574 | IF ( .NOT. found ) THEN |
---|
[1320] | 575 | message_string = 'no output available for: ' // & |
---|
[274] | 576 | TRIM( do3d(av,if) ) |
---|
[254] | 577 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
[1] | 578 | ENDIF |
---|
| 579 | |
---|
| 580 | END SELECT |
---|
| 581 | |
---|
| 582 | ! |
---|
| 583 | !-- Resort the array to be output, if not done above |
---|
| 584 | IF ( .NOT. resorted ) THEN |
---|
[667] | 585 | DO i = nxlg, nxrg |
---|
| 586 | DO j = nysg, nyng |
---|
[1551] | 587 | DO k = nzb_do, nzt_do |
---|
[1] | 588 | local_pf(i,j,k) = to_be_resorted(k,j,i) |
---|
| 589 | ENDDO |
---|
| 590 | ENDDO |
---|
| 591 | ENDDO |
---|
| 592 | ENDIF |
---|
| 593 | |
---|
| 594 | ! |
---|
[1327] | 595 | !-- Output of the 3D-array |
---|
| 596 | #if defined( __parallel ) |
---|
| 597 | IF ( netcdf_data_format < 5 ) THEN |
---|
[1] | 598 | ! |
---|
[1327] | 599 | !-- Non-parallel netCDF output. Data is output in parallel in |
---|
| 600 | !-- FORTRAN binary format here, and later collected into one file by |
---|
| 601 | !-- combine_plot_fields |
---|
| 602 | IF ( myid == 0 ) THEN |
---|
| 603 | WRITE ( 30 ) time_since_reference_point, & |
---|
| 604 | do3d_time_count(av), av |
---|
[1] | 605 | ENDIF |
---|
[1327] | 606 | DO i = 0, io_blocks-1 |
---|
| 607 | IF ( i == io_group ) THEN |
---|
[1551] | 608 | WRITE ( 30 ) nxlg, nxrg, nysg, nyng, nzb_do, nzt_do |
---|
| 609 | WRITE ( 30 ) local_pf(:,:,nzb_do:nzt_do) |
---|
[1327] | 610 | ENDIF |
---|
[1] | 611 | #if defined( __parallel ) |
---|
[1327] | 612 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[759] | 613 | #endif |
---|
[1327] | 614 | ENDDO |
---|
[559] | 615 | |
---|
[1327] | 616 | ELSE |
---|
[646] | 617 | #if defined( __netcdf ) |
---|
[493] | 618 | ! |
---|
[1327] | 619 | !-- Parallel output in netCDF4/HDF5 format. |
---|
| 620 | !-- Do not output redundant ghost point data except for the |
---|
| 621 | !-- boundaries of the total domain. |
---|
| 622 | IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
| 623 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 624 | local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do), & |
---|
| 625 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 626 | count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 627 | ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
| 628 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 629 | local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do), & |
---|
| 630 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 631 | count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 632 | ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
| 633 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 634 | local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do ), & |
---|
| 635 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 636 | count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 637 | ELSE |
---|
| 638 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 639 | local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do), & |
---|
| 640 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 641 | count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 642 | ENDIF |
---|
| 643 | CALL handle_netcdf_error( 'data_output_3d', 386 ) |
---|
[646] | 644 | #endif |
---|
[1327] | 645 | ENDIF |
---|
[1] | 646 | #else |
---|
| 647 | #if defined( __netcdf ) |
---|
[1327] | 648 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 649 | local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do), & |
---|
[1327] | 650 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
[1551] | 651 | count = (/ nx+2, ny+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 652 | CALL handle_netcdf_error( 'data_output_3d', 446 ) |
---|
[1] | 653 | #endif |
---|
| 654 | #endif |
---|
| 655 | |
---|
| 656 | if = if + 1 |
---|
| 657 | |
---|
| 658 | ! |
---|
[1551] | 659 | !-- Deallocate temporary array |
---|
| 660 | DEALLOCATE ( local_pf ) |
---|
[1] | 661 | |
---|
[1551] | 662 | ENDDO |
---|
[1] | 663 | |
---|
[1318] | 664 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
[1] | 665 | |
---|
| 666 | ! |
---|
| 667 | !-- Formats. |
---|
[1320] | 668 | 3300 FORMAT ('variable ',I4,' file=',A,' filetype=unformatted skip=',I12/ & |
---|
[1] | 669 | 'label = ',A,A) |
---|
| 670 | |
---|
| 671 | END SUBROUTINE data_output_3d |
---|