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