1 | !> @file init_3d_model.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
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-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: init_3d_model.f90 2339 2017-08-07 13:55:26Z Giersch $ |
---|
27 | ! corrected timestamp in header |
---|
28 | ! |
---|
29 | ! 2338 2017-08-07 12:15:38Z gronemeier |
---|
30 | ! Modularize 1D model |
---|
31 | ! |
---|
32 | ! 2329 2017-08-03 14:24:56Z knoop |
---|
33 | ! Removed temporary bugfix (r2327) as bug is properly resolved by this revision |
---|
34 | ! |
---|
35 | ! 2327 2017-08-02 07:40:57Z maronga |
---|
36 | ! Temporary bugfix |
---|
37 | ! |
---|
38 | ! 2320 2017-07-21 12:47:43Z suehring |
---|
39 | ! Modularize large-scale forcing and nudging |
---|
40 | ! |
---|
41 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
42 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
43 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
44 | ! and cloud water content (qc). |
---|
45 | ! |
---|
46 | ! 2277 2017-06-12 10:47:51Z kanani |
---|
47 | ! Removed unused variable sums_up_fraction_l |
---|
48 | ! |
---|
49 | ! 2270 2017-06-09 12:18:47Z maronga |
---|
50 | ! dots_num must be increased when LSM and/or radiation is used |
---|
51 | ! |
---|
52 | ! 2259 2017-06-08 09:09:11Z gronemeier |
---|
53 | ! Implemented synthetic turbulence generator |
---|
54 | ! |
---|
55 | ! 2252 2017-06-07 09:35:37Z knoop |
---|
56 | ! rho_air now depending on surface_pressure even in Boussinesq mode |
---|
57 | ! |
---|
58 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
59 | ! |
---|
60 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
61 | ! Adjustments to new topography and surface concept: |
---|
62 | ! - Modify passed parameters for disturb_field |
---|
63 | ! - Topography representation via flags |
---|
64 | ! - Remove unused arrays. |
---|
65 | ! - Move initialization of surface-related quantities to surface_mod |
---|
66 | ! |
---|
67 | ! 2172 2017-03-08 15:55:25Z knoop |
---|
68 | ! Bugfix: moved parallel random generator initialization into its module |
---|
69 | ! |
---|
70 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
71 | ! OpenACC directives removed |
---|
72 | ! |
---|
73 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
74 | ! Anelastic approximation implemented |
---|
75 | ! |
---|
76 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
77 | ! renamed variable rho to rho_ocean |
---|
78 | ! |
---|
79 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
80 | ! Flag urban_surface is now defined in module control_parameters. |
---|
81 | ! |
---|
82 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
83 | ! Added support for urban surface model, |
---|
84 | ! adjusted location_message in case of plant_canopy |
---|
85 | ! |
---|
86 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
87 | ! Forced header and separation lines into 80 columns |
---|
88 | ! |
---|
89 | ! 1992 2016-08-12 15:14:59Z suehring |
---|
90 | ! Initializaton of scalarflux at model top |
---|
91 | ! Bugfixes in initialization of surface and top salinity flux, top scalar and |
---|
92 | ! humidity fluxes |
---|
93 | ! |
---|
94 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
95 | ! Separate humidity and passive scalar |
---|
96 | ! Increase dimension for mean_inflow_profiles |
---|
97 | ! Remove inadvertent write-statement |
---|
98 | ! Bugfix, large-scale forcing is still not implemented for passive scalars |
---|
99 | ! |
---|
100 | ! 1957 2016-07-07 10:43:48Z suehring |
---|
101 | ! flight module added |
---|
102 | ! |
---|
103 | ! 1920 2016-05-30 10:50:15Z suehring |
---|
104 | ! Initialize us with very small number to avoid segmentation fault during |
---|
105 | ! calculation of Obukhov length |
---|
106 | ! |
---|
107 | ! 1918 2016-05-27 14:35:57Z raasch |
---|
108 | ! intermediate_timestep_count is set 0 instead 1 for first call of pres, |
---|
109 | ! bugfix: initialization of local sum arrays are moved to the beginning of the |
---|
110 | ! routine because otherwise results from pres are overwritten |
---|
111 | ! |
---|
112 | ! 1914 2016-05-26 14:44:07Z witha |
---|
113 | ! Added initialization of the wind turbine model |
---|
114 | ! |
---|
115 | ! 1878 2016-04-19 12:30:36Z hellstea |
---|
116 | ! The zeroth element of weight_pres removed as unnecessary |
---|
117 | ! |
---|
118 | ! 1849 2016-04-08 11:33:18Z hoffmann |
---|
119 | ! Adapted for modularization of microphysics. |
---|
120 | ! precipitation_amount, precipitation_rate, prr moved to arrays_3d. |
---|
121 | ! Initialization of nc_1d, nr_1d, pt_1d, qc_1d, qr_1d, q_1d moved to |
---|
122 | ! microphysics_init. |
---|
123 | ! |
---|
124 | ! 1845 2016-04-08 08:29:13Z raasch |
---|
125 | ! nzb_2d replaced by nzb_u|v_inner |
---|
126 | ! |
---|
127 | ! 1833 2016-04-07 14:23:03Z raasch |
---|
128 | ! initialization of spectra quantities moved to spectra_mod |
---|
129 | ! |
---|
130 | ! 1831 2016-04-07 13:15:51Z hoffmann |
---|
131 | ! turbulence renamed collision_turbulence |
---|
132 | ! |
---|
133 | ! 1826 2016-04-07 12:01:39Z maronga |
---|
134 | ! Renamed radiation calls. |
---|
135 | ! Renamed canopy model calls. |
---|
136 | ! |
---|
137 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
138 | ! icloud_scheme replaced by microphysics_* |
---|
139 | ! |
---|
140 | ! 1817 2016-04-06 15:44:20Z maronga |
---|
141 | ! Renamed lsm calls. |
---|
142 | ! |
---|
143 | ! 1815 2016-04-06 13:49:59Z raasch |
---|
144 | ! zero-settings for velocities inside topography re-activated (was deactivated |
---|
145 | ! in r1762) |
---|
146 | ! |
---|
147 | ! 1788 2016-03-10 11:01:04Z maronga |
---|
148 | ! Added z0q. |
---|
149 | ! Syntax layout improved. |
---|
150 | ! |
---|
151 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
152 | ! netcdf module name changed + related changes |
---|
153 | ! |
---|
154 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
155 | ! bugfix: increase size of volume_flow_area_l and volume_flow_initial_l by 1 |
---|
156 | ! |
---|
157 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
158 | ! Introduction of nested domain feature |
---|
159 | ! |
---|
160 | ! 1738 2015-12-18 13:56:05Z raasch |
---|
161 | ! calculate mean surface level height for each statistic region |
---|
162 | ! |
---|
163 | ! 1734 2015-12-02 12:17:12Z raasch |
---|
164 | ! no initial disturbances in case that the disturbance energy limit has been |
---|
165 | ! set zero |
---|
166 | ! |
---|
167 | ! 1707 2015-11-02 15:24:52Z maronga |
---|
168 | ! Bugfix: transfer of Richardson number from 1D model to Obukhov length caused |
---|
169 | ! devision by zero in neutral stratification |
---|
170 | ! |
---|
171 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
172 | ! Call to init_surface_layer added. rif is replaced by ol and zeta. |
---|
173 | ! |
---|
174 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
175 | ! Code annotations made doxygen readable |
---|
176 | ! |
---|
177 | ! 1615 2015-07-08 18:49:19Z suehring |
---|
178 | ! Enable turbulent inflow for passive_scalar and humidity |
---|
179 | ! |
---|
180 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
181 | ! Initialization of radiation code is now done after LSM initializtion |
---|
182 | ! |
---|
183 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
184 | ! adjustments for psolver-queries |
---|
185 | ! |
---|
186 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
187 | ! Allocation of land surface arrays is now done in the subroutine lsm_init_arrays, |
---|
188 | ! which is part of land_surface_model. |
---|
189 | ! |
---|
190 | ! 1507 2014-12-10 12:14:18Z suehring |
---|
191 | ! Bugfix: set horizontal velocity components to zero inside topography |
---|
192 | ! |
---|
193 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
194 | ! Added initialization of the land surface and radiation schemes |
---|
195 | ! |
---|
196 | ! 1484 2014-10-21 10:53:05Z kanani |
---|
197 | ! Changes due to new module structure of the plant canopy model: |
---|
198 | ! canopy-related initialization (e.g. lad and canopy_heat_flux) moved to new |
---|
199 | ! subroutine init_plant_canopy within the module plant_canopy_model_mod, |
---|
200 | ! call of subroutine init_plant_canopy added. |
---|
201 | ! |
---|
202 | ! 1431 2014-07-15 14:47:17Z suehring |
---|
203 | ! var_d added, in order to normalize spectra. |
---|
204 | ! |
---|
205 | ! 1429 2014-07-15 12:53:45Z knoop |
---|
206 | ! Ensemble run capability added to parallel random number generator |
---|
207 | ! |
---|
208 | ! 1411 2014-05-16 18:01:51Z suehring |
---|
209 | ! Initial horizontal velocity profiles were not set to zero at the first vertical |
---|
210 | ! grid level in case of non-cyclic lateral boundary conditions. |
---|
211 | ! |
---|
212 | ! 1406 2014-05-16 13:47:01Z raasch |
---|
213 | ! bugfix: setting of initial velocities at k=1 to zero not in case of a |
---|
214 | ! no-slip boundary condition for uv |
---|
215 | ! |
---|
216 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
217 | ! location messages modified |
---|
218 | ! |
---|
219 | ! 1400 2014-05-09 14:03:54Z knoop |
---|
220 | ! Parallel random number generator added |
---|
221 | ! |
---|
222 | ! 1384 2014-05-02 14:31:06Z raasch |
---|
223 | ! location messages added |
---|
224 | ! |
---|
225 | ! 1361 2014-04-16 15:17:48Z hoffmann |
---|
226 | ! tend_* removed |
---|
227 | ! Bugfix: w_subs is not allocated anymore if it is already allocated |
---|
228 | ! |
---|
229 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
230 | ! module lpm_init_mod added to use statements, because lpm_init has become a |
---|
231 | ! module |
---|
232 | ! |
---|
233 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
234 | ! REAL constants provided with KIND-attribute |
---|
235 | ! |
---|
236 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
237 | ! REAL constants defined as wp-kind |
---|
238 | ! |
---|
239 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
240 | ! REAL constants defined as wp-kind |
---|
241 | ! module interfaces removed |
---|
242 | ! |
---|
243 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
244 | ! ONLY-attribute added to USE-statements, |
---|
245 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
246 | ! kinds are defined in new module kinds, |
---|
247 | ! revision history before 2012 removed, |
---|
248 | ! comment fields (!:) to be used for variable explanations added to |
---|
249 | ! all variable declaration statements |
---|
250 | ! |
---|
251 | ! 1316 2014-03-17 07:44:59Z heinze |
---|
252 | ! Bugfix: allocation of w_subs |
---|
253 | ! |
---|
254 | ! 1299 2014-03-06 13:15:21Z heinze |
---|
255 | ! Allocate w_subs due to extension of large scale subsidence in combination |
---|
256 | ! with large scale forcing data (LSF_DATA) |
---|
257 | ! |
---|
258 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
259 | ! Overwrite initial profiles in case of nudging |
---|
260 | ! Inititialize shf and qsws in case of large_scale_forcing |
---|
261 | ! |
---|
262 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
263 | ! +rflags_s_inner in copyin statement, use copyin for most arrays instead of |
---|
264 | ! copy |
---|
265 | ! |
---|
266 | ! 1212 2013-08-15 08:46:27Z raasch |
---|
267 | ! array tri is allocated and included in data copy statement |
---|
268 | ! |
---|
269 | ! 1195 2013-07-01 12:27:57Z heinze |
---|
270 | ! Bugfix: move allocation of ref_state to parin.f90 and read_var_list.f90 |
---|
271 | ! |
---|
272 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
273 | ! allocate and set ref_state to be used in buoyancy terms |
---|
274 | ! |
---|
275 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
276 | ! diss array is allocated with full size if accelerator boards are used |
---|
277 | ! |
---|
278 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
279 | ! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir |
---|
280 | ! |
---|
281 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
282 | ! diss array is allocated with dummy elements even if it is not needed |
---|
283 | ! (required by PGI 13.4 / CUDA 5.0) |
---|
284 | ! |
---|
285 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
286 | ! unused variables removed |
---|
287 | ! |
---|
288 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
289 | ! openACC directive modified |
---|
290 | ! |
---|
291 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
292 | ! openACC directives added for pres |
---|
293 | ! array diss allocated only if required |
---|
294 | ! |
---|
295 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
296 | ! unused variables removed |
---|
297 | ! |
---|
298 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
299 | ! allocation of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
300 | ! |
---|
301 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
302 | ! allocation and initialisation of necessary data arrays for the two-moment |
---|
303 | ! cloud physics scheme the two new prognostic equations (nr, qr): |
---|
304 | ! +dr, lambda_r, mu_r, sed_*, xr, *s, *sws, *swst, *, *_p, t*_m, *_1, *_2, *_3, |
---|
305 | ! +tend_*, prr |
---|
306 | ! |
---|
307 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
308 | ! code put under GPL (PALM 3.9) |
---|
309 | ! |
---|
310 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
311 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
312 | ! |
---|
313 | ! 1025 2012-10-07 16:04:41Z letzel |
---|
314 | ! bugfix: swap indices of mask for ghost boundaries |
---|
315 | ! |
---|
316 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
317 | ! mask is set to zero for ghost boundaries |
---|
318 | ! |
---|
319 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
320 | ! cpp switch __nopointer added for pointer free version |
---|
321 | ! |
---|
322 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
323 | ! nxra,nyna, nzta replaced ny nxr, nyn, nzt |
---|
324 | ! |
---|
325 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
326 | ! all actions concerning leapfrog scheme removed |
---|
327 | ! |
---|
328 | ! 996 2012-09-07 10:41:47Z raasch |
---|
329 | ! little reformatting |
---|
330 | ! |
---|
331 | ! 978 2012-08-09 08:28:32Z fricke |
---|
332 | ! outflow damping layer removed |
---|
333 | ! roughness length for scalar quantites z0h added |
---|
334 | ! damping zone for the potential temperatur in case of non-cyclic lateral |
---|
335 | ! boundaries added |
---|
336 | ! initialization of ptdf_x, ptdf_y |
---|
337 | ! initialization of c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l |
---|
338 | ! |
---|
339 | ! 849 2012-03-15 10:35:09Z raasch |
---|
340 | ! init_particles renamed lpm_init |
---|
341 | ! |
---|
342 | ! 825 2012-02-19 03:03:44Z raasch |
---|
343 | ! wang_collision_kernel renamed wang_kernel |
---|
344 | ! |
---|
345 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
346 | ! Initial revision |
---|
347 | ! |
---|
348 | ! |
---|
349 | ! Description: |
---|
350 | ! ------------ |
---|
351 | !> Allocation of arrays and initialization of the 3D model via |
---|
352 | !> a) pre-run the 1D model |
---|
353 | !> or |
---|
354 | !> b) pre-set constant linear profiles |
---|
355 | !> or |
---|
356 | !> c) read values of a previous run |
---|
357 | !------------------------------------------------------------------------------! |
---|
358 | SUBROUTINE init_3d_model |
---|
359 | |
---|
360 | |
---|
361 | USE advec_ws |
---|
362 | |
---|
363 | USE arrays_3d |
---|
364 | |
---|
365 | USE cloud_parameters, & |
---|
366 | ONLY: cp, l_v, r_d |
---|
367 | |
---|
368 | USE constants, & |
---|
369 | ONLY: pi |
---|
370 | |
---|
371 | USE control_parameters |
---|
372 | |
---|
373 | USE flight_mod, & |
---|
374 | ONLY: flight_init |
---|
375 | |
---|
376 | USE grid_variables, & |
---|
377 | ONLY: dx, dy, ddx2_mg, ddy2_mg |
---|
378 | |
---|
379 | USE indices |
---|
380 | |
---|
381 | USE lpm_init_mod, & |
---|
382 | ONLY: lpm_init |
---|
383 | |
---|
384 | USE kinds |
---|
385 | |
---|
386 | USE land_surface_model_mod, & |
---|
387 | ONLY: lsm_init, lsm_init_arrays |
---|
388 | |
---|
389 | USE lsf_nudging_mod, & |
---|
390 | ONLY: lsf_init, ls_forcing_surf, nudge_init |
---|
391 | |
---|
392 | USE microphysics_mod, & |
---|
393 | ONLY: collision_turbulence, microphysics_init |
---|
394 | |
---|
395 | USE model_1d_mod, & |
---|
396 | ONLY: e1d, init_1d_model, kh1d, km1d, l1d, rif1d, u1d, us1d, usws1d, & |
---|
397 | v1d, vsws1d |
---|
398 | |
---|
399 | USE netcdf_interface, & |
---|
400 | ONLY: dots_max, dots_num |
---|
401 | |
---|
402 | USE particle_attributes, & |
---|
403 | ONLY: particle_advection, use_sgs_for_particles, wang_kernel |
---|
404 | |
---|
405 | USE pegrid |
---|
406 | |
---|
407 | USE plant_canopy_model_mod, & |
---|
408 | ONLY: pcm_init, plant_canopy |
---|
409 | |
---|
410 | USE radiation_model_mod, & |
---|
411 | ONLY: radiation_init, radiation, radiation_scheme |
---|
412 | |
---|
413 | USE random_function_mod |
---|
414 | |
---|
415 | USE random_generator_parallel, & |
---|
416 | ONLY: init_parallel_random_generator |
---|
417 | |
---|
418 | USE statistics, & |
---|
419 | ONLY: hom, hom_sum, mean_surface_level_height, pr_palm, rmask, & |
---|
420 | statistic_regions, sums, sums_divnew_l, sums_divold_l, sums_l, & |
---|
421 | sums_l_l, sums_wsts_bc_l, ts_value, & |
---|
422 | weight_pres, weight_substep |
---|
423 | |
---|
424 | USE synthetic_turbulence_generator_mod, & |
---|
425 | ONLY: stg_init, use_synthetic_turbulence_generator |
---|
426 | |
---|
427 | USE surface_layer_fluxes_mod, & |
---|
428 | ONLY: init_surface_layer_fluxes |
---|
429 | |
---|
430 | USE surface_mod, & |
---|
431 | ONLY : init_surface_arrays, init_surfaces, surf_def_h, surf_lsm_h, & |
---|
432 | surf_usm_h |
---|
433 | |
---|
434 | USE transpose_indices |
---|
435 | |
---|
436 | USE urban_surface_mod, & |
---|
437 | ONLY: usm_init_urban_surface |
---|
438 | |
---|
439 | USE wind_turbine_model_mod, & |
---|
440 | ONLY: wtm_init, wtm_init_arrays, wind_turbine |
---|
441 | |
---|
442 | IMPLICIT NONE |
---|
443 | |
---|
444 | INTEGER(iwp) :: i !< |
---|
445 | INTEGER(iwp) :: ind_array(1) !< |
---|
446 | INTEGER(iwp) :: j !< |
---|
447 | INTEGER(iwp) :: k !< |
---|
448 | INTEGER(iwp) :: k_surf !< surface level index |
---|
449 | INTEGER(iwp) :: m !< index of surface element in surface data type |
---|
450 | INTEGER(iwp) :: sr !< index of statistic region |
---|
451 | |
---|
452 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ngp_2dh_l !< |
---|
453 | |
---|
454 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l !< |
---|
455 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_s_inner_l !< |
---|
456 | |
---|
457 | REAL(wp) :: t_surface !< air temperature at the surface |
---|
458 | |
---|
459 | REAL(wp), DIMENSION(:), ALLOCATABLE :: p_hydrostatic !< hydrostatic pressure |
---|
460 | |
---|
461 | INTEGER(iwp) :: l !< loop variable |
---|
462 | INTEGER(iwp) :: nzt_l !< index of top PE boundary for multigrid level |
---|
463 | REAL(wp) :: dx_l !< grid spacing along x on different multigrid level |
---|
464 | REAL(wp) :: dy_l !< grid spacing along y on different multigrid level |
---|
465 | |
---|
466 | REAL(wp), DIMENSION(1:3) :: volume_flow_area_l !< |
---|
467 | REAL(wp), DIMENSION(1:3) :: volume_flow_initial_l !< |
---|
468 | |
---|
469 | REAL(wp), DIMENSION(:), ALLOCATABLE :: mean_surface_level_height_l !< |
---|
470 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_l !< |
---|
471 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_tmp !< |
---|
472 | |
---|
473 | |
---|
474 | CALL location_message( 'allocating arrays', .FALSE. ) |
---|
475 | ! |
---|
476 | !-- Allocate arrays |
---|
477 | ALLOCATE( mean_surface_level_height(0:statistic_regions), & |
---|
478 | mean_surface_level_height_l(0:statistic_regions), & |
---|
479 | ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
480 | ngp_3d(0:statistic_regions), & |
---|
481 | ngp_3d_inner(0:statistic_regions), & |
---|
482 | ngp_3d_inner_l(0:statistic_regions), & |
---|
483 | ngp_3d_inner_tmp(0:statistic_regions), & |
---|
484 | sums_divnew_l(0:statistic_regions), & |
---|
485 | sums_divold_l(0:statistic_regions) ) |
---|
486 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) ) |
---|
487 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
488 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
489 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
490 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
491 | rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions), & |
---|
492 | sums(nzb:nzt+1,pr_palm+max_pr_user), & |
---|
493 | sums_l(nzb:nzt+1,pr_palm+max_pr_user,0:threads_per_task-1), & |
---|
494 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
495 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions), & |
---|
496 | ts_value(dots_max,0:statistic_regions) ) |
---|
497 | ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) ) |
---|
498 | |
---|
499 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
500 | kh(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
501 | km(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
502 | p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
503 | tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
504 | |
---|
505 | #if defined( __nopointer ) |
---|
506 | ALLOCATE( e(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
507 | e_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
508 | pt(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
509 | pt_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
510 | u(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
511 | u_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
512 | v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
513 | v_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
514 | w(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
515 | w_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
516 | te_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
517 | tpt_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
518 | tu_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
519 | tv_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
520 | tw_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
521 | #else |
---|
522 | ALLOCATE( e_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
523 | e_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
524 | e_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
525 | pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
526 | pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
527 | u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
528 | u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
529 | u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
530 | v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
531 | v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
532 | v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
533 | w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
534 | w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
535 | w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
536 | IF ( .NOT. neutral ) THEN |
---|
537 | ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
538 | ENDIF |
---|
539 | #endif |
---|
540 | |
---|
541 | ! |
---|
542 | !-- Following array is required for perturbation pressure within the iterative |
---|
543 | !-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds |
---|
544 | !-- the weighted average of the substeps and cannot be used in the Poisson |
---|
545 | !-- solver. |
---|
546 | IF ( psolver == 'sor' ) THEN |
---|
547 | ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
548 | ELSEIF ( psolver(1:9) == 'multigrid' ) THEN |
---|
549 | ! |
---|
550 | !-- For performance reasons, multigrid is using one ghost layer only |
---|
551 | ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
552 | ENDIF |
---|
553 | |
---|
554 | ! |
---|
555 | !-- Array for storing constant coeffficients of the tridiagonal solver |
---|
556 | IF ( psolver == 'poisfft' ) THEN |
---|
557 | ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) ) |
---|
558 | ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) ) |
---|
559 | ENDIF |
---|
560 | |
---|
561 | IF ( humidity ) THEN |
---|
562 | ! |
---|
563 | !-- 3D-humidity |
---|
564 | #if defined( __nopointer ) |
---|
565 | ALLOCATE( q(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
566 | q_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
567 | tq_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
568 | #else |
---|
569 | ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
570 | q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
571 | q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
572 | #endif |
---|
573 | |
---|
574 | ! |
---|
575 | !-- 3D-arrays needed for humidity |
---|
576 | IF ( humidity ) THEN |
---|
577 | #if defined( __nopointer ) |
---|
578 | ALLOCATE( vpt(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
579 | #else |
---|
580 | ALLOCATE( vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
581 | #endif |
---|
582 | |
---|
583 | IF ( cloud_physics ) THEN |
---|
584 | ! |
---|
585 | !-- Liquid water content |
---|
586 | #if defined( __nopointer ) |
---|
587 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
588 | #else |
---|
589 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
590 | #endif |
---|
591 | |
---|
592 | ! |
---|
593 | !-- 3D-cloud water content |
---|
594 | IF ( .NOT. microphysics_morrison ) THEN |
---|
595 | #if defined( __nopointer ) |
---|
596 | ALLOCATE( qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
597 | #else |
---|
598 | ALLOCATE( qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
599 | #endif |
---|
600 | ENDIF |
---|
601 | ! |
---|
602 | !-- Precipitation amount and rate (only needed if output is switched) |
---|
603 | ALLOCATE( precipitation_amount(nysg:nyng,nxlg:nxrg), & |
---|
604 | precipitation_rate(nysg:nyng,nxlg:nxrg) ) |
---|
605 | |
---|
606 | ! |
---|
607 | !-- 3d-precipitation rate |
---|
608 | ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
609 | |
---|
610 | IF ( microphysics_morrison ) THEN |
---|
611 | ! |
---|
612 | !-- 3D-cloud drop water content, cloud drop concentration arrays |
---|
613 | #if defined( __nopointer ) |
---|
614 | ALLOCATE( nc(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
615 | nc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
616 | qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
617 | qc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
618 | tnc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) |
---|
619 | tqc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
620 | #else |
---|
621 | ALLOCATE( nc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
622 | nc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
623 | nc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
624 | qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
625 | qc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
626 | qc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
627 | #endif |
---|
628 | ENDIF |
---|
629 | |
---|
630 | IF ( microphysics_seifert ) THEN |
---|
631 | ! |
---|
632 | !-- 3D-rain water content, rain drop concentration arrays |
---|
633 | #if defined( __nopointer ) |
---|
634 | ALLOCATE( nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
635 | nr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
636 | qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
637 | qr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
638 | tnr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
639 | tqr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
640 | #else |
---|
641 | ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
642 | nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
643 | nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
644 | qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
645 | qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
646 | qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
647 | #endif |
---|
648 | ENDIF |
---|
649 | |
---|
650 | ENDIF |
---|
651 | |
---|
652 | IF ( cloud_droplets ) THEN |
---|
653 | ! |
---|
654 | !-- Liquid water content, change in liquid water content |
---|
655 | #if defined( __nopointer ) |
---|
656 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
657 | ql_c(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
658 | #else |
---|
659 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
660 | ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
661 | #endif |
---|
662 | ! |
---|
663 | !-- Real volume of particles (with weighting), volume of particles |
---|
664 | ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
665 | ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
666 | ENDIF |
---|
667 | |
---|
668 | ENDIF |
---|
669 | |
---|
670 | ENDIF |
---|
671 | |
---|
672 | |
---|
673 | IF ( passive_scalar ) THEN |
---|
674 | |
---|
675 | ! |
---|
676 | !-- 3D scalar arrays |
---|
677 | #if defined( __nopointer ) |
---|
678 | ALLOCATE( s(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
679 | s_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
680 | ts_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
681 | #else |
---|
682 | ALLOCATE( s_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
683 | s_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
684 | s_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
685 | #endif |
---|
686 | ENDIF |
---|
687 | |
---|
688 | IF ( ocean ) THEN |
---|
689 | #if defined( __nopointer ) |
---|
690 | ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
691 | rho_ocean(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
692 | sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
693 | sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
694 | tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
695 | #else |
---|
696 | ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
697 | rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
698 | sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
699 | sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
700 | sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
701 | prho => prho_1 |
---|
702 | rho_ocean => rho_1 ! routines calc_mean_profile and diffusion_e require |
---|
703 | ! density to be apointer |
---|
704 | #endif |
---|
705 | ENDIF |
---|
706 | |
---|
707 | ! |
---|
708 | !-- Allocation of anelastic and Boussinesq approximation specific arrays |
---|
709 | ALLOCATE( p_hydrostatic(nzb:nzt+1) ) |
---|
710 | ALLOCATE( rho_air(nzb:nzt+1) ) |
---|
711 | ALLOCATE( rho_air_zw(nzb:nzt+1) ) |
---|
712 | ALLOCATE( drho_air(nzb:nzt+1) ) |
---|
713 | ALLOCATE( drho_air_zw(nzb:nzt+1) ) |
---|
714 | |
---|
715 | ! |
---|
716 | !-- Density profile calculation for anelastic approximation |
---|
717 | t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**( r_d / cp ) |
---|
718 | IF ( TRIM( approximation ) == 'anelastic' ) THEN |
---|
719 | DO k = nzb, nzt+1 |
---|
720 | p_hydrostatic(k) = surface_pressure * 100.0_wp * & |
---|
721 | ( 1 - ( g * zu(k) ) / ( cp * t_surface ) & |
---|
722 | )**( cp / r_d ) |
---|
723 | rho_air(k) = ( p_hydrostatic(k) * & |
---|
724 | ( 100000.0_wp / p_hydrostatic(k) & |
---|
725 | )**( r_d / cp ) & |
---|
726 | ) / ( r_d * pt_init(k) ) |
---|
727 | ENDDO |
---|
728 | DO k = nzb, nzt |
---|
729 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
730 | ENDDO |
---|
731 | rho_air_zw(nzt+1) = rho_air_zw(nzt) & |
---|
732 | + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
733 | ELSE |
---|
734 | DO k = nzb, nzt+1 |
---|
735 | p_hydrostatic(k) = surface_pressure * 100.0_wp * & |
---|
736 | ( 1 - ( g * zu(nzb) ) / ( cp * t_surface ) & |
---|
737 | )**( cp / r_d ) |
---|
738 | rho_air(k) = ( p_hydrostatic(k) * & |
---|
739 | ( 100000.0_wp / p_hydrostatic(k) & |
---|
740 | )**( r_d / cp ) & |
---|
741 | ) / ( r_d * pt_init(nzb) ) |
---|
742 | ENDDO |
---|
743 | DO k = nzb, nzt |
---|
744 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
745 | ENDDO |
---|
746 | rho_air_zw(nzt+1) = rho_air_zw(nzt) & |
---|
747 | + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
748 | ENDIF |
---|
749 | |
---|
750 | !-- compute the inverse density array in order to avoid expencive divisions |
---|
751 | drho_air = 1.0_wp / rho_air |
---|
752 | drho_air_zw = 1.0_wp / rho_air_zw |
---|
753 | |
---|
754 | ! |
---|
755 | !-- Allocation of flux conversion arrays |
---|
756 | ALLOCATE( heatflux_input_conversion(nzb:nzt+1) ) |
---|
757 | ALLOCATE( waterflux_input_conversion(nzb:nzt+1) ) |
---|
758 | ALLOCATE( momentumflux_input_conversion(nzb:nzt+1) ) |
---|
759 | ALLOCATE( heatflux_output_conversion(nzb:nzt+1) ) |
---|
760 | ALLOCATE( waterflux_output_conversion(nzb:nzt+1) ) |
---|
761 | ALLOCATE( momentumflux_output_conversion(nzb:nzt+1) ) |
---|
762 | |
---|
763 | ! |
---|
764 | !-- calculate flux conversion factors according to approximation and in-/output mode |
---|
765 | DO k = nzb, nzt+1 |
---|
766 | |
---|
767 | IF ( TRIM( flux_input_mode ) == 'kinematic' ) THEN |
---|
768 | heatflux_input_conversion(k) = rho_air_zw(k) |
---|
769 | waterflux_input_conversion(k) = rho_air_zw(k) |
---|
770 | momentumflux_input_conversion(k) = rho_air_zw(k) |
---|
771 | ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN |
---|
772 | heatflux_input_conversion(k) = 1.0_wp / cp |
---|
773 | waterflux_input_conversion(k) = 1.0_wp / l_v |
---|
774 | momentumflux_input_conversion(k) = 1.0_wp |
---|
775 | ENDIF |
---|
776 | |
---|
777 | IF ( TRIM( flux_output_mode ) == 'kinematic' ) THEN |
---|
778 | heatflux_output_conversion(k) = drho_air_zw(k) |
---|
779 | waterflux_output_conversion(k) = drho_air_zw(k) |
---|
780 | momentumflux_output_conversion(k) = drho_air_zw(k) |
---|
781 | ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN |
---|
782 | heatflux_output_conversion(k) = cp |
---|
783 | waterflux_output_conversion(k) = l_v |
---|
784 | momentumflux_output_conversion(k) = 1.0_wp |
---|
785 | ENDIF |
---|
786 | |
---|
787 | IF ( .NOT. humidity ) THEN |
---|
788 | waterflux_input_conversion(k) = 1.0_wp |
---|
789 | waterflux_output_conversion(k) = 1.0_wp |
---|
790 | ENDIF |
---|
791 | |
---|
792 | ENDDO |
---|
793 | |
---|
794 | ! |
---|
795 | !-- In case of multigrid method, compute grid lengths and grid factors for the |
---|
796 | !-- grid levels with respective density on each grid |
---|
797 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
798 | |
---|
799 | ALLOCATE( ddx2_mg(maximum_grid_level) ) |
---|
800 | ALLOCATE( ddy2_mg(maximum_grid_level) ) |
---|
801 | ALLOCATE( dzu_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
802 | ALLOCATE( dzw_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
803 | ALLOCATE( f1_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
804 | ALLOCATE( f2_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
805 | ALLOCATE( f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
806 | ALLOCATE( rho_air_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
807 | ALLOCATE( rho_air_zw_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
808 | |
---|
809 | dzu_mg(:,maximum_grid_level) = dzu |
---|
810 | rho_air_mg(:,maximum_grid_level) = rho_air |
---|
811 | ! |
---|
812 | !-- Next line to ensure an equally spaced grid. |
---|
813 | dzu_mg(1,maximum_grid_level) = dzu(2) |
---|
814 | rho_air_mg(nzb,maximum_grid_level) = rho_air(nzb) + & |
---|
815 | (rho_air(nzb) - rho_air(nzb+1)) |
---|
816 | |
---|
817 | dzw_mg(:,maximum_grid_level) = dzw |
---|
818 | rho_air_zw_mg(:,maximum_grid_level) = rho_air_zw |
---|
819 | nzt_l = nzt |
---|
820 | DO l = maximum_grid_level-1, 1, -1 |
---|
821 | dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1) |
---|
822 | dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1) |
---|
823 | rho_air_mg(nzb,l) = rho_air_mg(nzb,l+1) + (rho_air_mg(nzb,l+1) - rho_air_mg(nzb+1,l+1)) |
---|
824 | rho_air_zw_mg(nzb,l) = rho_air_zw_mg(nzb,l+1) + (rho_air_zw_mg(nzb,l+1) - rho_air_zw_mg(nzb+1,l+1)) |
---|
825 | rho_air_mg(nzb+1,l) = rho_air_mg(nzb+1,l+1) |
---|
826 | rho_air_zw_mg(nzb+1,l) = rho_air_zw_mg(nzb+1,l+1) |
---|
827 | nzt_l = nzt_l / 2 |
---|
828 | DO k = 2, nzt_l+1 |
---|
829 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
830 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
831 | rho_air_mg(k,l) = rho_air_mg(2*k-1,l+1) |
---|
832 | rho_air_zw_mg(k,l) = rho_air_zw_mg(2*k-1,l+1) |
---|
833 | ENDDO |
---|
834 | ENDDO |
---|
835 | |
---|
836 | nzt_l = nzt |
---|
837 | dx_l = dx |
---|
838 | dy_l = dy |
---|
839 | DO l = maximum_grid_level, 1, -1 |
---|
840 | ddx2_mg(l) = 1.0_wp / dx_l**2 |
---|
841 | ddy2_mg(l) = 1.0_wp / dy_l**2 |
---|
842 | DO k = nzb+1, nzt_l |
---|
843 | f2_mg(k,l) = rho_air_zw_mg(k,l) / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
844 | f3_mg(k,l) = rho_air_zw_mg(k-1,l) / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
845 | f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) & |
---|
846 | * rho_air_mg(k,l) + f2_mg(k,l) + f3_mg(k,l) |
---|
847 | ENDDO |
---|
848 | nzt_l = nzt_l / 2 |
---|
849 | dx_l = dx_l * 2.0_wp |
---|
850 | dy_l = dy_l * 2.0_wp |
---|
851 | ENDDO |
---|
852 | |
---|
853 | ENDIF |
---|
854 | |
---|
855 | ! |
---|
856 | !-- 3D-array for storing the dissipation, needed for calculating the sgs |
---|
857 | !-- particle velocities |
---|
858 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. collision_turbulence )& |
---|
859 | THEN |
---|
860 | ALLOCATE( diss(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
861 | ENDIF |
---|
862 | |
---|
863 | ! |
---|
864 | !-- 1D-array for large scale subsidence velocity |
---|
865 | IF ( .NOT. ALLOCATED( w_subs ) ) THEN |
---|
866 | ALLOCATE ( w_subs(nzb:nzt+1) ) |
---|
867 | w_subs = 0.0_wp |
---|
868 | ENDIF |
---|
869 | |
---|
870 | ! |
---|
871 | !-- Arrays to store velocity data from t-dt and the phase speeds which |
---|
872 | !-- are needed for radiation boundary conditions |
---|
873 | IF ( outflow_l ) THEN |
---|
874 | ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2), & |
---|
875 | v_m_l(nzb:nzt+1,nysg:nyng,0:1), & |
---|
876 | w_m_l(nzb:nzt+1,nysg:nyng,0:1) ) |
---|
877 | ENDIF |
---|
878 | IF ( outflow_r ) THEN |
---|
879 | ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
880 | v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
881 | w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) ) |
---|
882 | ENDIF |
---|
883 | IF ( outflow_l .OR. outflow_r ) THEN |
---|
884 | ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng), & |
---|
885 | c_w(nzb:nzt+1,nysg:nyng) ) |
---|
886 | ENDIF |
---|
887 | IF ( outflow_s ) THEN |
---|
888 | ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg), & |
---|
889 | v_m_s(nzb:nzt+1,1:2,nxlg:nxrg), & |
---|
890 | w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) ) |
---|
891 | ENDIF |
---|
892 | IF ( outflow_n ) THEN |
---|
893 | ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
894 | v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
895 | w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) ) |
---|
896 | ENDIF |
---|
897 | IF ( outflow_s .OR. outflow_n ) THEN |
---|
898 | ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg), & |
---|
899 | c_w(nzb:nzt+1,nxlg:nxrg) ) |
---|
900 | ENDIF |
---|
901 | IF ( outflow_l .OR. outflow_r .OR. outflow_s .OR. outflow_n ) THEN |
---|
902 | ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) ) |
---|
903 | ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) ) |
---|
904 | ENDIF |
---|
905 | |
---|
906 | |
---|
907 | #if ! defined( __nopointer ) |
---|
908 | ! |
---|
909 | !-- Initial assignment of the pointers |
---|
910 | e => e_1; e_p => e_2; te_m => e_3 |
---|
911 | IF ( .NOT. neutral ) THEN |
---|
912 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3 |
---|
913 | ELSE |
---|
914 | pt => pt_1; pt_p => pt_1; tpt_m => pt_3 |
---|
915 | ENDIF |
---|
916 | u => u_1; u_p => u_2; tu_m => u_3 |
---|
917 | v => v_1; v_p => v_2; tv_m => v_3 |
---|
918 | w => w_1; w_p => w_2; tw_m => w_3 |
---|
919 | |
---|
920 | IF ( humidity ) THEN |
---|
921 | q => q_1; q_p => q_2; tq_m => q_3 |
---|
922 | IF ( humidity ) THEN |
---|
923 | vpt => vpt_1 |
---|
924 | IF ( cloud_physics ) THEN |
---|
925 | ql => ql_1 |
---|
926 | IF ( .NOT. microphysics_morrison ) THEN |
---|
927 | qc => qc_1 |
---|
928 | ENDIF |
---|
929 | IF ( microphysics_morrison ) THEN |
---|
930 | qc => qc_1; qc_p => qc_2; tqc_m => qc_3 |
---|
931 | nc => nc_1; nc_p => nc_2; tnc_m => nc_3 |
---|
932 | ENDIF |
---|
933 | IF ( microphysics_seifert ) THEN |
---|
934 | qr => qr_1; qr_p => qr_2; tqr_m => qr_3 |
---|
935 | nr => nr_1; nr_p => nr_2; tnr_m => nr_3 |
---|
936 | ENDIF |
---|
937 | ENDIF |
---|
938 | ENDIF |
---|
939 | IF ( cloud_droplets ) THEN |
---|
940 | ql => ql_1 |
---|
941 | ql_c => ql_2 |
---|
942 | ENDIF |
---|
943 | ENDIF |
---|
944 | |
---|
945 | IF ( passive_scalar ) THEN |
---|
946 | s => s_1; s_p => s_2; ts_m => s_3 |
---|
947 | ENDIF |
---|
948 | |
---|
949 | IF ( ocean ) THEN |
---|
950 | sa => sa_1; sa_p => sa_2; tsa_m => sa_3 |
---|
951 | ENDIF |
---|
952 | #endif |
---|
953 | ! |
---|
954 | !-- Initialize wall arrays |
---|
955 | CALL init_surface_arrays |
---|
956 | ! |
---|
957 | !-- Allocate land surface model arrays |
---|
958 | IF ( land_surface ) THEN |
---|
959 | CALL lsm_init_arrays |
---|
960 | ENDIF |
---|
961 | |
---|
962 | ! |
---|
963 | !-- Allocate wind turbine model arrays |
---|
964 | IF ( wind_turbine ) THEN |
---|
965 | CALL wtm_init_arrays |
---|
966 | ENDIF |
---|
967 | |
---|
968 | ! |
---|
969 | !-- Initialize virtual flight measurements |
---|
970 | IF ( virtual_flight ) THEN |
---|
971 | CALL flight_init |
---|
972 | ENDIF |
---|
973 | |
---|
974 | ! |
---|
975 | !-- Initialize nudging if required |
---|
976 | IF ( nudging ) THEN |
---|
977 | CALL nudge_init |
---|
978 | ENDIF |
---|
979 | |
---|
980 | ! |
---|
981 | !-- Initialize reading of large scale forcing from external file - if required |
---|
982 | IF ( large_scale_forcing ) THEN |
---|
983 | CALL lsf_init |
---|
984 | ENDIF |
---|
985 | |
---|
986 | ! |
---|
987 | !-- Allocate arrays containing the RK coefficient for calculation of |
---|
988 | !-- perturbation pressure and turbulent fluxes. At this point values are |
---|
989 | !-- set for pressure calculation during initialization (where no timestep |
---|
990 | !-- is done). Further below the values needed within the timestep scheme |
---|
991 | !-- will be set. |
---|
992 | ALLOCATE( weight_substep(1:intermediate_timestep_count_max), & |
---|
993 | weight_pres(1:intermediate_timestep_count_max) ) |
---|
994 | weight_substep = 1.0_wp |
---|
995 | weight_pres = 1.0_wp |
---|
996 | intermediate_timestep_count = 0 ! needed when simulated_time = 0.0 |
---|
997 | |
---|
998 | CALL location_message( 'finished', .TRUE. ) |
---|
999 | |
---|
1000 | ! |
---|
1001 | !-- Initialize local summation arrays for routine flow_statistics. |
---|
1002 | !-- This is necessary because they may not yet have been initialized when they |
---|
1003 | !-- are called from flow_statistics (or - depending on the chosen model run - |
---|
1004 | !-- are never initialized) |
---|
1005 | sums_divnew_l = 0.0_wp |
---|
1006 | sums_divold_l = 0.0_wp |
---|
1007 | sums_l_l = 0.0_wp |
---|
1008 | sums_wsts_bc_l = 0.0_wp |
---|
1009 | |
---|
1010 | ! |
---|
1011 | !-- Initialize model variables |
---|
1012 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
1013 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
1014 | ! |
---|
1015 | !-- First model run of a possible job queue. |
---|
1016 | !-- Initial profiles of the variables must be computes. |
---|
1017 | IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
1018 | |
---|
1019 | CALL location_message( 'initializing with 1D model profiles', .FALSE. ) |
---|
1020 | ! |
---|
1021 | !-- Use solutions of the 1D model as initial profiles, |
---|
1022 | !-- start 1D model |
---|
1023 | CALL init_1d_model |
---|
1024 | ! |
---|
1025 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
1026 | DO i = nxlg, nxrg |
---|
1027 | DO j = nysg, nyng |
---|
1028 | e(:,j,i) = e1d |
---|
1029 | kh(:,j,i) = kh1d |
---|
1030 | km(:,j,i) = km1d |
---|
1031 | pt(:,j,i) = pt_init |
---|
1032 | u(:,j,i) = u1d |
---|
1033 | v(:,j,i) = v1d |
---|
1034 | ENDDO |
---|
1035 | ENDDO |
---|
1036 | |
---|
1037 | IF ( humidity ) THEN |
---|
1038 | DO i = nxlg, nxrg |
---|
1039 | DO j = nysg, nyng |
---|
1040 | q(:,j,i) = q_init |
---|
1041 | ENDDO |
---|
1042 | ENDDO |
---|
1043 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
1044 | DO i = nxlg, nxrg |
---|
1045 | DO j = nysg, nyng |
---|
1046 | qc(:,j,i) = 0.0_wp |
---|
1047 | nc(:,j,i) = 0.0_wp |
---|
1048 | ENDDO |
---|
1049 | ENDDO |
---|
1050 | ENDIF |
---|
1051 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
1052 | DO i = nxlg, nxrg |
---|
1053 | DO j = nysg, nyng |
---|
1054 | qr(:,j,i) = 0.0_wp |
---|
1055 | nr(:,j,i) = 0.0_wp |
---|
1056 | ENDDO |
---|
1057 | ENDDO |
---|
1058 | ENDIF |
---|
1059 | ENDIF |
---|
1060 | |
---|
1061 | IF ( passive_scalar ) THEN |
---|
1062 | DO i = nxlg, nxrg |
---|
1063 | DO j = nysg, nyng |
---|
1064 | s(:,j,i) = s_init |
---|
1065 | ENDDO |
---|
1066 | ENDDO |
---|
1067 | ENDIF |
---|
1068 | |
---|
1069 | IF ( .NOT. constant_diffusion ) THEN |
---|
1070 | DO i = nxlg, nxrg |
---|
1071 | DO j = nysg, nyng |
---|
1072 | e(:,j,i) = e1d |
---|
1073 | ENDDO |
---|
1074 | ENDDO |
---|
1075 | ! |
---|
1076 | !-- Store initial profiles for output purposes etc. |
---|
1077 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
1078 | |
---|
1079 | ELSE |
---|
1080 | e = 0.0_wp ! must be set, because used in |
---|
1081 | ENDIF |
---|
1082 | ! |
---|
1083 | !-- Inside buildings set velocities back to zero |
---|
1084 | IF ( topography /= 'flat' ) THEN |
---|
1085 | DO i = nxlg, nxrg |
---|
1086 | DO j = nysg, nyng |
---|
1087 | DO k = nzb, nzt |
---|
1088 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, & |
---|
1089 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
1090 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, & |
---|
1091 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
1092 | ENDDO |
---|
1093 | ENDDO |
---|
1094 | ENDDO |
---|
1095 | |
---|
1096 | ! |
---|
1097 | !-- WARNING: The extra boundary conditions set after running the |
---|
1098 | !-- ------- 1D model impose an error on the divergence one layer |
---|
1099 | !-- below the topography; need to correct later |
---|
1100 | !-- ATTENTION: Provisional correction for Piacsek & Williams |
---|
1101 | !-- --------- advection scheme: keep u and v zero one layer below |
---|
1102 | !-- the topography. |
---|
1103 | IF ( ibc_uv_b == 1 ) THEN |
---|
1104 | ! |
---|
1105 | !-- Neumann condition |
---|
1106 | DO i = nxl-1, nxr+1 |
---|
1107 | DO j = nys-1, nyn+1 |
---|
1108 | u(nzb,j,i) = u(nzb+1,j,i) |
---|
1109 | v(nzb,j,i) = v(nzb+1,j,i) |
---|
1110 | ENDDO |
---|
1111 | ENDDO |
---|
1112 | |
---|
1113 | ENDIF |
---|
1114 | |
---|
1115 | ENDIF |
---|
1116 | |
---|
1117 | CALL location_message( 'finished', .TRUE. ) |
---|
1118 | |
---|
1119 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & |
---|
1120 | THEN |
---|
1121 | |
---|
1122 | CALL location_message( 'initializing with constant profiles', .FALSE. ) |
---|
1123 | ! |
---|
1124 | !-- Overwrite initial profiles in case of synthetic turbulence generator |
---|
1125 | IF( use_synthetic_turbulence_generator ) THEN |
---|
1126 | CALL stg_init |
---|
1127 | ENDIF |
---|
1128 | |
---|
1129 | ! |
---|
1130 | !-- Use constructed initial profiles (velocity constant with height, |
---|
1131 | !-- temperature profile with constant gradient) |
---|
1132 | DO i = nxlg, nxrg |
---|
1133 | DO j = nysg, nyng |
---|
1134 | pt(:,j,i) = pt_init |
---|
1135 | u(:,j,i) = u_init |
---|
1136 | v(:,j,i) = v_init |
---|
1137 | ENDDO |
---|
1138 | ENDDO |
---|
1139 | |
---|
1140 | ! |
---|
1141 | !-- Set initial horizontal velocities at the lowest computational grid |
---|
1142 | !-- levels to zero in order to avoid too small time steps caused by the |
---|
1143 | !-- diffusion limit in the initial phase of a run (at k=1, dz/2 occurs |
---|
1144 | !-- in the limiting formula!). |
---|
1145 | IF ( ibc_uv_b /= 1 ) THEN |
---|
1146 | DO i = nxlg, nxrg |
---|
1147 | DO j = nysg, nyng |
---|
1148 | DO k = nzb, nzt |
---|
1149 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, & |
---|
1150 | BTEST( wall_flags_0(k,j,i), 20 ) ) |
---|
1151 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, & |
---|
1152 | BTEST( wall_flags_0(k,j,i), 21 ) ) |
---|
1153 | ENDDO |
---|
1154 | ENDDO |
---|
1155 | ENDDO |
---|
1156 | ENDIF |
---|
1157 | |
---|
1158 | IF ( humidity ) THEN |
---|
1159 | DO i = nxlg, nxrg |
---|
1160 | DO j = nysg, nyng |
---|
1161 | q(:,j,i) = q_init |
---|
1162 | ENDDO |
---|
1163 | ENDDO |
---|
1164 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
1165 | DO i = nxlg, nxrg |
---|
1166 | DO j = nysg, nyng |
---|
1167 | qc(:,j,i) = 0.0_wp |
---|
1168 | nc(:,j,i) = 0.0_wp |
---|
1169 | ENDDO |
---|
1170 | ENDDO |
---|
1171 | ENDIF |
---|
1172 | |
---|
1173 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
1174 | DO i = nxlg, nxrg |
---|
1175 | DO j = nysg, nyng |
---|
1176 | qr(:,j,i) = 0.0_wp |
---|
1177 | nr(:,j,i) = 0.0_wp |
---|
1178 | ENDDO |
---|
1179 | ENDDO |
---|
1180 | ENDIF |
---|
1181 | |
---|
1182 | ENDIF |
---|
1183 | |
---|
1184 | IF ( passive_scalar ) THEN |
---|
1185 | DO i = nxlg, nxrg |
---|
1186 | DO j = nysg, nyng |
---|
1187 | s(:,j,i) = s_init |
---|
1188 | ENDDO |
---|
1189 | ENDDO |
---|
1190 | ENDIF |
---|
1191 | |
---|
1192 | IF ( ocean ) THEN |
---|
1193 | DO i = nxlg, nxrg |
---|
1194 | DO j = nysg, nyng |
---|
1195 | sa(:,j,i) = sa_init |
---|
1196 | ENDDO |
---|
1197 | ENDDO |
---|
1198 | ENDIF |
---|
1199 | |
---|
1200 | IF ( constant_diffusion ) THEN |
---|
1201 | km = km_constant |
---|
1202 | kh = km / prandtl_number |
---|
1203 | e = 0.0_wp |
---|
1204 | ELSEIF ( e_init > 0.0_wp ) THEN |
---|
1205 | DO k = nzb+1, nzt |
---|
1206 | km(k,:,:) = 0.1_wp * l_grid(k) * SQRT( e_init ) |
---|
1207 | ENDDO |
---|
1208 | km(nzb,:,:) = km(nzb+1,:,:) |
---|
1209 | km(nzt+1,:,:) = km(nzt,:,:) |
---|
1210 | kh = km / prandtl_number |
---|
1211 | e = e_init |
---|
1212 | ELSE |
---|
1213 | IF ( .NOT. ocean ) THEN |
---|
1214 | kh = 0.01_wp ! there must exist an initial diffusion, because |
---|
1215 | km = 0.01_wp ! otherwise no TKE would be produced by the |
---|
1216 | ! production terms, as long as not yet |
---|
1217 | ! e = (u*/cm)**2 at k=nzb+1 |
---|
1218 | ELSE |
---|
1219 | kh = 0.00001_wp |
---|
1220 | km = 0.00001_wp |
---|
1221 | ENDIF |
---|
1222 | e = 0.0_wp |
---|
1223 | ENDIF |
---|
1224 | ! |
---|
1225 | !-- Compute initial temperature field and other constants used in case |
---|
1226 | !-- of a sloping surface |
---|
1227 | IF ( sloping_surface ) CALL init_slope |
---|
1228 | |
---|
1229 | CALL location_message( 'finished', .TRUE. ) |
---|
1230 | |
---|
1231 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) & |
---|
1232 | THEN |
---|
1233 | |
---|
1234 | CALL location_message( 'initializing by user', .FALSE. ) |
---|
1235 | ! |
---|
1236 | !-- Initialization will completely be done by the user |
---|
1237 | CALL user_init_3d_model |
---|
1238 | |
---|
1239 | CALL location_message( 'finished', .TRUE. ) |
---|
1240 | |
---|
1241 | ENDIF |
---|
1242 | |
---|
1243 | CALL location_message( 'initializing statistics, boundary conditions, etc.', & |
---|
1244 | .FALSE. ) |
---|
1245 | |
---|
1246 | ! |
---|
1247 | !-- Bottom boundary |
---|
1248 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
1249 | u(nzb,:,:) = 0.0_wp |
---|
1250 | v(nzb,:,:) = 0.0_wp |
---|
1251 | ENDIF |
---|
1252 | |
---|
1253 | ! |
---|
1254 | !-- Apply channel flow boundary condition |
---|
1255 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
1256 | u(nzt+1,:,:) = 0.0_wp |
---|
1257 | v(nzt+1,:,:) = 0.0_wp |
---|
1258 | ENDIF |
---|
1259 | |
---|
1260 | ! |
---|
1261 | !-- Calculate virtual potential temperature |
---|
1262 | IF ( humidity ) vpt = pt * ( 1.0_wp + 0.61_wp * q ) |
---|
1263 | |
---|
1264 | ! |
---|
1265 | !-- Store initial profiles for output purposes etc. |
---|
1266 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1267 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1268 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2) THEN |
---|
1269 | hom(nzb,1,5,:) = 0.0_wp |
---|
1270 | hom(nzb,1,6,:) = 0.0_wp |
---|
1271 | ENDIF |
---|
1272 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1273 | hom(:,1,23,:) = SPREAD( km(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1274 | hom(:,1,24,:) = SPREAD( kh(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1275 | |
---|
1276 | IF ( ocean ) THEN |
---|
1277 | ! |
---|
1278 | !-- Store initial salinity profile |
---|
1279 | hom(:,1,26,:) = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1280 | ENDIF |
---|
1281 | |
---|
1282 | IF ( humidity ) THEN |
---|
1283 | ! |
---|
1284 | !-- Store initial profile of total water content, virtual potential |
---|
1285 | !-- temperature |
---|
1286 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1287 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1288 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
1289 | ! |
---|
1290 | !-- Store initial profile of specific humidity and potential |
---|
1291 | !-- temperature |
---|
1292 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1293 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1294 | ENDIF |
---|
1295 | ENDIF |
---|
1296 | |
---|
1297 | IF ( passive_scalar ) THEN |
---|
1298 | ! |
---|
1299 | !-- Store initial scalar profile |
---|
1300 | hom(:,1,115,:) = SPREAD( s(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1301 | ENDIF |
---|
1302 | |
---|
1303 | ! |
---|
1304 | !-- Initialize the random number generators (from numerical recipes) |
---|
1305 | CALL random_function_ini |
---|
1306 | |
---|
1307 | IF ( random_generator == 'random-parallel' ) THEN |
---|
1308 | CALL init_parallel_random_generator(nx, ny, nys, nyn, nxl, nxr) |
---|
1309 | ENDIF |
---|
1310 | ! |
---|
1311 | !-- Set the reference state to be used in the buoyancy terms (for ocean runs |
---|
1312 | !-- the reference state will be set (overwritten) in init_ocean) |
---|
1313 | IF ( use_single_reference_value ) THEN |
---|
1314 | IF ( .NOT. humidity ) THEN |
---|
1315 | ref_state(:) = pt_reference |
---|
1316 | ELSE |
---|
1317 | ref_state(:) = vpt_reference |
---|
1318 | ENDIF |
---|
1319 | ELSE |
---|
1320 | IF ( .NOT. humidity ) THEN |
---|
1321 | ref_state(:) = pt_init(:) |
---|
1322 | ELSE |
---|
1323 | ref_state(:) = vpt(:,nys,nxl) |
---|
1324 | ENDIF |
---|
1325 | ENDIF |
---|
1326 | |
---|
1327 | ! |
---|
1328 | !-- For the moment, vertical velocity is zero |
---|
1329 | w = 0.0_wp |
---|
1330 | |
---|
1331 | ! |
---|
1332 | !-- Initialize array sums (must be defined in first call of pres) |
---|
1333 | sums = 0.0_wp |
---|
1334 | |
---|
1335 | ! |
---|
1336 | !-- In case of iterative solvers, p must get an initial value |
---|
1337 | IF ( psolver(1:9) == 'multigrid' .OR. psolver == 'sor' ) p = 0.0_wp |
---|
1338 | |
---|
1339 | ! |
---|
1340 | !-- Treating cloud physics, liquid water content and precipitation amount |
---|
1341 | !-- are zero at beginning of the simulation |
---|
1342 | IF ( cloud_physics ) THEN |
---|
1343 | ql = 0.0_wp |
---|
1344 | qc = 0.0_wp |
---|
1345 | |
---|
1346 | precipitation_amount = 0.0_wp |
---|
1347 | ENDIF |
---|
1348 | ! |
---|
1349 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
1350 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
1351 | CALL init_rankine |
---|
1352 | ENDIF |
---|
1353 | |
---|
1354 | ! |
---|
1355 | !-- Impose temperature anomaly (advection test only) |
---|
1356 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 ) THEN |
---|
1357 | CALL init_pt_anomaly |
---|
1358 | ENDIF |
---|
1359 | |
---|
1360 | ! |
---|
1361 | !-- If required, change the surface temperature at the start of the 3D run |
---|
1362 | IF ( pt_surface_initial_change /= 0.0_wp ) THEN |
---|
1363 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
1364 | ENDIF |
---|
1365 | |
---|
1366 | ! |
---|
1367 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
1368 | !-- run |
---|
1369 | IF ( humidity .AND. q_surface_initial_change /= 0.0_wp ) & |
---|
1370 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
1371 | |
---|
1372 | IF ( passive_scalar .AND. s_surface_initial_change /= 0.0_wp ) & |
---|
1373 | s(nzb,:,:) = s(nzb,:,:) + s_surface_initial_change |
---|
1374 | |
---|
1375 | |
---|
1376 | ! |
---|
1377 | !-- Initialize old and new time levels. |
---|
1378 | te_m = 0.0_wp; tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
1379 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
1380 | |
---|
1381 | IF ( humidity ) THEN |
---|
1382 | tq_m = 0.0_wp |
---|
1383 | q_p = q |
---|
1384 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
1385 | tqc_m = 0.0_wp |
---|
1386 | qc_p = qc |
---|
1387 | tnc_m = 0.0_wp |
---|
1388 | nc_p = nc |
---|
1389 | ENDIF |
---|
1390 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
1391 | tqr_m = 0.0_wp |
---|
1392 | qr_p = qr |
---|
1393 | tnr_m = 0.0_wp |
---|
1394 | nr_p = nr |
---|
1395 | ENDIF |
---|
1396 | ENDIF |
---|
1397 | |
---|
1398 | IF ( passive_scalar ) THEN |
---|
1399 | ts_m = 0.0_wp |
---|
1400 | s_p = s |
---|
1401 | ENDIF |
---|
1402 | |
---|
1403 | IF ( ocean ) THEN |
---|
1404 | tsa_m = 0.0_wp |
---|
1405 | sa_p = sa |
---|
1406 | ENDIF |
---|
1407 | |
---|
1408 | CALL location_message( 'finished', .TRUE. ) |
---|
1409 | |
---|
1410 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
1411 | TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
1412 | THEN |
---|
1413 | |
---|
1414 | CALL location_message( 'initializing in case of restart / cyclic_fill', & |
---|
1415 | .FALSE. ) |
---|
1416 | ! |
---|
1417 | !-- Initialize surface elements and its attributes, e.g. heat- and |
---|
1418 | !-- momentumfluxes, roughness, scaling parameters. As number of surface |
---|
1419 | !-- elements might be different between runs, e.g. in case of cyclic fill, |
---|
1420 | !-- and not all surface elements are read, surface elements need to be |
---|
1421 | !-- initialized before. |
---|
1422 | CALL init_surfaces |
---|
1423 | ! |
---|
1424 | !-- When reading data for cyclic fill of 3D prerun data files, read |
---|
1425 | !-- some of the global variables from the restart file which are required |
---|
1426 | !-- for initializing the inflow |
---|
1427 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
1428 | |
---|
1429 | DO i = 0, io_blocks-1 |
---|
1430 | IF ( i == io_group ) THEN |
---|
1431 | CALL read_parts_of_var_list |
---|
1432 | CALL close_file( 13 ) |
---|
1433 | ENDIF |
---|
1434 | #if defined( __parallel ) |
---|
1435 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1436 | #endif |
---|
1437 | ENDDO |
---|
1438 | |
---|
1439 | ENDIF |
---|
1440 | |
---|
1441 | ! |
---|
1442 | !-- Read binary data from restart file |
---|
1443 | DO i = 0, io_blocks-1 |
---|
1444 | IF ( i == io_group ) THEN |
---|
1445 | CALL read_3d_binary |
---|
1446 | ENDIF |
---|
1447 | #if defined( __parallel ) |
---|
1448 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1449 | #endif |
---|
1450 | ENDDO |
---|
1451 | |
---|
1452 | ! |
---|
1453 | !-- Initialization of the turbulence recycling method |
---|
1454 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
1455 | turbulent_inflow ) THEN |
---|
1456 | ! |
---|
1457 | !-- First store the profiles to be used at the inflow. |
---|
1458 | !-- These profiles are the (temporally) and horizontally averaged vertical |
---|
1459 | !-- profiles from the prerun. Alternatively, prescribed profiles |
---|
1460 | !-- for u,v-components can be used. |
---|
1461 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,7) ) |
---|
1462 | |
---|
1463 | IF ( use_prescribed_profile_data ) THEN |
---|
1464 | mean_inflow_profiles(:,1) = u_init ! u |
---|
1465 | mean_inflow_profiles(:,2) = v_init ! v |
---|
1466 | ELSE |
---|
1467 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
1468 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
1469 | ENDIF |
---|
1470 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
1471 | mean_inflow_profiles(:,5) = hom_sum(:,8,0) ! e |
---|
1472 | IF ( humidity ) & |
---|
1473 | mean_inflow_profiles(:,6) = hom_sum(:,41,0) ! q |
---|
1474 | IF ( passive_scalar ) & |
---|
1475 | mean_inflow_profiles(:,7) = hom_sum(:,115,0) ! s |
---|
1476 | |
---|
1477 | ! |
---|
1478 | !-- If necessary, adjust the horizontal flow field to the prescribed |
---|
1479 | !-- profiles |
---|
1480 | IF ( use_prescribed_profile_data ) THEN |
---|
1481 | DO i = nxlg, nxrg |
---|
1482 | DO j = nysg, nyng |
---|
1483 | DO k = nzb, nzt+1 |
---|
1484 | u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k) |
---|
1485 | v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k) |
---|
1486 | ENDDO |
---|
1487 | ENDDO |
---|
1488 | ENDDO |
---|
1489 | ENDIF |
---|
1490 | |
---|
1491 | ! |
---|
1492 | !-- Use these mean profiles at the inflow (provided that Dirichlet |
---|
1493 | !-- conditions are used) |
---|
1494 | IF ( inflow_l ) THEN |
---|
1495 | DO j = nysg, nyng |
---|
1496 | DO k = nzb, nzt+1 |
---|
1497 | u(k,j,nxlg:-1) = mean_inflow_profiles(k,1) |
---|
1498 | v(k,j,nxlg:-1) = mean_inflow_profiles(k,2) |
---|
1499 | w(k,j,nxlg:-1) = 0.0_wp |
---|
1500 | pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4) |
---|
1501 | e(k,j,nxlg:-1) = mean_inflow_profiles(k,5) |
---|
1502 | IF ( humidity ) & |
---|
1503 | q(k,j,nxlg:-1) = mean_inflow_profiles(k,6) |
---|
1504 | IF ( passive_scalar ) & |
---|
1505 | s(k,j,nxlg:-1) = mean_inflow_profiles(k,7) |
---|
1506 | ENDDO |
---|
1507 | ENDDO |
---|
1508 | ENDIF |
---|
1509 | |
---|
1510 | ! |
---|
1511 | !-- Calculate the damping factors to be used at the inflow. For a |
---|
1512 | !-- turbulent inflow the turbulent fluctuations have to be limited |
---|
1513 | !-- vertically because otherwise the turbulent inflow layer will grow |
---|
1514 | !-- in time. |
---|
1515 | IF ( inflow_damping_height == 9999999.9_wp ) THEN |
---|
1516 | ! |
---|
1517 | !-- Default: use the inversion height calculated by the prerun; if |
---|
1518 | !-- this is zero, inflow_damping_height must be explicitly |
---|
1519 | !-- specified. |
---|
1520 | IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp ) THEN |
---|
1521 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
1522 | ELSE |
---|
1523 | WRITE( message_string, * ) 'inflow_damping_height must be ', & |
---|
1524 | 'explicitly specified because&the inversion height ', & |
---|
1525 | 'calculated by the prerun is zero.' |
---|
1526 | CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 ) |
---|
1527 | ENDIF |
---|
1528 | |
---|
1529 | ENDIF |
---|
1530 | |
---|
1531 | IF ( inflow_damping_width == 9999999.9_wp ) THEN |
---|
1532 | ! |
---|
1533 | !-- Default for the transition range: one tenth of the undamped |
---|
1534 | !-- layer |
---|
1535 | inflow_damping_width = 0.1_wp * inflow_damping_height |
---|
1536 | |
---|
1537 | ENDIF |
---|
1538 | |
---|
1539 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
1540 | |
---|
1541 | DO k = nzb, nzt+1 |
---|
1542 | |
---|
1543 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
1544 | inflow_damping_factor(k) = 1.0_wp |
---|
1545 | ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) ) THEN |
---|
1546 | inflow_damping_factor(k) = 1.0_wp - & |
---|
1547 | ( zu(k) - inflow_damping_height ) / & |
---|
1548 | inflow_damping_width |
---|
1549 | ELSE |
---|
1550 | inflow_damping_factor(k) = 0.0_wp |
---|
1551 | ENDIF |
---|
1552 | |
---|
1553 | ENDDO |
---|
1554 | |
---|
1555 | ENDIF |
---|
1556 | |
---|
1557 | ! |
---|
1558 | !-- Inside buildings set velocities and TKE back to zero |
---|
1559 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
1560 | topography /= 'flat' ) THEN |
---|
1561 | ! |
---|
1562 | !-- Inside buildings set velocities and TKE back to zero. |
---|
1563 | !-- Other scalars (pt, q, s, km, kh, p, sa, ...) are ignored at present, |
---|
1564 | !-- maybe revise later. |
---|
1565 | DO i = nxlg, nxrg |
---|
1566 | DO j = nysg, nyng |
---|
1567 | DO k = nzb, nzt |
---|
1568 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, & |
---|
1569 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
1570 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, & |
---|
1571 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
1572 | w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, & |
---|
1573 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
1574 | e(k,j,i) = MERGE( e(k,j,i), 0.0_wp, & |
---|
1575 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
1576 | tu_m(k,j,i) = MERGE( tu_m(k,j,i), 0.0_wp, & |
---|
1577 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
1578 | tv_m(k,j,i) = MERGE( tv_m(k,j,i), 0.0_wp, & |
---|
1579 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
1580 | tw_m(k,j,i) = MERGE( tw_m(k,j,i), 0.0_wp, & |
---|
1581 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
1582 | te_m(k,j,i) = MERGE( te_m(k,j,i), 0.0_wp, & |
---|
1583 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
1584 | tpt_m(k,j,i) = MERGE( tpt_m(k,j,i), 0.0_wp, & |
---|
1585 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
1586 | ENDDO |
---|
1587 | ENDDO |
---|
1588 | ENDDO |
---|
1589 | |
---|
1590 | ENDIF |
---|
1591 | |
---|
1592 | ! |
---|
1593 | !-- Calculate initial temperature field and other constants used in case |
---|
1594 | !-- of a sloping surface |
---|
1595 | IF ( sloping_surface ) CALL init_slope |
---|
1596 | |
---|
1597 | ! |
---|
1598 | !-- Initialize new time levels (only done in order to set boundary values |
---|
1599 | !-- including ghost points) |
---|
1600 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
1601 | IF ( humidity ) THEN |
---|
1602 | q_p = q |
---|
1603 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
1604 | qc_p = qc |
---|
1605 | nc_p = nc |
---|
1606 | ENDIF |
---|
1607 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
1608 | qr_p = qr |
---|
1609 | nr_p = nr |
---|
1610 | ENDIF |
---|
1611 | ENDIF |
---|
1612 | IF ( passive_scalar ) s_p = s |
---|
1613 | IF ( ocean ) sa_p = sa |
---|
1614 | |
---|
1615 | ! |
---|
1616 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
1617 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
1618 | !-- there before they are set. |
---|
1619 | te_m = 0.0_wp; tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
1620 | IF ( humidity ) THEN |
---|
1621 | tq_m = 0.0_wp |
---|
1622 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
1623 | tqc_m = 0.0_wp |
---|
1624 | tnc_m = 0.0_wp |
---|
1625 | ENDIF |
---|
1626 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
1627 | tqr_m = 0.0_wp |
---|
1628 | tnr_m = 0.0_wp |
---|
1629 | ENDIF |
---|
1630 | ENDIF |
---|
1631 | IF ( passive_scalar ) ts_m = 0.0_wp |
---|
1632 | IF ( ocean ) tsa_m = 0.0_wp |
---|
1633 | ! |
---|
1634 | !-- Initialize synthetic turbulence generator in case of restart. |
---|
1635 | IF ( TRIM( initializing_actions ) == 'read_restart_data' .AND. & |
---|
1636 | use_synthetic_turbulence_generator ) CALL stg_init |
---|
1637 | |
---|
1638 | CALL location_message( 'finished', .TRUE. ) |
---|
1639 | |
---|
1640 | ELSE |
---|
1641 | ! |
---|
1642 | !-- Actually this part of the programm should not be reached |
---|
1643 | message_string = 'unknown initializing problem' |
---|
1644 | CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 ) |
---|
1645 | ENDIF |
---|
1646 | |
---|
1647 | |
---|
1648 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1649 | ! |
---|
1650 | !-- Initialize old timelevels needed for radiation boundary conditions |
---|
1651 | IF ( outflow_l ) THEN |
---|
1652 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
1653 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
1654 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
1655 | ENDIF |
---|
1656 | IF ( outflow_r ) THEN |
---|
1657 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
1658 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
1659 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
1660 | ENDIF |
---|
1661 | IF ( outflow_s ) THEN |
---|
1662 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
1663 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
1664 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
1665 | ENDIF |
---|
1666 | IF ( outflow_n ) THEN |
---|
1667 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
1668 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
1669 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
1670 | ENDIF |
---|
1671 | |
---|
1672 | ENDIF |
---|
1673 | |
---|
1674 | ! |
---|
1675 | !-- Calculate the initial volume flow at the right and north boundary |
---|
1676 | IF ( conserve_volume_flow ) THEN |
---|
1677 | |
---|
1678 | IF ( use_prescribed_profile_data ) THEN |
---|
1679 | |
---|
1680 | volume_flow_initial_l = 0.0_wp |
---|
1681 | volume_flow_area_l = 0.0_wp |
---|
1682 | |
---|
1683 | IF ( nxr == nx ) THEN |
---|
1684 | DO j = nys, nyn |
---|
1685 | DO k = nzb+1, nzt |
---|
1686 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1687 | u_init(k) * dzw(k) & |
---|
1688 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1689 | BTEST( wall_flags_0(k,j,nxr), 1 )& |
---|
1690 | ) |
---|
1691 | |
---|
1692 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
1693 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1694 | BTEST( wall_flags_0(k,j,nxr), 1 )& |
---|
1695 | ) |
---|
1696 | ENDDO |
---|
1697 | ENDDO |
---|
1698 | ENDIF |
---|
1699 | |
---|
1700 | IF ( nyn == ny ) THEN |
---|
1701 | DO i = nxl, nxr |
---|
1702 | DO k = nzb+1, nzt |
---|
1703 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1704 | v_init(k) * dzw(k) & |
---|
1705 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1706 | BTEST( wall_flags_0(k,nyn,i), 2 )& |
---|
1707 | ) |
---|
1708 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
1709 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1710 | BTEST( wall_flags_0(k,nyn,i), 2 )& |
---|
1711 | ) |
---|
1712 | ENDDO |
---|
1713 | ENDDO |
---|
1714 | ENDIF |
---|
1715 | |
---|
1716 | #if defined( __parallel ) |
---|
1717 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1718 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1719 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1720 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1721 | |
---|
1722 | #else |
---|
1723 | volume_flow_initial = volume_flow_initial_l |
---|
1724 | volume_flow_area = volume_flow_area_l |
---|
1725 | #endif |
---|
1726 | |
---|
1727 | ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
1728 | |
---|
1729 | volume_flow_initial_l = 0.0_wp |
---|
1730 | volume_flow_area_l = 0.0_wp |
---|
1731 | |
---|
1732 | IF ( nxr == nx ) THEN |
---|
1733 | DO j = nys, nyn |
---|
1734 | DO k = nzb+1, nzt |
---|
1735 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1736 | hom_sum(k,1,0) * dzw(k) & |
---|
1737 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1738 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
1739 | ) |
---|
1740 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
1741 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1742 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
1743 | ) |
---|
1744 | ENDDO |
---|
1745 | ENDDO |
---|
1746 | ENDIF |
---|
1747 | |
---|
1748 | IF ( nyn == ny ) THEN |
---|
1749 | DO i = nxl, nxr |
---|
1750 | DO k = nzb+1, nzt |
---|
1751 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1752 | hom_sum(k,2,0) * dzw(k) & |
---|
1753 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1754 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
1755 | ) |
---|
1756 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
1757 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1758 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
1759 | ) |
---|
1760 | ENDDO |
---|
1761 | ENDDO |
---|
1762 | ENDIF |
---|
1763 | |
---|
1764 | #if defined( __parallel ) |
---|
1765 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1766 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1767 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1768 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1769 | |
---|
1770 | #else |
---|
1771 | volume_flow_initial = volume_flow_initial_l |
---|
1772 | volume_flow_area = volume_flow_area_l |
---|
1773 | #endif |
---|
1774 | |
---|
1775 | ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1776 | |
---|
1777 | volume_flow_initial_l = 0.0_wp |
---|
1778 | volume_flow_area_l = 0.0_wp |
---|
1779 | |
---|
1780 | IF ( nxr == nx ) THEN |
---|
1781 | DO j = nys, nyn |
---|
1782 | DO k = nzb+1, nzt |
---|
1783 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1784 | u(k,j,nx) * dzw(k) & |
---|
1785 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1786 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
1787 | ) |
---|
1788 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
1789 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1790 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
1791 | ) |
---|
1792 | ENDDO |
---|
1793 | ENDDO |
---|
1794 | ENDIF |
---|
1795 | |
---|
1796 | IF ( nyn == ny ) THEN |
---|
1797 | DO i = nxl, nxr |
---|
1798 | DO k = nzb+1, nzt |
---|
1799 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1800 | v(k,ny,i) * dzw(k) & |
---|
1801 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1802 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
1803 | ) |
---|
1804 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
1805 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1806 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
1807 | ) |
---|
1808 | ENDDO |
---|
1809 | ENDDO |
---|
1810 | ENDIF |
---|
1811 | |
---|
1812 | #if defined( __parallel ) |
---|
1813 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1814 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1815 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1816 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1817 | |
---|
1818 | #else |
---|
1819 | volume_flow_initial = volume_flow_initial_l |
---|
1820 | volume_flow_area = volume_flow_area_l |
---|
1821 | #endif |
---|
1822 | |
---|
1823 | ENDIF |
---|
1824 | |
---|
1825 | ! |
---|
1826 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is calculated |
---|
1827 | !-- from u|v_bulk instead |
---|
1828 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
1829 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
1830 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
1831 | ENDIF |
---|
1832 | |
---|
1833 | ENDIF |
---|
1834 | ! |
---|
1835 | !-- Initialize surface elements and its attributes, e.g. heat- and |
---|
1836 | !-- momentumfluxes, roughness, scaling parameters. |
---|
1837 | !-- This is already done in case of restart data. |
---|
1838 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
1839 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
1840 | CALL init_surfaces |
---|
1841 | ! |
---|
1842 | !-- Finally, if random_heatflux is set, disturb shf at horizontal |
---|
1843 | !-- surfaces. Actually, this should be done in surface_mod, where all other |
---|
1844 | !-- initializations of surface quantities are done. However, this |
---|
1845 | !-- would create a ring dependency, hence, it is done here. Maybe delete |
---|
1846 | !-- disturb_heatflux and tranfer the respective code directly into the |
---|
1847 | !-- initialization in surface_mod. |
---|
1848 | IF ( use_surface_fluxes .AND. constant_heatflux .AND. & |
---|
1849 | random_heatflux ) THEN |
---|
1850 | IF ( surf_def_h(0)%ns >= 1 ) CALL disturb_heatflux( surf_def_h(0) ) |
---|
1851 | IF ( surf_lsm_h%ns >= 1 ) CALL disturb_heatflux( surf_lsm_h ) |
---|
1852 | IF ( surf_usm_h%ns >= 1 ) CALL disturb_heatflux( surf_usm_h ) |
---|
1853 | ENDIF |
---|
1854 | ENDIF |
---|
1855 | |
---|
1856 | ! |
---|
1857 | !-- Initialize surface forcing corresponding to large-scale forcing. Therein, |
---|
1858 | !-- initialize heat-fluxes, etc. via datatype. Revise it later! |
---|
1859 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
1860 | IF ( use_surface_fluxes .AND. constant_heatflux ) THEN |
---|
1861 | CALL ls_forcing_surf ( simulated_time ) |
---|
1862 | ENDIF |
---|
1863 | ENDIF |
---|
1864 | ! |
---|
1865 | !-- Initialize quantities for special advections schemes |
---|
1866 | CALL init_advec |
---|
1867 | |
---|
1868 | ! |
---|
1869 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
1870 | !-- remove the divergences from the velocity field at the initial stage |
---|
1871 | IF ( create_disturbances .AND. disturbance_energy_limit /= 0.0_wp .AND. & |
---|
1872 | TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
1873 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
1874 | |
---|
1875 | CALL location_message( 'creating initial disturbances', .FALSE. ) |
---|
1876 | CALL disturb_field( 'u', tend, u ) |
---|
1877 | CALL disturb_field( 'v', tend, v ) |
---|
1878 | CALL location_message( 'finished', .TRUE. ) |
---|
1879 | |
---|
1880 | CALL location_message( 'calling pressure solver', .FALSE. ) |
---|
1881 | n_sor = nsor_ini |
---|
1882 | CALL pres |
---|
1883 | n_sor = nsor |
---|
1884 | CALL location_message( 'finished', .TRUE. ) |
---|
1885 | |
---|
1886 | ENDIF |
---|
1887 | |
---|
1888 | ! |
---|
1889 | !-- If required, initialize quantities needed for the plant canopy model |
---|
1890 | IF ( plant_canopy ) THEN |
---|
1891 | CALL location_message( 'initializing plant canopy model', .FALSE. ) |
---|
1892 | CALL pcm_init |
---|
1893 | CALL location_message( 'finished', .TRUE. ) |
---|
1894 | ENDIF |
---|
1895 | |
---|
1896 | ! |
---|
1897 | !-- If required, initialize dvrp-software |
---|
1898 | IF ( dt_dvrp /= 9999999.9_wp ) CALL init_dvrp |
---|
1899 | |
---|
1900 | IF ( ocean ) THEN |
---|
1901 | ! |
---|
1902 | !-- Initialize quantities needed for the ocean model |
---|
1903 | CALL init_ocean |
---|
1904 | |
---|
1905 | ELSE |
---|
1906 | ! |
---|
1907 | !-- Initialize quantities for handling cloud physics |
---|
1908 | !-- This routine must be called before lpm_init, because |
---|
1909 | !-- otherwise, array pt_d_t, needed in data_output_dvrp (called by |
---|
1910 | !-- lpm_init) is not defined. |
---|
1911 | CALL init_cloud_physics |
---|
1912 | ! |
---|
1913 | !-- Initialize bulk cloud microphysics |
---|
1914 | CALL microphysics_init |
---|
1915 | ENDIF |
---|
1916 | |
---|
1917 | ! |
---|
1918 | !-- If required, initialize particles |
---|
1919 | IF ( particle_advection ) CALL lpm_init |
---|
1920 | |
---|
1921 | ! |
---|
1922 | !-- If required, initialize quantities needed for the LSM |
---|
1923 | IF ( land_surface ) THEN |
---|
1924 | CALL location_message( 'initializing land surface model', .FALSE. ) |
---|
1925 | CALL lsm_init |
---|
1926 | CALL location_message( 'finished', .TRUE. ) |
---|
1927 | ENDIF |
---|
1928 | |
---|
1929 | ! |
---|
1930 | !-- Initialize surface layer (done after LSM as roughness length are required |
---|
1931 | !-- for initialization |
---|
1932 | IF ( constant_flux_layer ) THEN |
---|
1933 | CALL location_message( 'initializing surface layer', .FALSE. ) |
---|
1934 | CALL init_surface_layer_fluxes |
---|
1935 | CALL location_message( 'finished', .TRUE. ) |
---|
1936 | ENDIF |
---|
1937 | |
---|
1938 | ! |
---|
1939 | !-- If required, initialize radiation model |
---|
1940 | IF ( radiation ) THEN |
---|
1941 | CALL location_message( 'initializing radiation model', .FALSE. ) |
---|
1942 | CALL radiation_init |
---|
1943 | CALL location_message( 'finished', .TRUE. ) |
---|
1944 | ENDIF |
---|
1945 | |
---|
1946 | |
---|
1947 | ! |
---|
1948 | !-- Temporary solution to add LSM and radiation time series to the default |
---|
1949 | !-- output |
---|
1950 | IF ( land_surface .OR. radiation ) THEN |
---|
1951 | IF ( TRIM( radiation_scheme ) == 'rrtmg' ) THEN |
---|
1952 | dots_num = dots_num + 15 |
---|
1953 | ELSE |
---|
1954 | dots_num = dots_num + 11 |
---|
1955 | ENDIF |
---|
1956 | ENDIF |
---|
1957 | |
---|
1958 | ! |
---|
1959 | !-- If required, initialize urban surface model |
---|
1960 | IF ( urban_surface ) THEN |
---|
1961 | CALL location_message( 'initializing urban surface model', .FALSE. ) |
---|
1962 | CALL usm_init_urban_surface |
---|
1963 | CALL location_message( 'finished', .TRUE. ) |
---|
1964 | ENDIF |
---|
1965 | |
---|
1966 | ! |
---|
1967 | !-- If required, initialize quantities needed for the wind turbine model |
---|
1968 | IF ( wind_turbine ) THEN |
---|
1969 | CALL location_message( 'initializing wind turbine model', .FALSE. ) |
---|
1970 | CALL wtm_init |
---|
1971 | CALL location_message( 'finished', .TRUE. ) |
---|
1972 | ENDIF |
---|
1973 | |
---|
1974 | |
---|
1975 | ! |
---|
1976 | !-- Initialize the ws-scheme. |
---|
1977 | IF ( ws_scheme_sca .OR. ws_scheme_mom ) CALL ws_init |
---|
1978 | |
---|
1979 | ! |
---|
1980 | !-- Setting weighting factors for calculation of perturbation pressure |
---|
1981 | !-- and turbulent quantities from the RK substeps |
---|
1982 | IF ( TRIM(timestep_scheme) == 'runge-kutta-3' ) THEN ! for RK3-method |
---|
1983 | |
---|
1984 | weight_substep(1) = 1._wp/6._wp |
---|
1985 | weight_substep(2) = 3._wp/10._wp |
---|
1986 | weight_substep(3) = 8._wp/15._wp |
---|
1987 | |
---|
1988 | weight_pres(1) = 1._wp/3._wp |
---|
1989 | weight_pres(2) = 5._wp/12._wp |
---|
1990 | weight_pres(3) = 1._wp/4._wp |
---|
1991 | |
---|
1992 | ELSEIF ( TRIM(timestep_scheme) == 'runge-kutta-2' ) THEN ! for RK2-method |
---|
1993 | |
---|
1994 | weight_substep(1) = 1._wp/2._wp |
---|
1995 | weight_substep(2) = 1._wp/2._wp |
---|
1996 | |
---|
1997 | weight_pres(1) = 1._wp/2._wp |
---|
1998 | weight_pres(2) = 1._wp/2._wp |
---|
1999 | |
---|
2000 | ELSE ! for Euler-method |
---|
2001 | |
---|
2002 | weight_substep(1) = 1.0_wp |
---|
2003 | weight_pres(1) = 1.0_wp |
---|
2004 | |
---|
2005 | ENDIF |
---|
2006 | |
---|
2007 | ! |
---|
2008 | !-- Initialize Rayleigh damping factors |
---|
2009 | rdf = 0.0_wp |
---|
2010 | rdf_sc = 0.0_wp |
---|
2011 | IF ( rayleigh_damping_factor /= 0.0_wp ) THEN |
---|
2012 | IF ( .NOT. ocean ) THEN |
---|
2013 | DO k = nzb+1, nzt |
---|
2014 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
2015 | rdf(k) = rayleigh_damping_factor * & |
---|
2016 | ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height ) & |
---|
2017 | / ( zu(nzt) - rayleigh_damping_height ) ) & |
---|
2018 | )**2 |
---|
2019 | ENDIF |
---|
2020 | ENDDO |
---|
2021 | ELSE |
---|
2022 | DO k = nzt, nzb+1, -1 |
---|
2023 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
2024 | rdf(k) = rayleigh_damping_factor * & |
---|
2025 | ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) ) & |
---|
2026 | / ( rayleigh_damping_height - zu(nzb+1) ) ) & |
---|
2027 | )**2 |
---|
2028 | ENDIF |
---|
2029 | ENDDO |
---|
2030 | ENDIF |
---|
2031 | ENDIF |
---|
2032 | IF ( scalar_rayleigh_damping ) rdf_sc = rdf |
---|
2033 | |
---|
2034 | ! |
---|
2035 | !-- Initialize the starting level and the vertical smoothing factor used for |
---|
2036 | !-- the external pressure gradient |
---|
2037 | dp_smooth_factor = 1.0_wp |
---|
2038 | IF ( dp_external ) THEN |
---|
2039 | ! |
---|
2040 | !-- Set the starting level dp_level_ind_b only if it has not been set before |
---|
2041 | !-- (e.g. in init_grid). |
---|
2042 | IF ( dp_level_ind_b == 0 ) THEN |
---|
2043 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
2044 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
2045 | ! MINLOC uses lower array bound 1 |
---|
2046 | ENDIF |
---|
2047 | IF ( dp_smooth ) THEN |
---|
2048 | dp_smooth_factor(:dp_level_ind_b) = 0.0_wp |
---|
2049 | DO k = dp_level_ind_b+1, nzt |
---|
2050 | dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi * & |
---|
2051 | ( REAL( k - dp_level_ind_b, KIND=wp ) / & |
---|
2052 | REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) ) |
---|
2053 | ENDDO |
---|
2054 | ENDIF |
---|
2055 | ENDIF |
---|
2056 | |
---|
2057 | ! |
---|
2058 | !-- Initialize damping zone for the potential temperature in case of |
---|
2059 | !-- non-cyclic lateral boundaries. The damping zone has the maximum value |
---|
2060 | !-- at the inflow boundary and decreases to zero at pt_damping_width. |
---|
2061 | ptdf_x = 0.0_wp |
---|
2062 | ptdf_y = 0.0_wp |
---|
2063 | IF ( bc_lr_dirrad ) THEN |
---|
2064 | DO i = nxl, nxr |
---|
2065 | IF ( ( i * dx ) < pt_damping_width ) THEN |
---|
2066 | ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp * & |
---|
2067 | REAL( pt_damping_width - i * dx, KIND=wp ) / ( & |
---|
2068 | REAL( pt_damping_width, KIND=wp ) ) ) )**2 |
---|
2069 | ENDIF |
---|
2070 | ENDDO |
---|
2071 | ELSEIF ( bc_lr_raddir ) THEN |
---|
2072 | DO i = nxl, nxr |
---|
2073 | IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) ) THEN |
---|
2074 | ptdf_x(i) = pt_damping_factor * & |
---|
2075 | SIN( pi * 0.5_wp * & |
---|
2076 | ( ( i - nx ) * dx + pt_damping_width ) / & |
---|
2077 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
2078 | ENDIF |
---|
2079 | ENDDO |
---|
2080 | ELSEIF ( bc_ns_dirrad ) THEN |
---|
2081 | DO j = nys, nyn |
---|
2082 | IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) ) THEN |
---|
2083 | ptdf_y(j) = pt_damping_factor * & |
---|
2084 | SIN( pi * 0.5_wp * & |
---|
2085 | ( ( j - ny ) * dy + pt_damping_width ) / & |
---|
2086 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
2087 | ENDIF |
---|
2088 | ENDDO |
---|
2089 | ELSEIF ( bc_ns_raddir ) THEN |
---|
2090 | DO j = nys, nyn |
---|
2091 | IF ( ( j * dy ) < pt_damping_width ) THEN |
---|
2092 | ptdf_y(j) = pt_damping_factor * & |
---|
2093 | SIN( pi * 0.5_wp * & |
---|
2094 | ( pt_damping_width - j * dy ) / & |
---|
2095 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
2096 | ENDIF |
---|
2097 | ENDDO |
---|
2098 | ENDIF |
---|
2099 | |
---|
2100 | ! |
---|
2101 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
2102 | !-- Ghost points are excluded because counting values at the ghost boundaries |
---|
2103 | !-- would bias the statistics |
---|
2104 | rmask = 1.0_wp |
---|
2105 | rmask(:,nxlg:nxl-1,:) = 0.0_wp; rmask(:,nxr+1:nxrg,:) = 0.0_wp |
---|
2106 | rmask(nysg:nys-1,:,:) = 0.0_wp; rmask(nyn+1:nyng,:,:) = 0.0_wp |
---|
2107 | |
---|
2108 | ! |
---|
2109 | !-- User-defined initializing actions. Check afterwards, if maximum number |
---|
2110 | !-- of allowed timeseries is exceeded |
---|
2111 | CALL user_init |
---|
2112 | |
---|
2113 | IF ( dots_num > dots_max ) THEN |
---|
2114 | WRITE( message_string, * ) 'number of time series quantities exceeds', & |
---|
2115 | ' its maximum of dots_max = ', dots_max, & |
---|
2116 | ' &Please increase dots_max in modules.f90.' |
---|
2117 | CALL message( 'init_3d_model', 'PA0194', 1, 2, 0, 6, 0 ) |
---|
2118 | ENDIF |
---|
2119 | |
---|
2120 | ! |
---|
2121 | !-- Input binary data file is not needed anymore. This line must be placed |
---|
2122 | !-- after call of user_init! |
---|
2123 | CALL close_file( 13 ) |
---|
2124 | |
---|
2125 | ! |
---|
2126 | !-- Compute total sum of active mask grid points |
---|
2127 | !-- and the mean surface level height for each statistic region |
---|
2128 | !-- ngp_2dh: number of grid points of a horizontal cross section through the |
---|
2129 | !-- total domain |
---|
2130 | !-- ngp_3d: number of grid points of the total domain |
---|
2131 | ngp_2dh_outer_l = 0 |
---|
2132 | ngp_2dh_outer = 0 |
---|
2133 | ngp_2dh_s_inner_l = 0 |
---|
2134 | ngp_2dh_s_inner = 0 |
---|
2135 | ngp_2dh_l = 0 |
---|
2136 | ngp_2dh = 0 |
---|
2137 | ngp_3d_inner_l = 0.0_wp |
---|
2138 | ngp_3d_inner = 0 |
---|
2139 | ngp_3d = 0 |
---|
2140 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
2141 | |
---|
2142 | mean_surface_level_height = 0.0_wp |
---|
2143 | mean_surface_level_height_l = 0.0_wp |
---|
2144 | |
---|
2145 | ! |
---|
2146 | !-- To do: New concept for these non-topography grid points! |
---|
2147 | DO sr = 0, statistic_regions |
---|
2148 | DO i = nxl, nxr |
---|
2149 | DO j = nys, nyn |
---|
2150 | IF ( rmask(j,i,sr) == 1.0_wp ) THEN |
---|
2151 | ! |
---|
2152 | !-- All xy-grid points |
---|
2153 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
2154 | ! |
---|
2155 | !-- Determine mean surface-level height. In case of downward- |
---|
2156 | !-- facing walls are present, more than one surface level exist. |
---|
2157 | !-- In this case, use the lowest surface-level height. |
---|
2158 | IF ( surf_def_h(0)%start_index(j,i) <= & |
---|
2159 | surf_def_h(0)%end_index(j,i) ) THEN |
---|
2160 | m = surf_def_h(0)%start_index(j,i) |
---|
2161 | k = surf_def_h(0)%k(m) |
---|
2162 | mean_surface_level_height_l(sr) = & |
---|
2163 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
2164 | ENDIF |
---|
2165 | IF ( surf_lsm_h%start_index(j,i) <= & |
---|
2166 | surf_lsm_h%end_index(j,i) ) THEN |
---|
2167 | m = surf_lsm_h%start_index(j,i) |
---|
2168 | k = surf_lsm_h%k(m) |
---|
2169 | mean_surface_level_height_l(sr) = & |
---|
2170 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
2171 | ENDIF |
---|
2172 | IF ( surf_usm_h%start_index(j,i) <= & |
---|
2173 | surf_usm_h%end_index(j,i) ) THEN |
---|
2174 | m = surf_usm_h%start_index(j,i) |
---|
2175 | k = surf_usm_h%k(m) |
---|
2176 | mean_surface_level_height_l(sr) = & |
---|
2177 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
2178 | ENDIF |
---|
2179 | |
---|
2180 | k_surf = k - 1 |
---|
2181 | |
---|
2182 | DO k = nzb, nzt+1 |
---|
2183 | ! |
---|
2184 | !-- xy-grid points above topography |
---|
2185 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + & |
---|
2186 | MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 24 ) ) |
---|
2187 | |
---|
2188 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + & |
---|
2189 | MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 22 ) ) |
---|
2190 | |
---|
2191 | ENDDO |
---|
2192 | ! |
---|
2193 | !-- All grid points of the total domain above topography |
---|
2194 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + ( nz - k_surf + 2 ) |
---|
2195 | |
---|
2196 | |
---|
2197 | |
---|
2198 | ENDIF |
---|
2199 | ENDDO |
---|
2200 | ENDDO |
---|
2201 | ENDDO |
---|
2202 | |
---|
2203 | sr = statistic_regions + 1 |
---|
2204 | #if defined( __parallel ) |
---|
2205 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2206 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & |
---|
2207 | comm2d, ierr ) |
---|
2208 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2209 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & |
---|
2210 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
2211 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2212 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), & |
---|
2213 | (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
2214 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2215 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, & |
---|
2216 | MPI_SUM, comm2d, ierr ) |
---|
2217 | ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
2218 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
2219 | CALL MPI_ALLREDUCE( mean_surface_level_height_l(0), & |
---|
2220 | mean_surface_level_height(0), sr, MPI_REAL, & |
---|
2221 | MPI_SUM, comm2d, ierr ) |
---|
2222 | mean_surface_level_height = mean_surface_level_height / REAL( ngp_2dh ) |
---|
2223 | #else |
---|
2224 | ngp_2dh = ngp_2dh_l |
---|
2225 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
2226 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
2227 | ngp_3d_inner = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
2228 | mean_surface_level_height = mean_surface_level_height_l / REAL( ngp_2dh_l ) |
---|
2229 | #endif |
---|
2230 | |
---|
2231 | ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * & |
---|
2232 | INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) ) |
---|
2233 | |
---|
2234 | ! |
---|
2235 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, |
---|
2236 | !-- buoyancy, etc. A zero value will occur for cases where all grid points of |
---|
2237 | !-- the respective subdomain lie below the surface topography |
---|
2238 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
2239 | ngp_3d_inner = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), & |
---|
2240 | ngp_3d_inner(:) ) |
---|
2241 | ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) |
---|
2242 | |
---|
2243 | DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l, & |
---|
2244 | ngp_3d_inner_l, ngp_3d_inner_tmp ) |
---|
2245 | |
---|
2246 | CALL location_message( 'leaving init_3d_model', .TRUE. ) |
---|
2247 | |
---|
2248 | END SUBROUTINE init_3d_model |
---|