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