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