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