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