1 | #if defined( __ibmy_special ) |
---|
2 | @PROCESS NOOPTimize |
---|
3 | #endif |
---|
4 | SUBROUTINE init_3d_model |
---|
5 | |
---|
6 | !--------------------------------------------------------------------------------! |
---|
7 | ! This file is part of PALM. |
---|
8 | ! |
---|
9 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
10 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
11 | ! either version 3 of the License, or (at your option) any later version. |
---|
12 | ! |
---|
13 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
14 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
15 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
16 | ! |
---|
17 | ! You should have received a copy of the GNU General Public License along with |
---|
18 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | ! |
---|
20 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
21 | !--------------------------------------------------------------------------------! |
---|
22 | ! |
---|
23 | ! Current revisions: |
---|
24 | ! ------------------ |
---|
25 | ! array tri is allocated and included in data copy statement |
---|
26 | ! |
---|
27 | ! Former revisions: |
---|
28 | ! ----------------- |
---|
29 | ! $Id: init_3d_model.f90 1212 2013-08-15 08:46:27Z raasch $ |
---|
30 | ! |
---|
31 | ! 1195 2013-07-01 12:27:57Z heinze |
---|
32 | ! Bugfix: move allocation of ref_state to parin.f90 and read_var_list.f90 |
---|
33 | ! |
---|
34 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
35 | ! allocate and set ref_state to be used in buoyancy terms |
---|
36 | ! |
---|
37 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
38 | ! diss array is allocated with full size if accelerator boards are used |
---|
39 | ! |
---|
40 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
41 | ! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir |
---|
42 | ! |
---|
43 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
44 | ! diss array is allocated with dummy elements even if it is not needed |
---|
45 | ! (required by PGI 13.4 / CUDA 5.0) |
---|
46 | ! |
---|
47 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
48 | ! unused variables removed |
---|
49 | ! |
---|
50 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
51 | ! openACC directive modified |
---|
52 | ! |
---|
53 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
54 | ! openACC directives added for pres |
---|
55 | ! array diss allocated only if required |
---|
56 | ! |
---|
57 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
58 | ! unused variables removed |
---|
59 | ! |
---|
60 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
61 | ! allocation of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
62 | ! |
---|
63 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
64 | ! allocation and initialisation of necessary data arrays for the two-moment |
---|
65 | ! cloud physics scheme the two new prognostic equations (nr, qr): |
---|
66 | ! +dr, lambda_r, mu_r, sed_*, xr, *s, *sws, *swst, *, *_p, t*_m, *_1, *_2, *_3, |
---|
67 | ! +tend_*, prr |
---|
68 | ! |
---|
69 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
70 | ! code put under GPL (PALM 3.9) |
---|
71 | ! |
---|
72 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
73 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
74 | ! |
---|
75 | ! 1025 2012-10-07 16:04:41Z letzel |
---|
76 | ! bugfix: swap indices of mask for ghost boundaries |
---|
77 | ! |
---|
78 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
79 | ! mask is set to zero for ghost boundaries |
---|
80 | ! |
---|
81 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
82 | ! cpp switch __nopointer added for pointer free version |
---|
83 | ! |
---|
84 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
85 | ! nxra,nyna, nzta replaced ny nxr, nyn, nzt |
---|
86 | ! |
---|
87 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
88 | ! all actions concerning leapfrog scheme removed |
---|
89 | ! |
---|
90 | ! 996 2012-09-07 10:41:47Z raasch |
---|
91 | ! little reformatting |
---|
92 | ! |
---|
93 | ! 978 2012-08-09 08:28:32Z fricke |
---|
94 | ! outflow damping layer removed |
---|
95 | ! roughness length for scalar quantites z0h added |
---|
96 | ! damping zone for the potential temperatur in case of non-cyclic lateral |
---|
97 | ! boundaries added |
---|
98 | ! initialization of ptdf_x, ptdf_y |
---|
99 | ! initialization of c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l |
---|
100 | ! |
---|
101 | ! 849 2012-03-15 10:35:09Z raasch |
---|
102 | ! init_particles renamed lpm_init |
---|
103 | ! |
---|
104 | ! 825 2012-02-19 03:03:44Z raasch |
---|
105 | ! wang_collision_kernel renamed wang_kernel |
---|
106 | ! |
---|
107 | ! 790 2011-11-29 03:11:20Z raasch |
---|
108 | ! diss is also allocated in case that the Wang kernel is used |
---|
109 | ! |
---|
110 | ! 787 2011-11-28 12:49:05Z heinze $ |
---|
111 | ! bugfix: call init_advec in every case - not only for inital runs |
---|
112 | ! |
---|
113 | ! 785 2011-11-28 09:47:19Z raasch |
---|
114 | ! initialization of rdf_sc |
---|
115 | ! |
---|
116 | ! 767 2011-10-14 06:39:12Z raasch |
---|
117 | ! adjustments concerning implementation of prescribed u,v-profiles |
---|
118 | ! bugfix: dirichlet_0 conditions for ug/vg moved to check_parameters |
---|
119 | ! |
---|
120 | ! 759 2011-09-15 13:58:31Z raasch |
---|
121 | ! Splitting of parallel I/O in blocks of PEs |
---|
122 | ! Bugfix: No zero assignments to volume_flow_initial and volume_flow_area in |
---|
123 | ! case of normal restart runs. |
---|
124 | ! |
---|
125 | ! 713 2011-03-30 14:21:21Z suehring |
---|
126 | ! weight_substep and weight_pres are given as fractions. |
---|
127 | ! |
---|
128 | ! 709 2011-03-30 09:31:40Z raasch |
---|
129 | ! formatting adjustments |
---|
130 | ! |
---|
131 | ! 707 2011-03-29 11:39:40Z raasch |
---|
132 | ! p_sub renamed p_loc and allocated depending on the chosen pressure solver, |
---|
133 | ! initial assignments of zero to array p for iterative solvers only, |
---|
134 | ! bc_lr/ns replaced by bc_lr/ns_dirrad/raddir |
---|
135 | ! |
---|
136 | ! 680 2011-02-04 23:16:06Z gryschka |
---|
137 | ! bugfix: volume_flow_control |
---|
138 | ! |
---|
139 | ! 673 2011-01-18 16:19:48Z suehring |
---|
140 | ! weight_substep (moved from advec_ws) and weight_pres added. |
---|
141 | ! Allocate p_sub when using Multigrid or SOR solver. |
---|
142 | ! Call of ws_init moved behind the if requests. |
---|
143 | ! |
---|
144 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
145 | ! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and |
---|
146 | ! allocation of arrays. Calls of exchange_horiz are modified. |
---|
147 | ! Call ws_init to initialize arrays needed for calculating statisticas and for |
---|
148 | ! optimization when ws-scheme is used. |
---|
149 | ! Initial volume flow is now calculated by using the variable hom_sum. |
---|
150 | ! Therefore the correction of initial volume flow for non-flat topography |
---|
151 | ! removed (removed u_nzb_p1_for_vfc and v_nzb_p1_for_vfc) |
---|
152 | ! Changed surface boundary conditions for u and v in case of ibc_uv_b == 0 from |
---|
153 | ! mirror to Dirichlet boundary conditions (u=v=0), so that k=nzb is |
---|
154 | ! representative for the height z0. |
---|
155 | ! Bugfix: type conversion of '1' to 64bit for the MAX function (ngp_3d_inner) |
---|
156 | ! |
---|
157 | ! 622 2010-12-10 08:08:13Z raasch |
---|
158 | ! optional barriers included in order to speed up collective operations |
---|
159 | ! |
---|
160 | ! 560 2010-09-09 10:06:09Z weinreis |
---|
161 | ! bugfix: correction of calculating ngp_3d for 64 bit |
---|
162 | ! |
---|
163 | ! 485 2010-02-05 10:57:51Z raasch |
---|
164 | ! calculation of ngp_3d + ngp_3d_inner changed because they have now 64 bit |
---|
165 | ! |
---|
166 | ! 407 2009-12-01 15:01:15Z maronga |
---|
167 | ! var_ts is replaced by dots_max |
---|
168 | ! Enabled passive scalar/humidity wall fluxes for non-flat topography |
---|
169 | ! |
---|
170 | ! 388 2009-09-23 09:40:33Z raasch |
---|
171 | ! Initialization of prho added. |
---|
172 | ! bugfix: correction of initial volume flow for non-flat topography |
---|
173 | ! bugfix: zero initialization of arrays within buildings for 'cyclic_fill' |
---|
174 | ! bugfix: avoid that ngp_2dh_s_inner becomes zero |
---|
175 | ! initializing_actions='read_data_for_recycling' renamed to 'cyclic_fill', now |
---|
176 | ! independent of turbulent_inflow |
---|
177 | ! Output of messages replaced by message handling routine. |
---|
178 | ! Set the starting level and the vertical smoothing factor used for |
---|
179 | ! the external pressure gradient |
---|
180 | ! +conserve_volume_flow_mode: 'default', 'initial_profiles', 'inflow_profile' |
---|
181 | ! and 'bulk_velocity' |
---|
182 | ! If the inversion height calculated by the prerun is zero, |
---|
183 | ! inflow_damping_height must be explicitly specified. |
---|
184 | ! |
---|
185 | ! 181 2008-07-30 07:07:47Z raasch |
---|
186 | ! bugfix: zero assignments to tendency arrays in case of restarts, |
---|
187 | ! further extensions and modifications in the initialisation of the plant |
---|
188 | ! canopy model, |
---|
189 | ! allocation of hom_sum moved to parin, initialization of spectrum_x|y directly |
---|
190 | ! after allocating theses arrays, |
---|
191 | ! read data for recycling added as new initialization option, |
---|
192 | ! dummy allocation for diss |
---|
193 | ! |
---|
194 | ! 138 2007-11-28 10:03:58Z letzel |
---|
195 | ! New counter ngp_2dh_s_inner. |
---|
196 | ! Allow new case bc_uv_t = 'dirichlet_0' for channel flow. |
---|
197 | ! Corrected calculation of initial volume flow for 'set_1d-model_profiles' and |
---|
198 | ! 'set_constant_profiles' in case of buildings in the reference cross-sections. |
---|
199 | ! |
---|
200 | ! 108 2007-08-24 15:10:38Z letzel |
---|
201 | ! Flux initialization in case of coupled runs, +momentum fluxes at top boundary, |
---|
202 | ! +arrays for phase speed c_u, c_v, c_w, indices for u|v|w_m_l|r changed |
---|
203 | ! +qswst_remote in case of atmosphere model with humidity coupled to ocean |
---|
204 | ! Rayleigh damping for ocean, optionally calculate km and kh from initial |
---|
205 | ! TKE e_init |
---|
206 | ! |
---|
207 | ! 97 2007-06-21 08:23:15Z raasch |
---|
208 | ! Initialization of salinity, call of init_ocean |
---|
209 | ! |
---|
210 | ! 87 2007-05-22 15:46:47Z raasch |
---|
211 | ! var_hom and var_sum renamed pr_palm |
---|
212 | ! |
---|
213 | ! 75 2007-03-22 09:54:05Z raasch |
---|
214 | ! Arrays for radiation boundary conditions are allocated (u_m_l, u_m_r, etc.), |
---|
215 | ! bugfix for cases with the outflow damping layer extending over more than one |
---|
216 | ! subdomain, moisture renamed humidity, |
---|
217 | ! new initializing action "by_user" calls user_init_3d_model, |
---|
218 | ! precipitation_amount/rate, ts_value are allocated, +module netcdf_control, |
---|
219 | ! initial velocities at nzb+1 are regarded for volume |
---|
220 | ! flow control in case they have been set zero before (to avoid small timesteps) |
---|
221 | ! -uvmean_outflow, uxrp, vynp eliminated |
---|
222 | ! |
---|
223 | ! 19 2007-02-23 04:53:48Z raasch |
---|
224 | ! +handling of top fluxes |
---|
225 | ! |
---|
226 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
227 | ! |
---|
228 | ! Revision 1.49 2006/08/22 15:59:07 raasch |
---|
229 | ! No optimization of this file on the ibmy (Yonsei Univ.) |
---|
230 | ! |
---|
231 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
232 | ! Initial revision |
---|
233 | ! |
---|
234 | ! |
---|
235 | ! Description: |
---|
236 | ! ------------ |
---|
237 | ! Allocation of arrays and initialization of the 3D model via |
---|
238 | ! a) pre-run the 1D model |
---|
239 | ! or |
---|
240 | ! b) pre-set constant linear profiles |
---|
241 | ! or |
---|
242 | ! c) read values of a previous run |
---|
243 | !------------------------------------------------------------------------------! |
---|
244 | |
---|
245 | USE advec_ws |
---|
246 | USE arrays_3d |
---|
247 | USE averaging |
---|
248 | USE cloud_parameters |
---|
249 | USE constants |
---|
250 | USE control_parameters |
---|
251 | USE cpulog |
---|
252 | USE grid_variables |
---|
253 | USE indices |
---|
254 | USE interfaces |
---|
255 | USE model_1d |
---|
256 | USE netcdf_control |
---|
257 | USE particle_attributes |
---|
258 | USE pegrid |
---|
259 | USE profil_parameter |
---|
260 | USE random_function_mod |
---|
261 | USE statistics |
---|
262 | USE transpose_indices |
---|
263 | |
---|
264 | IMPLICIT NONE |
---|
265 | |
---|
266 | INTEGER :: i, ind_array(1), j, k, sr |
---|
267 | |
---|
268 | INTEGER, DIMENSION(:), ALLOCATABLE :: ngp_2dh_l |
---|
269 | |
---|
270 | INTEGER, DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l, & |
---|
271 | ngp_2dh_s_inner_l |
---|
272 | |
---|
273 | REAL, DIMENSION(1:2) :: volume_flow_area_l, volume_flow_initial_l |
---|
274 | |
---|
275 | REAL, DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_l, ngp_3d_inner_tmp |
---|
276 | |
---|
277 | |
---|
278 | ! |
---|
279 | !-- Allocate arrays |
---|
280 | ALLOCATE( ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
281 | ngp_3d(0:statistic_regions), & |
---|
282 | ngp_3d_inner(0:statistic_regions), & |
---|
283 | ngp_3d_inner_l(0:statistic_regions), & |
---|
284 | ngp_3d_inner_tmp(0:statistic_regions), & |
---|
285 | sums_divnew_l(0:statistic_regions), & |
---|
286 | sums_divold_l(0:statistic_regions) ) |
---|
287 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) ) |
---|
288 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
289 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
290 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
291 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
292 | rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions), & |
---|
293 | sums(nzb:nzt+1,pr_palm+max_pr_user), & |
---|
294 | sums_l(nzb:nzt+1,pr_palm+max_pr_user,0:threads_per_task-1), & |
---|
295 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
296 | sums_up_fraction_l(10,3,0:statistic_regions), & |
---|
297 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions), & |
---|
298 | ts_value(dots_max,0:statistic_regions) ) |
---|
299 | ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) ) |
---|
300 | |
---|
301 | ALLOCATE( rif(nysg:nyng,nxlg:nxrg), shf(nysg:nyng,nxlg:nxrg), & |
---|
302 | ts(nysg:nyng,nxlg:nxrg), tswst(nysg:nyng,nxlg:nxrg), & |
---|
303 | us(nysg:nyng,nxlg:nxrg), usws(nysg:nyng,nxlg:nxrg), & |
---|
304 | uswst(nysg:nyng,nxlg:nxrg), vsws(nysg:nyng,nxlg:nxrg), & |
---|
305 | vswst(nysg:nyng,nxlg:nxrg), z0(nysg:nyng,nxlg:nxrg), & |
---|
306 | z0h(nysg:nyng,nxlg:nxrg) ) |
---|
307 | |
---|
308 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
309 | kh(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
310 | km(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
311 | p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
312 | tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
313 | |
---|
314 | #if defined( __nopointer ) |
---|
315 | ALLOCATE( e(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
316 | e_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
317 | pt(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
318 | pt_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
319 | u(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
320 | u_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
321 | v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
322 | v_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
323 | w(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
324 | w_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
325 | te_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
326 | tpt_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
327 | tu_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
328 | tv_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
329 | tw_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
330 | #else |
---|
331 | ALLOCATE( e_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
332 | e_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
333 | e_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
334 | pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
335 | pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
336 | u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
337 | u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
338 | u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
339 | v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
340 | v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
341 | v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
342 | w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
343 | w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
344 | w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
345 | IF ( .NOT. neutral ) THEN |
---|
346 | ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
347 | ENDIF |
---|
348 | #endif |
---|
349 | |
---|
350 | ! |
---|
351 | !-- Following array is required for perturbation pressure within the iterative |
---|
352 | !-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds |
---|
353 | !-- the weighted average of the substeps and cannot be used in the Poisson |
---|
354 | !-- solver. |
---|
355 | IF ( psolver == 'sor' ) THEN |
---|
356 | ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
357 | ELSEIF ( psolver == 'multigrid' ) THEN |
---|
358 | ! |
---|
359 | !-- For performance reasons, multigrid is using one ghost layer only |
---|
360 | ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
361 | ENDIF |
---|
362 | |
---|
363 | ! |
---|
364 | !-- Array for storing constant coeffficients of the tridiagonal solver |
---|
365 | IF ( psolver == 'poisfft' ) THEN |
---|
366 | ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) ) |
---|
367 | ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) ) |
---|
368 | ENDIF |
---|
369 | |
---|
370 | IF ( humidity .OR. passive_scalar ) THEN |
---|
371 | ! |
---|
372 | !-- 2D-humidity/scalar arrays |
---|
373 | ALLOCATE ( qs(nysg:nyng,nxlg:nxrg), & |
---|
374 | qsws(nysg:nyng,nxlg:nxrg), & |
---|
375 | qswst(nysg:nyng,nxlg:nxrg) ) |
---|
376 | |
---|
377 | ! |
---|
378 | !-- 3D-humidity/scalar arrays |
---|
379 | #if defined( __nopointer ) |
---|
380 | ALLOCATE( q(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
381 | q_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
382 | tq_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
383 | #else |
---|
384 | ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
385 | q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
386 | q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
387 | #endif |
---|
388 | |
---|
389 | ! |
---|
390 | !-- 3D-arrays needed for humidity only |
---|
391 | IF ( humidity ) THEN |
---|
392 | #if defined( __nopointer ) |
---|
393 | ALLOCATE( vpt(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
394 | #else |
---|
395 | ALLOCATE( vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
396 | #endif |
---|
397 | |
---|
398 | IF ( cloud_physics ) THEN |
---|
399 | |
---|
400 | ! |
---|
401 | !-- Liquid water content |
---|
402 | #if defined( __nopointer ) |
---|
403 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
404 | #else |
---|
405 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
406 | #endif |
---|
407 | ! |
---|
408 | !-- Precipitation amount and rate (only needed if output is switched) |
---|
409 | ALLOCATE( precipitation_amount(nysg:nyng,nxlg:nxrg), & |
---|
410 | precipitation_rate(nysg:nyng,nxlg:nxrg) ) |
---|
411 | |
---|
412 | IF ( icloud_scheme == 0 ) THEN |
---|
413 | ! |
---|
414 | !-- 1D-arrays |
---|
415 | ALLOCATE ( nc_1d(nzb:nzt+1), pt_1d(nzb:nzt+1), & |
---|
416 | q_1d(nzb:nzt+1), qc_1d(nzb:nzt+1) ) |
---|
417 | ! |
---|
418 | !-- 3D-cloud water content |
---|
419 | #if defined( __nopointer ) |
---|
420 | ALLOCATE( qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
421 | #else |
---|
422 | ALLOCATE( qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
423 | #endif |
---|
424 | ! |
---|
425 | !-- 3D-tendency arrays |
---|
426 | ALLOCATE( tend_pt(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
427 | tend_q(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
428 | |
---|
429 | IF ( precipitation ) THEN |
---|
430 | ! |
---|
431 | !-- 1D-arrays |
---|
432 | ALLOCATE ( nr_1d(nzb:nzt+1), qr_1d(nzb:nzt+1) ) |
---|
433 | ! |
---|
434 | ! |
---|
435 | !-- 3D-tendency arrays |
---|
436 | ALLOCATE( tend_nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
437 | tend_qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
438 | ! |
---|
439 | !-- 2D-rain water content and rain drop concentration arrays |
---|
440 | ALLOCATE ( qrs(nysg:nyng,nxlg:nxrg), & |
---|
441 | qrsws(nysg:nyng,nxlg:nxrg), & |
---|
442 | qrswst(nysg:nyng,nxlg:nxrg), & |
---|
443 | nrs(nysg:nyng,nxlg:nxrg), & |
---|
444 | nrsws(nysg:nyng,nxlg:nxrg), & |
---|
445 | nrswst(nysg:nyng,nxlg:nxrg) ) |
---|
446 | ! |
---|
447 | !-- 3D-rain water content, rain drop concentration arrays |
---|
448 | #if defined( __nopointer ) |
---|
449 | ALLOCATE( nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
450 | nr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
451 | qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
452 | qr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
453 | tnr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
454 | tqr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
455 | #else |
---|
456 | ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
457 | nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
458 | nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
459 | qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
460 | qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
461 | qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
462 | #endif |
---|
463 | ! |
---|
464 | !-- 3d-precipitation rate |
---|
465 | ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
466 | ENDIF |
---|
467 | |
---|
468 | ENDIF |
---|
469 | ENDIF |
---|
470 | |
---|
471 | IF ( cloud_droplets ) THEN |
---|
472 | ! |
---|
473 | !-- Liquid water content, change in liquid water content |
---|
474 | #if defined( __nopointer ) |
---|
475 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
476 | ql_c(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
477 | #else |
---|
478 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
479 | ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
480 | #endif |
---|
481 | ! |
---|
482 | !-- Real volume of particles (with weighting), volume of particles |
---|
483 | ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
484 | ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
485 | ENDIF |
---|
486 | |
---|
487 | ENDIF |
---|
488 | |
---|
489 | ENDIF |
---|
490 | |
---|
491 | IF ( ocean ) THEN |
---|
492 | ALLOCATE( saswsb(nysg:nyng,nxlg:nxrg), & |
---|
493 | saswst(nysg:nyng,nxlg:nxrg) ) |
---|
494 | #if defined( __nopointer ) |
---|
495 | ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
496 | rho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
497 | sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
498 | sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
499 | tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
500 | #else |
---|
501 | ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
502 | rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
503 | sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
504 | sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
505 | sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
506 | prho => prho_1 |
---|
507 | rho => rho_1 ! routines calc_mean_profile and diffusion_e require |
---|
508 | ! density to be apointer |
---|
509 | #endif |
---|
510 | IF ( humidity_remote ) THEN |
---|
511 | ALLOCATE( qswst_remote(nysg:nyng,nxlg:nxrg)) |
---|
512 | qswst_remote = 0.0 |
---|
513 | ENDIF |
---|
514 | ENDIF |
---|
515 | |
---|
516 | ! |
---|
517 | !-- 3D-array for storing the dissipation, needed for calculating the sgs |
---|
518 | !-- particle velocities |
---|
519 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. turbulence .OR. & |
---|
520 | num_acc_per_node > 0 ) THEN |
---|
521 | ALLOCATE( diss(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
522 | ENDIF |
---|
523 | |
---|
524 | IF ( dt_dosp /= 9999999.9 ) THEN |
---|
525 | ALLOCATE( spectrum_x( 1:nx/2, 1:10, 1:10 ), & |
---|
526 | spectrum_y( 1:ny/2, 1:10, 1:10 ) ) |
---|
527 | spectrum_x = 0.0 |
---|
528 | spectrum_y = 0.0 |
---|
529 | ENDIF |
---|
530 | |
---|
531 | ! |
---|
532 | !-- 3D-arrays for the leaf area density and the canopy drag coefficient |
---|
533 | IF ( plant_canopy ) THEN |
---|
534 | ALLOCATE ( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
535 | lad_u(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
536 | lad_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
537 | lad_w(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
538 | cdc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
539 | |
---|
540 | IF ( passive_scalar ) THEN |
---|
541 | ALLOCATE ( sls(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
542 | sec(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
543 | ENDIF |
---|
544 | |
---|
545 | IF ( cthf /= 0.0 ) THEN |
---|
546 | ALLOCATE ( lai(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
547 | canopy_heat_flux(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
548 | ENDIF |
---|
549 | |
---|
550 | ENDIF |
---|
551 | |
---|
552 | ! |
---|
553 | !-- 4D-array for storing the Rif-values at vertical walls |
---|
554 | IF ( topography /= 'flat' ) THEN |
---|
555 | ALLOCATE( rif_wall(nzb:nzt+1,nysg:nyng,nxlg:nxrg,1:4) ) |
---|
556 | rif_wall = 0.0 |
---|
557 | ENDIF |
---|
558 | |
---|
559 | ! |
---|
560 | !-- Arrays to store velocity data from t-dt and the phase speeds which |
---|
561 | !-- are needed for radiation boundary conditions |
---|
562 | IF ( outflow_l ) THEN |
---|
563 | ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2), & |
---|
564 | v_m_l(nzb:nzt+1,nysg:nyng,0:1), & |
---|
565 | w_m_l(nzb:nzt+1,nysg:nyng,0:1) ) |
---|
566 | ENDIF |
---|
567 | IF ( outflow_r ) THEN |
---|
568 | ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
569 | v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
570 | w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) ) |
---|
571 | ENDIF |
---|
572 | IF ( outflow_l .OR. outflow_r ) THEN |
---|
573 | ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng), & |
---|
574 | c_w(nzb:nzt+1,nysg:nyng) ) |
---|
575 | ENDIF |
---|
576 | IF ( outflow_s ) THEN |
---|
577 | ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg), & |
---|
578 | v_m_s(nzb:nzt+1,1:2,nxlg:nxrg), & |
---|
579 | w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) ) |
---|
580 | ENDIF |
---|
581 | IF ( outflow_n ) THEN |
---|
582 | ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
583 | v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
584 | w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) ) |
---|
585 | ENDIF |
---|
586 | IF ( outflow_s .OR. outflow_n ) THEN |
---|
587 | ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg), & |
---|
588 | c_w(nzb:nzt+1,nxlg:nxrg) ) |
---|
589 | ENDIF |
---|
590 | IF ( outflow_l .OR. outflow_r .OR. outflow_s .OR. outflow_n ) THEN |
---|
591 | ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) ) |
---|
592 | ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) ) |
---|
593 | ENDIF |
---|
594 | |
---|
595 | |
---|
596 | #if ! defined( __nopointer ) |
---|
597 | ! |
---|
598 | !-- Initial assignment of the pointers |
---|
599 | e => e_1; e_p => e_2; te_m => e_3 |
---|
600 | IF ( .NOT. neutral ) THEN |
---|
601 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3 |
---|
602 | ELSE |
---|
603 | pt => pt_1; pt_p => pt_1; tpt_m => pt_3 |
---|
604 | ENDIF |
---|
605 | u => u_1; u_p => u_2; tu_m => u_3 |
---|
606 | v => v_1; v_p => v_2; tv_m => v_3 |
---|
607 | w => w_1; w_p => w_2; tw_m => w_3 |
---|
608 | |
---|
609 | IF ( humidity .OR. passive_scalar ) THEN |
---|
610 | q => q_1; q_p => q_2; tq_m => q_3 |
---|
611 | IF ( humidity ) THEN |
---|
612 | vpt => vpt_1 |
---|
613 | IF ( cloud_physics ) THEN |
---|
614 | ql => ql_1 |
---|
615 | IF ( icloud_scheme == 0 ) THEN |
---|
616 | qc => qc_1 |
---|
617 | IF ( precipitation ) THEN |
---|
618 | qr => qr_1; qr_p => qr_2; tqr_m => qr_3 |
---|
619 | nr => nr_1; nr_p => nr_2; tnr_m => nr_3 |
---|
620 | ENDIF |
---|
621 | ENDIF |
---|
622 | ENDIF |
---|
623 | ENDIF |
---|
624 | IF ( cloud_droplets ) THEN |
---|
625 | ql => ql_1 |
---|
626 | ql_c => ql_2 |
---|
627 | ENDIF |
---|
628 | ENDIF |
---|
629 | |
---|
630 | IF ( ocean ) THEN |
---|
631 | sa => sa_1; sa_p => sa_2; tsa_m => sa_3 |
---|
632 | ENDIF |
---|
633 | #endif |
---|
634 | |
---|
635 | ! |
---|
636 | !-- Allocate arrays containing the RK coefficient for calculation of |
---|
637 | !-- perturbation pressure and turbulent fluxes. At this point values are |
---|
638 | !-- set for pressure calculation during initialization (where no timestep |
---|
639 | !-- is done). Further below the values needed within the timestep scheme |
---|
640 | !-- will be set. |
---|
641 | ALLOCATE( weight_substep(1:intermediate_timestep_count_max), & |
---|
642 | weight_pres(1:intermediate_timestep_count_max) ) |
---|
643 | weight_substep = 1.0 |
---|
644 | weight_pres = 1.0 |
---|
645 | intermediate_timestep_count = 1 ! needed when simulated_time = 0.0 |
---|
646 | |
---|
647 | ! |
---|
648 | !-- Initialize model variables |
---|
649 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
650 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
651 | ! |
---|
652 | !-- First model run of a possible job queue. |
---|
653 | !-- Initial profiles of the variables must be computes. |
---|
654 | IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
655 | ! |
---|
656 | !-- Use solutions of the 1D model as initial profiles, |
---|
657 | !-- start 1D model |
---|
658 | CALL init_1d_model |
---|
659 | ! |
---|
660 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
661 | DO i = nxlg, nxrg |
---|
662 | DO j = nysg, nyng |
---|
663 | e(:,j,i) = e1d |
---|
664 | kh(:,j,i) = kh1d |
---|
665 | km(:,j,i) = km1d |
---|
666 | pt(:,j,i) = pt_init |
---|
667 | u(:,j,i) = u1d |
---|
668 | v(:,j,i) = v1d |
---|
669 | ENDDO |
---|
670 | ENDDO |
---|
671 | |
---|
672 | IF ( humidity .OR. passive_scalar ) THEN |
---|
673 | DO i = nxlg, nxrg |
---|
674 | DO j = nysg, nyng |
---|
675 | q(:,j,i) = q_init |
---|
676 | ENDDO |
---|
677 | ENDDO |
---|
678 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
679 | precipitation ) THEN |
---|
680 | DO i = nxlg, nxrg |
---|
681 | DO j = nysg, nyng |
---|
682 | qr(:,j,i) = 0.0 |
---|
683 | nr(:,j,i) = 0.0 |
---|
684 | ENDDO |
---|
685 | ENDDO |
---|
686 | ! |
---|
687 | !-- Initialze nc_1d with default value |
---|
688 | nc_1d(:) = nc_const |
---|
689 | |
---|
690 | ENDIF |
---|
691 | ENDIF |
---|
692 | |
---|
693 | IF ( .NOT. constant_diffusion ) THEN |
---|
694 | DO i = nxlg, nxrg |
---|
695 | DO j = nysg, nyng |
---|
696 | e(:,j,i) = e1d |
---|
697 | ENDDO |
---|
698 | ENDDO |
---|
699 | ! |
---|
700 | !-- Store initial profiles for output purposes etc. |
---|
701 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
702 | |
---|
703 | IF ( prandtl_layer ) THEN |
---|
704 | rif = rif1d(nzb+1) |
---|
705 | ts = 0.0 ! could actually be computed more accurately in the |
---|
706 | ! 1D model. Update when opportunity arises. |
---|
707 | us = us1d |
---|
708 | usws = usws1d |
---|
709 | vsws = vsws1d |
---|
710 | ELSE |
---|
711 | ts = 0.0 ! must be set, because used in |
---|
712 | rif = 0.0 ! flowste |
---|
713 | us = 0.0 |
---|
714 | usws = 0.0 |
---|
715 | vsws = 0.0 |
---|
716 | ENDIF |
---|
717 | |
---|
718 | ELSE |
---|
719 | e = 0.0 ! must be set, because used in |
---|
720 | rif = 0.0 ! flowste |
---|
721 | ts = 0.0 |
---|
722 | us = 0.0 |
---|
723 | usws = 0.0 |
---|
724 | vsws = 0.0 |
---|
725 | ENDIF |
---|
726 | uswst = top_momentumflux_u |
---|
727 | vswst = top_momentumflux_v |
---|
728 | |
---|
729 | ! |
---|
730 | !-- In every case qs = 0.0 (see also pt) |
---|
731 | !-- This could actually be computed more accurately in the 1D model. |
---|
732 | !-- Update when opportunity arises! |
---|
733 | IF ( humidity .OR. passive_scalar ) THEN |
---|
734 | qs = 0.0 |
---|
735 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
736 | precipitation ) THEN |
---|
737 | qrs = 0.0 |
---|
738 | nrs = 0.0 |
---|
739 | ENDIF |
---|
740 | ENDIF |
---|
741 | |
---|
742 | ! |
---|
743 | !-- inside buildings set velocities back to zero |
---|
744 | IF ( topography /= 'flat' ) THEN |
---|
745 | DO i = nxl-1, nxr+1 |
---|
746 | DO j = nys-1, nyn+1 |
---|
747 | u(nzb:nzb_u_inner(j,i),j,i) = 0.0 |
---|
748 | v(nzb:nzb_v_inner(j,i),j,i) = 0.0 |
---|
749 | ENDDO |
---|
750 | ENDDO |
---|
751 | |
---|
752 | ! |
---|
753 | !-- WARNING: The extra boundary conditions set after running the |
---|
754 | !-- ------- 1D model impose an error on the divergence one layer |
---|
755 | !-- below the topography; need to correct later |
---|
756 | !-- ATTENTION: Provisional correction for Piacsek & Williams |
---|
757 | !-- --------- advection scheme: keep u and v zero one layer below |
---|
758 | !-- the topography. |
---|
759 | IF ( ibc_uv_b == 1 ) THEN |
---|
760 | ! |
---|
761 | !-- Neumann condition |
---|
762 | DO i = nxl-1, nxr+1 |
---|
763 | DO j = nys-1, nyn+1 |
---|
764 | IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = u(1,j,i) |
---|
765 | IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = v(1,j,i) |
---|
766 | ENDDO |
---|
767 | ENDDO |
---|
768 | |
---|
769 | ENDIF |
---|
770 | |
---|
771 | ENDIF |
---|
772 | |
---|
773 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & |
---|
774 | THEN |
---|
775 | ! |
---|
776 | !-- Use constructed initial profiles (velocity constant with height, |
---|
777 | !-- temperature profile with constant gradient) |
---|
778 | DO i = nxlg, nxrg |
---|
779 | DO j = nysg, nyng |
---|
780 | pt(:,j,i) = pt_init |
---|
781 | u(:,j,i) = u_init |
---|
782 | v(:,j,i) = v_init |
---|
783 | ENDDO |
---|
784 | ENDDO |
---|
785 | |
---|
786 | ! |
---|
787 | !-- Set initial horizontal velocities at the lowest computational grid |
---|
788 | !-- levels to zero in order to avoid too small time steps caused by the |
---|
789 | !-- diffusion limit in the initial phase of a run (at k=1, dz/2 occurs |
---|
790 | !-- in the limiting formula!). The original values are stored to be later |
---|
791 | !-- used for volume flow control. |
---|
792 | DO i = nxlg, nxrg |
---|
793 | DO j = nysg, nyng |
---|
794 | u(nzb:nzb_u_inner(j,i)+1,j,i) = 0.0 |
---|
795 | v(nzb:nzb_v_inner(j,i)+1,j,i) = 0.0 |
---|
796 | ENDDO |
---|
797 | ENDDO |
---|
798 | |
---|
799 | IF ( humidity .OR. passive_scalar ) THEN |
---|
800 | DO i = nxlg, nxrg |
---|
801 | DO j = nysg, nyng |
---|
802 | q(:,j,i) = q_init |
---|
803 | ENDDO |
---|
804 | ENDDO |
---|
805 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
806 | ! |
---|
807 | !-- Initialze nc_1d with default value |
---|
808 | nc_1d(:) = nc_const |
---|
809 | |
---|
810 | IF ( precipitation ) THEN |
---|
811 | DO i = nxlg, nxrg |
---|
812 | DO j = nysg, nyng |
---|
813 | qr(:,j,i) = 0.0 |
---|
814 | nr(:,j,i) = 0.0 |
---|
815 | ENDDO |
---|
816 | ENDDO |
---|
817 | ENDIF |
---|
818 | |
---|
819 | ENDIF |
---|
820 | ENDIF |
---|
821 | |
---|
822 | IF ( ocean ) THEN |
---|
823 | DO i = nxlg, nxrg |
---|
824 | DO j = nysg, nyng |
---|
825 | sa(:,j,i) = sa_init |
---|
826 | ENDDO |
---|
827 | ENDDO |
---|
828 | ENDIF |
---|
829 | |
---|
830 | IF ( constant_diffusion ) THEN |
---|
831 | km = km_constant |
---|
832 | kh = km / prandtl_number |
---|
833 | e = 0.0 |
---|
834 | ELSEIF ( e_init > 0.0 ) THEN |
---|
835 | DO k = nzb+1, nzt |
---|
836 | km(k,:,:) = 0.1 * l_grid(k) * SQRT( e_init ) |
---|
837 | ENDDO |
---|
838 | km(nzb,:,:) = km(nzb+1,:,:) |
---|
839 | km(nzt+1,:,:) = km(nzt,:,:) |
---|
840 | kh = km / prandtl_number |
---|
841 | e = e_init |
---|
842 | ELSE |
---|
843 | IF ( .NOT. ocean ) THEN |
---|
844 | kh = 0.01 ! there must exist an initial diffusion, because |
---|
845 | km = 0.01 ! otherwise no TKE would be produced by the |
---|
846 | ! production terms, as long as not yet |
---|
847 | ! e = (u*/cm)**2 at k=nzb+1 |
---|
848 | ELSE |
---|
849 | kh = 0.00001 |
---|
850 | km = 0.00001 |
---|
851 | ENDIF |
---|
852 | e = 0.0 |
---|
853 | ENDIF |
---|
854 | rif = 0.0 |
---|
855 | ts = 0.0 |
---|
856 | us = 0.0 |
---|
857 | usws = 0.0 |
---|
858 | uswst = top_momentumflux_u |
---|
859 | vsws = 0.0 |
---|
860 | vswst = top_momentumflux_v |
---|
861 | IF ( humidity .OR. passive_scalar ) qs = 0.0 |
---|
862 | |
---|
863 | ! |
---|
864 | !-- Compute initial temperature field and other constants used in case |
---|
865 | !-- of a sloping surface |
---|
866 | IF ( sloping_surface ) CALL init_slope |
---|
867 | |
---|
868 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) & |
---|
869 | THEN |
---|
870 | ! |
---|
871 | !-- Initialization will completely be done by the user |
---|
872 | CALL user_init_3d_model |
---|
873 | |
---|
874 | ENDIF |
---|
875 | ! |
---|
876 | !-- Bottom boundary |
---|
877 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
878 | u(nzb,:,:) = 0.0 |
---|
879 | v(nzb,:,:) = 0.0 |
---|
880 | ENDIF |
---|
881 | |
---|
882 | ! |
---|
883 | !-- Apply channel flow boundary condition |
---|
884 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
885 | u(nzt+1,:,:) = 0.0 |
---|
886 | v(nzt+1,:,:) = 0.0 |
---|
887 | ENDIF |
---|
888 | |
---|
889 | ! |
---|
890 | !-- Calculate virtual potential temperature |
---|
891 | IF ( humidity ) vpt = pt * ( 1.0 + 0.61 * q ) |
---|
892 | |
---|
893 | ! |
---|
894 | !-- Store initial profiles for output purposes etc. |
---|
895 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
896 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
897 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2) THEN |
---|
898 | hom(nzb,1,5,:) = 0.0 |
---|
899 | hom(nzb,1,6,:) = 0.0 |
---|
900 | ENDIF |
---|
901 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
902 | hom(:,1,23,:) = SPREAD( km(:,nys,nxl), 2, statistic_regions+1 ) |
---|
903 | hom(:,1,24,:) = SPREAD( kh(:,nys,nxl), 2, statistic_regions+1 ) |
---|
904 | |
---|
905 | IF ( ocean ) THEN |
---|
906 | ! |
---|
907 | !-- Store initial salinity profile |
---|
908 | hom(:,1,26,:) = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 ) |
---|
909 | ENDIF |
---|
910 | |
---|
911 | IF ( humidity ) THEN |
---|
912 | ! |
---|
913 | !-- Store initial profile of total water content, virtual potential |
---|
914 | !-- temperature |
---|
915 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
916 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
917 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
918 | ! |
---|
919 | !-- Store initial profile of specific humidity and potential |
---|
920 | !-- temperature |
---|
921 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
922 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
923 | ENDIF |
---|
924 | ENDIF |
---|
925 | |
---|
926 | IF ( passive_scalar ) THEN |
---|
927 | ! |
---|
928 | !-- Store initial scalar profile |
---|
929 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
930 | ENDIF |
---|
931 | |
---|
932 | ! |
---|
933 | !-- Initialize fluxes at bottom surface |
---|
934 | IF ( use_surface_fluxes ) THEN |
---|
935 | |
---|
936 | IF ( constant_heatflux ) THEN |
---|
937 | ! |
---|
938 | !-- Heat flux is prescribed |
---|
939 | IF ( random_heatflux ) THEN |
---|
940 | CALL disturb_heatflux |
---|
941 | ELSE |
---|
942 | shf = surface_heatflux |
---|
943 | ! |
---|
944 | !-- Over topography surface_heatflux is replaced by wall_heatflux(0) |
---|
945 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
946 | DO i = nxlg, nxrg |
---|
947 | DO j = nysg, nyng |
---|
948 | IF ( nzb_s_inner(j,i) /= 0 ) THEN |
---|
949 | shf(j,i) = wall_heatflux(0) |
---|
950 | ENDIF |
---|
951 | ENDDO |
---|
952 | ENDDO |
---|
953 | ENDIF |
---|
954 | ENDIF |
---|
955 | ENDIF |
---|
956 | |
---|
957 | ! |
---|
958 | !-- Determine the near-surface water flux |
---|
959 | IF ( humidity .OR. passive_scalar ) THEN |
---|
960 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
961 | precipitation ) THEN |
---|
962 | qrsws = 0.0 |
---|
963 | nrsws = 0.0 |
---|
964 | ENDIF |
---|
965 | IF ( constant_waterflux ) THEN |
---|
966 | qsws = surface_waterflux |
---|
967 | ! |
---|
968 | !-- Over topography surface_waterflux is replaced by |
---|
969 | !-- wall_humidityflux(0) |
---|
970 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
971 | wall_qflux = wall_humidityflux |
---|
972 | DO i = nxlg, nxrg |
---|
973 | DO j = nysg, nyng |
---|
974 | IF ( nzb_s_inner(j,i) /= 0 ) THEN |
---|
975 | qsws(j,i) = wall_qflux(0) |
---|
976 | ENDIF |
---|
977 | ENDDO |
---|
978 | ENDDO |
---|
979 | ENDIF |
---|
980 | ENDIF |
---|
981 | ENDIF |
---|
982 | |
---|
983 | ENDIF |
---|
984 | |
---|
985 | ! |
---|
986 | !-- Initialize fluxes at top surface |
---|
987 | !-- Currently, only the heatflux and salinity flux can be prescribed. |
---|
988 | !-- The latent flux is zero in this case! |
---|
989 | IF ( use_top_fluxes ) THEN |
---|
990 | |
---|
991 | IF ( constant_top_heatflux ) THEN |
---|
992 | ! |
---|
993 | !-- Heat flux is prescribed |
---|
994 | tswst = top_heatflux |
---|
995 | |
---|
996 | IF ( humidity .OR. passive_scalar ) THEN |
---|
997 | qswst = 0.0 |
---|
998 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
999 | precipitation ) THEN |
---|
1000 | nrswst = 0.0 |
---|
1001 | qrswst = 0.0 |
---|
1002 | ENDIF |
---|
1003 | ENDIF |
---|
1004 | |
---|
1005 | IF ( ocean ) THEN |
---|
1006 | saswsb = bottom_salinityflux |
---|
1007 | saswst = top_salinityflux |
---|
1008 | ENDIF |
---|
1009 | ENDIF |
---|
1010 | |
---|
1011 | ! |
---|
1012 | !-- Initialization in case of a coupled model run |
---|
1013 | IF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
1014 | tswst = 0.0 |
---|
1015 | ENDIF |
---|
1016 | |
---|
1017 | ENDIF |
---|
1018 | |
---|
1019 | ! |
---|
1020 | !-- Initialize Prandtl layer quantities |
---|
1021 | IF ( prandtl_layer ) THEN |
---|
1022 | |
---|
1023 | z0 = roughness_length |
---|
1024 | z0h = z0h_factor * z0 |
---|
1025 | |
---|
1026 | IF ( .NOT. constant_heatflux ) THEN |
---|
1027 | ! |
---|
1028 | !-- Surface temperature is prescribed. Here the heat flux cannot be |
---|
1029 | !-- simply estimated, because therefore rif, u* and theta* would have |
---|
1030 | !-- to be computed by iteration. This is why the heat flux is assumed |
---|
1031 | !-- to be zero before the first time step. It approaches its correct |
---|
1032 | !-- value in the course of the first few time steps. |
---|
1033 | shf = 0.0 |
---|
1034 | ENDIF |
---|
1035 | |
---|
1036 | IF ( humidity .OR. passive_scalar ) THEN |
---|
1037 | IF ( .NOT. constant_waterflux ) qsws = 0.0 |
---|
1038 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
1039 | precipitation ) THEN |
---|
1040 | qrsws = 0.0 |
---|
1041 | nrsws = 0.0 |
---|
1042 | ENDIF |
---|
1043 | ENDIF |
---|
1044 | |
---|
1045 | ENDIF |
---|
1046 | |
---|
1047 | ! |
---|
1048 | !-- Set the reference state to be used in the buoyancy terms (for ocean runs |
---|
1049 | !-- the reference state will be set (overwritten) in init_ocean) |
---|
1050 | IF ( use_single_reference_value ) THEN |
---|
1051 | IF ( .NOT. humidity ) THEN |
---|
1052 | ref_state(:) = pt_reference |
---|
1053 | ELSE |
---|
1054 | ref_state(:) = vpt_reference |
---|
1055 | ENDIF |
---|
1056 | ELSE |
---|
1057 | IF ( .NOT. humidity ) THEN |
---|
1058 | ref_state(:) = pt_init(:) |
---|
1059 | ELSE |
---|
1060 | ref_state(:) = vpt(:,nys,nxl) |
---|
1061 | ENDIF |
---|
1062 | ENDIF |
---|
1063 | |
---|
1064 | ! |
---|
1065 | !-- For the moment, vertical velocity is zero |
---|
1066 | w = 0.0 |
---|
1067 | |
---|
1068 | ! |
---|
1069 | !-- Initialize array sums (must be defined in first call of pres) |
---|
1070 | sums = 0.0 |
---|
1071 | |
---|
1072 | ! |
---|
1073 | !-- In case of iterative solvers, p must get an initial value |
---|
1074 | IF ( psolver == 'multigrid' .OR. psolver == 'sor' ) p = 0.0 |
---|
1075 | |
---|
1076 | ! |
---|
1077 | !-- Treating cloud physics, liquid water content and precipitation amount |
---|
1078 | !-- are zero at beginning of the simulation |
---|
1079 | IF ( cloud_physics ) THEN |
---|
1080 | ql = 0.0 |
---|
1081 | IF ( precipitation ) precipitation_amount = 0.0 |
---|
1082 | IF ( icloud_scheme == 0 ) THEN |
---|
1083 | qc = 0.0 |
---|
1084 | nc_1d = nc_const |
---|
1085 | ENDIF |
---|
1086 | ENDIF |
---|
1087 | ! |
---|
1088 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
1089 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
1090 | CALL init_rankine |
---|
1091 | ENDIF |
---|
1092 | |
---|
1093 | ! |
---|
1094 | !-- Impose temperature anomaly (advection test only) |
---|
1095 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 ) THEN |
---|
1096 | CALL init_pt_anomaly |
---|
1097 | ENDIF |
---|
1098 | |
---|
1099 | ! |
---|
1100 | !-- If required, change the surface temperature at the start of the 3D run |
---|
1101 | IF ( pt_surface_initial_change /= 0.0 ) THEN |
---|
1102 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
1103 | ENDIF |
---|
1104 | |
---|
1105 | ! |
---|
1106 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
1107 | !-- run |
---|
1108 | IF ( ( humidity .OR. passive_scalar ) .AND. & |
---|
1109 | q_surface_initial_change /= 0.0 ) THEN |
---|
1110 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
1111 | ENDIF |
---|
1112 | ! |
---|
1113 | !-- Initialize the random number generator (from numerical recipes) |
---|
1114 | CALL random_function_ini |
---|
1115 | |
---|
1116 | ! |
---|
1117 | !-- Initialize old and new time levels. |
---|
1118 | te_m = 0.0; tpt_m = 0.0; tu_m = 0.0; tv_m = 0.0; tw_m = 0.0 |
---|
1119 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
1120 | |
---|
1121 | IF ( humidity .OR. passive_scalar ) THEN |
---|
1122 | tq_m = 0.0 |
---|
1123 | q_p = q |
---|
1124 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
1125 | precipitation ) THEN |
---|
1126 | tqr_m = 0.0 |
---|
1127 | qr_p = qr |
---|
1128 | tnr_m = 0.0 |
---|
1129 | nr_p = nr |
---|
1130 | ENDIF |
---|
1131 | ENDIF |
---|
1132 | |
---|
1133 | IF ( ocean ) THEN |
---|
1134 | tsa_m = 0.0 |
---|
1135 | sa_p = sa |
---|
1136 | ENDIF |
---|
1137 | |
---|
1138 | |
---|
1139 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
1140 | TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
1141 | THEN |
---|
1142 | ! |
---|
1143 | !-- When reading data for cyclic fill of 3D prerun data files, read |
---|
1144 | !-- some of the global variables from the restart file which are required |
---|
1145 | !-- for initializing the inflow |
---|
1146 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
1147 | |
---|
1148 | DO i = 0, io_blocks-1 |
---|
1149 | IF ( i == io_group ) THEN |
---|
1150 | CALL read_parts_of_var_list |
---|
1151 | CALL close_file( 13 ) |
---|
1152 | ENDIF |
---|
1153 | #if defined( __parallel ) |
---|
1154 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1155 | #endif |
---|
1156 | ENDDO |
---|
1157 | |
---|
1158 | ENDIF |
---|
1159 | |
---|
1160 | ! |
---|
1161 | !-- Read binary data from restart file |
---|
1162 | DO i = 0, io_blocks-1 |
---|
1163 | IF ( i == io_group ) THEN |
---|
1164 | CALL read_3d_binary |
---|
1165 | ENDIF |
---|
1166 | #if defined( __parallel ) |
---|
1167 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1168 | #endif |
---|
1169 | ENDDO |
---|
1170 | |
---|
1171 | ! |
---|
1172 | !-- Initialization of the turbulence recycling method |
---|
1173 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
1174 | turbulent_inflow ) THEN |
---|
1175 | ! |
---|
1176 | !-- First store the profiles to be used at the inflow. |
---|
1177 | !-- These profiles are the (temporally) and horizontally averaged vertical |
---|
1178 | !-- profiles from the prerun. Alternatively, prescribed profiles |
---|
1179 | !-- for u,v-components can be used. |
---|
1180 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,5) ) |
---|
1181 | |
---|
1182 | IF ( use_prescribed_profile_data ) THEN |
---|
1183 | mean_inflow_profiles(:,1) = u_init ! u |
---|
1184 | mean_inflow_profiles(:,2) = v_init ! v |
---|
1185 | ELSE |
---|
1186 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
1187 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
1188 | ENDIF |
---|
1189 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
1190 | mean_inflow_profiles(:,5) = hom_sum(:,8,0) ! e |
---|
1191 | |
---|
1192 | ! |
---|
1193 | !-- If necessary, adjust the horizontal flow field to the prescribed |
---|
1194 | !-- profiles |
---|
1195 | IF ( use_prescribed_profile_data ) THEN |
---|
1196 | DO i = nxlg, nxrg |
---|
1197 | DO j = nysg, nyng |
---|
1198 | DO k = nzb, nzt+1 |
---|
1199 | u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k) |
---|
1200 | v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k) |
---|
1201 | ENDDO |
---|
1202 | ENDDO |
---|
1203 | ENDDO |
---|
1204 | ENDIF |
---|
1205 | |
---|
1206 | ! |
---|
1207 | !-- Use these mean profiles at the inflow (provided that Dirichlet |
---|
1208 | !-- conditions are used) |
---|
1209 | IF ( inflow_l ) THEN |
---|
1210 | DO j = nysg, nyng |
---|
1211 | DO k = nzb, nzt+1 |
---|
1212 | u(k,j,nxlg:-1) = mean_inflow_profiles(k,1) |
---|
1213 | v(k,j,nxlg:-1) = mean_inflow_profiles(k,2) |
---|
1214 | w(k,j,nxlg:-1) = 0.0 |
---|
1215 | pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4) |
---|
1216 | e(k,j,nxlg:-1) = mean_inflow_profiles(k,5) |
---|
1217 | ENDDO |
---|
1218 | ENDDO |
---|
1219 | ENDIF |
---|
1220 | |
---|
1221 | ! |
---|
1222 | !-- Calculate the damping factors to be used at the inflow. For a |
---|
1223 | !-- turbulent inflow the turbulent fluctuations have to be limited |
---|
1224 | !-- vertically because otherwise the turbulent inflow layer will grow |
---|
1225 | !-- in time. |
---|
1226 | IF ( inflow_damping_height == 9999999.9 ) THEN |
---|
1227 | ! |
---|
1228 | !-- Default: use the inversion height calculated by the prerun; if |
---|
1229 | !-- this is zero, inflow_damping_height must be explicitly |
---|
1230 | !-- specified. |
---|
1231 | IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0 ) THEN |
---|
1232 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
1233 | ELSE |
---|
1234 | WRITE( message_string, * ) 'inflow_damping_height must be ',& |
---|
1235 | 'explicitly specified because&the inversion height ', & |
---|
1236 | 'calculated by the prerun is zero.' |
---|
1237 | CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 ) |
---|
1238 | ENDIF |
---|
1239 | |
---|
1240 | ENDIF |
---|
1241 | |
---|
1242 | IF ( inflow_damping_width == 9999999.9 ) THEN |
---|
1243 | ! |
---|
1244 | !-- Default for the transition range: one tenth of the undamped |
---|
1245 | !-- layer |
---|
1246 | inflow_damping_width = 0.1 * inflow_damping_height |
---|
1247 | |
---|
1248 | ENDIF |
---|
1249 | |
---|
1250 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
1251 | |
---|
1252 | DO k = nzb, nzt+1 |
---|
1253 | |
---|
1254 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
1255 | inflow_damping_factor(k) = 1.0 |
---|
1256 | ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) ) THEN |
---|
1257 | inflow_damping_factor(k) = 1.0 - & |
---|
1258 | ( zu(k) - inflow_damping_height ) / & |
---|
1259 | inflow_damping_width |
---|
1260 | ELSE |
---|
1261 | inflow_damping_factor(k) = 0.0 |
---|
1262 | ENDIF |
---|
1263 | |
---|
1264 | ENDDO |
---|
1265 | |
---|
1266 | ENDIF |
---|
1267 | |
---|
1268 | ! |
---|
1269 | !-- Inside buildings set velocities and TKE back to zero |
---|
1270 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
1271 | topography /= 'flat' ) THEN |
---|
1272 | ! |
---|
1273 | !-- Inside buildings set velocities and TKE back to zero. |
---|
1274 | !-- Other scalars (pt, q, s, km, kh, p, sa, ...) are ignored at present, |
---|
1275 | !-- maybe revise later. |
---|
1276 | DO i = nxlg, nxrg |
---|
1277 | DO j = nysg, nyng |
---|
1278 | u (nzb:nzb_u_inner(j,i),j,i) = 0.0 |
---|
1279 | v (nzb:nzb_v_inner(j,i),j,i) = 0.0 |
---|
1280 | w (nzb:nzb_w_inner(j,i),j,i) = 0.0 |
---|
1281 | e (nzb:nzb_w_inner(j,i),j,i) = 0.0 |
---|
1282 | tu_m(nzb:nzb_u_inner(j,i),j,i) = 0.0 |
---|
1283 | tv_m(nzb:nzb_v_inner(j,i),j,i) = 0.0 |
---|
1284 | tw_m(nzb:nzb_w_inner(j,i),j,i) = 0.0 |
---|
1285 | te_m(nzb:nzb_w_inner(j,i),j,i) = 0.0 |
---|
1286 | tpt_m(nzb:nzb_w_inner(j,i),j,i) = 0.0 |
---|
1287 | ENDDO |
---|
1288 | ENDDO |
---|
1289 | |
---|
1290 | ENDIF |
---|
1291 | |
---|
1292 | ! |
---|
1293 | !-- Calculate initial temperature field and other constants used in case |
---|
1294 | !-- of a sloping surface |
---|
1295 | IF ( sloping_surface ) CALL init_slope |
---|
1296 | |
---|
1297 | ! |
---|
1298 | !-- Initialize new time levels (only done in order to set boundary values |
---|
1299 | !-- including ghost points) |
---|
1300 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
1301 | IF ( humidity .OR. passive_scalar ) THEN |
---|
1302 | q_p = q |
---|
1303 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
1304 | precipitation ) THEN |
---|
1305 | qr_p = qr |
---|
1306 | nr_p = nr |
---|
1307 | ENDIF |
---|
1308 | ENDIF |
---|
1309 | IF ( ocean ) sa_p = sa |
---|
1310 | |
---|
1311 | ! |
---|
1312 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
1313 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
1314 | !-- there before they are set. |
---|
1315 | te_m = 0.0; tpt_m = 0.0; tu_m = 0.0; tv_m = 0.0; tw_m = 0.0 |
---|
1316 | IF ( humidity .OR. passive_scalar ) THEN |
---|
1317 | tq_m = 0.0 |
---|
1318 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
1319 | precipitation ) THEN |
---|
1320 | tqr_m = 0.0 |
---|
1321 | tnr_m = 0.0 |
---|
1322 | ENDIF |
---|
1323 | ENDIF |
---|
1324 | IF ( ocean ) tsa_m = 0.0 |
---|
1325 | |
---|
1326 | ELSE |
---|
1327 | ! |
---|
1328 | !-- Actually this part of the programm should not be reached |
---|
1329 | message_string = 'unknown initializing problem' |
---|
1330 | CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 ) |
---|
1331 | ENDIF |
---|
1332 | |
---|
1333 | |
---|
1334 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1335 | ! |
---|
1336 | !-- Initialize old timelevels needed for radiation boundary conditions |
---|
1337 | IF ( outflow_l ) THEN |
---|
1338 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
1339 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
1340 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
1341 | ENDIF |
---|
1342 | IF ( outflow_r ) THEN |
---|
1343 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
1344 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
1345 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
1346 | ENDIF |
---|
1347 | IF ( outflow_s ) THEN |
---|
1348 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
1349 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
1350 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
1351 | ENDIF |
---|
1352 | IF ( outflow_n ) THEN |
---|
1353 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
1354 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
1355 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
1356 | ENDIF |
---|
1357 | |
---|
1358 | ENDIF |
---|
1359 | |
---|
1360 | ! |
---|
1361 | !-- Calculate the initial volume flow at the right and north boundary |
---|
1362 | IF ( conserve_volume_flow ) THEN |
---|
1363 | |
---|
1364 | IF ( use_prescribed_profile_data ) THEN |
---|
1365 | |
---|
1366 | volume_flow_initial_l = 0.0 |
---|
1367 | volume_flow_area_l = 0.0 |
---|
1368 | |
---|
1369 | IF ( nxr == nx ) THEN |
---|
1370 | DO j = nys, nyn |
---|
1371 | DO k = nzb_2d(j,nx)+1, nzt |
---|
1372 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1373 | u_init(k) * dzw(k) |
---|
1374 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
1375 | ENDDO |
---|
1376 | ENDDO |
---|
1377 | ENDIF |
---|
1378 | |
---|
1379 | IF ( nyn == ny ) THEN |
---|
1380 | DO i = nxl, nxr |
---|
1381 | DO k = nzb_2d(ny,i)+1, nzt |
---|
1382 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1383 | v_init(k) * dzw(k) |
---|
1384 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
1385 | ENDDO |
---|
1386 | ENDDO |
---|
1387 | ENDIF |
---|
1388 | |
---|
1389 | #if defined( __parallel ) |
---|
1390 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1391 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1392 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1393 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1394 | |
---|
1395 | #else |
---|
1396 | volume_flow_initial = volume_flow_initial_l |
---|
1397 | volume_flow_area = volume_flow_area_l |
---|
1398 | #endif |
---|
1399 | |
---|
1400 | ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
1401 | |
---|
1402 | volume_flow_initial_l = 0.0 |
---|
1403 | volume_flow_area_l = 0.0 |
---|
1404 | |
---|
1405 | IF ( nxr == nx ) THEN |
---|
1406 | DO j = nys, nyn |
---|
1407 | DO k = nzb_2d(j,nx)+1, nzt |
---|
1408 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1409 | hom_sum(k,1,0) * dzw(k) |
---|
1410 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
1411 | ENDDO |
---|
1412 | ENDDO |
---|
1413 | ENDIF |
---|
1414 | |
---|
1415 | IF ( nyn == ny ) THEN |
---|
1416 | DO i = nxl, nxr |
---|
1417 | DO k = nzb_2d(ny,i)+1, nzt |
---|
1418 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1419 | hom_sum(k,2,0) * dzw(k) |
---|
1420 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
1421 | ENDDO |
---|
1422 | ENDDO |
---|
1423 | ENDIF |
---|
1424 | |
---|
1425 | #if defined( __parallel ) |
---|
1426 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1427 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1428 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1429 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1430 | |
---|
1431 | #else |
---|
1432 | volume_flow_initial = volume_flow_initial_l |
---|
1433 | volume_flow_area = volume_flow_area_l |
---|
1434 | #endif |
---|
1435 | |
---|
1436 | ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1437 | |
---|
1438 | volume_flow_initial_l = 0.0 |
---|
1439 | volume_flow_area_l = 0.0 |
---|
1440 | |
---|
1441 | IF ( nxr == nx ) THEN |
---|
1442 | DO j = nys, nyn |
---|
1443 | DO k = nzb_2d(j,nx)+1, nzt |
---|
1444 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1445 | u(k,j,nx) * dzw(k) |
---|
1446 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
1447 | ENDDO |
---|
1448 | ENDDO |
---|
1449 | ENDIF |
---|
1450 | |
---|
1451 | IF ( nyn == ny ) THEN |
---|
1452 | DO i = nxl, nxr |
---|
1453 | DO k = nzb_2d(ny,i)+1, nzt |
---|
1454 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1455 | v(k,ny,i) * dzw(k) |
---|
1456 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
1457 | ENDDO |
---|
1458 | ENDDO |
---|
1459 | ENDIF |
---|
1460 | |
---|
1461 | #if defined( __parallel ) |
---|
1462 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1463 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1464 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1465 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1466 | |
---|
1467 | #else |
---|
1468 | volume_flow_initial = volume_flow_initial_l |
---|
1469 | volume_flow_area = volume_flow_area_l |
---|
1470 | #endif |
---|
1471 | |
---|
1472 | ENDIF |
---|
1473 | |
---|
1474 | ! |
---|
1475 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is calculated |
---|
1476 | !-- from u|v_bulk instead |
---|
1477 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
1478 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
1479 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
1480 | ENDIF |
---|
1481 | |
---|
1482 | ENDIF |
---|
1483 | |
---|
1484 | ! |
---|
1485 | !-- Initialize quantities for special advections schemes |
---|
1486 | CALL init_advec |
---|
1487 | |
---|
1488 | ! |
---|
1489 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
1490 | !-- remove the divergences from the velocity field at the initial stage |
---|
1491 | IF ( create_disturbances .AND. & |
---|
1492 | TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
1493 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
1494 | |
---|
1495 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
1496 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
1497 | n_sor = nsor_ini |
---|
1498 | !$acc data copy( d, ddzu, ddzw, nzb_s_inner, nzb_u_inner, nzb_v_inner, nzb_w_inner, p, tri, tric, u, v, w, weight_pres, weight_substep, tend ) |
---|
1499 | CALL pres |
---|
1500 | !$acc end data |
---|
1501 | n_sor = nsor |
---|
1502 | ENDIF |
---|
1503 | |
---|
1504 | ! |
---|
1505 | !-- Initialization of the leaf area density |
---|
1506 | IF ( plant_canopy ) THEN |
---|
1507 | |
---|
1508 | SELECT CASE ( TRIM( canopy_mode ) ) |
---|
1509 | |
---|
1510 | CASE( 'block' ) |
---|
1511 | |
---|
1512 | DO i = nxlg, nxrg |
---|
1513 | DO j = nysg, nyng |
---|
1514 | lad_s(:,j,i) = lad(:) |
---|
1515 | cdc(:,j,i) = drag_coefficient |
---|
1516 | IF ( passive_scalar ) THEN |
---|
1517 | sls(:,j,i) = leaf_surface_concentration |
---|
1518 | sec(:,j,i) = scalar_exchange_coefficient |
---|
1519 | ENDIF |
---|
1520 | ENDDO |
---|
1521 | ENDDO |
---|
1522 | |
---|
1523 | CASE DEFAULT |
---|
1524 | |
---|
1525 | ! |
---|
1526 | !-- The DEFAULT case is reached either if the parameter |
---|
1527 | !-- canopy mode contains a wrong character string or if the |
---|
1528 | !-- user has coded a special case in the user interface. |
---|
1529 | !-- There, the subroutine user_init_plant_canopy checks |
---|
1530 | !-- which of these two conditions applies. |
---|
1531 | CALL user_init_plant_canopy |
---|
1532 | |
---|
1533 | END SELECT |
---|
1534 | |
---|
1535 | CALL exchange_horiz( lad_s, nbgp ) |
---|
1536 | CALL exchange_horiz( cdc, nbgp ) |
---|
1537 | |
---|
1538 | IF ( passive_scalar ) THEN |
---|
1539 | CALL exchange_horiz( sls, nbgp ) |
---|
1540 | CALL exchange_horiz( sec, nbgp ) |
---|
1541 | ENDIF |
---|
1542 | |
---|
1543 | ! |
---|
1544 | !-- Sharp boundaries of the plant canopy in horizontal directions |
---|
1545 | !-- In vertical direction the interpolation is retained, as the leaf |
---|
1546 | !-- area density is initialised by prescribing a vertical profile |
---|
1547 | !-- consisting of piecewise linear segments. The upper boundary |
---|
1548 | !-- of the plant canopy is now defined by lad_w(pch_index,:,:) = 0.0. |
---|
1549 | |
---|
1550 | DO i = nxl, nxr |
---|
1551 | DO j = nys, nyn |
---|
1552 | DO k = nzb, nzt+1 |
---|
1553 | IF ( lad_s(k,j,i) > 0.0 ) THEN |
---|
1554 | lad_u(k,j,i) = lad_s(k,j,i) |
---|
1555 | lad_u(k,j,i+1) = lad_s(k,j,i) |
---|
1556 | lad_v(k,j,i) = lad_s(k,j,i) |
---|
1557 | lad_v(k,j+1,i) = lad_s(k,j,i) |
---|
1558 | ENDIF |
---|
1559 | ENDDO |
---|
1560 | DO k = nzb, nzt |
---|
1561 | lad_w(k,j,i) = 0.5 * ( lad_s(k+1,j,i) + lad_s(k,j,i) ) |
---|
1562 | ENDDO |
---|
1563 | ENDDO |
---|
1564 | ENDDO |
---|
1565 | |
---|
1566 | lad_w(pch_index,:,:) = 0.0 |
---|
1567 | lad_w(nzt+1,:,:) = lad_w(nzt,:,:) |
---|
1568 | |
---|
1569 | CALL exchange_horiz( lad_u, nbgp ) |
---|
1570 | CALL exchange_horiz( lad_v, nbgp ) |
---|
1571 | CALL exchange_horiz( lad_w, nbgp ) |
---|
1572 | |
---|
1573 | ! |
---|
1574 | !-- Initialisation of the canopy heat source distribution |
---|
1575 | IF ( cthf /= 0.0 ) THEN |
---|
1576 | ! |
---|
1577 | !-- Piecewise evaluation of the leaf area index by |
---|
1578 | !-- integration of the leaf area density |
---|
1579 | lai(:,:,:) = 0.0 |
---|
1580 | DO i = nxlg, nxrg |
---|
1581 | DO j = nysg, nyng |
---|
1582 | DO k = pch_index-1, 0, -1 |
---|
1583 | lai(k,j,i) = lai(k+1,j,i) + & |
---|
1584 | ( 0.5 * ( lad_w(k+1,j,i) + & |
---|
1585 | lad_s(k+1,j,i) ) * & |
---|
1586 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
1587 | ( 0.5 * ( lad_w(k,j,i) + & |
---|
1588 | lad_s(k+1,j,i) ) * & |
---|
1589 | ( zu(k+1) - zw(k) ) ) |
---|
1590 | ENDDO |
---|
1591 | ENDDO |
---|
1592 | ENDDO |
---|
1593 | |
---|
1594 | ! |
---|
1595 | !-- Evaluation of the upward kinematic vertical heat flux within the |
---|
1596 | !-- canopy |
---|
1597 | DO i = nxlg, nxrg |
---|
1598 | DO j = nysg, nyng |
---|
1599 | DO k = 0, pch_index |
---|
1600 | canopy_heat_flux(k,j,i) = cthf * & |
---|
1601 | exp( -0.6 * lai(k,j,i) ) |
---|
1602 | ENDDO |
---|
1603 | ENDDO |
---|
1604 | ENDDO |
---|
1605 | |
---|
1606 | ! |
---|
1607 | !-- The near surface heat flux is derived from the heat flux |
---|
1608 | !-- distribution within the canopy |
---|
1609 | shf(:,:) = canopy_heat_flux(0,:,:) |
---|
1610 | |
---|
1611 | ENDIF |
---|
1612 | |
---|
1613 | ENDIF |
---|
1614 | |
---|
1615 | ! |
---|
1616 | !-- If required, initialize dvrp-software |
---|
1617 | IF ( dt_dvrp /= 9999999.9 ) CALL init_dvrp |
---|
1618 | |
---|
1619 | IF ( ocean ) THEN |
---|
1620 | ! |
---|
1621 | !-- Initialize quantities needed for the ocean model |
---|
1622 | CALL init_ocean |
---|
1623 | |
---|
1624 | ELSE |
---|
1625 | ! |
---|
1626 | !-- Initialize quantities for handling cloud physics |
---|
1627 | !-- This routine must be called before lpm_init, because |
---|
1628 | !-- otherwise, array pt_d_t, needed in data_output_dvrp (called by |
---|
1629 | !-- lpm_init) is not defined. |
---|
1630 | CALL init_cloud_physics |
---|
1631 | ENDIF |
---|
1632 | |
---|
1633 | ! |
---|
1634 | !-- If required, initialize particles |
---|
1635 | IF ( particle_advection ) CALL lpm_init |
---|
1636 | |
---|
1637 | ! |
---|
1638 | !-- Initialize the ws-scheme. |
---|
1639 | IF ( ws_scheme_sca .OR. ws_scheme_mom ) CALL ws_init |
---|
1640 | |
---|
1641 | ! |
---|
1642 | !-- Setting weighting factors for calculation of perturbation pressure |
---|
1643 | !-- and turbulent quantities from the RK substeps |
---|
1644 | IF ( TRIM(timestep_scheme) == 'runge-kutta-3' ) THEN ! for RK3-method |
---|
1645 | |
---|
1646 | weight_substep(1) = 1./6. |
---|
1647 | weight_substep(2) = 3./10. |
---|
1648 | weight_substep(3) = 8./15. |
---|
1649 | |
---|
1650 | weight_pres(1) = 1./3. |
---|
1651 | weight_pres(2) = 5./12. |
---|
1652 | weight_pres(3) = 1./4. |
---|
1653 | |
---|
1654 | ELSEIF ( TRIM(timestep_scheme) == 'runge-kutta-2' ) THEN ! for RK2-method |
---|
1655 | |
---|
1656 | weight_substep(1) = 1./2. |
---|
1657 | weight_substep(2) = 1./2. |
---|
1658 | |
---|
1659 | weight_pres(1) = 1./2. |
---|
1660 | weight_pres(2) = 1./2. |
---|
1661 | |
---|
1662 | ELSE ! for Euler-method |
---|
1663 | |
---|
1664 | weight_substep(1) = 1.0 |
---|
1665 | weight_pres(1) = 1.0 |
---|
1666 | |
---|
1667 | ENDIF |
---|
1668 | |
---|
1669 | ! |
---|
1670 | !-- Initialize Rayleigh damping factors |
---|
1671 | rdf = 0.0 |
---|
1672 | rdf_sc = 0.0 |
---|
1673 | IF ( rayleigh_damping_factor /= 0.0 ) THEN |
---|
1674 | IF ( .NOT. ocean ) THEN |
---|
1675 | DO k = nzb+1, nzt |
---|
1676 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
1677 | rdf(k) = rayleigh_damping_factor * & |
---|
1678 | ( SIN( pi * 0.5 * ( zu(k) - rayleigh_damping_height ) & |
---|
1679 | / ( zu(nzt) - rayleigh_damping_height ) )& |
---|
1680 | )**2 |
---|
1681 | ENDIF |
---|
1682 | ENDDO |
---|
1683 | ELSE |
---|
1684 | DO k = nzt, nzb+1, -1 |
---|
1685 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
1686 | rdf(k) = rayleigh_damping_factor * & |
---|
1687 | ( SIN( pi * 0.5 * ( rayleigh_damping_height - zu(k) ) & |
---|
1688 | / ( rayleigh_damping_height - zu(nzb+1)))& |
---|
1689 | )**2 |
---|
1690 | ENDIF |
---|
1691 | ENDDO |
---|
1692 | ENDIF |
---|
1693 | ENDIF |
---|
1694 | IF ( scalar_rayleigh_damping ) rdf_sc = rdf |
---|
1695 | |
---|
1696 | ! |
---|
1697 | !-- Initialize the starting level and the vertical smoothing factor used for |
---|
1698 | !-- the external pressure gradient |
---|
1699 | dp_smooth_factor = 1.0 |
---|
1700 | IF ( dp_external ) THEN |
---|
1701 | ! |
---|
1702 | !-- Set the starting level dp_level_ind_b only if it has not been set before |
---|
1703 | !-- (e.g. in init_grid). |
---|
1704 | IF ( dp_level_ind_b == 0 ) THEN |
---|
1705 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
1706 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
1707 | ! MINLOC uses lower array bound 1 |
---|
1708 | ENDIF |
---|
1709 | IF ( dp_smooth ) THEN |
---|
1710 | dp_smooth_factor(:dp_level_ind_b) = 0.0 |
---|
1711 | DO k = dp_level_ind_b+1, nzt |
---|
1712 | dp_smooth_factor(k) = 0.5 * ( 1.0 + SIN( pi * & |
---|
1713 | ( REAL( k - dp_level_ind_b ) / & |
---|
1714 | REAL( nzt - dp_level_ind_b ) - 0.5 ) ) ) |
---|
1715 | ENDDO |
---|
1716 | ENDIF |
---|
1717 | ENDIF |
---|
1718 | |
---|
1719 | ! |
---|
1720 | !-- Initialize damping zone for the potential temperature in case of |
---|
1721 | !-- non-cyclic lateral boundaries. The damping zone has the maximum value |
---|
1722 | !-- at the inflow boundary and decreases to zero at pt_damping_width. |
---|
1723 | ptdf_x = 0.0 |
---|
1724 | ptdf_y = 0.0 |
---|
1725 | IF ( bc_lr_dirrad ) THEN |
---|
1726 | DO i = nxl, nxr |
---|
1727 | IF ( ( i * dx ) < pt_damping_width ) THEN |
---|
1728 | ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5 * & |
---|
1729 | REAL( pt_damping_width - i * dx ) / ( & |
---|
1730 | REAL( pt_damping_width ) ) ) )**2 |
---|
1731 | ENDIF |
---|
1732 | ENDDO |
---|
1733 | ELSEIF ( bc_lr_raddir ) THEN |
---|
1734 | DO i = nxl, nxr |
---|
1735 | IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) ) THEN |
---|
1736 | ptdf_x(i) = pt_damping_factor * & |
---|
1737 | SIN( pi * 0.5 * ( ( i - nx ) * dx + pt_damping_width ) / & |
---|
1738 | REAL( pt_damping_width ) )**2 |
---|
1739 | ENDIF |
---|
1740 | ENDDO |
---|
1741 | ELSEIF ( bc_ns_dirrad ) THEN |
---|
1742 | DO j = nys, nyn |
---|
1743 | IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) ) THEN |
---|
1744 | ptdf_y(j) = pt_damping_factor * & |
---|
1745 | SIN( pi * 0.5 * ( ( j - ny ) * dy + pt_damping_width ) / & |
---|
1746 | REAL( pt_damping_width ) )**2 |
---|
1747 | ENDIF |
---|
1748 | ENDDO |
---|
1749 | ELSEIF ( bc_ns_raddir ) THEN |
---|
1750 | DO j = nys, nyn |
---|
1751 | IF ( ( j * dy ) < pt_damping_width ) THEN |
---|
1752 | ptdf_y(j) = pt_damping_factor * & |
---|
1753 | SIN( pi * 0.5 * ( pt_damping_width - j * dy ) / & |
---|
1754 | REAL( pt_damping_width ) )**2 |
---|
1755 | ENDIF |
---|
1756 | ENDDO |
---|
1757 | ENDIF |
---|
1758 | |
---|
1759 | ! |
---|
1760 | !-- Initialize local summation arrays for routine flow_statistics. |
---|
1761 | !-- This is necessary because they may not yet have been initialized when they |
---|
1762 | !-- are called from flow_statistics (or - depending on the chosen model run - |
---|
1763 | !-- are never initialized) |
---|
1764 | sums_divnew_l = 0.0 |
---|
1765 | sums_divold_l = 0.0 |
---|
1766 | sums_l_l = 0.0 |
---|
1767 | sums_up_fraction_l = 0.0 |
---|
1768 | sums_wsts_bc_l = 0.0 |
---|
1769 | |
---|
1770 | ! |
---|
1771 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
1772 | !-- Ghost points are excluded because counting values at the ghost boundaries |
---|
1773 | !-- would bias the statistics |
---|
1774 | rmask = 1.0 |
---|
1775 | rmask(:,nxlg:nxl-1,:) = 0.0; rmask(:,nxr+1:nxrg,:) = 0.0 |
---|
1776 | rmask(nysg:nys-1,:,:) = 0.0; rmask(nyn+1:nyng,:,:) = 0.0 |
---|
1777 | |
---|
1778 | ! |
---|
1779 | !-- User-defined initializing actions. Check afterwards, if maximum number |
---|
1780 | !-- of allowed timeseries is exceeded |
---|
1781 | CALL user_init |
---|
1782 | |
---|
1783 | IF ( dots_num > dots_max ) THEN |
---|
1784 | WRITE( message_string, * ) 'number of time series quantities exceeds', & |
---|
1785 | ' its maximum of dots_max = ', dots_max, & |
---|
1786 | ' &Please increase dots_max in modules.f90.' |
---|
1787 | CALL message( 'init_3d_model', 'PA0194', 1, 2, 0, 6, 0 ) |
---|
1788 | ENDIF |
---|
1789 | |
---|
1790 | ! |
---|
1791 | !-- Input binary data file is not needed anymore. This line must be placed |
---|
1792 | !-- after call of user_init! |
---|
1793 | CALL close_file( 13 ) |
---|
1794 | |
---|
1795 | ! |
---|
1796 | !-- Compute total sum of active mask grid points |
---|
1797 | !-- ngp_2dh: number of grid points of a horizontal cross section through the |
---|
1798 | !-- total domain |
---|
1799 | !-- ngp_3d: number of grid points of the total domain |
---|
1800 | ngp_2dh_outer_l = 0 |
---|
1801 | ngp_2dh_outer = 0 |
---|
1802 | ngp_2dh_s_inner_l = 0 |
---|
1803 | ngp_2dh_s_inner = 0 |
---|
1804 | ngp_2dh_l = 0 |
---|
1805 | ngp_2dh = 0 |
---|
1806 | ngp_3d_inner_l = 0.0 |
---|
1807 | ngp_3d_inner = 0 |
---|
1808 | ngp_3d = 0 |
---|
1809 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
1810 | |
---|
1811 | DO sr = 0, statistic_regions |
---|
1812 | DO i = nxl, nxr |
---|
1813 | DO j = nys, nyn |
---|
1814 | IF ( rmask(j,i,sr) == 1.0 ) THEN |
---|
1815 | ! |
---|
1816 | !-- All xy-grid points |
---|
1817 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
1818 | ! |
---|
1819 | !-- xy-grid points above topography |
---|
1820 | DO k = nzb_s_outer(j,i), nz + 1 |
---|
1821 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + 1 |
---|
1822 | ENDDO |
---|
1823 | DO k = nzb_s_inner(j,i), nz + 1 |
---|
1824 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + 1 |
---|
1825 | ENDDO |
---|
1826 | ! |
---|
1827 | !-- All grid points of the total domain above topography |
---|
1828 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + & |
---|
1829 | ( nz - nzb_s_inner(j,i) + 2 ) |
---|
1830 | ENDIF |
---|
1831 | ENDDO |
---|
1832 | ENDDO |
---|
1833 | ENDDO |
---|
1834 | |
---|
1835 | sr = statistic_regions + 1 |
---|
1836 | #if defined( __parallel ) |
---|
1837 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1838 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & |
---|
1839 | comm2d, ierr ) |
---|
1840 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1841 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & |
---|
1842 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1843 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1844 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), & |
---|
1845 | (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1846 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1847 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, & |
---|
1848 | MPI_SUM, comm2d, ierr ) |
---|
1849 | ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
1850 | #else |
---|
1851 | ngp_2dh = ngp_2dh_l |
---|
1852 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
1853 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
1854 | ngp_3d_inner = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
1855 | #endif |
---|
1856 | |
---|
1857 | ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * & |
---|
1858 | INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) ) |
---|
1859 | |
---|
1860 | ! |
---|
1861 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, |
---|
1862 | !-- buoyancy, etc. A zero value will occur for cases where all grid points of |
---|
1863 | !-- the respective subdomain lie below the surface topography |
---|
1864 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
1865 | ngp_3d_inner = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), & |
---|
1866 | ngp_3d_inner(:) ) |
---|
1867 | ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) |
---|
1868 | |
---|
1869 | DEALLOCATE( ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l, ngp_3d_inner_tmp ) |
---|
1870 | |
---|
1871 | |
---|
1872 | END SUBROUTINE init_3d_model |
---|