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