source: palm/tags/release-3.9/SOURCE/init_3d_model.f90 @ 2238

Last change on this file since 2238 was 1037, checked in by raasch, 11 years ago

last commit documented

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