[1682] | 1 | !> @file data_output_3d.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1036] | 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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[1106] | 21 | ! ------------------ |
---|
[3589] | 22 | ! |
---|
| 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: data_output_3d.f90 4360 2020-01-07 11:25:50Z Giersch $ |
---|
[4346] | 27 | ! Introduction of wall_flags_total_0, which currently sets bits based on static |
---|
| 28 | ! topography information used in wall_flags_static_0 |
---|
| 29 | ! |
---|
| 30 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
[4329] | 31 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
| 32 | ! |
---|
| 33 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
[4182] | 34 | ! Corrected "Former revisions" section |
---|
| 35 | ! |
---|
| 36 | ! 4162 2019-08-16 05:54:29Z raasch |
---|
[4162] | 37 | ! bugfix for r4155 |
---|
| 38 | ! |
---|
| 39 | ! 4155 2019-08-14 06:25:18Z raasch |
---|
[4155] | 40 | ! bugfix for 3d-output in serial mode (ghost points must not be written) |
---|
| 41 | ! |
---|
| 42 | ! 4127 2019-07-30 14:47:10Z suehring |
---|
[4127] | 43 | ! Adjustment for top boundary index for plant-canopy model outputs |
---|
| 44 | ! (merge from branch resler) |
---|
| 45 | ! |
---|
| 46 | ! 4048 2019-06-21 21:00:21Z knoop |
---|
[4048] | 47 | ! Moved tcm_data_output_3d to module_interface |
---|
| 48 | ! |
---|
| 49 | ! 4039 2019-06-18 10:32:41Z suehring |
---|
[4039] | 50 | ! modularize diagnostic output |
---|
| 51 | ! |
---|
| 52 | ! 3994 2019-05-22 18:08:09Z suehring |
---|
[3994] | 53 | ! output of turbulence intensity added |
---|
| 54 | ! |
---|
| 55 | ! 3987 2019-05-22 09:52:13Z kanani |
---|
[3987] | 56 | ! Introduce alternative switch for debug output during timestepping |
---|
| 57 | ! |
---|
| 58 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
[3885] | 59 | ! Changes related to global restructuring of location messages and introduction |
---|
| 60 | ! of additional debug messages |
---|
| 61 | ! |
---|
| 62 | ! 3814 2019-03-26 08:40:31Z pavelkrc |
---|
[3766] | 63 | ! unused variables removed |
---|
| 64 | ! |
---|
| 65 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3646] | 66 | ! Bugfix: use time_since_reference_point instead of simulated_time (relevant |
---|
| 67 | ! when using wall/soil spinup) |
---|
[3582] | 68 | ! |
---|
[4182] | 69 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
| 70 | ! Initial revision |
---|
| 71 | ! |
---|
| 72 | ! |
---|
[1] | 73 | ! Description: |
---|
| 74 | ! ------------ |
---|
[1682] | 75 | !> Output of the 3D-arrays in netCDF and/or AVS format. |
---|
[1] | 76 | !------------------------------------------------------------------------------! |
---|
[1682] | 77 | SUBROUTINE data_output_3d( av ) |
---|
| 78 | |
---|
[1] | 79 | |
---|
[1320] | 80 | USE arrays_3d, & |
---|
[3766] | 81 | ONLY: d_exner, e, p, pt, q, ql, ql_c, ql_v, s, tend, u, v, vpt, w |
---|
[3274] | 82 | |
---|
[1] | 83 | USE averaging |
---|
[3274] | 84 | |
---|
| 85 | USE basic_constants_and_equations_mod, & |
---|
| 86 | ONLY: lv_d_cp |
---|
| 87 | |
---|
| 88 | USE bulk_cloud_model_mod, & |
---|
[3637] | 89 | ONLY: bulk_cloud_model |
---|
[3274] | 90 | |
---|
[1320] | 91 | USE control_parameters, & |
---|
[3987] | 92 | ONLY: debug_output_timestep, & |
---|
[3885] | 93 | do3d, do3d_no, do3d_time_count, io_blocks, io_group, & |
---|
[4127] | 94 | land_surface, message_string, ntdim_3d, nz_do3d, plant_canopy, & |
---|
| 95 | psolver, time_since_reference_point, urban_surface, & |
---|
| 96 | varnamelength |
---|
[3274] | 97 | |
---|
[1320] | 98 | USE cpulog, & |
---|
| 99 | ONLY: log_point, cpu_log |
---|
[2817] | 100 | |
---|
[3405] | 101 | #if defined( __parallel ) |
---|
[1320] | 102 | USE indices, & |
---|
[3241] | 103 | ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
[4346] | 104 | wall_flags_total_0 |
---|
[3405] | 105 | #else |
---|
| 106 | USE indices, & |
---|
| 107 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, & |
---|
[4346] | 108 | nzt, wall_flags_total_0 |
---|
[3405] | 109 | #endif |
---|
[3274] | 110 | |
---|
[1320] | 111 | USE kinds |
---|
[3274] | 112 | |
---|
[1551] | 113 | USE land_surface_model_mod, & |
---|
[2232] | 114 | ONLY: lsm_data_output_3d, nzb_soil, nzt_soil |
---|
[1551] | 115 | |
---|
[3637] | 116 | USE module_interface, & |
---|
| 117 | ONLY: module_interface_data_output_3d |
---|
| 118 | |
---|
[1783] | 119 | #if defined( __netcdf ) |
---|
| 120 | USE NETCDF |
---|
| 121 | #endif |
---|
| 122 | |
---|
| 123 | USE netcdf_interface, & |
---|
[2696] | 124 | ONLY: fill_value, id_set_3d, id_var_do3d, id_var_time_3d, nc_stat, & |
---|
[1783] | 125 | netcdf_data_format, netcdf_handle_error |
---|
[3294] | 126 | |
---|
[1320] | 127 | USE particle_attributes, & |
---|
[1359] | 128 | ONLY: grid_particles, number_of_particles, particles, & |
---|
| 129 | particle_advection_start, prt_count |
---|
[3637] | 130 | |
---|
[1] | 131 | USE pegrid |
---|
| 132 | |
---|
[4127] | 133 | USE plant_canopy_model_mod, & |
---|
| 134 | ONLY: pch_index |
---|
| 135 | |
---|
[1585] | 136 | USE radiation_model_mod, & |
---|
[3814] | 137 | ONLY: nz_urban_b, nz_urban_t |
---|
[1585] | 138 | |
---|
[2007] | 139 | USE urban_surface_mod, & |
---|
[2696] | 140 | ONLY: usm_data_output_3d |
---|
[1585] | 141 | |
---|
[2007] | 142 | |
---|
[1] | 143 | IMPLICIT NONE |
---|
| 144 | |
---|
[3554] | 145 | INTEGER(iwp) :: av !< flag for (non-)average output |
---|
[2696] | 146 | INTEGER(iwp) :: flag_nr !< number of masking flag |
---|
[3554] | 147 | INTEGER(iwp) :: i !< loop index |
---|
| 148 | INTEGER(iwp) :: ivar !< variable index |
---|
| 149 | INTEGER(iwp) :: j !< loop index |
---|
| 150 | INTEGER(iwp) :: k !< loop index |
---|
| 151 | INTEGER(iwp) :: n !< loop index |
---|
[1682] | 152 | INTEGER(iwp) :: nzb_do !< vertical lower limit for data output |
---|
| 153 | INTEGER(iwp) :: nzt_do !< vertical upper limit for data output |
---|
[1] | 154 | |
---|
[3554] | 155 | LOGICAL :: found !< true if output variable was found |
---|
| 156 | LOGICAL :: resorted !< true if variable is resorted |
---|
[1] | 157 | |
---|
[3554] | 158 | REAL(wp) :: mean_r !< mean particle radius |
---|
| 159 | REAL(wp) :: s_r2 !< sum( particle-radius**2 ) |
---|
| 160 | REAL(wp) :: s_r3 !< sum( particle-radius**3 ) |
---|
[1] | 161 | |
---|
[3554] | 162 | REAL(sp), DIMENSION(:,:,:), ALLOCATABLE :: local_pf !< output array |
---|
[1] | 163 | |
---|
[3554] | 164 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< pointer to array which shall be output |
---|
[1] | 165 | |
---|
[2011] | 166 | CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string |
---|
[2007] | 167 | |
---|
[1] | 168 | ! |
---|
| 169 | !-- Return, if nothing to output |
---|
| 170 | IF ( do3d_no(av) == 0 ) RETURN |
---|
| 171 | |
---|
[3987] | 172 | IF ( debug_output_timestep ) CALL debug_message( 'data_output_3d', 'start' ) |
---|
[3885] | 173 | |
---|
[1] | 174 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
| 175 | |
---|
| 176 | ! |
---|
| 177 | !-- Open output file. |
---|
[2512] | 178 | !-- For classic or 64bit netCDF output on more than one PE, each PE opens its |
---|
| 179 | !-- own file and writes the data of its subdomain in binary format. After the |
---|
| 180 | !-- run, these files are combined to one NetCDF file by combine_plot_fields. |
---|
[1031] | 181 | !-- For netCDF4/HDF5 output, data is written in parallel into one file. |
---|
[1327] | 182 | IF ( netcdf_data_format < 5 ) THEN |
---|
[2967] | 183 | #if defined( __parallel ) |
---|
[1327] | 184 | CALL check_open( 30 ) |
---|
[2967] | 185 | #endif |
---|
[1327] | 186 | IF ( myid == 0 ) CALL check_open( 106+av*10 ) |
---|
[493] | 187 | ELSE |
---|
[1327] | 188 | CALL check_open( 106+av*10 ) |
---|
[493] | 189 | ENDIF |
---|
[1] | 190 | |
---|
| 191 | ! |
---|
[1745] | 192 | !-- For parallel netcdf output the time axis must be limited. Return, if this |
---|
| 193 | !-- limit is exceeded. This could be the case, if the simulated time exceeds |
---|
| 194 | !-- the given end time by the length of the given output interval. |
---|
| 195 | IF ( netcdf_data_format > 4 ) THEN |
---|
| 196 | IF ( do3d_time_count(av) + 1 > ntdim_3d(av) ) THEN |
---|
[3646] | 197 | WRITE ( message_string, * ) 'Output of 3d data is not given at t=', & |
---|
| 198 | time_since_reference_point, 's because the maximum ', & |
---|
| 199 | 'number of output time levels is ', & |
---|
[1745] | 200 | 'exceeded.' |
---|
| 201 | CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 ) |
---|
| 202 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
| 203 | RETURN |
---|
| 204 | ENDIF |
---|
| 205 | ENDIF |
---|
| 206 | |
---|
| 207 | ! |
---|
[1031] | 208 | !-- Update the netCDF time axis |
---|
[1308] | 209 | !-- In case of parallel output, this is only done by PE0 to increase the |
---|
| 210 | !-- performance. |
---|
[1] | 211 | #if defined( __netcdf ) |
---|
[1308] | 212 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
| 213 | IF ( myid == 0 ) THEN |
---|
[1327] | 214 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
| 215 | (/ time_since_reference_point /), & |
---|
| 216 | start = (/ do3d_time_count(av) /), & |
---|
| 217 | count = (/ 1 /) ) |
---|
[1783] | 218 | CALL netcdf_handle_error( 'data_output_3d', 376 ) |
---|
[1] | 219 | ENDIF |
---|
| 220 | #endif |
---|
| 221 | |
---|
| 222 | ! |
---|
| 223 | !-- Loop over all variables to be written. |
---|
[3554] | 224 | ivar = 1 |
---|
[1] | 225 | |
---|
[3554] | 226 | DO WHILE ( do3d(av,ivar)(1:1) /= ' ' ) |
---|
[2007] | 227 | |
---|
[1] | 228 | ! |
---|
[3637] | 229 | !-- Initiate found flag and resorting flag |
---|
| 230 | found = .FALSE. |
---|
| 231 | resorted = .FALSE. |
---|
[4127] | 232 | trimvar = TRIM( do3d(av,ivar) ) |
---|
| 233 | |
---|
[3637] | 234 | ! |
---|
| 235 | !-- Temporary solution to account for data output within the new urban |
---|
[2007] | 236 | !-- surface model (urban_surface_mod.f90), see also SELECT CASE ( trimvar ). |
---|
[1] | 237 | !-- Store the array chosen on the temporary array. |
---|
[3637] | 238 | nzb_do = nzb |
---|
[4127] | 239 | ! |
---|
| 240 | !-- Set top index for 3D output. Note in case of plant-canopy model |
---|
| 241 | !-- these index is determined by pch_index. |
---|
| 242 | IF ( plant_canopy .AND. trimvar(1:4) == 'pcm_' ) THEN |
---|
| 243 | nzt_do = pch_index |
---|
| 244 | ELSE |
---|
| 245 | nzt_do = nz_do3d |
---|
| 246 | ENDIF |
---|
[3637] | 247 | |
---|
[1551] | 248 | ! |
---|
| 249 | !-- Allocate a temporary array with the desired output dimensions. |
---|
[2512] | 250 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[2696] | 251 | ! |
---|
| 252 | !-- Before each output, set array local_pf to fill value |
---|
| 253 | local_pf = fill_value |
---|
| 254 | ! |
---|
| 255 | !-- Set masking flag for topography for not resorted arrays |
---|
| 256 | flag_nr = 0 |
---|
[1551] | 257 | |
---|
[2007] | 258 | SELECT CASE ( trimvar ) |
---|
[1] | 259 | |
---|
| 260 | CASE ( 'e' ) |
---|
| 261 | IF ( av == 0 ) THEN |
---|
| 262 | to_be_resorted => e |
---|
| 263 | ELSE |
---|
[3004] | 264 | IF ( .NOT. ALLOCATED( e_av ) ) THEN |
---|
| 265 | ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 266 | e_av = REAL( fill_value, KIND = wp ) |
---|
| 267 | ENDIF |
---|
[1] | 268 | to_be_resorted => e_av |
---|
| 269 | ENDIF |
---|
| 270 | |
---|
[3421] | 271 | CASE ( 'thetal' ) |
---|
[771] | 272 | IF ( av == 0 ) THEN |
---|
| 273 | to_be_resorted => pt |
---|
| 274 | ELSE |
---|
[3004] | 275 | IF ( .NOT. ALLOCATED( lpt_av ) ) THEN |
---|
| 276 | ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 277 | lpt_av = REAL( fill_value, KIND = wp ) |
---|
| 278 | ENDIF |
---|
[771] | 279 | to_be_resorted => lpt_av |
---|
| 280 | ENDIF |
---|
| 281 | |
---|
[1] | 282 | CASE ( 'p' ) |
---|
| 283 | IF ( av == 0 ) THEN |
---|
[727] | 284 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p, nbgp ) |
---|
[1] | 285 | to_be_resorted => p |
---|
| 286 | ELSE |
---|
[3004] | 287 | IF ( .NOT. ALLOCATED( p_av ) ) THEN |
---|
| 288 | ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 289 | p_av = REAL( fill_value, KIND = wp ) |
---|
| 290 | ENDIF |
---|
[727] | 291 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p_av, nbgp ) |
---|
[1] | 292 | to_be_resorted => p_av |
---|
| 293 | ENDIF |
---|
| 294 | |
---|
| 295 | CASE ( 'pc' ) ! particle concentration (requires ghostpoint exchange) |
---|
| 296 | IF ( av == 0 ) THEN |
---|
[3646] | 297 | IF ( time_since_reference_point >= particle_advection_start ) THEN |
---|
[1359] | 298 | tend = prt_count |
---|
| 299 | ELSE |
---|
| 300 | tend = 0.0_wp |
---|
| 301 | ENDIF |
---|
[2512] | 302 | DO i = nxl, nxr |
---|
| 303 | DO j = nys, nyn |
---|
[1551] | 304 | DO k = nzb_do, nzt_do |
---|
[1] | 305 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 306 | ENDDO |
---|
| 307 | ENDDO |
---|
| 308 | ENDDO |
---|
| 309 | resorted = .TRUE. |
---|
| 310 | ELSE |
---|
[3004] | 311 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
| 312 | ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 313 | pc_av = REAL( fill_value, KIND = wp ) |
---|
| 314 | ENDIF |
---|
[1] | 315 | to_be_resorted => pc_av |
---|
| 316 | ENDIF |
---|
| 317 | |
---|
[1359] | 318 | CASE ( 'pr' ) ! mean particle radius (effective radius) |
---|
[1] | 319 | IF ( av == 0 ) THEN |
---|
[3646] | 320 | IF ( time_since_reference_point >= particle_advection_start ) THEN |
---|
[1359] | 321 | DO i = nxl, nxr |
---|
| 322 | DO j = nys, nyn |
---|
[1551] | 323 | DO k = nzb_do, nzt_do |
---|
[1359] | 324 | number_of_particles = prt_count(k,j,i) |
---|
| 325 | IF (number_of_particles <= 0) CYCLE |
---|
| 326 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 327 | s_r2 = 0.0_wp |
---|
| 328 | s_r3 = 0.0_wp |
---|
| 329 | DO n = 1, number_of_particles |
---|
| 330 | IF ( particles(n)%particle_mask ) THEN |
---|
| 331 | s_r2 = s_r2 + particles(n)%radius**2 * & |
---|
| 332 | particles(n)%weight_factor |
---|
| 333 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
| 334 | particles(n)%weight_factor |
---|
| 335 | ENDIF |
---|
| 336 | ENDDO |
---|
| 337 | IF ( s_r2 > 0.0_wp ) THEN |
---|
| 338 | mean_r = s_r3 / s_r2 |
---|
| 339 | ELSE |
---|
| 340 | mean_r = 0.0_wp |
---|
| 341 | ENDIF |
---|
| 342 | tend(k,j,i) = mean_r |
---|
[1] | 343 | ENDDO |
---|
| 344 | ENDDO |
---|
| 345 | ENDDO |
---|
[1359] | 346 | ELSE |
---|
| 347 | tend = 0.0_wp |
---|
| 348 | ENDIF |
---|
[2512] | 349 | DO i = nxl, nxr |
---|
| 350 | DO j = nys, nyn |
---|
[1551] | 351 | DO k = nzb_do, nzt_do |
---|
[1] | 352 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 353 | ENDDO |
---|
| 354 | ENDDO |
---|
| 355 | ENDDO |
---|
| 356 | resorted = .TRUE. |
---|
| 357 | ELSE |
---|
[3004] | 358 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
| 359 | ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 360 | pr_av = REAL( fill_value, KIND = wp ) |
---|
| 361 | ENDIF |
---|
[1] | 362 | to_be_resorted => pr_av |
---|
| 363 | ENDIF |
---|
| 364 | |
---|
[3421] | 365 | CASE ( 'theta' ) |
---|
[1] | 366 | IF ( av == 0 ) THEN |
---|
[3274] | 367 | IF ( .NOT. bulk_cloud_model ) THEN |
---|
[1] | 368 | to_be_resorted => pt |
---|
| 369 | ELSE |
---|
[2512] | 370 | DO i = nxl, nxr |
---|
| 371 | DO j = nys, nyn |
---|
[1551] | 372 | DO k = nzb_do, nzt_do |
---|
[3274] | 373 | local_pf(i,j,k) = pt(k,j,i) + lv_d_cp * & |
---|
| 374 | d_exner(k) * & |
---|
[1] | 375 | ql(k,j,i) |
---|
| 376 | ENDDO |
---|
| 377 | ENDDO |
---|
| 378 | ENDDO |
---|
| 379 | resorted = .TRUE. |
---|
| 380 | ENDIF |
---|
| 381 | ELSE |
---|
[3004] | 382 | IF ( .NOT. ALLOCATED( pt_av ) ) THEN |
---|
| 383 | ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 384 | pt_av = REAL( fill_value, KIND = wp ) |
---|
| 385 | ENDIF |
---|
[1] | 386 | to_be_resorted => pt_av |
---|
| 387 | ENDIF |
---|
| 388 | |
---|
| 389 | CASE ( 'q' ) |
---|
| 390 | IF ( av == 0 ) THEN |
---|
| 391 | to_be_resorted => q |
---|
| 392 | ELSE |
---|
[3004] | 393 | IF ( .NOT. ALLOCATED( q_av ) ) THEN |
---|
| 394 | ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 395 | q_av = REAL( fill_value, KIND = wp ) |
---|
| 396 | ENDIF |
---|
[1] | 397 | to_be_resorted => q_av |
---|
| 398 | ENDIF |
---|
[691] | 399 | |
---|
[1053] | 400 | CASE ( 'ql' ) |
---|
| 401 | IF ( av == 0 ) THEN |
---|
[1115] | 402 | to_be_resorted => ql |
---|
[1053] | 403 | ELSE |
---|
[3004] | 404 | IF ( .NOT. ALLOCATED( ql_av ) ) THEN |
---|
| 405 | ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 406 | ql_av = REAL( fill_value, KIND = wp ) |
---|
| 407 | ENDIF |
---|
[1115] | 408 | to_be_resorted => ql_av |
---|
[1053] | 409 | ENDIF |
---|
| 410 | |
---|
[1] | 411 | CASE ( 'ql_c' ) |
---|
| 412 | IF ( av == 0 ) THEN |
---|
| 413 | to_be_resorted => ql_c |
---|
| 414 | ELSE |
---|
[3004] | 415 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
| 416 | ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 417 | ql_c_av = REAL( fill_value, KIND = wp ) |
---|
| 418 | ENDIF |
---|
[1] | 419 | to_be_resorted => ql_c_av |
---|
| 420 | ENDIF |
---|
| 421 | |
---|
| 422 | CASE ( 'ql_v' ) |
---|
| 423 | IF ( av == 0 ) THEN |
---|
| 424 | to_be_resorted => ql_v |
---|
| 425 | ELSE |
---|
[3004] | 426 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
| 427 | ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 428 | ql_v_av = REAL( fill_value, KIND = wp ) |
---|
| 429 | ENDIF |
---|
[1] | 430 | to_be_resorted => ql_v_av |
---|
| 431 | ENDIF |
---|
| 432 | |
---|
| 433 | CASE ( 'ql_vp' ) |
---|
| 434 | IF ( av == 0 ) THEN |
---|
[3646] | 435 | IF ( time_since_reference_point >= particle_advection_start ) THEN |
---|
[1359] | 436 | DO i = nxl, nxr |
---|
| 437 | DO j = nys, nyn |
---|
[1551] | 438 | DO k = nzb_do, nzt_do |
---|
[1359] | 439 | number_of_particles = prt_count(k,j,i) |
---|
| 440 | IF (number_of_particles <= 0) CYCLE |
---|
| 441 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 442 | DO n = 1, number_of_particles |
---|
| 443 | IF ( particles(n)%particle_mask ) THEN |
---|
| 444 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 445 | particles(n)%weight_factor / & |
---|
| 446 | prt_count(k,j,i) |
---|
| 447 | ENDIF |
---|
| 448 | ENDDO |
---|
[1007] | 449 | ENDDO |
---|
| 450 | ENDDO |
---|
| 451 | ENDDO |
---|
[1359] | 452 | ELSE |
---|
| 453 | tend = 0.0_wp |
---|
| 454 | ENDIF |
---|
[2512] | 455 | DO i = nxl, nxr |
---|
| 456 | DO j = nys, nyn |
---|
[1551] | 457 | DO k = nzb_do, nzt_do |
---|
[1007] | 458 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 459 | ENDDO |
---|
| 460 | ENDDO |
---|
| 461 | ENDDO |
---|
| 462 | resorted = .TRUE. |
---|
[1] | 463 | ELSE |
---|
[3004] | 464 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
| 465 | ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 466 | ql_vp_av = REAL( fill_value, KIND = wp ) |
---|
| 467 | ENDIF |
---|
[1] | 468 | to_be_resorted => ql_vp_av |
---|
| 469 | ENDIF |
---|
| 470 | |
---|
| 471 | CASE ( 'qv' ) |
---|
| 472 | IF ( av == 0 ) THEN |
---|
[2512] | 473 | DO i = nxl, nxr |
---|
| 474 | DO j = nys, nyn |
---|
[1551] | 475 | DO k = nzb_do, nzt_do |
---|
[1] | 476 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
| 477 | ENDDO |
---|
| 478 | ENDDO |
---|
| 479 | ENDDO |
---|
| 480 | resorted = .TRUE. |
---|
| 481 | ELSE |
---|
[3004] | 482 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
| 483 | ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 484 | qv_av = REAL( fill_value, KIND = wp ) |
---|
| 485 | ENDIF |
---|
[1] | 486 | to_be_resorted => qv_av |
---|
| 487 | ENDIF |
---|
| 488 | |
---|
| 489 | CASE ( 's' ) |
---|
| 490 | IF ( av == 0 ) THEN |
---|
[1960] | 491 | to_be_resorted => s |
---|
[1] | 492 | ELSE |
---|
[3004] | 493 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
| 494 | ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 495 | s_av = REAL( fill_value, KIND = wp ) |
---|
| 496 | ENDIF |
---|
[355] | 497 | to_be_resorted => s_av |
---|
[1] | 498 | ENDIF |
---|
[691] | 499 | |
---|
[1] | 500 | CASE ( 'u' ) |
---|
[2696] | 501 | flag_nr = 1 |
---|
[1] | 502 | IF ( av == 0 ) THEN |
---|
| 503 | to_be_resorted => u |
---|
| 504 | ELSE |
---|
[3004] | 505 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
| 506 | ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 507 | u_av = REAL( fill_value, KIND = wp ) |
---|
| 508 | ENDIF |
---|
[1] | 509 | to_be_resorted => u_av |
---|
| 510 | ENDIF |
---|
| 511 | |
---|
| 512 | CASE ( 'v' ) |
---|
[2696] | 513 | flag_nr = 2 |
---|
[1] | 514 | IF ( av == 0 ) THEN |
---|
| 515 | to_be_resorted => v |
---|
| 516 | ELSE |
---|
[3004] | 517 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
| 518 | ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 519 | v_av = REAL( fill_value, KIND = wp ) |
---|
| 520 | ENDIF |
---|
[1] | 521 | to_be_resorted => v_av |
---|
| 522 | ENDIF |
---|
| 523 | |
---|
[3421] | 524 | CASE ( 'thetav' ) |
---|
[1] | 525 | IF ( av == 0 ) THEN |
---|
| 526 | to_be_resorted => vpt |
---|
| 527 | ELSE |
---|
[3004] | 528 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
| 529 | ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 530 | vpt_av = REAL( fill_value, KIND = wp ) |
---|
| 531 | ENDIF |
---|
[1] | 532 | to_be_resorted => vpt_av |
---|
| 533 | ENDIF |
---|
| 534 | |
---|
| 535 | CASE ( 'w' ) |
---|
[2696] | 536 | flag_nr = 3 |
---|
[1] | 537 | IF ( av == 0 ) THEN |
---|
| 538 | to_be_resorted => w |
---|
| 539 | ELSE |
---|
[3004] | 540 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
| 541 | ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 542 | w_av = REAL( fill_value, KIND = wp ) |
---|
| 543 | ENDIF |
---|
[1] | 544 | to_be_resorted => w_av |
---|
| 545 | ENDIF |
---|
| 546 | |
---|
| 547 | CASE DEFAULT |
---|
[3637] | 548 | ! |
---|
| 549 | !-- Quantities of other modules |
---|
| 550 | IF ( .NOT. found ) THEN |
---|
| 551 | CALL module_interface_data_output_3d( & |
---|
| 552 | av, trimvar, found, local_pf, & |
---|
| 553 | fill_value, resorted, nzb_do, nzt_do & |
---|
| 554 | ) |
---|
[3294] | 555 | ENDIF |
---|
| 556 | |
---|
[1972] | 557 | ! |
---|
[3637] | 558 | !-- Temporary workaround: ToDo: refactor local_pf allocation |
---|
| 559 | IF ( .NOT. found .AND. urban_surface .AND. trimvar(1:4) == 'usm_' ) THEN |
---|
| 560 | ! |
---|
| 561 | !-- For urban model quantities, it is required to re-allocate local_pf |
---|
[3814] | 562 | nzb_do = nz_urban_b |
---|
| 563 | nzt_do = nz_urban_t |
---|
[1972] | 564 | |
---|
| 565 | DEALLOCATE ( local_pf ) |
---|
[2512] | 566 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[2696] | 567 | local_pf = fill_value |
---|
[1972] | 568 | |
---|
[3637] | 569 | CALL usm_data_output_3d( av, trimvar, found, local_pf, & |
---|
| 570 | nzb_do, nzt_do ) |
---|
[1972] | 571 | resorted = .TRUE. |
---|
[1976] | 572 | |
---|
| 573 | ! |
---|
| 574 | !-- If no soil model variable was found, re-allocate local_pf |
---|
| 575 | IF ( .NOT. found ) THEN |
---|
| 576 | nzb_do = nzb |
---|
| 577 | nzt_do = nz_do3d |
---|
| 578 | |
---|
| 579 | DEALLOCATE ( local_pf ) |
---|
[3637] | 580 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[1976] | 581 | ENDIF |
---|
| 582 | |
---|
[1972] | 583 | ENDIF |
---|
| 584 | |
---|
[3637] | 585 | ! |
---|
| 586 | !-- Temporary workaround: ToDo: refactor local_pf allocation |
---|
| 587 | IF ( .NOT. found .AND. land_surface ) THEN |
---|
| 588 | ! |
---|
| 589 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 590 | nzb_do = nzb_soil |
---|
| 591 | nzt_do = nzt_soil |
---|
[1976] | 592 | |
---|
[3637] | 593 | DEALLOCATE ( local_pf ) |
---|
| 594 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
| 595 | local_pf = fill_value |
---|
[2817] | 596 | |
---|
[3637] | 597 | CALL lsm_data_output_3d( av, trimvar, found, local_pf ) |
---|
[2696] | 598 | resorted = .TRUE. |
---|
| 599 | |
---|
[3467] | 600 | ! |
---|
[3637] | 601 | !-- If no soil model variable was found, re-allocate local_pf |
---|
| 602 | IF ( .NOT. found ) THEN |
---|
| 603 | nzb_do = nzb |
---|
| 604 | nzt_do = nz_do3d |
---|
[2209] | 605 | |
---|
[3637] | 606 | DEALLOCATE ( local_pf ) |
---|
| 607 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
| 608 | ENDIF |
---|
[3448] | 609 | |
---|
[1972] | 610 | ENDIF |
---|
[1] | 611 | |
---|
[254] | 612 | IF ( .NOT. found ) THEN |
---|
[1320] | 613 | message_string = 'no output available for: ' // & |
---|
[3554] | 614 | TRIM( do3d(av,ivar) ) |
---|
[254] | 615 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
[1] | 616 | ENDIF |
---|
| 617 | |
---|
| 618 | END SELECT |
---|
| 619 | |
---|
| 620 | ! |
---|
| 621 | !-- Resort the array to be output, if not done above |
---|
| 622 | IF ( .NOT. resorted ) THEN |
---|
[2512] | 623 | DO i = nxl, nxr |
---|
| 624 | DO j = nys, nyn |
---|
[1551] | 625 | DO k = nzb_do, nzt_do |
---|
[2696] | 626 | local_pf(i,j,k) = MERGE( & |
---|
| 627 | to_be_resorted(k,j,i), & |
---|
| 628 | REAL( fill_value, KIND = wp ), & |
---|
[4346] | 629 | BTEST( wall_flags_total_0(k,j,i), flag_nr ) ) |
---|
[1] | 630 | ENDDO |
---|
| 631 | ENDDO |
---|
| 632 | ENDDO |
---|
| 633 | ENDIF |
---|
| 634 | |
---|
| 635 | ! |
---|
[1327] | 636 | !-- Output of the 3D-array |
---|
| 637 | #if defined( __parallel ) |
---|
| 638 | IF ( netcdf_data_format < 5 ) THEN |
---|
[1] | 639 | ! |
---|
[1327] | 640 | !-- Non-parallel netCDF output. Data is output in parallel in |
---|
| 641 | !-- FORTRAN binary format here, and later collected into one file by |
---|
| 642 | !-- combine_plot_fields |
---|
| 643 | IF ( myid == 0 ) THEN |
---|
| 644 | WRITE ( 30 ) time_since_reference_point, & |
---|
| 645 | do3d_time_count(av), av |
---|
[1] | 646 | ENDIF |
---|
[1327] | 647 | DO i = 0, io_blocks-1 |
---|
| 648 | IF ( i == io_group ) THEN |
---|
[2512] | 649 | WRITE ( 30 ) nxl, nxr, nys, nyn, nzb_do, nzt_do |
---|
[1551] | 650 | WRITE ( 30 ) local_pf(:,:,nzb_do:nzt_do) |
---|
[1327] | 651 | ENDIF |
---|
[1972] | 652 | |
---|
[1327] | 653 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1972] | 654 | |
---|
[1327] | 655 | ENDDO |
---|
[559] | 656 | |
---|
[1327] | 657 | ELSE |
---|
[646] | 658 | #if defined( __netcdf ) |
---|
[493] | 659 | ! |
---|
[1327] | 660 | !-- Parallel output in netCDF4/HDF5 format. |
---|
[2512] | 661 | ! IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
[3554] | 662 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar), & |
---|
[2512] | 663 | ! local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do), & |
---|
| 664 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 665 | ! count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
| 666 | ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
[3554] | 667 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar), & |
---|
[2512] | 668 | ! local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do), & |
---|
| 669 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 670 | ! count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
| 671 | ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
[3554] | 672 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar), & |
---|
[2512] | 673 | ! local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do ), & |
---|
| 674 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 675 | ! count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
| 676 | ! ELSE |
---|
[3554] | 677 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar), & |
---|
[1551] | 678 | local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do), & |
---|
| 679 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 680 | count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[2512] | 681 | ! ENDIF |
---|
[1783] | 682 | CALL netcdf_handle_error( 'data_output_3d', 386 ) |
---|
[646] | 683 | #endif |
---|
[1327] | 684 | ENDIF |
---|
[1] | 685 | #else |
---|
| 686 | #if defined( __netcdf ) |
---|
[3554] | 687 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar), & |
---|
[4155] | 688 | local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do), & |
---|
| 689 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
[4162] | 690 | count = (/ nx+1, ny+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1783] | 691 | CALL netcdf_handle_error( 'data_output_3d', 446 ) |
---|
[1] | 692 | #endif |
---|
| 693 | #endif |
---|
| 694 | |
---|
[3554] | 695 | ivar = ivar + 1 |
---|
[1] | 696 | |
---|
| 697 | ! |
---|
[1551] | 698 | !-- Deallocate temporary array |
---|
| 699 | DEALLOCATE ( local_pf ) |
---|
[1] | 700 | |
---|
[1551] | 701 | ENDDO |
---|
[1] | 702 | |
---|
[1318] | 703 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
[1] | 704 | |
---|
[3987] | 705 | IF ( debug_output_timestep ) CALL debug_message( 'data_output_3d', 'end' ) |
---|
[3885] | 706 | |
---|
[3987] | 707 | |
---|
[1] | 708 | END SUBROUTINE data_output_3d |
---|