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