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