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