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