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