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