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

Last change on this file since 2716 was 2716, checked in by kanani, 6 years ago

Correction of "Former revisions" section

  • Property svn:keywords set to Id
  • Property svn:mergeinfo set to False
    /palm/branches/forwind/SOURCE/init_3d_model.f901564-1913
    /palm/branches/palm4u/SOURCE/init_3d_model.f902540-2692
File size: 93.9 KB
RevLine 
[1682]1!> @file init_3d_model.f90
[2000]2!------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[254]20! Current revisions:
[732]21! ------------------
[2233]22!
[2701]23!
[2233]24! Former revisions:
25! -----------------
26! $Id: init_3d_model.f90 2716 2017-12-29 16:35:59Z kanani $
[2716]27! Corrected "Former revisions" section
28!
29! 2705 2017-12-18 11:26:23Z maronga
[2705]30! Bugfix for reading initial profiles from ls/nuding file
[2716]31!
32! 2701 2017-12-15 15:40:50Z suehring
33! Changes from last commit documented
[2705]34!
[2716]35! 2700 2017-12-15 14:12:35Z suehring
[2701]36! Bugfix, missing initialization of surface attributes in case of
37! inifor-initialization branch
[2716]38!
39! 2698 2017-12-14 18:46:24Z suehring
40! Bugfix in get_topography_top_index
41!
42! 2696 2017-12-14 17:12:51Z kanani
43! Change in file header (GPL part)
[2696]44! Implementation of uv exposure model (FK)
45! Moved initialisation of diss, e, kh, km to turbulence_closure_mod (TG)
46! Added chemical emissions (FK)
47! Initialize masking arrays and number-of-grid-points arrays before initialize
48! LSM, USM and radiation module
49! Initialization with inifor (MS)
50!
51! 2618 2017-11-16 15:37:30Z suehring
[2618]52! Reorder calls of init_surfaces.
53!
54! 2564 2017-10-19 15:56:56Z Giersch
[2564]55! Variable wind_turbine was added to control_parameters.
56!
57! 2550 2017-10-16 17:12:01Z boeske
[2550]58! Modifications to cyclic fill method and turbulence recycling method in case of
59! complex terrain simulations
60!
61! 2513 2017-10-04 09:24:39Z kanani
[2513]62! Bugfix in storing initial scalar profile (wrong index)
63!
64! 2350 2017-08-15 11:48:26Z kanani
[2350]65! Bugfix in nopointer version
66!
67! 2339 2017-08-07 13:55:26Z gronemeier
[2339]68! corrected timestamp in header
69!
70! 2338 2017-08-07 12:15:38Z gronemeier
[2338]71! Modularize 1D model
72!
[2339]73! 2329 2017-08-03 14:24:56Z knoop
[2329]74! Removed temporary bugfix (r2327) as bug is properly resolved by this revision
75!
76! 2327 2017-08-02 07:40:57Z maronga
[2327]77! Temporary bugfix
78!
79! 2320 2017-07-21 12:47:43Z suehring
[2320]80! Modularize large-scale forcing and nudging
81!
82! 2292 2017-06-20 09:51:42Z schwenkel
[2292]83! Implementation of new microphysic scheme: cloud_scheme = 'morrison'
84! includes two more prognostic equations for cloud drop concentration (nc) 
85! and cloud water content (qc).
86!
87! 2277 2017-06-12 10:47:51Z kanani
[2277]88! Removed unused variable sums_up_fraction_l
89!
90! 2270 2017-06-09 12:18:47Z maronga
[2270]91! dots_num must be increased when LSM and/or radiation is used
92!
93! 2259 2017-06-08 09:09:11Z gronemeier
[2259]94! Implemented synthetic turbulence generator
95!
96! 2252 2017-06-07 09:35:37Z knoop
[2252]97! rho_air now depending on surface_pressure even in Boussinesq mode
98!
99! 2233 2017-05-30 18:08:54Z suehring
[2233]100!
101! 2232 2017-05-30 17:47:52Z suehring
[2232]102! Adjustments to new topography and surface concept:
103!   - Modify passed parameters for disturb_field
104!   - Topography representation via flags
105!   - Remove unused arrays.
106!   - Move initialization of surface-related quantities to surface_mod
[1961]107!
[2173]108! 2172 2017-03-08 15:55:25Z knoop
109! Bugfix: moved parallel random generator initialization into its module
110!
[2119]111! 2118 2017-01-17 16:38:49Z raasch
112! OpenACC directives removed
113!
[2038]114! 2037 2016-10-26 11:15:40Z knoop
115! Anelastic approximation implemented
116!
[2032]117! 2031 2016-10-21 15:11:58Z knoop
118! renamed variable rho to rho_ocean
119!
[2012]120! 2011 2016-09-19 17:29:57Z kanani
121! Flag urban_surface is now defined in module control_parameters.
122!
[2008]123! 2007 2016-08-24 15:47:17Z kanani
124! Added support for urban surface model,
125! adjusted location_message in case of plant_canopy
126!
[2001]127! 2000 2016-08-20 18:09:15Z knoop
128! Forced header and separation lines into 80 columns
129!
[1993]130! 1992 2016-08-12 15:14:59Z suehring
131! Initializaton of scalarflux at model top
132! Bugfixes in initialization of surface and top salinity flux, top scalar and
133! humidity fluxes
134!
[1961]135! 1960 2016-07-12 16:34:24Z suehring
[1960]136! Separate humidity and passive scalar
137! Increase dimension for mean_inflow_profiles
138! Remove inadvertent write-statement
139! Bugfix, large-scale forcing is still not implemented for passive scalars
[1919]140!
[1958]141! 1957 2016-07-07 10:43:48Z suehring
142! flight module added
143!
[1921]144! 1920 2016-05-30 10:50:15Z suehring
145! Initialize us with very small number to avoid segmentation fault during
146! calculation of Obukhov length
147!
[1919]148! 1918 2016-05-27 14:35:57Z raasch
149! intermediate_timestep_count is set 0 instead 1 for first call of pres,
150! bugfix: initialization of local sum arrays are moved to the beginning of the
151!         routine because otherwise results from pres are overwritten
152!
[1917]153! 1914 2016-05-26 14:44:07Z witha
154! Added initialization of the wind turbine model
155!
[1879]156! 1878 2016-04-19 12:30:36Z hellstea
157! The zeroth element of weight_pres removed as unnecessary
158!
[1851]159! 1849 2016-04-08 11:33:18Z hoffmann
[1849]160! Adapted for modularization of microphysics.
161! precipitation_amount, precipitation_rate, prr moved to arrays_3d.
[1852]162! Initialization of nc_1d, nr_1d, pt_1d, qc_1d, qr_1d, q_1d moved to
[1849]163! microphysics_init.
164!
[1846]165! 1845 2016-04-08 08:29:13Z raasch
166! nzb_2d replaced by nzb_u|v_inner
[1914]167!
[1834]168! 1833 2016-04-07 14:23:03Z raasch
169! initialization of spectra quantities moved to spectra_mod
170!
[1832]171! 1831 2016-04-07 13:15:51Z hoffmann
172! turbulence renamed collision_turbulence
173!
[1827]174! 1826 2016-04-07 12:01:39Z maronga
175! Renamed radiation calls.
176! Renamed canopy model calls.
177!
[1823]178! 1822 2016-04-07 07:49:42Z hoffmann
179! icloud_scheme replaced by microphysics_*
[1914]180!
[1818]181! 1817 2016-04-06 15:44:20Z maronga
182! Renamed lsm calls.
183!
[1816]184! 1815 2016-04-06 13:49:59Z raasch
185! zero-settings for velocities inside topography re-activated (was deactivated
186! in r1762)
187!
[1789]188! 1788 2016-03-10 11:01:04Z maronga
189! Added z0q.
190! Syntax layout improved.
191!
[1784]192! 1783 2016-03-06 18:36:17Z raasch
193! netcdf module name changed + related changes
194!
[1765]195! 1764 2016-02-28 12:45:19Z raasch
196! bugfix: increase size of volume_flow_area_l and volume_flow_initial_l by 1
197!
[1763]198! 1762 2016-02-25 12:31:13Z hellstea
199! Introduction of nested domain feature
200!
[1739]201! 1738 2015-12-18 13:56:05Z raasch
202! calculate mean surface level height for each statistic region
203!
[1735]204! 1734 2015-12-02 12:17:12Z raasch
205! no initial disturbances in case that the disturbance energy limit has been
206! set zero
207!
[1708]208! 1707 2015-11-02 15:24:52Z maronga
209! Bugfix: transfer of Richardson number from 1D model to Obukhov length caused
210! devision by zero in neutral stratification
211!
[1692]212! 1691 2015-10-26 16:17:44Z maronga
213! Call to init_surface_layer added. rif is replaced by ol and zeta.
214!
[1683]215! 1682 2015-10-07 23:56:08Z knoop
216! Code annotations made doxygen readable
217!
[1616]218! 1615 2015-07-08 18:49:19Z suehring
219! Enable turbulent inflow for passive_scalar and humidity
220!
[1586]221! 1585 2015-04-30 07:05:52Z maronga
222! Initialization of radiation code is now done after LSM initializtion
223!
[1576]224! 1575 2015-03-27 09:56:27Z raasch
225! adjustments for psolver-queries
226!
[1552]227! 1551 2015-03-03 14:18:16Z maronga
[1817]228! Allocation of land surface arrays is now done in the subroutine lsm_init_arrays,
[1552]229! which is part of land_surface_model.
230!
[1508]231! 1507 2014-12-10 12:14:18Z suehring
232! Bugfix: set horizontal velocity components to zero inside topography
233!
[1497]234! 1496 2014-12-02 17:25:50Z maronga
235! Added initialization of the land surface and radiation schemes
236!
[1485]237! 1484 2014-10-21 10:53:05Z kanani
[1484]238! Changes due to new module structure of the plant canopy model:
[1508]239! canopy-related initialization (e.g. lad and canopy_heat_flux) moved to new
240! subroutine init_plant_canopy within the module plant_canopy_model_mod,
241! call of subroutine init_plant_canopy added.
[1341]242!
[1432]243! 1431 2014-07-15 14:47:17Z suehring
244! var_d added, in order to normalize spectra.
245!
[1430]246! 1429 2014-07-15 12:53:45Z knoop
247! Ensemble run capability added to parallel random number generator
248!
[1412]249! 1411 2014-05-16 18:01:51Z suehring
250! Initial horizontal velocity profiles were not set to zero at the first vertical
251! grid level in case of non-cyclic lateral boundary conditions.
252!
[1407]253! 1406 2014-05-16 13:47:01Z raasch
254! bugfix: setting of initial velocities at k=1 to zero not in case of a
255! no-slip boundary condition for uv
256!
[1403]257! 1402 2014-05-09 14:25:13Z raasch
258! location messages modified
259!
[1401]260! 1400 2014-05-09 14:03:54Z knoop
261! Parallel random number generator added
262!
[1385]263! 1384 2014-05-02 14:31:06Z raasch
264! location messages added
265!
[1362]266! 1361 2014-04-16 15:17:48Z hoffmann
267! tend_* removed
268! Bugfix: w_subs is not allocated anymore if it is already allocated
269!
[1360]270! 1359 2014-04-11 17:15:14Z hoffmann
271! module lpm_init_mod added to use statements, because lpm_init has become a
272! module
273!
[1354]274! 1353 2014-04-08 15:21:23Z heinze
275! REAL constants provided with KIND-attribute
276!
[1341]277! 1340 2014-03-25 19:45:13Z kanani
278! REAL constants defined as wp-kind
279!
[1323]280! 1322 2014-03-20 16:38:49Z raasch
281! REAL constants defined as wp-kind
282! module interfaces removed
283!
[1321]284! 1320 2014-03-20 08:40:49Z raasch
285! ONLY-attribute added to USE-statements,
286! kind-parameters added to all INTEGER and REAL declaration statements,
287! kinds are defined in new module kinds,
288! revision history before 2012 removed,
289! comment fields (!:) to be used for variable explanations added to
290! all variable declaration statements
291!
[1317]292! 1316 2014-03-17 07:44:59Z heinze
293! Bugfix: allocation of w_subs
294!
[1300]295! 1299 2014-03-06 13:15:21Z heinze
296! Allocate w_subs due to extension of large scale subsidence in combination
297! with large scale forcing data (LSF_DATA)
298!
[1242]299! 1241 2013-10-30 11:36:58Z heinze
300! Overwrite initial profiles in case of nudging
301! Inititialize shf and qsws in case of large_scale_forcing
302!
[1222]303! 1221 2013-09-10 08:59:13Z raasch
304! +rflags_s_inner in copyin statement, use copyin for most arrays instead of
305! copy
306!
[1213]307! 1212 2013-08-15 08:46:27Z raasch
308! array tri is allocated and included in data copy statement
309!
[1196]310! 1195 2013-07-01 12:27:57Z heinze
311! Bugfix: move allocation of ref_state to parin.f90 and read_var_list.f90
312!
[1182]313! 1179 2013-06-14 05:57:58Z raasch
314! allocate and set ref_state to be used in buoyancy terms
315!
[1172]316! 1171 2013-05-30 11:27:45Z raasch
317! diss array is allocated with full size if accelerator boards are used
318!
[1160]319! 1159 2013-05-21 11:58:22Z fricke
320! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir
321!
[1154]322! 1153 2013-05-10 14:33:08Z raasch
323! diss array is allocated with dummy elements even if it is not needed
[1171]324! (required by PGI 13.4 / CUDA 5.0)
[1154]325!
[1116]326! 1115 2013-03-26 18:16:16Z hoffmann
327! unused variables removed
328!
[1114]329! 1113 2013-03-10 02:48:14Z raasch
330! openACC directive modified
331!
[1112]332! 1111 2013-03-08 23:54:10Z raasch
333! openACC directives added for pres
334! array diss allocated only if required
335!
[1093]336! 1092 2013-02-02 11:24:22Z raasch
337! unused variables removed
338!
[1066]339! 1065 2012-11-22 17:42:36Z hoffmann
340! allocation of diss (dissipation rate) in case of turbulence = .TRUE. added
341!
[1054]342! 1053 2012-11-13 17:11:03Z hoffmann
[1053]343! allocation and initialisation of necessary data arrays for the two-moment
344! cloud physics scheme the two new prognostic equations (nr, qr):
345! +dr, lambda_r, mu_r, sed_*, xr, *s, *sws, *swst, *, *_p, t*_m, *_1, *_2, *_3,
346! +tend_*, prr
[979]347!
[1037]348! 1036 2012-10-22 13:43:42Z raasch
349! code put under GPL (PALM 3.9)
350!
[1033]351! 1032 2012-10-21 13:03:21Z letzel
352! save memory by not allocating pt_2 in case of neutral = .T.
353!
[1026]354! 1025 2012-10-07 16:04:41Z letzel
355! bugfix: swap indices of mask for ghost boundaries
356!
[1017]357! 1015 2012-09-27 09:23:24Z raasch
358! mask is set to zero for ghost boundaries
359!
[1011]360! 1010 2012-09-20 07:59:54Z raasch
361! cpp switch __nopointer added for pointer free version
362!
[1004]363! 1003 2012-09-14 14:35:53Z raasch
364! nxra,nyna, nzta replaced ny nxr, nyn, nzt
365!
[1002]366! 1001 2012-09-13 14:08:46Z raasch
367! all actions concerning leapfrog scheme removed
368!
[997]369! 996 2012-09-07 10:41:47Z raasch
370! little reformatting
371!
[979]372! 978 2012-08-09 08:28:32Z fricke
[978]373! outflow damping layer removed
374! roughness length for scalar quantites z0h added
375! damping zone for the potential temperatur in case of non-cyclic lateral
376! boundaries added
377! initialization of ptdf_x, ptdf_y
378! initialization of c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l
[708]379!
[850]380! 849 2012-03-15 10:35:09Z raasch
381! init_particles renamed lpm_init
382!
[826]383! 825 2012-02-19 03:03:44Z raasch
384! wang_collision_kernel renamed wang_kernel
385!
[1]386! Revision 1.1  1998/03/09 16:22:22  raasch
387! Initial revision
388!
389!
390! Description:
391! ------------
[1682]392!> Allocation of arrays and initialization of the 3D model via
393!> a) pre-run the 1D model
394!> or
395!> b) pre-set constant linear profiles
396!> or
397!> c) read values of a previous run
[1]398!------------------------------------------------------------------------------!
[1682]399 SUBROUTINE init_3d_model
400 
[1]401
[667]402    USE advec_ws
[1320]403
[1]404    USE arrays_3d
[1849]405
[2696]406#if defined( __chem )
407    USE chemistry_model_mod,                                                   &
408        ONLY:  chem_emissions
409#endif
410
[2037]411    USE cloud_parameters,                                                      &
412        ONLY:  cp, l_v, r_d
413
[1320]414    USE constants,                                                             &
415        ONLY:  pi
416   
[1]417    USE control_parameters
[1320]418   
[1957]419    USE flight_mod,                                                            &
420        ONLY:  flight_init
421   
[1320]422    USE grid_variables,                                                        &
[2037]423        ONLY:  dx, dy, ddx2_mg, ddy2_mg
[1320]424   
[1]425    USE indices
[1359]426
[1429]427    USE lpm_init_mod,                                                          &
[1359]428        ONLY:  lpm_init
[1320]429   
430    USE kinds
[1496]431
432    USE land_surface_model_mod,                                                &
[2232]433        ONLY:  lsm_init, lsm_init_arrays
[1496]434 
[2320]435    USE lsf_nudging_mod,                                                       &
[2696]436        ONLY:  lsf_init, ls_forcing_surf, nudge_init
[1849]437
438    USE microphysics_mod,                                                      &
439        ONLY:  collision_turbulence, microphysics_init
440
[2338]441    USE model_1d_mod,                                                          &
442        ONLY:  e1d, init_1d_model, kh1d, km1d, l1d, rif1d, u1d, us1d, usws1d,  &
443               v1d, vsws1d 
444
[1783]445    USE netcdf_interface,                                                      &
446        ONLY:  dots_max, dots_num
[2696]447
448    USE netcdf_data_input_mod,                                                  &
449        ONLY:  init_3d, netcdf_data_input_interpolate, netcdf_data_input_init_3d
[1320]450   
451    USE particle_attributes,                                                   &
452        ONLY:  particle_advection, use_sgs_for_particles, wang_kernel
453   
[1]454    USE pegrid
[1320]455   
[1484]456    USE plant_canopy_model_mod,                                                &
[1826]457        ONLY:  pcm_init, plant_canopy
[1496]458
459    USE radiation_model_mod,                                                   &
[2696]460        ONLY:  radiation_init, radiation, radiation_control, radiation_scheme, &
461               read_svf_on_init,                                               &
462               write_svf_on_init, radiation_calc_svf, radiation_write_svf,     &
463               radiation_interaction, radiation_interactions,                  &
464               radiation_interaction_init, radiation_read_svf
[1484]465   
[1320]466    USE random_function_mod 
467   
[1400]468    USE random_generator_parallel,                                             &
[2172]469        ONLY:  init_parallel_random_generator
[1400]470   
[1320]471    USE statistics,                                                            &
[1738]472        ONLY:  hom, hom_sum, mean_surface_level_height, pr_palm, rmask,        &
[1833]473               statistic_regions, sums, sums_divnew_l, sums_divold_l, sums_l,  &
[2277]474               sums_l_l, sums_wsts_bc_l, ts_value,                             &
[1833]475               weight_pres, weight_substep
[2259]476
477    USE synthetic_turbulence_generator_mod,                                    &
478        ONLY:  stg_init, use_synthetic_turbulence_generator
479
[1691]480    USE surface_layer_fluxes_mod,                                              &
481        ONLY:  init_surface_layer_fluxes
[2232]482
483    USE surface_mod,                                                           &
484        ONLY :  init_surface_arrays, init_surfaces, surf_def_h, surf_lsm_h,    &
[2698]485                surf_usm_h, get_topography_top_index_ji
[1691]486   
[2007]487    USE transpose_indices
[1]488
[2696]489    USE turbulence_closure_mod,                                                &
490        ONLY:  tcm_init_arrays, tcm_init
491
[2007]492    USE urban_surface_mod,                                                     &
[2696]493        ONLY:  usm_init_urban_surface, usm_allocate_surface
[2007]494
[2696]495    USE uv_exposure_model_mod,                                                 &
496        ONLY:  uvem_init, uvem_init_arrays
497
[1914]498    USE wind_turbine_model_mod,                                                &
[2564]499        ONLY:  wtm_init, wtm_init_arrays
[1914]500
[1]501    IMPLICIT NONE
502
[1682]503    INTEGER(iwp) ::  i             !<
504    INTEGER(iwp) ::  ind_array(1)  !<
505    INTEGER(iwp) ::  j             !<
506    INTEGER(iwp) ::  k             !<
[2232]507    INTEGER(iwp) ::  k_surf        !< surface level index
508    INTEGER(iwp) ::  m             !< index of surface element in surface data type
509    INTEGER(iwp) ::  sr            !< index of statistic region
[1]510
[1682]511    INTEGER(iwp), DIMENSION(:), ALLOCATABLE   ::  ngp_2dh_l  !<
[1]512
[1682]513    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_outer_l    !<
514    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_s_inner_l  !<
[1]515
[2037]516    REAL(wp)     ::  t_surface !< air temperature at the surface
517
518    REAL(wp), DIMENSION(:), ALLOCATABLE ::  p_hydrostatic !< hydrostatic pressure
519
520    INTEGER(iwp) ::  l       !< loop variable
521    INTEGER(iwp) ::  nzt_l   !< index of top PE boundary for multigrid level
522    REAL(wp) ::  dx_l !< grid spacing along x on different multigrid level
523    REAL(wp) ::  dy_l !< grid spacing along y on different multigrid level
524
[1764]525    REAL(wp), DIMENSION(1:3) ::  volume_flow_area_l     !<
526    REAL(wp), DIMENSION(1:3) ::  volume_flow_initial_l  !<
[1]527
[1738]528    REAL(wp), DIMENSION(:), ALLOCATABLE ::  mean_surface_level_height_l    !<
[1682]529    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner_l    !<
530    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner_tmp  !<
[1]531
[2550]532    INTEGER(iwp) ::  nz_u_shift   !<
533    INTEGER(iwp) ::  nz_v_shift   !<
534    INTEGER(iwp) ::  nz_w_shift   !<
535    INTEGER(iwp) ::  nz_s_shift   !<
536    INTEGER(iwp) ::  nz_u_shift_l !<
537    INTEGER(iwp) ::  nz_v_shift_l !<
538    INTEGER(iwp) ::  nz_w_shift_l !<
539    INTEGER(iwp) ::  nz_s_shift_l !<
[485]540
[1402]541    CALL location_message( 'allocating arrays', .FALSE. )
[1]542!
543!-- Allocate arrays
[1788]544    ALLOCATE( mean_surface_level_height(0:statistic_regions),                  &
545              mean_surface_level_height_l(0:statistic_regions),                &
546              ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions),    &
547              ngp_3d(0:statistic_regions),                                     &
548              ngp_3d_inner(0:statistic_regions),                               &
549              ngp_3d_inner_l(0:statistic_regions),                             &
550              ngp_3d_inner_tmp(0:statistic_regions),                           &
551              sums_divnew_l(0:statistic_regions),                              &
[1]552              sums_divold_l(0:statistic_regions) )
[1195]553    ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) )
[1788]554    ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions),                    &
555              ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions),                  &
556              ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions),                  &
557              ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions),                &
558              rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions),                  &
559              sums(nzb:nzt+1,pr_palm+max_pr_user),                             &
560              sums_l(nzb:nzt+1,pr_palm+max_pr_user,0:threads_per_task-1),      &
561              sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1),    &
562              sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions),                   &
[394]563              ts_value(dots_max,0:statistic_regions) )
[978]564    ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) )
[1]565
[1788]566    ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr),                                    &
567              p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                &
[1010]568              tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
569
570#if defined( __nopointer )
[2696]571    ALLOCATE( pt(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                               &
[1788]572              pt_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
573              u(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                &
574              u_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
575              v(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                &
576              v_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
577              w(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                &
578              w_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
579              tpt_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                            &
580              tu_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
581              tv_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
[1010]582              tw_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
583#else
[2696]584    ALLOCATE( pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
[1788]585              pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
586              u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
587              u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
588              u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
589              v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
590              v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
591              v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
592              w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
593              w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                              &
[667]594              w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1788]595    IF (  .NOT.  neutral )  THEN
[1032]596       ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
597    ENDIF
[1010]598#endif
599
[673]600!
[707]601!-- Following array is required for perturbation pressure within the iterative
602!-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds
603!-- the weighted average of the substeps and cannot be used in the Poisson
604!-- solver.
605    IF ( psolver == 'sor' )  THEN
606       ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1575]607    ELSEIF ( psolver(1:9) == 'multigrid' )  THEN
[707]608!
609!--    For performance reasons, multigrid is using one ghost layer only
610       ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
[673]611    ENDIF
[1]612
[1111]613!
614!-- Array for storing constant coeffficients of the tridiagonal solver
615    IF ( psolver == 'poisfft' )  THEN
[1212]616       ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) )
[1111]617       ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) )
618    ENDIF
619
[1960]620    IF ( humidity )  THEN
[1]621!
[1960]622!--    3D-humidity
[1010]623#if defined( __nopointer )
[1788]624       ALLOCATE( q(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
625                 q_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
[1010]626                 tq_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
627#else
[1788]628       ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
629                 q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
[667]630                 q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1010]631#endif
[1]632
633!
[1960]634!--    3D-arrays needed for humidity
[75]635       IF ( humidity )  THEN
[1010]636#if defined( __nopointer )
637          ALLOCATE( vpt(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
638#else
[667]639          ALLOCATE( vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1010]640#endif
[1]641
[1788]642          IF ( cloud_physics )  THEN
[1]643!
644!--          Liquid water content
[1010]645#if defined( __nopointer )
646             ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
647#else
[667]648             ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1010]649#endif
[1053]650
651!
[1822]652!--          3D-cloud water content
[2292]653             IF ( .NOT. microphysics_morrison )  THEN
[1053]654#if defined( __nopointer )
[2292]655                ALLOCATE( qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1053]656#else
[2292]657                ALLOCATE( qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1053]658#endif
[2292]659             ENDIF
[1822]660!
[2292]661!--          Precipitation amount and rate (only needed if output is switched)
662             ALLOCATE( precipitation_amount(nysg:nyng,nxlg:nxrg),              &
663                       precipitation_rate(nysg:nyng,nxlg:nxrg) )
664
665!
[1822]666!--          3d-precipitation rate
667             ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1115]668
[2292]669             IF ( microphysics_morrison )  THEN
670!
671!--             3D-cloud drop water content, cloud drop concentration arrays
672#if defined( __nopointer )
673                ALLOCATE( nc(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                &
674                          nc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
675                          qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                &
676                          qc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
[2350]677                          tnc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),             & 
[2292]678                          tqc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
679#else
680                ALLOCATE( nc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
681                          nc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
682                          nc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
683                          qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
684                          qc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
685                          qc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
686#endif
687             ENDIF
688
[1822]689             IF ( microphysics_seifert )  THEN
[1053]690!
[1822]691!--             3D-rain water content, rain drop concentration arrays
[1115]692#if defined( __nopointer )
[1822]693                ALLOCATE( nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                &
694                          nr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
695                          qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                &
696                          qr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
697                          tnr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),             &
698                          tqr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1115]699#else
[1822]700                ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
701                          nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
702                          nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
703                          qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
704                          qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),              &
705                          qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1115]706#endif
[1822]707             ENDIF
[1053]708
[1]709          ENDIF
710
711          IF ( cloud_droplets )  THEN
712!
[1010]713!--          Liquid water content, change in liquid water content
714#if defined( __nopointer )
[1788]715             ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
[1010]716                        ql_c(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
717#else
[1788]718             ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                   &
[1010]719                        ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
720#endif
721!
722!--          Real volume of particles (with weighting), volume of particles
[1788]723             ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                   &
[667]724                        ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[1]725          ENDIF
726
727       ENDIF
728
729    ENDIF
[1960]730   
731   
732    IF ( passive_scalar )  THEN
[1]733
[1960]734!
735!--    3D scalar arrays
736#if defined( __nopointer )
737       ALLOCATE( s(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
738                 s_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
739                 ts_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
740#else
741       ALLOCATE( s_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
742                 s_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
743                 s_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
744#endif
745    ENDIF
746
[94]747    IF ( ocean )  THEN
[1010]748#if defined( __nopointer )
[1788]749       ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
[2031]750                 rho_ocean(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
[1788]751                 sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                            &
752                 sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
[1010]753                 tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
754#else
[1788]755       ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                        &
756                 rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                         &
757                 sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
758                 sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
[667]759                 sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
[388]760       prho => prho_1
[2031]761       rho_ocean  => rho_1  ! routines calc_mean_profile and diffusion_e require
[388]762                      ! density to be apointer
[1010]763#endif
[94]764    ENDIF
765
[1]766!
[2037]767!-- Allocation of anelastic and Boussinesq approximation specific arrays
768    ALLOCATE( p_hydrostatic(nzb:nzt+1) )
769    ALLOCATE( rho_air(nzb:nzt+1) )
770    ALLOCATE( rho_air_zw(nzb:nzt+1) )
771    ALLOCATE( drho_air(nzb:nzt+1) )
772    ALLOCATE( drho_air_zw(nzb:nzt+1) )
773
774!
775!-- Density profile calculation for anelastic approximation
[2252]776    t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**( r_d / cp )
[2037]777    IF ( TRIM( approximation ) == 'anelastic' ) THEN
778       DO  k = nzb, nzt+1
779          p_hydrostatic(k)    = surface_pressure * 100.0_wp *                  &
780                                ( 1 - ( g * zu(k) ) / ( cp * t_surface )       &
781                                )**( cp / r_d )
782          rho_air(k)          = ( p_hydrostatic(k) *                           &
783                                  ( 100000.0_wp / p_hydrostatic(k)             &
784                                  )**( r_d / cp )                              &
785                                ) / ( r_d * pt_init(k) )
786       ENDDO
787       DO  k = nzb, nzt
788          rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) )
789       ENDDO
790       rho_air_zw(nzt+1)  = rho_air_zw(nzt)                                    &
791                            + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt)  )
792    ELSE
[2252]793       DO  k = nzb, nzt+1
794          p_hydrostatic(k)    = surface_pressure * 100.0_wp *                  &
795                                ( 1 - ( g * zu(nzb) ) / ( cp * t_surface )       &
796                                )**( cp / r_d )
797          rho_air(k)          = ( p_hydrostatic(k) *                           &
798                                  ( 100000.0_wp / p_hydrostatic(k)             &
799                                  )**( r_d / cp )                              &
800                                ) / ( r_d * pt_init(nzb) )
801       ENDDO
802       DO  k = nzb, nzt
803          rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) )
804       ENDDO
805       rho_air_zw(nzt+1)  = rho_air_zw(nzt)                                    &
806                            + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt)  )
[2037]807    ENDIF
[2696]808!
[2037]809!-- compute the inverse density array in order to avoid expencive divisions
810    drho_air    = 1.0_wp / rho_air
811    drho_air_zw = 1.0_wp / rho_air_zw
812
813!
814!-- Allocation of flux conversion arrays
815    ALLOCATE( heatflux_input_conversion(nzb:nzt+1) )
816    ALLOCATE( waterflux_input_conversion(nzb:nzt+1) )
817    ALLOCATE( momentumflux_input_conversion(nzb:nzt+1) )
818    ALLOCATE( heatflux_output_conversion(nzb:nzt+1) )
819    ALLOCATE( waterflux_output_conversion(nzb:nzt+1) )
820    ALLOCATE( momentumflux_output_conversion(nzb:nzt+1) )
821
822!
823!-- calculate flux conversion factors according to approximation and in-/output mode
824    DO  k = nzb, nzt+1
825
826        IF ( TRIM( flux_input_mode ) == 'kinematic' )  THEN
827            heatflux_input_conversion(k)      = rho_air_zw(k)
828            waterflux_input_conversion(k)     = rho_air_zw(k)
829            momentumflux_input_conversion(k)  = rho_air_zw(k)
830        ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN
831            heatflux_input_conversion(k)      = 1.0_wp / cp
832            waterflux_input_conversion(k)     = 1.0_wp / l_v
833            momentumflux_input_conversion(k)  = 1.0_wp
834        ENDIF
835
836        IF ( TRIM( flux_output_mode ) == 'kinematic' )  THEN
837            heatflux_output_conversion(k)     = drho_air_zw(k)
838            waterflux_output_conversion(k)    = drho_air_zw(k)
839            momentumflux_output_conversion(k) = drho_air_zw(k)
840        ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN
841            heatflux_output_conversion(k)     = cp
842            waterflux_output_conversion(k)    = l_v
843            momentumflux_output_conversion(k) = 1.0_wp
844        ENDIF
845
846        IF ( .NOT. humidity ) THEN
847            waterflux_input_conversion(k)  = 1.0_wp
848            waterflux_output_conversion(k) = 1.0_wp
849        ENDIF
850
851    ENDDO
852
853!
854!-- In case of multigrid method, compute grid lengths and grid factors for the
855!-- grid levels with respective density on each grid
856    IF ( psolver(1:9) == 'multigrid' )  THEN
857
858       ALLOCATE( ddx2_mg(maximum_grid_level) )
859       ALLOCATE( ddy2_mg(maximum_grid_level) )
860       ALLOCATE( dzu_mg(nzb+1:nzt+1,maximum_grid_level) )
861       ALLOCATE( dzw_mg(nzb+1:nzt+1,maximum_grid_level) )
862       ALLOCATE( f1_mg(nzb+1:nzt,maximum_grid_level) )
863       ALLOCATE( f2_mg(nzb+1:nzt,maximum_grid_level) )
864       ALLOCATE( f3_mg(nzb+1:nzt,maximum_grid_level) )
865       ALLOCATE( rho_air_mg(nzb:nzt+1,maximum_grid_level) )
866       ALLOCATE( rho_air_zw_mg(nzb:nzt+1,maximum_grid_level) )
867
868       dzu_mg(:,maximum_grid_level) = dzu
869       rho_air_mg(:,maximum_grid_level) = rho_air
870!       
871!--    Next line to ensure an equally spaced grid.
872       dzu_mg(1,maximum_grid_level) = dzu(2)
873       rho_air_mg(nzb,maximum_grid_level) = rho_air(nzb) +                     &
874                                             (rho_air(nzb) - rho_air(nzb+1))
875
876       dzw_mg(:,maximum_grid_level) = dzw
877       rho_air_zw_mg(:,maximum_grid_level) = rho_air_zw
878       nzt_l = nzt
879       DO  l = maximum_grid_level-1, 1, -1
880           dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1)
881           dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1)
882           rho_air_mg(nzb,l)    = rho_air_mg(nzb,l+1) + (rho_air_mg(nzb,l+1) - rho_air_mg(nzb+1,l+1))
883           rho_air_zw_mg(nzb,l) = rho_air_zw_mg(nzb,l+1) + (rho_air_zw_mg(nzb,l+1) - rho_air_zw_mg(nzb+1,l+1))
884           rho_air_mg(nzb+1,l)    = rho_air_mg(nzb+1,l+1)
885           rho_air_zw_mg(nzb+1,l) = rho_air_zw_mg(nzb+1,l+1)
886           nzt_l = nzt_l / 2
887           DO  k = 2, nzt_l+1
888              dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1)
889              dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1)
890              rho_air_mg(k,l)    = rho_air_mg(2*k-1,l+1)
891              rho_air_zw_mg(k,l) = rho_air_zw_mg(2*k-1,l+1)
892           ENDDO
893       ENDDO
894
895       nzt_l = nzt
896       dx_l  = dx
897       dy_l  = dy
898       DO  l = maximum_grid_level, 1, -1
899          ddx2_mg(l) = 1.0_wp / dx_l**2
900          ddy2_mg(l) = 1.0_wp / dy_l**2
901          DO  k = nzb+1, nzt_l
902             f2_mg(k,l) = rho_air_zw_mg(k,l) / ( dzu_mg(k+1,l) * dzw_mg(k,l) )
903             f3_mg(k,l) = rho_air_zw_mg(k-1,l) / ( dzu_mg(k,l)   * dzw_mg(k,l) )
904             f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) &
905                          * rho_air_mg(k,l) + f2_mg(k,l) + f3_mg(k,l)
906          ENDDO
907          nzt_l = nzt_l / 2
908          dx_l  = dx_l * 2.0_wp
909          dy_l  = dy_l * 2.0_wp
910       ENDDO
911
912    ENDIF
913
914!
[1299]915!-- 1D-array for large scale subsidence velocity
[1361]916    IF ( .NOT. ALLOCATED( w_subs ) )  THEN
917       ALLOCATE ( w_subs(nzb:nzt+1) )
918       w_subs = 0.0_wp
919    ENDIF
[1299]920
921!
[106]922!-- Arrays to store velocity data from t-dt and the phase speeds which
923!-- are needed for radiation boundary conditions
[73]924    IF ( outflow_l )  THEN
[1788]925       ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2),                               &
926                 v_m_l(nzb:nzt+1,nysg:nyng,0:1),                               &
[667]927                 w_m_l(nzb:nzt+1,nysg:nyng,0:1) )
[73]928    ENDIF
929    IF ( outflow_r )  THEN
[1788]930       ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
931                 v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
[667]932                 w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) )
[73]933    ENDIF
[106]934    IF ( outflow_l  .OR.  outflow_r )  THEN
[1788]935       ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng),           &
[667]936                 c_w(nzb:nzt+1,nysg:nyng) )
[106]937    ENDIF
[73]938    IF ( outflow_s )  THEN
[1788]939       ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg),                               &
940                 v_m_s(nzb:nzt+1,1:2,nxlg:nxrg),                               &
[667]941                 w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) )
[73]942    ENDIF
943    IF ( outflow_n )  THEN
[1788]944       ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
945                 v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
[667]946                 w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) )
[73]947    ENDIF
[106]948    IF ( outflow_s  .OR.  outflow_n )  THEN
[1788]949       ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg),           &
[667]950                 c_w(nzb:nzt+1,nxlg:nxrg) )
[106]951    ENDIF
[996]952    IF ( outflow_l  .OR.  outflow_r  .OR.  outflow_s  .OR.  outflow_n )  THEN
[978]953       ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) )                   
954       ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) )
955    ENDIF
[73]956
[978]957
[1010]958#if ! defined( __nopointer )
[73]959!
[1]960!-- Initial assignment of the pointers
[1032]961    IF ( .NOT. neutral )  THEN
962       pt => pt_1;  pt_p => pt_2;  tpt_m => pt_3
963    ELSE
964       pt => pt_1;  pt_p => pt_1;  tpt_m => pt_3
965    ENDIF
[1001]966    u  => u_1;   u_p  => u_2;   tu_m  => u_3
967    v  => v_1;   v_p  => v_2;   tv_m  => v_3
968    w  => w_1;   w_p  => w_2;   tw_m  => w_3
[1]969
[1960]970    IF ( humidity )  THEN
[1001]971       q => q_1;  q_p => q_2;  tq_m => q_3
[1053]972       IF ( humidity )  THEN
973          vpt  => vpt_1   
974          IF ( cloud_physics )  THEN
975             ql => ql_1
[2292]976             IF ( .NOT. microphysics_morrison )  THEN
977                qc => qc_1
978             ENDIF
979             IF ( microphysics_morrison )  THEN
980                qc => qc_1;  qc_p  => qc_2;  tqc_m  => qc_3
981                nc => nc_1;  nc_p  => nc_2;  tnc_m  => nc_3
982             ENDIF
[1822]983             IF ( microphysics_seifert )  THEN
984                qr => qr_1;  qr_p  => qr_2;  tqr_m  => qr_3
985                nr => nr_1;  nr_p  => nr_2;  tnr_m  => nr_3
[1053]986             ENDIF
987          ENDIF
988       ENDIF
[1001]989       IF ( cloud_droplets )  THEN
990          ql   => ql_1
991          ql_c => ql_2
[1]992       ENDIF
[1001]993    ENDIF
[1960]994   
995    IF ( passive_scalar )  THEN
996       s => s_1;  s_p => s_2;  ts_m => s_3
997    ENDIF   
[1]998
[1001]999    IF ( ocean )  THEN
1000       sa => sa_1;  sa_p => sa_2;  tsa_m => sa_3
1001    ENDIF
[1010]1002#endif
[1]1003!
[2696]1004!-- Initialize arrays for turbulence closure
1005    CALL tcm_init_arrays
1006!
1007!-- Initialize surface arrays
[2232]1008    CALL init_surface_arrays
1009!
[1551]1010!-- Allocate land surface model arrays
1011    IF ( land_surface )  THEN
[1817]1012       CALL lsm_init_arrays
[1551]1013    ENDIF
1014
1015!
[1914]1016!-- Allocate wind turbine model arrays
1017    IF ( wind_turbine )  THEN
1018       CALL wtm_init_arrays
1019    ENDIF
[1957]1020   
1021!
1022!-- Initialize virtual flight measurements
1023    IF ( virtual_flight )  THEN
1024       CALL flight_init
1025    ENDIF
[1914]1026
1027!
[2696]1028!-- Read uv exposure input data
1029    IF ( uv_exposure )  THEN
1030       CALL uvem_init
[2320]1031    ENDIF
1032!
[2696]1033!-- Allocate uv exposure arrays
1034    IF ( uv_exposure )  THEN
1035       CALL uvem_init_arrays
[2320]1036    ENDIF
1037
1038!
[2705]1039!-- Initialize nudging if required
1040    IF ( nudging )  THEN
1041       CALL nudge_init
1042    ENDIF
1043
1044!
1045!-- Initialize reading of large scale forcing from external file - if required
1046    IF ( large_scale_forcing  .OR.  forcing )  THEN
1047       CALL lsf_init
1048    ENDIF
1049
1050!
[709]1051!-- Allocate arrays containing the RK coefficient for calculation of
1052!-- perturbation pressure and turbulent fluxes. At this point values are
1053!-- set for pressure calculation during initialization (where no timestep
1054!-- is done). Further below the values needed within the timestep scheme
1055!-- will be set.
[1788]1056    ALLOCATE( weight_substep(1:intermediate_timestep_count_max),               &
[1878]1057              weight_pres(1:intermediate_timestep_count_max) )
[1340]1058    weight_substep = 1.0_wp
1059    weight_pres    = 1.0_wp
[1918]1060    intermediate_timestep_count = 0  ! needed when simulated_time = 0.0
[673]1061       
[1402]1062    CALL location_message( 'finished', .TRUE. )
[1918]1063
[673]1064!
[1918]1065!-- Initialize local summation arrays for routine flow_statistics.
1066!-- This is necessary because they may not yet have been initialized when they
1067!-- are called from flow_statistics (or - depending on the chosen model run -
1068!-- are never initialized)
1069    sums_divnew_l      = 0.0_wp
1070    sums_divold_l      = 0.0_wp
1071    sums_l_l           = 0.0_wp
1072    sums_wsts_bc_l     = 0.0_wp
1073
[2696]1074
1075
[1918]1076!
[1]1077!-- Initialize model variables
[1788]1078    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.            &
[328]1079         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
[1]1080!
[2696]1081!--    Initialization with provided input data derived from larger-scale model
1082       IF ( INDEX( initializing_actions, 'inifor' ) /= 0 )  THEN
1083          CALL location_message( 'initializing with INIFOR', .FALSE. )
1084!
1085!--       Read initial 1D profiles from NetCDF file if available.
1086!--       At the moment, only u, v, w, pt and q are provided.
1087          CALL netcdf_data_input_init_3d
1088!
1089!--       Please note, at the moment INIFOR assumes only an equidistant vertical
1090!--       grid. In case of vertical grid stretching, input of inital data
1091!--       need to be inter- and/or extrapolated.
1092!--       Therefore, check if zu grid on file is identical to numeric zw grid.
1093!--       Please note 
1094          IF ( ANY( zu(1:nzt+1) /= init_3d%zu_atmos(1:init_3d%nzu) ) )  THEN
[1384]1095
[2696]1096             CALL netcdf_data_input_interpolate( init_3d%u_init(nzb+1:nzt+1),  &
1097                                                 zu(nzb+1:nzt+1),              &
1098                                                 init_3d%zu_atmos )
1099             CALL netcdf_data_input_interpolate( init_3d%v_init(nzb+1:nzt+1),  &
1100                                                 zu(nzb+1:nzt+1),              &
1101                                                 init_3d%zu_atmos )
1102!              CALL netcdf_data_input_interpolate( init_3d%w_init(nzb+1:nzt),    &
1103!                                                  zw(nzb+1:nzt),                &
1104!                                                  init_3d%zw_atmos )
1105             IF ( .NOT. neutral )                                              &
1106                CALL netcdf_data_input_interpolate(                            &
1107                                             init_3d%pt_init(nzb+1:nzt+1),     &
1108                                             zu(nzb+1:nzt+1),                  &
1109                                             init_3d%zu_atmos )
1110             IF ( humidity )                                                   &
1111                CALL netcdf_data_input_interpolate(                            &
1112                                             init_3d%q_init(nzb+1:nzt+1),      &
1113                                             zu(nzb+1:nzt+1),                  &
1114                                             init_3d%zu_atmos )
1115          ENDIF
1116
1117          u_init = init_3d%u_init
1118          v_init = init_3d%v_init   
1119          IF( .NOT. neutral )  pt_init = init_3d%pt_init
1120          IF( humidity      )  q_init  = init_3d%q_init
1121
1122!
1123!--       Please note, Inifor provides data from nzb+1 to nzt+1.
1124!--       Initialize pt and q with Neumann condition at nzb.
1125          IF( .NOT. neutral )  pt_init(nzb) = pt_init(nzb+1)
1126          IF( humidity      )  q_init(nzb)  = q_init(nzb+1)
1127          DO  i = nxlg, nxrg
1128             DO  j = nysg, nyng
1129                u(:,j,i) = u_init(:)
1130                v(:,j,i) = v_init(:)
1131                IF( .NOT. neutral )  pt(:,j,i) = pt_init(:)
1132                IF( humidity      )  q(:,j,i)  = q_init(:)
1133             ENDDO
1134          ENDDO
1135!
1136!--       MS: What about the geostrophic wind profiles? Actually these
1137!--           are not identical to the initial wind profiles in this case.
1138!--           This need to be further revised.
1139!           ug(:) = u_init(:)
1140!           vg(:) = v_init(:)
1141!
1142!--       Set inital w to 0
1143          w = 0.0_wp
1144!
1145!--       Initialize the remaining quantities
1146          IF ( humidity )  THEN
1147             IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1148                DO  i = nxlg, nxrg
1149                   DO  j = nysg, nyng
1150                      qc(:,j,i) = 0.0_wp
1151                      nc(:,j,i) = 0.0_wp
1152                   ENDDO
1153                ENDDO
1154             ENDIF
1155
1156             IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
1157                DO  i = nxlg, nxrg
1158                   DO  j = nysg, nyng
1159                      qr(:,j,i) = 0.0_wp
1160                      nr(:,j,i) = 0.0_wp
1161                   ENDDO
1162                ENDDO
1163             ENDIF
1164
1165          ENDIF
1166
1167          IF ( passive_scalar )  THEN
1168             DO  i = nxlg, nxrg
1169                DO  j = nysg, nyng
1170                   s(:,j,i) = s_init
1171                ENDDO
1172             ENDDO
1173          ENDIF
1174
1175          IF ( ocean )  THEN
1176             DO  i = nxlg, nxrg
1177                DO  j = nysg, nyng
1178                   sa(:,j,i) = sa_init
1179                ENDDO
1180             ENDDO
1181          ENDIF
1182
1183!
1184!--       Set velocity components at non-atmospheric / oceanic grid points to
1185!--       zero.
1186          u = MERGE( u, 0.0_wp, BTEST( wall_flags_0, 1 ) )
1187          v = MERGE( v, 0.0_wp, BTEST( wall_flags_0, 2 ) )
1188          w = MERGE( w, 0.0_wp, BTEST( wall_flags_0, 3 ) )
[2700]1189!
1190!--       Initialize surface variables, e.g. friction velocity, momentum
1191!--       fluxes, etc.
1192          CALL init_surfaces
[2696]1193
1194          CALL location_message( 'finished', .TRUE. )
1195!
1196!--    Initialization via computed 1D-model profiles
1197       ELSEIF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
1198
[1402]1199          CALL location_message( 'initializing with 1D model profiles', .FALSE. )
[1]1200!
1201!--       Use solutions of the 1D model as initial profiles,
1202!--       start 1D model
1203          CALL init_1d_model
1204!
1205!--       Transfer initial profiles to the arrays of the 3D model
[667]1206          DO  i = nxlg, nxrg
1207             DO  j = nysg, nyng
[1]1208                pt(:,j,i) = pt_init
1209                u(:,j,i)  = u1d
1210                v(:,j,i)  = v1d
1211             ENDDO
1212          ENDDO
1213
[1960]1214          IF ( humidity )  THEN
[667]1215             DO  i = nxlg, nxrg
1216                DO  j = nysg, nyng
[1]1217                   q(:,j,i) = q_init
1218                ENDDO
1219             ENDDO
[2292]1220             IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1221                DO  i = nxlg, nxrg
1222                   DO  j = nysg, nyng
1223                      qc(:,j,i) = 0.0_wp
1224                      nc(:,j,i) = 0.0_wp
1225                   ENDDO
1226                ENDDO
1227             ENDIF
[1822]1228             IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
[1053]1229                DO  i = nxlg, nxrg
1230                   DO  j = nysg, nyng
[1340]1231                      qr(:,j,i) = 0.0_wp
1232                      nr(:,j,i) = 0.0_wp
[1053]1233                   ENDDO
1234                ENDDO
1235             ENDIF
[1]1236          ENDIF
[2292]1237
[1960]1238          IF ( passive_scalar )  THEN
1239             DO  i = nxlg, nxrg
1240                DO  j = nysg, nyng
1241                   s(:,j,i) = s_init
1242                ENDDO
1243             ENDDO   
1244          ENDIF
[1]1245!
1246!--          Store initial profiles for output purposes etc.
[2696]1247          IF ( .NOT. constant_diffusion )  THEN
[1]1248             hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 )
1249          ENDIF
1250!
[2696]1251!--       Set velocities back to zero
1252          DO  i = nxlg, nxrg
1253             DO  j = nysg, nyng
1254                DO  k = nzb, nzt
1255                   u(k,j,i) = MERGE( u(k,j,i), 0.0_wp,                      &
1256                                     BTEST( wall_flags_0(k,j,i), 1 ) )
1257                   v(k,j,i) = MERGE( v(k,j,i), 0.0_wp,                      &
1258                                     BTEST( wall_flags_0(k,j,i), 2 ) )
[1]1259                ENDDO
1260             ENDDO
[2696]1261          ENDDO
1262         
[1]1263!
[2696]1264!--       WARNING: The extra boundary conditions set after running the
1265!--       -------  1D model impose an error on the divergence one layer
1266!--                below the topography; need to correct later
1267!--       ATTENTION: Provisional correction for Piacsek & Williams
1268!--       ---------  advection scheme: keep u and v zero one layer below
1269!--                  the topography.
1270          IF ( ibc_uv_b == 1 )  THEN
[667]1271!
[2696]1272!--          Neumann condition
1273             DO  i = nxl-1, nxr+1
1274                DO  j = nys-1, nyn+1
1275                   u(nzb,j,i) = u(nzb+1,j,i)
1276                   v(nzb,j,i) = v(nzb+1,j,i)
[1]1277                ENDDO
[2696]1278             ENDDO
[1]1279
1280          ENDIF
[2618]1281!
1282!--       Initialize surface variables, e.g. friction velocity, momentum
1283!--       fluxes, etc.
1284          CALL init_surfaces
[1]1285
[1402]1286          CALL location_message( 'finished', .TRUE. )
[1384]1287
[1788]1288       ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 )    &
[1]1289       THEN
[1241]1290
[1402]1291          CALL location_message( 'initializing with constant profiles', .FALSE. )
[1]1292!
[2259]1293!--       Overwrite initial profiles in case of synthetic turbulence generator
1294          IF( use_synthetic_turbulence_generator ) THEN
1295             CALL stg_init
1296          ENDIF
1297
1298!
[1]1299!--       Use constructed initial profiles (velocity constant with height,
1300!--       temperature profile with constant gradient)
[667]1301          DO  i = nxlg, nxrg
1302             DO  j = nysg, nyng
[1]1303                pt(:,j,i) = pt_init
1304                u(:,j,i)  = u_init
1305                v(:,j,i)  = v_init
1306             ENDDO
1307          ENDDO
[75]1308
[1]1309!
[292]1310!--       Set initial horizontal velocities at the lowest computational grid
1311!--       levels to zero in order to avoid too small time steps caused by the
1312!--       diffusion limit in the initial phase of a run (at k=1, dz/2 occurs
[1815]1313!--       in the limiting formula!).
1314          IF ( ibc_uv_b /= 1 )  THEN
1315             DO  i = nxlg, nxrg
1316                DO  j = nysg, nyng
[2232]1317                   DO  k = nzb, nzt
1318                      u(k,j,i) = MERGE( u(k,j,i), 0.0_wp,                      &
1319                                        BTEST( wall_flags_0(k,j,i), 20 ) )
1320                      v(k,j,i) = MERGE( v(k,j,i), 0.0_wp,                      &
1321                                        BTEST( wall_flags_0(k,j,i), 21 ) )
1322                   ENDDO
[1815]1323                ENDDO
1324             ENDDO
1325          ENDIF
[1]1326
[1960]1327          IF ( humidity )  THEN
[667]1328             DO  i = nxlg, nxrg
1329                DO  j = nysg, nyng
[1]1330                   q(:,j,i) = q_init
1331                ENDDO
1332             ENDDO
[2292]1333             IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1334                DO  i = nxlg, nxrg
1335                   DO  j = nysg, nyng
1336                      qc(:,j,i) = 0.0_wp
1337                      nc(:,j,i) = 0.0_wp
1338                   ENDDO
1339                ENDDO
1340             ENDIF
1341
[1822]1342             IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
1343                DO  i = nxlg, nxrg
1344                   DO  j = nysg, nyng
1345                      qr(:,j,i) = 0.0_wp
1346                      nr(:,j,i) = 0.0_wp
[1053]1347                   ENDDO
[1822]1348                ENDDO
[2292]1349             ENDIF
[1115]1350
[1]1351          ENDIF
[1960]1352         
1353          IF ( passive_scalar )  THEN
1354             DO  i = nxlg, nxrg
1355                DO  j = nysg, nyng
1356                   s(:,j,i) = s_init
1357                ENDDO
1358             ENDDO
1359          ENDIF
[1]1360
[94]1361          IF ( ocean )  THEN
[667]1362             DO  i = nxlg, nxrg
1363                DO  j = nysg, nyng
[94]1364                   sa(:,j,i) = sa_init
1365                ENDDO
1366             ENDDO
1367          ENDIF
[1920]1368!
[1]1369!--       Compute initial temperature field and other constants used in case
1370!--       of a sloping surface
1371          IF ( sloping_surface )  CALL init_slope
[2618]1372!
1373!--       Initialize surface variables, e.g. friction velocity, momentum
1374!--       fluxes, etc.
1375          CALL init_surfaces
[1]1376
[1402]1377          CALL location_message( 'finished', .TRUE. )
[1384]1378
[1788]1379       ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 )                  &
[46]1380       THEN
[1384]1381
[1402]1382          CALL location_message( 'initializing by user', .FALSE. )
[46]1383!
[2618]1384!--       Pre-initialize surface variables, i.e. setting start- and end-indices
1385!--       at each (j,i)-location. Please note, this does not supersede
1386!--       user-defined initialization of surface quantities.
1387          CALL init_surfaces
1388!
[46]1389!--       Initialization will completely be done by the user
1390          CALL user_init_3d_model
1391
[1402]1392          CALL location_message( 'finished', .TRUE. )
[1384]1393
[1]1394       ENDIF
[1384]1395
[1402]1396       CALL location_message( 'initializing statistics, boundary conditions, etc.', &
1397                              .FALSE. )
[1384]1398
[667]1399!
1400!--    Bottom boundary
1401       IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2  )  THEN
[1340]1402          u(nzb,:,:) = 0.0_wp
1403          v(nzb,:,:) = 0.0_wp
[667]1404       ENDIF
[1]1405
1406!
[151]1407!--    Apply channel flow boundary condition
[132]1408       IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
[1340]1409          u(nzt+1,:,:) = 0.0_wp
1410          v(nzt+1,:,:) = 0.0_wp
[132]1411       ENDIF
1412
1413!
[1]1414!--    Calculate virtual potential temperature
[1960]1415       IF ( humidity )  vpt = pt * ( 1.0_wp + 0.61_wp * q )
[1]1416
1417!
[2696]1418!--    Store initial profiles for output purposes etc.. Please note, in case of
1419!--    initialization of u, v, w, pt, and q via output data derived from larger
1420!--    scale models, data will not be horizontally homogeneous. Actually, a mean
1421!--    profile should be calculated before.   
[1]1422       hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 )
1423       hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 )
[667]1424       IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2)  THEN
[1340]1425          hom(nzb,1,5,:) = 0.0_wp
1426          hom(nzb,1,6,:) = 0.0_wp
[1]1427       ENDIF
1428       hom(:,1,7,:)  = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 )
1429
[2696]1430
1431!
1432!--    Store initial salinity profile
[97]1433       IF ( ocean )  THEN
1434          hom(:,1,26,:)  = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 )
1435       ENDIF
[1]1436
[75]1437       IF ( humidity )  THEN
[1]1438!
1439!--       Store initial profile of total water content, virtual potential
1440!--       temperature
1441          hom(:,1,26,:) = SPREAD(   q(:,nys,nxl), 2, statistic_regions+1 )
1442          hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 )
[2696]1443!
1444!--       Store initial profile of specific humidity and potential
1445!--       temperature
[1]1446          IF ( cloud_physics  .OR.  cloud_droplets ) THEN
1447             hom(:,1,27,:) = SPREAD(  q(:,nys,nxl), 2, statistic_regions+1 )
1448             hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 )
1449          ENDIF
1450       ENDIF
1451
[2696]1452!
1453!--    Store initial scalar profile
[1]1454       IF ( passive_scalar )  THEN
[2513]1455          hom(:,1,121,:) = SPREAD(  s(:,nys,nxl), 2, statistic_regions+1 )
[1]1456       ENDIF
1457
1458!
[1400]1459!--    Initialize the random number generators (from numerical recipes)
1460       CALL random_function_ini
[1429]1461       
[1400]1462       IF ( random_generator == 'random-parallel' )  THEN
[2172]1463          CALL init_parallel_random_generator(nx, ny, nys, nyn, nxl, nxr)
[1400]1464       ENDIF
1465!
[1179]1466!--    Set the reference state to be used in the buoyancy terms (for ocean runs
1467!--    the reference state will be set (overwritten) in init_ocean)
1468       IF ( use_single_reference_value )  THEN
[1788]1469          IF (  .NOT.  humidity )  THEN
[1179]1470             ref_state(:) = pt_reference
1471          ELSE
1472             ref_state(:) = vpt_reference
1473          ENDIF
1474       ELSE
[1788]1475          IF (  .NOT.  humidity )  THEN
[1179]1476             ref_state(:) = pt_init(:)
1477          ELSE
1478             ref_state(:) = vpt(:,nys,nxl)
1479          ENDIF
1480       ENDIF
[152]1481
1482!
[707]1483!--    For the moment, vertical velocity is zero
[1340]1484       w = 0.0_wp
[1]1485
1486!
1487!--    Initialize array sums (must be defined in first call of pres)
[1340]1488       sums = 0.0_wp
[1]1489
1490!
[707]1491!--    In case of iterative solvers, p must get an initial value
[1575]1492       IF ( psolver(1:9) == 'multigrid'  .OR.  psolver == 'sor' )  p = 0.0_wp
[707]1493
1494!
[72]1495!--    Treating cloud physics, liquid water content and precipitation amount
1496!--    are zero at beginning of the simulation
1497       IF ( cloud_physics )  THEN
[1340]1498          ql = 0.0_wp
[1822]1499          qc = 0.0_wp
1500
1501          precipitation_amount = 0.0_wp
[72]1502       ENDIF
[673]1503!
[1]1504!--    Impose vortex with vertical axis on the initial velocity profile
1505       IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 )  THEN
1506          CALL init_rankine
1507       ENDIF
1508
1509!
1510!--    Impose temperature anomaly (advection test only)
1511       IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 )  THEN
1512          CALL init_pt_anomaly
1513       ENDIF
1514
1515!
1516!--    If required, change the surface temperature at the start of the 3D run
[1340]1517       IF ( pt_surface_initial_change /= 0.0_wp )  THEN
[1]1518          pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change
1519       ENDIF
1520
1521!
1522!--    If required, change the surface humidity/scalar at the start of the 3D
1523!--    run
[1960]1524       IF ( humidity  .AND.  q_surface_initial_change /= 0.0_wp )              &
[1]1525          q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change
[1960]1526         
1527       IF ( passive_scalar .AND.  s_surface_initial_change /= 0.0_wp )         &
1528          s(nzb,:,:) = s(nzb,:,:) + s_surface_initial_change
1529       
[1]1530
1531!
1532!--    Initialize old and new time levels.
[2696]1533       tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp
1534       pt_p = pt; u_p = u; v_p = v; w_p = w
[1]1535
[1960]1536       IF ( humidity  )  THEN
[1340]1537          tq_m = 0.0_wp
[1]1538          q_p = q
[2292]1539          IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1540             tqc_m = 0.0_wp
1541             qc_p  = qc
1542             tnc_m = 0.0_wp
1543             nc_p  = nc
1544          ENDIF
[1822]1545          IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
[1340]1546             tqr_m = 0.0_wp
[1822]1547             qr_p  = qr
[1340]1548             tnr_m = 0.0_wp
[1822]1549             nr_p  = nr
[1053]1550          ENDIF
[1]1551       ENDIF
[1960]1552       
1553       IF ( passive_scalar )  THEN
1554          ts_m = 0.0_wp
1555          s_p  = s
1556       ENDIF       
[1]1557
[94]1558       IF ( ocean )  THEN
[1340]1559          tsa_m = 0.0_wp
[94]1560          sa_p  = sa
1561       ENDIF
[667]1562       
[1402]1563       CALL location_message( 'finished', .TRUE. )
[94]1564
[1788]1565    ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data'  .OR.         &
[2232]1566             TRIM( initializing_actions ) == 'cyclic_fill' )                   &
[1]1567    THEN
[1384]1568
[1402]1569       CALL location_message( 'initializing in case of restart / cyclic_fill', &
1570                              .FALSE. )
[1]1571!
[2232]1572!--    Initialize surface elements and its attributes, e.g. heat- and
1573!--    momentumfluxes, roughness, scaling parameters. As number of surface
1574!--    elements might be different between runs, e.g. in case of cyclic fill,
1575!--    and not all surface elements are read, surface elements need to be
1576!--    initialized before.     
1577       CALL init_surfaces
1578!
[767]1579!--    When reading data for cyclic fill of 3D prerun data files, read
1580!--    some of the global variables from the restart file which are required
1581!--    for initializing the inflow
[328]1582       IF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
[559]1583
[759]1584          DO  i = 0, io_blocks-1
1585             IF ( i == io_group )  THEN
1586                CALL read_parts_of_var_list
1587                CALL close_file( 13 )
1588             ENDIF
1589#if defined( __parallel )
1590             CALL MPI_BARRIER( comm2d, ierr )
1591#endif
1592          ENDDO
[328]1593
[767]1594       ENDIF
1595
[151]1596!
[767]1597!--    Read binary data from restart file
1598       DO  i = 0, io_blocks-1
1599          IF ( i == io_group )  THEN
1600             CALL read_3d_binary
1601          ENDIF
1602#if defined( __parallel )
1603          CALL MPI_BARRIER( comm2d, ierr )
1604#endif
1605       ENDDO
1606
[328]1607!
[2550]1608!--    In case of complex terrain and cyclic fill method as initialization,
1609!--    shift initial data in the vertical direction for each point in the
1610!--    x-y-plane depending on local surface height
1611       IF ( complex_terrain  .AND.                                             &
1612            TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1613          DO  i = nxlg, nxrg
1614             DO  j = nysg, nyng
[2698]1615                nz_u_shift = get_topography_top_index_ji( j, i, 'u' )
1616                nz_v_shift = get_topography_top_index_ji( j, i, 'v' )
1617                nz_w_shift = get_topography_top_index_ji( j, i, 'w' )
1618                nz_s_shift = get_topography_top_index_ji( j, i, 's' )
[2550]1619
1620                u(nz_u_shift:nzt+1,j,i)  = u(0:nzt+1-nz_u_shift,j,i)               
1621
1622                v(nz_v_shift:nzt+1,j,i)  = v(0:nzt+1-nz_v_shift,j,i)
1623
1624                w(nz_w_shift:nzt+1,j,i)  = w(0:nzt+1-nz_w_shift,j,i)
1625
1626                p(nz_s_shift:nzt+1,j,i)  =  p(0:nzt+1-nz_s_shift,j,i)
1627                pt(nz_s_shift:nzt+1,j,i) = pt(0:nzt+1-nz_s_shift,j,i)
1628             ENDDO
1629          ENDDO
1630       ENDIF
1631
1632!
[767]1633!--    Initialization of the turbulence recycling method
[1788]1634       IF ( TRIM( initializing_actions ) == 'cyclic_fill'  .AND.               &
[767]1635            turbulent_inflow )  THEN
1636!
1637!--       First store the profiles to be used at the inflow.
1638!--       These profiles are the (temporally) and horizontally averaged vertical
1639!--       profiles from the prerun. Alternatively, prescribed profiles
1640!--       for u,v-components can be used.
[1960]1641          ALLOCATE( mean_inflow_profiles(nzb:nzt+1,7) )
[151]1642
[767]1643          IF ( use_prescribed_profile_data )  THEN
1644             mean_inflow_profiles(:,1) = u_init            ! u
1645             mean_inflow_profiles(:,2) = v_init            ! v
1646          ELSE
[328]1647             mean_inflow_profiles(:,1) = hom_sum(:,1,0)    ! u
1648             mean_inflow_profiles(:,2) = hom_sum(:,2,0)    ! v
[767]1649          ENDIF
1650          mean_inflow_profiles(:,4) = hom_sum(:,4,0)       ! pt
[1960]1651          IF ( humidity )                                                      &
1652             mean_inflow_profiles(:,6) = hom_sum(:,41,0)   ! q
1653          IF ( passive_scalar )                                                &
1654             mean_inflow_profiles(:,7) = hom_sum(:,115,0)   ! s
[2550]1655!
1656!--       In case of complex terrain, determine vertical displacement at inflow
1657!--       boundary and adjust mean inflow profiles
1658          IF ( complex_terrain )  THEN
1659             IF ( nxlg <= 0 .AND. nxrg >= 0 .AND. nysg <= 0 .AND. nyng >= 0 )  THEN
[2698]1660                nz_u_shift_l = get_topography_top_index_ji( 0, 0, 'u' )
1661                nz_v_shift_l = get_topography_top_index_ji( 0, 0, 'v' )
1662                nz_w_shift_l = get_topography_top_index_ji( 0, 0, 'w' )
1663                nz_s_shift_l = get_topography_top_index_ji( 0, 0, 's' )
[2550]1664             ELSE
1665                nz_u_shift_l = 0
1666                nz_v_shift_l = 0
1667                nz_w_shift_l = 0
1668                nz_s_shift_l = 0
1669             ENDIF
[151]1670
[2550]1671#if defined( __parallel )
1672             CALL MPI_ALLREDUCE(nz_u_shift_l, nz_u_shift, 1, MPI_INTEGER,      &
1673                                MPI_MAX, comm2d, ierr)
1674             CALL MPI_ALLREDUCE(nz_v_shift_l, nz_v_shift, 1, MPI_INTEGER,      &
1675                                MPI_MAX, comm2d, ierr)
1676             CALL MPI_ALLREDUCE(nz_w_shift_l, nz_w_shift, 1, MPI_INTEGER,      & 
1677                                MPI_MAX, comm2d, ierr)
1678             CALL MPI_ALLREDUCE(nz_s_shift_l, nz_s_shift, 1, MPI_INTEGER,      &
1679                                MPI_MAX, comm2d, ierr)
1680#else
1681             nz_u_shift = nz_u_shift_l
1682             nz_v_shift = nz_v_shift_l
1683             nz_w_shift = nz_w_shift_l
1684             nz_s_shift = nz_s_shift_l
1685#endif
1686
1687             mean_inflow_profiles(:,1) = 0.0_wp
1688             mean_inflow_profiles(nz_u_shift:nzt+1,1) = hom_sum(0:nzt+1-nz_u_shift,1,0)  ! u
1689
1690             mean_inflow_profiles(:,2) = 0.0_wp
1691             mean_inflow_profiles(nz_v_shift:nzt+1,2) = hom_sum(0:nzt+1-nz_v_shift,2,0)  ! v
1692
1693             mean_inflow_profiles(nz_s_shift:nzt+1,4) = hom_sum(0:nzt+1-nz_s_shift,4,0)  ! pt
1694
1695          ENDIF
1696
[151]1697!
[767]1698!--       If necessary, adjust the horizontal flow field to the prescribed
1699!--       profiles
1700          IF ( use_prescribed_profile_data )  THEN
1701             DO  i = nxlg, nxrg
[667]1702                DO  j = nysg, nyng
[328]1703                   DO  k = nzb, nzt+1
[767]1704                      u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k)
1705                      v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k)
[328]1706                   ENDDO
[151]1707                ENDDO
[767]1708             ENDDO
1709          ENDIF
[151]1710
1711!
[767]1712!--       Use these mean profiles at the inflow (provided that Dirichlet
1713!--       conditions are used)
1714          IF ( inflow_l )  THEN
1715             DO  j = nysg, nyng
1716                DO  k = nzb, nzt+1
1717                   u(k,j,nxlg:-1)  = mean_inflow_profiles(k,1)
1718                   v(k,j,nxlg:-1)  = mean_inflow_profiles(k,2)
[1340]1719                   w(k,j,nxlg:-1)  = 0.0_wp
[767]1720                   pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4)
[1960]1721                   IF ( humidity )                                             &
[1615]1722                      q(k,j,nxlg:-1)  = mean_inflow_profiles(k,6)
[1960]1723                   IF ( passive_scalar )                                       &
1724                      s(k,j,nxlg:-1)  = mean_inflow_profiles(k,7)                     
[767]1725                ENDDO
1726             ENDDO
1727          ENDIF
1728
[151]1729!
[767]1730!--       Calculate the damping factors to be used at the inflow. For a
1731!--       turbulent inflow the turbulent fluctuations have to be limited
1732!--       vertically because otherwise the turbulent inflow layer will grow
1733!--       in time.
[1340]1734          IF ( inflow_damping_height == 9999999.9_wp )  THEN
[767]1735!
1736!--          Default: use the inversion height calculated by the prerun; if
1737!--          this is zero, inflow_damping_height must be explicitly
1738!--          specified.
[1340]1739             IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp )  THEN
[767]1740                inflow_damping_height = hom_sum(nzb+6,pr_palm,0)
1741             ELSE
[1788]1742                WRITE( message_string, * ) 'inflow_damping_height must be ',   &
1743                     'explicitly specified because&the inversion height ',     &
[767]1744                     'calculated by the prerun is zero.'
1745                CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 )
[292]1746             ENDIF
[151]1747
[767]1748          ENDIF
1749
[1340]1750          IF ( inflow_damping_width == 9999999.9_wp )  THEN
[151]1751!
[767]1752!--          Default for the transition range: one tenth of the undamped
1753!--          layer
[1340]1754             inflow_damping_width = 0.1_wp * inflow_damping_height
[151]1755
[767]1756          ENDIF
[151]1757
[767]1758          ALLOCATE( inflow_damping_factor(nzb:nzt+1) )
[151]1759
[767]1760          DO  k = nzb, nzt+1
[151]1761
[767]1762             IF ( zu(k) <= inflow_damping_height )  THEN
[1340]1763                inflow_damping_factor(k) = 1.0_wp
[996]1764             ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) )  THEN
[1340]1765                inflow_damping_factor(k) = 1.0_wp -                            &
[996]1766                                           ( zu(k) - inflow_damping_height ) / &
1767                                           inflow_damping_width
[767]1768             ELSE
[1340]1769                inflow_damping_factor(k) = 0.0_wp
[767]1770             ENDIF
[151]1771
[767]1772          ENDDO
[151]1773
[147]1774       ENDIF
1775
[152]1776!
[2696]1777!--    Inside buildings set velocities back to zero
[1788]1778       IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND.                &
[359]1779            topography /= 'flat' )  THEN
1780!
[2696]1781!--       Inside buildings set velocities back to zero.
1782!--       Other scalars (pt, q, s, p, sa, ...) are ignored at present,
[359]1783!--       maybe revise later.
[1001]1784          DO  i = nxlg, nxrg
1785             DO  j = nysg, nyng
[2232]1786                DO  k = nzb, nzt
1787                   u(k,j,i)     = MERGE( u(k,j,i), 0.0_wp,                     &
1788                                         BTEST( wall_flags_0(k,j,i), 1 ) )
1789                   v(k,j,i)     = MERGE( v(k,j,i), 0.0_wp,                     &
1790                                         BTEST( wall_flags_0(k,j,i), 2 ) )
1791                   w(k,j,i)     = MERGE( w(k,j,i), 0.0_wp,                     &
1792                                         BTEST( wall_flags_0(k,j,i), 3 ) )
1793                   tu_m(k,j,i)  = MERGE( tu_m(k,j,i), 0.0_wp,                  &
1794                                         BTEST( wall_flags_0(k,j,i), 1 ) )
1795                   tv_m(k,j,i)  = MERGE( tv_m(k,j,i), 0.0_wp,                  &
1796                                         BTEST( wall_flags_0(k,j,i), 2 ) )
1797                   tw_m(k,j,i)  = MERGE( tw_m(k,j,i), 0.0_wp,                  &
1798                                         BTEST( wall_flags_0(k,j,i), 3 ) )
1799                   tpt_m(k,j,i) = MERGE( tpt_m(k,j,i), 0.0_wp,                 &
1800                                         BTEST( wall_flags_0(k,j,i), 0 ) )
1801                ENDDO
[359]1802             ENDDO
[1001]1803          ENDDO
[359]1804
1805       ENDIF
1806
1807!
[1]1808!--    Calculate initial temperature field and other constants used in case
1809!--    of a sloping surface
1810       IF ( sloping_surface )  CALL init_slope
1811
1812!
1813!--    Initialize new time levels (only done in order to set boundary values
1814!--    including ghost points)
[2696]1815       pt_p = pt; u_p = u; v_p = v; w_p = w
[1960]1816       IF ( humidity )  THEN
[1053]1817          q_p = q
[2292]1818          IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1819             qc_p = qc
1820             nc_p = nc
1821          ENDIF
[1822]1822          IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
[1053]1823             qr_p = qr
1824             nr_p = nr
1825          ENDIF
1826       ENDIF
[1960]1827       IF ( passive_scalar )  s_p  = s
1828       IF ( ocean          )  sa_p = sa
[1]1829
[181]1830!
1831!--    Allthough tendency arrays are set in prognostic_equations, they have
1832!--    have to be predefined here because they are used (but multiplied with 0)
1833!--    there before they are set.
[2696]1834       tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp
[1960]1835       IF ( humidity )  THEN
[1340]1836          tq_m = 0.0_wp
[2292]1837          IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
1838             tqc_m = 0.0_wp
1839             tnc_m = 0.0_wp
1840          ENDIF
[1822]1841          IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
[1340]1842             tqr_m = 0.0_wp
1843             tnr_m = 0.0_wp
[1053]1844          ENDIF
1845       ENDIF
[1960]1846       IF ( passive_scalar )  ts_m  = 0.0_wp
1847       IF ( ocean          )  tsa_m = 0.0_wp
[2259]1848!
1849!--    Initialize synthetic turbulence generator in case of restart.
1850       IF ( TRIM( initializing_actions ) == 'read_restart_data'  .AND.         &
1851            use_synthetic_turbulence_generator )  CALL stg_init
[181]1852
[1402]1853       CALL location_message( 'finished', .TRUE. )
[1384]1854
[1]1855    ELSE
1856!
1857!--    Actually this part of the programm should not be reached
[254]1858       message_string = 'unknown initializing problem'
1859       CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 )
[1]1860    ENDIF
1861
[2696]1862!
1863!-- Initialize TKE, Kh and Km
1864    CALL tcm_init
[151]1865
[2696]1866
[151]1867    IF (  TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
[1]1868!
[151]1869!--    Initialize old timelevels needed for radiation boundary conditions
1870       IF ( outflow_l )  THEN
1871          u_m_l(:,:,:) = u(:,:,1:2)
1872          v_m_l(:,:,:) = v(:,:,0:1)
1873          w_m_l(:,:,:) = w(:,:,0:1)
1874       ENDIF
1875       IF ( outflow_r )  THEN
1876          u_m_r(:,:,:) = u(:,:,nx-1:nx)
1877          v_m_r(:,:,:) = v(:,:,nx-1:nx)
1878          w_m_r(:,:,:) = w(:,:,nx-1:nx)
1879       ENDIF
1880       IF ( outflow_s )  THEN
1881          u_m_s(:,:,:) = u(:,0:1,:)
1882          v_m_s(:,:,:) = v(:,1:2,:)
1883          w_m_s(:,:,:) = w(:,0:1,:)
1884       ENDIF
1885       IF ( outflow_n )  THEN
1886          u_m_n(:,:,:) = u(:,ny-1:ny,:)
1887          v_m_n(:,:,:) = v(:,ny-1:ny,:)
1888          w_m_n(:,:,:) = w(:,ny-1:ny,:)
1889       ENDIF
[667]1890       
[151]1891    ENDIF
[680]1892
[667]1893!
1894!-- Calculate the initial volume flow at the right and north boundary
[709]1895    IF ( conserve_volume_flow )  THEN
[151]1896
[767]1897       IF ( use_prescribed_profile_data )  THEN
[667]1898
[1340]1899          volume_flow_initial_l = 0.0_wp
1900          volume_flow_area_l    = 0.0_wp
[732]1901
[667]1902          IF ( nxr == nx )  THEN
1903             DO  j = nys, nyn
[2232]1904                DO  k = nzb+1, nzt
[1788]1905                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
[2232]1906                                              u_init(k) * dzw(k)               &
1907                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1908                                              BTEST( wall_flags_0(k,j,nxr), 1 )&
1909                                            )
1910
1911                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
1912                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1913                                              BTEST( wall_flags_0(k,j,nxr), 1 )&
1914                                            )
[767]1915                ENDDO
1916             ENDDO
1917          ENDIF
1918         
1919          IF ( nyn == ny )  THEN
1920             DO  i = nxl, nxr
[2232]1921                DO  k = nzb+1, nzt
1922                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
1923                                              v_init(k) * dzw(k)               &       
1924                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1925                                              BTEST( wall_flags_0(k,nyn,i), 2 )&
1926                                            )
1927                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &       
1928                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1929                                              BTEST( wall_flags_0(k,nyn,i), 2 )&
1930                                            )
[767]1931                ENDDO
1932             ENDDO
1933          ENDIF
1934
1935#if defined( __parallel )
1936          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),&
1937                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
1938          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1),      &
1939                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
1940
1941#else
1942          volume_flow_initial = volume_flow_initial_l
1943          volume_flow_area    = volume_flow_area_l
1944#endif 
1945
1946       ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
1947
[1340]1948          volume_flow_initial_l = 0.0_wp
1949          volume_flow_area_l    = 0.0_wp
[767]1950
1951          IF ( nxr == nx )  THEN
1952             DO  j = nys, nyn
[2232]1953                DO  k = nzb+1, nzt
[1788]1954                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
[2232]1955                                              hom_sum(k,1,0) * dzw(k)          &
1956                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1957                                              BTEST( wall_flags_0(k,j,nx), 1 ) &
1958                                            )
1959                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
1960                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1961                                              BTEST( wall_flags_0(k,j,nx), 1 ) &
1962                                            )
[667]1963                ENDDO
1964             ENDDO
1965          ENDIF
1966         
1967          IF ( nyn == ny )  THEN
1968             DO  i = nxl, nxr
[2232]1969                DO  k = nzb+1, nzt
[1788]1970                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
[2232]1971                                              hom_sum(k,2,0) * dzw(k)          &       
1972                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1973                                              BTEST( wall_flags_0(k,ny,i), 2 ) &
1974                                            )
1975                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &       
1976                                     * MERGE( 1.0_wp, 0.0_wp,                  &
1977                                              BTEST( wall_flags_0(k,ny,i), 2 ) &
1978                                            )
[667]1979                ENDDO
1980             ENDDO
1981          ENDIF
1982
[732]1983#if defined( __parallel )
1984          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),&
1985                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
1986          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1),      &
1987                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
1988
1989#else
1990          volume_flow_initial = volume_flow_initial_l
1991          volume_flow_area    = volume_flow_area_l
1992#endif 
1993
[667]1994       ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1995
[1340]1996          volume_flow_initial_l = 0.0_wp
1997          volume_flow_area_l    = 0.0_wp
[732]1998
[667]1999          IF ( nxr == nx )  THEN
2000             DO  j = nys, nyn
[2232]2001                DO  k = nzb+1, nzt
2002                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
2003                                              u(k,j,nx) * dzw(k)               &
2004                                     * MERGE( 1.0_wp, 0.0_wp,                  &
2005                                              BTEST( wall_flags_0(k,j,nx), 1 ) &
2006                                            )
2007                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
2008                                     * MERGE( 1.0_wp, 0.0_wp,                  &
2009                                              BTEST( wall_flags_0(k,j,nx), 1 ) &
2010                                            )
[667]2011                ENDDO
2012             ENDDO
2013          ENDIF
2014         
2015          IF ( nyn == ny )  THEN
2016             DO  i = nxl, nxr
[2232]2017                DO  k = nzb+1, nzt
[1788]2018                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
[2232]2019                                              v(k,ny,i) * dzw(k)               &       
2020                                     * MERGE( 1.0_wp, 0.0_wp,                  &
2021                                              BTEST( wall_flags_0(k,ny,i), 2 ) &
2022                                            )
2023                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &       
2024                                     * MERGE( 1.0_wp, 0.0_wp,                  &
2025                                              BTEST( wall_flags_0(k,ny,i), 2 ) &
2026                                            )
[667]2027                ENDDO
2028             ENDDO
2029          ENDIF
2030
2031#if defined( __parallel )
[732]2032          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),&
2033                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
2034          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1),      &
2035                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
[667]2036
2037#else
[732]2038          volume_flow_initial = volume_flow_initial_l
2039          volume_flow_area    = volume_flow_area_l
[667]2040#endif 
2041
[732]2042       ENDIF
2043
[151]2044!
[709]2045!--    In case of 'bulk_velocity' mode, volume_flow_initial is calculated
2046!--    from u|v_bulk instead
[680]2047       IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
2048          volume_flow_initial(1) = u_bulk * volume_flow_area(1)
2049          volume_flow_initial(2) = v_bulk * volume_flow_area(2)
2050       ENDIF
[667]2051
[680]2052    ENDIF
[2232]2053!
[2618]2054!-- Finally, if random_heatflux is set, disturb shf at horizontal
2055!-- surfaces. Actually, this should be done in surface_mod, where all other
2056!-- initializations of surface quantities are done. However, this
2057!-- would create a ring dependency, hence, it is done here. Maybe delete
2058!-- disturb_heatflux and tranfer the respective code directly into the
2059!-- initialization in surface_mod.         
[2232]2060    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.            &
2061         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
[2618]2062 
[2232]2063       IF ( use_surface_fluxes  .AND.  constant_heatflux  .AND.                &
2064            random_heatflux )  THEN
2065          IF ( surf_def_h(0)%ns >= 1 )  CALL disturb_heatflux( surf_def_h(0) )
2066          IF ( surf_lsm_h%ns    >= 1 )  CALL disturb_heatflux( surf_lsm_h    )
2067          IF ( surf_usm_h%ns    >= 1 )  CALL disturb_heatflux( surf_usm_h    )
2068       ENDIF
2069    ENDIF
[680]2070
[787]2071!
[2696]2072!-- Before initializing further modules, compute total sum of active mask
2073!-- grid points and the mean surface level height for each statistic region.
2074!-- ngp_2dh: number of grid points of a horizontal cross section through the
2075!--          total domain
2076!-- ngp_3d:  number of grid points of the total domain
2077    ngp_2dh_outer_l   = 0
2078    ngp_2dh_outer     = 0
2079    ngp_2dh_s_inner_l = 0
2080    ngp_2dh_s_inner   = 0
2081    ngp_2dh_l         = 0
2082    ngp_2dh           = 0
2083    ngp_3d_inner_l    = 0.0_wp
2084    ngp_3d_inner      = 0
2085    ngp_3d            = 0
2086    ngp_sums          = ( nz + 2 ) * ( pr_palm + max_pr_user )
2087
2088    mean_surface_level_height   = 0.0_wp
2089    mean_surface_level_height_l = 0.0_wp
2090!
2091!-- Pre-set masks for regional statistics. Default is the total model domain.
2092!-- Ghost points are excluded because counting values at the ghost boundaries
2093!-- would bias the statistics
2094    rmask = 1.0_wp
2095    rmask(:,nxlg:nxl-1,:) = 0.0_wp;  rmask(:,nxr+1:nxrg,:) = 0.0_wp
2096    rmask(nysg:nys-1,:,:) = 0.0_wp;  rmask(nyn+1:nyng,:,:) = 0.0_wp
2097
2098!
2099!-- To do: New concept for these non-topography grid points!
2100    DO  sr = 0, statistic_regions
2101       DO  i = nxl, nxr
2102          DO  j = nys, nyn
2103             IF ( rmask(j,i,sr) == 1.0_wp )  THEN
2104!
2105!--             All xy-grid points
2106                ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1
2107!
2108!--             Determine mean surface-level height. In case of downward-
2109!--             facing walls are present, more than one surface level exist.
2110!--             In this case, use the lowest surface-level height.
2111                IF ( surf_def_h(0)%start_index(j,i) <=                         &
2112                     surf_def_h(0)%end_index(j,i) )  THEN
2113                   m = surf_def_h(0)%start_index(j,i)
2114                   k = surf_def_h(0)%k(m)
2115                   mean_surface_level_height_l(sr) =                           &
2116                                       mean_surface_level_height_l(sr) + zw(k-1)
2117                ENDIF
2118                IF ( surf_lsm_h%start_index(j,i) <=                            &
2119                     surf_lsm_h%end_index(j,i) )  THEN
2120                   m = surf_lsm_h%start_index(j,i)
2121                   k = surf_lsm_h%k(m)
2122                   mean_surface_level_height_l(sr) =                           &
2123                                       mean_surface_level_height_l(sr) + zw(k-1)
2124                ENDIF
2125                IF ( surf_usm_h%start_index(j,i) <=                            &
2126                     surf_usm_h%end_index(j,i) )  THEN
2127                   m = surf_usm_h%start_index(j,i)
2128                   k = surf_usm_h%k(m)
2129                   mean_surface_level_height_l(sr) =                           &
2130                                       mean_surface_level_height_l(sr) + zw(k-1)
2131                ENDIF
2132
2133                k_surf = k - 1
2134
2135                DO  k = nzb, nzt+1
2136!
2137!--                xy-grid points above topography
2138                   ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr)     +         &
2139                                  MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 24 ) )
2140
2141                   ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) +         &
2142                                  MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 22 ) )
2143
2144                ENDDO
2145!
2146!--             All grid points of the total domain above topography
2147                ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + ( nz - k_surf + 2 )
2148
2149
2150
2151             ENDIF
2152          ENDDO
2153       ENDDO
2154    ENDDO
2155
2156    sr = statistic_regions + 1
2157#if defined( __parallel )
2158    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
2159    CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM,    &
2160                        comm2d, ierr )
2161    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
2162    CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr,   &
2163                        MPI_INTEGER, MPI_SUM, comm2d, ierr )
2164    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
2165    CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0),          &
2166                        (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr )
2167    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
2168    CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL,  &
2169                        MPI_SUM, comm2d, ierr )
2170    ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) )
2171    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
2172    CALL MPI_ALLREDUCE( mean_surface_level_height_l(0),                        &
2173                        mean_surface_level_height(0), sr, MPI_REAL,            &
2174                        MPI_SUM, comm2d, ierr )
2175    mean_surface_level_height = mean_surface_level_height / REAL( ngp_2dh )
2176#else
2177    ngp_2dh         = ngp_2dh_l
2178    ngp_2dh_outer   = ngp_2dh_outer_l
2179    ngp_2dh_s_inner = ngp_2dh_s_inner_l
2180    ngp_3d_inner    = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) )
2181    mean_surface_level_height = mean_surface_level_height_l / REAL( ngp_2dh_l )
2182#endif
2183
2184    ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * &
2185             INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) )
2186
2187!
2188!-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics,
2189!-- buoyancy, etc. A zero value will occur for cases where all grid points of
2190!-- the respective subdomain lie below the surface topography
2191    ngp_2dh_outer   = MAX( 1, ngp_2dh_outer(:,:)   ) 
2192    ngp_3d_inner    = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )),             &
2193                           ngp_3d_inner(:) )
2194    ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) 
2195
2196    DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l,       &
2197                ngp_3d_inner_l, ngp_3d_inner_tmp )
2198
2199!
[2232]2200!-- Initialize surface forcing corresponding to large-scale forcing. Therein,
2201!-- initialize heat-fluxes, etc. via datatype. Revise it later!
2202    IF ( large_scale_forcing .AND. lsf_surf )  THEN
2203       IF ( use_surface_fluxes  .AND.  constant_heatflux )  THEN
2204          CALL ls_forcing_surf ( simulated_time )
2205       ENDIF
2206    ENDIF
2207!
[787]2208!-- Initialize quantities for special advections schemes
2209    CALL init_advec
[680]2210
[667]2211!
[680]2212!-- Impose random perturbation on the horizontal velocity field and then
2213!-- remove the divergences from the velocity field at the initial stage
[1788]2214    IF ( create_disturbances  .AND.  disturbance_energy_limit /= 0.0_wp  .AND. &
2215         TRIM( initializing_actions ) /= 'read_restart_data'  .AND.            &
[680]2216         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
2217
[1402]2218       CALL location_message( 'creating initial disturbances', .FALSE. )
[2232]2219       CALL disturb_field( 'u', tend, u )
2220       CALL disturb_field( 'v', tend, v )
[1402]2221       CALL location_message( 'finished', .TRUE. )
[1384]2222
[1402]2223       CALL location_message( 'calling pressure solver', .FALSE. )
[680]2224       n_sor = nsor_ini
2225       CALL pres
2226       n_sor = nsor
[1402]2227       CALL location_message( 'finished', .TRUE. )
[1384]2228
[680]2229    ENDIF
2230
2231!
[1484]2232!-- If required, initialize quantities needed for the plant canopy model
[2007]2233    IF ( plant_canopy )  THEN
2234       CALL location_message( 'initializing plant canopy model', .FALSE. )   
2235       CALL pcm_init
2236       CALL location_message( 'finished', .TRUE. )
2237    ENDIF
[138]2238
2239!
[1]2240!-- If required, initialize dvrp-software
[1340]2241    IF ( dt_dvrp /= 9999999.9_wp )  CALL init_dvrp
[1]2242
[96]2243    IF ( ocean )  THEN
[1]2244!
[96]2245!--    Initialize quantities needed for the ocean model
2246       CALL init_ocean
[388]2247
[96]2248    ELSE
2249!
2250!--    Initialize quantities for handling cloud physics
[849]2251!--    This routine must be called before lpm_init, because
[96]2252!--    otherwise, array pt_d_t, needed in data_output_dvrp (called by
[849]2253!--    lpm_init) is not defined.
[96]2254       CALL init_cloud_physics
[1849]2255!
2256!--    Initialize bulk cloud microphysics
2257       CALL microphysics_init
[96]2258    ENDIF
[1]2259
2260!
2261!-- If required, initialize particles
[849]2262    IF ( particle_advection )  CALL lpm_init
[1]2263
[1585]2264!
2265!-- If required, initialize quantities needed for the LSM
2266    IF ( land_surface )  THEN
2267       CALL location_message( 'initializing land surface model', .FALSE. )
[1817]2268       CALL lsm_init
[1585]2269       CALL location_message( 'finished', .TRUE. )
2270    ENDIF
[1496]2271
[1]2272!
[2696]2273!-- If required, allocate USM and LSM surfaces
2274    IF ( urban_surface )  THEN
2275       CALL location_message( 'initializing and allocating urban surfaces', .FALSE. )
2276       CALL usm_allocate_surface
2277       CALL location_message( 'finished', .TRUE. )
2278    ENDIF
2279!
2280!-- If required, initialize urban surface model
2281    IF ( urban_surface )  THEN
2282       CALL location_message( 'initializing urban surface model', .FALSE. )
2283       CALL usm_init_urban_surface
2284       CALL location_message( 'finished', .TRUE. )
2285    ENDIF
2286
2287!
[1691]2288!-- Initialize surface layer (done after LSM as roughness length are required
2289!-- for initialization
2290    IF ( constant_flux_layer )  THEN
2291       CALL location_message( 'initializing surface layer', .FALSE. )
2292       CALL init_surface_layer_fluxes
2293       CALL location_message( 'finished', .TRUE. )
2294    ENDIF
2295
2296!
[2696]2297!-- If required, set chemical emissions
2298!-- (todo(FK): This should later on be CALLed time-dependently in init_3d_model)
2299#if defined( __chem )
2300    IF ( air_chemistry ) THEN
2301       CALL chem_emissions
2302    ENDIF
2303#endif
2304
2305!
2306!-- Initialize radiation processes
[1496]2307    IF ( radiation )  THEN
[2696]2308!
2309!--    If required, initialize radiation interactions between surfaces
2310!--    via sky-view factors. This must be done befoe radiation is initialized.
2311       IF ( radiation_interactions )  CALL radiation_interaction_init
2312
2313!
2314!--    Initialize radiation model
[1585]2315       CALL location_message( 'initializing radiation model', .FALSE. )
[1826]2316       CALL radiation_init
[1585]2317       CALL location_message( 'finished', .TRUE. )
[2696]2318
2319!
2320!--    If required, read or calculate and write out the SVF
2321       IF ( radiation_interactions  .AND.  read_svf_on_init )  THEN
2322!
2323!--       Read sky-view factors and further required data from file
2324          CALL location_message( '    Start reading SVF from file', .FALSE. )
2325          CALL radiation_read_svf()
2326          CALL location_message( '    Reading SVF from file has finished', .TRUE. )
2327
2328       ELSEIF ( radiation_interactions )  THEN
2329!
2330!--       calculate SFV and CSF
2331          CALL location_message( '    Start calculation of SVF', .FALSE. )
2332          CALL radiation_calc_svf()
2333          CALL location_message( '    Calculation of SVF has finished', .TRUE. )
2334       ENDIF
2335
2336       IF ( radiation_interactions  .AND.  write_svf_on_init )  THEN
2337!
2338!--       Write svf, csf svfsurf and csfsurf data to file
2339          CALL radiation_write_svf()
2340       ENDIF
2341
2342!
2343!--    Adjust radiative fluxes. In case of urban and land surfaces, also
2344!--    call an initial interaction.
2345       CALL radiation_control 
2346       IF ( radiation_interactions )  THEN
2347          CALL radiation_interaction
2348       ENDIF
[1496]2349    ENDIF
[2270]2350   
[1914]2351!
[2270]2352!-- Temporary solution to add LSM and radiation time series to the default
2353!-- output
2354    IF ( land_surface  .OR.  radiation )  THEN
2355       IF ( TRIM( radiation_scheme ) == 'rrtmg' )  THEN
2356          dots_num = dots_num + 15
2357       ELSE
2358          dots_num = dots_num + 11
2359       ENDIF
2360    ENDIF
2361   
[2007]2362
[2696]2363
[2007]2364!
[1914]2365!-- If required, initialize quantities needed for the wind turbine model
2366    IF ( wind_turbine )  THEN
2367       CALL location_message( 'initializing wind turbine model', .FALSE. )
2368       CALL wtm_init
2369       CALL location_message( 'finished', .TRUE. )
2370    ENDIF
[1496]2371
[1914]2372
[1496]2373!
[673]2374!-- Initialize the ws-scheme.   
2375    IF ( ws_scheme_sca .OR. ws_scheme_mom )  CALL ws_init       
[1]2376
2377!
[709]2378!-- Setting weighting factors for calculation of perturbation pressure
[1762]2379!-- and turbulent quantities from the RK substeps
[709]2380    IF ( TRIM(timestep_scheme) == 'runge-kutta-3' )  THEN      ! for RK3-method
2381
[1322]2382       weight_substep(1) = 1._wp/6._wp
2383       weight_substep(2) = 3._wp/10._wp
2384       weight_substep(3) = 8._wp/15._wp
[709]2385
[1322]2386       weight_pres(1)    = 1._wp/3._wp
2387       weight_pres(2)    = 5._wp/12._wp
2388       weight_pres(3)    = 1._wp/4._wp
[709]2389
2390    ELSEIF ( TRIM(timestep_scheme) == 'runge-kutta-2' )  THEN  ! for RK2-method
2391
[1322]2392       weight_substep(1) = 1._wp/2._wp
2393       weight_substep(2) = 1._wp/2._wp
[673]2394         
[1322]2395       weight_pres(1)    = 1._wp/2._wp
2396       weight_pres(2)    = 1._wp/2._wp       
[709]2397
[1001]2398    ELSE                                     ! for Euler-method
[709]2399
[1340]2400       weight_substep(1) = 1.0_wp     
2401       weight_pres(1)    = 1.0_wp                   
[709]2402
[673]2403    ENDIF
2404
2405!
[1]2406!-- Initialize Rayleigh damping factors
[1340]2407    rdf    = 0.0_wp
2408    rdf_sc = 0.0_wp
2409    IF ( rayleigh_damping_factor /= 0.0_wp )  THEN
[1788]2410       IF (  .NOT.  ocean )  THEN
[108]2411          DO  k = nzb+1, nzt
2412             IF ( zu(k) >= rayleigh_damping_height )  THEN
[1788]2413                rdf(k) = rayleigh_damping_factor *                             &
[1340]2414                      ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height ) &
[1788]2415                             / ( zu(nzt) - rayleigh_damping_height ) )         &
[1]2416                      )**2
[108]2417             ENDIF
2418          ENDDO
2419       ELSE
2420          DO  k = nzt, nzb+1, -1
2421             IF ( zu(k) <= rayleigh_damping_height )  THEN
[1788]2422                rdf(k) = rayleigh_damping_factor *                             &
[1340]2423                      ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) ) &
[1788]2424                             / ( rayleigh_damping_height - zu(nzb+1) ) )       &
[108]2425                      )**2
2426             ENDIF
2427          ENDDO
2428       ENDIF
[1]2429    ENDIF
[785]2430    IF ( scalar_rayleigh_damping )  rdf_sc = rdf
[1]2431
2432!
[240]2433!-- Initialize the starting level and the vertical smoothing factor used for
2434!-- the external pressure gradient
[1340]2435    dp_smooth_factor = 1.0_wp
[240]2436    IF ( dp_external )  THEN
2437!
2438!--    Set the starting level dp_level_ind_b only if it has not been set before
2439!--    (e.g. in init_grid).
2440       IF ( dp_level_ind_b == 0 )  THEN
2441          ind_array = MINLOC( ABS( dp_level_b - zu ) )
2442          dp_level_ind_b = ind_array(1) - 1 + nzb 
2443                                        ! MINLOC uses lower array bound 1
2444       ENDIF
2445       IF ( dp_smooth )  THEN
[1340]2446          dp_smooth_factor(:dp_level_ind_b) = 0.0_wp
[240]2447          DO  k = dp_level_ind_b+1, nzt
[1340]2448             dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi *               &
2449                        ( REAL( k - dp_level_ind_b, KIND=wp ) /                &
2450                          REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) )
[240]2451          ENDDO
2452       ENDIF
2453    ENDIF
2454
2455!
[978]2456!-- Initialize damping zone for the potential temperature in case of
2457!-- non-cyclic lateral boundaries. The damping zone has the maximum value
2458!-- at the inflow boundary and decreases to zero at pt_damping_width.
[1340]2459    ptdf_x = 0.0_wp
2460    ptdf_y = 0.0_wp
[1159]2461    IF ( bc_lr_dirrad )  THEN
[996]2462       DO  i = nxl, nxr
[978]2463          IF ( ( i * dx ) < pt_damping_width )  THEN
[1340]2464             ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp *              &
2465                            REAL( pt_damping_width - i * dx, KIND=wp ) / (     &
[1788]2466                            REAL( pt_damping_width, KIND=wp ) ) ) )**2 
[73]2467          ENDIF
2468       ENDDO
[1159]2469    ELSEIF ( bc_lr_raddir )  THEN
[996]2470       DO  i = nxl, nxr
[978]2471          IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) )  THEN
[1322]2472             ptdf_x(i) = pt_damping_factor *                                   &
[1340]2473                         SIN( pi * 0.5_wp *                                    &
2474                                 ( ( i - nx ) * dx + pt_damping_width ) /      &
2475                                 REAL( pt_damping_width, KIND=wp ) )**2
[73]2476          ENDIF
[978]2477       ENDDO 
[1159]2478    ELSEIF ( bc_ns_dirrad )  THEN
[996]2479       DO  j = nys, nyn
[978]2480          IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) )  THEN
[1322]2481             ptdf_y(j) = pt_damping_factor *                                   &
[1340]2482                         SIN( pi * 0.5_wp *                                    &
2483                                 ( ( j - ny ) * dy + pt_damping_width ) /      &
2484                                 REAL( pt_damping_width, KIND=wp ) )**2
[1]2485          ENDIF
[978]2486       ENDDO 
[1159]2487    ELSEIF ( bc_ns_raddir )  THEN
[996]2488       DO  j = nys, nyn
[978]2489          IF ( ( j * dy ) < pt_damping_width )  THEN
[1322]2490             ptdf_y(j) = pt_damping_factor *                                   &
[1340]2491                         SIN( pi * 0.5_wp *                                    &
2492                                ( pt_damping_width - j * dy ) /                &
2493                                REAL( pt_damping_width, KIND=wp ) )**2
[1]2494          ENDIF
[73]2495       ENDDO
[1]2496    ENDIF
2497
2498!
[51]2499!-- User-defined initializing actions. Check afterwards, if maximum number
[709]2500!-- of allowed timeseries is exceeded
[1]2501    CALL user_init
2502
[51]2503    IF ( dots_num > dots_max )  THEN
[1788]2504       WRITE( message_string, * ) 'number of time series quantities exceeds',  &
2505                                  ' its maximum of dots_max = ', dots_max,     &
[254]2506                                  ' &Please increase dots_max in modules.f90.'
2507       CALL message( 'init_3d_model', 'PA0194', 1, 2, 0, 6, 0 )   
[51]2508    ENDIF
2509
[1]2510!
2511!-- Input binary data file is not needed anymore. This line must be placed
2512!-- after call of user_init!
2513    CALL close_file( 13 )
2514
[1402]2515    CALL location_message( 'leaving init_3d_model', .TRUE. )
[1]2516
2517 END SUBROUTINE init_3d_model
Note: See TracBrowser for help on using the repository browser.