[1682] | 1 | !> @file init_masks.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 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[298] | 21 | ! ----------------- |
---|
[1805] | 22 | ! |
---|
[3049] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: init_masks.f90 3049 2018-05-29 13:52:36Z Giersch $ |
---|
[3045] | 27 | ! Error messages revised |
---|
| 28 | ! |
---|
[3049] | 29 | ! 3045 2018-05-28 07:55:41Z Giersch |
---|
| 30 | ! Error messages revised |
---|
| 31 | ! |
---|
[3045] | 32 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 33 | ! Corrected "Former revisions" section |
---|
| 34 | ! |
---|
| 35 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 36 | ! Change in file header (GPL part) |
---|
| 37 | ! |
---|
| 38 | ! 2344 2017-08-09 11:00:34Z raasch |
---|
[2344] | 39 | ! explicit setting of initial values for array domask required due to a bug |
---|
| 40 | ! in the Cray compiler (appears only if option -eD is used) |
---|
| 41 | ! |
---|
| 42 | ! 2301 2017-06-29 16:41:21Z gronemeier |
---|
[2301] | 43 | ! Bugfix: set variable name length to global value |
---|
| 44 | ! |
---|
| 45 | ! |
---|
[2292] | 46 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
| 47 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
| 48 | ! and cloud water content (qc). |
---|
| 49 | ! |
---|
| 50 | ! 2271 2017-06-09 12:34:55Z sward |
---|
[2271] | 51 | ! Changed error message |
---|
| 52 | ! |
---|
| 53 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
[1321] | 54 | ! |
---|
[2032] | 55 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
| 56 | ! renamed variable rho to rho_ocean |
---|
| 57 | ! |
---|
[2001] | 58 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 59 | ! Forced header and separation lines into 80 columns |
---|
| 60 | ! |
---|
[1823] | 61 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 62 | ! icloud_scheme replaced by microphysics_* |
---|
| 63 | ! |
---|
[1805] | 64 | ! 1804 2016-04-05 16:30:18Z maronga |
---|
| 65 | ! Removed code for parameter file check (__check) |
---|
| 66 | ! |
---|
[1784] | 67 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 68 | ! netcdf module name changed + related changes |
---|
| 69 | ! |
---|
[1683] | 70 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 71 | ! Code annotations made doxygen readable |
---|
| 72 | ! |
---|
[1439] | 73 | ! 1438 2014-07-22 14:14:06Z heinze |
---|
| 74 | ! +nr, qc, qr |
---|
| 75 | ! |
---|
[1415] | 76 | ! 1414 2014-05-31 11:19:48Z gronemeier |
---|
| 77 | ! Bugfix: first and last grid points as they appear in 3D volume data can now |
---|
| 78 | ! be included to masked data output |
---|
| 79 | ! |
---|
[1354] | 80 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 81 | ! REAL constants provided with KIND-attribute |
---|
| 82 | ! |
---|
[1325] | 83 | ! 1324 2014-03-21 09:13:16Z suehring |
---|
| 84 | ! Bugfix: ONLY statement for module netcdf_control removed |
---|
| 85 | ! |
---|
[1321] | 86 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 87 | ! ONLY-attribute added to USE-statements, |
---|
| 88 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 89 | ! kinds are defined in new module kinds, |
---|
| 90 | ! revision history before 2012 removed, |
---|
| 91 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 92 | ! all variable declaration statements |
---|
[298] | 93 | ! |
---|
[1187] | 94 | ! 1186 2013-06-18 06:22:52Z raasch |
---|
| 95 | ! bugfix: 0.0 replaced by zu(nzb) as the lowest default height level for masks, |
---|
| 96 | ! because a zero value does not work in case of ocean runs |
---|
| 97 | ! |
---|
[1037] | 98 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 99 | ! code put under GPL (PALM 3.9) |
---|
| 100 | ! |
---|
[1033] | 101 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
| 102 | ! mask locations determined based on scalar positions |
---|
| 103 | ! |
---|
[1035] | 104 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
| 105 | ! netCDF4 without parallel file support implemented |
---|
| 106 | ! |
---|
[997] | 107 | ! 996 2012-09-07 10:41:47Z raasch |
---|
| 108 | ! little reformatting |
---|
| 109 | ! |
---|
[979] | 110 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 111 | ! +z0h* |
---|
| 112 | ! |
---|
[810] | 113 | ! 809 2012-01-30 13:32:58Z maronga |
---|
| 114 | ! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives |
---|
| 115 | ! |
---|
[808] | 116 | ! 807 2012-01-25 11:53:51Z maronga |
---|
| 117 | ! New cpp directive "__check" implemented which is used by check_namelist_files |
---|
| 118 | ! |
---|
[449] | 119 | ! 410 2009-12-04 17:05:40Z letzel |
---|
| 120 | ! Initial revision |
---|
[298] | 121 | ! |
---|
[449] | 122 | ! |
---|
[298] | 123 | ! Description: |
---|
| 124 | ! ------------ |
---|
[1682] | 125 | !> Initialize masked data output |
---|
[298] | 126 | !------------------------------------------------------------------------------! |
---|
[1682] | 127 | SUBROUTINE init_masks |
---|
[298] | 128 | |
---|
[1320] | 129 | USE arrays_3d, & |
---|
| 130 | ONLY: zu, zw |
---|
| 131 | |
---|
| 132 | USE control_parameters, & |
---|
| 133 | ONLY: constant_diffusion, cloud_droplets, cloud_physics, & |
---|
| 134 | data_output_masks, data_output_masks_user, & |
---|
| 135 | doav, doav_n, domask, domask_no, dz, dz_stretch_level, humidity,& |
---|
[1822] | 136 | mask, masks, mask_scale, mask_i, & |
---|
[1320] | 137 | mask_i_global, mask_j, mask_j_global, mask_k, mask_k_global, & |
---|
| 138 | mask_loop, mask_size, mask_size_l, mask_start_l, mask_x, & |
---|
| 139 | mask_x_loop, mask_xyz_dimension, mask_y, mask_y_loop, mask_z, & |
---|
| 140 | mask_z_loop, max_masks, message_string, mid, & |
---|
[2292] | 141 | microphysics_morrison, microphysics_seifert, passive_scalar, & |
---|
[2301] | 142 | ocean, varnamelength |
---|
[1320] | 143 | |
---|
| 144 | USE grid_variables, & |
---|
| 145 | ONLY: dx, dy |
---|
| 146 | |
---|
| 147 | USE indices, & |
---|
| 148 | ONLY: nx, nxl, nxr, ny, nyn, nys, nz, nzb, nzt |
---|
| 149 | |
---|
| 150 | USE kinds |
---|
| 151 | |
---|
[1783] | 152 | USE netcdf_interface, & |
---|
| 153 | ONLY: domask_unit, netcdf_data_format |
---|
[1320] | 154 | |
---|
| 155 | USE particle_attributes, & |
---|
| 156 | ONLY: particle_advection |
---|
| 157 | |
---|
[298] | 158 | USE pegrid |
---|
| 159 | |
---|
| 160 | IMPLICIT NONE |
---|
| 161 | |
---|
[2301] | 162 | CHARACTER (LEN=varnamelength) :: var !< |
---|
[1682] | 163 | CHARACTER (LEN=7) :: unit !< |
---|
[1320] | 164 | |
---|
[2301] | 165 | CHARACTER (LEN=varnamelength), DIMENSION(max_masks,100) :: do_mask !< |
---|
| 166 | CHARACTER (LEN=varnamelength), DIMENSION(max_masks,100) :: do_mask_user !< |
---|
[298] | 167 | |
---|
[1682] | 168 | INTEGER(iwp) :: i !< |
---|
| 169 | INTEGER(iwp) :: ilen !< |
---|
| 170 | INTEGER(iwp) :: ind(6) !< |
---|
| 171 | INTEGER(iwp) :: ind_array(1) !< |
---|
| 172 | INTEGER(iwp) :: j !< |
---|
| 173 | INTEGER(iwp) :: k !< |
---|
| 174 | INTEGER(iwp) :: n !< |
---|
| 175 | INTEGER(iwp) :: sender !< |
---|
[1320] | 176 | |
---|
[1682] | 177 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: tmp_array !< |
---|
[298] | 178 | |
---|
[1682] | 179 | LOGICAL :: found !< |
---|
[2344] | 180 | |
---|
[298] | 181 | ! |
---|
[2344] | 182 | !-- Initial values are explicitly set here due to a bug in the Cray compiler |
---|
| 183 | !-- in case of assignments of initial values in declaration statements for |
---|
| 184 | !-- arrays with more than 9999 elements (appears with -eD only) |
---|
| 185 | domask = ' ' |
---|
| 186 | |
---|
| 187 | ! |
---|
[298] | 188 | !-- Allocation and initialization |
---|
[1414] | 189 | ALLOCATE( tmp_array( MAX(nx,ny,nz)+2 ) ) |
---|
[298] | 190 | |
---|
[1414] | 191 | ALLOCATE( mask_i(max_masks,nxr-nxl+2), & |
---|
| 192 | mask_j(max_masks,nyn-nys+2), & |
---|
| 193 | mask_k(max_masks,nzt-nzb+2) ) |
---|
[298] | 194 | ! |
---|
| 195 | !-- internal mask arrays ("mask,dimension,selection") |
---|
| 196 | ALLOCATE( mask(max_masks,3,mask_xyz_dimension), & |
---|
| 197 | mask_loop(max_masks,3,3) ) |
---|
[493] | 198 | |
---|
[298] | 199 | ! |
---|
[3045] | 200 | !-- Parallel mask output not yet supported. In check_parameters data format |
---|
| 201 | !-- is restricted and is switched back to non-parallel output. Therefore the |
---|
| 202 | !-- following error can not occur at the moment. |
---|
[1031] | 203 | IF ( netcdf_data_format > 4 ) THEN |
---|
[3045] | 204 | message_string = 'netCDF file formats '// & |
---|
| 205 | '5 and 6 (with parallel I/O support)'// & |
---|
| 206 | ' are currently not supported.' |
---|
[564] | 207 | CALL message( 'init_masks', 'PA0328', 1, 2, 0, 6, 0 ) |
---|
[298] | 208 | ENDIF |
---|
[553] | 209 | |
---|
[298] | 210 | ! |
---|
| 211 | !-- Store data output parameters for masked data output in few shared arrays |
---|
[996] | 212 | DO mid = 1, masks |
---|
[564] | 213 | |
---|
[553] | 214 | do_mask (mid,:) = data_output_masks(mid,:) |
---|
| 215 | do_mask_user(mid,:) = data_output_masks_user(mid,:) |
---|
| 216 | mask (mid,1,:) = mask_x(mid,:) |
---|
| 217 | mask (mid,2,:) = mask_y(mid,:) |
---|
| 218 | mask (mid,3,:) = mask_z(mid,:) |
---|
[564] | 219 | |
---|
[1353] | 220 | IF ( mask_x_loop(mid,1) == -1.0_wp .AND. mask_x_loop(mid,2) == -1.0_wp& |
---|
| 221 | .AND. mask_x_loop(mid,3) == -1.0_wp ) THEN |
---|
| 222 | mask_loop(mid,1,1:2) = -1.0_wp |
---|
| 223 | mask_loop(mid,1,3) = 0.0_wp |
---|
[564] | 224 | ELSE |
---|
| 225 | mask_loop(mid,1,:) = mask_x_loop(mid,:) |
---|
| 226 | ENDIF |
---|
[1353] | 227 | IF ( mask_y_loop(mid,1) == -1.0_wp .AND. mask_y_loop(mid,2) == -1.0_wp& |
---|
| 228 | .AND. mask_y_loop(mid,3) == -1.0_wp ) THEN |
---|
| 229 | mask_loop(mid,2,1:2) = -1.0_wp |
---|
| 230 | mask_loop(mid,2,3) = 0.0_wp |
---|
[564] | 231 | ELSE |
---|
| 232 | mask_loop(mid,2,:) = mask_y_loop(mid,:) |
---|
| 233 | ENDIF |
---|
[1353] | 234 | IF ( mask_z_loop(mid,1) == -1.0_wp .AND. mask_z_loop(mid,2) == -1.0_wp& |
---|
| 235 | .AND. mask_z_loop(mid,3) == -1.0_wp ) THEN |
---|
| 236 | mask_loop(mid,3,1:2) = -1.0_wp |
---|
| 237 | mask_loop(mid,3,3) = 0.0_wp |
---|
[564] | 238 | ELSE |
---|
| 239 | mask_loop(mid,3,:) = mask_z_loop(mid,:) |
---|
| 240 | ENDIF |
---|
| 241 | |
---|
[553] | 242 | ENDDO |
---|
| 243 | |
---|
[298] | 244 | mask_i = -1; mask_j = -1; mask_k = -1 |
---|
[553] | 245 | |
---|
[298] | 246 | ! |
---|
| 247 | !-- Global arrays are required by define_netcdf_header. |
---|
[1031] | 248 | IF ( myid == 0 .OR. netcdf_data_format > 4 ) THEN |
---|
[1414] | 249 | ALLOCATE( mask_i_global(max_masks,nx+2), & |
---|
| 250 | mask_j_global(max_masks,ny+2), & |
---|
| 251 | mask_k_global(max_masks,nz+2) ) |
---|
[298] | 252 | mask_i_global = -1; mask_j_global = -1; mask_k_global = -1 |
---|
| 253 | ENDIF |
---|
| 254 | |
---|
| 255 | ! |
---|
| 256 | !-- Determine variable names for each mask |
---|
| 257 | DO mid = 1, masks |
---|
| 258 | ! |
---|
| 259 | !-- Append user-defined data output variables to the standard data output |
---|
| 260 | IF ( do_mask_user(mid,1) /= ' ' ) THEN |
---|
| 261 | i = 1 |
---|
| 262 | DO WHILE ( do_mask(mid,i) /= ' ' .AND. i <= 100 ) |
---|
| 263 | i = i + 1 |
---|
| 264 | ENDDO |
---|
| 265 | j = 1 |
---|
| 266 | DO WHILE ( do_mask_user(mid,j) /= ' ' .AND. j <= 100 ) |
---|
| 267 | IF ( i > 100 ) THEN |
---|
[3045] | 268 | WRITE ( message_string, * ) 'number of output quantitities ', & |
---|
| 269 | 'given by data_output_mask and data_output_mask_user ', & |
---|
[298] | 270 | 'exceeds the limit of 100' |
---|
[564] | 271 | CALL message( 'init_masks', 'PA0329', 1, 2, 0, 6, 0 ) |
---|
[298] | 272 | ENDIF |
---|
| 273 | do_mask(mid,i) = do_mask_user(mid,j) |
---|
| 274 | i = i + 1 |
---|
| 275 | j = j + 1 |
---|
| 276 | ENDDO |
---|
| 277 | ENDIF |
---|
| 278 | |
---|
| 279 | ! |
---|
| 280 | !-- Check and set steering parameters for mask data output and averaging |
---|
| 281 | i = 1 |
---|
[996] | 282 | DO WHILE ( do_mask(mid,i) /= ' ' .AND. i <= 100 ) |
---|
[298] | 283 | ! |
---|
| 284 | !-- Check for data averaging |
---|
| 285 | ilen = LEN_TRIM( do_mask(mid,i) ) |
---|
| 286 | j = 0 ! no data averaging |
---|
| 287 | IF ( ilen > 3 ) THEN |
---|
| 288 | IF ( do_mask(mid,i)(ilen-2:ilen) == '_av' ) THEN |
---|
| 289 | j = 1 ! data averaging |
---|
| 290 | do_mask(mid,i) = do_mask(mid,i)(1:ilen-3) |
---|
| 291 | ENDIF |
---|
| 292 | ENDIF |
---|
| 293 | var = TRIM( do_mask(mid,i) ) |
---|
| 294 | ! |
---|
| 295 | !-- Check for allowed value and set units |
---|
| 296 | SELECT CASE ( TRIM( var ) ) |
---|
| 297 | |
---|
| 298 | CASE ( 'e' ) |
---|
| 299 | IF ( constant_diffusion ) THEN |
---|
[3045] | 300 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 301 | '" requires constant_diffusion = .FALSE.' |
---|
[564] | 302 | CALL message( 'init_masks', 'PA0103', 1, 2, 0, 6, 0 ) |
---|
[298] | 303 | ENDIF |
---|
| 304 | unit = 'm2/s2' |
---|
| 305 | |
---|
[771] | 306 | CASE ( 'lpt' ) |
---|
| 307 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 308 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[771] | 309 | '" requires cloud_physics = .TRUE.' |
---|
[773] | 310 | CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
[771] | 311 | ENDIF |
---|
| 312 | unit = 'K' |
---|
| 313 | |
---|
[2292] | 314 | CASE ( 'nc' ) |
---|
| 315 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 316 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[2292] | 317 | '" requires cloud_physics = .TRUE.' |
---|
| 318 | CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
| 319 | ELSEIF ( .NOT. microphysics_morrison ) THEN |
---|
[3045] | 320 | message_string = 'output of "' // TRIM( var ) // '" ' // & |
---|
| 321 | 'requires = morrison' |
---|
[2292] | 322 | CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 ) |
---|
| 323 | ENDIF |
---|
| 324 | unit = '1/m3' |
---|
| 325 | |
---|
[1438] | 326 | CASE ( 'nr' ) |
---|
| 327 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 328 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[1438] | 329 | '" requires cloud_physics = .TRUE.' |
---|
| 330 | CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
[1822] | 331 | ELSEIF ( .NOT. microphysics_seifert ) THEN |
---|
[3045] | 332 | message_string = 'output of "' // TRIM( var ) // '"' // & |
---|
| 333 | 'requires cloud_scheme = seifert_beheng' |
---|
[1438] | 334 | CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 ) |
---|
| 335 | ENDIF |
---|
| 336 | unit = '1/m3' |
---|
| 337 | |
---|
[298] | 338 | CASE ( 'pc', 'pr' ) |
---|
| 339 | IF ( .NOT. particle_advection ) THEN |
---|
[3045] | 340 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
| 341 | '" requires a "particles_par"-NAMELIST in the ', & |
---|
[298] | 342 | 'parameter file (PARIN)' |
---|
[564] | 343 | CALL message( 'init_masks', 'PA0104', 1, 2, 0, 6, 0 ) |
---|
[298] | 344 | ENDIF |
---|
| 345 | IF ( TRIM( var ) == 'pc' ) unit = 'number' |
---|
| 346 | IF ( TRIM( var ) == 'pr' ) unit = 'm' |
---|
| 347 | |
---|
| 348 | CASE ( 'q', 'vpt' ) |
---|
| 349 | IF ( .NOT. humidity ) THEN |
---|
[3045] | 350 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 351 | '" requires humidity = .TRUE.' |
---|
[564] | 352 | CALL message( 'init_masks', 'PA0105', 1, 2, 0, 6, 0 ) |
---|
[298] | 353 | ENDIF |
---|
| 354 | IF ( TRIM( var ) == 'q' ) unit = 'kg/kg' |
---|
| 355 | IF ( TRIM( var ) == 'vpt' ) unit = 'K' |
---|
| 356 | |
---|
[1438] | 357 | CASE ( 'qc' ) |
---|
| 358 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 359 | message_string = 'output of "' // TRIM( var ) // '"' // & |
---|
| 360 | 'requires cloud_physics = .TRUE.' |
---|
[1438] | 361 | CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
| 362 | ENDIF |
---|
| 363 | unit = 'kg/kg' |
---|
| 364 | |
---|
[298] | 365 | CASE ( 'ql' ) |
---|
| 366 | IF ( .NOT. ( cloud_physics .OR. cloud_droplets ) ) THEN |
---|
[3045] | 367 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 368 | '" requires cloud_physics = .TRUE. or cloud_droplets', & |
---|
| 369 | ' = .TRUE.' |
---|
[3045] | 370 | CALL message( 'init_masks', 'PA0106', 1, 2, 0, 6, 0 ) |
---|
[298] | 371 | ENDIF |
---|
| 372 | unit = 'kg/kg' |
---|
| 373 | |
---|
| 374 | CASE ( 'ql_c', 'ql_v', 'ql_vp' ) |
---|
| 375 | IF ( .NOT. cloud_droplets ) THEN |
---|
[3045] | 376 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 377 | '" requires cloud_droplets = .TRUE.' |
---|
[564] | 378 | CALL message( 'init_masks', 'PA0107', 1, 2, 0, 6, 0 ) |
---|
[298] | 379 | ENDIF |
---|
| 380 | IF ( TRIM( var ) == 'ql_c' ) unit = 'kg/kg' |
---|
| 381 | IF ( TRIM( var ) == 'ql_v' ) unit = 'm3' |
---|
| 382 | IF ( TRIM( var ) == 'ql_vp' ) unit = 'none' |
---|
| 383 | |
---|
| 384 | CASE ( 'qv' ) |
---|
| 385 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 386 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 387 | '" requires cloud_physics = .TRUE.' |
---|
[564] | 388 | CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
[298] | 389 | ENDIF |
---|
| 390 | unit = 'kg/kg' |
---|
| 391 | |
---|
[1438] | 392 | CASE ( 'qr' ) |
---|
| 393 | IF ( .NOT. cloud_physics ) THEN |
---|
[3045] | 394 | message_string = 'output of "' // TRIM( var ) // '" ' // & |
---|
| 395 | 'requires cloud_physics = .TRUE.' |
---|
[1438] | 396 | CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 ) |
---|
[1822] | 397 | ELSEIF ( .NOT. microphysics_seifert ) THEN |
---|
[3045] | 398 | message_string = 'output of "' // TRIM( var ) // '" ' // & |
---|
| 399 | 'requires cloud_scheme = seifert_beheng' |
---|
[1438] | 400 | CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 ) |
---|
| 401 | ENDIF |
---|
| 402 | unit = 'kg/kg' |
---|
| 403 | |
---|
[2031] | 404 | CASE ( 'rho_ocean' ) |
---|
[298] | 405 | IF ( .NOT. ocean ) THEN |
---|
[3045] | 406 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 407 | '" requires ocean = .TRUE.' |
---|
[564] | 408 | CALL message( 'init_masks', 'PA0109', 1, 2, 0, 6, 0 ) |
---|
[298] | 409 | ENDIF |
---|
| 410 | unit = 'kg/m3' |
---|
| 411 | |
---|
| 412 | CASE ( 's' ) |
---|
| 413 | IF ( .NOT. passive_scalar ) THEN |
---|
[3045] | 414 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 415 | '" requires passive_scalar = .TRUE.' |
---|
[564] | 416 | CALL message( 'init_masks', 'PA0110', 1, 2, 0, 6, 0 ) |
---|
[298] | 417 | ENDIF |
---|
| 418 | unit = 'conc' |
---|
| 419 | |
---|
| 420 | CASE ( 'sa' ) |
---|
| 421 | IF ( .NOT. ocean ) THEN |
---|
[3045] | 422 | WRITE ( message_string, * ) 'output of "', TRIM( var ), & |
---|
[298] | 423 | '" requires ocean = .TRUE.' |
---|
[564] | 424 | CALL message( 'init_masks', 'PA0109', 1, 2, 0, 6, 0 ) |
---|
[298] | 425 | ENDIF |
---|
| 426 | unit = 'psu' |
---|
| 427 | |
---|
[978] | 428 | CASE ( 'u*', 't*', 'lwp*', 'pra*', 'prr*', 'z0*', 'z0h*' ) |
---|
[3045] | 429 | WRITE ( message_string, * ) 'illegal value for data_', & |
---|
| 430 | 'output: "', TRIM( var ), '" is only allowed', & |
---|
[298] | 431 | 'for horizontal cross section' |
---|
[564] | 432 | CALL message( 'init_masks', 'PA0111', 1, 2, 0, 6, 0 ) |
---|
[298] | 433 | |
---|
| 434 | CASE ( 'p', 'pt', 'u', 'v', 'w' ) |
---|
| 435 | IF ( TRIM( var ) == 'p' ) unit = 'Pa' |
---|
| 436 | IF ( TRIM( var ) == 'pt' ) unit = 'K' |
---|
| 437 | IF ( TRIM( var ) == 'u' ) unit = 'm/s' |
---|
| 438 | IF ( TRIM( var ) == 'v' ) unit = 'm/s' |
---|
| 439 | IF ( TRIM( var ) == 'w' ) unit = 'm/s' |
---|
| 440 | CONTINUE |
---|
| 441 | |
---|
| 442 | CASE DEFAULT |
---|
| 443 | CALL user_check_data_output( var, unit ) |
---|
| 444 | |
---|
| 445 | IF ( unit == 'illegal' ) THEN |
---|
| 446 | IF ( do_mask_user(mid,1) /= ' ' ) THEN |
---|
[3045] | 447 | WRITE ( message_string, * ) 'illegal value for data_', & |
---|
| 448 | 'output_masks or data_output_masks_user: "', & |
---|
[298] | 449 | TRIM( do_mask(mid,i) ), '"' |
---|
[3045] | 450 | CALL message( 'init_masks', 'PA0018', 1, 2, 0, 6, 0 ) |
---|
[298] | 451 | ELSE |
---|
[3045] | 452 | WRITE ( message_string, * ) 'illegal value for data_', & |
---|
| 453 | ' output_masks : "', TRIM( do_mask(mid,i) ), '"' |
---|
[564] | 454 | CALL message( 'init_masks', 'PA0330', 1, 2, 0, 6, 0 ) |
---|
[298] | 455 | ENDIF |
---|
| 456 | ENDIF |
---|
| 457 | |
---|
| 458 | END SELECT |
---|
| 459 | ! |
---|
| 460 | !-- Set the internal steering parameters appropriately |
---|
| 461 | domask_no(mid,j) = domask_no(mid,j) + 1 |
---|
| 462 | domask(mid,j,domask_no(mid,j)) = do_mask(mid,i) |
---|
| 463 | domask_unit(mid,j,domask_no(mid,j)) = unit |
---|
| 464 | |
---|
| 465 | IF ( j == 1 ) THEN |
---|
| 466 | ! |
---|
| 467 | !-- Check, if variable is already subject to averaging |
---|
| 468 | found = .FALSE. |
---|
| 469 | DO k = 1, doav_n |
---|
| 470 | IF ( TRIM( doav(k) ) == TRIM( var ) ) found = .TRUE. |
---|
| 471 | ENDDO |
---|
| 472 | |
---|
| 473 | IF ( .NOT. found ) THEN |
---|
| 474 | doav_n = doav_n + 1 |
---|
| 475 | doav(doav_n) = var |
---|
| 476 | ENDIF |
---|
| 477 | ENDIF |
---|
| 478 | |
---|
| 479 | i = i + 1 |
---|
| 480 | |
---|
| 481 | ENDDO ! do_mask(mid,i) |
---|
| 482 | ENDDO ! mid |
---|
| 483 | |
---|
| 484 | |
---|
| 485 | ! |
---|
| 486 | !-- Determine mask locations for each mask |
---|
| 487 | DO mid = 1, masks |
---|
| 488 | ! |
---|
| 489 | !-- Set local masks for each subdomain along all three dimensions |
---|
| 490 | CALL set_mask_locations( 1, dx, 'dx', nx, 'nx', nxl, nxr ) |
---|
| 491 | CALL set_mask_locations( 2, dy, 'dy', ny, 'ny', nys, nyn ) |
---|
| 492 | CALL set_mask_locations( 3, dz, 'dz', nz, 'nz', nzb, nzt ) |
---|
| 493 | ! |
---|
| 494 | !-- Set global masks along all three dimensions (required by |
---|
| 495 | !-- define_netcdf_header). |
---|
[1804] | 496 | #if defined( __parallel ) |
---|
[298] | 497 | ! |
---|
| 498 | !-- PE0 receives partial arrays from all processors of the respective mask |
---|
| 499 | !-- and outputs them. Here a barrier has to be set, because otherwise |
---|
| 500 | !-- "-MPI- FATAL: Remote protocol queue full" may occur. |
---|
[807] | 501 | |
---|
[298] | 502 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 503 | |
---|
| 504 | IF ( myid == 0 ) THEN |
---|
| 505 | ! |
---|
| 506 | !-- Local arrays can be relocated directly. |
---|
| 507 | mask_i_global(mid,mask_start_l(mid,1): & |
---|
| 508 | mask_start_l(mid,1)+mask_size_l(mid,1)-1) = & |
---|
| 509 | mask_i(mid,:mask_size_l(mid,1)) |
---|
| 510 | mask_j_global(mid,mask_start_l(mid,2): & |
---|
| 511 | mask_start_l(mid,2)+mask_size_l(mid,2)-1) = & |
---|
| 512 | mask_j(mid,:mask_size_l(mid,2)) |
---|
| 513 | mask_k_global(mid,mask_start_l(mid,3): & |
---|
| 514 | mask_start_l(mid,3)+mask_size_l(mid,3)-1) = & |
---|
| 515 | mask_k(mid,:mask_size_l(mid,3)) |
---|
| 516 | ! |
---|
| 517 | !-- Receive data from all other PEs. |
---|
| 518 | DO n = 1, numprocs-1 |
---|
| 519 | ! |
---|
| 520 | !-- Receive index limits first, then arrays. |
---|
| 521 | !-- Index limits are received in arbitrary order from the PEs. |
---|
| 522 | CALL MPI_RECV( ind(1), 6, MPI_INTEGER, MPI_ANY_SOURCE, 0, & |
---|
| 523 | comm2d, status, ierr ) |
---|
| 524 | ! |
---|
| 525 | !-- Not all PEs have data for the mask. |
---|
| 526 | IF ( ind(1) /= -9999 ) THEN |
---|
| 527 | sender = status(MPI_SOURCE) |
---|
| 528 | CALL MPI_RECV( tmp_array(ind(1)), ind(2)-ind(1)+1, & |
---|
[363] | 529 | MPI_INTEGER, sender, 1, comm2d, status, ierr ) |
---|
[298] | 530 | mask_i_global(mid,ind(1):ind(2)) = tmp_array(ind(1):ind(2)) |
---|
| 531 | CALL MPI_RECV( tmp_array(ind(3)), ind(4)-ind(3)+1, & |
---|
[363] | 532 | MPI_INTEGER, sender, 2, comm2d, status, ierr ) |
---|
[298] | 533 | mask_j_global(mid,ind(3):ind(4)) = tmp_array(ind(3):ind(4)) |
---|
| 534 | CALL MPI_RECV( tmp_array(ind(5)), ind(6)-ind(5)+1, & |
---|
[363] | 535 | MPI_INTEGER, sender, 3, comm2d, status, ierr ) |
---|
[298] | 536 | mask_k_global(mid,ind(5):ind(6)) = tmp_array(ind(5):ind(6)) |
---|
| 537 | ENDIF |
---|
| 538 | ENDDO |
---|
| 539 | |
---|
| 540 | ELSE |
---|
| 541 | ! |
---|
| 542 | !-- If at least part of the mask resides on the PE, send the index limits |
---|
| 543 | !-- for the target array, otherwise send -9999 to PE0. |
---|
[996] | 544 | IF ( mask_size_l(mid,1) > 0 .AND. mask_size_l(mid,2) > 0 .AND. & |
---|
| 545 | mask_size_l(mid,3) > 0 ) THEN |
---|
[298] | 546 | ind(1) = mask_start_l(mid,1) |
---|
| 547 | ind(2) = mask_start_l(mid,1) + mask_size_l(mid,1) - 1 |
---|
| 548 | ind(3) = mask_start_l(mid,2) |
---|
| 549 | ind(4) = mask_start_l(mid,2) + mask_size_l(mid,2) - 1 |
---|
| 550 | ind(5) = mask_start_l(mid,3) |
---|
| 551 | ind(6) = mask_start_l(mid,3) + mask_size_l(mid,3) - 1 |
---|
| 552 | ELSE |
---|
| 553 | ind(1) = -9999; ind(2) = -9999 |
---|
| 554 | ind(3) = -9999; ind(4) = -9999 |
---|
| 555 | ind(5) = -9999; ind(6) = -9999 |
---|
| 556 | ENDIF |
---|
| 557 | CALL MPI_SEND( ind(1), 6, MPI_INTEGER, 0, 0, comm2d, ierr ) |
---|
| 558 | ! |
---|
| 559 | !-- If applicable, send data to PE0. |
---|
| 560 | IF ( ind(1) /= -9999 ) THEN |
---|
| 561 | tmp_array(:mask_size_l(mid,1)) = mask_i(mid,:mask_size_l(mid,1)) |
---|
| 562 | CALL MPI_SEND( tmp_array(1), mask_size_l(mid,1), & |
---|
[363] | 563 | MPI_INTEGER, 0, 1, comm2d, ierr ) |
---|
[298] | 564 | tmp_array(:mask_size_l(mid,2)) = mask_j(mid,:mask_size_l(mid,2)) |
---|
| 565 | CALL MPI_SEND( tmp_array(1), mask_size_l(mid,2), & |
---|
[363] | 566 | MPI_INTEGER, 0, 2, comm2d, ierr ) |
---|
[298] | 567 | tmp_array(:mask_size_l(mid,3)) = mask_k(mid,:mask_size_l(mid,3)) |
---|
| 568 | CALL MPI_SEND( tmp_array(1), mask_size_l(mid,3), & |
---|
[363] | 569 | MPI_INTEGER, 0, 3, comm2d, ierr ) |
---|
[298] | 570 | ENDIF |
---|
| 571 | ENDIF |
---|
| 572 | ! |
---|
| 573 | !-- A barrier has to be set, because otherwise some PEs may proceed too fast |
---|
| 574 | !-- so that PE0 may receive wrong data on tag 0. |
---|
| 575 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[409] | 576 | |
---|
[1031] | 577 | IF ( netcdf_data_format > 4 ) THEN |
---|
[409] | 578 | |
---|
[1414] | 579 | CALL MPI_BCAST( mask_i_global(mid,:), nx+2, MPI_INTEGER, 0, comm2d, & |
---|
[493] | 580 | ierr ) |
---|
[1414] | 581 | CALL MPI_BCAST( mask_j_global(mid,:), ny+2, MPI_INTEGER, 0, comm2d, & |
---|
[493] | 582 | ierr ) |
---|
[1414] | 583 | CALL MPI_BCAST( mask_k_global(mid,:), nz+2, MPI_INTEGER, 0, comm2d, & |
---|
[493] | 584 | ierr ) |
---|
[1682] | 585 | |
---|
[409] | 586 | ENDIF |
---|
[298] | 587 | |
---|
[1804] | 588 | #else |
---|
[298] | 589 | ! |
---|
| 590 | !-- Local arrays can be relocated directly. |
---|
| 591 | mask_i_global(mid,:) = mask_i(mid,:) |
---|
| 592 | mask_j_global(mid,:) = mask_j(mid,:) |
---|
| 593 | mask_k_global(mid,:) = mask_k(mid,:) |
---|
| 594 | #endif |
---|
| 595 | ENDDO ! mid |
---|
| 596 | |
---|
| 597 | DEALLOCATE( tmp_array ) |
---|
| 598 | ! |
---|
| 599 | !-- Internal mask arrays cannot be deallocated on PE 0 because they are |
---|
| 600 | !-- required for header output on PE 0. |
---|
| 601 | IF ( myid /= 0 ) DEALLOCATE( mask, mask_loop ) |
---|
| 602 | |
---|
| 603 | CONTAINS |
---|
[493] | 604 | |
---|
[298] | 605 | !------------------------------------------------------------------------------! |
---|
| 606 | ! Description: |
---|
| 607 | ! ------------ |
---|
[1682] | 608 | !> Set local mask for each subdomain along 'dim' direction. |
---|
[298] | 609 | !------------------------------------------------------------------------------! |
---|
[1682] | 610 | SUBROUTINE set_mask_locations( dim, dxyz, dxyz_string, nxyz, nxyz_string, & |
---|
| 611 | lb, ub ) |
---|
[298] | 612 | |
---|
| 613 | IMPLICIT NONE |
---|
| 614 | |
---|
[1682] | 615 | CHARACTER (LEN=2) :: dxyz_string !< |
---|
| 616 | CHARACTER (LEN=2) :: nxyz_string !< |
---|
[1320] | 617 | |
---|
[1682] | 618 | INTEGER(iwp) :: count !< |
---|
| 619 | INTEGER(iwp) :: count_l !< |
---|
| 620 | INTEGER(iwp) :: dim !< |
---|
| 621 | INTEGER(iwp) :: m !< |
---|
| 622 | INTEGER(iwp) :: loop_begin !< |
---|
| 623 | INTEGER(iwp) :: loop_end !< |
---|
| 624 | INTEGER(iwp) :: loop_stride !< |
---|
| 625 | INTEGER(iwp) :: lb !< |
---|
| 626 | INTEGER(iwp) :: nxyz !< |
---|
| 627 | INTEGER(iwp) :: ub !< |
---|
[1320] | 628 | |
---|
[1682] | 629 | REAL(wp) :: dxyz !< |
---|
| 630 | REAL(wp) :: ddxyz !< |
---|
| 631 | REAL(wp) :: tmp1 !< |
---|
| 632 | REAL(wp) :: tmp2 !< |
---|
[298] | 633 | |
---|
[1353] | 634 | count = 0; count_l = 0 |
---|
| 635 | ddxyz = 1.0_wp / dxyz |
---|
| 636 | tmp1 = 0.0_wp |
---|
| 637 | tmp2 = 0.0_wp |
---|
[298] | 638 | |
---|
[1353] | 639 | IF ( mask(mid,dim,1) >= 0.0_wp ) THEN |
---|
[298] | 640 | ! |
---|
| 641 | !-- use predefined mask_* array |
---|
[1353] | 642 | DO WHILE ( mask(mid,dim,count+1) >= 0.0_wp ) |
---|
[298] | 643 | count = count + 1 |
---|
| 644 | IF ( dim == 1 .OR. dim == 2 ) THEN |
---|
[1353] | 645 | m = NINT( mask(mid,dim,count) * mask_scale(dim) * ddxyz - 0.5_wp ) |
---|
[1414] | 646 | IF ( m < 0 ) m = 0 ! avoid negative values |
---|
[298] | 647 | ELSEIF ( dim == 3 ) THEN |
---|
| 648 | ind_array = & |
---|
[595] | 649 | MINLOC( ABS( mask(mid,dim,count) * mask_scale(dim) - zu ) ) |
---|
[298] | 650 | m = ind_array(1) - 1 + nzb ! MINLOC uses lower array bound 1 |
---|
| 651 | ENDIF |
---|
[1414] | 652 | IF ( m > (nxyz+1) ) THEN |
---|
[3045] | 653 | WRITE ( message_string, '(I3,A,I3,A,I1,3A,I3)' ) & |
---|
| 654 | m,' in mask ',mid,' along dimension ',dim, & |
---|
[1414] | 655 | ' exceeds (',nxyz_string,'+1) = ',nxyz+1 |
---|
[564] | 656 | CALL message( 'init_masks', 'PA0331', 1, 2, 0, 6, 0 ) |
---|
[298] | 657 | ENDIF |
---|
[1414] | 658 | IF ( ( m >= lb .AND. m <= ub ) .OR. & |
---|
| 659 | ( m == (nxyz+1) .AND. ub == nxyz ) ) THEN |
---|
[298] | 660 | IF ( count_l == 0 ) mask_start_l(mid,dim) = count |
---|
| 661 | count_l = count_l + 1 |
---|
| 662 | IF ( dim == 1 ) THEN |
---|
| 663 | mask_i(mid,count_l) = m |
---|
| 664 | ELSEIF ( dim == 2 ) THEN |
---|
| 665 | mask_j(mid,count_l) = m |
---|
| 666 | ELSEIF ( dim == 3 ) THEN |
---|
| 667 | mask_k(mid,count_l) = m |
---|
| 668 | ENDIF |
---|
| 669 | ENDIF |
---|
| 670 | IF ( count == mask_xyz_dimension ) EXIT |
---|
| 671 | ENDDO |
---|
| 672 | mask_size(mid,dim) = count |
---|
| 673 | mask_size_l(mid,dim) = count_l |
---|
| 674 | |
---|
| 675 | ELSE |
---|
| 676 | ! |
---|
| 677 | !-- use predefined mask_loop_* array, or use the default (all grid points |
---|
| 678 | !-- along this direction) |
---|
[1353] | 679 | IF ( mask_loop(mid,dim,1) < 0.0_wp ) THEN |
---|
[298] | 680 | tmp1 = mask_loop(mid,dim,1) |
---|
[1186] | 681 | mask_loop(mid,dim,1) = zw(nzb) ! lowest level (default) |
---|
[298] | 682 | ENDIF |
---|
| 683 | IF ( dim == 1 .OR. dim == 2 ) THEN |
---|
[1353] | 684 | IF ( mask_loop(mid,dim,2) < 0.0_wp ) THEN |
---|
[298] | 685 | tmp2 = mask_loop(mid,dim,2) |
---|
[1414] | 686 | mask_loop(mid,dim,2) = (nxyz+1)*dxyz / mask_scale(dim) ! (default) |
---|
[298] | 687 | ENDIF |
---|
| 688 | IF ( MAXVAL( mask_loop(mid,dim,1:2) ) & |
---|
[1414] | 689 | > (nxyz+1) * dxyz / mask_scale(dim) ) THEN |
---|
[303] | 690 | WRITE ( message_string, '(2(A,I3,A,I1,A,F9.3),5A,I1,A,F9.3)' ) & |
---|
[3045] | 691 | 'mask_loop(',mid,',',dim,',1)=',mask_loop(mid,dim,1), & |
---|
[303] | 692 | ' and/or mask_loop(',mid,',',dim,',2)=', & |
---|
[3045] | 693 | mask_loop(mid,dim,2),' exceed (', & |
---|
| 694 | nxyz_string,'+1)*',dxyz_string,'/mask_scale(',dim,')=', & |
---|
[1414] | 695 | (nxyz+1)*dxyz/mask_scale(dim) |
---|
[564] | 696 | CALL message( 'init_masks', 'PA0332', 1, 2, 0, 6, 0 ) |
---|
[298] | 697 | ENDIF |
---|
[3045] | 698 | loop_begin = NINT( mask_loop(mid,dim,1) * mask_scale(dim) & |
---|
[1353] | 699 | * ddxyz - 0.5_wp ) |
---|
[3045] | 700 | loop_end = NINT( mask_loop(mid,dim,2) * mask_scale(dim) & |
---|
[1353] | 701 | * ddxyz - 0.5_wp ) |
---|
[3045] | 702 | loop_stride = NINT( mask_loop(mid,dim,3) * mask_scale(dim) & |
---|
[1032] | 703 | * ddxyz ) |
---|
[1414] | 704 | IF ( loop_begin == -1 ) loop_begin = 0 ! avoid negative values |
---|
[298] | 705 | ELSEIF ( dim == 3 ) THEN |
---|
[1353] | 706 | IF ( mask_loop(mid,dim,2) < 0.0_wp ) THEN |
---|
[298] | 707 | tmp2 = mask_loop(mid,dim,2) |
---|
[1414] | 708 | mask_loop(mid,dim,2) = zu(nz+1) / mask_scale(dim) ! (default) |
---|
[298] | 709 | ENDIF |
---|
| 710 | IF ( MAXVAL( mask_loop(mid,dim,1:2) ) & |
---|
[1414] | 711 | > zu(nz+1) / mask_scale(dim) ) THEN |
---|
[3045] | 712 | WRITE ( message_string, '(2(A,I3,A,I1,A,F9.3),A,I1,A,F9.3)' ) & |
---|
| 713 | 'mask_loop(',mid,',',dim,',1)=',mask_loop(mid,dim,1), & |
---|
[303] | 714 | ' and/or mask_loop(',mid,',',dim,',2)=', & |
---|
[3045] | 715 | mask_loop(mid,dim,2),' exceed zu(nz+1)/mask_scale(',dim, & |
---|
[1414] | 716 | ')=',zu(nz+1)/mask_scale(dim) |
---|
[564] | 717 | CALL message( 'init_masks', 'PA0333', 1, 2, 0, 6, 0 ) |
---|
[298] | 718 | ENDIF |
---|
[303] | 719 | ind_array = & |
---|
[595] | 720 | MINLOC( ABS( mask_loop(mid,dim,1) * mask_scale(dim) - zu ) ) |
---|
[298] | 721 | loop_begin = & |
---|
[303] | 722 | ind_array(1) - 1 + nzb ! MINLOC uses lower array bound 1 |
---|
| 723 | ind_array = & |
---|
[595] | 724 | MINLOC( ABS( mask_loop(mid,dim,2) * mask_scale(dim) - zu ) ) |
---|
[298] | 725 | loop_end = ind_array(1) - 1 + nzb ! MINLOC uses lower array bound 1 |
---|
| 726 | ! |
---|
[303] | 727 | !-- The following line assumes a constant vertical grid spacing within |
---|
| 728 | !-- the vertical mask range; it fails for vertical grid stretching. |
---|
| 729 | !-- Maybe revise later. Issue warning but continue execution. |
---|
| 730 | loop_stride = NINT( mask_loop(mid,dim,3) * mask_scale(dim) * ddxyz ) |
---|
| 731 | |
---|
| 732 | IF ( mask_loop(mid,dim,2) * mask_scale(dim) > dz_stretch_level ) & |
---|
| 733 | THEN |
---|
[3045] | 734 | WRITE ( message_string, '(A,I3,A,I1,A,F9.3,A,F8.2,3A)' ) & |
---|
| 735 | 'mask_loop(',mid,',',dim,',2)=', mask_loop(mid,dim,2), & |
---|
| 736 | ' exceeds dz_stretch_level=',dz_stretch_level, & |
---|
[3046] | 737 | '.&Vertical mask locations will not ', & |
---|
[3045] | 738 | 'match the desired heights within the stretching ', & |
---|
[2271] | 739 | 'region.' |
---|
[564] | 740 | CALL message( 'init_masks', 'PA0334', 0, 1, 0, 6, 0 ) |
---|
[303] | 741 | ENDIF |
---|
| 742 | |
---|
[298] | 743 | ENDIF |
---|
| 744 | ! |
---|
| 745 | !-- If necessary, reset mask_loop(mid,dim,1) and mask_loop(mid,dim,2). |
---|
[1353] | 746 | IF ( tmp1 < 0.0_wp ) mask_loop(mid,dim,1) = tmp1 |
---|
| 747 | IF ( tmp2 < 0.0_wp ) mask_loop(mid,dim,2) = tmp2 |
---|
[298] | 748 | ! |
---|
| 749 | !-- The default stride +/-1 (every grid point) applies if |
---|
| 750 | !-- mask_loop(mid,dim,3) is not specified (its default is zero). |
---|
| 751 | IF ( loop_stride == 0 ) THEN |
---|
| 752 | IF ( loop_end >= loop_begin ) THEN |
---|
| 753 | loop_stride = 1 |
---|
| 754 | ELSE |
---|
| 755 | loop_stride = -1 |
---|
| 756 | ENDIF |
---|
| 757 | ENDIF |
---|
| 758 | DO m = loop_begin, loop_end, loop_stride |
---|
| 759 | count = count + 1 |
---|
[1414] | 760 | IF ( ( m >= lb .AND. m <= ub ) .OR. & |
---|
| 761 | ( m == (nxyz+1) .AND. ub == nxyz ) ) THEN |
---|
[298] | 762 | IF ( count_l == 0 ) mask_start_l(mid,dim) = count |
---|
| 763 | count_l = count_l + 1 |
---|
| 764 | IF ( dim == 1 ) THEN |
---|
| 765 | mask_i(mid,count_l) = m |
---|
| 766 | ELSEIF ( dim == 2 ) THEN |
---|
| 767 | mask_j(mid,count_l) = m |
---|
| 768 | ELSEIF ( dim == 3 ) THEN |
---|
| 769 | mask_k(mid,count_l) = m |
---|
| 770 | ENDIF |
---|
| 771 | ENDIF |
---|
| 772 | ENDDO |
---|
| 773 | mask_size(mid,dim) = count |
---|
| 774 | mask_size_l(mid,dim) = count_l |
---|
[1414] | 775 | |
---|
[298] | 776 | ENDIF |
---|
| 777 | |
---|
| 778 | END SUBROUTINE set_mask_locations |
---|
| 779 | |
---|
| 780 | END SUBROUTINE init_masks |
---|