1 | #if defined( __ibmy_special ) |
---|
2 | @PROCESS NOOPTimize |
---|
3 | #endif |
---|
4 | SUBROUTINE init_3d_model |
---|
5 | |
---|
6 | !------------------------------------------------------------------------------! |
---|
7 | ! Actual revisions: |
---|
8 | ! ----------------- |
---|
9 | ! Set the starting level and the vertical smoothing factor used for |
---|
10 | ! the external pressure gradient |
---|
11 | ! +converve_volume_flow_mode: 'default', 'initial_profiles', 'inflow_profile' |
---|
12 | ! and 'bulk_velocity' |
---|
13 | ! |
---|
14 | ! Former revisions: |
---|
15 | ! ----------------- |
---|
16 | ! $Id: init_3d_model.f90 241 2009-02-19 16:08:56Z heinze $ |
---|
17 | ! |
---|
18 | ! 181 2008-07-30 07:07:47Z raasch |
---|
19 | ! bugfix: zero assignments to tendency arrays in case of restarts, |
---|
20 | ! further extensions and modifications in the initialisation of the plant |
---|
21 | ! canopy model, |
---|
22 | ! allocation of hom_sum moved to parin, initialization of spectrum_x|y directly |
---|
23 | ! after allocating theses arrays, |
---|
24 | ! read data for recycling added as new initialization option, |
---|
25 | ! dummy allocation for diss |
---|
26 | ! |
---|
27 | ! 138 2007-11-28 10:03:58Z letzel |
---|
28 | ! New counter ngp_2dh_s_inner. |
---|
29 | ! Allow new case bc_uv_t = 'dirichlet_0' for channel flow. |
---|
30 | ! Corrected calculation of initial volume flow for 'set_1d-model_profiles' and |
---|
31 | ! 'set_constant_profiles' in case of buildings in the reference cross-sections. |
---|
32 | ! |
---|
33 | ! 108 2007-08-24 15:10:38Z letzel |
---|
34 | ! Flux initialization in case of coupled runs, +momentum fluxes at top boundary, |
---|
35 | ! +arrays for phase speed c_u, c_v, c_w, indices for u|v|w_m_l|r changed |
---|
36 | ! +qswst_remote in case of atmosphere model with humidity coupled to ocean |
---|
37 | ! Rayleigh damping for ocean, optionally calculate km and kh from initial |
---|
38 | ! TKE e_init |
---|
39 | ! |
---|
40 | ! 97 2007-06-21 08:23:15Z raasch |
---|
41 | ! Initialization of salinity, call of init_ocean |
---|
42 | ! |
---|
43 | ! 87 2007-05-22 15:46:47Z raasch |
---|
44 | ! var_hom and var_sum renamed pr_palm |
---|
45 | ! |
---|
46 | ! 75 2007-03-22 09:54:05Z raasch |
---|
47 | ! Arrays for radiation boundary conditions are allocated (u_m_l, u_m_r, etc.), |
---|
48 | ! bugfix for cases with the outflow damping layer extending over more than one |
---|
49 | ! subdomain, moisture renamed humidity, |
---|
50 | ! new initializing action "by_user" calls user_init_3d_model, |
---|
51 | ! precipitation_amount/rate, ts_value are allocated, +module netcdf_control, |
---|
52 | ! initial velocities at nzb+1 are regarded for volume |
---|
53 | ! flow control in case they have been set zero before (to avoid small timesteps) |
---|
54 | ! -uvmean_outflow, uxrp, vynp eliminated |
---|
55 | ! |
---|
56 | ! 19 2007-02-23 04:53:48Z raasch |
---|
57 | ! +handling of top fluxes |
---|
58 | ! |
---|
59 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
60 | ! |
---|
61 | ! Revision 1.49 2006/08/22 15:59:07 raasch |
---|
62 | ! No optimization of this file on the ibmy (Yonsei Univ.) |
---|
63 | ! |
---|
64 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
65 | ! Initial revision |
---|
66 | ! |
---|
67 | ! |
---|
68 | ! Description: |
---|
69 | ! ------------ |
---|
70 | ! Allocation of arrays and initialization of the 3D model via |
---|
71 | ! a) pre-run the 1D model |
---|
72 | ! or |
---|
73 | ! b) pre-set constant linear profiles |
---|
74 | ! or |
---|
75 | ! c) read values of a previous run |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | |
---|
78 | USE arrays_3d |
---|
79 | USE averaging |
---|
80 | USE cloud_parameters |
---|
81 | USE constants |
---|
82 | USE control_parameters |
---|
83 | USE cpulog |
---|
84 | USE indices |
---|
85 | USE interfaces |
---|
86 | USE model_1d |
---|
87 | USE netcdf_control |
---|
88 | USE particle_attributes |
---|
89 | USE pegrid |
---|
90 | USE profil_parameter |
---|
91 | USE random_function_mod |
---|
92 | USE statistics |
---|
93 | |
---|
94 | IMPLICIT NONE |
---|
95 | |
---|
96 | INTEGER :: i, ind_array(1), j, k, sr |
---|
97 | |
---|
98 | INTEGER, DIMENSION(:), ALLOCATABLE :: ngp_2dh_l, ngp_3d_inner_l |
---|
99 | |
---|
100 | INTEGER, DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l, & |
---|
101 | ngp_2dh_s_inner_l |
---|
102 | |
---|
103 | REAL :: a, b |
---|
104 | |
---|
105 | REAL, DIMENSION(1:2) :: volume_flow_area_l, volume_flow_initial_l |
---|
106 | |
---|
107 | |
---|
108 | ! |
---|
109 | !-- Allocate arrays |
---|
110 | ALLOCATE( ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
111 | ngp_3d(0:statistic_regions), & |
---|
112 | ngp_3d_inner(0:statistic_regions), & |
---|
113 | ngp_3d_inner_l(0:statistic_regions), & |
---|
114 | sums_divnew_l(0:statistic_regions), & |
---|
115 | sums_divold_l(0:statistic_regions) ) |
---|
116 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt) ) |
---|
117 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
118 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
119 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
120 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
121 | rmask(nys-1:nyn+1,nxl-1:nxr+1,0:statistic_regions), & |
---|
122 | sums(nzb:nzt+1,pr_palm+max_pr_user), & |
---|
123 | sums_l(nzb:nzt+1,pr_palm+max_pr_user,0:threads_per_task-1), & |
---|
124 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
125 | sums_up_fraction_l(10,3,0:statistic_regions), & |
---|
126 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions), & |
---|
127 | ts_value(var_ts,0:statistic_regions) ) |
---|
128 | ALLOCATE( km_damp_x(nxl-1:nxr+1), km_damp_y(nys-1:nyn+1) ) |
---|
129 | |
---|
130 | ALLOCATE( rif_1(nys-1:nyn+1,nxl-1:nxr+1), shf_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
131 | ts(nys-1:nyn+1,nxl-1:nxr+1), tswst_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
132 | us(nys-1:nyn+1,nxl-1:nxr+1), usws_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
133 | uswst_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
134 | vsws_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
135 | vswst_1(nys-1:nyn+1,nxl-1:nxr+1), z0(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
136 | |
---|
137 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
138 | ! |
---|
139 | !-- Leapfrog scheme needs two timelevels of diffusion quantities |
---|
140 | ALLOCATE( rif_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
141 | shf_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
142 | tswst_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
143 | usws_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
144 | uswst_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
145 | vswst_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
146 | vsws_2(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
147 | ENDIF |
---|
148 | |
---|
149 | ALLOCATE( d(nzb+1:nzta,nys:nyna,nxl:nxra), & |
---|
150 | e_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
151 | e_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
152 | e_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
153 | kh_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
154 | km_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
155 | p(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
156 | pt_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
157 | pt_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
158 | pt_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
159 | tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
160 | u_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
161 | u_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
162 | u_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
163 | v_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
164 | v_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
165 | v_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
166 | w_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
167 | w_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
168 | w_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
169 | |
---|
170 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
171 | ALLOCATE( kh_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
172 | km_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
173 | ENDIF |
---|
174 | |
---|
175 | IF ( humidity .OR. passive_scalar ) THEN |
---|
176 | ! |
---|
177 | !-- 2D-humidity/scalar arrays |
---|
178 | ALLOCATE ( qs(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
179 | qsws_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
180 | qswst_1(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
181 | |
---|
182 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
183 | ALLOCATE( qsws_2(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
184 | qswst_2(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
185 | ENDIF |
---|
186 | ! |
---|
187 | !-- 3D-humidity/scalar arrays |
---|
188 | ALLOCATE( q_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
189 | q_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
190 | q_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
191 | |
---|
192 | ! |
---|
193 | !-- 3D-arrays needed for humidity only |
---|
194 | IF ( humidity ) THEN |
---|
195 | ALLOCATE( vpt_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
196 | |
---|
197 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
198 | ALLOCATE( vpt_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
199 | ENDIF |
---|
200 | |
---|
201 | IF ( cloud_physics ) THEN |
---|
202 | ! |
---|
203 | !-- Liquid water content |
---|
204 | ALLOCATE ( ql_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
205 | ! |
---|
206 | !-- Precipitation amount and rate (only needed if output is switched) |
---|
207 | ALLOCATE( precipitation_amount(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
208 | precipitation_rate(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
209 | ENDIF |
---|
210 | |
---|
211 | IF ( cloud_droplets ) THEN |
---|
212 | ! |
---|
213 | !-- Liquid water content, change in liquid water content, |
---|
214 | !-- real volume of particles (with weighting), volume of particles |
---|
215 | ALLOCATE ( ql_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
216 | ql_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
217 | ql_v(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
218 | ql_vp(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
219 | ENDIF |
---|
220 | |
---|
221 | ENDIF |
---|
222 | |
---|
223 | ENDIF |
---|
224 | |
---|
225 | IF ( ocean ) THEN |
---|
226 | ALLOCATE( saswsb_1(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
227 | saswst_1(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
228 | ALLOCATE( rho_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
229 | sa_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
230 | sa_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
231 | sa_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
232 | rho => rho_1 ! routine calc_mean_profile requires density to be a |
---|
233 | ! pointer |
---|
234 | IF ( humidity_remote ) THEN |
---|
235 | ALLOCATE( qswst_remote(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
236 | qswst_remote = 0.0 |
---|
237 | ENDIF |
---|
238 | ENDIF |
---|
239 | |
---|
240 | ! |
---|
241 | !-- 3D-array for storing the dissipation, needed for calculating the sgs |
---|
242 | !-- particle velocities |
---|
243 | IF ( use_sgs_for_particles ) THEN |
---|
244 | ALLOCATE ( diss(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
245 | ELSE |
---|
246 | ALLOCATE ( diss(2,2,2) ) ! required because diss is used as a |
---|
247 | ! formal parameter |
---|
248 | ENDIF |
---|
249 | |
---|
250 | IF ( dt_dosp /= 9999999.9 ) THEN |
---|
251 | ALLOCATE( spectrum_x( 1:nx/2, 1:10, 1:10 ), & |
---|
252 | spectrum_y( 1:ny/2, 1:10, 1:10 ) ) |
---|
253 | spectrum_x = 0.0 |
---|
254 | spectrum_y = 0.0 |
---|
255 | ENDIF |
---|
256 | |
---|
257 | ! |
---|
258 | !-- 3D-arrays for the leaf area density and the canopy drag coefficient |
---|
259 | IF ( plant_canopy ) THEN |
---|
260 | ALLOCATE ( lad_s(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
261 | lad_u(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
262 | lad_v(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
263 | lad_w(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
264 | cdc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
265 | |
---|
266 | IF ( passive_scalar ) THEN |
---|
267 | ALLOCATE ( sls(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
268 | sec(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
269 | ENDIF |
---|
270 | |
---|
271 | IF ( cthf /= 0.0 ) THEN |
---|
272 | ALLOCATE ( lai(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & |
---|
273 | canopy_heat_flux(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
274 | ENDIF |
---|
275 | |
---|
276 | ENDIF |
---|
277 | |
---|
278 | ! |
---|
279 | !-- 4D-array for storing the Rif-values at vertical walls |
---|
280 | IF ( topography /= 'flat' ) THEN |
---|
281 | ALLOCATE( rif_wall(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1,1:4) ) |
---|
282 | rif_wall = 0.0 |
---|
283 | ENDIF |
---|
284 | |
---|
285 | ! |
---|
286 | !-- Velocities at nzb+1 needed for volume flow control |
---|
287 | IF ( conserve_volume_flow ) THEN |
---|
288 | ALLOCATE( u_nzb_p1_for_vfc(nys:nyn), v_nzb_p1_for_vfc(nxl:nxr) ) |
---|
289 | u_nzb_p1_for_vfc = 0.0 |
---|
290 | v_nzb_p1_for_vfc = 0.0 |
---|
291 | ENDIF |
---|
292 | |
---|
293 | ! |
---|
294 | !-- Arrays to store velocity data from t-dt and the phase speeds which |
---|
295 | !-- are needed for radiation boundary conditions |
---|
296 | IF ( outflow_l ) THEN |
---|
297 | ALLOCATE( u_m_l(nzb:nzt+1,nys-1:nyn+1,1:2), & |
---|
298 | v_m_l(nzb:nzt+1,nys-1:nyn+1,0:1), & |
---|
299 | w_m_l(nzb:nzt+1,nys-1:nyn+1,0:1) ) |
---|
300 | ENDIF |
---|
301 | IF ( outflow_r ) THEN |
---|
302 | ALLOCATE( u_m_r(nzb:nzt+1,nys-1:nyn+1,nx-1:nx), & |
---|
303 | v_m_r(nzb:nzt+1,nys-1:nyn+1,nx-1:nx), & |
---|
304 | w_m_r(nzb:nzt+1,nys-1:nyn+1,nx-1:nx) ) |
---|
305 | ENDIF |
---|
306 | IF ( outflow_l .OR. outflow_r ) THEN |
---|
307 | ALLOCATE( c_u(nzb:nzt+1,nys-1:nyn+1), c_v(nzb:nzt+1,nys-1:nyn+1), & |
---|
308 | c_w(nzb:nzt+1,nys-1:nyn+1) ) |
---|
309 | ENDIF |
---|
310 | IF ( outflow_s ) THEN |
---|
311 | ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxl-1:nxr+1), & |
---|
312 | v_m_s(nzb:nzt+1,1:2,nxl-1:nxr+1), & |
---|
313 | w_m_s(nzb:nzt+1,0:1,nxl-1:nxr+1) ) |
---|
314 | ENDIF |
---|
315 | IF ( outflow_n ) THEN |
---|
316 | ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxl-1:nxr+1), & |
---|
317 | v_m_n(nzb:nzt+1,ny-1:ny,nxl-1:nxr+1), & |
---|
318 | w_m_n(nzb:nzt+1,ny-1:ny,nxl-1:nxr+1) ) |
---|
319 | ENDIF |
---|
320 | IF ( outflow_s .OR. outflow_n ) THEN |
---|
321 | ALLOCATE( c_u(nzb:nzt+1,nxl-1:nxr+1), c_v(nzb:nzt+1,nxl-1:nxr+1), & |
---|
322 | c_w(nzb:nzt+1,nxl-1:nxr+1) ) |
---|
323 | ENDIF |
---|
324 | |
---|
325 | ! |
---|
326 | !-- Initial assignment of the pointers |
---|
327 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
328 | |
---|
329 | rif_m => rif_1; rif => rif_2 |
---|
330 | shf_m => shf_1; shf => shf_2 |
---|
331 | tswst_m => tswst_1; tswst => tswst_2 |
---|
332 | usws_m => usws_1; usws => usws_2 |
---|
333 | uswst_m => uswst_1; uswst => uswst_2 |
---|
334 | vsws_m => vsws_1; vsws => vsws_2 |
---|
335 | vswst_m => vswst_1; vswst => vswst_2 |
---|
336 | e_m => e_1; e => e_2; e_p => e_3; te_m => e_3 |
---|
337 | kh_m => kh_1; kh => kh_2 |
---|
338 | km_m => km_1; km => km_2 |
---|
339 | pt_m => pt_1; pt => pt_2; pt_p => pt_3; tpt_m => pt_3 |
---|
340 | u_m => u_1; u => u_2; u_p => u_3; tu_m => u_3 |
---|
341 | v_m => v_1; v => v_2; v_p => v_3; tv_m => v_3 |
---|
342 | w_m => w_1; w => w_2; w_p => w_3; tw_m => w_3 |
---|
343 | |
---|
344 | IF ( humidity .OR. passive_scalar ) THEN |
---|
345 | qsws_m => qsws_1; qsws => qsws_2 |
---|
346 | qswst_m => qswst_1; qswst => qswst_2 |
---|
347 | q_m => q_1; q => q_2; q_p => q_3; tq_m => q_3 |
---|
348 | IF ( humidity ) vpt_m => vpt_1; vpt => vpt_2 |
---|
349 | IF ( cloud_physics ) ql => ql_1 |
---|
350 | IF ( cloud_droplets ) THEN |
---|
351 | ql => ql_1 |
---|
352 | ql_c => ql_2 |
---|
353 | ENDIF |
---|
354 | ENDIF |
---|
355 | |
---|
356 | ELSE |
---|
357 | |
---|
358 | rif => rif_1 |
---|
359 | shf => shf_1 |
---|
360 | tswst => tswst_1 |
---|
361 | usws => usws_1 |
---|
362 | uswst => uswst_1 |
---|
363 | vsws => vsws_1 |
---|
364 | vswst => vswst_1 |
---|
365 | e => e_1; e_p => e_2; te_m => e_3; e_m => e_3 |
---|
366 | kh => kh_1 |
---|
367 | km => km_1 |
---|
368 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3; pt_m => pt_3 |
---|
369 | u => u_1; u_p => u_2; tu_m => u_3; u_m => u_3 |
---|
370 | v => v_1; v_p => v_2; tv_m => v_3; v_m => v_3 |
---|
371 | w => w_1; w_p => w_2; tw_m => w_3; w_m => w_3 |
---|
372 | |
---|
373 | IF ( humidity .OR. passive_scalar ) THEN |
---|
374 | qsws => qsws_1 |
---|
375 | qswst => qswst_1 |
---|
376 | q => q_1; q_p => q_2; tq_m => q_3; q_m => q_3 |
---|
377 | IF ( humidity ) vpt => vpt_1 |
---|
378 | IF ( cloud_physics ) ql => ql_1 |
---|
379 | IF ( cloud_droplets ) THEN |
---|
380 | ql => ql_1 |
---|
381 | ql_c => ql_2 |
---|
382 | ENDIF |
---|
383 | ENDIF |
---|
384 | |
---|
385 | IF ( ocean ) THEN |
---|
386 | saswsb => saswsb_1 |
---|
387 | saswst => saswst_1 |
---|
388 | sa => sa_1; sa_p => sa_2; tsa_m => sa_3 |
---|
389 | ENDIF |
---|
390 | |
---|
391 | ENDIF |
---|
392 | |
---|
393 | ! |
---|
394 | !-- Initialize model variables |
---|
395 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
396 | TRIM( initializing_actions ) /= 'read_data_for_recycling' ) THEN |
---|
397 | ! |
---|
398 | !-- First model run of a possible job queue. |
---|
399 | !-- Initial profiles of the variables must be computes. |
---|
400 | IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
401 | ! |
---|
402 | !-- Use solutions of the 1D model as initial profiles, |
---|
403 | !-- start 1D model |
---|
404 | CALL init_1d_model |
---|
405 | ! |
---|
406 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
407 | DO i = nxl-1, nxr+1 |
---|
408 | DO j = nys-1, nyn+1 |
---|
409 | e(:,j,i) = e1d |
---|
410 | kh(:,j,i) = kh1d |
---|
411 | km(:,j,i) = km1d |
---|
412 | pt(:,j,i) = pt_init |
---|
413 | u(:,j,i) = u1d |
---|
414 | v(:,j,i) = v1d |
---|
415 | ENDDO |
---|
416 | ENDDO |
---|
417 | |
---|
418 | IF ( humidity .OR. passive_scalar ) THEN |
---|
419 | DO i = nxl-1, nxr+1 |
---|
420 | DO j = nys-1, nyn+1 |
---|
421 | q(:,j,i) = q_init |
---|
422 | ENDDO |
---|
423 | ENDDO |
---|
424 | ENDIF |
---|
425 | |
---|
426 | IF ( .NOT. constant_diffusion ) THEN |
---|
427 | DO i = nxl-1, nxr+1 |
---|
428 | DO j = nys-1, nyn+1 |
---|
429 | e(:,j,i) = e1d |
---|
430 | ENDDO |
---|
431 | ENDDO |
---|
432 | ! |
---|
433 | !-- Store initial profiles for output purposes etc. |
---|
434 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
435 | |
---|
436 | IF ( prandtl_layer ) THEN |
---|
437 | rif = rif1d(nzb+1) |
---|
438 | ts = 0.0 ! could actually be computed more accurately in the |
---|
439 | ! 1D model. Update when opportunity arises. |
---|
440 | us = us1d |
---|
441 | usws = usws1d |
---|
442 | vsws = vsws1d |
---|
443 | ELSE |
---|
444 | ts = 0.0 ! must be set, because used in |
---|
445 | rif = 0.0 ! flowste |
---|
446 | us = 0.0 |
---|
447 | usws = 0.0 |
---|
448 | vsws = 0.0 |
---|
449 | ENDIF |
---|
450 | |
---|
451 | ELSE |
---|
452 | e = 0.0 ! must be set, because used in |
---|
453 | rif = 0.0 ! flowste |
---|
454 | ts = 0.0 |
---|
455 | us = 0.0 |
---|
456 | usws = 0.0 |
---|
457 | vsws = 0.0 |
---|
458 | ENDIF |
---|
459 | uswst = top_momentumflux_u |
---|
460 | vswst = top_momentumflux_v |
---|
461 | |
---|
462 | ! |
---|
463 | !-- In every case qs = 0.0 (see also pt) |
---|
464 | !-- This could actually be computed more accurately in the 1D model. |
---|
465 | !-- Update when opportunity arises! |
---|
466 | IF ( humidity .OR. passive_scalar ) qs = 0.0 |
---|
467 | |
---|
468 | ! |
---|
469 | !-- inside buildings set velocities back to zero |
---|
470 | IF ( topography /= 'flat' ) THEN |
---|
471 | DO i = nxl-1, nxr+1 |
---|
472 | DO j = nys-1, nyn+1 |
---|
473 | u(nzb:nzb_u_inner(j,i),j,i) = 0.0 |
---|
474 | v(nzb:nzb_v_inner(j,i),j,i) = 0.0 |
---|
475 | ENDDO |
---|
476 | ENDDO |
---|
477 | IF ( conserve_volume_flow ) THEN |
---|
478 | IF ( nxr == nx ) THEN |
---|
479 | DO j = nys, nyn |
---|
480 | DO k = nzb + 1, nzb_u_inner(j,nx) |
---|
481 | u_nzb_p1_for_vfc(j) = u1d(k) * dzu(k) |
---|
482 | ENDDO |
---|
483 | ENDDO |
---|
484 | ENDIF |
---|
485 | IF ( nyn == ny ) THEN |
---|
486 | DO i = nxl, nxr |
---|
487 | DO k = nzb + 1, nzb_v_inner(ny,i) |
---|
488 | v_nzb_p1_for_vfc(i) = v1d(k) * dzu(k) |
---|
489 | ENDDO |
---|
490 | ENDDO |
---|
491 | ENDIF |
---|
492 | ENDIF |
---|
493 | ! |
---|
494 | !-- WARNING: The extra boundary conditions set after running the |
---|
495 | !-- ------- 1D model impose an error on the divergence one layer |
---|
496 | !-- below the topography; need to correct later |
---|
497 | !-- ATTENTION: Provisional correction for Piacsek & Williams |
---|
498 | !-- --------- advection scheme: keep u and v zero one layer below |
---|
499 | !-- the topography. |
---|
500 | IF ( ibc_uv_b == 0 ) THEN |
---|
501 | ! |
---|
502 | !-- Satisfying the Dirichlet condition with an extra layer below |
---|
503 | !-- the surface where the u and v component change their sign. |
---|
504 | DO i = nxl-1, nxr+1 |
---|
505 | DO j = nys-1, nyn+1 |
---|
506 | IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = -u(1,j,i) |
---|
507 | IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = -v(1,j,i) |
---|
508 | ENDDO |
---|
509 | ENDDO |
---|
510 | |
---|
511 | ELSE |
---|
512 | ! |
---|
513 | !-- Neumann condition |
---|
514 | DO i = nxl-1, nxr+1 |
---|
515 | DO j = nys-1, nyn+1 |
---|
516 | IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = u(1,j,i) |
---|
517 | IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = v(1,j,i) |
---|
518 | ENDDO |
---|
519 | ENDDO |
---|
520 | |
---|
521 | ENDIF |
---|
522 | |
---|
523 | ENDIF |
---|
524 | |
---|
525 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & |
---|
526 | THEN |
---|
527 | ! |
---|
528 | !-- Use constructed initial profiles (velocity constant with height, |
---|
529 | !-- temperature profile with constant gradient) |
---|
530 | DO i = nxl-1, nxr+1 |
---|
531 | DO j = nys-1, nyn+1 |
---|
532 | pt(:,j,i) = pt_init |
---|
533 | u(:,j,i) = u_init |
---|
534 | v(:,j,i) = v_init |
---|
535 | ENDDO |
---|
536 | ENDDO |
---|
537 | |
---|
538 | ! |
---|
539 | !-- Set initial horizontal velocities at the lowest computational grid levels |
---|
540 | !-- to zero in order to avoid too small time steps caused by the diffusion |
---|
541 | !-- limit in the initial phase of a run (at k=1, dz/2 occurs in the |
---|
542 | !-- limiting formula!). The original values are stored to be later used for |
---|
543 | !-- volume flow control. |
---|
544 | DO i = nxl-1, nxr+1 |
---|
545 | DO j = nys-1, nyn+1 |
---|
546 | u(nzb:nzb_u_inner(j,i)+1,j,i) = 0.0 |
---|
547 | v(nzb:nzb_v_inner(j,i)+1,j,i) = 0.0 |
---|
548 | ENDDO |
---|
549 | ENDDO |
---|
550 | IF ( conserve_volume_flow ) THEN |
---|
551 | IF ( nxr == nx ) THEN |
---|
552 | DO j = nys, nyn |
---|
553 | DO k = nzb + 1, nzb_u_inner(j,nx) + 1 |
---|
554 | u_nzb_p1_for_vfc(j) = u_init(k) * dzu(k) |
---|
555 | ENDDO |
---|
556 | ENDDO |
---|
557 | ENDIF |
---|
558 | IF ( nyn == ny ) THEN |
---|
559 | DO i = nxl, nxr |
---|
560 | DO k = nzb + 1, nzb_v_inner(ny,i) + 1 |
---|
561 | v_nzb_p1_for_vfc(i) = v_init(k) * dzu(k) |
---|
562 | ENDDO |
---|
563 | ENDDO |
---|
564 | ENDIF |
---|
565 | ENDIF |
---|
566 | |
---|
567 | IF ( humidity .OR. passive_scalar ) THEN |
---|
568 | DO i = nxl-1, nxr+1 |
---|
569 | DO j = nys-1, nyn+1 |
---|
570 | q(:,j,i) = q_init |
---|
571 | ENDDO |
---|
572 | ENDDO |
---|
573 | ENDIF |
---|
574 | |
---|
575 | IF ( ocean ) THEN |
---|
576 | DO i = nxl-1, nxr+1 |
---|
577 | DO j = nys-1, nyn+1 |
---|
578 | sa(:,j,i) = sa_init |
---|
579 | ENDDO |
---|
580 | ENDDO |
---|
581 | ENDIF |
---|
582 | |
---|
583 | IF ( constant_diffusion ) THEN |
---|
584 | km = km_constant |
---|
585 | kh = km / prandtl_number |
---|
586 | e = 0.0 |
---|
587 | ELSEIF ( e_init > 0.0 ) THEN |
---|
588 | DO k = nzb+1, nzt |
---|
589 | km(k,:,:) = 0.1 * l_grid(k) * SQRT( e_init ) |
---|
590 | ENDDO |
---|
591 | km(nzb,:,:) = km(nzb+1,:,:) |
---|
592 | km(nzt+1,:,:) = km(nzt,:,:) |
---|
593 | kh = km / prandtl_number |
---|
594 | e = e_init |
---|
595 | ELSE |
---|
596 | IF ( .NOT. ocean ) THEN |
---|
597 | kh = 0.01 ! there must exist an initial diffusion, because |
---|
598 | km = 0.01 ! otherwise no TKE would be produced by the |
---|
599 | ! production terms, as long as not yet |
---|
600 | ! e = (u*/cm)**2 at k=nzb+1 |
---|
601 | ELSE |
---|
602 | kh = 0.00001 |
---|
603 | km = 0.00001 |
---|
604 | ENDIF |
---|
605 | e = 0.0 |
---|
606 | ENDIF |
---|
607 | rif = 0.0 |
---|
608 | ts = 0.0 |
---|
609 | us = 0.0 |
---|
610 | usws = 0.0 |
---|
611 | uswst = top_momentumflux_u |
---|
612 | vsws = 0.0 |
---|
613 | vswst = top_momentumflux_v |
---|
614 | IF ( humidity .OR. passive_scalar ) qs = 0.0 |
---|
615 | |
---|
616 | ! |
---|
617 | !-- Compute initial temperature field and other constants used in case |
---|
618 | !-- of a sloping surface |
---|
619 | IF ( sloping_surface ) CALL init_slope |
---|
620 | |
---|
621 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) & |
---|
622 | THEN |
---|
623 | ! |
---|
624 | !-- Initialization will completely be done by the user |
---|
625 | CALL user_init_3d_model |
---|
626 | |
---|
627 | ENDIF |
---|
628 | |
---|
629 | ! |
---|
630 | !-- Apply channel flow boundary condition |
---|
631 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
632 | |
---|
633 | u(nzt+1,:,:) = 0.0 |
---|
634 | v(nzt+1,:,:) = 0.0 |
---|
635 | |
---|
636 | !-- For the Dirichlet condition to be correctly applied at the top, set |
---|
637 | !-- ug and vg to zero there |
---|
638 | ug(nzt+1) = 0.0 |
---|
639 | vg(nzt+1) = 0.0 |
---|
640 | |
---|
641 | ENDIF |
---|
642 | |
---|
643 | ! |
---|
644 | !-- Calculate virtual potential temperature |
---|
645 | IF ( humidity ) vpt = pt * ( 1.0 + 0.61 * q ) |
---|
646 | |
---|
647 | ! |
---|
648 | !-- Store initial profiles for output purposes etc. |
---|
649 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
650 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
651 | IF ( ibc_uv_b == 0 ) THEN |
---|
652 | hom(nzb,1,5,:) = -hom(nzb+1,1,5,:) ! due to satisfying the Dirichlet |
---|
653 | hom(nzb,1,6,:) = -hom(nzb+1,1,6,:) ! condition with an extra layer |
---|
654 | ! below the surface where the u and v component change their sign |
---|
655 | ENDIF |
---|
656 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
657 | hom(:,1,23,:) = SPREAD( km(:,nys,nxl), 2, statistic_regions+1 ) |
---|
658 | hom(:,1,24,:) = SPREAD( kh(:,nys,nxl), 2, statistic_regions+1 ) |
---|
659 | |
---|
660 | IF ( ocean ) THEN |
---|
661 | ! |
---|
662 | !-- Store initial salinity profile |
---|
663 | hom(:,1,26,:) = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 ) |
---|
664 | ENDIF |
---|
665 | |
---|
666 | IF ( humidity ) THEN |
---|
667 | ! |
---|
668 | !-- Store initial profile of total water content, virtual potential |
---|
669 | !-- temperature |
---|
670 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
671 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
672 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
673 | ! |
---|
674 | !-- Store initial profile of specific humidity and potential |
---|
675 | !-- temperature |
---|
676 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
677 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
678 | ENDIF |
---|
679 | ENDIF |
---|
680 | |
---|
681 | IF ( passive_scalar ) THEN |
---|
682 | ! |
---|
683 | !-- Store initial scalar profile |
---|
684 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
685 | ENDIF |
---|
686 | |
---|
687 | ! |
---|
688 | !-- Initialize fluxes at bottom surface |
---|
689 | IF ( use_surface_fluxes ) THEN |
---|
690 | |
---|
691 | IF ( constant_heatflux ) THEN |
---|
692 | ! |
---|
693 | !-- Heat flux is prescribed |
---|
694 | IF ( random_heatflux ) THEN |
---|
695 | CALL disturb_heatflux |
---|
696 | ELSE |
---|
697 | shf = surface_heatflux |
---|
698 | ! |
---|
699 | !-- Over topography surface_heatflux is replaced by wall_heatflux(0) |
---|
700 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
701 | DO i = nxl-1, nxr+1 |
---|
702 | DO j = nys-1, nyn+1 |
---|
703 | IF ( nzb_s_inner(j,i) /= 0 ) THEN |
---|
704 | shf(j,i) = wall_heatflux(0) |
---|
705 | ENDIF |
---|
706 | ENDDO |
---|
707 | ENDDO |
---|
708 | ENDIF |
---|
709 | ENDIF |
---|
710 | IF ( ASSOCIATED( shf_m ) ) shf_m = shf |
---|
711 | ENDIF |
---|
712 | |
---|
713 | ! |
---|
714 | !-- Determine the near-surface water flux |
---|
715 | IF ( humidity .OR. passive_scalar ) THEN |
---|
716 | IF ( constant_waterflux ) THEN |
---|
717 | qsws = surface_waterflux |
---|
718 | IF ( ASSOCIATED( qsws_m ) ) qsws_m = qsws |
---|
719 | ENDIF |
---|
720 | ENDIF |
---|
721 | |
---|
722 | ENDIF |
---|
723 | |
---|
724 | ! |
---|
725 | !-- Initialize fluxes at top surface |
---|
726 | !-- Currently, only the heatflux and salinity flux can be prescribed. |
---|
727 | !-- The latent flux is zero in this case! |
---|
728 | IF ( use_top_fluxes ) THEN |
---|
729 | |
---|
730 | IF ( constant_top_heatflux ) THEN |
---|
731 | ! |
---|
732 | !-- Heat flux is prescribed |
---|
733 | tswst = top_heatflux |
---|
734 | IF ( ASSOCIATED( tswst_m ) ) tswst_m = tswst |
---|
735 | |
---|
736 | IF ( humidity .OR. passive_scalar ) THEN |
---|
737 | qswst = 0.0 |
---|
738 | IF ( ASSOCIATED( qswst_m ) ) qswst_m = qswst |
---|
739 | ENDIF |
---|
740 | |
---|
741 | IF ( ocean ) THEN |
---|
742 | saswsb = bottom_salinityflux |
---|
743 | saswst = top_salinityflux |
---|
744 | ENDIF |
---|
745 | ENDIF |
---|
746 | |
---|
747 | ! |
---|
748 | !-- Initialization in case of a coupled model run |
---|
749 | IF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
750 | tswst = 0.0 |
---|
751 | IF ( ASSOCIATED( tswst_m ) ) tswst_m = tswst |
---|
752 | ENDIF |
---|
753 | |
---|
754 | ENDIF |
---|
755 | |
---|
756 | ! |
---|
757 | !-- Initialize Prandtl layer quantities |
---|
758 | IF ( prandtl_layer ) THEN |
---|
759 | |
---|
760 | z0 = roughness_length |
---|
761 | |
---|
762 | IF ( .NOT. constant_heatflux ) THEN |
---|
763 | ! |
---|
764 | !-- Surface temperature is prescribed. Here the heat flux cannot be |
---|
765 | !-- simply estimated, because therefore rif, u* and theta* would have |
---|
766 | !-- to be computed by iteration. This is why the heat flux is assumed |
---|
767 | !-- to be zero before the first time step. It approaches its correct |
---|
768 | !-- value in the course of the first few time steps. |
---|
769 | shf = 0.0 |
---|
770 | IF ( ASSOCIATED( shf_m ) ) shf_m = 0.0 |
---|
771 | ENDIF |
---|
772 | |
---|
773 | IF ( humidity .OR. passive_scalar ) THEN |
---|
774 | IF ( .NOT. constant_waterflux ) THEN |
---|
775 | qsws = 0.0 |
---|
776 | IF ( ASSOCIATED( qsws_m ) ) qsws_m = 0.0 |
---|
777 | ENDIF |
---|
778 | ENDIF |
---|
779 | |
---|
780 | ENDIF |
---|
781 | |
---|
782 | ! |
---|
783 | !-- Calculate the initial volume flow at the right and north boundary |
---|
784 | IF ( conserve_volume_flow ) THEN |
---|
785 | |
---|
786 | volume_flow_initial_l = 0.0 |
---|
787 | volume_flow_area_l = 0.0 |
---|
788 | |
---|
789 | IF ( nxr == nx ) THEN |
---|
790 | DO j = nys, nyn |
---|
791 | DO k = nzb_2d(j,nx) + 1, nzt |
---|
792 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
793 | u(k,j,nx) * dzu(k) |
---|
794 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzu(k) |
---|
795 | ENDDO |
---|
796 | ! |
---|
797 | !-- Correction if velocity at nzb+1 has been set zero further above |
---|
798 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
799 | u_nzb_p1_for_vfc(j) |
---|
800 | ENDDO |
---|
801 | ENDIF |
---|
802 | |
---|
803 | IF ( nyn == ny ) THEN |
---|
804 | DO i = nxl, nxr |
---|
805 | DO k = nzb_2d(ny,i) + 1, nzt |
---|
806 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
807 | v(k,ny,i) * dzu(k) |
---|
808 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzu(k) |
---|
809 | ENDDO |
---|
810 | ! |
---|
811 | !-- Correction if velocity at nzb+1 has been set zero further above |
---|
812 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
813 | v_nzb_p1_for_vfc(i) |
---|
814 | ENDDO |
---|
815 | ENDIF |
---|
816 | |
---|
817 | #if defined( __parallel ) |
---|
818 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
819 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
820 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
821 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
822 | #else |
---|
823 | volume_flow_initial = volume_flow_initial_l |
---|
824 | volume_flow_area = volume_flow_area_l |
---|
825 | #endif |
---|
826 | ! |
---|
827 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is overridden |
---|
828 | !-- and calculated from u|v_bulk instead. |
---|
829 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
830 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
831 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
832 | ENDIF |
---|
833 | |
---|
834 | ENDIF |
---|
835 | |
---|
836 | ! |
---|
837 | !-- For the moment, perturbation pressure and vertical velocity are zero |
---|
838 | p = 0.0; w = 0.0 |
---|
839 | |
---|
840 | ! |
---|
841 | !-- Initialize array sums (must be defined in first call of pres) |
---|
842 | sums = 0.0 |
---|
843 | |
---|
844 | ! |
---|
845 | !-- Treating cloud physics, liquid water content and precipitation amount |
---|
846 | !-- are zero at beginning of the simulation |
---|
847 | IF ( cloud_physics ) THEN |
---|
848 | ql = 0.0 |
---|
849 | IF ( precipitation ) precipitation_amount = 0.0 |
---|
850 | ENDIF |
---|
851 | |
---|
852 | ! |
---|
853 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
854 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
855 | CALL init_rankine |
---|
856 | ENDIF |
---|
857 | |
---|
858 | ! |
---|
859 | !-- Impose temperature anomaly (advection test only) |
---|
860 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 ) THEN |
---|
861 | CALL init_pt_anomaly |
---|
862 | ENDIF |
---|
863 | |
---|
864 | ! |
---|
865 | !-- If required, change the surface temperature at the start of the 3D run |
---|
866 | IF ( pt_surface_initial_change /= 0.0 ) THEN |
---|
867 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
868 | ENDIF |
---|
869 | |
---|
870 | ! |
---|
871 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
872 | !-- run |
---|
873 | IF ( ( humidity .OR. passive_scalar ) .AND. & |
---|
874 | q_surface_initial_change /= 0.0 ) THEN |
---|
875 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
876 | ENDIF |
---|
877 | |
---|
878 | ! |
---|
879 | !-- Initialize the random number generator (from numerical recipes) |
---|
880 | CALL random_function_ini |
---|
881 | |
---|
882 | ! |
---|
883 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
884 | !-- remove the divergences from the velocity field |
---|
885 | IF ( create_disturbances ) THEN |
---|
886 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
887 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
888 | n_sor = nsor_ini |
---|
889 | CALL pres |
---|
890 | n_sor = nsor |
---|
891 | ENDIF |
---|
892 | |
---|
893 | ! |
---|
894 | !-- Once again set the perturbation pressure explicitly to zero in order to |
---|
895 | !-- assure that it does not generate any divergences in the first time step. |
---|
896 | !-- At t=0 the velocity field is free of divergence (as constructed above). |
---|
897 | !-- Divergences being created during a time step are not yet known and thus |
---|
898 | !-- cannot be corrected during the time step yet. |
---|
899 | p = 0.0 |
---|
900 | |
---|
901 | ! |
---|
902 | !-- Initialize old and new time levels. |
---|
903 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
904 | e_m = e; pt_m = pt; u_m = u; v_m = v; w_m = w; kh_m = kh; km_m = km |
---|
905 | ELSE |
---|
906 | te_m = 0.0; tpt_m = 0.0; tu_m = 0.0; tv_m = 0.0; tw_m = 0.0 |
---|
907 | ENDIF |
---|
908 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
909 | |
---|
910 | IF ( humidity .OR. passive_scalar ) THEN |
---|
911 | IF ( ASSOCIATED( q_m ) ) q_m = q |
---|
912 | IF ( timestep_scheme(1:5) == 'runge' ) tq_m = 0.0 |
---|
913 | q_p = q |
---|
914 | IF ( humidity .AND. ASSOCIATED( vpt_m ) ) vpt_m = vpt |
---|
915 | ENDIF |
---|
916 | |
---|
917 | IF ( ocean ) THEN |
---|
918 | tsa_m = 0.0 |
---|
919 | sa_p = sa |
---|
920 | ENDIF |
---|
921 | |
---|
922 | |
---|
923 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
924 | TRIM( initializing_actions ) == 'read_data_for_recycling' ) & |
---|
925 | THEN |
---|
926 | ! |
---|
927 | !-- When reading data for initializing the recycling method, first read |
---|
928 | !-- some of the global variables from restart file |
---|
929 | IF ( TRIM( initializing_actions ) == 'read_data_for_recycling' ) THEN |
---|
930 | |
---|
931 | WRITE (9,*) 'before read_parts_of_var_list' |
---|
932 | CALL local_flush( 9 ) |
---|
933 | CALL read_parts_of_var_list |
---|
934 | WRITE (9,*) 'after read_parts_of_var_list' |
---|
935 | CALL local_flush( 9 ) |
---|
936 | CALL close_file( 13 ) |
---|
937 | ! |
---|
938 | !-- Store temporally and horizontally averaged vertical profiles to be |
---|
939 | !-- used as mean inflow profiles |
---|
940 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,5) ) |
---|
941 | |
---|
942 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
943 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
944 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
945 | mean_inflow_profiles(:,5) = hom_sum(:,8,0) ! e |
---|
946 | |
---|
947 | ! |
---|
948 | !-- Use these mean profiles for the inflow (provided that Dirichlet |
---|
949 | !-- conditions are used) |
---|
950 | IF ( inflow_l ) THEN |
---|
951 | DO j = nys-1, nyn+1 |
---|
952 | DO k = nzb, nzt+1 |
---|
953 | u(k,j,-1) = mean_inflow_profiles(k,1) |
---|
954 | v(k,j,-1) = mean_inflow_profiles(k,2) |
---|
955 | w(k,j,-1) = 0.0 |
---|
956 | pt(k,j,-1) = mean_inflow_profiles(k,4) |
---|
957 | e(k,j,-1) = mean_inflow_profiles(k,5) |
---|
958 | ENDDO |
---|
959 | ENDDO |
---|
960 | ENDIF |
---|
961 | |
---|
962 | ! |
---|
963 | !-- Calculate the damping factors to be used at the inflow. For a |
---|
964 | !-- turbulent inflow the turbulent fluctuations have to be limited |
---|
965 | !-- vertically because otherwise the turbulent inflow layer will grow |
---|
966 | !-- in time. |
---|
967 | IF ( inflow_damping_height == 9999999.9 ) THEN |
---|
968 | ! |
---|
969 | !-- Default: use the inversion height calculated by the prerun |
---|
970 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
971 | |
---|
972 | ENDIF |
---|
973 | |
---|
974 | IF ( inflow_damping_width == 9999999.9 ) THEN |
---|
975 | ! |
---|
976 | !-- Default for the transition range: one tenth of the undamped layer |
---|
977 | inflow_damping_width = 0.1 * inflow_damping_height |
---|
978 | |
---|
979 | ENDIF |
---|
980 | |
---|
981 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
982 | |
---|
983 | DO k = nzb, nzt+1 |
---|
984 | |
---|
985 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
986 | inflow_damping_factor(k) = 1.0 |
---|
987 | ELSEIF ( zu(k) <= inflow_damping_height + inflow_damping_width ) & |
---|
988 | THEN |
---|
989 | inflow_damping_factor(k) = 1.0 - & |
---|
990 | ( zu(k) - inflow_damping_height ) / & |
---|
991 | inflow_damping_width |
---|
992 | ELSE |
---|
993 | inflow_damping_factor(k) = 0.0 |
---|
994 | ENDIF |
---|
995 | |
---|
996 | ENDDO |
---|
997 | |
---|
998 | ENDIF |
---|
999 | |
---|
1000 | ! |
---|
1001 | !-- Read binary data from restart file |
---|
1002 | WRITE (9,*) 'before read_3d_binary' |
---|
1003 | CALL local_flush( 9 ) |
---|
1004 | CALL read_3d_binary |
---|
1005 | WRITE (9,*) 'after read_3d_binary' |
---|
1006 | CALL local_flush( 9 ) |
---|
1007 | |
---|
1008 | ! |
---|
1009 | !-- Calculate the initial volume flow at the right and north boundary |
---|
1010 | IF ( conserve_volume_flow .AND. & |
---|
1011 | TRIM( initializing_actions ) == 'read_data_for_recycling' ) THEN |
---|
1012 | |
---|
1013 | volume_flow_initial_l = 0.0 |
---|
1014 | volume_flow_area_l = 0.0 |
---|
1015 | |
---|
1016 | IF ( nxr == nx ) THEN |
---|
1017 | DO j = nys, nyn |
---|
1018 | DO k = nzb_2d(j,nx) + 1, nzt |
---|
1019 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1020 | u(k,j,nx) * dzu(k) |
---|
1021 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzu(k) |
---|
1022 | ENDDO |
---|
1023 | ! |
---|
1024 | !-- Correction if velocity at nzb+1 has been set zero further above |
---|
1025 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
1026 | u_nzb_p1_for_vfc(j) |
---|
1027 | ENDDO |
---|
1028 | ENDIF |
---|
1029 | |
---|
1030 | IF ( nyn == ny ) THEN |
---|
1031 | DO i = nxl, nxr |
---|
1032 | DO k = nzb_2d(ny,i) + 1, nzt |
---|
1033 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1034 | v(k,ny,i) * dzu(k) |
---|
1035 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzu(k) |
---|
1036 | ENDDO |
---|
1037 | ! |
---|
1038 | !-- Correction if velocity at nzb+1 has been set zero further above |
---|
1039 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
1040 | v_nzb_p1_for_vfc(i) |
---|
1041 | ENDDO |
---|
1042 | ENDIF |
---|
1043 | |
---|
1044 | #if defined( __parallel ) |
---|
1045 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
1046 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1047 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
1048 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1049 | #else |
---|
1050 | volume_flow_initial = volume_flow_initial_l |
---|
1051 | volume_flow_area = volume_flow_area_l |
---|
1052 | #endif |
---|
1053 | ENDIF |
---|
1054 | |
---|
1055 | |
---|
1056 | ! |
---|
1057 | !-- Calculate initial temperature field and other constants used in case |
---|
1058 | !-- of a sloping surface |
---|
1059 | IF ( sloping_surface ) CALL init_slope |
---|
1060 | |
---|
1061 | ! |
---|
1062 | !-- Initialize new time levels (only done in order to set boundary values |
---|
1063 | !-- including ghost points) |
---|
1064 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
1065 | IF ( humidity .OR. passive_scalar ) q_p = q |
---|
1066 | IF ( ocean ) sa_p = sa |
---|
1067 | |
---|
1068 | ! |
---|
1069 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
1070 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
1071 | !-- there before they are set. |
---|
1072 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1073 | te_m = 0.0; tpt_m = 0.0; tu_m = 0.0; tv_m = 0.0; tw_m = 0.0 |
---|
1074 | IF ( humidity .OR. passive_scalar ) tq_m = 0.0 |
---|
1075 | IF ( ocean ) tsa_m = 0.0 |
---|
1076 | ENDIF |
---|
1077 | |
---|
1078 | ELSE |
---|
1079 | ! |
---|
1080 | !-- Actually this part of the programm should not be reached |
---|
1081 | IF ( myid == 0 ) PRINT*,'+++ init_3d_model: unknown initializing ', & |
---|
1082 | 'problem' |
---|
1083 | CALL local_stop |
---|
1084 | ENDIF |
---|
1085 | |
---|
1086 | |
---|
1087 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1088 | ! |
---|
1089 | !-- Initialize old timelevels needed for radiation boundary conditions |
---|
1090 | IF ( outflow_l ) THEN |
---|
1091 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
1092 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
1093 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
1094 | ENDIF |
---|
1095 | IF ( outflow_r ) THEN |
---|
1096 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
1097 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
1098 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
1099 | ENDIF |
---|
1100 | IF ( outflow_s ) THEN |
---|
1101 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
1102 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
1103 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
1104 | ENDIF |
---|
1105 | IF ( outflow_n ) THEN |
---|
1106 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
1107 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
1108 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
1109 | ENDIF |
---|
1110 | |
---|
1111 | ENDIF |
---|
1112 | |
---|
1113 | ! |
---|
1114 | !-- Initialization of the leaf area density |
---|
1115 | IF ( plant_canopy ) THEN |
---|
1116 | |
---|
1117 | SELECT CASE ( TRIM( canopy_mode ) ) |
---|
1118 | |
---|
1119 | CASE( 'block' ) |
---|
1120 | |
---|
1121 | DO i = nxl-1, nxr+1 |
---|
1122 | DO j = nys-1, nyn+1 |
---|
1123 | lad_s(:,j,i) = lad(:) |
---|
1124 | cdc(:,j,i) = drag_coefficient |
---|
1125 | IF ( passive_scalar ) THEN |
---|
1126 | sls(:,j,i) = leaf_surface_concentration |
---|
1127 | sec(:,j,i) = scalar_exchange_coefficient |
---|
1128 | ENDIF |
---|
1129 | ENDDO |
---|
1130 | ENDDO |
---|
1131 | |
---|
1132 | CASE DEFAULT |
---|
1133 | |
---|
1134 | ! |
---|
1135 | !-- The DEFAULT case is reached either if the parameter |
---|
1136 | !-- canopy mode contains a wrong character string or if the |
---|
1137 | !-- user has coded a special case in the user interface. |
---|
1138 | !-- There, the subroutine user_init_plant_canopy checks |
---|
1139 | !-- which of these two conditions applies. |
---|
1140 | CALL user_init_plant_canopy |
---|
1141 | |
---|
1142 | END SELECT |
---|
1143 | |
---|
1144 | CALL exchange_horiz( lad_s ) |
---|
1145 | CALL exchange_horiz( cdc ) |
---|
1146 | |
---|
1147 | IF ( passive_scalar ) THEN |
---|
1148 | CALL exchange_horiz( sls ) |
---|
1149 | CALL exchange_horiz( sec ) |
---|
1150 | ENDIF |
---|
1151 | |
---|
1152 | ! |
---|
1153 | !-- Sharp boundaries of the plant canopy in horizontal directions |
---|
1154 | !-- In vertical direction the interpolation is retained, as the leaf |
---|
1155 | !-- area density is initialised by prescribing a vertical profile |
---|
1156 | !-- consisting of piecewise linear segments. The upper boundary |
---|
1157 | !-- of the plant canopy is now defined by lad_w(pch_index,:,:) = 0.0. |
---|
1158 | |
---|
1159 | DO i = nxl, nxr |
---|
1160 | DO j = nys, nyn |
---|
1161 | DO k = nzb, nzt+1 |
---|
1162 | IF ( lad_s(k,j,i) > 0.0 ) THEN |
---|
1163 | lad_u(k,j,i) = lad_s(k,j,i) |
---|
1164 | lad_u(k,j,i+1) = lad_s(k,j,i) |
---|
1165 | lad_v(k,j,i) = lad_s(k,j,i) |
---|
1166 | lad_v(k,j+1,i) = lad_s(k,j,i) |
---|
1167 | ENDIF |
---|
1168 | ENDDO |
---|
1169 | DO k = nzb, nzt |
---|
1170 | lad_w(k,j,i) = 0.5 * ( lad_s(k+1,j,i) + lad_s(k,j,i) ) |
---|
1171 | ENDDO |
---|
1172 | ENDDO |
---|
1173 | ENDDO |
---|
1174 | |
---|
1175 | lad_w(pch_index,:,:) = 0.0 |
---|
1176 | lad_w(nzt+1,:,:) = lad_w(nzt,:,:) |
---|
1177 | |
---|
1178 | CALL exchange_horiz( lad_u ) |
---|
1179 | CALL exchange_horiz( lad_v ) |
---|
1180 | CALL exchange_horiz( lad_w ) |
---|
1181 | |
---|
1182 | ! |
---|
1183 | !-- Initialisation of the canopy heat source distribution |
---|
1184 | IF ( cthf /= 0.0 ) THEN |
---|
1185 | ! |
---|
1186 | !-- Piecewise evaluation of the leaf area index by |
---|
1187 | !-- integration of the leaf area density |
---|
1188 | lai(:,:,:) = 0.0 |
---|
1189 | DO i = nxl-1, nxr+1 |
---|
1190 | DO j = nys-1, nyn+1 |
---|
1191 | DO k = pch_index-1, 0, -1 |
---|
1192 | lai(k,j,i) = lai(k+1,j,i) + & |
---|
1193 | ( 0.5 * ( lad_w(k+1,j,i) + & |
---|
1194 | lad_s(k+1,j,i) ) * & |
---|
1195 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
1196 | ( 0.5 * ( lad_w(k,j,i) + & |
---|
1197 | lad_s(k+1,j,i) ) * & |
---|
1198 | ( zu(k+1) - zw(k) ) ) |
---|
1199 | ENDDO |
---|
1200 | ENDDO |
---|
1201 | ENDDO |
---|
1202 | |
---|
1203 | ! |
---|
1204 | !-- Evaluation of the upward kinematic vertical heat flux within the |
---|
1205 | !-- canopy |
---|
1206 | DO i = nxl-1, nxr+1 |
---|
1207 | DO j = nys-1, nyn+1 |
---|
1208 | DO k = 0, pch_index |
---|
1209 | canopy_heat_flux(k,j,i) = cthf * & |
---|
1210 | exp( -0.6 * lai(k,j,i) ) |
---|
1211 | ENDDO |
---|
1212 | ENDDO |
---|
1213 | ENDDO |
---|
1214 | |
---|
1215 | ! |
---|
1216 | !-- The near surface heat flux is derived from the heat flux |
---|
1217 | !-- distribution within the canopy |
---|
1218 | shf(:,:) = canopy_heat_flux(0,:,:) |
---|
1219 | |
---|
1220 | IF ( ASSOCIATED( shf_m ) ) shf_m = shf |
---|
1221 | |
---|
1222 | ENDIF |
---|
1223 | |
---|
1224 | ENDIF |
---|
1225 | |
---|
1226 | ! |
---|
1227 | !-- If required, initialize dvrp-software |
---|
1228 | IF ( dt_dvrp /= 9999999.9 ) CALL init_dvrp |
---|
1229 | |
---|
1230 | IF ( ocean ) THEN |
---|
1231 | ! |
---|
1232 | !-- Initialize quantities needed for the ocean model |
---|
1233 | CALL init_ocean |
---|
1234 | ELSE |
---|
1235 | ! |
---|
1236 | !-- Initialize quantities for handling cloud physics |
---|
1237 | !-- This routine must be called before init_particles, because |
---|
1238 | !-- otherwise, array pt_d_t, needed in data_output_dvrp (called by |
---|
1239 | !-- init_particles) is not defined. |
---|
1240 | CALL init_cloud_physics |
---|
1241 | ENDIF |
---|
1242 | |
---|
1243 | ! |
---|
1244 | !-- If required, initialize particles |
---|
1245 | IF ( particle_advection ) CALL init_particles |
---|
1246 | |
---|
1247 | ! |
---|
1248 | !-- Initialize quantities for special advections schemes |
---|
1249 | CALL init_advec |
---|
1250 | |
---|
1251 | ! |
---|
1252 | !-- Initialize Rayleigh damping factors |
---|
1253 | rdf = 0.0 |
---|
1254 | IF ( rayleigh_damping_factor /= 0.0 ) THEN |
---|
1255 | IF ( .NOT. ocean ) THEN |
---|
1256 | DO k = nzb+1, nzt |
---|
1257 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
1258 | rdf(k) = rayleigh_damping_factor * & |
---|
1259 | ( SIN( pi * 0.5 * ( zu(k) - rayleigh_damping_height ) & |
---|
1260 | / ( zu(nzt) - rayleigh_damping_height ) )& |
---|
1261 | )**2 |
---|
1262 | ENDIF |
---|
1263 | ENDDO |
---|
1264 | ELSE |
---|
1265 | DO k = nzt, nzb+1, -1 |
---|
1266 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
1267 | rdf(k) = rayleigh_damping_factor * & |
---|
1268 | ( SIN( pi * 0.5 * ( rayleigh_damping_height - zu(k) ) & |
---|
1269 | / ( rayleigh_damping_height - zu(nzb+1)))& |
---|
1270 | )**2 |
---|
1271 | ENDIF |
---|
1272 | ENDDO |
---|
1273 | ENDIF |
---|
1274 | ENDIF |
---|
1275 | |
---|
1276 | ! |
---|
1277 | !-- Initialize the starting level and the vertical smoothing factor used for |
---|
1278 | !-- the external pressure gradient |
---|
1279 | dp_smooth_factor = 1.0 |
---|
1280 | IF ( dp_external ) THEN |
---|
1281 | ! |
---|
1282 | !-- Set the starting level dp_level_ind_b only if it has not been set before |
---|
1283 | !-- (e.g. in init_grid). |
---|
1284 | IF ( dp_level_ind_b == 0 ) THEN |
---|
1285 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
1286 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
1287 | ! MINLOC uses lower array bound 1 |
---|
1288 | ENDIF |
---|
1289 | IF ( dp_smooth ) THEN |
---|
1290 | dp_smooth_factor(:dp_level_ind_b) = 0.0 |
---|
1291 | DO k = dp_level_ind_b+1, nzt |
---|
1292 | dp_smooth_factor(k) = 0.5 * ( 1.0 + SIN( pi * & |
---|
1293 | ( REAL( k - dp_level_ind_b ) / & |
---|
1294 | REAL( nzt - dp_level_ind_b ) - 0.5 ) ) ) |
---|
1295 | ENDDO |
---|
1296 | ENDIF |
---|
1297 | ENDIF |
---|
1298 | |
---|
1299 | ! |
---|
1300 | !-- Initialize diffusivities used within the outflow damping layer in case of |
---|
1301 | !-- non-cyclic lateral boundaries. A linear increase is assumed over the first |
---|
1302 | !-- half of the width of the damping layer |
---|
1303 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
1304 | |
---|
1305 | DO i = nxl-1, nxr+1 |
---|
1306 | IF ( i >= nx - outflow_damping_width ) THEN |
---|
1307 | km_damp_x(i) = km_damp_max * MIN( 1.0, & |
---|
1308 | ( i - ( nx - outflow_damping_width ) ) / & |
---|
1309 | REAL( outflow_damping_width/2 ) & |
---|
1310 | ) |
---|
1311 | ELSE |
---|
1312 | km_damp_x(i) = 0.0 |
---|
1313 | ENDIF |
---|
1314 | ENDDO |
---|
1315 | |
---|
1316 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
1317 | |
---|
1318 | DO i = nxl-1, nxr+1 |
---|
1319 | IF ( i <= outflow_damping_width ) THEN |
---|
1320 | km_damp_x(i) = km_damp_max * MIN( 1.0, & |
---|
1321 | ( outflow_damping_width - i ) / & |
---|
1322 | REAL( outflow_damping_width/2 ) & |
---|
1323 | ) |
---|
1324 | ELSE |
---|
1325 | km_damp_x(i) = 0.0 |
---|
1326 | ENDIF |
---|
1327 | ENDDO |
---|
1328 | |
---|
1329 | ENDIF |
---|
1330 | |
---|
1331 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
1332 | |
---|
1333 | DO j = nys-1, nyn+1 |
---|
1334 | IF ( j >= ny - outflow_damping_width ) THEN |
---|
1335 | km_damp_y(j) = km_damp_max * MIN( 1.0, & |
---|
1336 | ( j - ( ny - outflow_damping_width ) ) / & |
---|
1337 | REAL( outflow_damping_width/2 ) & |
---|
1338 | ) |
---|
1339 | ELSE |
---|
1340 | km_damp_y(j) = 0.0 |
---|
1341 | ENDIF |
---|
1342 | ENDDO |
---|
1343 | |
---|
1344 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
1345 | |
---|
1346 | DO j = nys-1, nyn+1 |
---|
1347 | IF ( j <= outflow_damping_width ) THEN |
---|
1348 | km_damp_y(j) = km_damp_max * MIN( 1.0, & |
---|
1349 | ( outflow_damping_width - j ) / & |
---|
1350 | REAL( outflow_damping_width/2 ) & |
---|
1351 | ) |
---|
1352 | ELSE |
---|
1353 | km_damp_y(j) = 0.0 |
---|
1354 | ENDIF |
---|
1355 | ENDDO |
---|
1356 | |
---|
1357 | ENDIF |
---|
1358 | |
---|
1359 | ! |
---|
1360 | !-- Initialize local summation arrays for UP flow_statistics. This is necessary |
---|
1361 | !-- because they may not yet have been initialized when they are called from |
---|
1362 | !-- flow_statistics (or - depending on the chosen model run - are never |
---|
1363 | !-- initialized) |
---|
1364 | sums_divnew_l = 0.0 |
---|
1365 | sums_divold_l = 0.0 |
---|
1366 | sums_l_l = 0.0 |
---|
1367 | sums_up_fraction_l = 0.0 |
---|
1368 | sums_wsts_bc_l = 0.0 |
---|
1369 | |
---|
1370 | ! |
---|
1371 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
1372 | rmask = 1.0 |
---|
1373 | |
---|
1374 | ! |
---|
1375 | !-- User-defined initializing actions. Check afterwards, if maximum number |
---|
1376 | !-- of allowed timeseries is not exceeded |
---|
1377 | CALL user_init |
---|
1378 | |
---|
1379 | IF ( dots_num > dots_max ) THEN |
---|
1380 | IF ( myid == 0 ) THEN |
---|
1381 | PRINT*, '+++ user_init: number of time series quantities exceeds', & |
---|
1382 | ' its maximum of dots_max = ', dots_max |
---|
1383 | PRINT*, ' Please increase dots_max in modules.f90.' |
---|
1384 | ENDIF |
---|
1385 | CALL local_stop |
---|
1386 | ENDIF |
---|
1387 | |
---|
1388 | ! |
---|
1389 | !-- Input binary data file is not needed anymore. This line must be placed |
---|
1390 | !-- after call of user_init! |
---|
1391 | CALL close_file( 13 ) |
---|
1392 | |
---|
1393 | ! |
---|
1394 | !-- Compute total sum of active mask grid points |
---|
1395 | !-- ngp_2dh: number of grid points of a horizontal cross section through the |
---|
1396 | !-- total domain |
---|
1397 | !-- ngp_3d: number of grid points of the total domain |
---|
1398 | ngp_2dh_outer_l = 0 |
---|
1399 | ngp_2dh_outer = 0 |
---|
1400 | ngp_2dh_s_inner_l = 0 |
---|
1401 | ngp_2dh_s_inner = 0 |
---|
1402 | ngp_2dh_l = 0 |
---|
1403 | ngp_2dh = 0 |
---|
1404 | ngp_3d_inner_l = 0 |
---|
1405 | ngp_3d_inner = 0 |
---|
1406 | ngp_3d = 0 |
---|
1407 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
1408 | |
---|
1409 | DO sr = 0, statistic_regions |
---|
1410 | DO i = nxl, nxr |
---|
1411 | DO j = nys, nyn |
---|
1412 | IF ( rmask(j,i,sr) == 1.0 ) THEN |
---|
1413 | ! |
---|
1414 | !-- All xy-grid points |
---|
1415 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
1416 | ! |
---|
1417 | !-- xy-grid points above topography |
---|
1418 | DO k = nzb_s_outer(j,i), nz + 1 |
---|
1419 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + 1 |
---|
1420 | ENDDO |
---|
1421 | DO k = nzb_s_inner(j,i), nz + 1 |
---|
1422 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + 1 |
---|
1423 | ENDDO |
---|
1424 | ! |
---|
1425 | !-- All grid points of the total domain above topography |
---|
1426 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + & |
---|
1427 | ( nz - nzb_s_inner(j,i) + 2 ) |
---|
1428 | ENDIF |
---|
1429 | ENDDO |
---|
1430 | ENDDO |
---|
1431 | ENDDO |
---|
1432 | |
---|
1433 | sr = statistic_regions + 1 |
---|
1434 | #if defined( __parallel ) |
---|
1435 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & |
---|
1436 | comm2d, ierr ) |
---|
1437 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & |
---|
1438 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1439 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), & |
---|
1440 | (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1441 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner(0), sr, MPI_INTEGER, & |
---|
1442 | MPI_SUM, comm2d, ierr ) |
---|
1443 | #else |
---|
1444 | ngp_2dh = ngp_2dh_l |
---|
1445 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
1446 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
1447 | ngp_3d_inner = ngp_3d_inner_l |
---|
1448 | #endif |
---|
1449 | |
---|
1450 | ngp_3d = ngp_2dh * ( nz + 2 ) |
---|
1451 | |
---|
1452 | ! |
---|
1453 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, |
---|
1454 | !-- buoyancy, etc. A zero value will occur for cases where all grid points of |
---|
1455 | !-- the respective subdomain lie below the surface topography |
---|
1456 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
1457 | ngp_3d_inner = MAX( 1, ngp_3d_inner(:) ) |
---|
1458 | |
---|
1459 | DEALLOCATE( ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l ) |
---|
1460 | |
---|
1461 | |
---|
1462 | END SUBROUTINE init_3d_model |
---|