source: palm/trunk/SOURCE/init_3d_model.f90 @ 4850

Last change on this file since 4850 was 4848, checked in by gronemeier, 3 years ago

bugfix: removed syn_turb_gen from restart files, replaced use_syn_turb_gen by syn_turb_gen

  • Property svn:keywords set to Id
  • Property svn:mergeinfo set to (toggle deleted branches)
    /palm/branches/chemistry/SOURCE/init_3d_model.f902047-3190,​3218-3297
    /palm/branches/rans/SOURCE/init_3d_model.f902078-3128
    /palm/branches/resler/SOURCE/init_3d_model.f902023-4492
    /palm/branches/salsa/SOURCE/init_3d_model.f902503-3581
    /palm/branches/forwind/SOURCE/init_3d_model.f901564-1913
    /palm/branches/mosaik_M2/init_3d_model.f902360-3471
    /palm/branches/palm4u/SOURCE/init_3d_model.f902540-2692
File size: 84.4 KB
Line 
1!> @file init_3d_model.f90
2!--------------------------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
6! Public License as published by the Free Software Foundation, either version 3 of the License, or
7! (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11! Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with PALM. If not, see
14! <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2021 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------------------------!
18!
19! Current revisions:
20! ------------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: init_3d_model.f90 4848 2021-01-21 15:51:51Z suehring $
26! replaced use_syn_turb_gen by syn_turb_gen
27!
28! 4845 2021-01-18 11:15:37Z raasch
29! removed allocation and initialization of arrays required for radiation boundary conditions
30!
31! 4828 2021-01-05 11:21:41Z Giersch
32! Add possibility to initialize surface flux of passive scalar via static driver
33!
34! 4783 2020-11-13 13:58:45Z raasch
35! bugfix for reading restart data with MPI-I/O (does not work with blockwise I/O)
36!
37! 4680 2020-09-16 10:20:34Z gronemeier
38! Add option to fix date or time of the simulation
39!
40! 4671 2020-09-09 20:27:58Z pavelkrc
41! Implementation of downward facing USM and LSM surfaces
42!
43! 4648 2020-08-25 07:52:08Z raasch
44! file re-formatted to follow the PALM coding standard
45!
46! 4548 2020-05-28 19:36:45Z suehring
47! Bugfix, move call for lsf_forcing_surf after lsf_init is called
48!
49! 4514 2020-04-30 16:29:59Z suehring
50! Add possibility to initialize surface sensible and latent heat fluxes via a static driver.
51!
52! 4493 2020-04-10 09:49:43Z pavelkrc
53! Overwrite u_init, v_init, pt_init, q_init and s_init with hom for all cyclic_fill-cases, not only
54! for turbulent_inflow = .TRUE.
55!
56! 4360 2020-01-07 11:25:50Z suehring
57! Introduction of wall_flags_total_0, which currently sets bits based on static topography
58! information used in wall_flags_static_0
59!
60! 4329 2019-12-10 15:46:36Z motisi
61! Renamed wall_flags_0 to wall_flags_static_0
62!
63! 4286 2019-10-30 16:01:14Z resler
64! implement new palm_date_time_mod
65!
66! 4223 2019-09-10 09:20:47Z gronemeier
67! Deallocate temporary string array since it may be re-used to read different input data in other
68! modules
69!
70! 4186 2019-08-23 16:06:14Z suehring
71! Design change, use variables defined in netcdf_data_input_mod to read netcd variables rather than
72! define local ones.
73!
74! 4185 2019-08-23 13:49:38Z oliver.maas
75! For initializing_actions = ' cyclic_fill':
76! Overwrite u_init, v_init, pt_init, q_init and s_init with the (temporally) and horizontally
77! averaged vertical profiles from the end of the prerun, because these profiles shall be used as the
78! basic state for the rayleigh damping and the pt_damping.
79!
80! 4182 2019-08-22 15:20:23Z scharf
81! Corrected "Former revisions" section
82!
83! 4168 2019-08-16 13:50:17Z suehring
84! Replace function get_topography_top_index by topo_top_ind
85!
86! 4151 2019-08-09 08:24:30Z suehring
87! Add netcdf directive around input calls (fix for last commit)
88!
89! 4150 2019-08-08 20:00:47Z suehring
90! Input of additional surface variables independent on land- or urban-surface model
91!
92! 4131 2019-08-02 11:06:18Z monakurppa
93! Allocate sums and sums_l to allow profile output for salsa variables.
94!
95! 4130 2019-08-01 13:04:13Z suehring
96! Effectively reduce 3D initialization to 1D initial profiles. This is because 3D initialization
97! produces structures in the w-component that are correlated with the processor grid for some
98! unknown reason
99!
100! 4090 2019-07-11 15:06:47Z Giersch
101! Unused variables removed
102!
103! 4088 2019-07-11 13:57:56Z Giersch
104! Pressure and density profile calculations revised using basic functions
105!
106! 4048 2019-06-21 21:00:21Z knoop
107! Further modularization of particle code components
108!
109! 4017 2019-06-06 12:16:46Z schwenkel
110! Convert most location messages to debug messages to reduce output in job logfile to a minimum
111!
112! unused variable removed
113!
114! 3937 2019-04-29 15:09:07Z suehring
115! Move initialization of synthetic turbulence generator behind initialization of offline nesting.
116! Remove call for stg_adjust, as this is now already done in stg_init.
117!
118! 3900 2019-04-16 15:17:43Z suehring
119! Fix problem with LOD = 2 initialization
120!
121! 3885 2019-04-11 11:29:34Z kanani
122! Changes related to global restructuring of location messages and introduction of additional debug
123! messages
124!
125! 3849 2019-04-01 16:35:16Z knoop
126! Move initialization of rmask before initializing user_init_arrays
127!
128! 3711 2019-01-31 13:44:26Z knoop
129! Introduced module_interface_init_checks for post-init checks in modules
130!
131! 3700 2019-01-26 17:03:42Z knoop
132! Some interface calls moved to module_interface + cleanup
133!
134! 3648 2019-01-02 16:35:46Z suehring
135! Rename subroutines for surface-data output
136!
137! Revision 1.1  1998/03/09 16:22:22  raasch
138! Initial revision
139!
140!
141! Description:
142! ------------
143!> Allocation of arrays and initialization of the 3D model via
144!> a) pre-run the 1D model
145!> or
146!> b) pre-set constant linear profiles
147!> or
148!> c) read values of a previous run
149!--------------------------------------------------------------------------------------------------!
150 SUBROUTINE init_3d_model
151
152
153    USE advec_ws
154
155    USE arrays_3d
156
157    USE basic_constants_and_equations_mod,                                                         &
158        ONLY:  barometric_formula, c_p, exner_function, exner_function_invers, g,                  &
159               ideal_gas_law_rho, ideal_gas_law_rho_pt, l_v, pi
160
161    USE bulk_cloud_model_mod,                                                                      &
162        ONLY:  bulk_cloud_model
163
164    USE chem_modules,                                                                              &
165        ONLY:  max_pr_cs ! ToDo: this dependency needs to be removed cause it is ugly #new_dom
166
167    USE control_parameters
168
169    USE grid_variables,                                                                            &
170        ONLY:  dx, dy, ddx2_mg, ddy2_mg
171
172    USE indices
173
174    USE kinds
175
176    USE lsf_nudging_mod,                                                                           &
177        ONLY:  ls_forcing_surf
178
179    USE model_1d_mod,                                                                              &
180        ONLY:  init_1d_model, l1d, u1d, v1d
181
182    USE module_interface,                                                                          &
183        ONLY:  module_interface_init_arrays,                                                       &
184               module_interface_init,                                                              &
185               module_interface_init_checks
186
187    USE multi_agent_system_mod,                                                                    &
188        ONLY:  agents_active, mas_init
189
190    USE netcdf_interface,                                                                          &
191        ONLY:  dots_max
192
193    USE netcdf_data_input_mod,                                                                     &
194        ONLY:  char_fill,                                                                          &
195               check_existence,                                                                    &
196               close_input_file,                                                                   &
197               get_attribute,                                                                      &
198               get_variable,                                                                       &
199               init_3d,                                                                            &
200               input_pids_static,                                                                  &
201               inquire_num_variables,                                                              &
202               inquire_variable_names,                                                             &
203               input_file_static,                                                                  &
204               netcdf_data_input_init_3d,                                                          &
205               num_var_pids,                                                                       &
206               open_read_file,                                                                     &
207               pids_id,                                                                            &
208               real_2d,                                                                            &
209               vars_pids
210
211    USE nesting_offl_mod,                                                                          &
212        ONLY:  nesting_offl_init
213
214    USE palm_date_time_mod,                                                                        &
215        ONLY:  init_date_time
216
217    USE pegrid
218
219#if defined( __parallel )
220    USE pmc_interface,                                                                             &
221        ONLY:  nested_run
222#endif
223
224    USE random_function_mod
225
226    USE random_generator_parallel,                                                                 &
227        ONLY:  init_parallel_random_generator
228
229    USE read_restart_data_mod,                                                                     &
230        ONLY:  rrd_local, rrd_read_parts_of_global
231
232    USE statistics,                                                                                &
233        ONLY:  hom, hom_sum, mean_surface_level_height, pr_palm, rmask, statistic_regions, sums,   &
234               sums_divnew_l, sums_divold_l, sums_l, sums_l_l, sums_wsts_bc_l, ts_value,           &
235               weight_pres, weight_substep
236
237    USE synthetic_turbulence_generator_mod,                                                        &
238        ONLY:  stg_init
239
240    USE surface_layer_fluxes_mod,                                                                  &
241        ONLY:  init_surface_layer_fluxes
242
243    USE surface_mod,                                                                               &
244        ONLY :  init_single_surface_properties,                                                    &
245                init_surface_arrays,                                                               &
246                init_surfaces,                                                                     &
247                surf_def_h,                                                                        &
248                surf_def_v,                                                                        &
249                surf_lsm_h,                                                                        &
250                surf_usm_h
251
252#if defined( _OPENACC )
253    USE surface_mod,                                                                               &
254        ONLY :  bc_h
255#endif
256
257    USE surface_data_output_mod,                                                                   &
258        ONLY:  surface_data_output_init
259
260    USE transpose_indices
261
262
263    IMPLICIT NONE
264
265    INTEGER(iwp) ::  i                    !< grid index in x direction
266    INTEGER(iwp) ::  ind_array(1)         !< dummy used to determine start index for external pressure forcing
267    INTEGER(iwp) ::  j                    !< grid index in y direction
268    INTEGER(iwp) ::  k                    !< grid index in z direction
269    INTEGER(iwp) ::  k_surf               !< surface level index
270    INTEGER(iwp) ::  l                    !< running index over surface orientation
271    INTEGER(iwp) ::  m                    !< index of surface element in surface data type
272    INTEGER(iwp) ::  nz_u_shift           !< topography-top index on u-grid, used to vertically shift initial profiles
273    INTEGER(iwp) ::  nz_v_shift           !< topography-top index on v-grid, used to vertically shift initial profiles
274    INTEGER(iwp) ::  nz_w_shift           !< topography-top index on w-grid, used to vertically shift initial profiles
275    INTEGER(iwp) ::  nz_s_shift           !< topography-top index on scalar-grid, used to vertically shift initial profiles
276    INTEGER(iwp) ::  nz_u_shift_l         !< topography-top index on u-grid, used to vertically shift initial profiles
277    INTEGER(iwp) ::  nz_v_shift_l         !< topography-top index on v-grid, used to vertically shift initial profiles
278    INTEGER(iwp) ::  nz_w_shift_l         !< topography-top index on w-grid, used to vertically shift initial profiles
279    INTEGER(iwp) ::  nz_s_shift_l         !< topography-top index on scalar-grid, used to vertically shift initial profiles
280    INTEGER(iwp) ::  nzt_l                !< index of top PE boundary for multigrid level
281    INTEGER(iwp) ::  sr                   !< index of statistic region
282
283    INTEGER(iwp), DIMENSION(:), ALLOCATABLE   ::  ngp_2dh_l  !< toal number of horizontal grid points in statistical region on
284                                                             !< subdomain
285
286    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_outer_l    !< number of horizontal non-wall bounded grid points on
287                                                                     !< subdomain
288    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_s_inner_l  !< number of horizontal non-topography grid points on
289                                                                     !< subdomain
290
291    REAL(wp) ::  dx_l !< grid spacing along x on different multigrid level
292    REAL(wp) ::  dy_l !< grid spacing along y on different multigrid level
293
294    REAL(wp), DIMENSION(:), ALLOCATABLE ::  init_l                       !< dummy array used for averaging 3D data to obtain
295                                                                         !< inital profiles
296    REAL(wp), DIMENSION(:), ALLOCATABLE ::  mean_surface_level_height_l  !< mean surface level height on subdomain
297    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner_l               !< total number of non-topography grid points on subdomain
298    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner_tmp             !< total number of non-topography grid points
299    REAL(wp), DIMENSION(:), ALLOCATABLE ::  p_hydrostatic                !< hydrostatic pressure
300
301    REAL(wp), DIMENSION(1:3) ::  volume_flow_area_l     !< area of lateral and top model domain surface on local subdomain
302    REAL(wp), DIMENSION(1:3) ::  volume_flow_initial_l  !< initial volume flow into model domain
303
304    TYPE(real_2d) ::  tmp_2d !< temporary variable to input additional surface-data from static file
305
306    CALL location_message( 'model initialization', 'start' )
307!
308!-- Set reference date-time
309    CALL init_date_time( date_time_str=origin_date_time,                                           &
310                         use_fixed_date=use_fixed_date,                                            &
311                         use_fixed_time=use_fixed_time )
312
313    IF ( debug_output )  CALL debug_message( 'allocating arrays', 'start' )
314!
315!-- Allocate arrays
316    ALLOCATE( mean_surface_level_height(0:statistic_regions),                                      &
317              mean_surface_level_height_l(0:statistic_regions),                                    &
318              ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions),                        &
319              ngp_3d(0:statistic_regions),                                                         &
320              ngp_3d_inner(0:statistic_regions),                                                   &
321              ngp_3d_inner_l(0:statistic_regions),                                                 &
322              ngp_3d_inner_tmp(0:statistic_regions),                                               &
323              sums_divnew_l(0:statistic_regions),                                                  &
324              sums_divold_l(0:statistic_regions) )
325    ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) )
326    ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions),                                        &
327              ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions),                                      &
328              ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions),                                      &
329              ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions),                                    &
330              rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions),                                      &
331              sums(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa),                          &
332              sums_l(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:threads_per_task-1),   &
333              sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1),                        &
334              sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions) )
335    ALLOCATE( ts_value(dots_max,0:statistic_regions) )
336    ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) )
337
338    ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr),                                                        &
339              p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                    &
340              tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
341
342    ALLOCATE( pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                 &
343              pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                 &
344              u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
345              u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
346              u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
347              v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
348              v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
349              v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
350              w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
351              w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                  &
352              w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
353    IF (  .NOT.  neutral )  THEN
354       ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
355    ENDIF
356!
357!-- Pre-set masks for regional statistics. Default is the total model domain.
358!-- Ghost points are excluded because counting values at the ghost boundaries would bias the
359!-- statistics.
360    rmask = 1.0_wp
361    rmask(:,nxlg:nxl-1,:) = 0.0_wp;  rmask(:,nxr+1:nxrg,:) = 0.0_wp
362    rmask(nysg:nys-1,:,:) = 0.0_wp;  rmask(nyn+1:nyng,:,:) = 0.0_wp
363!
364!-- Following array is required for perturbation pressure within the iterative pressure solvers. For
365!-- the multistep schemes (Runge-Kutta), array p holds the weighted average of the substeps and
366!-- cannot be used in the Poisson solver.
367    IF ( psolver == 'sor' )  THEN
368       ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
369    ELSEIF ( psolver(1:9) == 'multigrid' )  THEN
370!
371!--    For performance reasons, multigrid is using one ghost layer only
372       ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
373    ENDIF
374
375!
376!-- Array for storing constant coeffficients of the tridiagonal solver
377    IF ( psolver == 'poisfft' )  THEN
378       ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) )
379       ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) )
380    ENDIF
381
382    IF ( humidity )  THEN
383!
384!--    3D-humidity
385       ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
386                 q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
387                 q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
388                 vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
389    ENDIF
390
391    IF ( passive_scalar )  THEN
392
393!
394!--    3D scalar arrays
395       ALLOCATE( s_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
396                 s_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
397                 s_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
398
399    ENDIF
400
401!
402!-- Allocate and set 1d-profiles for Stokes drift velocity. It may be set to non-zero values later
403!-- in ocean_init.
404    ALLOCATE( u_stokes_zu(nzb:nzt+1), u_stokes_zw(nzb:nzt+1),                                      &
405              v_stokes_zu(nzb:nzt+1), v_stokes_zw(nzb:nzt+1) )
406    u_stokes_zu(:) = 0.0_wp
407    u_stokes_zw(:) = 0.0_wp
408    v_stokes_zu(:) = 0.0_wp
409    v_stokes_zw(:) = 0.0_wp
410
411!
412!-- Allocation of anelastic and Boussinesq approximation specific arrays
413    ALLOCATE( p_hydrostatic(nzb:nzt+1) )
414    ALLOCATE( rho_air(nzb:nzt+1) )
415    ALLOCATE( rho_air_zw(nzb:nzt+1) )
416    ALLOCATE( drho_air(nzb:nzt+1) )
417    ALLOCATE( drho_air_zw(nzb:nzt+1) )
418!
419!-- Density profile calculation for anelastic and Boussinesq approximation.
420!-- In case of a Boussinesq approximation, a constant density is calculated mainly for output
421!-- purposes. This density does not need to be considered in the model's system of equations.
422    IF ( TRIM( approximation ) == 'anelastic' )  THEN
423       DO  k = nzb, nzt+1
424          p_hydrostatic(k) = barometric_formula(zu(k), pt_surface *                                &
425                                                exner_function(surface_pressure * 100.0_wp),       &
426                                                surface_pressure * 100.0_wp)
427
428          rho_air(k) = ideal_gas_law_rho_pt(p_hydrostatic(k), pt_init(k))
429       ENDDO
430
431       DO  k = nzb, nzt
432          rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) )
433       ENDDO
434
435       rho_air_zw(nzt+1)  = rho_air_zw(nzt) + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt)  )
436
437    ELSE
438       DO  k = nzb, nzt+1
439          p_hydrostatic(k) = barometric_formula(zu(nzb), pt_surface *                              &
440                                                exner_function(surface_pressure * 100.0_wp),       &
441                                                surface_pressure * 100.0_wp)
442
443          rho_air(k) = ideal_gas_law_rho_pt(p_hydrostatic(k), pt_init(nzb))
444       ENDDO
445
446       DO  k = nzb, nzt
447          rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) )
448       ENDDO
449
450       rho_air_zw(nzt+1)  = rho_air_zw(nzt) + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt)  )
451
452    ENDIF
453!
454!-- Compute the inverse density array in order to avoid expencive divisions
455    drho_air    = 1.0_wp / rho_air
456    drho_air_zw = 1.0_wp / rho_air_zw
457
458!
459!-- Allocation of flux conversion arrays
460    ALLOCATE( heatflux_input_conversion(nzb:nzt+1) )
461    ALLOCATE( waterflux_input_conversion(nzb:nzt+1) )
462    ALLOCATE( momentumflux_input_conversion(nzb:nzt+1) )
463    ALLOCATE( heatflux_output_conversion(nzb:nzt+1) )
464    ALLOCATE( waterflux_output_conversion(nzb:nzt+1) )
465    ALLOCATE( momentumflux_output_conversion(nzb:nzt+1) )
466
467!
468!-- Calculate flux conversion factors according to approximation and in-/output mode
469    DO  k = nzb, nzt+1
470
471        IF ( TRIM( flux_input_mode ) == 'kinematic' )  THEN
472            heatflux_input_conversion(k)      = rho_air_zw(k)
473            waterflux_input_conversion(k)     = rho_air_zw(k)
474            momentumflux_input_conversion(k)  = rho_air_zw(k)
475        ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN
476            heatflux_input_conversion(k)      = 1.0_wp / c_p
477            waterflux_input_conversion(k)     = 1.0_wp / l_v
478            momentumflux_input_conversion(k)  = 1.0_wp
479        ENDIF
480
481        IF ( TRIM( flux_output_mode ) == 'kinematic' )  THEN
482            heatflux_output_conversion(k)     = drho_air_zw(k)
483            waterflux_output_conversion(k)    = drho_air_zw(k)
484            momentumflux_output_conversion(k) = drho_air_zw(k)
485        ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN
486            heatflux_output_conversion(k)     = c_p
487            waterflux_output_conversion(k)    = l_v
488            momentumflux_output_conversion(k) = 1.0_wp
489        ENDIF
490
491        IF ( .NOT. humidity ) THEN
492            waterflux_input_conversion(k)  = 1.0_wp
493            waterflux_output_conversion(k) = 1.0_wp
494        ENDIF
495
496    ENDDO
497
498!
499!-- In case of multigrid method, compute grid lengths and grid factors for the grid levels with
500!-- respective density on each grid.
501    IF ( psolver(1:9) == 'multigrid' )  THEN
502
503       ALLOCATE( ddx2_mg(maximum_grid_level) )
504       ALLOCATE( ddy2_mg(maximum_grid_level) )
505       ALLOCATE( dzu_mg(nzb+1:nzt+1,maximum_grid_level) )
506       ALLOCATE( dzw_mg(nzb+1:nzt+1,maximum_grid_level) )
507       ALLOCATE( f1_mg(nzb+1:nzt,maximum_grid_level) )
508       ALLOCATE( f2_mg(nzb+1:nzt,maximum_grid_level) )
509       ALLOCATE( f3_mg(nzb+1:nzt,maximum_grid_level) )
510       ALLOCATE( rho_air_mg(nzb:nzt+1,maximum_grid_level) )
511       ALLOCATE( rho_air_zw_mg(nzb:nzt+1,maximum_grid_level) )
512
513       dzu_mg(:,maximum_grid_level) = dzu
514       rho_air_mg(:,maximum_grid_level) = rho_air
515!
516!--    Next line to ensure an equally spaced grid.
517       dzu_mg(1,maximum_grid_level) = dzu(2)
518       rho_air_mg(nzb,maximum_grid_level) = rho_air(nzb) + (rho_air(nzb) - rho_air(nzb+1))
519
520       dzw_mg(:,maximum_grid_level) = dzw
521       rho_air_zw_mg(:,maximum_grid_level) = rho_air_zw
522       nzt_l = nzt
523       DO  l = maximum_grid_level-1, 1, -1
524           dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1)
525           dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1)
526           rho_air_mg(nzb,l)    = rho_air_mg(nzb,l+1)    + ( rho_air_mg(nzb,l+1)    -              &
527                                                             rho_air_mg(nzb+1,l+1)    )
528           rho_air_zw_mg(nzb,l) = rho_air_zw_mg(nzb,l+1) + ( rho_air_zw_mg(nzb,l+1) -              &
529                                                             rho_air_zw_mg(nzb+1,l+1) )
530           rho_air_mg(nzb+1,l)    = rho_air_mg(nzb+1,l+1)
531           rho_air_zw_mg(nzb+1,l) = rho_air_zw_mg(nzb+1,l+1)
532           nzt_l = nzt_l / 2
533           DO  k = 2, nzt_l+1
534              dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1)
535              dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1)
536              rho_air_mg(k,l)    = rho_air_mg(2*k-1,l+1)
537              rho_air_zw_mg(k,l) = rho_air_zw_mg(2*k-1,l+1)
538           ENDDO
539       ENDDO
540
541       nzt_l = nzt
542       dx_l  = dx
543       dy_l  = dy
544       DO  l = maximum_grid_level, 1, -1
545          ddx2_mg(l) = 1.0_wp / dx_l**2
546          ddy2_mg(l) = 1.0_wp / dy_l**2
547          DO  k = nzb+1, nzt_l
548             f2_mg(k,l) = rho_air_zw_mg(k,l) / ( dzu_mg(k+1,l) * dzw_mg(k,l) )
549             f3_mg(k,l) = rho_air_zw_mg(k-1,l) / ( dzu_mg(k,l)   * dzw_mg(k,l) )
550             f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) )                                     &
551                          * rho_air_mg(k,l) + f2_mg(k,l) + f3_mg(k,l)
552          ENDDO
553          nzt_l = nzt_l / 2
554          dx_l  = dx_l * 2.0_wp
555          dy_l  = dy_l * 2.0_wp
556       ENDDO
557
558    ENDIF
559
560!
561!-- 1D-array for large scale subsidence velocity
562    IF ( .NOT. ALLOCATED( w_subs ) )  THEN
563       ALLOCATE ( w_subs(nzb:nzt+1) )
564       w_subs = 0.0_wp
565    ENDIF
566
567!
568!-- Initial assignment of the pointers
569    IF ( .NOT. neutral )  THEN
570       pt => pt_1;  pt_p => pt_2;  tpt_m => pt_3
571    ELSE
572       pt => pt_1;  pt_p => pt_1;  tpt_m => pt_3
573    ENDIF
574    u  => u_1;   u_p  => u_2;   tu_m  => u_3
575    v  => v_1;   v_p  => v_2;   tv_m  => v_3
576    w  => w_1;   w_p  => w_2;   tw_m  => w_3
577
578    IF ( humidity )  THEN
579       q => q_1;  q_p => q_2;  tq_m => q_3
580       vpt  => vpt_1
581    ENDIF
582
583    IF ( passive_scalar )  THEN
584       s => s_1;  s_p => s_2;  ts_m => s_3
585    ENDIF
586
587!
588!-- Initialize surface arrays
589    CALL init_surface_arrays
590!
591!-- Allocate arrays for other modules
592    CALL module_interface_init_arrays
593
594
595!
596!-- Allocate arrays containing the RK coefficient for calculation of perturbation pressure and
597!-- turbulent fluxes. At this point values are set for pressure calculation during initialization
598!-- (where no timestep is done). Further below the values needed within the timestep scheme will be
599!-- set.
600    ALLOCATE( weight_substep(1:intermediate_timestep_count_max),                                   &
601              weight_pres(1:intermediate_timestep_count_max) )
602    weight_substep = 1.0_wp
603    weight_pres    = 1.0_wp
604    intermediate_timestep_count = 0  ! needed when simulated_time = 0.0
605
606    IF ( debug_output )  CALL debug_message( 'allocating arrays', 'end' )
607
608!
609!-- Initialize time series
610    ts_value = 0.0_wp
611
612!
613!-- Initialize local summation arrays for routine flow_statistics.
614!-- This is necessary because they may not yet have been initialized when they are called from
615!-- flow_statistics (or - depending on the chosen model run - are never initialized)
616    sums_divnew_l  = 0.0_wp
617    sums_divold_l  = 0.0_wp
618    sums_l_l       = 0.0_wp
619    sums_wsts_bc_l = 0.0_wp
620
621!
622!-- Initialize model variables
623    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.                                &
624         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
625!
626!--    Initialization with provided input data derived from larger-scale model
627       IF ( INDEX( initializing_actions, 'inifor' ) /= 0 )  THEN
628          IF ( debug_output )  CALL debug_message( 'initializing with INIFOR', 'start' )
629!
630!--       Read initial 1D profiles or 3D data from NetCDF file, depending on the provided
631!--       level-of-detail.
632!--       At the moment, only u, v, w, pt and q are provided.
633          CALL netcdf_data_input_init_3d
634!
635!--       Please note, Inifor provides data from nzb+1 to nzt.
636!--       Bottom and top boundary conditions for Inifor profiles are already set (just after
637!--       reading), so that this is not necessary here.
638!--       Depending on the provided level-of-detail, initial Inifor data is either stored on data
639!--       type (lod=1), or directly on 3D arrays (lod=2).
640!--       In order to obtain also initial profiles in case of lod=2 (which is required for e.g.
641!--       damping), average over 3D data.
642          IF( init_3d%lod_u == 1 )  THEN
643             u_init = init_3d%u_init
644          ELSEIF( init_3d%lod_u == 2 )  THEN
645             ALLOCATE( init_l(nzb:nzt+1) )
646             DO  k = nzb, nzt+1
647                init_l(k) = SUM( u(k,nys:nyn,nxl:nxr) )
648             ENDDO
649             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
650
651#if defined( __parallel )
652             CALL MPI_ALLREDUCE( init_l, u_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
653#else
654             u_init = init_l
655#endif
656             DEALLOCATE( init_l )
657
658          ENDIF
659
660          IF( init_3d%lod_v == 1 )  THEN
661             v_init = init_3d%v_init
662          ELSEIF( init_3d%lod_v == 2 )  THEN
663             ALLOCATE( init_l(nzb:nzt+1) )
664             DO  k = nzb, nzt+1
665                init_l(k) = SUM( v(k,nys:nyn,nxl:nxr) )
666             ENDDO
667             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
668
669#if defined( __parallel )
670             CALL MPI_ALLREDUCE( init_l, v_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
671#else
672             v_init = init_l
673#endif
674             DEALLOCATE( init_l )
675          ENDIF
676          IF( .NOT. neutral )  THEN
677             IF( init_3d%lod_pt == 1 )  THEN
678                pt_init = init_3d%pt_init
679             ELSEIF( init_3d%lod_pt == 2 )  THEN
680                ALLOCATE( init_l(nzb:nzt+1) )
681                DO  k = nzb, nzt+1
682                   init_l(k) = SUM( pt(k,nys:nyn,nxl:nxr) )
683                ENDDO
684                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
685
686#if defined( __parallel )
687                CALL MPI_ALLREDUCE( init_l, pt_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
688#else
689                pt_init = init_l
690#endif
691                DEALLOCATE( init_l )
692             ENDIF
693          ENDIF
694
695
696          IF( humidity )  THEN
697             IF( init_3d%lod_q == 1 )  THEN
698                q_init = init_3d%q_init
699             ELSEIF( init_3d%lod_q == 2 )  THEN
700                ALLOCATE( init_l(nzb:nzt+1) )
701                DO  k = nzb, nzt+1
702                   init_l(k) = SUM( q(k,nys:nyn,nxl:nxr) )
703                ENDDO
704                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
705
706#if defined( __parallel )
707                CALL MPI_ALLREDUCE( init_l, q_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
708#else
709                q_init = init_l
710#endif
711                DEALLOCATE( init_l )
712             ENDIF
713          ENDIF
714
715!
716!--       Write initial profiles onto 3D arrays.
717!--       Work-around, 3D initialization of u,v,w creates artificial structures which correlate with
718!--       the processor grid. The reason for this is still unknown. To work-around this, 3D
719!--       initialization will be effectively reduce to a 1D initialization where no such artificial
720!--       structures appear.
721          DO  i = nxlg, nxrg
722             DO  j = nysg, nyng
723                IF( init_3d%lod_u == 1  .OR.  init_3d%lod_u == 2 )  u(:,j,i) = u_init(:)
724                IF( init_3d%lod_v == 1  .OR.  init_3d%lod_u == 2 )  v(:,j,i) = v_init(:)
725                IF( .NOT. neutral  .AND.  ( init_3d%lod_pt == 1  .OR.  init_3d%lod_pt == 2 ) )     &
726                   pt(:,j,i) = pt_init(:)
727                IF( humidity  .AND.  ( init_3d%lod_q == 1  .OR.  init_3d%lod_q == 2 ) )            &
728                   q(:,j,i) = q_init(:)
729             ENDDO
730          ENDDO
731!
732!--       Set geostrophic wind components.
733          IF ( init_3d%from_file_ug )  THEN
734             ug(:) = init_3d%ug_init(:)
735          ENDIF
736          IF ( init_3d%from_file_vg )  THEN
737             vg(:) = init_3d%vg_init(:)
738          ENDIF
739!
740!--       Set bottom and top boundary condition for geostrophic wind
741          ug(nzt+1) = ug(nzt)
742          vg(nzt+1) = vg(nzt)
743          ug(nzb)   = ug(nzb+1)
744          vg(nzb)   = vg(nzb+1)
745!
746!--       Set inital w to 0
747          w = 0.0_wp
748
749          IF ( passive_scalar )  THEN
750             DO  i = nxlg, nxrg
751                DO  j = nysg, nyng
752                   s(:,j,i) = s_init
753                ENDDO
754             ENDDO
755          ENDIF
756
757!
758!--       Set velocity components at non-atmospheric / oceanic grid points to zero.
759          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
760          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
761          w = MERGE( w, 0.0_wp, BTEST( wall_flags_total_0, 3 ) )
762!
763!--       Initialize surface variables, e.g. friction velocity, momentum fluxes, etc.
764          CALL  init_surfaces
765
766          IF ( debug_output )  CALL  debug_message( 'initializing with INIFOR', 'end' )
767!
768!--    Initialization via computed 1D-model profiles
769       ELSEIF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
770
771          IF ( debug_output )  CALL  debug_message( 'initializing with 1D model profiles', 'start' )
772!
773!--       Use solutions of the 1D model as initial profiles,
774!--       start 1D model
775          CALL init_1d_model
776!
777!--       Transfer initial profiles to the arrays of the 3D model
778          DO  i = nxlg, nxrg
779             DO  j = nysg, nyng
780                pt(:,j,i) = pt_init
781                u(:,j,i)  = u1d
782                v(:,j,i)  = v1d
783             ENDDO
784          ENDDO
785
786          IF ( humidity )  THEN
787             DO  i = nxlg, nxrg
788                DO  j = nysg, nyng
789                   q(:,j,i) = q_init
790                ENDDO
791             ENDDO
792          ENDIF
793
794          IF ( passive_scalar )  THEN
795             DO  i = nxlg, nxrg
796                DO  j = nysg, nyng
797                   s(:,j,i) = s_init
798                ENDDO
799             ENDDO
800          ENDIF
801!
802!--          Store initial profiles for output purposes etc.
803          IF ( .NOT. constant_diffusion )  THEN
804             hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 )
805          ENDIF
806!
807!--       Set velocities back to zero
808          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
809          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
810!
811!--       WARNING: The extra boundary conditions set after running the 1D model impose an error on
812!--       -------- the divergence one layer below the topography; need to correct later
813!--       ATTENTION: Provisional correction for Piacsek & Williams advection scheme: keep u and v
814!--       ---------- zero one layer below the topography.
815          IF ( ibc_uv_b == 1 )  THEN
816!
817!--          Neumann condition
818             DO  i = nxl-1, nxr+1
819                DO  j = nys-1, nyn+1
820                   u(nzb,j,i) = u(nzb+1,j,i)
821                   v(nzb,j,i) = v(nzb+1,j,i)
822                ENDDO
823             ENDDO
824
825          ENDIF
826!
827!--       Initialize surface variables, e.g. friction velocity, momentum fluxes, etc.
828          CALL init_surfaces
829
830          IF ( debug_output )  CALL  debug_message( 'initializing with 1D model profiles', 'end' )
831
832       ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 )  THEN
833
834          IF ( debug_output )  CALL  debug_message( 'initializing with constant profiles', 'start' )
835
836!
837!--       Use constructed initial profiles (velocity constant with height, temperature profile with
838!--       constant gradient)
839          DO  i = nxlg, nxrg
840             DO  j = nysg, nyng
841                pt(:,j,i) = pt_init
842                u(:,j,i)  = u_init
843                v(:,j,i)  = v_init
844             ENDDO
845          ENDDO
846!
847!--       Mask topography
848          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
849          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
850!
851!--       Set initial horizontal velocities at the lowest computational grid levels to zero in order
852!--       to avoid too small time steps caused by the diffusion limit in the initial phase of a run
853!--       (at k=1, dz/2 occurs in the limiting formula!).
854!--       Please note, in case land- or urban-surface model is used and a spinup is applied, masking
855!--       the lowest computational level is not possible as MOST as well as energy-balance
856!--       parametrizations will not work with zero wind velocity.
857          IF ( ibc_uv_b /= 1  .AND.  .NOT. spinup )  THEN
858             DO  i = nxlg, nxrg
859                DO  j = nysg, nyng
860                   DO  k = nzb, nzt
861                      u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 20 ) )
862                      v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 21 ) )
863                   ENDDO
864                ENDDO
865             ENDDO
866          ENDIF
867
868          IF ( humidity )  THEN
869             DO  i = nxlg, nxrg
870                DO  j = nysg, nyng
871                   q(:,j,i) = q_init
872                ENDDO
873             ENDDO
874          ENDIF
875
876          IF ( passive_scalar )  THEN
877             DO  i = nxlg, nxrg
878                DO  j = nysg, nyng
879                   s(:,j,i) = s_init
880                ENDDO
881             ENDDO
882          ENDIF
883
884!
885!--       Compute initial temperature field and other constants used in case of a sloping surface.
886          IF ( sloping_surface )  CALL init_slope
887!
888!--       Initialize surface variables, e.g. friction velocity, momentum fluxes, etc.
889          CALL init_surfaces
890
891          IF ( debug_output )  CALL debug_message( 'initializing with constant profiles', 'end' )
892
893       ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 )  THEN
894
895          IF ( debug_output )  CALL debug_message( 'initializing by user', 'start' )
896!
897!--       Pre-initialize surface variables, i.e. setting start- and end-indices at each
898!--       (j,i)-location. Please note, this does not supersede user-defined initialization of
899!--       surface quantities.
900          CALL init_surfaces
901!
902!--       Initialization will completely be done by the user
903          CALL user_init_3d_model
904
905          IF ( debug_output )  CALL debug_message( 'initializing by user', 'end' )
906
907       ENDIF
908
909       IF ( debug_output )  THEN
910          CALL debug_message( 'initializing statistics, boundary conditions, etc.', 'start' )
911       ENDIF
912
913!
914!--    Bottom boundary
915       IF ( ibc_uv_b == 0  .OR.  ibc_uv_b == 2  )  THEN
916          u(nzb,:,:) = 0.0_wp
917          v(nzb,:,:) = 0.0_wp
918       ENDIF
919
920!
921!--    Apply channel flow boundary condition
922       IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
923          u(nzt+1,:,:) = 0.0_wp
924          v(nzt+1,:,:) = 0.0_wp
925       ENDIF
926
927!
928!--    Calculate virtual potential temperature
929       IF ( humidity )  vpt = pt * ( 1.0_wp + 0.61_wp * q )
930
931!
932!--    Store initial profiles for output purposes etc.. Please note, in case of initialization of u,
933!--    v, w, pt, and q via output data derived from larger scale models, data will not be
934!--    horizontally homogeneous. Actually, a mean profile should be calculated before.
935       hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 )
936       hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 )
937       IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2)  THEN
938          hom(nzb,1,5,:) = 0.0_wp
939          hom(nzb,1,6,:) = 0.0_wp
940       ENDIF
941       hom(:,1,7,:)  = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 )
942
943       IF ( humidity )  THEN
944!
945!--       Store initial profile of total water content, virtual potential temperature
946          hom(:,1,26,:) = SPREAD(   q(:,nys,nxl), 2, statistic_regions+1 )
947          hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 )
948!
949!--       Store initial profile of mixing ratio and potential temperature
950          IF ( bulk_cloud_model  .OR.  cloud_droplets ) THEN
951             hom(:,1,27,:) = SPREAD(  q(:,nys,nxl), 2, statistic_regions+1 )
952             hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 )
953          ENDIF
954       ENDIF
955
956!
957!--    Store initial scalar profile
958       IF ( passive_scalar )  THEN
959          hom(:,1,121,:) = SPREAD(  s(:,nys,nxl), 2, statistic_regions+1 )
960       ENDIF
961
962!
963!--    Initialize the random number generators (from numerical recipes)
964       CALL random_function_ini
965
966       IF ( random_generator == 'random-parallel' )  THEN
967          CALL init_parallel_random_generator( nx, nys, nyn, nxl, nxr )
968       ENDIF
969!
970!--    Set the reference state to be used in the buoyancy terms (for ocean runs the reference state
971!--    will be set (overwritten) in init_ocean).
972       IF ( use_single_reference_value )  THEN
973          IF ( .NOT. humidity )  THEN
974             ref_state(:) = pt_reference
975          ELSE
976             ref_state(:) = vpt_reference
977          ENDIF
978       ELSE
979          IF ( .NOT. humidity )  THEN
980             ref_state(:) = pt_init(:)
981          ELSE
982             ref_state(:) = vpt(:,nys,nxl)
983          ENDIF
984       ENDIF
985
986!
987!--    For the moment, vertical velocity is zero
988       w = 0.0_wp
989
990!
991!--    Initialize array sums (must be defined in first call of pres)
992       sums = 0.0_wp
993
994!
995!--    In case of iterative solvers, p must get an initial value
996       IF ( psolver(1:9) == 'multigrid'  .OR.  psolver == 'sor' )  p = 0.0_wp
997!
998!--    Impose vortex with vertical axis on the initial velocity profile
999       IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 )  THEN
1000          CALL init_rankine
1001       ENDIF
1002
1003!
1004!--    Impose temperature anomaly (advection test only) or warm air bubble close to surface.
1005       IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0  .OR.                          &
1006            INDEX( initializing_actions, 'initialize_bubble' ) /= 0  )  THEN
1007          CALL init_pt_anomaly
1008       ENDIF
1009
1010!
1011!--    If required, change the surface temperature at the start of the 3D run
1012       IF ( pt_surface_initial_change /= 0.0_wp )  THEN
1013          pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change
1014       ENDIF
1015
1016!
1017!--    If required, change the surface humidity/scalar at the start of the 3D
1018!--    run
1019       IF ( humidity  .AND.  q_surface_initial_change /= 0.0_wp )                                  &
1020          q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change
1021
1022       IF ( passive_scalar  .AND.  s_surface_initial_change /= 0.0_wp )                            &
1023          s(nzb,:,:) = s(nzb,:,:) + s_surface_initial_change
1024
1025
1026!
1027!--    Initialize old and new time levels.
1028       tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp
1029       pt_p = pt; u_p = u; v_p = v; w_p = w
1030
1031       IF ( humidity  )  THEN
1032          tq_m = 0.0_wp
1033          q_p = q
1034       ENDIF
1035
1036       IF ( passive_scalar )  THEN
1037          ts_m = 0.0_wp
1038          s_p  = s
1039       ENDIF
1040
1041       IF ( debug_output )  THEN
1042          CALL debug_message( 'initializing statistics, boundary conditions, etc.', 'end' )
1043       ENDIF
1044
1045    ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data'  .OR.         &
1046             TRIM( initializing_actions ) == 'cyclic_fill' )                   &
1047    THEN
1048
1049       IF ( debug_output )  THEN
1050          CALL debug_message( 'initializing in case of restart / cyclic_fill', 'start' )
1051       ENDIF
1052!
1053!--    Initialize surface elements and its attributes, e.g. heat- and momentumfluxes, roughness,
1054!--    scaling parameters. As number of surface elements might be different between runs, e.g. in
1055!--    case of cyclic fill, and not all surface elements are read, surface elements need to be
1056!--    initialized before.
1057!--    Please note, in case of cyclic fill, surfaces should be initialized after restart data is
1058!--    read, else, individual settings of surface parameters will be overwritten from data of
1059!--    precursor run, hence, init_surfaces is called a second time after reading the restart data.
1060       CALL init_surfaces
1061!
1062!--    When reading data for cyclic fill of 3D prerun data files, read some of the global variables
1063!--    from the restart file which are required for initializing the inflow
1064       IF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1065
1066!
1067!--       Blockwise I/O does not work together with MPI-I/O
1068          IF ( restart_data_format_input(1:3) == 'mpi' )  THEN
1069             CALL rrd_read_parts_of_global
1070          ELSE
1071             DO  i = 0, io_blocks-1
1072                IF ( i == io_group )  THEN
1073                   CALL rrd_read_parts_of_global
1074                ENDIF
1075#if defined( __parallel )
1076                CALL MPI_BARRIER( comm2d, ierr )
1077#endif
1078             ENDDO
1079          ENDIF
1080
1081       ENDIF
1082
1083!
1084!--    Read processor specific binary data from restart file.
1085!--    Blockwise I/O does not work together with MPI-I/O
1086       IF ( restart_data_format_input(1:3) == 'mpi' )  THEN
1087          CALL rrd_local
1088       ELSE
1089          DO  i = 0, io_blocks-1
1090             IF ( i == io_group )  THEN
1091                CALL rrd_local
1092             ENDIF
1093#if defined( __parallel )
1094             CALL MPI_BARRIER( comm2d, ierr )
1095#endif
1096          ENDDO
1097       ENDIF
1098
1099
1100       IF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1101
1102!
1103!--       In case of cyclic fill, call init_surfaces a second time, so that surface properties such
1104!--       as heat fluxes are initialized as prescribed.
1105          CALL init_surfaces
1106
1107!
1108!--       Overwrite u_init, v_init, pt_init, q_init and s_init with the horizontally mean (hom)
1109!--       vertical profiles from the end of the prerun, because these profiles shall be used as the
1110!--       reference state for the rayleigh damping and the pt_damping. This is especially important
1111!--       for the use of large_scale_subsidence, because the reference temperature in the free
1112!--       atmosphere changes in time.
1113          u_init(:) = hom_sum(:,1,0)
1114          v_init(:) = hom_sum(:,2,0)
1115          pt_init(:) = hom_sum(:,4,0)
1116          IF ( humidity )  q_init(:) = hom_sum(:,41,0)
1117          IF ( passive_scalar )  s_init(:) = hom_sum(:,115,0)
1118       ENDIF
1119!
1120!--    In case of complex terrain and cyclic fill method as initialization, shift initial data in
1121!--    the vertical direction for each point in the x-y-plane depending on local surface height.
1122       IF ( complex_terrain  .AND.  TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1123          DO  i = nxlg, nxrg
1124             DO  j = nysg, nyng
1125                nz_u_shift = topo_top_ind(j,i,1)
1126                nz_v_shift = topo_top_ind(j,i,2)
1127                nz_w_shift = topo_top_ind(j,i,3)
1128                nz_s_shift = topo_top_ind(j,i,0)
1129
1130                u(nz_u_shift:nzt+1,j,i)  = u(0:nzt+1-nz_u_shift,j,i)
1131
1132                v(nz_v_shift:nzt+1,j,i)  = v(0:nzt+1-nz_v_shift,j,i)
1133
1134                w(nz_w_shift:nzt+1,j,i)  = w(0:nzt+1-nz_w_shift,j,i)
1135
1136                p(nz_s_shift:nzt+1,j,i)  =  p(0:nzt+1-nz_s_shift,j,i)
1137                pt(nz_s_shift:nzt+1,j,i) = pt(0:nzt+1-nz_s_shift,j,i)
1138             ENDDO
1139          ENDDO
1140       ENDIF
1141!
1142!--    Initialization of the turbulence recycling method
1143       IF ( TRIM( initializing_actions ) == 'cyclic_fill'  .AND.  turbulent_inflow )  THEN
1144!
1145!--       First store the profiles to be used at the inflow.
1146!--       These profiles are the (temporally) and horizontally averaged vertical profiles from the
1147!--       prerun. Alternatively, prescribed profiles for u,v-components can be used.
1148          ALLOCATE( mean_inflow_profiles(nzb:nzt+1,1:num_mean_inflow_profiles) )
1149
1150          IF ( use_prescribed_profile_data )  THEN
1151             mean_inflow_profiles(:,1) = u_init            ! u
1152             mean_inflow_profiles(:,2) = v_init            ! v
1153          ELSE
1154             mean_inflow_profiles(:,1) = hom_sum(:,1,0)    ! u
1155             mean_inflow_profiles(:,2) = hom_sum(:,2,0)    ! v
1156          ENDIF
1157          mean_inflow_profiles(:,4) = hom_sum(:,4,0)       ! pt
1158          IF ( humidity )  mean_inflow_profiles(:,6) = hom_sum(:,41,0)          ! q
1159          IF ( passive_scalar )  mean_inflow_profiles(:,7) = hom_sum(:,115,0)   ! s
1160
1161!
1162!--       In case of complex terrain, determine vertical displacement at inflow boundary and adjust
1163!--       mean inflow profiles
1164          IF ( complex_terrain )  THEN
1165             IF ( nxlg <= 0  .AND.  nxrg >= 0  .AND.  nysg <= 0  .AND.  nyng >= 0 )  THEN
1166                nz_u_shift_l = topo_top_ind(j,i,1)
1167                nz_v_shift_l = topo_top_ind(j,i,2)
1168                nz_w_shift_l = topo_top_ind(j,i,3)
1169                nz_s_shift_l = topo_top_ind(j,i,0)
1170             ELSE
1171                nz_u_shift_l = 0
1172                nz_v_shift_l = 0
1173                nz_w_shift_l = 0
1174                nz_s_shift_l = 0
1175             ENDIF
1176
1177#if defined( __parallel )
1178             CALL MPI_ALLREDUCE( nz_u_shift_l, nz_u_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )
1179             CALL MPI_ALLREDUCE( nz_v_shift_l, nz_v_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )
1180             CALL MPI_ALLREDUCE( nz_w_shift_l, nz_w_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )
1181             CALL MPI_ALLREDUCE( nz_s_shift_l, nz_s_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )
1182#else
1183             nz_u_shift = nz_u_shift_l
1184             nz_v_shift = nz_v_shift_l
1185             nz_w_shift = nz_w_shift_l
1186             nz_s_shift = nz_s_shift_l
1187#endif
1188
1189             mean_inflow_profiles(:,1) = 0.0_wp
1190             mean_inflow_profiles(nz_u_shift:nzt+1,1) = hom_sum(0:nzt+1-nz_u_shift,1,0)  ! u
1191
1192             mean_inflow_profiles(:,2) = 0.0_wp
1193             mean_inflow_profiles(nz_v_shift:nzt+1,2) = hom_sum(0:nzt+1-nz_v_shift,2,0)  ! v
1194
1195             mean_inflow_profiles(nz_s_shift:nzt+1,4) = hom_sum(0:nzt+1-nz_s_shift,4,0)  ! pt
1196
1197          ENDIF
1198
1199!
1200!--       If necessary, adjust the horizontal flow field to the prescribed profiles
1201          IF ( use_prescribed_profile_data )  THEN
1202             DO  i = nxlg, nxrg
1203                DO  j = nysg, nyng
1204                   DO  k = nzb, nzt+1
1205                      u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k)
1206                      v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k)
1207                   ENDDO
1208                ENDDO
1209             ENDDO
1210          ENDIF
1211
1212!
1213!--       Use these mean profiles at the inflow (provided that Dirichlet conditions are used)
1214          IF ( bc_dirichlet_l )  THEN
1215             DO  j = nysg, nyng
1216                DO  k = nzb, nzt+1
1217                   u(k,j,nxlg:-1)  = mean_inflow_profiles(k,1)
1218                   v(k,j,nxlg:-1)  = mean_inflow_profiles(k,2)
1219                   w(k,j,nxlg:-1)  = 0.0_wp
1220                   pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4)
1221                   IF ( humidity )  q(k,j,nxlg:-1)  = mean_inflow_profiles(k,6)
1222                   IF ( passive_scalar )  s(k,j,nxlg:-1)  = mean_inflow_profiles(k,7)
1223                ENDDO
1224             ENDDO
1225          ENDIF
1226
1227!
1228!--       Calculate the damping factors to be used at the inflow. For a turbulent inflow the
1229!--       turbulent fluctuations have to be limited vertically because otherwise the turbulent
1230!--       inflow layer will grow in time.
1231          IF ( inflow_damping_height == 9999999.9_wp )  THEN
1232!
1233!--          Default: use the inversion height calculated by the prerun; if this is zero,
1234!--          inflow_damping_height must be explicitly specified.
1235             IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp )  THEN
1236                inflow_damping_height = hom_sum(nzb+6,pr_palm,0)
1237             ELSE
1238                WRITE( message_string, * ) 'inflow_damping_height must be ',                       &
1239                                           'explicitly specified because&the inversion height ',   &
1240                                           'calculated by the prerun is zero.'
1241                CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 )
1242             ENDIF
1243
1244          ENDIF
1245
1246          IF ( inflow_damping_width == 9999999.9_wp )  THEN
1247!
1248!--          Default for the transition range: one tenth of the undamped layer
1249             inflow_damping_width = 0.1_wp * inflow_damping_height
1250
1251          ENDIF
1252
1253          ALLOCATE( inflow_damping_factor(nzb:nzt+1) )
1254
1255          DO  k = nzb, nzt+1
1256
1257             IF ( zu(k) <= inflow_damping_height )  THEN
1258                inflow_damping_factor(k) = 1.0_wp
1259             ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) )  THEN
1260                inflow_damping_factor(k) = 1.0_wp -                                                &
1261                                           ( zu(k) - inflow_damping_height ) / inflow_damping_width
1262             ELSE
1263                inflow_damping_factor(k) = 0.0_wp
1264             ENDIF
1265
1266          ENDDO
1267
1268       ENDIF
1269
1270!
1271!--    Inside buildings set velocities back to zero
1272       IF ( TRIM( initializing_actions ) == 'cyclic_fill'  .AND.  topography /= 'flat' )  THEN
1273!
1274!--       Inside buildings set velocities back to zero.
1275!--       Other scalars (pt, q, s, p, sa, ...) are ignored at present,
1276!--       maybe revise later.
1277          DO  i = nxlg, nxrg
1278             DO  j = nysg, nyng
1279                DO  k = nzb, nzt
1280                   u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
1281                   v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
1282                   w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
1283                ENDDO
1284             ENDDO
1285          ENDDO
1286
1287       ENDIF
1288
1289!
1290!--    Calculate initial temperature field and other constants used in case of a sloping surface
1291       IF ( sloping_surface )  CALL init_slope
1292
1293!
1294!--    Initialize new time levels (only done in order to set boundary values including ghost points)
1295       pt_p = pt; u_p = u; v_p = v; w_p = w
1296       IF ( humidity )  THEN
1297          q_p = q
1298       ENDIF
1299       IF ( passive_scalar )  s_p  = s
1300!
1301!--    Allthough tendency arrays are set in prognostic_equations, they have have to be predefined
1302!--    here because they are used (but multiplied with 0) there before they are set.
1303       tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp
1304       IF ( humidity )  THEN
1305          tq_m = 0.0_wp
1306       ENDIF
1307       IF ( passive_scalar )  ts_m  = 0.0_wp
1308
1309       IF ( debug_output )  THEN
1310          CALL debug_message( 'initializing in case of restart / cyclic_fill', 'end' )
1311       ENDIF
1312
1313    ELSE
1314!
1315!--    Actually this part of the programm should not be reached
1316       message_string = 'unknown initializing problem'
1317       CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 )
1318    ENDIF
1319
1320!
1321!-- Calculate the initial volume flow at the right and north boundary
1322    IF ( conserve_volume_flow )  THEN
1323
1324       IF ( use_prescribed_profile_data )  THEN
1325
1326          volume_flow_initial_l = 0.0_wp
1327          volume_flow_area_l    = 0.0_wp
1328
1329          IF ( nxr == nx )  THEN
1330             DO  j = nys, nyn
1331                DO  k = nzb+1, nzt
1332                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +                           &
1333                                              u_init(k) * dzw(k)                                   &
1334                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1335                                                       BTEST( wall_flags_total_0(k,j,nxr), 1 )     &
1336                                                     )
1337
1338                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)                       &
1339                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1340                                                       BTEST( wall_flags_total_0(k,j,nxr), 1 )     &
1341                                                     )
1342                ENDDO
1343             ENDDO
1344          ENDIF
1345
1346          IF ( nyn == ny )  THEN
1347             DO  i = nxl, nxr
1348                DO  k = nzb+1, nzt
1349                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +                           &
1350                                              v_init(k) * dzw(k)                                   &
1351                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1352                                                       BTEST( wall_flags_total_0(k,nyn,i), 2 )     &
1353                                                     )
1354                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)                       &
1355                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1356                                                       BTEST( wall_flags_total_0(k,nyn,i), 2 )     &
1357                                                     )
1358                ENDDO
1359             ENDDO
1360          ENDIF
1361
1362#if defined( __parallel )
1363          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL,       &
1364                              MPI_SUM, comm2d, ierr )
1365          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM,    &
1366                              comm2d, ierr )
1367
1368#else
1369          volume_flow_initial = volume_flow_initial_l
1370          volume_flow_area    = volume_flow_area_l
1371#endif
1372
1373       ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1374
1375          volume_flow_initial_l = 0.0_wp
1376          volume_flow_area_l    = 0.0_wp
1377
1378          IF ( nxr == nx )  THEN
1379             DO  j = nys, nyn
1380                DO  k = nzb+1, nzt
1381                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +                           &
1382                                              hom_sum(k,1,0) * dzw(k)                              &
1383                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1384                                                       BTEST( wall_flags_total_0(k,j,nx), 1 )      &
1385                                                     )
1386                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)                       &
1387                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1388                                                       BTEST( wall_flags_total_0(k,j,nx), 1 )      &
1389                                                     )
1390                ENDDO
1391             ENDDO
1392          ENDIF
1393
1394          IF ( nyn == ny )  THEN
1395             DO  i = nxl, nxr
1396                DO  k = nzb+1, nzt
1397                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +                           &
1398                                              hom_sum(k,2,0) * dzw(k)                              &
1399                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1400                                                       BTEST( wall_flags_total_0(k,ny,i), 2 )      &
1401                                                     )
1402                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)                       &
1403                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1404                                                       BTEST( wall_flags_total_0(k,ny,i), 2 )      &
1405                                                     )
1406                ENDDO
1407             ENDDO
1408          ENDIF
1409
1410#if defined( __parallel )
1411          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL,       &
1412                              MPI_SUM, comm2d, ierr )
1413          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM,    &
1414                              comm2d, ierr )
1415
1416#else
1417          volume_flow_initial = volume_flow_initial_l
1418          volume_flow_area    = volume_flow_area_l
1419#endif
1420
1421       ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1422
1423          volume_flow_initial_l = 0.0_wp
1424          volume_flow_area_l    = 0.0_wp
1425
1426          IF ( nxr == nx )  THEN
1427             DO  j = nys, nyn
1428                DO  k = nzb+1, nzt
1429                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +                           &
1430                                              u(k,j,nx) * dzw(k)                                   &
1431                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1432                                                       BTEST( wall_flags_total_0(k,j,nx), 1 )      &
1433                                                     )
1434                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)                       &
1435                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1436                                                   BTEST( wall_flags_total_0(k,j,nx), 1 )          &
1437                                                     )
1438                ENDDO
1439             ENDDO
1440          ENDIF
1441
1442          IF ( nyn == ny )  THEN
1443             DO  i = nxl, nxr
1444                DO  k = nzb+1, nzt
1445                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +                           &
1446                                              v(k,ny,i) * dzw(k)                                   &
1447                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1448                                                       BTEST( wall_flags_total_0(k,ny,i), 2 )      &
1449                                                     )
1450                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)                       &
1451                                              * MERGE( 1.0_wp, 0.0_wp,                             &
1452                                                       BTEST( wall_flags_total_0(k,ny,i), 2 )      &
1453                                                     )
1454                ENDDO
1455             ENDDO
1456          ENDIF
1457
1458#if defined( __parallel )
1459          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL,       &
1460                              MPI_SUM, comm2d, ierr )
1461          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM,    &
1462                              comm2d, ierr )
1463
1464#else
1465          volume_flow_initial = volume_flow_initial_l
1466          volume_flow_area    = volume_flow_area_l
1467#endif
1468
1469       ENDIF
1470
1471!
1472!--    In case of 'bulk_velocity' mode, volume_flow_initial is calculated from u|v_bulk instead
1473       IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
1474          volume_flow_initial(1) = u_bulk * volume_flow_area(1)
1475          volume_flow_initial(2) = v_bulk * volume_flow_area(2)
1476       ENDIF
1477
1478    ENDIF
1479!
1480!-- In the following, surface properties can be further initialized with input from static driver
1481!-- file.
1482!-- At the moment this affects only default surfaces. For example, roughness length or sensible /
1483!-- latent heat fluxes can be initialized heterogeneously for default surfaces. Therefore, a generic
1484!-- routine from netcdf_data_input_mod is called to read a 2D array.
1485    IF ( input_pids_static )  THEN
1486!
1487!--    Allocate memory for possible static input
1488       ALLOCATE( tmp_2d%var(nys:nyn,nxl:nxr) )
1489       tmp_2d%var = 0.0_wp
1490!
1491!--    Open the static input file
1492#if defined( __netcdf )
1493       CALL open_read_file( TRIM( input_file_static ) //                                           &
1494                            TRIM( coupling_char ), pids_id )
1495
1496       CALL inquire_num_variables( pids_id, num_var_pids )
1497!
1498!--    Allocate memory to store variable names and read them
1499       ALLOCATE( vars_pids(1:num_var_pids) )
1500       CALL inquire_variable_names( pids_id, vars_pids )
1501!
1502!--    Input roughness length.
1503       IF ( check_existence( vars_pids, 'z0' ) )  THEN
1504!
1505!--       Read _FillValue attribute
1506          CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'z0' )
1507!
1508!--       Read variable
1509          CALL get_variable( pids_id, 'z0', tmp_2d%var, nxl, nxr, nys, nyn )
1510!
1511!--       Initialize roughness length. Note, z0 will be only initialized at default-type surfaces.
1512!--       At natural or urban z0 is implicitly initialized by the respective parameter lists.
1513!--       Initialize horizontal surface elements.
1514          CALL init_single_surface_properties( surf_def_h(0)%z0, tmp_2d%var, surf_def_h(0)%ns,     &
1515                                               tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j )
1516!
1517!--       Initialize roughness also at vertical surface elements.
1518!--       Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the
1519!--       index arrays with their respective offset values.
1520          DO  l = 0, 3
1521             CALL init_single_surface_properties( surf_def_v(l)%z0, tmp_2d%var, surf_def_v(l)%ns,  &
1522                                                  tmp_2d%fill, surf_def_v(l)%i+surf_def_v(l)%ioff, &
1523                                                  surf_def_v(l)%j+surf_def_v(l)%joff )
1524          ENDDO
1525
1526       ENDIF
1527!
1528!--    Input surface sensible heat flux.
1529       IF ( check_existence( vars_pids, 'shf' ) )  THEN
1530!
1531!--       Read _FillValue attribute
1532          CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'shf' )
1533!
1534!--       Read variable
1535          CALL get_variable( pids_id, 'shf', tmp_2d%var, nxl, nxr, nys, nyn )
1536!
1537!--       Initialize heat flux. Note, shf will be only initialized at default-type surfaces. At
1538!--       natural or urban shf is implicitly initialized by the respective parameter lists.
1539!--       Initialize horizontal surface elements.
1540          CALL init_single_surface_properties( surf_def_h(0)%shf, tmp_2d%var, surf_def_h(0)%ns,    &
1541                                               tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j )
1542!
1543!--       Initialize heat flux also at vertical surface elements.
1544!--       Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the
1545!--       index arrays with their respective offset values.
1546          DO  l = 0, 3
1547             CALL init_single_surface_properties( surf_def_v(l)%shf, tmp_2d%var, surf_def_v(l)%ns, &
1548                                                  tmp_2d%fill, surf_def_v(l)%i+surf_def_v(l)%ioff, &
1549                                                  surf_def_v(l)%j+surf_def_v(l)%joff )
1550          ENDDO
1551
1552       ENDIF
1553!
1554!--    Input surface latent heat flux.
1555       IF ( humidity )  THEN
1556          IF ( check_existence( vars_pids, 'qsws' ) )  THEN
1557!
1558!--          Read _FillValue attribute
1559             CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'qsws' )
1560!
1561!--          Read variable
1562             CALL get_variable( pids_id, 'qsws', tmp_2d%var, nxl, nxr, nys, nyn )
1563!
1564!--          Initialize latent heat flux. Note, qsws will be only initialized at default-type surfaces.
1565!--          At natural or urban qsws is implicitly initialized by the respective parameter lists.
1566!--          Initialize horizontal surface elements.
1567             CALL init_single_surface_properties( surf_def_h(0)%qsws, tmp_2d%var, surf_def_h(0)%ns,&
1568                                                  tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j )
1569!
1570!--          Initialize latent heat flux also at vertical surface elements.
1571!--          Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the
1572!--          index arrays with their respective offset values.
1573             DO  l = 0, 3
1574                CALL init_single_surface_properties( surf_def_v(l)%qsws, tmp_2d%var,               &
1575                                                     surf_def_v(l)%ns, tmp_2d%fill,                &
1576                                                     surf_def_v(l)%i+surf_def_v(l)%ioff,           &
1577                                                     surf_def_v(l)%j+surf_def_v(l)%joff )
1578             ENDDO
1579
1580          ENDIF
1581       ENDIF
1582!
1583!--    Input passive scalar flux.
1584       IF ( passive_scalar )  THEN
1585          IF ( check_existence( vars_pids, 'ssws' ) )  THEN
1586!
1587!--          Read _FillValue attribute
1588             CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'ssws' )
1589!
1590!--          Read variable
1591             CALL get_variable( pids_id, 'ssws', tmp_2d%var, nxl, nxr, nys, nyn )
1592!
1593!--          Initialize passive scalar flux. Initialize horizontal surface elements.
1594             CALL init_single_surface_properties( surf_def_h(0)%ssws, tmp_2d%var, surf_def_h(0)%ns,&
1595                                                  tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j )
1596
1597             DO  l = 0, 3
1598                CALL init_single_surface_properties( surf_def_v(l)%ssws, tmp_2d%var,               &
1599                                                     surf_def_v(l)%ns, tmp_2d%fill,                &
1600                                                     surf_def_v(l)%i+surf_def_v(l)%ioff,           &
1601                                                     surf_def_v(l)%j+surf_def_v(l)%joff )
1602             ENDDO
1603
1604          ENDIF
1605       ENDIF
1606!
1607!--    Additional variables, can be initialized the
1608!--    same way.
1609
1610!
1611!--    Finally, close the input file and deallocate temporary arrays
1612       DEALLOCATE( vars_pids )
1613
1614       CALL close_input_file( pids_id )
1615#endif
1616       DEALLOCATE( tmp_2d%var )
1617    ENDIF
1618!
1619!-- Finally, if random_heatflux is set, disturb shf at horizontal surfaces. Actually, this should be
1620!-- done in surface_mod, where all other initializations of surface quantities are done. However,
1621!-- this would create a ring dependency, hence, it is done here. Maybe delete disturb_heatflux and
1622!-- tranfer the respective code directly into the initialization in surface_mod.
1623    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.                                &
1624         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
1625
1626       IF ( use_surface_fluxes  .AND.  constant_heatflux  .AND.  random_heatflux )  THEN
1627          IF ( surf_def_h(0)%ns >= 1 )  CALL disturb_heatflux( surf_def_h(0) )
1628          IF ( surf_lsm_h(0)%ns >= 1 )  CALL disturb_heatflux( surf_lsm_h(0) )
1629          IF ( surf_usm_h(0)%ns >= 1 )  CALL disturb_heatflux( surf_usm_h(0) )
1630       ENDIF
1631    ENDIF
1632
1633!
1634!-- Compute total sum of grid points and the mean surface level height for each statistic region.
1635!-- These are mainly used for horizontal averaging of turbulence statistics.
1636!-- ngp_2dh: number of grid points of a horizontal cross section through the respective statistic
1637!--          region
1638!-- ngp_3d:  number of grid points of the respective statistic region
1639    ngp_2dh_outer_l   = 0
1640    ngp_2dh_outer     = 0
1641    ngp_2dh_s_inner_l = 0
1642    ngp_2dh_s_inner   = 0
1643    ngp_2dh_l         = 0
1644    ngp_2dh           = 0
1645    ngp_3d_inner_l    = 0.0_wp
1646    ngp_3d_inner      = 0
1647    ngp_3d            = 0
1648    ngp_sums          = ( nz + 2 ) * ( pr_palm + max_pr_user )
1649
1650    mean_surface_level_height   = 0.0_wp
1651    mean_surface_level_height_l = 0.0_wp
1652!
1653!-- To do: New concept for these non-topography grid points!
1654    DO  sr = 0, statistic_regions
1655       DO  i = nxl, nxr
1656          DO  j = nys, nyn
1657             IF ( rmask(j,i,sr) == 1.0_wp )  THEN
1658!
1659!--             All xy-grid points
1660                ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1
1661!
1662!--             Determine mean surface-level height. In case of downward-facing walls are present,
1663!--             more than one surface level exist.
1664!--             In this case, use the lowest surface-level height.
1665                IF ( surf_def_h(0)%start_index(j,i) <= surf_def_h(0)%end_index(j,i) )  THEN
1666                   m = surf_def_h(0)%start_index(j,i)
1667                   k = surf_def_h(0)%k(m)
1668                   mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1)
1669                ENDIF
1670                IF ( surf_lsm_h(0)%start_index(j,i) <= surf_lsm_h(0)%end_index(j,i) )  THEN
1671                   m = surf_lsm_h(0)%start_index(j,i)
1672                   k = surf_lsm_h(0)%k(m)
1673                   mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1)
1674                ENDIF
1675                IF ( surf_usm_h(0)%start_index(j,i) <= surf_usm_h(0)%end_index(j,i) )  THEN
1676                   m = surf_usm_h(0)%start_index(j,i)
1677                   k = surf_usm_h(0)%k(m)
1678                   mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1)
1679                ENDIF
1680
1681                k_surf = k - 1
1682
1683                DO  k = nzb, nzt+1
1684!
1685!--                xy-grid points above topography
1686                   ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr)     +                             &
1687                                           MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 24 ) )
1688
1689                   ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) +                             &
1690                                             MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 22 ) )
1691
1692                ENDDO
1693!
1694!--             All grid points of the total domain above topography
1695                ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + ( nz - k_surf + 2 )
1696
1697
1698
1699             ENDIF
1700          ENDDO
1701       ENDDO
1702    ENDDO
1703
1704    sr = statistic_regions + 1
1705#if defined( __parallel )
1706    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
1707    CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, comm2d, ierr )
1708    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
1709    CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, MPI_INTEGER, MPI_SUM, &
1710                        comm2d, ierr )
1711    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
1712    CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), (nz+2)*sr, MPI_INTEGER,      &
1713                        MPI_SUM, comm2d, ierr )
1714    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
1715    CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, MPI_SUM, comm2d,     &
1716                        ierr )
1717    ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) )
1718    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
1719    CALL MPI_ALLREDUCE( mean_surface_level_height_l(0), mean_surface_level_height(0), sr, MPI_REAL,&
1720                        MPI_SUM, comm2d, ierr )
1721    mean_surface_level_height = mean_surface_level_height / REAL( ngp_2dh )
1722#else
1723    ngp_2dh         = ngp_2dh_l
1724    ngp_2dh_outer   = ngp_2dh_outer_l
1725    ngp_2dh_s_inner = ngp_2dh_s_inner_l
1726    ngp_3d_inner    = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) )
1727    mean_surface_level_height = mean_surface_level_height_l / REAL( ngp_2dh_l )
1728#endif
1729
1730    ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) *                                     &
1731             INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) )
1732
1733!
1734!-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, buoyancy, etc. A
1735!-- zero value will occur for cases where all grid points of the respective subdomain lie below the
1736!-- surface topography
1737    ngp_2dh_outer   = MAX( 1, ngp_2dh_outer(:,:)   )
1738    ngp_3d_inner    = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), ngp_3d_inner(:) )
1739    ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) )
1740
1741    DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l,           &
1742                ngp_3d_inner_tmp )
1743
1744!
1745!-- Initializae 3D offline nesting in COSMO model and read data from
1746!-- external NetCDF file.
1747    IF ( nesting_offline )  CALL nesting_offl_init
1748!
1749!-- Initialize quantities for special advections schemes
1750    CALL init_advec
1751
1752!
1753!-- Impose random perturbation on the horizontal velocity field and then
1754!-- remove the divergences from the velocity field at the initial stage
1755    IF ( create_disturbances  .AND.  disturbance_energy_limit /= 0.0_wp  .AND.                     &
1756         TRIM( initializing_actions ) /= 'read_restart_data'  .AND.                                &
1757         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
1758
1759       IF ( debug_output )  THEN
1760          CALL debug_message( 'creating disturbances + applying pressure solver', 'start' )
1761       ENDIF
1762!
1763!--    Needed for both disturb_field and pres
1764!$ACC DATA &
1765!$ACC CREATE(tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
1766!$ACC COPY(u(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
1767!$ACC COPY(v(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
1768
1769       CALL disturb_field( 'u', tend, u )
1770       CALL disturb_field( 'v', tend, v )
1771
1772!$ACC DATA &
1773!$ACC CREATE(d(nzb+1:nzt,nys:nyn,nxl:nxr)) &
1774!$ACC COPY(w(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
1775!$ACC COPY(p(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
1776!$ACC COPYIN(rho_air(nzb:nzt+1), rho_air_zw(nzb:nzt+1)) &
1777!$ACC COPYIN(ddzu(1:nzt+1), ddzw(1:nzt+1)) &
1778!$ACC COPYIN(wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
1779!$ACC COPYIN(bc_h(0:1)) &
1780!$ACC COPYIN(bc_h(0)%i(1:bc_h(0)%ns)) &
1781!$ACC COPYIN(bc_h(0)%j(1:bc_h(0)%ns)) &
1782!$ACC COPYIN(bc_h(0)%k(1:bc_h(0)%ns)) &
1783!$ACC COPYIN(bc_h(1)%i(1:bc_h(1)%ns)) &
1784!$ACC COPYIN(bc_h(1)%j(1:bc_h(1)%ns)) &
1785!$ACC COPYIN(bc_h(1)%k(1:bc_h(1)%ns))
1786
1787       n_sor = nsor_ini
1788       CALL pres
1789       n_sor = nsor
1790
1791!$ACC END DATA
1792!$ACC END DATA
1793
1794       IF ( debug_output )  THEN
1795          CALL debug_message( 'creating disturbances + applying pressure solver', 'end' )
1796       ENDIF
1797
1798    ENDIF
1799
1800    IF ( .NOT. ocean_mode )  THEN
1801
1802       ALLOCATE( hyp(nzb:nzt+1) )
1803       ALLOCATE( d_exner(nzb:nzt+1) )
1804       ALLOCATE( exner(nzb:nzt+1) )
1805       ALLOCATE( hyrho(nzb:nzt+1) )
1806!
1807!--    Check temperature in case of too large domain height
1808       DO  k = nzb, nzt+1
1809          IF ( ( pt_surface * exner_function( surface_pressure * 100.0_wp ) - g/c_p * zu(k) )      &
1810                 < 0.0_wp )  THEN
1811             WRITE( message_string, * )  'absolute temperature < 0.0 at zu(', k, ') = ', zu(k)
1812             CALL message( 'init_3d_model', 'PA0142', 1, 2, 0, 6, 0 )
1813          ENDIF
1814       ENDDO
1815
1816!
1817!--    Calculate vertical profile of the hydrostatic pressure (hyp)
1818       hyp    = barometric_formula( zu, pt_surface * exner_function( surface_pressure * 100.0_wp ),&
1819                                    surface_pressure * 100.0_wp )
1820       d_exner = exner_function_invers( hyp )
1821       exner = 1.0_wp / exner_function_invers( hyp )
1822       hyrho  = ideal_gas_law_rho_pt( hyp, pt_init )
1823!
1824!--    Compute reference density
1825       rho_surface = ideal_gas_law_rho( surface_pressure * 100.0_wp,                               &
1826                                        pt_surface * exner_function( surface_pressure * 100.0_wp ) )
1827
1828    ENDIF
1829
1830!
1831!-- If required, initialize particles
1832    IF ( agents_active )  CALL mas_init
1833!
1834!-- Initialization of synthetic turbulence generator
1835    IF ( syn_turb_gen )  CALL stg_init
1836!
1837!-- Initializing actions for all other modules
1838    CALL module_interface_init
1839!
1840!-- Initialize surface layer (done after LSM as roughness length are required for initialization
1841    IF ( constant_flux_layer )  CALL init_surface_layer_fluxes
1842!
1843!-- Initialize surface data output
1844    IF ( surface_output )  CALL surface_data_output_init
1845!
1846!-- Initialize the ws-scheme.
1847    IF ( ws_scheme_sca  .OR.  ws_scheme_mom )  CALL ws_init
1848!
1849!-- Perform post-initializing checks for all other modules
1850    CALL module_interface_init_checks
1851
1852!
1853!-- Initialize surface forcing corresponding to large-scale forcing. Therein,
1854!-- initialize heat-fluxes, etc. via datatype. Revise it later!
1855    IF ( large_scale_forcing  .AND.  lsf_surf )  THEN
1856       IF ( use_surface_fluxes  .AND.  constant_heatflux )  THEN
1857          CALL ls_forcing_surf( simulated_time )
1858       ENDIF
1859    ENDIF
1860!
1861!-- Setting weighting factors for calculation of perturbation pressure and turbulent quantities from
1862!-- the RK substeps.
1863    IF ( TRIM( timestep_scheme ) == 'runge-kutta-3' )  THEN      ! for RK3-method
1864
1865       weight_substep(1) = 1._wp/6._wp
1866       weight_substep(2) = 3._wp/10._wp
1867       weight_substep(3) = 8._wp/15._wp
1868
1869       weight_pres(1)    = 1._wp/3._wp
1870       weight_pres(2)    = 5._wp/12._wp
1871       weight_pres(3)    = 1._wp/4._wp
1872
1873    ELSEIF ( TRIM( timestep_scheme ) == 'runge-kutta-2' )  THEN  ! for RK2-method
1874
1875       weight_substep(1) = 1._wp/2._wp
1876       weight_substep(2) = 1._wp/2._wp
1877
1878       weight_pres(1)    = 1._wp/2._wp
1879       weight_pres(2)    = 1._wp/2._wp
1880
1881    ELSE                                     ! for Euler-method
1882
1883       weight_substep(1) = 1.0_wp
1884       weight_pres(1)    = 1.0_wp
1885
1886    ENDIF
1887
1888!
1889!-- Initialize Rayleigh damping factors
1890    rdf    = 0.0_wp
1891    rdf_sc = 0.0_wp
1892    IF ( rayleigh_damping_factor /= 0.0_wp )  THEN
1893
1894       IF (  .NOT.  ocean_mode )  THEN
1895          DO  k = nzb+1, nzt
1896             IF ( zu(k) >= rayleigh_damping_height )  THEN
1897                rdf(k) = rayleigh_damping_factor *                                                 &
1898                         ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height )                  &
1899                                / ( zu(nzt) - rayleigh_damping_height ) )                          &
1900                         )**2
1901             ENDIF
1902          ENDDO
1903       ELSE
1904!
1905!--       In ocean mode, rayleigh damping is applied in the lower part of the model domain
1906          DO  k = nzt, nzb+1, -1
1907             IF ( zu(k) <= rayleigh_damping_height )  THEN
1908                rdf(k) = rayleigh_damping_factor *                                                 &
1909                         ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) )                  &
1910                                / ( rayleigh_damping_height - zu(nzb+1) ) )                        &
1911                         )**2
1912             ENDIF
1913          ENDDO
1914       ENDIF
1915
1916    ENDIF
1917    IF ( scalar_rayleigh_damping )  rdf_sc = rdf
1918
1919!
1920!-- Initialize the starting level and the vertical smoothing factor used for the external pressure
1921!-- gradient
1922    dp_smooth_factor = 1.0_wp
1923    IF ( dp_external )  THEN
1924!
1925!--    Set the starting level dp_level_ind_b only if it has not been set before (e.g. in init_grid).
1926       IF ( dp_level_ind_b == 0 )  THEN
1927          ind_array = MINLOC( ABS( dp_level_b - zu ) )
1928          dp_level_ind_b = ind_array(1) - 1 + nzb
1929                                        ! MINLOC uses lower array bound 1
1930       ENDIF
1931       IF ( dp_smooth )  THEN
1932          dp_smooth_factor(:dp_level_ind_b) = 0.0_wp
1933          DO  k = dp_level_ind_b+1, nzt
1934             dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi *                                   &
1935                                             ( REAL( k - dp_level_ind_b, KIND=wp ) /               &
1936                                               REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) )
1937          ENDDO
1938       ENDIF
1939    ENDIF
1940
1941!
1942!-- Initialize damping zone for the potential temperature in case of non-cyclic lateral boundaries.
1943!-- The damping zone has the maximum value at the inflow boundary and decreases to zero at
1944!-- pt_damping_width.
1945    ptdf_x = 0.0_wp
1946    ptdf_y = 0.0_wp
1947    IF ( bc_lr_dirrad )  THEN
1948       DO  i = nxl, nxr
1949          IF ( ( i * dx ) < pt_damping_width )  THEN
1950             ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp *                                  &
1951                                                    REAL( pt_damping_width - i * dx, KIND=wp ) /   &
1952                                                    REAL( pt_damping_width, KIND=wp ) ) )**2
1953                                  ENDIF
1954       ENDDO
1955    ELSEIF ( bc_lr_raddir )  THEN
1956       DO  i = nxl, nxr
1957          IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) )  THEN
1958             ptdf_x(i) = pt_damping_factor * SIN( pi * 0.5_wp *                                    &
1959                                                  ( ( i - nx ) * dx + pt_damping_width ) /         &
1960                                                  REAL( pt_damping_width, KIND=wp ) )**2
1961          ENDIF
1962       ENDDO
1963    ELSEIF ( bc_ns_dirrad )  THEN
1964       DO  j = nys, nyn
1965          IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) )  THEN
1966             ptdf_y(j) = pt_damping_factor * SIN( pi * 0.5_wp *                                    &
1967                                                  ( ( j - ny ) * dy + pt_damping_width ) /         &
1968                                                  REAL( pt_damping_width, KIND=wp ) )**2
1969          ENDIF
1970       ENDDO
1971    ELSEIF ( bc_ns_raddir )  THEN
1972       DO  j = nys, nyn
1973          IF ( ( j * dy ) < pt_damping_width )  THEN
1974             ptdf_y(j) = pt_damping_factor * SIN( pi * 0.5_wp *                                    &
1975                                                  ( pt_damping_width - j * dy ) /                  &
1976                                                  REAL( pt_damping_width, KIND=wp ) )**2
1977          ENDIF
1978       ENDDO
1979    ENDIF
1980
1981!
1982!-- Input binary data file is not needed anymore. This line must be placed after call of user_init!
1983    CALL close_file( 13 )
1984!
1985!-- In case of nesting, put an barrier to assure that all parent and child domains finished
1986!-- initialization.
1987#if defined( __parallel )
1988    IF ( nested_run )  CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
1989#endif
1990
1991
1992    CALL location_message( 'model initialization', 'finished' )
1993
1994 END SUBROUTINE init_3d_model
Note: See TracBrowser for help on using the repository browser.