[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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[1106] | 21 | ! ------------------ |
---|
[1961] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1552] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: data_output_3d.f90 3014 2018-05-09 08:42:38Z schwenkel $ |
---|
[3014] | 27 | ! Added nzb_do and nzt_do for some modules for 3d output |
---|
| 28 | ! |
---|
| 29 | ! 3004 2018-04-27 12:33:25Z Giersch |
---|
[3004] | 30 | ! Allocation checks implemented (averaged data will be assigned to fill values |
---|
| 31 | ! if no allocation happened so far) |
---|
| 32 | ! |
---|
| 33 | ! 2967 2018-04-13 11:22:08Z raasch |
---|
[2967] | 34 | ! bugfix: missing parallel cpp-directives added |
---|
| 35 | ! |
---|
| 36 | ! 2817 2018-02-19 16:32:21Z knoop |
---|
[2817] | 37 | ! Preliminary gust module interface implemented |
---|
| 38 | ! |
---|
| 39 | ! 2766 2018-01-22 17:17:47Z kanani |
---|
[2766] | 40 | ! Removed preprocessor directive __chem |
---|
| 41 | ! |
---|
| 42 | ! 2756 2018-01-16 18:11:14Z suehring |
---|
[2756] | 43 | ! Fill values for 3D output of chemical species introduced. |
---|
| 44 | ! |
---|
| 45 | ! 2746 2018-01-15 12:06:04Z suehring |
---|
[2746] | 46 | ! Move flag plant canopy to modules |
---|
| 47 | ! |
---|
| 48 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 49 | ! Corrected "Former revisions" section |
---|
| 50 | ! |
---|
| 51 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 52 | ! Change in file header (GPL part) |
---|
[2696] | 53 | ! Implementation of turbulence_closure_mod (TG) |
---|
| 54 | ! Implementation of chemistry module (FK) |
---|
| 55 | ! Set fill values at topography grid points or e.g. non-natural-type surface |
---|
| 56 | ! in case of LSM output (MS) |
---|
| 57 | ! |
---|
| 58 | ! 2512 2017-10-04 08:26:59Z raasch |
---|
[2512] | 59 | ! upper bounds of 3d output changed from nx+1,ny+1 to nx,ny |
---|
| 60 | ! no output of ghost layer data |
---|
| 61 | ! |
---|
| 62 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
[2292] | 63 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
| 64 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
| 65 | ! and cloud water content (qc). |
---|
| 66 | ! |
---|
| 67 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[1552] | 68 | ! |
---|
[2233] | 69 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 70 | ! Adjustments to new topography concept |
---|
| 71 | ! |
---|
[2210] | 72 | ! 2209 2017-04-19 09:34:46Z kanani |
---|
| 73 | ! Added plant canopy model output |
---|
| 74 | ! |
---|
[2032] | 75 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
| 76 | ! renamed variable rho to rho_ocean and rho_av to rho_ocean_av |
---|
| 77 | ! |
---|
[2012] | 78 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
| 79 | ! Flag urban_surface is now defined in module control_parameters, |
---|
| 80 | ! changed prefix for urban surface model output to "usm_", |
---|
| 81 | ! introduced control parameter varnamelength for LEN of trimvar. |
---|
| 82 | ! |
---|
[2008] | 83 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
| 84 | ! Added support for new urban surface model (temporary modifications of |
---|
| 85 | ! SELECT CASE ( ) necessary, see variable trimvar) |
---|
| 86 | ! |
---|
[2001] | 87 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 88 | ! Forced header and separation lines into 80 columns |
---|
| 89 | ! |
---|
[1981] | 90 | ! 1980 2016-07-29 15:51:57Z suehring |
---|
| 91 | ! Bugfix, in order to steer user-defined output, setting flag found explicitly |
---|
| 92 | ! to .F. |
---|
| 93 | ! |
---|
[1977] | 94 | ! 1976 2016-07-27 13:28:04Z maronga |
---|
| 95 | ! Output of radiation quantities is now done directly in the respective module |
---|
| 96 | ! |
---|
[1973] | 97 | ! 1972 2016-07-26 07:52:02Z maronga |
---|
| 98 | ! Output of land surface quantities is now done directly in the respective module. |
---|
| 99 | ! Unnecessary directive __parallel removed. |
---|
| 100 | ! |
---|
[1961] | 101 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
| 102 | ! Scalar surface flux added |
---|
| 103 | ! |
---|
[1851] | 104 | ! 1849 2016-04-08 11:33:18Z hoffmann |
---|
| 105 | ! prr moved to arrays_3d |
---|
| 106 | ! |
---|
[1823] | 107 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 108 | ! prr vertical dimensions set to nzb_do to nzt_do. Unused variables deleted. |
---|
| 109 | ! |
---|
[1809] | 110 | ! 1808 2016-04-05 19:44:00Z raasch |
---|
| 111 | ! test output removed |
---|
| 112 | ! |
---|
[1784] | 113 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 114 | ! name change of netcdf routines and module + related changes |
---|
| 115 | ! |
---|
[1746] | 116 | ! 1745 2016-02-05 13:06:51Z gronemeier |
---|
| 117 | ! Bugfix: test if time axis limit exceeds moved to point after call of check_open |
---|
| 118 | ! |
---|
[1692] | 119 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 120 | ! Added output of radiative heating rates for RRTMG |
---|
| 121 | ! |
---|
[1683] | 122 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 123 | ! Code annotations made doxygen readable |
---|
| 124 | ! |
---|
[1586] | 125 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
| 126 | ! Added support for RRTMG |
---|
| 127 | ! |
---|
[1552] | 128 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
[1551] | 129 | ! Added suppport for land surface model and radiation model output. In the course |
---|
| 130 | ! of this action, the limits for vertical loops have been changed (from nzb and |
---|
| 131 | ! nzt+1 to nzb_do and nzt_do, respectively in order to allow soil model output). |
---|
| 132 | ! Moreover, a new vertical grid zs was introduced. |
---|
[1329] | 133 | ! |
---|
[1360] | 134 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 135 | ! New particle structure integrated. |
---|
| 136 | ! |
---|
[1354] | 137 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 138 | ! REAL constants provided with KIND-attribute |
---|
| 139 | ! |
---|
[1329] | 140 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
| 141 | ! parts concerning avs output removed, |
---|
| 142 | ! -netcdf output queries |
---|
| 143 | ! |
---|
[1321] | 144 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 145 | ! ONLY-attribute added to USE-statements, |
---|
| 146 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 147 | ! kinds are defined in new module kinds, |
---|
| 148 | ! old module precision_kind is removed, |
---|
| 149 | ! revision history before 2012 removed, |
---|
| 150 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 151 | ! all variable declaration statements |
---|
[674] | 152 | ! |
---|
[1319] | 153 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 154 | ! barrier argument removed from cpu_log, |
---|
| 155 | ! module interfaces removed |
---|
| 156 | ! |
---|
[1309] | 157 | ! 1308 2014-03-13 14:58:42Z fricke |
---|
| 158 | ! Check, if the limit of the time dimension is exceeded for parallel output |
---|
| 159 | ! To increase the performance for parallel output, the following is done: |
---|
| 160 | ! - Update of time axis is only done by PE0 |
---|
| 161 | ! |
---|
[1245] | 162 | ! 1244 2013-10-31 08:16:56Z raasch |
---|
| 163 | ! Bugfix for index bounds in case of 3d-parallel output |
---|
| 164 | ! |
---|
[1116] | 165 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 166 | ! ql is calculated by calc_liquid_water_content |
---|
| 167 | ! |
---|
[1107] | 168 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
| 169 | ! array_kind renamed precision_kind |
---|
| 170 | ! |
---|
[1077] | 171 | ! 1076 2012-12-05 08:30:18Z hoffmann |
---|
| 172 | ! Bugfix in output of ql |
---|
| 173 | ! |
---|
[1054] | 174 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 175 | ! +nr, qr, prr, qc and averaged quantities |
---|
| 176 | ! |
---|
[1037] | 177 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 178 | ! code put under GPL (PALM 3.9) |
---|
| 179 | ! |
---|
[1035] | 180 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
| 181 | ! netCDF4 without parallel file support implemented |
---|
| 182 | ! |
---|
[1008] | 183 | ! 1007 2012-09-19 14:30:36Z franke |
---|
| 184 | ! Bugfix: missing calculation of ql_vp added |
---|
| 185 | ! |
---|
[1] | 186 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
| 187 | ! Initial revision |
---|
| 188 | ! |
---|
| 189 | ! |
---|
| 190 | ! Description: |
---|
| 191 | ! ------------ |
---|
[1682] | 192 | !> Output of the 3D-arrays in netCDF and/or AVS format. |
---|
[1] | 193 | !------------------------------------------------------------------------------! |
---|
[1682] | 194 | SUBROUTINE data_output_3d( av ) |
---|
| 195 | |
---|
[1] | 196 | |
---|
[1320] | 197 | USE arrays_3d, & |
---|
[2292] | 198 | ONLY: e, nc, nr, p, pt, prr, q, qc, ql, ql_c, ql_v, qr, rho_ocean, s, & |
---|
| 199 | sa, tend, u, v, vpt, w |
---|
[1320] | 200 | |
---|
[1] | 201 | USE averaging |
---|
[1320] | 202 | |
---|
[2696] | 203 | USE chemistry_model_mod, & |
---|
| 204 | ONLY: chem_data_output_3d |
---|
| 205 | |
---|
[1320] | 206 | USE cloud_parameters, & |
---|
[1849] | 207 | ONLY: l_d_cp, pt_d_t |
---|
[1320] | 208 | |
---|
| 209 | USE control_parameters, & |
---|
[2696] | 210 | ONLY: air_chemistry, cloud_physics, do3d, do3d_no, do3d_time_count, & |
---|
| 211 | io_blocks, io_group, land_surface, message_string, & |
---|
[2746] | 212 | ntdim_3d, nz_do3d, plant_canopy, & |
---|
[2232] | 213 | psolver, simulated_time, time_since_reference_point, & |
---|
| 214 | urban_surface, varnamelength |
---|
[1320] | 215 | |
---|
| 216 | USE cpulog, & |
---|
| 217 | ONLY: log_point, cpu_log |
---|
[2817] | 218 | |
---|
| 219 | USE gust_mod, & |
---|
| 220 | ONLY: gust_data_output_3d, gust_module_enabled |
---|
[1320] | 221 | |
---|
| 222 | USE indices, & |
---|
[3004] | 223 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, & |
---|
| 224 | nzt, wall_flags_0 |
---|
[1320] | 225 | |
---|
| 226 | USE kinds |
---|
| 227 | |
---|
[1551] | 228 | USE land_surface_model_mod, & |
---|
[2232] | 229 | ONLY: lsm_data_output_3d, nzb_soil, nzt_soil |
---|
[1551] | 230 | |
---|
[1783] | 231 | #if defined( __netcdf ) |
---|
| 232 | USE NETCDF |
---|
| 233 | #endif |
---|
| 234 | |
---|
| 235 | USE netcdf_interface, & |
---|
[2696] | 236 | ONLY: fill_value, id_set_3d, id_var_do3d, id_var_time_3d, nc_stat, & |
---|
[1783] | 237 | netcdf_data_format, netcdf_handle_error |
---|
[1320] | 238 | |
---|
| 239 | USE particle_attributes, & |
---|
[1359] | 240 | ONLY: grid_particles, number_of_particles, particles, & |
---|
| 241 | particle_advection_start, prt_count |
---|
[1320] | 242 | |
---|
[1] | 243 | USE pegrid |
---|
| 244 | |
---|
[2209] | 245 | USE plant_canopy_model_mod, & |
---|
[2746] | 246 | ONLY: pcm_data_output_3d |
---|
[2209] | 247 | |
---|
[1585] | 248 | USE radiation_model_mod, & |
---|
[2696] | 249 | ONLY: nzub, nzut, radiation, radiation_data_output_3d |
---|
[1585] | 250 | |
---|
[2696] | 251 | USE turbulence_closure_mod, & |
---|
| 252 | ONLY: tcm_data_output_3d |
---|
| 253 | |
---|
[2007] | 254 | USE urban_surface_mod, & |
---|
[2696] | 255 | ONLY: usm_data_output_3d |
---|
[1585] | 256 | |
---|
[2007] | 257 | |
---|
[1] | 258 | IMPLICIT NONE |
---|
| 259 | |
---|
[1682] | 260 | INTEGER(iwp) :: av !< |
---|
[2696] | 261 | INTEGER(iwp) :: flag_nr !< number of masking flag |
---|
[1682] | 262 | INTEGER(iwp) :: i !< |
---|
| 263 | INTEGER(iwp) :: if !< |
---|
| 264 | INTEGER(iwp) :: j !< |
---|
| 265 | INTEGER(iwp) :: k !< |
---|
| 266 | INTEGER(iwp) :: n !< |
---|
| 267 | INTEGER(iwp) :: nzb_do !< vertical lower limit for data output |
---|
| 268 | INTEGER(iwp) :: nzt_do !< vertical upper limit for data output |
---|
[1] | 269 | |
---|
[1682] | 270 | LOGICAL :: found !< |
---|
| 271 | LOGICAL :: resorted !< |
---|
[1] | 272 | |
---|
[1682] | 273 | REAL(wp) :: mean_r !< |
---|
| 274 | REAL(wp) :: s_r2 !< |
---|
| 275 | REAL(wp) :: s_r3 !< |
---|
[1] | 276 | |
---|
[1682] | 277 | REAL(sp), DIMENSION(:,:,:), ALLOCATABLE :: local_pf !< |
---|
[1] | 278 | |
---|
[1682] | 279 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< |
---|
[1] | 280 | |
---|
[2011] | 281 | CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string |
---|
[2007] | 282 | |
---|
[1] | 283 | ! |
---|
| 284 | !-- Return, if nothing to output |
---|
| 285 | IF ( do3d_no(av) == 0 ) RETURN |
---|
| 286 | |
---|
| 287 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
| 288 | |
---|
| 289 | ! |
---|
| 290 | !-- Open output file. |
---|
[2512] | 291 | !-- For classic or 64bit netCDF output on more than one PE, each PE opens its |
---|
| 292 | !-- own file and writes the data of its subdomain in binary format. After the |
---|
| 293 | !-- run, these files are combined to one NetCDF file by combine_plot_fields. |
---|
[1031] | 294 | !-- For netCDF4/HDF5 output, data is written in parallel into one file. |
---|
[1327] | 295 | IF ( netcdf_data_format < 5 ) THEN |
---|
[2967] | 296 | #if defined( __parallel ) |
---|
[1327] | 297 | CALL check_open( 30 ) |
---|
[2967] | 298 | #endif |
---|
[1327] | 299 | IF ( myid == 0 ) CALL check_open( 106+av*10 ) |
---|
[493] | 300 | ELSE |
---|
[1327] | 301 | CALL check_open( 106+av*10 ) |
---|
[493] | 302 | ENDIF |
---|
[1] | 303 | |
---|
| 304 | ! |
---|
[1745] | 305 | !-- For parallel netcdf output the time axis must be limited. Return, if this |
---|
| 306 | !-- limit is exceeded. This could be the case, if the simulated time exceeds |
---|
| 307 | !-- the given end time by the length of the given output interval. |
---|
| 308 | IF ( netcdf_data_format > 4 ) THEN |
---|
| 309 | IF ( do3d_time_count(av) + 1 > ntdim_3d(av) ) THEN |
---|
| 310 | WRITE ( message_string, * ) 'Output of 3d data is not given at t=', & |
---|
| 311 | simulated_time, '&because the maximum ', & |
---|
| 312 | 'number of output time levels is ', & |
---|
| 313 | 'exceeded.' |
---|
| 314 | CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 ) |
---|
| 315 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
| 316 | RETURN |
---|
| 317 | ENDIF |
---|
| 318 | ENDIF |
---|
| 319 | |
---|
| 320 | ! |
---|
[1031] | 321 | !-- Update the netCDF time axis |
---|
[1308] | 322 | !-- In case of parallel output, this is only done by PE0 to increase the |
---|
| 323 | !-- performance. |
---|
[1] | 324 | #if defined( __netcdf ) |
---|
[1308] | 325 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
| 326 | IF ( myid == 0 ) THEN |
---|
[1327] | 327 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
| 328 | (/ time_since_reference_point /), & |
---|
| 329 | start = (/ do3d_time_count(av) /), & |
---|
| 330 | count = (/ 1 /) ) |
---|
[1783] | 331 | CALL netcdf_handle_error( 'data_output_3d', 376 ) |
---|
[1] | 332 | ENDIF |
---|
| 333 | #endif |
---|
| 334 | |
---|
| 335 | ! |
---|
| 336 | !-- Loop over all variables to be written. |
---|
| 337 | if = 1 |
---|
| 338 | |
---|
| 339 | DO WHILE ( do3d(av,if)(1:1) /= ' ' ) |
---|
[2007] | 340 | |
---|
[1] | 341 | ! |
---|
[2007] | 342 | !-- Temporary solution to account for data output within the new urban |
---|
| 343 | !-- surface model (urban_surface_mod.f90), see also SELECT CASE ( trimvar ). |
---|
[1] | 344 | !-- Store the array chosen on the temporary array. |
---|
[2007] | 345 | trimvar = TRIM( do3d(av,if) ) |
---|
[2011] | 346 | IF ( urban_surface .AND. trimvar(1:4) == 'usm_' ) THEN |
---|
[2007] | 347 | trimvar = 'usm_output' |
---|
| 348 | resorted = .TRUE. |
---|
| 349 | nzb_do = nzub |
---|
| 350 | nzt_do = nzut |
---|
| 351 | ELSE |
---|
| 352 | resorted = .FALSE. |
---|
| 353 | nzb_do = nzb |
---|
| 354 | nzt_do = nz_do3d |
---|
| 355 | ENDIF |
---|
[1551] | 356 | ! |
---|
[1980] | 357 | !-- Set flag to steer output of radiation, land-surface, or user-defined |
---|
| 358 | !-- quantities |
---|
| 359 | found = .FALSE. |
---|
| 360 | ! |
---|
[1551] | 361 | !-- Allocate a temporary array with the desired output dimensions. |
---|
[2512] | 362 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[2696] | 363 | ! |
---|
| 364 | !-- Before each output, set array local_pf to fill value |
---|
| 365 | local_pf = fill_value |
---|
| 366 | ! |
---|
| 367 | !-- Set masking flag for topography for not resorted arrays |
---|
| 368 | flag_nr = 0 |
---|
[1551] | 369 | |
---|
[2007] | 370 | SELECT CASE ( trimvar ) |
---|
[1] | 371 | |
---|
| 372 | CASE ( 'e' ) |
---|
| 373 | IF ( av == 0 ) THEN |
---|
| 374 | to_be_resorted => e |
---|
| 375 | ELSE |
---|
[3004] | 376 | IF ( .NOT. ALLOCATED( e_av ) ) THEN |
---|
| 377 | ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 378 | e_av = REAL( fill_value, KIND = wp ) |
---|
| 379 | ENDIF |
---|
[1] | 380 | to_be_resorted => e_av |
---|
| 381 | ENDIF |
---|
| 382 | |
---|
[771] | 383 | CASE ( 'lpt' ) |
---|
| 384 | IF ( av == 0 ) THEN |
---|
| 385 | to_be_resorted => pt |
---|
| 386 | ELSE |
---|
[3004] | 387 | IF ( .NOT. ALLOCATED( lpt_av ) ) THEN |
---|
| 388 | ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 389 | lpt_av = REAL( fill_value, KIND = wp ) |
---|
| 390 | ENDIF |
---|
[771] | 391 | to_be_resorted => lpt_av |
---|
| 392 | ENDIF |
---|
| 393 | |
---|
[2292] | 394 | CASE ( 'nc' ) |
---|
| 395 | IF ( av == 0 ) THEN |
---|
| 396 | to_be_resorted => nc |
---|
| 397 | ELSE |
---|
[3004] | 398 | IF ( .NOT. ALLOCATED( nc_av ) ) THEN |
---|
| 399 | ALLOCATE( nc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 400 | nc_av = REAL( fill_value, KIND = wp ) |
---|
| 401 | ENDIF |
---|
[2292] | 402 | to_be_resorted => nc_av |
---|
| 403 | ENDIF |
---|
| 404 | |
---|
[1053] | 405 | CASE ( 'nr' ) |
---|
| 406 | IF ( av == 0 ) THEN |
---|
| 407 | to_be_resorted => nr |
---|
| 408 | ELSE |
---|
[3004] | 409 | IF ( .NOT. ALLOCATED( nr_av ) ) THEN |
---|
| 410 | ALLOCATE( nr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 411 | nr_av = REAL( fill_value, KIND = wp ) |
---|
| 412 | ENDIF |
---|
[1053] | 413 | to_be_resorted => nr_av |
---|
| 414 | ENDIF |
---|
| 415 | |
---|
[1] | 416 | CASE ( 'p' ) |
---|
| 417 | IF ( av == 0 ) THEN |
---|
[727] | 418 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p, nbgp ) |
---|
[1] | 419 | to_be_resorted => p |
---|
| 420 | ELSE |
---|
[3004] | 421 | IF ( .NOT. ALLOCATED( p_av ) ) THEN |
---|
| 422 | ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 423 | p_av = REAL( fill_value, KIND = wp ) |
---|
| 424 | ENDIF |
---|
[727] | 425 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p_av, nbgp ) |
---|
[1] | 426 | to_be_resorted => p_av |
---|
| 427 | ENDIF |
---|
| 428 | |
---|
| 429 | CASE ( 'pc' ) ! particle concentration (requires ghostpoint exchange) |
---|
| 430 | IF ( av == 0 ) THEN |
---|
[1359] | 431 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 432 | tend = prt_count |
---|
| 433 | ELSE |
---|
| 434 | tend = 0.0_wp |
---|
| 435 | ENDIF |
---|
[2512] | 436 | DO i = nxl, nxr |
---|
| 437 | DO j = nys, nyn |
---|
[1551] | 438 | DO k = nzb_do, nzt_do |
---|
[1] | 439 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 440 | ENDDO |
---|
| 441 | ENDDO |
---|
| 442 | ENDDO |
---|
| 443 | resorted = .TRUE. |
---|
| 444 | ELSE |
---|
[3004] | 445 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
| 446 | ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 447 | pc_av = REAL( fill_value, KIND = wp ) |
---|
| 448 | ENDIF |
---|
[1] | 449 | to_be_resorted => pc_av |
---|
| 450 | ENDIF |
---|
| 451 | |
---|
[1359] | 452 | CASE ( 'pr' ) ! mean particle radius (effective radius) |
---|
[1] | 453 | IF ( av == 0 ) THEN |
---|
[1359] | 454 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 455 | DO i = nxl, nxr |
---|
| 456 | DO j = nys, nyn |
---|
[1551] | 457 | DO k = nzb_do, nzt_do |
---|
[1359] | 458 | number_of_particles = prt_count(k,j,i) |
---|
| 459 | IF (number_of_particles <= 0) CYCLE |
---|
| 460 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 461 | s_r2 = 0.0_wp |
---|
| 462 | s_r3 = 0.0_wp |
---|
| 463 | DO n = 1, number_of_particles |
---|
| 464 | IF ( particles(n)%particle_mask ) THEN |
---|
| 465 | s_r2 = s_r2 + particles(n)%radius**2 * & |
---|
| 466 | particles(n)%weight_factor |
---|
| 467 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
| 468 | particles(n)%weight_factor |
---|
| 469 | ENDIF |
---|
| 470 | ENDDO |
---|
| 471 | IF ( s_r2 > 0.0_wp ) THEN |
---|
| 472 | mean_r = s_r3 / s_r2 |
---|
| 473 | ELSE |
---|
| 474 | mean_r = 0.0_wp |
---|
| 475 | ENDIF |
---|
| 476 | tend(k,j,i) = mean_r |
---|
[1] | 477 | ENDDO |
---|
| 478 | ENDDO |
---|
| 479 | ENDDO |
---|
[1359] | 480 | ELSE |
---|
| 481 | tend = 0.0_wp |
---|
| 482 | ENDIF |
---|
[2512] | 483 | DO i = nxl, nxr |
---|
| 484 | DO j = nys, nyn |
---|
[1551] | 485 | DO k = nzb_do, nzt_do |
---|
[1] | 486 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 487 | ENDDO |
---|
| 488 | ENDDO |
---|
| 489 | ENDDO |
---|
| 490 | resorted = .TRUE. |
---|
| 491 | ELSE |
---|
[3004] | 492 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
| 493 | ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 494 | pr_av = REAL( fill_value, KIND = wp ) |
---|
| 495 | ENDIF |
---|
[1] | 496 | to_be_resorted => pr_av |
---|
| 497 | ENDIF |
---|
| 498 | |
---|
[1053] | 499 | CASE ( 'prr' ) |
---|
| 500 | IF ( av == 0 ) THEN |
---|
[2512] | 501 | DO i = nxl, nxr |
---|
| 502 | DO j = nys, nyn |
---|
[1822] | 503 | DO k = nzb_do, nzt_do |
---|
[1053] | 504 | local_pf(i,j,k) = prr(k,j,i) |
---|
| 505 | ENDDO |
---|
| 506 | ENDDO |
---|
| 507 | ENDDO |
---|
| 508 | ELSE |
---|
[3004] | 509 | IF ( .NOT. ALLOCATED( prr_av ) ) THEN |
---|
| 510 | ALLOCATE( prr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 511 | prr_av = REAL( fill_value, KIND = wp ) |
---|
| 512 | ENDIF |
---|
[2512] | 513 | DO i = nxl, nxr |
---|
| 514 | DO j = nys, nyn |
---|
[1822] | 515 | DO k = nzb_do, nzt_do |
---|
[1053] | 516 | local_pf(i,j,k) = prr_av(k,j,i) |
---|
| 517 | ENDDO |
---|
| 518 | ENDDO |
---|
| 519 | ENDDO |
---|
| 520 | ENDIF |
---|
| 521 | resorted = .TRUE. |
---|
| 522 | |
---|
[1] | 523 | CASE ( 'pt' ) |
---|
| 524 | IF ( av == 0 ) THEN |
---|
| 525 | IF ( .NOT. cloud_physics ) THEN |
---|
| 526 | to_be_resorted => pt |
---|
| 527 | ELSE |
---|
[2512] | 528 | DO i = nxl, nxr |
---|
| 529 | DO j = nys, nyn |
---|
[1551] | 530 | DO k = nzb_do, nzt_do |
---|
[1320] | 531 | local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & |
---|
| 532 | pt_d_t(k) * & |
---|
[1] | 533 | ql(k,j,i) |
---|
| 534 | ENDDO |
---|
| 535 | ENDDO |
---|
| 536 | ENDDO |
---|
| 537 | resorted = .TRUE. |
---|
| 538 | ENDIF |
---|
| 539 | ELSE |
---|
[3004] | 540 | IF ( .NOT. ALLOCATED( pt_av ) ) THEN |
---|
| 541 | ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 542 | pt_av = REAL( fill_value, KIND = wp ) |
---|
| 543 | ENDIF |
---|
[1] | 544 | to_be_resorted => pt_av |
---|
| 545 | ENDIF |
---|
| 546 | |
---|
| 547 | CASE ( 'q' ) |
---|
| 548 | IF ( av == 0 ) THEN |
---|
| 549 | to_be_resorted => q |
---|
| 550 | ELSE |
---|
[3004] | 551 | IF ( .NOT. ALLOCATED( q_av ) ) THEN |
---|
| 552 | ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 553 | q_av = REAL( fill_value, KIND = wp ) |
---|
| 554 | ENDIF |
---|
[1] | 555 | to_be_resorted => q_av |
---|
| 556 | ENDIF |
---|
[691] | 557 | |
---|
[1053] | 558 | CASE ( 'qc' ) |
---|
[1] | 559 | IF ( av == 0 ) THEN |
---|
[1115] | 560 | to_be_resorted => qc |
---|
[1] | 561 | ELSE |
---|
[3004] | 562 | IF ( .NOT. ALLOCATED( qc_av ) ) THEN |
---|
| 563 | ALLOCATE( qc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 564 | qc_av = REAL( fill_value, KIND = wp ) |
---|
| 565 | ENDIF |
---|
[1115] | 566 | to_be_resorted => qc_av |
---|
[1] | 567 | ENDIF |
---|
| 568 | |
---|
[1053] | 569 | CASE ( 'ql' ) |
---|
| 570 | IF ( av == 0 ) THEN |
---|
[1115] | 571 | to_be_resorted => ql |
---|
[1053] | 572 | ELSE |
---|
[3004] | 573 | IF ( .NOT. ALLOCATED( ql_av ) ) THEN |
---|
| 574 | ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 575 | ql_av = REAL( fill_value, KIND = wp ) |
---|
| 576 | ENDIF |
---|
[1115] | 577 | to_be_resorted => ql_av |
---|
[1053] | 578 | ENDIF |
---|
| 579 | |
---|
[1] | 580 | CASE ( 'ql_c' ) |
---|
| 581 | IF ( av == 0 ) THEN |
---|
| 582 | to_be_resorted => ql_c |
---|
| 583 | ELSE |
---|
[3004] | 584 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
| 585 | ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 586 | ql_c_av = REAL( fill_value, KIND = wp ) |
---|
| 587 | ENDIF |
---|
[1] | 588 | to_be_resorted => ql_c_av |
---|
| 589 | ENDIF |
---|
| 590 | |
---|
| 591 | CASE ( 'ql_v' ) |
---|
| 592 | IF ( av == 0 ) THEN |
---|
| 593 | to_be_resorted => ql_v |
---|
| 594 | ELSE |
---|
[3004] | 595 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
| 596 | ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 597 | ql_v_av = REAL( fill_value, KIND = wp ) |
---|
| 598 | ENDIF |
---|
[1] | 599 | to_be_resorted => ql_v_av |
---|
| 600 | ENDIF |
---|
| 601 | |
---|
| 602 | CASE ( 'ql_vp' ) |
---|
| 603 | IF ( av == 0 ) THEN |
---|
[1359] | 604 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
| 605 | DO i = nxl, nxr |
---|
| 606 | DO j = nys, nyn |
---|
[1551] | 607 | DO k = nzb_do, nzt_do |
---|
[1359] | 608 | number_of_particles = prt_count(k,j,i) |
---|
| 609 | IF (number_of_particles <= 0) CYCLE |
---|
| 610 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
| 611 | DO n = 1, number_of_particles |
---|
| 612 | IF ( particles(n)%particle_mask ) THEN |
---|
| 613 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 614 | particles(n)%weight_factor / & |
---|
| 615 | prt_count(k,j,i) |
---|
| 616 | ENDIF |
---|
| 617 | ENDDO |
---|
[1007] | 618 | ENDDO |
---|
| 619 | ENDDO |
---|
| 620 | ENDDO |
---|
[1359] | 621 | ELSE |
---|
| 622 | tend = 0.0_wp |
---|
| 623 | ENDIF |
---|
[2512] | 624 | DO i = nxl, nxr |
---|
| 625 | DO j = nys, nyn |
---|
[1551] | 626 | DO k = nzb_do, nzt_do |
---|
[1007] | 627 | local_pf(i,j,k) = tend(k,j,i) |
---|
| 628 | ENDDO |
---|
| 629 | ENDDO |
---|
| 630 | ENDDO |
---|
| 631 | resorted = .TRUE. |
---|
[1] | 632 | ELSE |
---|
[3004] | 633 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
| 634 | ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 635 | ql_vp_av = REAL( fill_value, KIND = wp ) |
---|
| 636 | ENDIF |
---|
[1] | 637 | to_be_resorted => ql_vp_av |
---|
| 638 | ENDIF |
---|
| 639 | |
---|
[1053] | 640 | CASE ( 'qr' ) |
---|
| 641 | IF ( av == 0 ) THEN |
---|
| 642 | to_be_resorted => qr |
---|
| 643 | ELSE |
---|
[3004] | 644 | IF ( .NOT. ALLOCATED( qr_av ) ) THEN |
---|
| 645 | ALLOCATE( qr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 646 | qr_av = REAL( fill_value, KIND = wp ) |
---|
| 647 | ENDIF |
---|
[1053] | 648 | to_be_resorted => qr_av |
---|
| 649 | ENDIF |
---|
| 650 | |
---|
[1] | 651 | CASE ( 'qv' ) |
---|
| 652 | IF ( av == 0 ) THEN |
---|
[2512] | 653 | DO i = nxl, nxr |
---|
| 654 | DO j = nys, nyn |
---|
[1551] | 655 | DO k = nzb_do, nzt_do |
---|
[1] | 656 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
| 657 | ENDDO |
---|
| 658 | ENDDO |
---|
| 659 | ENDDO |
---|
| 660 | resorted = .TRUE. |
---|
| 661 | ELSE |
---|
[3004] | 662 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
| 663 | ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 664 | qv_av = REAL( fill_value, KIND = wp ) |
---|
| 665 | ENDIF |
---|
[1] | 666 | to_be_resorted => qv_av |
---|
| 667 | ENDIF |
---|
| 668 | |
---|
[2031] | 669 | CASE ( 'rho_ocean' ) |
---|
[96] | 670 | IF ( av == 0 ) THEN |
---|
[2031] | 671 | to_be_resorted => rho_ocean |
---|
[96] | 672 | ELSE |
---|
[3004] | 673 | IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN |
---|
| 674 | ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 675 | u_av = REAL( fill_value, KIND = wp ) |
---|
| 676 | ENDIF |
---|
[2031] | 677 | to_be_resorted => rho_ocean_av |
---|
[96] | 678 | ENDIF |
---|
[691] | 679 | |
---|
[1] | 680 | CASE ( 's' ) |
---|
| 681 | IF ( av == 0 ) THEN |
---|
[1960] | 682 | to_be_resorted => s |
---|
[1] | 683 | ELSE |
---|
[3004] | 684 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
| 685 | ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 686 | s_av = REAL( fill_value, KIND = wp ) |
---|
| 687 | ENDIF |
---|
[355] | 688 | to_be_resorted => s_av |
---|
[1] | 689 | ENDIF |
---|
[691] | 690 | |
---|
[96] | 691 | CASE ( 'sa' ) |
---|
| 692 | IF ( av == 0 ) THEN |
---|
| 693 | to_be_resorted => sa |
---|
| 694 | ELSE |
---|
[3004] | 695 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
| 696 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 697 | sa_av = REAL( fill_value, KIND = wp ) |
---|
| 698 | ENDIF |
---|
[96] | 699 | to_be_resorted => sa_av |
---|
| 700 | ENDIF |
---|
[691] | 701 | |
---|
[1] | 702 | CASE ( 'u' ) |
---|
[2696] | 703 | flag_nr = 1 |
---|
[1] | 704 | IF ( av == 0 ) THEN |
---|
| 705 | to_be_resorted => u |
---|
| 706 | ELSE |
---|
[3004] | 707 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
| 708 | ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 709 | u_av = REAL( fill_value, KIND = wp ) |
---|
| 710 | ENDIF |
---|
[1] | 711 | to_be_resorted => u_av |
---|
| 712 | ENDIF |
---|
| 713 | |
---|
| 714 | CASE ( 'v' ) |
---|
[2696] | 715 | flag_nr = 2 |
---|
[1] | 716 | IF ( av == 0 ) THEN |
---|
| 717 | to_be_resorted => v |
---|
| 718 | ELSE |
---|
[3004] | 719 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
| 720 | ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 721 | v_av = REAL( fill_value, KIND = wp ) |
---|
| 722 | ENDIF |
---|
[1] | 723 | to_be_resorted => v_av |
---|
| 724 | ENDIF |
---|
| 725 | |
---|
| 726 | CASE ( 'vpt' ) |
---|
| 727 | IF ( av == 0 ) THEN |
---|
| 728 | to_be_resorted => vpt |
---|
| 729 | ELSE |
---|
[3004] | 730 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
| 731 | ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 732 | vpt_av = REAL( fill_value, KIND = wp ) |
---|
| 733 | ENDIF |
---|
[1] | 734 | to_be_resorted => vpt_av |
---|
| 735 | ENDIF |
---|
| 736 | |
---|
| 737 | CASE ( 'w' ) |
---|
[2696] | 738 | flag_nr = 3 |
---|
[1] | 739 | IF ( av == 0 ) THEN |
---|
| 740 | to_be_resorted => w |
---|
| 741 | ELSE |
---|
[3004] | 742 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
| 743 | ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 744 | w_av = REAL( fill_value, KIND = wp ) |
---|
| 745 | ENDIF |
---|
[1] | 746 | to_be_resorted => w_av |
---|
| 747 | ENDIF |
---|
[2007] | 748 | ! |
---|
| 749 | !-- Block of urban surface model outputs |
---|
| 750 | CASE ( 'usm_output' ) |
---|
| 751 | CALL usm_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
| 752 | nzb_do, nzt_do ) |
---|
[1] | 753 | |
---|
| 754 | CASE DEFAULT |
---|
[1972] | 755 | |
---|
[1] | 756 | ! |
---|
[1972] | 757 | !-- Land surface quantity |
---|
| 758 | IF ( land_surface ) THEN |
---|
| 759 | ! |
---|
| 760 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 761 | nzb_do = nzb_soil |
---|
| 762 | nzt_do = nzt_soil |
---|
| 763 | |
---|
| 764 | DEALLOCATE ( local_pf ) |
---|
[2512] | 765 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[2696] | 766 | local_pf = fill_value |
---|
[1972] | 767 | |
---|
| 768 | CALL lsm_data_output_3d( av, do3d(av,if), found, local_pf ) |
---|
| 769 | resorted = .TRUE. |
---|
[1976] | 770 | |
---|
| 771 | ! |
---|
| 772 | !-- If no soil model variable was found, re-allocate local_pf |
---|
| 773 | IF ( .NOT. found ) THEN |
---|
| 774 | nzb_do = nzb |
---|
| 775 | nzt_do = nz_do3d |
---|
| 776 | |
---|
| 777 | DEALLOCATE ( local_pf ) |
---|
[2512] | 778 | ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) ) |
---|
[1976] | 779 | ENDIF |
---|
| 780 | |
---|
[1972] | 781 | ENDIF |
---|
| 782 | |
---|
[2696] | 783 | IF ( .NOT. found ) THEN |
---|
[3014] | 784 | CALL tcm_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
| 785 | nzb_do, nzt_do ) |
---|
[2696] | 786 | resorted = .TRUE. |
---|
| 787 | ENDIF |
---|
| 788 | |
---|
[1972] | 789 | ! |
---|
[1976] | 790 | !-- Radiation quantity |
---|
| 791 | IF ( .NOT. found .AND. radiation ) THEN |
---|
| 792 | CALL radiation_data_output_3d( av, do3d(av,if), found, & |
---|
[3014] | 793 | local_pf, nzb_do, nzt_do ) |
---|
[1976] | 794 | resorted = .TRUE. |
---|
| 795 | ENDIF |
---|
| 796 | |
---|
| 797 | ! |
---|
[2817] | 798 | !-- Gust module quantities |
---|
| 799 | IF ( .NOT. found .AND. gust_module_enabled ) THEN |
---|
| 800 | CALL gust_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
| 801 | nzb_do, nzt_do ) |
---|
| 802 | resorted = .TRUE. |
---|
| 803 | ENDIF |
---|
| 804 | |
---|
| 805 | ! |
---|
[2696] | 806 | !-- Chemistry model output |
---|
| 807 | IF ( .NOT. found .AND. air_chemistry ) THEN |
---|
| 808 | CALL chem_data_output_3d( av, do3d(av,if), found, & |
---|
[3014] | 809 | local_pf, fill_value, nzb_do, nzt_do ) |
---|
[2696] | 810 | resorted = .TRUE. |
---|
| 811 | ENDIF |
---|
| 812 | |
---|
| 813 | ! |
---|
[2209] | 814 | !-- Plant canopy model output |
---|
| 815 | IF ( .NOT. found .AND. plant_canopy ) THEN |
---|
[2696] | 816 | CALL pcm_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
[3014] | 817 | fill_value, nzb_do, nzt_do ) |
---|
[2209] | 818 | resorted = .TRUE. |
---|
| 819 | ENDIF |
---|
| 820 | |
---|
| 821 | ! |
---|
[1] | 822 | !-- User defined quantity |
---|
[1972] | 823 | IF ( .NOT. found ) THEN |
---|
| 824 | CALL user_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
| 825 | nzb_do, nzt_do ) |
---|
| 826 | resorted = .TRUE. |
---|
| 827 | ENDIF |
---|
[1] | 828 | |
---|
[254] | 829 | IF ( .NOT. found ) THEN |
---|
[1320] | 830 | message_string = 'no output available for: ' // & |
---|
[274] | 831 | TRIM( do3d(av,if) ) |
---|
[254] | 832 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
[1] | 833 | ENDIF |
---|
| 834 | |
---|
| 835 | END SELECT |
---|
| 836 | |
---|
| 837 | ! |
---|
| 838 | !-- Resort the array to be output, if not done above |
---|
| 839 | IF ( .NOT. resorted ) THEN |
---|
[2512] | 840 | DO i = nxl, nxr |
---|
| 841 | DO j = nys, nyn |
---|
[1551] | 842 | DO k = nzb_do, nzt_do |
---|
[2696] | 843 | local_pf(i,j,k) = MERGE( & |
---|
| 844 | to_be_resorted(k,j,i), & |
---|
| 845 | REAL( fill_value, KIND = wp ), & |
---|
| 846 | BTEST( wall_flags_0(k,j,i), flag_nr ) ) |
---|
[1] | 847 | ENDDO |
---|
| 848 | ENDDO |
---|
| 849 | ENDDO |
---|
| 850 | ENDIF |
---|
| 851 | |
---|
| 852 | ! |
---|
[1327] | 853 | !-- Output of the 3D-array |
---|
| 854 | #if defined( __parallel ) |
---|
| 855 | IF ( netcdf_data_format < 5 ) THEN |
---|
[1] | 856 | ! |
---|
[1327] | 857 | !-- Non-parallel netCDF output. Data is output in parallel in |
---|
| 858 | !-- FORTRAN binary format here, and later collected into one file by |
---|
| 859 | !-- combine_plot_fields |
---|
| 860 | IF ( myid == 0 ) THEN |
---|
| 861 | WRITE ( 30 ) time_since_reference_point, & |
---|
| 862 | do3d_time_count(av), av |
---|
[1] | 863 | ENDIF |
---|
[1327] | 864 | DO i = 0, io_blocks-1 |
---|
| 865 | IF ( i == io_group ) THEN |
---|
[2512] | 866 | WRITE ( 30 ) nxl, nxr, nys, nyn, nzb_do, nzt_do |
---|
[1551] | 867 | WRITE ( 30 ) local_pf(:,:,nzb_do:nzt_do) |
---|
[1327] | 868 | ENDIF |
---|
[1972] | 869 | |
---|
[1327] | 870 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1972] | 871 | |
---|
[1327] | 872 | ENDDO |
---|
[559] | 873 | |
---|
[1327] | 874 | ELSE |
---|
[646] | 875 | #if defined( __netcdf ) |
---|
[493] | 876 | ! |
---|
[1327] | 877 | !-- Parallel output in netCDF4/HDF5 format. |
---|
[2512] | 878 | ! IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
| 879 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
| 880 | ! local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do), & |
---|
| 881 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 882 | ! count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
| 883 | ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
| 884 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
| 885 | ! local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do), & |
---|
| 886 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 887 | ! count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
| 888 | ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
| 889 | ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
| 890 | ! local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do ), & |
---|
| 891 | ! start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 892 | ! count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
| 893 | ! ELSE |
---|
[1327] | 894 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 895 | local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do), & |
---|
| 896 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 897 | count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[2512] | 898 | ! ENDIF |
---|
[1783] | 899 | CALL netcdf_handle_error( 'data_output_3d', 386 ) |
---|
[646] | 900 | #endif |
---|
[1327] | 901 | ENDIF |
---|
[1] | 902 | #else |
---|
| 903 | #if defined( __netcdf ) |
---|
[1327] | 904 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 905 | local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do), & |
---|
[1327] | 906 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
[2512] | 907 | count = (/ nx+1, ny+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1783] | 908 | CALL netcdf_handle_error( 'data_output_3d', 446 ) |
---|
[1] | 909 | #endif |
---|
| 910 | #endif |
---|
| 911 | |
---|
| 912 | if = if + 1 |
---|
| 913 | |
---|
| 914 | ! |
---|
[1551] | 915 | !-- Deallocate temporary array |
---|
| 916 | DEALLOCATE ( local_pf ) |
---|
[1] | 917 | |
---|
[1551] | 918 | ENDDO |
---|
[1] | 919 | |
---|
[1318] | 920 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
[1] | 921 | |
---|
| 922 | ! |
---|
| 923 | !-- Formats. |
---|
[1320] | 924 | 3300 FORMAT ('variable ',I4,' file=',A,' filetype=unformatted skip=',I12/ & |
---|
[1] | 925 | 'label = ',A,A) |
---|
| 926 | |
---|
| 927 | END SUBROUTINE data_output_3d |
---|