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