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