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