[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 | ! ------------------ |
---|
[1849] | 21 | ! prr moved to arrays_3d |
---|
[1784] | 22 | ! |
---|
[1552] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: data_output_3d.f90 1849 2016-04-08 11:33:18Z hoffmann $ |
---|
| 26 | ! |
---|
[1823] | 27 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 28 | ! prr vertical dimensions set to nzb_do to nzt_do. Unused variables deleted. |
---|
| 29 | ! |
---|
[1809] | 30 | ! 1808 2016-04-05 19:44:00Z raasch |
---|
| 31 | ! test output removed |
---|
| 32 | ! |
---|
[1784] | 33 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 34 | ! name change of netcdf routines and module + related changes |
---|
| 35 | ! |
---|
[1746] | 36 | ! 1745 2016-02-05 13:06:51Z gronemeier |
---|
| 37 | ! Bugfix: test if time axis limit exceeds moved to point after call of check_open |
---|
| 38 | ! |
---|
[1692] | 39 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 40 | ! Added output of radiative heating rates for RRTMG |
---|
| 41 | ! |
---|
[1683] | 42 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 43 | ! Code annotations made doxygen readable |
---|
| 44 | ! |
---|
[1586] | 45 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
| 46 | ! Added support for RRTMG |
---|
| 47 | ! |
---|
[1552] | 48 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
[1551] | 49 | ! Added suppport for land surface model and radiation model output. In the course |
---|
| 50 | ! of this action, the limits for vertical loops have been changed (from nzb and |
---|
| 51 | ! nzt+1 to nzb_do and nzt_do, respectively in order to allow soil model output). |
---|
| 52 | ! Moreover, a new vertical grid zs was introduced. |
---|
[1329] | 53 | ! |
---|
[1360] | 54 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 55 | ! New particle structure integrated. |
---|
| 56 | ! |
---|
[1354] | 57 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 58 | ! REAL constants provided with KIND-attribute |
---|
| 59 | ! |
---|
[1329] | 60 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
| 61 | ! parts concerning avs output removed, |
---|
| 62 | ! -netcdf output queries |
---|
| 63 | ! |
---|
[1321] | 64 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 65 | ! ONLY-attribute added to USE-statements, |
---|
| 66 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 67 | ! kinds are defined in new module kinds, |
---|
| 68 | ! old module precision_kind is removed, |
---|
| 69 | ! revision history before 2012 removed, |
---|
| 70 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 71 | ! all variable declaration statements |
---|
[674] | 72 | ! |
---|
[1319] | 73 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 74 | ! barrier argument removed from cpu_log, |
---|
| 75 | ! module interfaces removed |
---|
| 76 | ! |
---|
[1309] | 77 | ! 1308 2014-03-13 14:58:42Z fricke |
---|
| 78 | ! Check, if the limit of the time dimension is exceeded for parallel output |
---|
| 79 | ! To increase the performance for parallel output, the following is done: |
---|
| 80 | ! - Update of time axis is only done by PE0 |
---|
| 81 | ! |
---|
[1245] | 82 | ! 1244 2013-10-31 08:16:56Z raasch |
---|
| 83 | ! Bugfix for index bounds in case of 3d-parallel output |
---|
| 84 | ! |
---|
[1116] | 85 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 86 | ! ql is calculated by calc_liquid_water_content |
---|
| 87 | ! |
---|
[1107] | 88 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
| 89 | ! array_kind renamed precision_kind |
---|
| 90 | ! |
---|
[1077] | 91 | ! 1076 2012-12-05 08:30:18Z hoffmann |
---|
| 92 | ! Bugfix in output of ql |
---|
| 93 | ! |
---|
[1054] | 94 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 95 | ! +nr, qr, prr, qc and averaged quantities |
---|
| 96 | ! |
---|
[1037] | 97 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 98 | ! code put under GPL (PALM 3.9) |
---|
| 99 | ! |
---|
[1035] | 100 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
| 101 | ! netCDF4 without parallel file support implemented |
---|
| 102 | ! |
---|
[1008] | 103 | ! 1007 2012-09-19 14:30:36Z franke |
---|
| 104 | ! Bugfix: missing calculation of ql_vp added |
---|
| 105 | ! |
---|
[1] | 106 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
| 107 | ! Initial revision |
---|
| 108 | ! |
---|
| 109 | ! |
---|
| 110 | ! Description: |
---|
| 111 | ! ------------ |
---|
[1682] | 112 | !> Output of the 3D-arrays in netCDF and/or AVS format. |
---|
[1] | 113 | !------------------------------------------------------------------------------! |
---|
[1682] | 114 | SUBROUTINE data_output_3d( av ) |
---|
| 115 | |
---|
[1] | 116 | |
---|
[1320] | 117 | USE arrays_3d, & |
---|
[1849] | 118 | ONLY: e, nr, p, pt, prr, q, qc, ql, ql_c, ql_v, qr, rho, sa, tend, u, & |
---|
| 119 | v, vpt, w |
---|
[1320] | 120 | |
---|
[1] | 121 | USE averaging |
---|
[1320] | 122 | |
---|
| 123 | USE cloud_parameters, & |
---|
[1849] | 124 | ONLY: l_d_cp, pt_d_t |
---|
[1320] | 125 | |
---|
| 126 | USE control_parameters, & |
---|
[1822] | 127 | ONLY: cloud_physics, do3d, do3d_no, do3d_time_count, io_blocks, & |
---|
| 128 | io_group, message_string, ntdim_3d, nz_do3d, psolver, & |
---|
| 129 | simulated_time, time_since_reference_point |
---|
[1320] | 130 | |
---|
| 131 | USE cpulog, & |
---|
| 132 | ONLY: log_point, cpu_log |
---|
| 133 | |
---|
| 134 | USE indices, & |
---|
[1822] | 135 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb |
---|
[1320] | 136 | |
---|
| 137 | USE kinds |
---|
| 138 | |
---|
[1551] | 139 | USE land_surface_model_mod, & |
---|
| 140 | ONLY: m_soil, m_soil_av, nzb_soil, nzt_soil, t_soil, t_soil_av |
---|
| 141 | |
---|
[1783] | 142 | #if defined( __netcdf ) |
---|
| 143 | USE NETCDF |
---|
| 144 | #endif |
---|
| 145 | |
---|
| 146 | USE netcdf_interface, & |
---|
| 147 | ONLY: id_set_3d, id_var_do3d, id_var_time_3d, nc_stat, & |
---|
| 148 | netcdf_data_format, netcdf_handle_error |
---|
[1320] | 149 | |
---|
| 150 | USE particle_attributes, & |
---|
[1359] | 151 | ONLY: grid_particles, number_of_particles, particles, & |
---|
| 152 | particle_advection_start, prt_count |
---|
[1320] | 153 | |
---|
[1] | 154 | USE pegrid |
---|
| 155 | |
---|
[1585] | 156 | USE radiation_model_mod, & |
---|
| 157 | ONLY: rad_lw_in, rad_lw_in_av, rad_lw_out, rad_lw_out_av, & |
---|
[1691] | 158 | rad_lw_cs_hr, rad_lw_cs_hr_av, rad_lw_hr, rad_lw_hr_av, & |
---|
| 159 | rad_sw_in, rad_sw_in_av, rad_sw_out, rad_sw_out_av, & |
---|
| 160 | rad_sw_cs_hr, rad_sw_cs_hr_av, rad_sw_hr, rad_sw_hr_av |
---|
[1585] | 161 | |
---|
| 162 | |
---|
[1] | 163 | IMPLICIT NONE |
---|
| 164 | |
---|
[1682] | 165 | INTEGER(iwp) :: av !< |
---|
| 166 | INTEGER(iwp) :: i !< |
---|
| 167 | INTEGER(iwp) :: if !< |
---|
| 168 | INTEGER(iwp) :: j !< |
---|
| 169 | INTEGER(iwp) :: k !< |
---|
| 170 | INTEGER(iwp) :: n !< |
---|
| 171 | INTEGER(iwp) :: nzb_do !< vertical lower limit for data output |
---|
| 172 | INTEGER(iwp) :: nzt_do !< vertical upper limit for data output |
---|
[1] | 173 | |
---|
[1682] | 174 | LOGICAL :: found !< |
---|
| 175 | LOGICAL :: resorted !< |
---|
[1] | 176 | |
---|
[1682] | 177 | REAL(wp) :: mean_r !< |
---|
| 178 | REAL(wp) :: s_r2 !< |
---|
| 179 | REAL(wp) :: s_r3 !< |
---|
[1] | 180 | |
---|
[1682] | 181 | REAL(sp), DIMENSION(:,:,:), ALLOCATABLE :: local_pf !< |
---|
[1] | 182 | |
---|
[1682] | 183 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< |
---|
[1] | 184 | |
---|
| 185 | ! |
---|
| 186 | !-- Return, if nothing to output |
---|
| 187 | IF ( do3d_no(av) == 0 ) RETURN |
---|
| 188 | |
---|
| 189 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
| 190 | |
---|
| 191 | ! |
---|
| 192 | !-- Open output file. |
---|
| 193 | !-- Also creates coordinate and fld-file for AVS. |
---|
[1031] | 194 | !-- For classic or 64bit netCDF output or output of other (old) data formats, |
---|
[493] | 195 | !-- for a run on more than one PE, each PE opens its own file and |
---|
[1] | 196 | !-- writes the data of its subdomain in binary format (regardless of the format |
---|
| 197 | !-- the user has requested). After the run, these files are combined to one |
---|
| 198 | !-- file by combine_plot_fields in the format requested by the user (netcdf |
---|
[493] | 199 | !-- and/or avs). |
---|
[1031] | 200 | !-- For netCDF4/HDF5 output, data is written in parallel into one file. |
---|
[1327] | 201 | IF ( netcdf_data_format < 5 ) THEN |
---|
| 202 | CALL check_open( 30 ) |
---|
| 203 | IF ( myid == 0 ) CALL check_open( 106+av*10 ) |
---|
[493] | 204 | ELSE |
---|
[1327] | 205 | CALL check_open( 106+av*10 ) |
---|
[493] | 206 | ENDIF |
---|
[1] | 207 | |
---|
| 208 | ! |
---|
[1745] | 209 | !-- For parallel netcdf output the time axis must be limited. Return, if this |
---|
| 210 | !-- limit is exceeded. This could be the case, if the simulated time exceeds |
---|
| 211 | !-- the given end time by the length of the given output interval. |
---|
| 212 | IF ( netcdf_data_format > 4 ) THEN |
---|
| 213 | IF ( do3d_time_count(av) + 1 > ntdim_3d(av) ) THEN |
---|
| 214 | WRITE ( message_string, * ) 'Output of 3d data is not given at t=', & |
---|
| 215 | simulated_time, '&because the maximum ', & |
---|
| 216 | 'number of output time levels is ', & |
---|
| 217 | 'exceeded.' |
---|
| 218 | CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 ) |
---|
| 219 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
| 220 | RETURN |
---|
| 221 | ENDIF |
---|
| 222 | ENDIF |
---|
| 223 | |
---|
| 224 | ! |
---|
[1031] | 225 | !-- Update the netCDF time axis |
---|
[1308] | 226 | !-- In case of parallel output, this is only done by PE0 to increase the |
---|
| 227 | !-- performance. |
---|
[1] | 228 | #if defined( __netcdf ) |
---|
[1308] | 229 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
| 230 | IF ( myid == 0 ) THEN |
---|
[1327] | 231 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
| 232 | (/ time_since_reference_point /), & |
---|
| 233 | start = (/ do3d_time_count(av) /), & |
---|
| 234 | count = (/ 1 /) ) |
---|
[1783] | 235 | CALL netcdf_handle_error( 'data_output_3d', 376 ) |
---|
[1] | 236 | ENDIF |
---|
| 237 | #endif |
---|
| 238 | |
---|
| 239 | ! |
---|
| 240 | !-- Loop over all variables to be written. |
---|
| 241 | if = 1 |
---|
| 242 | |
---|
| 243 | DO WHILE ( do3d(av,if)(1:1) /= ' ' ) |
---|
| 244 | ! |
---|
| 245 | !-- Store the array chosen on the temporary array. |
---|
| 246 | resorted = .FALSE. |
---|
[1551] | 247 | nzb_do = nzb |
---|
| 248 | nzt_do = nz_do3d |
---|
| 249 | |
---|
| 250 | ! |
---|
| 251 | !-- Allocate a temporary array with the desired output dimensions. |
---|
| 252 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 253 | |
---|
[1] | 254 | SELECT CASE ( TRIM( do3d(av,if) ) ) |
---|
| 255 | |
---|
| 256 | CASE ( 'e' ) |
---|
| 257 | IF ( av == 0 ) THEN |
---|
| 258 | to_be_resorted => e |
---|
| 259 | ELSE |
---|
| 260 | to_be_resorted => e_av |
---|
| 261 | ENDIF |
---|
| 262 | |
---|
[771] | 263 | CASE ( 'lpt' ) |
---|
| 264 | IF ( av == 0 ) THEN |
---|
| 265 | to_be_resorted => pt |
---|
| 266 | ELSE |
---|
| 267 | to_be_resorted => lpt_av |
---|
| 268 | ENDIF |
---|
| 269 | |
---|
[1551] | 270 | CASE ( 'm_soil' ) |
---|
| 271 | nzb_do = nzb_soil |
---|
| 272 | nzt_do = nzt_soil |
---|
| 273 | ! |
---|
| 274 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 275 | DEALLOCATE ( local_pf ) |
---|
| 276 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 277 | |
---|
| 278 | IF ( av == 0 ) THEN |
---|
| 279 | to_be_resorted => m_soil |
---|
| 280 | ELSE |
---|
| 281 | to_be_resorted => m_soil_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 | |
---|
[1585] | 500 | CASE ( 'rad_sw_in' ) |
---|
| 501 | IF ( av == 0 ) THEN |
---|
| 502 | to_be_resorted => rad_sw_in |
---|
| 503 | ELSE |
---|
| 504 | to_be_resorted => rad_sw_in_av |
---|
| 505 | ENDIF |
---|
| 506 | |
---|
| 507 | CASE ( 'rad_sw_out' ) |
---|
| 508 | IF ( av == 0 ) THEN |
---|
| 509 | to_be_resorted => rad_sw_out |
---|
| 510 | ELSE |
---|
| 511 | to_be_resorted => rad_sw_out_av |
---|
| 512 | ENDIF |
---|
| 513 | |
---|
[1691] | 514 | CASE ( 'rad_sw_cs_hr' ) |
---|
| 515 | IF ( av == 0 ) THEN |
---|
| 516 | to_be_resorted => rad_sw_cs_hr |
---|
| 517 | ELSE |
---|
| 518 | to_be_resorted => rad_sw_cs_hr_av |
---|
| 519 | ENDIF |
---|
| 520 | |
---|
| 521 | CASE ( 'rad_sw_hr' ) |
---|
| 522 | IF ( av == 0 ) THEN |
---|
| 523 | to_be_resorted => rad_sw_hr |
---|
| 524 | ELSE |
---|
| 525 | to_be_resorted => rad_sw_hr_av |
---|
| 526 | ENDIF |
---|
| 527 | |
---|
[1585] | 528 | CASE ( 'rad_lw_in' ) |
---|
| 529 | IF ( av == 0 ) THEN |
---|
| 530 | to_be_resorted => rad_lw_in |
---|
| 531 | ELSE |
---|
| 532 | to_be_resorted => rad_lw_in_av |
---|
| 533 | ENDIF |
---|
| 534 | |
---|
| 535 | CASE ( 'rad_lw_out' ) |
---|
| 536 | IF ( av == 0 ) THEN |
---|
| 537 | to_be_resorted => rad_lw_out |
---|
| 538 | ELSE |
---|
| 539 | to_be_resorted => rad_lw_out_av |
---|
| 540 | ENDIF |
---|
| 541 | |
---|
[1691] | 542 | CASE ( 'rad_lw_cs_hr' ) |
---|
| 543 | IF ( av == 0 ) THEN |
---|
| 544 | to_be_resorted => rad_lw_cs_hr |
---|
| 545 | ELSE |
---|
| 546 | to_be_resorted => rad_lw_cs_hr_av |
---|
| 547 | ENDIF |
---|
| 548 | |
---|
| 549 | CASE ( 'rad_lw_hr' ) |
---|
| 550 | IF ( av == 0 ) THEN |
---|
| 551 | to_be_resorted => rad_lw_hr |
---|
| 552 | ELSE |
---|
| 553 | to_be_resorted => rad_lw_hr_av |
---|
| 554 | ENDIF |
---|
| 555 | |
---|
[96] | 556 | CASE ( 'rho' ) |
---|
| 557 | IF ( av == 0 ) THEN |
---|
| 558 | to_be_resorted => rho |
---|
| 559 | ELSE |
---|
| 560 | to_be_resorted => rho_av |
---|
| 561 | ENDIF |
---|
[691] | 562 | |
---|
[1] | 563 | CASE ( 's' ) |
---|
| 564 | IF ( av == 0 ) THEN |
---|
| 565 | to_be_resorted => q |
---|
| 566 | ELSE |
---|
[355] | 567 | to_be_resorted => s_av |
---|
[1] | 568 | ENDIF |
---|
[691] | 569 | |
---|
[96] | 570 | CASE ( 'sa' ) |
---|
| 571 | IF ( av == 0 ) THEN |
---|
| 572 | to_be_resorted => sa |
---|
| 573 | ELSE |
---|
| 574 | to_be_resorted => sa_av |
---|
| 575 | ENDIF |
---|
[691] | 576 | |
---|
[1551] | 577 | CASE ( 't_soil' ) |
---|
| 578 | nzb_do = nzb_soil |
---|
| 579 | nzt_do = nzt_soil |
---|
| 580 | ! |
---|
| 581 | !-- For soil model quantities, it is required to re-allocate local_pf |
---|
| 582 | DEALLOCATE ( local_pf ) |
---|
| 583 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) ) |
---|
| 584 | |
---|
| 585 | IF ( av == 0 ) THEN |
---|
| 586 | to_be_resorted => t_soil |
---|
| 587 | ELSE |
---|
| 588 | to_be_resorted => t_soil_av |
---|
| 589 | ENDIF |
---|
| 590 | |
---|
[1] | 591 | CASE ( 'u' ) |
---|
| 592 | IF ( av == 0 ) THEN |
---|
| 593 | to_be_resorted => u |
---|
| 594 | ELSE |
---|
| 595 | to_be_resorted => u_av |
---|
| 596 | ENDIF |
---|
| 597 | |
---|
| 598 | CASE ( 'v' ) |
---|
| 599 | IF ( av == 0 ) THEN |
---|
| 600 | to_be_resorted => v |
---|
| 601 | ELSE |
---|
| 602 | to_be_resorted => v_av |
---|
| 603 | ENDIF |
---|
| 604 | |
---|
| 605 | CASE ( 'vpt' ) |
---|
| 606 | IF ( av == 0 ) THEN |
---|
| 607 | to_be_resorted => vpt |
---|
| 608 | ELSE |
---|
| 609 | to_be_resorted => vpt_av |
---|
| 610 | ENDIF |
---|
| 611 | |
---|
| 612 | CASE ( 'w' ) |
---|
| 613 | IF ( av == 0 ) THEN |
---|
| 614 | to_be_resorted => w |
---|
| 615 | ELSE |
---|
| 616 | to_be_resorted => w_av |
---|
| 617 | ENDIF |
---|
| 618 | |
---|
| 619 | CASE DEFAULT |
---|
| 620 | ! |
---|
| 621 | !-- User defined quantity |
---|
[1320] | 622 | CALL user_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
[1551] | 623 | nzb_do, nzt_do ) |
---|
[1] | 624 | resorted = .TRUE. |
---|
| 625 | |
---|
[254] | 626 | IF ( .NOT. found ) THEN |
---|
[1320] | 627 | message_string = 'no output available for: ' // & |
---|
[274] | 628 | TRIM( do3d(av,if) ) |
---|
[254] | 629 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
[1] | 630 | ENDIF |
---|
| 631 | |
---|
| 632 | END SELECT |
---|
| 633 | |
---|
| 634 | ! |
---|
| 635 | !-- Resort the array to be output, if not done above |
---|
| 636 | IF ( .NOT. resorted ) THEN |
---|
[667] | 637 | DO i = nxlg, nxrg |
---|
| 638 | DO j = nysg, nyng |
---|
[1551] | 639 | DO k = nzb_do, nzt_do |
---|
[1] | 640 | local_pf(i,j,k) = to_be_resorted(k,j,i) |
---|
| 641 | ENDDO |
---|
| 642 | ENDDO |
---|
| 643 | ENDDO |
---|
| 644 | ENDIF |
---|
| 645 | |
---|
| 646 | ! |
---|
[1327] | 647 | !-- Output of the 3D-array |
---|
| 648 | #if defined( __parallel ) |
---|
| 649 | IF ( netcdf_data_format < 5 ) THEN |
---|
[1] | 650 | ! |
---|
[1327] | 651 | !-- Non-parallel netCDF output. Data is output in parallel in |
---|
| 652 | !-- FORTRAN binary format here, and later collected into one file by |
---|
| 653 | !-- combine_plot_fields |
---|
| 654 | IF ( myid == 0 ) THEN |
---|
| 655 | WRITE ( 30 ) time_since_reference_point, & |
---|
| 656 | do3d_time_count(av), av |
---|
[1] | 657 | ENDIF |
---|
[1327] | 658 | DO i = 0, io_blocks-1 |
---|
| 659 | IF ( i == io_group ) THEN |
---|
[1551] | 660 | WRITE ( 30 ) nxlg, nxrg, nysg, nyng, nzb_do, nzt_do |
---|
| 661 | WRITE ( 30 ) local_pf(:,:,nzb_do:nzt_do) |
---|
[1327] | 662 | ENDIF |
---|
[1] | 663 | #if defined( __parallel ) |
---|
[1327] | 664 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[759] | 665 | #endif |
---|
[1327] | 666 | ENDDO |
---|
[559] | 667 | |
---|
[1327] | 668 | ELSE |
---|
[646] | 669 | #if defined( __netcdf ) |
---|
[493] | 670 | ! |
---|
[1327] | 671 | !-- Parallel output in netCDF4/HDF5 format. |
---|
| 672 | !-- Do not output redundant ghost point data except for the |
---|
| 673 | !-- boundaries of the total domain. |
---|
| 674 | IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
| 675 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 676 | local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do), & |
---|
| 677 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 678 | count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 679 | ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
| 680 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 681 | local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do), & |
---|
| 682 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 683 | count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 684 | ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
| 685 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 686 | local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do ), & |
---|
| 687 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 688 | count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 689 | ELSE |
---|
| 690 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 691 | local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do), & |
---|
| 692 | start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /), & |
---|
| 693 | count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) ) |
---|
[1327] | 694 | ENDIF |
---|
[1783] | 695 | CALL netcdf_handle_error( 'data_output_3d', 386 ) |
---|
[646] | 696 | #endif |
---|
[1327] | 697 | ENDIF |
---|
[1] | 698 | #else |
---|
| 699 | #if defined( __netcdf ) |
---|
[1327] | 700 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
[1551] | 701 | local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do), & |
---|
[1327] | 702 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
[1551] | 703 | count = (/ nx+2, ny+2, nzt_do-nzb_do+1, 1 /) ) |
---|
[1783] | 704 | CALL netcdf_handle_error( 'data_output_3d', 446 ) |
---|
[1] | 705 | #endif |
---|
| 706 | #endif |
---|
| 707 | |
---|
| 708 | if = if + 1 |
---|
| 709 | |
---|
| 710 | ! |
---|
[1551] | 711 | !-- Deallocate temporary array |
---|
| 712 | DEALLOCATE ( local_pf ) |
---|
[1] | 713 | |
---|
[1551] | 714 | ENDDO |
---|
[1] | 715 | |
---|
[1318] | 716 | CALL cpu_log( log_point(14), 'data_output_3d', 'stop' ) |
---|
[1] | 717 | |
---|
| 718 | ! |
---|
| 719 | !-- Formats. |
---|
[1320] | 720 | 3300 FORMAT ('variable ',I4,' file=',A,' filetype=unformatted skip=',I12/ & |
---|
[1] | 721 | 'label = ',A,A) |
---|
| 722 | |
---|
| 723 | END SUBROUTINE data_output_3d |
---|