source: palm/trunk/SOURCE/modules.f90 @ 3885

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

restructure/add location/debug messages

  • Property svn:keywords set to Id
File size: 146.1 KB
Line 
1!> @file modules.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
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.
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!
17! Copyright 1997-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: modules.f90 3885 2019-04-11 11:29:34Z kanani $
27! Changes related to global restructuring of location messages and introduction
28! of additional debug messages
29!
30! 3871 2019-04-08 14:38:39Z knoop
31! Initialized parameter region
32!
33! 3746 2019-02-16 12:41:27Z gronemeier
34! Removed most_method
35!
36! 3648 2019-01-02 16:35:46Z suehring
37! -surface_data_output +surface_output
38!
39! 3636 2018-12-19 13:48:34Z raasch
40! nopointer option removed
41!
42! 3597 2018-12-04 08:40:18Z maronga
43! Added flag parameter do_output_at_2m for automatic output of 2m-temperature
44!
45! 3589 2018-11-30 15:09:51Z suehring
46! Move the control parameter "salsa" from salsa_mod to control_parameters
47! (M. Kurppa)
48!
49! 3582 2018-11-29 19:16:36Z suehring
50! dom_dwd_user, Schrempf:
51! -uv_exposure flag, UV model is now part of biometeorology_mod
52!
53! 3543 2018-11-20 17:06:15Z suehring
54! +type_x_byte, type_y_byte
55!
56! 3542 2018-11-20 17:04:13Z suehring
57! +run_zone
58!
59! 3473 2018-10-30 20:50:15Z suehring
60! +virtual_measurement
61!
62! 3472 2018-10-30 20:43:50Z suehring
63! Add indoor model (kanani, srissman, tlang)
64!
65! 3467 2018-10-30 19:05:21Z suehring
66! Add biometeorology
67!
68! 3435 2018-10-26 18:25:44Z gronemeier
69! +mask_k_over_surface, mask_surface
70!
71! 3422 2018-10-24 19:01:57Z gronemeier
72! bugfix: increase number of blanks in output string
73!
74! 3421 2018-10-24 18:39:32Z gronemeier
75! Renamed output variables
76! +surface_data_output
77!
78! 3355 2018-10-16 14:03:34Z knoop
79! (from branch resler)
80! Increase dimension of uv_heights etc.
81!
82! 3302 2018-10-03 02:39:40Z raasch
83! +u/v_stokes_zu, u/v_stokes_zw
84!
85! 3298 2018-10-02 12:21:11Z kanani
86! Minor formatting/clean-up (kanani)
87! Added some variables for time treatment (Russo)
88!
89! 3294 2018-10-01 02:37:10Z raasch
90! ocean renamed ocean_mode
91!
92! 3289 2018-09-28 10:23:58Z suehring
93! +num_mean_inflow_profiles
94!
95! 3288 2018-09-28 10:23:08Z suehring
96! Modularization of all bulk cloud physics code components
97!
98! 3240 2018-09-12 12:04:40Z Giersch
99! max_pr_user_tmp has been defined as a control variable because it is not
100! local anymore
101!
102! 3235 2018-09-07 14:06:15Z sward
103! Added global variable dim_size_agtnum to own module. Necessary to avoid
104! circular dependency in agent output.
105!
106! 3232 2018-09-07 12:21:44Z raasch
107! references to mrun replaced by palmrun, and updated
108!
109! 3198 2018-08-15 09:23:10Z sward
110! Added multi_agent_system_end and multi_agent_system_start
111!
112! 3183 2018-07-27 14:25:55Z suehring
113! Rename offline nesting variables:
114! -inflow_l, inflow_n, inflow_r, inflow_s,
115!  nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, forcing,
116!  force_bound_l, force_bound_n, force_bound_r, force_bound_s, outflow_l,
117!  outflow_n, outflow_r, outflow_s
118! +bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_n, bc_dirichlet_r,
119!  bc_radiation_l, bc_radiation_n, bc_radiation_n, bc_radiation_r, child_domain
120!  nesting_offline
121!
122! 3182 2018-07-27 13:36:03Z suehring
123! Default value of dz_max has changed to a more uncommon value of 999 (value
124! of dz_max can not be part of dz values when using new stretching procedure)
125!
126! 3159 2018-07-20 11:20:01Z sward
127! Added multi agent system
128!
129! 3157 2018-07-19 21:08:49Z maronga
130! added use_free_convection_scaling
131!
132! 3129 2018-07-16 07:45:13Z gronemeier
133! add target attribute to km and kh, necessary for output in tcm_data_output_3d
134!
135! 3120 2018-07-11 18:30:57Z gronemeier
136! +les_dynamic
137!
138! 3083 2018-06-19 14:03:12Z gronemeier
139! set dt_3d = 0.01
140!
141! 3065 2018-06-12 07:03:02Z Giersch
142! Variables concerning stretching introduced or revised
143!
144! 3045 2018-05-28 07:55:41Z Giersch
145! z_max_do2d removed
146!
147! 3026 2018-05-22 10:30:53Z schwenkel
148! Changed the name specific humidity to mixing ratio, since we are computing
149! mixing ratios.
150!
151! 3014 2018-05-09 08:42:38Z maronga
152! Added default values of u_max, v_max, and w_max to avoid floating invalid
153! during spinup
154!
155! 3004 2018-04-27 12:33:25Z Giersch
156! precipitation_rate removed
157!
158! 3003 2018-04-23 10:22:58Z Giersch
159! The inversion height is defined as a global variable now which belongs to the
160! module statistics
161!
162! 2968 2018-04-13 11:52:24Z suehring
163! +topo_min_level
164!
165! 2964 2018-04-12 16:04:03Z raasch
166! *_time_count variables are all initialized with zero now
167!
168! 2918 2018-03-21 15:52:14Z gronemeier
169! -l_grid, -l_wall
170!
171! 2906 2018-03-19 08:56:40Z Giersch
172! Module control_parameters has been extended with ENVIRONMENT variables
173! read/write_svf
174!
175! 2894 2018-03-15 09:17:58Z Giersch
176! _prerun flags were removed, Control paramters restart_string and length have
177! been added
178!
179! 2881 2018-03-13 16:24:40Z suehring
180! Added flag for switching on/off calculation of soil moisture
181!
182! 2797 2018-02-08 13:24:35Z suehring
183! +ghf_av
184!
185! 2776 2018-01-31 10:44:42Z Giersch
186! Variable synthetic_turbulence_generator has been abbreviated and _prerun flags
187! for skipping module related restart data has beed introduced
188!
189! 2765 2018-01-22 11:34:58Z maronga
190! Set initial value for time_since_reference_point
191!
192! 2746 2018-01-15 12:06:04Z suehring
193! +plant_canopy
194!
195! 2742 2018-01-12 14:59:47Z suehring
196! +tsurf_av
197!
198! 2735 2018-01-11 12:01:27Z suehring
199! +r_a_av
200!
201! 2718 2018-01-02 08:49:38Z maronga
202! Corrected "Former revisions" section
203!
204! 2696 2017-12-14 17:12:51Z kanani
205! Change in file header (GPL part)
206! Implementation of uv exposure model (FK)
207! + turbulence closure variables (control_parameters)
208! + arrays for prognostic equation of disspiation (arrays_3d)
209! + km_av, kh_av (TG)
210! Implementation of chemistry module (FK)
211! -lod
212! +topo_distinct (MS)
213!
214! 2669 2017-12-06 16:03:27Z raasch
215! CONTIGUOUS-attribut added to 3d pointer arrays,
216! coupling_char extended to LEN=8
217!
218! 2575 2017-10-24 09:57:58Z maronga
219! Renamed phi -> latitude, moved longitude from radiation model to modules
220!
221! 2563 2017-10-19 15:36:10Z Giersch
222! Variable wind_turbine was added to control_parameters
223!
224! 2550 2017-10-16 17:12:01Z boeske
225! complex_terrain namelist parameter added
226!
227! 2508 2017-10-02 08:57:09Z suehring
228! Change default value for pt/q/s/sa_vertical_gradient_level
229!
230! 2499 2017-09-22 16:47:58Z kanani
231! Default changed to fft_method = 'temperton-algorithm'
232!
233! 2408 2017-09-05 15:47:53Z gronemeier
234! Changed default value of mg_cycles from -1 to 4.
235!
236! 2375 2017-08-29 14:10:28Z schwenkel
237! Moved mass_of_solute, molecular_weight_of_solute, molecular_weight_of_water,
238! vanthoff back from particle attributes because they can now also be used in
239! bulk microphysics.
240! Added aerosol_bulk, aerosol_nacl, aerosol_c3h4o4, aerosol_nh4no3
241!
242! 2372 2017-08-25 12:37:32Z sward
243! y_shift namelist parameter added
244!
245! 2339 2017-08-07 13:55:26Z gronemeier
246! corrected timestamp in header
247!
248! 2338 2017-08-07 12:15:38Z gronemeier
249! moved 1d-model varaibles to own module model_1d_mod
250!
251! 2337 2017-08-07 08:59:53Z gronemeier
252! -old_dt_1d
253! +l1d_diss
254!
255! 2326 2017-08-01 07:23:24Z gronemeier
256! Updated variable descriptions
257!
258! 2320 2017-07-21 12:47:43Z suehring
259! -ptnudge, qnudge, tnudge, td_lsa_lpt, td_lsa_q, td_sub_lpt, td_sub_q, ug_vert,
260!  vg_vert, unudge, vnudge, wsubs_vert, shf_surf, p_surf, pt_surf, q_surt,
261!  qsws_surf, tmp_tnudge, timenudge, time_surf, time_vert
262!
263! 2300 2017-06-29 13:31:14Z raasch
264! default value for host changed to '????', default value for loop_optimization
265! changed to 'cache', default value for termination_time_needed set to 35.0
266!
267! 2298 2017-06-29 09:28:18Z raasch
268! missing variable descriptions have been added,
269! type of write_binary changed from CHARACTER to LOGICAL
270! -plot_precision, plot_3d_precision, return_addres, return_username,
271! avs_data_file, exchange_mg, sendrecvcound_yxd, sendrecv_in_background,
272! port_name, profile_number, cross_ts_numbers, cross_ts_number_count,
273! dots_crossindex, dots_index, cross_ts_uymax, cross_ts_uymax_computed,
274! cross_ts_uymin, cross_ts_uymin_computed
275!
276! 2296 2017-06-28 07:53:56Z maronga
277! Added parameters for model spinup
278!
279! 2292 2017-06-20 09:51:42Z schwenkel
280! Implementation of new microphysic scheme: cloud_scheme = 'morrison'
281! includes two more prognostic equations for cloud drop concentration (nc) 
282! and cloud water content (qc).
283!
284! 2277 2017-06-12 10:47:51Z kanani
285! Added doxygen comments for variables/parameters,
286! removed unused variables dissipation_control, do2d_xy_n, do2d_xz_n, do2d_yz_n,
287! do3d_avs_n, lptnudge, lqnudge, lunudge, lvnudge, lwnudge, skip_do_avs,
288! sums_up_fraction_l.
289!
290! 2259 2017-06-08 09:09:11Z gronemeier
291! Implemented synthetic turbulence generator
292!
293! 2256 2017-06-07 13:58:08Z suehring
294! Change default value of zeta_min to -20
295! Increase dimension for wall_heatflux, etc.
296!
297! 2233 2017-05-30 18:08:54Z suehring
298!
299! 2232 2017-05-30 17:47:52Z suehring
300! Renamed wall_flags_0 and wall_flags_00 into advc_flags_1 and advc_flags_2,
301! respectively. Moreover, introduced further flag array wall_flags_0.
302!
303! Adjustments for new topography concept:
304!   -fwxm, fwxp, fwym, fwyp, fxm, fxp, fym, fyp, rif_wall, wall_e_x, wall_e_y,
305!   -wall_v, wall_u, wall_w_x, wall_w_y, wall_qflux, wall_sflux, wall_nrflux,
306!   -wall_qrflux
307!
308! Adjustments for new surface concept:
309!   +land_surface
310!   -z0, z0h, z0q, us, ts, qs, qsws, nrs, nrsws, qrs, qrsws, ssws, ss, saswsb
311!   -nzb_diff_u, nzb_diff_v, nzt_diff
312!   -uswst, vswst, tswst, sswst, saswst, qswst, qrswst, nrswst, qswst_remote
313!
314! Generic tunnel setup:
315!   +tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,
316!   +tunnel_wall_depth
317!
318! Topography input via netcdf
319!   +lod
320!
321! 2200 2017-04-11 11:37:51Z suehring
322! -monotonic_adjustment
323!
324! 2174 2017-03-13 08:18:57Z maronga
325! Changed default values for most_method to 'newton'
326!
327! 2118 2017-01-17 16:38:49Z raasch
328! -acc_rank, background_communication, i_left, i_right, j_south, j_north,
329!  num_acc_per_node, on_device
330!
331! 2107 2017-01-09 12:21:49Z kanani
332! Preparation for doxygen comments (Giersch)
333!
334! 2050 2016-11-08 15:00:55Z gronemeier
335! Implement turbulent outflow condition
336!
337! 2037 2016-10-26 11:15:40Z knoop
338! Anelastic approximation implemented
339!
340! 2031 2016-10-21 15:11:58Z knoop
341! renamed variable rho to rho_ocean and rho_av to rho_ocean_av
342!
343! 2011 2016-09-19 17:29:57Z kanani
344! +urban_surface, +lsf_exception, +varnamelength
345!
346! 2007 2016-08-24 15:47:17Z kanani
347! Increased DIMENSION of data_output, data_output_user, do2d, do3d
348!
349! 2000 2016-08-20 18:09:15Z knoop
350! Forced header and separation lines into 80 columns
351!
352! 1992 2016-08-12 15:14:59Z suehring
353! +constant_top_scalarflux, top_scalarflux
354! default of bc_s_t adjusted
355!
356! 1968 2016-07-18 12:01:49Z suehring
357! Changed dimension for MPI-datatypes type_x_int and type_y_int
358!
359! 1960 2016-07-12 16:34:24Z suehring
360! Separate humidity and passive scalar
361! +bc_s_t_val, diss_s_s, diss_l_s, flux_s_s, flux_l_s, s, sp, s1, s2, s3, ssws_av,
362!  s_init, s_surf, sums_wsss_ws_l, ss, ssws, sswst, ts_m, wall_sflux
363! +constant_scalarflux, ibc_s_b, ibc_s_t, s_vertical_gradient_level_ind
364!
365! Unused variables removed
366! -gamma_x, gamma_y, gamma_z, var_x, var_y, var_z
367!
368! Change initial values (in order to unify gradient calculation):
369! pt_vertical_gradient_level, sa_vertical_gradient_level
370!
371! 1957 2016-07-07 10:43:48Z suehring
372! +fl_max, num_leg, num_var_fl, num_var_fl_user, var_fl_max, virtual_flight
373!
374! 1918 2016-05-27 14:35:57Z raasch
375! default timestep switched from -1.0 to +1.0 in order to avoid wrong sign of
376! initially calculated divergence
377!
378! 1906 2016-05-24 14:38:08Z suehring
379! default value of mg_switch_to_pe0_level changed to -1
380!
381! 1849 2016-04-08 11:33:18Z hoffmann
382! bfactor, mass_of_solute, molecular_weight_of_solute, molecular_weight_of_water,
383! vanthoff moved to mod_particle_attributes.
384! dt_micro and several cloud_parameters moved to microphysics_mod.
385! 1d-microphysics profiles moved to microphysics_mod.
386!
387! 1845 2016-04-08 08:29:13Z raasch
388! -nzb_2d
389!
390! 1833 2016-04-07 14:23:03Z raasch
391! spectra parameter moved to spectra module
392!
393! 1831 2016-04-07 13:15:51Z hoffmann
394! curvature_solution_effects removed
395! turbulence renamed collision_turbulence, drizzle renamed
396! cloud_water_sedimentation
397!
398! 1822 2016-04-07 07:49:42Z hoffmann
399! icloud_scheme removed. microphysics_sat_adjust, microphysics_kessler,
400! microphysics_seifert added.
401!
402! 1815 2016-04-06 13:49:59Z raasch
403! cpp-directive for decalpha removed
404!
405! 1808 2016-04-05 19:44:00Z raasch
406! MPI module used by default on all machines
407!
408! 1804 2016-04-05 16:30:18Z maronga
409! Removed code for parameter file check (__check)
410!
411! 1788 2016-03-10 11:01:04Z maronga
412! Added roughness length for moisture (z0q)
413!
414! 1786 2016-03-08 05:49:27Z raasch
415! module spectrum moved to new separate module
416!
417! 1783 2016-03-06 18:36:17Z raasch
418! netcdf variables moved to the netcdf-interface module
419!
420! 1779 2016-03-03 08:01:28Z raasch
421! coupling_char extended to LEN=3
422!
423! 1764 2016-02-28 12:45:19Z raasch
424! some reformatting
425!
426! 1762 2016-02-25 12:31:13Z hellstea
427! +nest_* variables, size of volume_flow arrays increased by one element
428!
429! 1738 2015-12-18 13:56:05Z raasch
430! +mean_surface_level_height
431!
432! 1695 2015-10-27 10:03:11Z maronga
433! Removed rif (forgotten in last revision)
434!
435! 1693 2015-10-27 08:35:45Z maronga
436! Renamed zp -> z_mo
437!
438! 1691 2015-10-26 16:17:44Z maronga
439! Renamed Obukhov length. Added ol, removed rif. Increased number of profiles
440! (pr_palm). Changed default values for dissipation_1d to 'detering' and
441! (mixing_length_1d to 'blackadar'. Added most_method. rif_min and rif_max
442! renamed to zeta_min and zeta_max and new values assigned.
443!
444! 1682 2015-10-07 23:56:08Z knoop
445! Code annotations made doxygen readable
446!
447! 1677 2015-10-02 13:25:23Z boeske
448! +ngp_yz_int, type_xz_int, type_yz_int
449!
450! 1666 2015-09-23 07:31:10Z raasch
451! +user_interface_current_revision, user_interface_required_revision in
452! control_parameters
453!
454! 1639 2015-08-31 14:46:48Z knoop
455! Bugfix: string 'unknown' extended to match LEN=13
456!
457! 1575 2015-03-27 09:56:27Z raasch
458! +ngp_xz
459!
460! 1560 2015-03-06 10:48:54Z keck
461! +recycling_yshift
462!
463! 1557 2015-03-05 16:43:04Z suehring
464! +monotonic_adjustment
465!
466! 1551 2015-03-03 14:18:16Z maronga
467! Increased pr_palm to 120. Increased length of dots_unit and dots_label to 13
468! digits. Increased length of domask, do2d, and do3d to 20 digits.
469!
470! 1496 2014-12-02 17:25:50Z maronga
471! Renamed "radiation" -> "cloud_top_radiation"
472!
473! 1484 2014-10-21 10:53:05Z kanani
474! Changes due to new module structure of the plant canopy model:
475!   canopy-model related parameters/variables moved to module
476!   plant_canopy_model_mod
477!
478! 1468 2014-09-24 14:06:57Z maronga
479! Adapted for use on up to 6-digit processor cores.
480! Increased identifier string length for user-defined quantities to 20.
481!
482! 1450 2014-08-21 07:31:51Z heinze
483! ntnudge from 100 to 1000 increased to allow longer simulations
484!
485! 1431 2014-07-15 14:47:17Z suehring
486! +var_d
487!
488! 1429 2014-07-15 12:53:45Z knoop
489! +ensemble_member_nr to prepare the random_generator for ensemble runs
490!
491! 1382 2014-04-30 12:15:41Z boeske
492! Renamed variables which store large scale forcing tendencies
493! pt_lsa -> td_lsa_lpt, pt_subs -> td_sub_lpt,
494! q_lsa  -> td_lsa_q,   q_subs  -> td_sub_q
495!
496! 1365 2014-04-22 15:03:56Z boeske
497! Usage of large scale forcing enabled:
498! increase pr_palm from 90 to 100 to allow for more standard profiles
499! + ngp_sums_ls, pt_lsa, pt_subs, q_lsa, q_subs, tmp_tnudge, sums_ls_l,
500! use_subsidence_tendencies
501!
502! 1361 2014-04-16 15:17:48Z hoffmann
503! tend_* removed
504! call_microphysics_at_all_substeps added
505! default of drizzle set to true
506!
507! 1359 2014-04-11 17:15:14Z hoffmann
508! particle_attributes moved to mod_particle_attributes.f90
509!
510! 1353 2014-04-08 15:21:23Z heinze
511! REAL constants provided with KIND-attribute
512!
513! 1327 2014-03-21 11:00:16Z raasch
514! REAL constants defined as wp-kind
515! -avs_output, data_output_format, do3d_compress, iso2d_output, netcdf_output
516!
517! 1320 2014-03-20 08:40:49Z raasch
518! ONLY-attribute added to USE-statements,
519! kind-parameters added to all INTEGER and REAL declaration statements,
520! kinds are defined in new module kinds,
521! old module precision_kind is removed,
522! revision history before 2012 removed,
523! comment fields (!:) to be used for variable explanations added to
524! all variable declaration statements
525!
526! 1318 2014-03-17 13:35:16Z raasch
527! module cpulog moved to new separate module-file
528! interface for cpu_log removed
529!
530! 1314 2014-03-14 18:25:17Z suehring
531! + log_z_z0, number_of_sublayers, z0_av_global
532! 1308 2014-03-13 14:58:42Z fricke
533! +ntdim_2d_xy, ntdim_2d_xz, ntdim_2d_yz, ntdim_3d
534!
535! 1257 2013-11-08 15:18:40Z raasch
536! set default values for grid indices of maximum velocity components
537! u|v|w_max_ijk
538!
539! 1241 2013-10-30 11:36:58Z heinze
540! Usage of nudging enabled
541! +nudging, ntnudge, ptnudge, qnudge, tnudge, unudge, vnudge, wnudge
542! increase pr_palm from 80 to 90 to allow for more standard profiles
543!
544! Enable prescribed time depenend surface fluxes and geostrophic wind read in
545! from external file LSF_DATA
546! +large_scale_forcing, lsf_surf, lsf_vert, nlsf, time_surf, shf_surf, qsws_surf,
547!  pt_surf, q_surf, p_surf, time_vert, ug_vert, vg_vert, wsubs_vert
548!
549! 1221 2013-09-10 08:59:13Z raasch
550! wall_flags_0 changed to 32bit int, +wall_flags_00,
551! +rflags_s_inner, rflags_invers
552!
553! 1216 2013-08-26 09:31:42Z raasch
554! +transpose_compute_overlap,
555! several variables are now defined in the serial (non-parallel) case also
556!
557! 1212 2013-08-15 08:46:27Z raasch
558! +tri
559!
560! 1179 2013-06-14 05:57:58Z raasch
561! +reference_state, ref_state, use_initial_profile_as_reference, vpt_reference,
562! use_reference renamed use_single_reference_value
563!
564! 1159 2013-05-21 11:58:22Z fricke
565! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir
566! +use_cmax
567!
568! 1128 2013-04-12 06:19:32Z raasch
569! +background_communication, i_left, i_right, j_north, j_south, req, req_count,
570! send_receive, sendrecv_in_background, wait_stat
571!
572! 1115 2013-03-26 18:16:16Z hoffmann
573! unused variables removed
574!
575! 1113 2013-03-10 02:48:14Z raasch
576! +on_device
577!
578! 1111 2013-03-08 23:54:10Z raasch
579! +tric, nr_timesteps_this_run
580!
581! 1106 2013-03-04 05:31:38Z raasch
582! array_kind renamed precision_kind, pdims defined in serial code
583! bugfix: default value assigned to coupling_start_time
584!
585! 1095 2013-02-03 02:21:01Z raasch
586! FORTRAN error in r1092 removed
587!
588! 1092 2013-02-02 11:24:22Z raasch
589! character length in some derived type changed for better alignment
590!
591! 1065 2012-11-22 17:42:36Z hoffmann
592! + c_sedimentation, limiter_sedimentation, turbulence, a_1, a_2, a_3, b_1, b_2,
593! + b_3, c_1, c_2, c_3, beta_cc
594!
595! bottom boundary condition of qr, nr changed from Dirichlet to Neumann
596!
597! 1053 2012-11-13 17:11:03Z hoffmann
598! necessary expansions according to the two new prognostic equations (nr, qr)
599! of the two-moment cloud physics scheme:
600! +*_init, flux_l_*, diss_l_*, flux_s_*, diss_s_*, *sws, *swst, tend_*, *, *_p
601! +t*_m, *_1, *_2, *_3, *_av, bc_*_b, bc_*_t, ibc_*_b, ibc_*_t, bc_*_t_val,
602! +*_vertical_gradient, *_surface_initial_change, *_vertical_gradient_level,
603! +*_vertical_gradient_level_ind, *_surface, constant_waterflux_*, 
604! +cloud_scheme, icloud_scheme, surface_waterflux_*, sums_ws*s_ws_l, wall_*flux
605!
606! constants for the two-moment scheme:
607! +a_vent, a_term, b_vent, b_term, c_evap, c_term, cof, eps_sb, k_cc, k_cr, k_rr,
608! +k_br, kappa_rr, kin_vis_air, mu_constant_value, nc, pirho_l, dpirho_l, rho_1,
609! +schmidt, schmidt_p_1d3, stp, x0, xmin, xmax, dt_precipitation, w_precipitation
610!
611! steering parameters for the two_moment scheme:
612! +mu_constant, ventilation_effect
613!
614! 1036 2012-10-22 13:43:42Z raasch
615! code put under GPL (PALM 3.9)
616!
617! 1031 2012-10-19 14:35:30Z raasch
618! +output_format_netcdf
619!
620! 1015 2012-09-27 09:23:24Z raasch
621! +acc_rank, num_acc_per_node,
622! -adjust_mixing_length
623!
624! 1010 2012-09-20 07:59:54Z raasch
625! pointer free version can be generated with cpp switch __nopointer
626!
627! 1003 2012-09-14 14:35:53Z raasch
628! -grid_matching, nxa, nya, etc., nnx_pe, nny_pe, spl_*
629!
630! 1001 2012-09-13 14:08:46Z raasch
631! -asselin_filter_factor, cut_spline_overshoot, dt_changed, last_dt_change,
632! last_dt_change_1d, long_filter_factor, overshoot_limit_*, ups_limit_*
633! several pointer/target arrays converted to normal ones
634!
635! 996 2012-09-07 10:41:47Z raasch
636! -use_prior_plot1d_parameters
637!
638! 978 2012-08-09 08:28:32Z fricke
639! +c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l,
640! +bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir
641! -km_damp_x, km_damp_y, km_damp_max, outflow_damping_width
642! +z0h, z0h_av, z0h_factor, z0h1d
643! +ptdf_x, ptdf_y, pt_damping_width, pt_damping_factor
644!
645! 964 2012-07-26 09:14:24Z raasch
646! -cross_linecolors, cross_linestyles, cross_normalized_x, cross_normx_factor,
647! cross_normalized_y, cross_normy_factor, cross_pnc_local,
648! cross_profile_numbers, cross_profile_number_counter, cross_uxmax,
649! cross_uxmax_computed, cross_uxmax_normalized,
650! cross_uxmax_normalized_computed, cross_uxmin, cross_uxmin_computed,
651! cross_uxmin_normalized, cross_uxmin_normalized_computed, cross_uymax,
652! cross_uymin, cross_xtext, dopr_crossindex, dopr_label, linecolors, linestyles,
653! nz_do1d, profil_output, z_max_do1d, z_max_do1d_normalized
654!
655! 951 2012-07-19 14:22:52Z hoffmann
656! changing profile_columns and profile_rows
657!
658! 940 2012-07-09 14:31:00Z raasch
659! +neutral
660!
661! 927 2012-06-06 19:15:04Z raasch
662! +masking_method
663!
664! 880 2012-04-13 06:28:59Z raasch
665! gathered_size, subdomain_size moved to control_parameters
666!
667! 866 2012-03-28 06:44:41Z raasch
668! interface for global_min_max changed
669!
670! 861 2012-03-26 14:18:34Z suehring
671! +wall_flags_0
672! -boundary_flags
673! +nzb_max
674! +adv_sca_1, +adv_mom_1
675!
676! 849 2012-03-15 10:35:09Z raasch
677! +deleted_particles, deleted_tails, tr.._count_sum, tr.._count_recv_sum in
678! particle_attributes,
679! +de_dx, de_dy, de_dz in arrays_3d,
680! first_call_advec_particles renamed first_call_lpm
681!
682! 828 2012-02-21 12:00:36Z raasch
683! +dissipation_classes, radius_classes, use_kernel_tables,
684! particle feature color renamed class
685!
686! 825 2012-02-19 03:03:44Z raasch
687! +bfactor, curvature_solution_effects, eps_ros, molecular_weight_of_water,
688! vanthoff, -b_cond in cloud_parameters,
689! dopts_num increased to 29, particle attributes speed_x|y|z_sgs renamed
690! rvar1|2|3
691! wang_collision_kernel and turbulence_effects_on_collision replaced by
692! collision_kernel, hall_kernel, palm_kernel, wang_kernel
693!
694! 809 2012-01-30 13:32:58Z marongas
695! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
696!
697! 807 2012-01-25 11:53:51Z maronga
698! New cpp directive "__check" implemented which is used by check_namelist_files.
699! New parameter check_restart has been defined which is needed by
700! check_namelist_files only.
701!
702! 805 2012-01-17 15:53:28Z franke
703! Bugfix collective_wait must be out of parallel branch for runs in serial mode
704!
705! 801 2012-01-10 17:30:36Z suehring
706! Dimesion of sums_wsus_ws_l, ! sums_wsvs_ws_l, sums_us2_ws_l, sums_vs2_ws_l,
707! sums_ws2_ws_l, sums_wspts_ws_l, sums_wsqs_ws_l, sums_wssas_ws_l increased.
708! for thread-safe summation in advec_ws.
709!
710! RCS Log replace by Id keyword, revision history cleaned up
711!
712! Revision 1.95  2007/02/11 13:18:30  raasch
713! version 3.1b (last under RCS control)
714!
715! Revision 1.1  1997/07/24 11:21:26  raasch
716! Initial revision
717!
718!
719!------------------------------------------------------------------------------!
720! Description:
721! ------------
722!> Definition of global variables
723!------------------------------------------------------------------------------!
724
725
726!------------------------------------------------------------------------------!
727! Description:
728! ------------
729!> Definition of variables for special advection schemes.
730!------------------------------------------------------------------------------!
731 MODULE advection
732 
733    USE kinds
734
735    REAL(wp), DIMENSION(:), ALLOCATABLE ::  aex  !< exponential coefficient for the Bott-Chlond advection scheme
736    REAL(wp), DIMENSION(:), ALLOCATABLE ::  bex  !< exponential coefficient for the Bott-Chlond advection scheme
737    REAL(wp), DIMENSION(:), ALLOCATABLE ::  dex  !< exponential coefficient for the Bott-Chlond advection scheme
738    REAL(wp), DIMENSION(:), ALLOCATABLE ::  eex  !< exponential coefficient for the Bott-Chlond advection scheme
739   
740    SAVE
741
742 END MODULE advection
743
744
745
746!------------------------------------------------------------------------------!
747! Description:
748! ------------
749!> The variable in this module is used by multi_agent_system_mod AND
750!> netcdf_interface_mod. It must be here to avoid circular dependency.
751!> This is a workaround.
752!------------------------------------------------------------------------------!
753 MODULE mas_global_attributes
754 
755    USE kinds
756
757    INTEGER(iwp) ::  dim_size_agtnum  !< size of agent number dimension for netCDF output
758
759    SAVE
760
761 END MODULE mas_global_attributes
762
763
764!------------------------------------------------------------------------------!
765! Description:
766! ------------
767!> Definition of all arrays defined on the computational grid.
768!------------------------------------------------------------------------------!
769 MODULE arrays_3d
770
771    USE kinds
772
773    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_u_m                  !< mean phase velocity at outflow for u-component used in radiation boundary condition
774    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_u_m_l                !< mean phase velocity at outflow for u-component used in radiation boundary condition (local subdomain value)
775    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_v_m                  !< mean phase velocity at outflow for v-component used in radiation boundary condition
776    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_v_m_l                !< mean phase velocity at outflow for v-component used in radiation boundary condition (local subdomain value)
777    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_w_m                  !< mean phase velocity at outflow for w-component used in radiation boundary condition
778    REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_w_m_l                !< mean phase velocity at outflow for w-component used in radiation boundary condition (local subdomain value)
779    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ddzu                   !< 1/dzu
780    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ddzu_pres              !< modified ddzu for pressure solver
781    REAL(wp), DIMENSION(:), ALLOCATABLE ::  dd2zu                  !< 1/(dzu(k)+dzu(k+1))
782    REAL(wp), DIMENSION(:), ALLOCATABLE ::  dzu                    !< vertical grid size (u-grid)
783    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ddzw                   !< 1/dzw
784    REAL(wp), DIMENSION(:), ALLOCATABLE ::  dzw                    !< vertical grid size (w-grid)
785    REAL(wp), DIMENSION(:), ALLOCATABLE ::  hyp                    !< hydrostatic pressure
786    REAL(wp), DIMENSION(:), ALLOCATABLE ::  inflow_damping_factor  !< used for turbulent inflow (non-cyclic boundary conditions)
787    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ptdf_x                 !< damping factor for potential temperature in x-direction
788    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ptdf_y                 !< damping factor for potential temperature in y-direction
789    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pt_init                !< initial profile of potential temperature
790    REAL(wp), DIMENSION(:), ALLOCATABLE ::  q_init                 !< initial profile of total water mixing ratio
791                                                                   !< (or total water content with active cloud physics)
792    REAL(wp), DIMENSION(:), ALLOCATABLE ::  rdf                    !< rayleigh damping factor for velocity components
793    REAL(wp), DIMENSION(:), ALLOCATABLE ::  rdf_sc                 !< rayleigh damping factor for scalar quantities
794    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ref_state              !< reference state of potential temperature
795                                                                   !< (and density in case of ocean simulation)
796    REAL(wp), DIMENSION(:), ALLOCATABLE ::  s_init                 !< initial profile of passive scalar concentration
797    REAL(wp), DIMENSION(:), ALLOCATABLE ::  sa_init                !< initial profile of salinity (ocean)
798    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ug                     !< geostrophic wind component in x-direction
799    REAL(wp), DIMENSION(:), ALLOCATABLE ::  u_init                 !< initial profile of horizontal velocity component u
800    REAL(wp), DIMENSION(:), ALLOCATABLE ::  u_stokes_zu            !< u-component of Stokes drift velocity at zu levels
801    REAL(wp), DIMENSION(:), ALLOCATABLE ::  u_stokes_zw            !< u-component of Stokes drift velocity at zw levels
802    REAL(wp), DIMENSION(:), ALLOCATABLE ::  vg                     !< geostrophic wind component in y-direction
803    REAL(wp), DIMENSION(:), ALLOCATABLE ::  v_init                 !< initial profile of horizontal velocity component v
804    REAL(wp), DIMENSION(:), ALLOCATABLE ::  v_stokes_zu            !< v-component of Stokes drift velocity at zu levels
805    REAL(wp), DIMENSION(:), ALLOCATABLE ::  v_stokes_zw            !< v-component of Stokes drift velocity at zw levels
806    REAL(wp), DIMENSION(:), ALLOCATABLE ::  w_subs                 !< subsidence/ascent velocity
807    REAL(wp), DIMENSION(:), ALLOCATABLE ::  x                      !< horizontal grid coordinate of v-grid (in m)
808    REAL(wp), DIMENSION(:), ALLOCATABLE ::  xu                     !< horizontal grid coordinate of u-grid (in m)
809    REAL(wp), DIMENSION(:), ALLOCATABLE ::  y                      !< horizontal grid coordinate of u-grid (in m)
810    REAL(wp), DIMENSION(:), ALLOCATABLE ::  yv                     !< horizontal grid coordinate of v-grid (in m)
811    REAL(wp), DIMENSION(:), ALLOCATABLE ::  zu                     !< vertical grid coordinate of u-grid (in m)
812    REAL(wp), DIMENSION(:), ALLOCATABLE ::  zw                     !< vertical grid coordinate of w-grid (in m)
813
814    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  c_u                   !< phase speed of u-velocity component
815    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  c_v                   !< phase speed of v-velocity component
816    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  c_w                   !< phase speed of w-velocity component
817    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_diss           !< artificial numerical dissipation flux at south face of grid box - TKE dissipation
818    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_e              !< artificial numerical dissipation flux at south face of grid box - subgrid-scale TKE
819    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_nc             !< artificial numerical dissipation flux at south face of grid box - clouddrop-number concentration   
820    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_nr             !< artificial numerical dissipation flux at south face of grid box - raindrop-number concentration   
821    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_pt             !< artificial numerical dissipation flux at south face of grid box - potential temperature
822    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_q              !< artificial numerical dissipation flux at south face of grid box - mixing ratio
823    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_qc             !< artificial numerical dissipation flux at south face of grid box - cloudwater
824    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_qr             !< artificial numerical dissipation flux at south face of grid box - rainwater
825    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_s              !< artificial numerical dissipation flux at south face of grid box - passive scalar
826    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_sa             !< artificial numerical dissipation flux at south face of grid box - salinity
827    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_u              !< artificial numerical dissipation flux at south face of grid box - u-component
828    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_v              !< artificial numerical dissipation flux at south face of grid box - v-component
829    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_w              !< artificial numerical dissipation flux at south face of grid box - w-component
830    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  dzu_mg                !< vertical grid size (u-grid) for multigrid pressure solver
831    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  dzw_mg                !< vertical grid size (w-grid) for multigrid pressure solver
832    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_diss           !< 6th-order advective flux at south face of grid box - TKE dissipation
833    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_e              !< 6th-order advective flux at south face of grid box - subgrid-scale TKE
834    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_nc             !< 6th-order advective flux at south face of grid box - clouddrop-number concentration
835    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_nr             !< 6th-order advective flux at south face of grid box - raindrop-number concentration
836    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_pt             !< 6th-order advective flux at south face of grid box - potential temperature
837    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_q              !< 6th-order advective flux at south face of grid box - mixing ratio
838    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_qc             !< 6th-order advective flux at south face of grid box - cloudwater
839    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_qr             !< 6th-order advective flux at south face of grid box - rainwater
840    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_s              !< 6th-order advective flux at south face of grid box - passive scalar
841    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_sa             !< 6th-order advective flux at south face of grid box - salinity
842    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_u              !< 6th-order advective flux at south face of grid box - u-component
843    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_v              !< 6th-order advective flux at south face of grid box - v-component
844    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_w              !< 6th-order advective flux at south face of grid box - w-component
845    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  f1_mg                 !< grid factor used in right hand side of Gauss-Seidel equation (multigrid)
846    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  f2_mg                 !< grid factor used in right hand side of Gauss-Seidel equation (multigrid)
847    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  f3_mg                 !< grid factor used in right hand side of Gauss-Seidel equation (multigrid)
848    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  mean_inflow_profiles  !< used for turbulent inflow (non-cyclic boundary conditions)
849    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  precipitation_amount  !< precipitation amount due to gravitational settling (bulk microphysics)
850    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  pt_slope_ref          !< potential temperature in rotated coordinate system
851                                                                    !< (in case of sloped surface)
852    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  total_2d_a            !< horizontal array to store the total domain data, used for atmosphere-ocean coupling (atmosphere data)
853    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  total_2d_o            !< horizontal array to store the total domain data, used for atmosphere-ocean coupling (ocean data)
854   
855    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  d           !< divergence
856    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  de_dx       !< gradient of sgs tke in x-direction (lpm)
857    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  de_dy       !< gradient of sgs tke in y-direction (lpm)
858    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  de_dz       !< gradient of sgs tke in z-direction (lpm)
859    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_diss !< artificial numerical dissipation flux at left face of grid box - TKE dissipation
860    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_e    !< artificial numerical dissipation flux at left face of grid box - subgrid-scale TKE
861    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_nc   !< artificial numerical dissipation flux at left face of grid box - clouddrop-number concentration
862    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_nr   !< artificial numerical dissipation flux at left face of grid box - raindrop-number concentration
863    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_pt   !< artificial numerical dissipation flux at left face of grid box - potential temperature
864    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_q    !< artificial numerical dissipation flux at left face of grid box - mixing ratio
865    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_qc   !< artificial numerical dissipation flux at left face of grid box - cloudwater
866    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_qr   !< artificial numerical dissipation flux at left face of grid box - rainwater
867    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_s    !< artificial numerical dissipation flux at left face of grid box - passive scalar
868    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_sa   !< artificial numerical dissipation flux at left face of grid box - salinity
869    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_u    !< artificial numerical dissipation flux at left face of grid box - u-component
870    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_v    !< artificial numerical dissipation flux at left face of grid box - v-component
871    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_w    !< artificial numerical dissipation flux at left face of grid box - w-component
872    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_diss !< 6th-order advective flux at south face of grid box - TKE dissipation
873    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_e    !< 6th-order advective flux at south face of grid box - subgrid-scale TKE
874    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_nc   !< 6th-order advective flux at south face of grid box - clouddrop-number concentration
875    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_nr   !< 6th-order advective flux at south face of grid box - raindrop-number concentration
876    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_pt   !< 6th-order advective flux at south face of grid box - potential temperature
877    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_q    !< 6th-order advective flux at south face of grid box - mixing ratio
878    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_qc   !< 6th-order advective flux at south face of grid box - cloudwater
879    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_qr   !< 6th-order advective flux at south face of grid box - rainwater
880    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_s    !< 6th-order advective flux at south face of grid box - passive scalar
881    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_sa   !< 6th-order advective flux at south face of grid box - salinity
882    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_u    !< 6th-order advective flux at south face of grid box - u-component
883    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_v    !< 6th-order advective flux at south face of grid box - v-component
884    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_w    !< 6th-order advective flux at south face of grid box - w-component
885    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  kh  !< eddy diffusivity for heat
886    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  km  !< eddy diffusivity for momentum
887    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  prr         !< rain rate
888    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  p_loc       !< local array in multigrid/sor solver containing the pressure which is iteratively advanced in each iteration step
889    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  tend        !< tendency field (time integration)
890    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  tric        !< coefficients of the tridiagonal matrix for solution of the Poisson equation in Fourier space
891    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_m_l       !< velocity data (u at left boundary) from time level t-dt required for radiation boundary condition
892    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_m_n       !< velocity data (u at north boundary) from time level t-dt required for radiation boundary condition
893    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_m_r       !< velocity data (u at right boundary) from time level t-dt required for radiation boundary condition
894    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_m_s       !< velocity data (u at south boundary) from time level t-dt required for radiation boundary condition
895    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_m_l       !< velocity data (v at left boundary) from time level t-dt required for radiation boundary condition
896    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_m_n       !< velocity data (v at north boundary) from time level t-dt required for radiation boundary condition
897    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_m_r       !< velocity data (v at right boundary) from time level t-dt required for radiation boundary condition
898    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_m_s       !< velocity data (v at south boundary) from time level t-dt required for radiation boundary condition
899    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_m_l       !< velocity data (w at left boundary) from time level t-dt required for radiation boundary condition
900    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_m_n       !< velocity data (w at north boundary) from time level t-dt required for radiation boundary condition
901    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_m_r       !< velocity data (w at right boundary) from time level t-dt required for radiation boundary condition
902    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_m_s       !< velocity data (w at south boundary) from time level t-dt required for radiation boundary condition
903
904    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  diss_1  !< pointer for swapping of timelevels for respective quantity
905    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  diss_2  !< pointer for swapping of timelevels for respective quantity
906    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  diss_3  !< pointer for swapping of timelevels for respective quantity
907    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  e_1     !< pointer for swapping of timelevels for respective quantity
908    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  e_2     !< pointer for swapping of timelevels for respective quantity
909    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  e_3     !< pointer for swapping of timelevels for respective quantity
910    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  p       !< pointer: perturbation pressure
911    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  prho_1  !< pointer for swapping of timelevels for respective quantity
912    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_1    !< pointer for swapping of timelevels for respective quantity
913    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_2    !< pointer for swapping of timelevels for respective quantity
914    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_3    !< pointer for swapping of timelevels for respective quantity
915    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_1    !< pointer for swapping of timelevels for respective quantity
916    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_2    !< pointer for swapping of timelevels for respective quantity
917    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_3    !< pointer for swapping of timelevels for respective quantity
918    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pt_1    !< pointer for swapping of timelevels for respective quantity
919    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pt_2    !< pointer for swapping of timelevels for respective quantity
920    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pt_3    !< pointer for swapping of timelevels for respective quantity
921    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  q_1     !< pointer for swapping of timelevels for respective quantity
922    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  q_2     !< pointer for swapping of timelevels for respective quantity
923    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  q_3     !< pointer for swapping of timelevels for respective quantity
924    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_1    !< pointer for swapping of timelevels for respective quantity
925    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_2    !< pointer for swapping of timelevels for respective quantity
926    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_3    !< pointer for swapping of timelevels for respective quantity
927    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_v    !< pointer: volume of liquid water
928    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_vp   !< pointer: liquid water weighting factor
929    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_1    !< pointer for swapping of timelevels for respective quantity
930    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_2    !< pointer for swapping of timelevels for respective quantity
931    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qr_1    !< pointer for swapping of timelevels for respective quantity
932    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qr_2    !< pointer for swapping of timelevels for respective quantity
933    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qr_3    !< pointer for swapping of timelevels for respective quantity
934    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  rho_1   !< pointer for swapping of timelevels for respective quantity
935    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  s_1     !< pointer for swapping of timelevels for respective quantity
936    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  s_2     !< pointer for swapping of timelevels for respective quantity
937    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  s_3     !< pointer for swapping of timelevels for respective quantity
938    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  sa_1    !< pointer for swapping of timelevels for respective quantity
939    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  sa_2    !< pointer for swapping of timelevels for respective quantity
940    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  sa_3    !< pointer for swapping of timelevels for respective quantity
941    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  u_1     !< pointer for swapping of timelevels for respective quantity
942    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  u_2     !< pointer for swapping of timelevels for respective quantity
943    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  u_3     !< pointer for swapping of timelevels for respective quantity
944    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  v_1     !< pointer for swapping of timelevels for respective quantity
945    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  v_2     !< pointer for swapping of timelevels for respective quantity
946    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  v_3     !< pointer for swapping of timelevels for respective quantity
947    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  vpt_1   !< pointer for swapping of timelevels for respective quantity
948    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  w_1     !< pointer for swapping of timelevels for respective quantity
949    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  w_2     !< pointer for swapping of timelevels for respective quantity
950    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  w_3     !< pointer for swapping of timelevels for respective quantity
951
952    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  diss       !< pointer: TKE dissipation
953    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  diss_p     !< pointer: prognostic value of TKE dissipation
954    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  e          !< pointer: subgrid-scale turbulence kinetic energy (sgs tke)
955    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  e_p        !< pointer: prognostic value of sgs tke
956    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nc         !< pointer: cloud drop number density
957    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nc_p       !< pointer: prognostic value of cloud drop number density
958    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nr         !< pointer: rain drop number density
959    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nr_p       !< pointer: prognostic value of rain drop number density
960    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  prho       !< pointer: potential density
961    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  pt         !< pointer: potential temperature
962    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  pt_p       !< pointer: prognostic value of potential temperature
963    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  q          !< pointer: mixing ratio
964    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  q_p        !< pointer: prognostic value of mixing ratio
965    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qc         !< pointer: cloud water content
966    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qc_p       !< pointer: cloud water content
967    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ql         !< pointer: liquid water content
968    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ql_c       !< pointer: change in liquid water content due to
969                                                                   !< condensation/evaporation during last time step
970    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qr         !< pointer: rain water content
971    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qr_p       !< pointer: prognostic value of rain water content
972    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  rho_ocean  !< pointer: density of ocean
973    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  s          !< pointer: passive scalar
974    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  s_p        !< pointer: prognostic value of passive scalar
975    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  sa         !< pointer: ocean salinity
976    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  sa_p       !< pointer: prognostic value of ocean salinity
977    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tdiss_m    !< pointer: weighted tendency of diss for previous sub-timestep (Runge-Kutta)
978    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  te_m       !< pointer: weighted tendency of e for previous sub-timestep (Runge-Kutta)
979    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tnc_m      !< pointer: weighted tendency of nc for previous sub-timestep (Runge-Kutta)
980    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tnr_m      !< pointer: weighted tendency of nr for previous sub-timestep (Runge-Kutta)
981    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tpt_m      !< pointer: weighted tendency of pt for previous sub-timestep (Runge-Kutta)
982    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tq_m       !< pointer: weighted tendency of q for previous sub-timestep (Runge-Kutta)
983    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tqc_m      !< pointer: weighted tendency of qc for previous sub-timestep (Runge-Kutta)
984    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tqr_m      !< pointer: weighted tendency of qr for previous sub-timestep (Runge-Kutta)
985    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ts_m       !< pointer: weighted tendency of s for previous sub-timestep (Runge-Kutta)
986    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tsa_m      !< pointer: weighted tendency of sa for previous sub-timestep (Runge-Kutta)
987    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tu_m       !< pointer: weighted tendency of u for previous sub-timestep (Runge-Kutta)
988    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tv_m       !< pointer: weighted tendency of v for previous sub-timestep (Runge-Kutta)
989    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tw_m       !< pointer: weighted tendency of w for previous sub-timestep (Runge-Kutta)
990    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  u          !< pointer: horizontal velocity component u (x-direction)
991    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  u_p        !< pointer: prognostic value of u
992    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  v          !< pointer: horizontal velocity component v (y-direction)
993    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  v_p        !< pointer: prognostic value of v
994    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  vpt        !< pointer: virtual potential temperature
995    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  w          !< pointer: vertical velocity component w (z-direction)
996    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  w_p        !< pointer: prognostic value of w
997
998    REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  tri    !<  array to hold the tridiagonal matrix for solution of the Poisson equation in Fourier space (4th dimension for threads)
999
1000    REAL(wp), DIMENSION(:), ALLOCATABLE ::  rho_air      !< air density profile on the uv grid
1001    REAL(wp), DIMENSION(:), ALLOCATABLE ::  rho_air_zw   !< air density profile on the w grid
1002    REAL(wp), DIMENSION(:), ALLOCATABLE ::  drho_air     !< inverse air density profile on the uv grid
1003    REAL(wp), DIMENSION(:), ALLOCATABLE ::  drho_air_zw  !< inverse air density profile on the w grid
1004
1005    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_air_mg     !< air density profiles on the uv grid for multigrid
1006    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_air_zw_mg  !< air density profiles on the w grid for multigrid
1007
1008    REAL(wp), DIMENSION(:), ALLOCATABLE ::  heatflux_input_conversion       !< conversion factor array for heatflux input
1009    REAL(wp), DIMENSION(:), ALLOCATABLE ::  waterflux_input_conversion      !< conversion factor array for waterflux input
1010    REAL(wp), DIMENSION(:), ALLOCATABLE ::  momentumflux_input_conversion   !< conversion factor array for momentumflux input
1011    REAL(wp), DIMENSION(:), ALLOCATABLE ::  heatflux_output_conversion      !< conversion factor array for heatflux output
1012    REAL(wp), DIMENSION(:), ALLOCATABLE ::  waterflux_output_conversion     !< conversion factor array for waterflux output
1013    REAL(wp), DIMENSION(:), ALLOCATABLE ::  momentumflux_output_conversion  !< conversion factor array for momentumflux output
1014
1015    REAL(wp), DIMENSION(:), ALLOCATABLE ::  hyrho   !< density of air calculated with hydrostatic pressure
1016    REAL(wp), DIMENSION(:), ALLOCATABLE ::  exner   !< ratio of actual and potential temperature
1017    REAL(wp), DIMENSION(:), ALLOCATABLE ::  d_exner !< ratio of potential and actual temperature
1018
1019    SAVE
1020
1021 END MODULE arrays_3d
1022
1023
1024!------------------------------------------------------------------------------!
1025! Description:
1026! ------------
1027!> Definition of variables needed for time-averaging of 2d/3d data.
1028!------------------------------------------------------------------------------!
1029 MODULE averaging
1030 
1031    USE kinds
1032
1033    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ghf_av                 !< avg. ground heat flux
1034    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lwp_av                 !< avg. liquid water path
1035    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ol_av                  !< avg. Obukhov length
1036    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  pt_2m_av               !< avg. 2m- air potential temperature
1037    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  qsws_av                !< avg. surface moisture flux
1038    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  r_a_av                 !< avg. resistance
1039    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ssws_av                !< avg. surface scalar flux
1040    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  shf_av                 !< avg. surface heat flux
1041    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tsurf_av               !< avg. surface temperature
1042    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ts_av                  !< avg. characteristic temperature scale
1043    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  us_av                  !< avg. friction velocity
1044    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  z0_av                  !< avg. roughness length for momentum
1045    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  z0h_av                 !< avg. roughness length for heat
1046    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  z0q_av                 !< avg. roughness length for moisture
1047
1048    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  diss_av       !< avg. tke dissipation rate
1049    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  e_av          !< avg. subgrid-scale tke
1050    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  kh_av         !< avg. eddy diffusivity for heat
1051    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  km_av         !< avg. eddy diffusivity for momentum
1052    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  lpt_av        !< avg. liquid water potential temperature
1053    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_av         !< avg. cloud drop number density
1054    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_av         !< avg. rain drop number density
1055    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  p_av          !< avg. perturbation pressure
1056    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pc_av         !< avg. particle/droplet concentration
1057    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pr_av         !< avg. particle/droplet radius
1058    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  prr_av        !< avg. precipitation rate
1059    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  pt_av         !< avg. potential temperature
1060    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  q_av          !< avg. mixing ratio
1061                                                                      !< (or total water content with active cloud physics)
1062    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_av         !< avg. cloud water content
1063    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_av         !< avg. liquid water content
1064    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_c_av       !< avg. change in liquid water content due to
1065                                                                      !< condensation/evaporation during last time step
1066    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_v_av       !< avg. volume of liquid water
1067    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_vp_av      !< avg. liquid water weighting factor
1068    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qr_av         !< avg. rain water content
1069    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qv_av         !< avg. water vapor content (mixing ratio)
1070    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  rho_ocean_av  !< avg. ocean density
1071    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  s_av          !< avg. passive scalar
1072    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  sa_av         !< avg. salinity
1073    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  u_av          !< avg. horizontal velocity component u
1074    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  v_av          !< avg. horizontal velocity component v
1075    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  vpt_av        !< avg. virtual potential temperature
1076    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  w_av          !< avg. vertical velocity component
1077 
1078 END MODULE averaging
1079
1080 
1081!------------------------------------------------------------------------------!
1082! Description:
1083! ------------
1084!> Definition of parameters for program control
1085!------------------------------------------------------------------------------!
1086 MODULE control_parameters
1087
1088    USE kinds
1089
1090    TYPE file_status
1091       LOGICAL ::  opened         !< file is currently open
1092       LOGICAL ::  opened_before  !< file is currently closed, but has been openend before
1093    END TYPE file_status
1094   
1095    INTEGER, PARAMETER      ::  mask_xyz_dimension = 100  !< limit of mask dimensions (100 points in each direction)
1096    INTEGER, PARAMETER      ::  max_masks = 50            !< maximum number of masks
1097    INTEGER(iwp), PARAMETER ::  varnamelength = 30        !< length of output variable names
1098
1099    TYPE(file_status), DIMENSION(200+2*max_masks) ::                &  !< indicates if file is open or if it has been opened before
1100                             openfile = file_status(.FALSE.,.FALSE.)
1101
1102    CHARACTER (LEN=1)    ::  cycle_mg = 'w'                               !< namelist parameter (see documentation)
1103    CHARACTER (LEN=1)    ::  timestep_reason = ' '                        !< 'A'dvection or 'D'iffusion criterion, written to RUN_CONTROL file
1104    CHARACTER (LEN=8)    ::  coupling_char = ''                           !< appended to filenames in coupled or nested runs ('_O': ocean PE,
1105                                                                          !< '_NV': vertically nested atmosphere PE, '_N##': PE of nested domain ##
1106    CHARACTER (LEN=10)   ::  run_date = ' '                               !< date of simulation run
1107    CHARACTER (LEN=8)    ::  run_time = ' '                               !< time of simulation run
1108    CHARACTER (LEN=5)    ::  run_zone = ' '                               !< time zone of simulation run
1109    CHARACTER (LEN=9)    ::  simulated_time_chr                           !< simulated time, printed to RUN_CONTROL file
1110    CHARACTER (LEN=11)   ::  topography_grid_convention = ' '             !< namelist parameter
1111    CHARACTER (LEN=12)   ::  version = ' '                                !< PALM version number
1112    CHARACTER (LEN=12)   ::  revision = ' '                               !< PALM revision number
1113    CHARACTER (LEN=12)   ::  user_interface_current_revision = ' '        !< revision number of the currently used user-interface (must match user_interface_required_revision)
1114    CHARACTER (LEN=12)   ::  user_interface_required_revision = ' '       !< required user-interface revision number
1115    CHARACTER (LEN=16)   ::  conserve_volume_flow_mode = 'default'        !< namelist parameter
1116    CHARACTER (LEN=16)   ::  loop_optimization = 'cache'                  !< namelist parameter
1117    CHARACTER (LEN=16)   ::  momentum_advec = 'ws-scheme'                 !< namelist parameter
1118    CHARACTER (LEN=16)   ::  psolver = 'poisfft'                          !< namelist parameter
1119    CHARACTER (LEN=16)   ::  scalar_advec = 'ws-scheme'                   !< namelist parameter
1120    CHARACTER (LEN=20)   ::  approximation = 'boussinesq'                 !< namelist parameter
1121    CHARACTER (LEN=40)   ::  flux_input_mode = 'approximation-specific'   !< type of flux input: dynamic or kinematic
1122    CHARACTER (LEN=40)   ::  flux_output_mode = 'approximation-specific'  !< type of flux output: dynamic or kinematic
1123    CHARACTER (LEN=20)   ::  bc_e_b = 'neumann'                           !< namelist parameter
1124    CHARACTER (LEN=20)   ::  bc_lr = 'cyclic'                             !< namelist parameter
1125    CHARACTER (LEN=20)   ::  bc_ns = 'cyclic'                             !< namelist parameter
1126    CHARACTER (LEN=20)   ::  bc_p_b = 'neumann'                           !< namelist parameter
1127    CHARACTER (LEN=20)   ::  bc_p_t = 'dirichlet'                         !< namelist parameter
1128    CHARACTER (LEN=20)   ::  bc_pt_b = 'dirichlet'                        !< namelist parameter
1129    CHARACTER (LEN=20)   ::  bc_pt_t = 'initial_gradient'                 !< namelist parameter
1130    CHARACTER (LEN=20)   ::  bc_q_b = 'dirichlet'                         !< namelist parameter
1131    CHARACTER (LEN=20)   ::  bc_q_t = 'neumann'                           !< namelist parameter
1132    CHARACTER (LEN=20)   ::  bc_s_b = 'dirichlet'                         !< namelist parameter
1133    CHARACTER (LEN=20)   ::  bc_s_t = 'initial_gradient'                  !< namelist parameter
1134    CHARACTER (LEN=20)   ::  bc_uv_b = 'dirichlet'                        !< namelist parameter
1135    CHARACTER (LEN=20)   ::  bc_uv_t = 'dirichlet'                        !< namelist parameter
1136    CHARACTER (LEN=20)   ::  coupling_mode = 'uncoupled'                  !< coupling mode for atmosphere-ocean coupling 
1137    CHARACTER (LEN=20)   ::  coupling_mode_remote = 'uncoupled'           !< coupling mode of the remote process in case of coupled atmosphere-ocean runs
1138    CHARACTER (LEN=20)   ::  dissipation_1d = 'detering'                  !< namelist parameter
1139    CHARACTER (LEN=20)   ::  fft_method = 'temperton-algorithm'           !< namelist parameter
1140    CHARACTER (LEN=20)   ::  mixing_length_1d = 'blackadar'               !< namelist parameter
1141    CHARACTER (LEN=20)   ::  random_generator = 'random-parallel'         !< namelist parameter
1142    CHARACTER (LEN=20)   ::  reference_state = 'initial_profile'          !< namelist parameter 
1143    CHARACTER (LEN=20)   ::  timestep_scheme = 'runge-kutta-3'            !< namelist parameter       
1144    CHARACTER (LEN=20)   ::  turbulence_closure = 'Moeng_Wyngaard'        !< namelist parameter
1145    CHARACTER (LEN=40)   ::  topography = 'flat'                          !< namelist parameter
1146    CHARACTER (LEN=64)   ::  host = '????'                                !< configuration identifier as given by palmrun option -c, ENVPAR namelist parameter provided by palmrun
1147    CHARACTER (LEN=80)   ::  log_message                                  !< user-defined message for debugging (sse data_log.f90)
1148    CHARACTER (LEN=80)   ::  run_identifier                               !< run identifier as given by palmrun option -r, ENVPAR namelist parameter provided by palmrun
1149    CHARACTER (LEN=100)  ::  initializing_actions = ' '                   !< namelist parameter
1150    CHARACTER (LEN=100)  ::  restart_string = ' '                         !< for storing strings in case of writing/reading restart data
1151    CHARACTER (LEN=210)  ::  run_description_header                       !< string containing diverse run informations as run identifier, coupling mode, host, ensemble number, run date and time
1152    CHARACTER (LEN=1000) ::  debug_string = ' '                           !<.....
1153    CHARACTER (LEN=1000) ::  message_string = ' '                         !< dynamic string for error message output
1154
1155    CHARACTER (LEN=varnamelength), DIMENSION(500) ::  data_output = ' '       !< namelist parameter
1156    CHARACTER (LEN=varnamelength), DIMENSION(500) ::  data_output_user = ' '  !< namelist parameter
1157    CHARACTER (LEN=varnamelength), DIMENSION(500) ::  doav = ' '              !< label array for multi-dimensional,
1158                                                                              !< averaged output quantities
1159                                           
1160    CHARACTER (LEN=varnamelength), DIMENSION(max_masks,100) ::  data_output_masks = ' '       !< namelist parameter
1161    CHARACTER (LEN=varnamelength), DIMENSION(max_masks,100) ::  data_output_masks_user = ' '  !< namelist parameter
1162
1163    CHARACTER (LEN=varnamelength), DIMENSION(300) ::  data_output_pr = ' '  !< namelist parameter
1164   
1165    CHARACTER (LEN=varnamelength), DIMENSION(200) ::  data_output_pr_user = ' '  !< namelist parameter
1166   
1167    CHARACTER (LEN=varnamelength), DIMENSION(max_masks,0:1,100) ::  domask = ' ' !< label array for multi-dimensional,
1168                                                                                 !< masked output quantities
1169   
1170    CHARACTER (LEN=varnamelength), DIMENSION(0:1,500) ::  do2d = ' '  !< label array for 2d output quantities
1171    CHARACTER (LEN=varnamelength), DIMENSION(0:1,500) ::  do3d = ' '  !< label array for 3d output quantities
1172
1173    INTEGER(iwp), PARAMETER ::  fl_max = 100     !< maximum number of virtual-flight measurements
1174    INTEGER(iwp), PARAMETER ::  var_fl_max = 20  !< maximum number of different sampling variables in virtual flight measurements
1175   
1176    INTEGER(iwp) ::  abort_mode = 1                    !< abort condition (nested runs)
1177    INTEGER(iwp) ::  agt_time_count = 0                !< number of output intervals for agent data output
1178    INTEGER(iwp) ::  average_count_pr = 0              !< number of samples in vertical-profile output
1179    INTEGER(iwp) ::  average_count_3d = 0              !< number of samples in 3d output
1180    INTEGER(iwp) ::  current_timestep_number = 0       !< current timestep number, printed to RUN_CONTROL file
1181    INTEGER(iwp) ::  coupling_topology = 0             !< switch for atmosphere-ocean-coupling: 0: same number of grid points and PEs along x and y in atmosphere and ocean, otherwise 1
1182    INTEGER(iwp) ::  dist_range = 0                    !< switch for steering the horizontal disturbance range, 1: inflow disturbances in case of non-cyclic horizontal BC, 0: otherwise
1183    INTEGER(iwp) ::  disturbance_level_ind_b           !< lowest grid index where flow disturbance is applied
1184    INTEGER(iwp) ::  disturbance_level_ind_t           !< highest grid index where flow disturbance is applied
1185    INTEGER(iwp) ::  doav_n = 0                        !< number of 2d/3d output quantities subject to time averaging
1186    INTEGER(iwp) ::  dopr_n = 0                        !< number of profile output quantities subject to time averaging
1187    INTEGER(iwp) ::  dopr_time_count = 0               !< number of output intervals for profile output
1188    INTEGER(iwp) ::  dopts_time_count = 0              !< number of output intervals for particle data timeseries
1189    INTEGER(iwp) ::  dots_time_count = 0               !< number of output intervals for timeseries output
1190    INTEGER(iwp) ::  dp_level_ind_b = 0                !< lowest grid index for external pressure gradient forcing
1191    INTEGER(iwp) ::  dvrp_filecount = 0                !< parameter for dvr visualization software
1192    INTEGER(iwp) ::  ensemble_member_nr = 0            !< namelist parameter
1193    INTEGER(iwp) ::  gamma_mg                          !< switch for steering the multigrid cycle: 1: v-cycle, 2: w-cycle
1194    INTEGER(iwp) ::  gathered_size                     !< number of total domain grid points of the grid level which is gathered on PE0 (multigrid solver)
1195    INTEGER(iwp) ::  grid_level                        !< current grid level handled in the multigrid solver
1196    INTEGER(iwp) ::  ibc_e_b                           !< integer flag for bc_e_b
1197    INTEGER(iwp) ::  ibc_p_b                           !< integer flag for bc_p_b
1198    INTEGER(iwp) ::  ibc_p_t                           !< integer flag for bc_p_t
1199    INTEGER(iwp) ::  ibc_pt_b                          !< integer flag for bc_pt_b
1200    INTEGER(iwp) ::  ibc_pt_t                          !< integer flag for bc_pt_t
1201    INTEGER(iwp) ::  ibc_q_b                           !< integer flag for bc_q_b
1202    INTEGER(iwp) ::  ibc_q_t                           !< integer flag for bc_q_t
1203    INTEGER(iwp) ::  ibc_s_b                           !< integer flag for bc_s_b
1204    INTEGER(iwp) ::  ibc_s_t                           !< integer flag for bc_s_t
1205    INTEGER(iwp) ::  ibc_uv_b                          !< integer flag for bc_uv_b
1206    INTEGER(iwp) ::  ibc_uv_t                          !< integer flag for bc_uv_t
1207    INTEGER(iwp) ::  inflow_disturbance_begin = -1     !< namelist parameter
1208    INTEGER(iwp) ::  inflow_disturbance_end = -1       !< namelist parameter
1209    INTEGER(iwp) ::  intermediate_timestep_count       !< number of current Runge-Kutta substep
1210    INTEGER(iwp) ::  intermediate_timestep_count_max   !< maximum number of Runge-Kutta substeps
1211    INTEGER(iwp) ::  io_group = 0                      !< I/O group to which the PE belongs (= #PE / io_blocks)
1212    INTEGER(iwp) ::  io_blocks = 1                     !< number of blocks for which I/O is done in sequence (total number of PEs / maximum_parallel_io_streams)
1213    INTEGER(iwp) ::  iran = -1234567                   !< integer random number used for flow disturbances
1214    INTEGER(iwp) ::  length = 0                        !< integer that specifies the length of a string in case of writing/reading restart data
1215    INTEGER(iwp) ::  masks = 0                         !< counter for number of masked output quantities
1216    INTEGER(iwp) ::  maximum_grid_level                !< number of grid levels that the multigrid solver is using
1217    INTEGER(iwp) ::  maximum_parallel_io_streams = -1  !< maximum number of parallel io streams that the underlying parallel file system allows, set with palmrun option -w, ENVPAR namelist parameter, provided by palmrun
1218    INTEGER(iwp) ::  max_pr_user = 0                   !< number of user-defined profiles (must not change within a job chain)
1219    INTEGER(iwp) ::  max_pr_user_tmp = 0               !< number of user-defined profiles that is temporary stored to check it against max_pr_user in case of restarts
1220    INTEGER(iwp) ::  mgcycles = 0                      !< number of multigrid cycles that the multigrid solver has actually carried out
1221    INTEGER(iwp) ::  mg_cycles = 4                     !< namelist parameter
1222    INTEGER(iwp) ::  mg_switch_to_pe0_level = -1       !< namelist parameter
1223    INTEGER(iwp) ::  mid                               !< masked output running index
1224    INTEGER(iwp) ::  ngsrb = 2                         !< namelist parameter
1225    INTEGER(iwp) ::  nr_timesteps_this_run = 0         !< number of timesteps (cpu time measurements)
1226    INTEGER(iwp) ::  nsor = 20                         !< namelist parameter
1227    INTEGER(iwp) ::  nsor_ini = 100                    !< namelist parameter
1228    INTEGER(iwp) ::  n_sor                             !< number of iterations to be used in SOR-scheme
1229    INTEGER(iwp) ::  normalizing_region = 0            !< namelist parameter
1230    INTEGER(iwp) ::  num_mean_inflow_profiles = 7      !< number of mean inflow profiles in case of turbulent inflow
1231    INTEGER(iwp) ::  num_leg=0                         !< number of different legs in virtual flight measurements
1232    INTEGER(iwp) ::  num_var_fl                        !< number of sampling/output variables in virtual flight measurements
1233    INTEGER(iwp) ::  num_var_fl_user=0                 !< number of user-defined sampling/output variables in virtual flight measurements
1234    INTEGER(iwp) ::  number_stretch_level_start        !< number of user-specified start levels for stretching
1235    INTEGER(iwp) ::  number_stretch_level_end          !< number of user-specified end levels for stretching
1236    INTEGER(iwp) ::  nz_do3d = -9999                   !< namelist parameter
1237    INTEGER(iwp) ::  prt_time_count = 0                !< number of output intervals for particle data output
1238    INTEGER(iwp) ::  recycling_plane                   !< position of recycling plane along x (in grid points) in case of turbulence recycling
1239    INTEGER(iwp) ::  runnr = 0                         !< number of run in job chain
1240    INTEGER(iwp) ::  subdomain_size                    !< number of grid points in (3d) subdomain including ghost points
1241    INTEGER(iwp) ::  terminate_coupled = 0             !< switch for steering termination in case of coupled runs
1242    INTEGER(iwp) ::  terminate_coupled_remote = 0      !< switch for steering termination in case of coupled runs (condition of the remote model)
1243    INTEGER(iwp) ::  timestep_count = 0                !< number of timesteps carried out since the beginning of the initial run
1244    INTEGER(iwp) ::  y_shift = 0                       !< namelist parameter
1245   
1246    INTEGER(iwp) ::  dist_nxl(0:1)                               !< left boundary of disturbance region
1247    INTEGER(iwp) ::  dist_nxr(0:1)                               !< right boundary of disturbance region
1248    INTEGER(iwp) ::  dist_nyn(0:1)                               !< north boundary of disturbance region
1249    INTEGER(iwp) ::  dist_nys(0:1)                               !< south boundary of disturbance region
1250    INTEGER(iwp) ::  do2d_no(0:1) = 0                            !< number of 2d output quantities
1251    INTEGER(iwp) ::  do2d_xy_time_count(0:1) = 0                 !< number of output intervals for 2d data (xy)
1252    INTEGER(iwp) ::  do2d_xz_time_count(0:1) = 0                 !< number of output intervals for 2d data (xz)
1253    INTEGER(iwp) ::  do2d_yz_time_count(0:1) = 0                 !< number of output intervals for 2d data (yz)
1254    INTEGER(iwp) ::  do3d_no(0:1) = 0                            !< number of 3d output quantities
1255    INTEGER(iwp) ::  do3d_time_count(0:1) = 0                    !< number of output intervals for 3d data
1256    INTEGER(iwp) ::  domask_no(max_masks,0:1) = 0                !< number of masked output quantities
1257    INTEGER(iwp) ::  domask_time_count(max_masks,0:1)            !< number of output intervals for masked data
1258    INTEGER(iwp) ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
1259    INTEGER(iwp) ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
1260    INTEGER(iwp) ::  mask_size(max_masks,3) = -1                 !< size of mask array per mask and dimension (for netcdf output)
1261    INTEGER(iwp) ::  mask_size_l(max_masks,3) = -1               !< subdomain size of mask array per mask and dimension (for netcdf output)
1262    INTEGER(iwp) ::  mask_start_l(max_masks,3) = -1              !< subdomain start index of mask array (for netcdf output)
1263    INTEGER(iwp) ::  pt_vertical_gradient_level_ind(10) = -9999  !< grid index values of pt_vertical_gradient_level(s)
1264    INTEGER(iwp) ::  q_vertical_gradient_level_ind(10) = -9999   !< grid index values of q_vertical_gradient_level(s)
1265    INTEGER(iwp) ::  s_vertical_gradient_level_ind(10) = -9999   !< grid index values of s_vertical_gradient_level(s)   
1266    INTEGER(iwp) ::  section(100,3)                              !< collective array for section_xy/xz/yz
1267    INTEGER(iwp) ::  section_xy(100) = -9999                     !< namelist parameter
1268    INTEGER(iwp) ::  section_xz(100) = -9999                     !< namelist parameter
1269    INTEGER(iwp) ::  section_yz(100) = -9999                     !< namelist parameter
1270    INTEGER(iwp) ::  ug_vertical_gradient_level_ind(10) = -9999  !< grid index values of ug_vertical_gradient_level(s)
1271    INTEGER(iwp) ::  vg_vertical_gradient_level_ind(10) = -9999  !< grid index values of vg_vertical_gradient_level(s)
1272    INTEGER(iwp) ::  subs_vertical_gradient_level_i(10) = -9999  !< grid index values of subs_vertical_gradient_level(s)
1273
1274    INTEGER(iwp), DIMENSION(0:1) ::  ntdim_2d_xy  !< number of output intervals for 2d data (xy)
1275    INTEGER(iwp), DIMENSION(0:1) ::  ntdim_2d_xz  !< number of output intervals for 2d data (xz)
1276    INTEGER(iwp), DIMENSION(0:1) ::  ntdim_2d_yz  !< number of output intervals for 2d data (yz)
1277    INTEGER(iwp), DIMENSION(0:1) ::  ntdim_3d     !< number of output intervals for 3d data
1278
1279    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  grid_level_count  !< internal switch for steering the multigrid v- and w-cycles
1280
1281    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_i         !< subdomain grid index of masked output point on x-dimension
1282    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_j         !< subdomain grid index of masked output point on y-dimension
1283    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_k         !< subdomain grid index of masked output point on z-dimension
1284    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_i_global  !< global grid index of masked output point on x-dimension
1285    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_j_global  !< global grid index of masked output point on y-dimension
1286    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mask_k_global  !< global grid index of masked output point on z-dimension
1287
1288    INTEGER(iwp), DIMENSION(max_masks,mask_xyz_dimension) ::  mask_k_over_surface = -1  !< namelist parameter, k index of height over surface
1289
1290    LOGICAL ::  agent_time_unlimited = .FALSE.                   !< namelist parameter
1291    LOGICAL ::  air_chemistry = .FALSE.                          !< chemistry model switch
1292    LOGICAL ::  bc_dirichlet_l                                   !< flag indicating dirichlet boundary condition on left model boundary
1293    LOGICAL ::  bc_dirichlet_n                                   !< flag indicating dirichlet boundary condition on north model boundary
1294    LOGICAL ::  bc_dirichlet_r                                   !< flag indicating dirichlet boundary condition on right model boundary
1295    LOGICAL ::  bc_dirichlet_s                                   !< flag indicating dirichlet boundary condition on south model boundary
1296    LOGICAL ::  bc_lr_cyc =.TRUE.                                !< left-right boundary condition cyclic?
1297    LOGICAL ::  bc_lr_dirrad = .FALSE.                           !< left-right boundary condition dirichlet/radiation?
1298    LOGICAL ::  bc_lr_raddir = .FALSE.                           !< left-right boundary condition radiation/dirichlet?
1299    LOGICAL ::  bc_ns_cyc = .TRUE.                               !< north-south boundary condition cyclic?
1300    LOGICAL ::  bc_ns_dirrad = .FALSE.                           !< north-south boundary condition dirichlet/radiation?
1301    LOGICAL ::  bc_ns_raddir = .FALSE.                           !< north-south boundary condition radiation/dirichlet?
1302    LOGICAL ::  bc_radiation_l = .FALSE.                         !< radiation boundary condition for outflow at left domain boundary
1303    LOGICAL ::  bc_radiation_n = .FALSE.                         !< radiation boundary condition for outflow at north domain boundary
1304    LOGICAL ::  bc_radiation_r = .FALSE.                         !< radiation boundary condition for outflow at right domain boundary
1305    LOGICAL ::  bc_radiation_s = .FALSE.                         !< radiation boundary condition for outflow at south domain boundary
1306    LOGICAL ::  biometeorology = .FALSE.                         !< biometeorology module switch
1307    LOGICAL ::  calc_soil_moisture_during_spinup = .FALSE.       !< namelist parameter
1308    LOGICAL ::  call_psolver_at_all_substeps = .TRUE.            !< namelist parameter
1309    LOGICAL ::  child_domain  = .FALSE.                          !< flag indicating that model is nested in a parent domain
1310    LOGICAL ::  cloud_droplets = .FALSE.                         !< namelist parameter
1311    LOGICAL ::  complex_terrain = .FALSE.                        !< namelist parameter
1312    LOGICAL ::  conserve_volume_flow = .FALSE.                   !< namelist parameter
1313    LOGICAL ::  constant_diffusion = .FALSE.                     !< diffusion coefficient constant?
1314    LOGICAL ::  constant_flux_layer = .TRUE.                     !< namelist parameter
1315    LOGICAL ::  constant_heatflux = .TRUE.                       !< heat flux at all surfaces constant?
1316    LOGICAL ::  constant_top_heatflux = .TRUE.                   !< heat flux at domain top constant?
1317    LOGICAL ::  constant_top_momentumflux = .FALSE.              !< momentum flux at domain topconstant?
1318    LOGICAL ::  constant_top_salinityflux = .TRUE.               !< constant salinity flux at ocean surface
1319    LOGICAL ::  constant_top_scalarflux = .TRUE.                 !< passive-scalar flux at domain top constant?
1320    LOGICAL ::  constant_scalarflux = .TRUE.                     !< passive-scalar flux at surfaces constant?
1321    LOGICAL ::  constant_waterflux = .TRUE.                      !< water flux at all surfaces constant?
1322    LOGICAL ::  create_disturbances = .TRUE.                     !< namelist parameter
1323    LOGICAL ::  data_output_during_spinup = .FALSE.              !< namelist parameter
1324    LOGICAL ::  data_output_2d_on_each_pe = .TRUE.               !< namelist parameter
1325    LOGICAL ::  debug_output = .FALSE.                           !< namelist parameter
1326    LOGICAL ::  disturbance_created = .FALSE.                    !< flow disturbance imposed?
1327    LOGICAL ::  do2d_at_begin = .FALSE.                          !< namelist parameter
1328    LOGICAL ::  do3d_at_begin = .FALSE.                          !< namelist parameter
1329    LOGICAL ::  do_output_at_2m = .FALSE.                        !< flag for activating calculation of potential temperature at z = 2 m
1330    LOGICAL ::  do_sum = .FALSE.                                 !< contribute to time average of profile data?
1331    LOGICAL ::  dp_external = .FALSE.                            !< namelist parameter
1332    LOGICAL ::  dp_smooth = .FALSE.                              !< namelist parameter
1333    LOGICAL ::  dt_fixed = .FALSE.                               !< fixed timestep (namelist parameter dt set)?
1334    LOGICAL ::  dt_3d_reached                                    !< internal timestep for particle advection
1335    LOGICAL ::  dt_3d_reached_l                                  !< internal timestep for particle advection
1336    LOGICAL ::  first_call_lpm = .TRUE.                          !< call lpm only once per timestep?
1337    LOGICAL ::  first_call_mas = .TRUE.                          !< call mas only once per timestep
1338    LOGICAL ::  force_print_header = .FALSE.                     !< namelist parameter
1339    LOGICAL ::  galilei_transformation = .FALSE.                 !< namelist parameter
1340    LOGICAL ::  humidity = .FALSE.                               !< namelist parameter
1341    LOGICAL ::  humidity_remote = .FALSE.                        !< switch for receiving near-surface humidity flux (atmosphere-ocean coupling)
1342    LOGICAL ::  indoor_model = .FALSE.                           !< switch for indoor-climate and energy-demand model
1343    LOGICAL ::  large_scale_forcing = .FALSE.                    !< namelist parameter
1344    LOGICAL ::  large_scale_subsidence = .FALSE.                 !< namelist parameter
1345    LOGICAL ::  land_surface = .FALSE.                           !< use land surface model?
1346    LOGICAL ::  les_dynamic = .FALSE.                            !< use dynamic subgrid model as turbulence closure for LES mode
1347    LOGICAL ::  les_mw = .FALSE.                                 !< use Moeng-Wyngaard turbulence closure for LES mode
1348    LOGICAL ::  lsf_exception = .FALSE.                          !< use of lsf with buildings (temporary)?
1349    LOGICAL ::  lsf_surf = .TRUE.                                !< use surface forcing (large scale forcing)?
1350    LOGICAL ::  lsf_vert = .TRUE.                                !< use atmospheric forcing (large scale forcing)?
1351    LOGICAL ::  masking_method = .FALSE.                         !< namelist parameter
1352    LOGICAL ::  mg_switch_to_pe0 = .FALSE.                       !< internal multigrid switch for steering the ghost point exchange in case that data has been collected on PE0
1353    LOGICAL ::  nesting_offline = .FALSE.                        !< flag controlling offline nesting in COSMO model 
1354    LOGICAL ::  neutral = .FALSE.                                !< namelist parameter
1355    LOGICAL ::  nudging = .FALSE.                                !< namelist parameter
1356    LOGICAL ::  ocean_mode = .FALSE.                             !< namelist parameter
1357    LOGICAL ::  passive_scalar = .FALSE.                         !< namelist parameter
1358    LOGICAL ::  plant_canopy = .FALSE.                           !< switch for use of plant canopy model
1359    LOGICAL ::  random_heatflux = .FALSE.                        !< namelist parameter
1360    LOGICAL ::  rans_mode = .FALSE.                              !< switch between RANS and LES mode
1361    LOGICAL ::  rans_tke_e = .FALSE.                             !< use TKE-e turbulence closure for RANS mode
1362    LOGICAL ::  rans_tke_l = .FALSE.                             !< use TKE-l turbulence closure for RANS mode
1363    LOGICAL ::  read_svf = .FALSE.                               !< ENVPAR namelist parameter to steer input of svf (ENVPAR is provided by palmrun)
1364    LOGICAL ::  recycling_yshift = .FALSE.                       !< namelist parameter
1365    LOGICAL ::  run_control_header = .FALSE.                     !< onetime output of RUN_CONTROL header
1366    LOGICAL ::  run_coupled = .TRUE.                             !< internal switch telling PALM to run in coupled mode (i.e. to exchange surface data) in case of atmosphere-ocean coupling
1367    LOGICAL ::  salsa = .FALSE.                                  !< switch for the sectional aerosol module salsa
1368    LOGICAL ::  scalar_rayleigh_damping = .TRUE.                 !< namelist parameter
1369    LOGICAL ::  sloping_surface = .FALSE.                        !< use sloped surface? (namelist parameter alpha_surface)
1370    LOGICAL ::  spinup = .FALSE.                                 !< perform model spinup without atmosphere code?
1371    LOGICAL ::  surface_output = .FALSE.                         !< output of surface data
1372    LOGICAL ::  stop_dt = .FALSE.                                !< internal switch to stop the time stepping
1373    LOGICAL ::  synchronous_exchange = .FALSE.                   !< namelist parameter
1374    LOGICAL ::  syn_turb_gen = .FALSE.                           !< flag for synthetic turbulence generator module
1375    LOGICAL ::  terminate_run = .FALSE.                          !< terminate run (cpu-time limit, restarts)?
1376    LOGICAL ::  topo_no_distinct = .FALSE.                       !< flag controlling classification of topography surfaces
1377    LOGICAL ::  transpose_compute_overlap = .FALSE.              !< namelist parameter
1378    LOGICAL ::  turbulent_inflow = .FALSE.                       !< namelist parameter
1379    LOGICAL ::  turbulent_outflow = .FALSE.                      !< namelist parameter
1380    LOGICAL ::  urban_surface = .FALSE.                          !< use urban surface model?
1381    LOGICAL ::  use_cmax = .TRUE.                                !< namelist parameter
1382    LOGICAL ::  use_free_convection_scaling = .FALSE.            !< namelist parameter to switch on free convection velocity scale in calculation of horizontal wind speed (surface_layer_fluxes)
1383    LOGICAL ::  use_initial_profile_as_reference = .FALSE.       !< use of initial profiles as reference state?
1384    LOGICAL ::  use_prescribed_profile_data = .FALSE.            !< use of prescribed wind profiles?
1385                                                                 !< (namelist parameters u_profile, v_profile)
1386    LOGICAL ::  use_single_reference_value = .FALSE.             !< use of single value as reference state?
1387    LOGICAL ::  use_subsidence_tendencies = .FALSE.              !< namelist parameter
1388    LOGICAL ::  use_surface_fluxes = .FALSE.                     !< namelist parameter
1389    LOGICAL ::  use_top_fluxes = .FALSE.                         !< namelist parameter
1390    LOGICAL ::  use_ug_for_galilei_tr = .TRUE.                   !< namelist parameter
1391    LOGICAL ::  use_upstream_for_tke = .FALSE.                   !< namelist parameter
1392    LOGICAL ::  virtual_flight = .FALSE.                         !< use virtual flight model
1393    LOGICAL ::  virtual_measurement = .FALSE.                    !< control parameter to switch-on virtual measurements
1394    LOGICAL ::  wall_adjustment = .TRUE.                         !< namelist parameter
1395    LOGICAL ::  wind_turbine = .FALSE.                           !< flag for use of wind turbine model
1396    LOGICAL ::  write_binary = .FALSE.                           !< ENVPAR namelist parameter to steer restart I/O (ENVPAR is provided by palmrun)
1397    LOGICAL ::  write_svf = .FALSE.                              !< ENVPAR namelist parameter to steer output of svf (ENVPAR is provided by palmrun)
1398    LOGICAL ::  ws_scheme_sca = .FALSE.                          !< use Wicker-Skamarock scheme (scalar advection)?
1399    LOGICAL ::  ws_scheme_mom = .FALSE.                          !< use Wicker-Skamarock scheme (momentum advection)?
1400
1401    LOGICAL ::  data_output_xy(0:1) = .FALSE.                !< output of xy cross-section data?
1402    LOGICAL ::  data_output_xz(0:1) = .FALSE.                !< output of xz cross-section data?
1403    LOGICAL ::  data_output_yz(0:1) = .FALSE.                !< output of yz cross-section data?
1404
1405    LOGICAL, DIMENSION(max_masks) ::  mask_surface = .FALSE.      !< flag for surface-following masked output
1406
1407    REAL(wp) ::  advected_distance_x = 0.0_wp                  !< advected distance of model domain along x
1408                                                               !< (galilei transformation)
1409    REAL(wp) ::  advected_distance_y = 0.0_wp                  !< advected distance of model domain along y
1410                                                               !< (galilei transformation)
1411    REAL(wp) ::  alpha_surface = 0.0_wp                        !< namelist parameter
1412    REAL(wp) ::  atmos_ocean_sign = 1.0_wp                     !< vertical-grid conversion factor
1413                                                               !< (=1.0 in atmosphere, =-1.0 in ocean)
1414    REAL(wp) ::  averaging_interval = 0.0_wp                   !< namelist parameter
1415    REAL(wp) ::  averaging_interval_pr = 9999999.9_wp          !< namelist parameter
1416    REAL(wp) ::  bc_pt_t_val                                   !< vertical gradient of pt near domain top
1417    REAL(wp) ::  bc_q_t_val                                    !< vertical gradient of humidity near domain top
1418    REAL(wp) ::  bc_s_t_val                                    !< vertical gradient of passive scalar near domain top
1419    REAL(wp) ::  bottom_salinityflux = 0.0_wp                  !< namelist parameter
1420    REAL(wp) ::  building_height = 50.0_wp                     !< namelist parameter
1421    REAL(wp) ::  building_length_x = 50.0_wp                   !< namelist parameter
1422    REAL(wp) ::  building_length_y = 50.0_wp                   !< namelist parameter
1423    REAL(wp) ::  building_wall_left = 9999999.9_wp             !< namelist parameter
1424    REAL(wp) ::  building_wall_south = 9999999.9_wp            !< namelist parameter
1425    REAL(wp) ::  canyon_height = 50.0_wp                       !< namelist parameter
1426    REAL(wp) ::  canyon_width_x = 9999999.9_wp                 !< namelist parameter
1427    REAL(wp) ::  canyon_width_y = 9999999.9_wp                 !< namelist parameter
1428    REAL(wp) ::  canyon_wall_left = 9999999.9_wp               !< namelist parameter
1429    REAL(wp) ::  canyon_wall_south = 9999999.9_wp              !< namelist parameter
1430    REAL(wp) ::  cfl_factor = -1.0_wp                          !< namelist parameter
1431    REAL(wp) ::  cos_alpha_surface                             !< cosine of alpha_surface
1432    REAL(wp) ::  coupling_start_time = 0.0_wp                  !< namelist parameter
1433    REAL(wp) ::  days_since_reference_point = 0.0_wp           !< days after atmosphere-ocean coupling has been activated,
1434                                                               !< or after spinup phase of LSM has been finished
1435    REAL(wp) ::  disturbance_amplitude = 0.25_wp               !< namelist parameter
1436    REAL(wp) ::  disturbance_energy_limit = 0.01_wp            !< namelist parameter
1437    REAL(wp) ::  disturbance_level_b = -9999999.9_wp           !< namelist parameter
1438    REAL(wp) ::  disturbance_level_t = -9999999.9_wp           !< namelist parameter
1439    REAL(wp) ::  dp_level_b = 0.0_wp                           !< namelist parameter
1440    REAL(wp) ::  dt = -1.0_wp                                  !< namelist parameter
1441    REAL(wp) ::  dt_averaging_input = 0.0_wp                   !< namelist parameter
1442    REAL(wp) ::  dt_averaging_input_pr = 9999999.9_wp          !< namelist parameter
1443    REAL(wp) ::  dt_coupling = 9999999.9_wp                    !< namelist parameter
1444    REAL(wp) ::  dt_data_output = 9999999.9_wp                 !< namelist parameter
1445    REAL(wp) ::  dt_data_output_av = 9999999.9_wp              !< namelist parameter
1446    REAL(wp) ::  dt_disturb = 9999999.9_wp                     !< namelist parameter
1447    REAL(wp) ::  dt_dopr = 9999999.9_wp                        !< namelist parameter
1448    REAL(wp) ::  dt_dopr_listing = 9999999.9_wp                !< namelist parameter
1449    REAL(wp) ::  dt_dopts = 9999999.9_wp                       !< namelist parameter
1450    REAL(wp) ::  dt_dots = 9999999.9_wp                        !< namelist parameter
1451    REAL(wp) ::  dt_do2d_xy = 9999999.9_wp                     !< namelist parameter
1452    REAL(wp) ::  dt_do2d_xz = 9999999.9_wp                     !< namelist parameter
1453    REAL(wp) ::  dt_do2d_yz = 9999999.9_wp                     !< namelist parameter
1454    REAL(wp) ::  dt_do3d = 9999999.9_wp                        !< namelist parameter
1455    REAL(wp) ::  dt_dvrp = 9999999.9_wp                        !< namelist parameter
1456    REAL(wp) ::  dt_max = 20.0_wp                              !< namelist parameter
1457    REAL(wp) ::  dt_restart = 9999999.9_wp                     !< namelist parameter
1458    REAL(wp) ::  dt_run_control = 60.0_wp                      !< namelist parameter
1459    REAL(wp) ::  dt_spinup = 60.0_wp                           !< namelist parameter
1460    REAL(wp) ::  dt_write_agent_data = 9999999.9_wp            !< namelist parameter
1461    REAL(wp) ::  dt_3d = 0.01_wp                               !< time step
1462    REAL(wp) ::  dz_max = 999.0_wp                             !< namelist parameter
1463    REAL(wp) ::  dz_stretch_factor = 1.08_wp                   !< namelist parameter
1464    REAL(wp) ::  dz_stretch_level = -9999999.9_wp              !< namelist parameter
1465    REAL(wp) ::  e_init = 0.0_wp                               !< namelist parameter
1466    REAL(wp) ::  e_min = 0.0_wp                                !< namelist parameter
1467    REAL(wp) ::  end_time = 0.0_wp                             !< namelist parameter
1468    REAL(wp) ::  f = 0.0_wp                                    !< Coriolis parameter
1469    REAL(wp) ::  fs = 0.0_wp                                   !< Coriolis parameter
1470    REAL(wp) ::  inflow_damping_height = 9999999.9_wp          !< namelist parameter
1471    REAL(wp) ::  inflow_damping_width = 9999999.9_wp           !< namelist parameter
1472    REAL(wp) ::  km_constant = -1.0_wp                         !< namelist parameter
1473    REAL(wp) ::  latitude = 55.0_wp                            !< namelist parameter
1474    REAL(wp) ::  longitude = 0.0_wp                            !< namelist parameter
1475    REAL(wp) ::  mask_scale_x = 1.0_wp                         !< namelist parameter
1476    REAL(wp) ::  mask_scale_y = 1.0_wp                         !< namelist parameter
1477    REAL(wp) ::  mask_scale_z = 1.0_wp                         !< namelist parameter
1478    REAL(wp) ::  maximum_cpu_time_allowed = 0.0_wp             !< given wall time for run
1479    REAL(wp) ::  molecular_viscosity = 1.461E-5_wp             !< molecular viscosity (used in lsm and lpm)
1480    REAL(wp) ::  multi_agent_system_end   = 9999999.9_wp       !< namelist parameter (see documentation)
1481    REAL(wp) ::  multi_agent_system_start = 0.0_wp             !< namelist parameter (see documentation)
1482    REAL(wp) ::  old_dt = 1.0E-10_wp                           !< length of previous timestep
1483    REAL(wp) ::  omega = 7.29212E-5_wp                         !< namelist parameter
1484    REAL(wp) ::  omega_sor = 1.8_wp                            !< namelist parameter
1485    REAL(wp) ::  outflow_source_plane = -9999999.9_wp          !< namelist parameter
1486    REAL(wp) ::  particle_maximum_age = 9999999.9_wp           !< namelist parameter
1487    REAL(wp) ::  prandtl_number = 1.0_wp                       !< namelist parameter
1488    REAL(wp) ::  pt_damping_factor = 0.0_wp                    !< namelist parameter
1489    REAL(wp) ::  pt_damping_width = 0.0_wp                     !< namelist parameter
1490    REAL(wp) ::  pt_reference = 9999999.9_wp                   !< namelist parameter
1491    REAL(wp) ::  pt_slope_offset = 0.0_wp                      !< temperature difference between left and right
1492                                                               !< boundary of total domain
1493    REAL(wp) ::  pt_surface = 300.0_wp                         !< namelist parameter
1494    REAL(wp) ::  pt_surface_initial_change = 0.0_wp            !< namelist parameter
1495    REAL(wp) ::  q_surface = 0.0_wp                            !< namelist parameter
1496    REAL(wp) ::  q_surface_initial_change = 0.0_wp             !< namelist parameter
1497    REAL(wp) ::  rayleigh_damping_factor = -1.0_wp             !< namelist parameter
1498    REAL(wp) ::  rayleigh_damping_height = -1.0_wp             !< namelist parameter
1499    REAL(wp) ::  recycling_width = 9999999.9_wp                !< namelist parameter
1500    REAL(wp) ::  residual_limit = 1.0E-4_wp                    !< namelist parameter
1501    REAL(wp) ::  restart_time = 9999999.9_wp                   !< namelist parameter
1502    REAL(wp) ::  rho_reference                                 !< reference state of density
1503    REAL(wp) ::  rho_surface                                   !< surface value of density
1504    REAL(wp) ::  roughness_length = 0.1_wp                     !< namelist parameter
1505    REAL(wp) ::  simulated_time = 0.0_wp                       !< elapsed simulated time
1506    REAL(wp) ::  simulated_time_at_begin                       !< elapsed simulated time of previous run (job chain)
1507    REAL(wp) ::  sin_alpha_surface                             !< sine of alpha_surface (sloped surface)
1508    REAL(wp) ::  skip_time_data_output = 0.0_wp                !< namelist parameter
1509    REAL(wp) ::  skip_time_data_output_av = 9999999.9_wp       !< namelist parameter
1510    REAL(wp) ::  skip_time_dopr = 9999999.9_wp                 !< namelist parameter
1511    REAL(wp) ::  skip_time_do2d_xy = 9999999.9_wp              !< namelist parameter
1512    REAL(wp) ::  skip_time_do2d_xz = 9999999.9_wp              !< namelist parameter
1513    REAL(wp) ::  skip_time_do2d_yz = 9999999.9_wp              !< namelist parameter
1514    REAL(wp) ::  skip_time_do3d = 9999999.9_wp                 !< namelist parameter
1515    REAL(wp) ::  spinup_pt_amplitude = 9999999.9_wp            !< namelist parameter
1516    REAL(wp) ::  spinup_pt_mean = 9999999.9_wp                 !< namelist parameter
1517    REAL(wp) ::  spinup_time = 0.0_wp                          !< namelist parameter
1518    REAL(wp) ::  surface_heatflux = 9999999.9_wp               !< namelist parameter
1519    REAL(wp) ::  surface_pressure = 1013.25_wp                 !< namelist parameter
1520    REAL(wp) ::  surface_scalarflux = 9999999.9_wp             !< namelist parameter
1521    REAL(wp) ::  surface_waterflux = 9999999.9_wp              !< namelist parameter
1522    REAL(wp) ::  s_surface = 0.0_wp                            !< namelist parameter
1523    REAL(wp) ::  s_surface_initial_change = 0.0_wp             !< namelist parameter
1524    REAL(wp) ::  termination_time_needed = 35.0_wp             !< namelist parameter
1525    REAL(wp) ::  time_coupling = 0.0_wp                        !< time since last coupling (surface_coupler)
1526    REAL(wp) ::  time_disturb = 0.0_wp                         !< time since last flow disturbance
1527    REAL(wp) ::  time_dopr = 0.0_wp                            !< time since last profile output
1528    REAL(wp) ::  time_dopr_av = 0.0_wp                         !< time since last averaged profile output
1529    REAL(wp) ::  time_dopr_listing = 0.0_wp                    !< time since last profile output (ASCII) on file
1530    REAL(wp) ::  time_dopts = 0.0_wp                           !< time since last particle timeseries output
1531    REAL(wp) ::  time_dosp = 0.0_wp                            !< time since last spectra output
1532    REAL(wp) ::  time_dosp_av = 0.0_wp                         !< time since last averaged spectra output
1533    REAL(wp) ::  time_dots = 0.0_wp                            !< time since last timeseries output
1534    REAL(wp) ::  time_do2d_xy = 0.0_wp                         !< time since last xy cross-section output
1535    REAL(wp) ::  time_do2d_xz = 0.0_wp                         !< time since last xz cross-section output
1536    REAL(wp) ::  time_do2d_yz = 0.0_wp                         !< time since last yz cross-section output
1537    REAL(wp) ::  time_do3d = 0.0_wp                            !< time since last 3d output
1538    REAL(wp) ::  time_do_av = 0.0_wp                           !< time since last averaged-data output
1539    REAL(wp) ::  time_do_sla = 0.0_wp                          !< time since last
1540    REAL(wp) ::  time_dvrp = 0.0_wp                            !< time since last dvrp output
1541    REAL(wp) ::  time_restart = 9999999.9_wp                   !< time at which run shall be terminated and restarted
1542    REAL(wp) ::  time_run_control = 0.0_wp                     !< time since last RUN_CONTROL output
1543    REAL(wp) ::  time_since_reference_point = 0.0_wp           !< time after atmosphere-ocean coupling has been activated, or time after spinup phase of LSM has been finished
1544    REAL(wp) ::  top_heatflux = 9999999.9_wp                   !< namelist parameter
1545    REAL(wp) ::  top_momentumflux_u = 9999999.9_wp             !< namelist parameter
1546    REAL(wp) ::  top_momentumflux_v = 9999999.9_wp             !< namelist parameter
1547    REAL(wp) ::  top_salinityflux = 9999999.9_wp               !< namelist parameter
1548    REAL(wp) ::  top_scalarflux = 9999999.9_wp                 !< namelist parameter
1549    REAL(wp) ::  tunnel_height = 9999999.9_wp                  !< namelist parameter
1550    REAL(wp) ::  tunnel_length = 9999999.9_wp                  !< namelist parameter
1551    REAL(wp) ::  tunnel_width_x = 9999999.9_wp                 !< namelist parameter
1552    REAL(wp) ::  tunnel_width_y = 9999999.9_wp                 !< namelist parameter
1553    REAL(wp) ::  tunnel_wall_depth = 9999999.9_wp              !< namelist parameter
1554    REAL(wp) ::  ug_surface = 0.0_wp                           !< namelist parameter
1555    REAL(wp) ::  u_bulk = 0.0_wp                               !< namelist parameter
1556    REAL(wp) ::  u_gtrans = 0.0_wp                             !< transformed wind component (galilei transformation)
1557    REAL(wp) ::  vg_surface = 0.0_wp                           !< namelist parameter
1558    REAL(wp) ::  vpt_reference = 9999999.9_wp                  !< reference state of virtual potential temperature
1559    REAL(wp) ::  v_bulk = 0.0_wp                               !< namelist parameter
1560    REAL(wp) ::  v_gtrans = 0.0_wp                             !< transformed wind component (galilei transformation)
1561    REAL(wp) ::  wall_adjustment_factor = 1.8_wp               !< adjustment factor for mixing length l
1562    REAL(wp) ::  zeta_max = 20.0_wp                            !< namelist parameter
1563    REAL(wp) ::  zeta_min = -20.0_wp                           !< namelist parameter
1564    REAL(wp) ::  z0h_factor = 1.0_wp                           !< namelist parameter
1565
1566    REAL(wp) ::  do2d_xy_last_time(0:1) = -1.0_wp                  !< time of previous xy output
1567    REAL(wp) ::  do2d_xz_last_time(0:1) = -1.0_wp                  !< time of previous xz output
1568    REAL(wp) ::  do2d_yz_last_time(0:1) = -1.0_wp                  !< time of previous yz output
1569    REAL(wp) ::  dpdxy(1:2) = 0.0_wp                               !< namelist parameter
1570    REAL(wp) ::  dt_domask(max_masks) = 9999999.9_wp               !< namelist parameter
1571    REAL(wp) ::  dz(10) = -1.0_wp                                  !< namelist parameter
1572    REAL(wp) ::  dz_stretch_level_start(9) = -9999999.9_wp         !< namelist parameter
1573    REAL(wp) ::  dz_stretch_level_end(9) = 9999999.9_wp            !< namelist parameter
1574    REAL(wp) ::  dz_stretch_factor_array(9) = 1.08_wp              !< namelist parameter
1575    REAL(wp) ::  mask_scale(3)                                     !< collective array for mask_scale_x/y/z
1576    REAL(wp) ::  pt_vertical_gradient(10) = 0.0_wp                 !< namelist parameter
1577    REAL(wp) ::  pt_vertical_gradient_level(10) = -999999.9_wp   !< namelist parameter
1578    REAL(wp) ::  q_vertical_gradient(10) = 0.0_wp                  !< namelist parameter
1579    REAL(wp) ::  q_vertical_gradient_level(10) = -999999.9_wp    !< namelist parameter
1580    REAL(wp) ::  s_vertical_gradient(10) = 0.0_wp                  !< namelist parameter
1581    REAL(wp) ::  s_vertical_gradient_level(10) = -999999.9_wp    !< namelist parameter
1582    REAL(wp) ::  skip_time_domask(max_masks) = 9999999.9_wp        !< namelist parameter
1583    REAL(wp) ::  threshold(20) = 0.0_wp                            !< namelist parameter
1584    REAL(wp) ::  time_domask(max_masks) = 0.0_wp                   !< namelist parameter
1585    REAL(wp) ::  tsc(10) = (/ 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, &    !< array used for controlling time-integration at different substeps
1586                 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp /)
1587    REAL(wp) ::  u_profile(200) = 9999999.9_wp                     !< namelist parameter
1588    REAL(wp) ::  uv_heights(200) = 9999999.9_wp                    !< namelist parameter
1589    REAL(wp) ::  v_profile(200) = 9999999.9_wp                     !< namelist parameter
1590    REAL(wp) ::  ug_vertical_gradient(10) = 0.0_wp                 !< namelist parameter
1591    REAL(wp) ::  ug_vertical_gradient_level(10) = -9999999.9_wp    !< namelist parameter
1592    REAL(wp) ::  vg_vertical_gradient(10) = 0.0_wp                 !< namelist parameter
1593    REAL(wp) ::  vg_vertical_gradient_level(10) = -9999999.9_wp    !< namelist parameter
1594    REAL(wp) ::  volume_flow(1:3) = 0.0_wp                         !< volume flow through 1:yz-plane, 2: xz-plane, 3: xy-plane (nest childs only)
1595    REAL(wp) ::  volume_flow_area(1:3) = 0.0_wp                    !< area of the respective volume flow planes
1596    REAL(wp) ::  volume_flow_initial(1:3) = 0.0_wp                 !< initial volume flow (t=0) through the respective volume flow planes
1597    REAL(wp) ::  wall_heatflux(0:5) = 0.0_wp                       !< namelist parameter
1598    REAL(wp) ::  wall_humidityflux(0:5) = 0.0_wp                   !< namelist parameter
1599    REAL(wp) ::  wall_salinityflux(0:5) = 0.0_wp                   !< namelist parameter
1600    REAL(wp) ::  wall_scalarflux(0:5) = 0.0_wp                     !< namelist parameter
1601    REAL(wp) ::  subs_vertical_gradient(10) = 0.0_wp               !< namelist parameter
1602    REAL(wp) ::  subs_vertical_gradient_level(10) = -9999999.9_wp  !< namelist parameter
1603
1604    REAL(wp), DIMENSION(:), ALLOCATABLE ::  dp_smooth_factor  !< smoothing factor for external pressure gradient forcing
1605
1606    REAL(wp), DIMENSION(max_masks,mask_xyz_dimension) ::  mask_x = -1.0_wp  !< namelist parameter
1607    REAL(wp), DIMENSION(max_masks,mask_xyz_dimension) ::  mask_y = -1.0_wp  !< namelist parameter
1608    REAL(wp), DIMENSION(max_masks,mask_xyz_dimension) ::  mask_z = -1.0_wp  !< namelist parameter
1609   
1610    REAL(wp), DIMENSION(max_masks,3) ::  mask_x_loop = -1.0_wp  !< namelist parameter
1611    REAL(wp), DIMENSION(max_masks,3) ::  mask_y_loop = -1.0_wp  !< namelist parameter
1612    REAL(wp), DIMENSION(max_masks,3) ::  mask_z_loop = -1.0_wp  !< namelist parameter
1613   
1614!
1615!--    internal mask arrays ("mask,dimension,selection")
1616       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  mask       !< collective array for mask_x/y/z
1617       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  mask_loop  !< collective array for mask_x/y/z_loop
1618
1619    SAVE
1620
1621 END MODULE control_parameters
1622
1623
1624!------------------------------------------------------------------------------!
1625! Description:
1626! ------------
1627!> Definition of variables used with dvrp-software.
1628!------------------------------------------------------------------------------!
1629 MODULE dvrp_variables
1630
1631    USE kinds
1632
1633    CHARACTER (LEN=10) ::  dvrp_output = 'rtsp'        !< dvr namelist parameter
1634    CHARACTER (LEN=10) ::  particle_color = 'none'     !< dvr namelist parameter
1635    CHARACTER (LEN=10) ::  particle_dvrpsize = 'none'  !< dvr namelist parameter
1636
1637    CHARACTER (LEN=20), DIMENSION(10) ::  mode_dvrp = &  !< dvr namelist parameter
1638                                     (/ ( '                    ', i9 = 1,10 ) /)
1639
1640    CHARACTER (LEN=80) ::  dvrp_directory = 'default'                     !< dvr namelist parameter
1641    CHARACTER (LEN=80) ::  dvrp_file      = 'default'                     !< dvr namelist parameter
1642    CHARACTER (LEN=80) ::  dvrp_host      = 'origin.rvs.uni-hannover.de'  !< dvr namelist parameter
1643    CHARACTER (LEN=80) ::  dvrp_password  = '********'                    !< dvr namelist parameter
1644    CHARACTER (LEN=80) ::  dvrp_username  = ' '                           !< dvr namelist parameter
1645
1646    INTEGER(iwp) ::  cluster_size = 1                   !< dvr namelist parameter
1647    INTEGER(iwp) ::  dvrp_colortable_entries = 4        !< internal dvr software variable
1648    INTEGER(iwp) ::  dvrp_colortable_entries_prt = 22   !< internal dvr software variable
1649    INTEGER(iwp) ::  islice_dvrp                        !< internal dvr software variable
1650    INTEGER(iwp) ::  nx_dvrp                            !< internal dvr software variable
1651    INTEGER(iwp) ::  nxl_dvrp                           !< internal dvr software variable
1652    INTEGER(iwp) ::  nxr_dvrp                           !< internal dvr software variable
1653    INTEGER(iwp) ::  ny_dvrp                            !< internal dvr software variable
1654    INTEGER(iwp) ::  nyn_dvrp                           !< internal dvr software variable
1655    INTEGER(iwp) ::  nys_dvrp                           !< internal dvr software variable
1656    INTEGER(iwp) ::  nz_dvrp                            !< internal dvr software variable
1657    INTEGER(iwp) ::  pathlines_fadeintime = 5           !< dvr namelist parameter
1658    INTEGER(iwp) ::  pathlines_fadeouttime = 5          !< dvr namelist parameter
1659    INTEGER(iwp) ::  pathlines_linecount = 1000         !< dvr namelist parameter
1660    INTEGER(iwp) ::  pathlines_maxhistory = 40          !< dvr namelist parameter
1661    INTEGER(iwp) ::  pathlines_wavecount = 10           !< dvr namelist parameter
1662    INTEGER(iwp) ::  pathlines_wavetime = 50            !< dvr namelist parameter
1663    INTEGER(iwp) ::  vc_gradient_normals = 0            !< dvr namelist parameter
1664    INTEGER(iwp) ::  vc_mode = 0                        !< dvr namelist parameter
1665    INTEGER(iwp) ::  vc_size_x = 2                      !< dvr namelist parameter
1666    INTEGER(iwp) ::  vc_size_y = 2                      !< dvr namelist parameter
1667    INTEGER(iwp) ::  vc_size_z = 2                      !< dvr namelist parameter
1668
1669    INTEGER(iwp), DIMENSION(10) ::  slicer_position_dvrp  !< internal dvr software variable
1670
1671    LOGICAL ::  cyclic_dvrp = .FALSE.                      !< internal dvr software variable
1672    LOGICAL ::  dvrp_overlap                               !< internal dvr software variable
1673    LOGICAL ::  dvrp_total_overlap                         !< internal dvr software variable
1674    LOGICAL ::  local_dvrserver_running                    !< namelist parameter (ENVPAR namelist provided by palmrun)
1675    LOGICAL ::  lock_steering_update = .FALSE.             !< internal dvr software variable
1676    LOGICAL ::  use_seperate_pe_for_dvrp_output = .FALSE.  !< internal dvr software variable
1677
1678    REAL(wp) ::  clip_dvrp_l = 9999999.9_wp  !< dvr namelist parameter
1679    REAL(wp) ::  clip_dvrp_n = 9999999.9_wp  !< dvr namelist parameter
1680    REAL(wp) ::  clip_dvrp_r = 9999999.9_wp  !< dvr namelist parameter
1681    REAL(wp) ::  clip_dvrp_s = 9999999.9_wp  !< dvr namelist parameter
1682    REAL(wp) ::  superelevation = 1.0_wp     !< dvr namelist parameter
1683    REAL(wp) ::  superelevation_x = 1.0_wp   !< dvr namelist parameter
1684    REAL(wp) ::  superelevation_y = 1.0_wp   !< dvr namelist parameter
1685    REAL(wp) ::  vc_alpha = 38.0_wp          !< dvr namelist parameter
1686
1687    REAL(wp), DIMENSION(2) ::  color_interval = (/ 0.0_wp, 1.0_wp /)     !< dvr namelist parameter
1688    REAL(wp), DIMENSION(2) ::  dvrpsize_interval = (/ 0.0_wp, 1.0_wp /)  !< dvr namelist parameter
1689
1690    REAL(wp), DIMENSION(3) ::  groundplate_color = (/ 0.0_wp, 0.6_wp, 0.0_wp /)  !< dvr namelist parameter
1691    REAL(wp), DIMENSION(3) ::  topography_color = (/ 0.8_wp, 0.7_wp, 0.6_wp /)   !< dvr namelist parameter
1692
1693    REAL(wp), DIMENSION(2,10) ::  slicer_range_limits_dvrp  !< dvr namelist parameter
1694
1695    REAL(wp), DIMENSION(3,10) ::  isosurface_color  !< dvr namelist parameter
1696
1697    REAL(sp), DIMENSION(2,100) ::  interval_values_dvrp          !< internal dvr software variable
1698    REAL(sp), DIMENSION(2,100) ::  interval_values_dvrp_prt      !< internal dvr software variable
1699    REAL(sp), DIMENSION(2,100) ::  interval_h_dvrp               !< internal dvr software variable
1700    REAL(sp), DIMENSION(2,100) ::  interval_h_dvrp_prt           !< internal dvr software variable
1701    REAL(sp), DIMENSION(2,100) ::  interval_l_dvrp = 0.5_sp      !< internal dvr software variable
1702    REAL(sp), DIMENSION(2,100) ::  interval_l_dvrp_prt = 0.5_sp  !< internal dvr software variable
1703    REAL(sp), DIMENSION(2,100) ::  interval_s_dvrp = 1.0_sp      !< internal dvr software variable
1704    REAL(sp), DIMENSION(2,100) ::  interval_s_dvrp_prt = 1.0_sp  !< internal dvr software variable
1705    REAL(sp), DIMENSION(2,100) ::  interval_a_dvrp = 0.0_sp      !< internal dvr software variable
1706    REAL(sp), DIMENSION(2,100) ::  interval_a_dvrp_prt = 0.0_sp  !< internal dvr software variable
1707
1708    DATA  slicer_range_limits_dvrp / -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, &  !< internal dvr software variable
1709                                     -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, &
1710                                     -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp, &
1711                                     -1.0_wp, 1.0_wp /
1712
1713    DATA  isosurface_color / 0.9_wp, 0.9_wp, 0.9_wp,  0.8_wp, 0.1_wp, 0.1_wp,  0.1_wp, 0.1_wp, 0.8_wp, &  !< internal dvr software variable
1714                             0.1_wp, 0.8_wp, 0.1_wp,  0.6_wp, 0.1_wp, 0.1_wp,  0.1_wp, 0.1_wp, 0.6_wp, &
1715                             0.1_wp, 0.6_wp, 0.1_wp,  0.4_wp, 0.1_wp, 0.1_wp,  0.1_wp, 0.1_wp, 0.4_wp, &
1716                             0.1_wp, 0.4_wp, 0.1_wp /
1717
1718    DATA  interval_h_dvrp / 270.0_wp, 225.0_wp, 225.0_wp, 180.0_wp, 70.0_wp, 25.0_wp, &  !< internal dvr software variable
1719                            25.0_wp, -25.0_wp, 192 * 0.0_wp /
1720
1721    DATA  interval_h_dvrp_prt / 270.0_wp, 225.0_wp, 225.0_wp, 180.0_wp, 70.0_wp, 25.0_wp, &  !< internal dvr software variable
1722                                25.0_wp, -25.0_wp, 192 * 0.0_wp /
1723
1724    REAL(sp), DIMENSION(:), ALLOCATABLE ::  xcoor_dvrp  !< internal dvr software variable
1725    REAL(sp), DIMENSION(:), ALLOCATABLE ::  ycoor_dvrp  !< internal dvr software variable
1726    REAL(sp), DIMENSION(:), ALLOCATABLE ::  zcoor_dvrp  !< internal dvr software variable
1727
1728    TYPE steering
1729       CHARACTER (LEN=24) ::  name  !< internal dvr software variable
1730       REAL(sp)           ::  min   !< internal dvr software variable
1731       REAL(sp)           ::  max   !< internal dvr software variable
1732       INTEGER(iwp)       ::  imin  !< internal dvr software variable
1733       INTEGER(iwp)       ::  imax  !< internal dvr software variable
1734    END TYPE steering
1735
1736    TYPE(steering), DIMENSION(:), ALLOCATABLE ::  steering_dvrp  !< internal dvr software variable
1737
1738    SAVE
1739
1740 END MODULE dvrp_variables
1741
1742
1743!------------------------------------------------------------------------------!
1744! Description:
1745! ------------
1746!> Definition of grid spacings.
1747!------------------------------------------------------------------------------!
1748 MODULE grid_variables
1749
1750    USE kinds
1751
1752    REAL(wp) ::  ddx          !< 1/dx
1753    REAL(wp) ::  ddx2         !< 1/dx2
1754    REAL(wp) ::  dx = 1.0_wp  !< horizontal grid size (along x-direction)
1755    REAL(wp) ::  dx2          !< dx*dx
1756    REAL(wp) ::  ddy          !< 1/dy
1757    REAL(wp) ::  ddy2         !< 1/dy2
1758    REAL(wp) ::  dy = 1.0_wp  !< horizontal grid size (along y-direction)
1759    REAL(wp) ::  dy2          !< dy*dy
1760
1761    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ddx2_mg  !< 1/dx_l**2 (dx_l: grid spacing along x on different multigrid level)
1762    REAL(wp), DIMENSION(:), ALLOCATABLE ::  ddy2_mg  !< 1/dy_l**2 (dy_l: grid spacing along y on different multigrid level)
1763
1764    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zu_s_inner  !< height of topography top on scalar grid
1765    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zw_w_inner  !< height of topography top on w grid
1766                                             
1767    SAVE
1768
1769 END MODULE grid_variables
1770
1771
1772!------------------------------------------------------------------------------!
1773! Description:
1774! ------------
1775!> Definition of array bounds, number of gridpoints, and wall flag arrays.
1776!------------------------------------------------------------------------------!
1777 MODULE indices
1778
1779    USE kinds
1780
1781    INTEGER(iwp) ::  nbgp = 3       !< number of boundary ghost points
1782    INTEGER(iwp) ::  ngp_sums       !< number of vertical profile grid points time number of output profiles - used for allreduce statements in MPI calls
1783    INTEGER(iwp) ::  ngp_sums_ls    !< number of vertical profile grid points time number of large-scale forcing profiles - used for allreduce statements in MPI calls
1784    INTEGER(iwp) ::  nnx            !< number of subdomain grid points in x-direction
1785    INTEGER(iwp) ::  nx = 0         !< nx+1 = total number of grid points in x-direction
1786    INTEGER(iwp) ::  nx_a           !< in coupled atmosphere-ocean runs: total number of grid points along x (atmosphere)
1787    INTEGER(iwp) ::  nx_o           !< in coupled atmosphere-ocean runs: total number of grid points along x (ocean)
1788    INTEGER(iwp) ::  nxl            !< left-most grid index of subdomain (excluding ghost points)
1789    INTEGER(iwp) ::  nxlg           !< left-most grid index of subdomain (including ghost points)
1790    INTEGER(iwp) ::  nxlu           !< =nxl+1 (at left domain boundary with inflow from left), else =nxl (used for u-velocity component)
1791    INTEGER(iwp) ::  nxr            !< right-most grid index of subdomain (excluding ghost points)
1792    INTEGER(iwp) ::  nxrg           !< right-most grid index of subdomain (including ghost points)
1793    INTEGER(iwp) ::  nx_on_file     !< nx of previous run in job chain
1794    INTEGER(iwp) ::  nny            !< number of subdomain grid points in y-direction
1795    INTEGER(iwp) ::  ny = 0         !< ny+1 = total number of grid points in y-direction
1796    INTEGER(iwp) ::  ny_a           !< in coupled atmosphere-ocean runs: total number of grid points along y (atmosphere)
1797    INTEGER(iwp) ::  ny_o           !< in coupled atmosphere-ocean runs: total number of grid points along y (ocean)
1798    INTEGER(iwp) ::  nyn            !< north-most grid index of subdomain (excluding ghost points)
1799    INTEGER(iwp) ::  nyng           !< north-most grid index of subdomain (including ghost points)
1800    INTEGER(iwp) ::  nys            !< south-most grid index of subdomain (excluding ghost points)
1801    INTEGER(iwp) ::  nysg           !< south-most grid index of subdomain (including ghost points)
1802    INTEGER(iwp) ::  nysv           !< =nys+1 (at south domain boundary with inflow from south), else =nys (used for v-velocity component)
1803    INTEGER(iwp) ::  ny_on_file     !< ny of previous run in job chain
1804    INTEGER(iwp) ::  nnz            !< number of subdomain grid points in z-direction
1805    INTEGER(iwp) ::  nz = 0         !< total number of grid points in z-direction
1806    INTEGER(iwp) ::  nzb            !< bottom grid index of computational domain
1807    INTEGER(iwp) ::  nzb_diff       !< will be removed
1808    INTEGER(iwp) ::  nzb_max        !< vertical index of topography top
1809    INTEGER(iwp) ::  nzt            !< nzt+1 = top grid index of computational domain
1810    INTEGER(iwp) ::  topo_min_level !< minimum topography-top index (usually equal to nzb)
1811
1812    INTEGER(idp), DIMENSION(:), ALLOCATABLE ::  ngp_3d        !< number of grid points of the total domain
1813    INTEGER(idp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner  !< ! need to have 64 bit for grids > 2E9
1814                   
1815    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_2dh  !< number of grid points of a horizontal cross section through the total domain
1816    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nxl_mg   !< left-most grid index of subdomain on different multigrid level
1817    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nxr_mg   !< right-most grid index of subdomain on different multigrid level
1818    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nyn_mg   !< north-most grid index of subdomain on different multigrid level
1819    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nys_mg   !< south-most grid index of subdomain on different multigrid level
1820    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nzt_mg   !< top-most grid index of subdomain on different multigrid level
1821
1822
1823    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_outer     !< number of horizontal grid points which are non-topography and non-surface-bounded
1824    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_s_inner   !< number of horizontal grid points which are non-topography
1825    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  mg_loc_ind        !< internal array to store index bounds of all PEs of that multigrid level where data is collected to PE0
1826    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_diff_s_inner  !< will be removed
1827    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_diff_s_outer  !< will be removed
1828    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_inner         !< will be removed
1829    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_outer         !< will be removed
1830    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_s_inner       !< will be removed
1831    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_s_outer       !< will be removed
1832    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_u_inner       !< will be removed
1833    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_u_outer       !< will be removed
1834    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_v_inner       !< will be removed
1835    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_v_outer       !< will be removed
1836    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_w_inner       !< will be removed
1837    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_w_outer       !< will be removed
1838
1839    INTEGER(iwp), DIMENSION(:,:,:), POINTER ::  flags  !< pointer to wall_flags_1-10
1840
1841    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_1   !< topograpyh masking flag on multigrid level 1
1842    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_2   !< topograpyh masking flag on multigrid level 2
1843    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_3   !< topograpyh masking flag on multigrid level 3
1844    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_4   !< topograpyh masking flag on multigrid level 4
1845    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_5   !< topograpyh masking flag on multigrid level 5
1846    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_6   !< topograpyh masking flag on multigrid level 6
1847    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_7   !< topograpyh masking flag on multigrid level 7
1848    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_8   !< topograpyh masking flag on multigrid level 8
1849    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_9   !< topograpyh masking flag on multigrid level 9
1850    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_10  !< topograpyh masking flag on multigrid level 10
1851
1852    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_1            !< flags used to degrade order of advection scheme
1853    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_2            !< flags used to degrade order of advection scheme
1854    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  wall_flags_0            !< flags to mask topography and surface-bounded grid points
1855
1856    SAVE
1857
1858 END MODULE indices
1859
1860
1861!------------------------------------------------------------------------------!
1862! Description:
1863! ------------
1864!> Interfaces for special subroutines which use optional parameters.
1865!------------------------------------------------------------------------------!
1866 MODULE interfaces
1867
1868    INTERFACE
1869
1870!------------------------------------------------------------------------------!
1871! Description:
1872! ------------
1873!> @todo Missing subroutine description.
1874!------------------------------------------------------------------------------!
1875       SUBROUTINE global_min_max ( i1, i2, j1, j2, k1, k2, array, mode, offset, &
1876                                   result, result_ijk, result1, result1_ijk )
1877
1878          USE kinds
1879
1880          CHARACTER (LEN=*), INTENT(IN) ::  mode                      !< mode of global min/max function: can be 'min', 'max', 'minmax', 'abs', or 'absoff'
1881          INTEGER(iwp), INTENT(IN)      ::  i1                        !< internal index of min/max function
1882          INTEGER(iwp), INTENT(IN)      ::  i2                        !< internal index of min/max function
1883          INTEGER(iwp), INTENT(IN)      ::  j1                        !< internal index of min/max function
1884          INTEGER(iwp), INTENT(IN)      ::  j2                        !< internal index of min/max function
1885          INTEGER(iwp), INTENT(IN)      ::  k1                        !< internal index of min/max function
1886          INTEGER(iwp), INTENT(IN)      ::  k2                        !< internal index of min/max function
1887          INTEGER(iwp)                  ::  result_ijk(3)             !< grid index result of min/max function
1888          INTEGER(iwp), OPTIONAL        ::  result1_ijk(3)            !< optional grid index result of min/max function
1889          REAL(wp)                      ::  offset                    !< min/max function calculates absolute value with respect to an offset
1890          REAL(wp)                      ::  result                    !< result of min/max function
1891          REAL(wp), OPTIONAL            ::  result1                   !< optional result of min/max function
1892          REAL(wp), INTENT(IN)          ::  array(i1:i2,j1:j2,k1:k2)  !< input array of min/max function
1893
1894       END SUBROUTINE global_min_max
1895
1896    END INTERFACE
1897
1898    SAVE
1899
1900 END MODULE interfaces
1901
1902
1903!------------------------------------------------------------------------------!
1904! Description:
1905! ------------
1906!> Interfaces for subroutines with pointer arguments called in
1907!> prognostic_equations.
1908!------------------------------------------------------------------------------!
1909 MODULE pointer_interfaces
1910
1911    INTERFACE
1912
1913!------------------------------------------------------------------------------!
1914! Description:
1915! ------------
1916!> @todo Missing subroutine description.
1917!------------------------------------------------------------------------------!
1918       SUBROUTINE advec_s_bc( sk, sk_char )
1919
1920          USE kinds
1921
1922          CHARACTER (LEN=*), INTENT(IN) ::  sk_char  !< string for treated scalar in Bott-Chlond scheme
1923
1924          REAL(wp), DIMENSION(:,:,:), POINTER ::  sk  !< treated scalar array in Bott-Chlond scheme
1925
1926       END SUBROUTINE advec_s_bc
1927
1928    END INTERFACE
1929
1930    SAVE
1931
1932 END MODULE pointer_interfaces
1933
1934
1935!------------------------------------------------------------------------------!
1936! Description:
1937! ------------
1938!> Definition of variables which define processor topology and the exchange of
1939!> ghost point layers. This module must be placed in all routines containing
1940!> MPI-calls.
1941!------------------------------------------------------------------------------!
1942 MODULE pegrid
1943
1944    USE kinds
1945
1946#if defined( __parallel )
1947#if defined( __mpifh )
1948    INCLUDE "mpif.h"
1949#else
1950    USE MPI
1951#endif
1952#endif
1953    CHARACTER(LEN=2) ::  send_receive = 'al'     !<
1954    CHARACTER(LEN=7) ::  myid_char = ''          !< character string containing processor id number
1955   
1956    INTEGER(iwp) ::  comm1dx                     !< communicator for domain decomposition along x
1957    INTEGER(iwp) ::  comm1dy                     !< communicator for domain decomposition along y
1958    INTEGER(iwp) ::  comm2d                      !< standard 2d (xy) communicator used in PALM for the process group the PE belongs to
1959    INTEGER(iwp) ::  comm_inter                  !< intercommunicator that connects atmosphere/ocean process groups
1960    INTEGER(iwp) ::  comm_palm                   !< internal communicator used during the MPI setup at the beginning of a run
1961    INTEGER(iwp) ::  id_inflow = 0               !< myidx of procs at inflow (turbulent inflow method)
1962    INTEGER(iwp) ::  id_outflow = 0              !< myidx of procs at outflow (turbulent outflow method)
1963    INTEGER(iwp) ::  id_outflow_source = 0       !< myidx of procs including ouflow source plane (turbulent outflow method)
1964    INTEGER(iwp) ::  id_recycling = 0            !< myidx of procs containing the recycling plane (turbulence recycling method)
1965    INTEGER(iwp) ::  ierr                        !< standard error parameter in MPI calls
1966    INTEGER(iwp) ::  myid = 0                    !< id number of processor element
1967    INTEGER(iwp) ::  myidx = 0                   !< id number of processor elements with same position along x-direction
1968    INTEGER(iwp) ::  myidy = 0                   !< id number of processor elements with same position along y-direction
1969    INTEGER(iwp) ::  ndim = 2                    !< dimension of the virtual PE grid
1970    INTEGER(iwp) ::  ngp_a                       !< used in atmosphere/ocean coupling: total number of horizontal grid points (atmosphere)
1971    INTEGER(iwp) ::  ngp_o                       !< used in atmosphere/ocean coupling: total number of horizontal grid points (ocean)
1972    INTEGER(iwp) ::  ngp_xy                      !< used in atmosphere/ocean coupling: number of grid points of the subdomain
1973    INTEGER(iwp) ::  ngp_y                       !< number of subdomain grid points along y including ghost points
1974    INTEGER(iwp) ::  npex = -1                   !< number of processor elements in x-direction
1975    INTEGER(iwp) ::  npey = -1                   !< number of processor elements in y-direction
1976    INTEGER(iwp) ::  numprocs = 1                !< total number of appointed processor elements
1977    INTEGER(iwp) ::  numprocs_previous_run = -1  !< total number of appointed processor elements in previous run (job chain)
1978    INTEGER(iwp) ::  pleft                       !< MPI-address of the processor left of the current one
1979    INTEGER(iwp) ::  pnorth                      !< MPI-address of the processor north of the current one
1980    INTEGER(iwp) ::  pright                      !< MPI-address of the processor right of the current one
1981    INTEGER(iwp) ::  psouth                      !< MPI-address of the processor south of the current one
1982    INTEGER(iwp) ::  req_count = 0               !< MPI return variable - checks if Send-Receive operation is already finished
1983    INTEGER(iwp) ::  sendrecvcount_xy            !< number of subdomain gridpoints to be exchanged in direct transpositions (y --> x, or x --> y) or second (2d) transposition x --> y
1984    INTEGER(iwp) ::  sendrecvcount_yz            !< number of subdomain gridpoints to be exchanged in third (2d) transposition y --> z
1985    INTEGER(iwp) ::  sendrecvcount_zx            !< number of subdomain gridpoints to be exchanged in first (2d) transposition z --> x
1986    INTEGER(iwp) ::  sendrecvcount_zyd           !< number of subdomain gridpoints to be exchanged in direct transpositions z --> y (used for calculating spectra)
1987    INTEGER(iwp) ::  target_id                   !< in atmosphere/ocean coupling: id of the ocean/atmosphere counterpart PE with whom the atmosphere/ocean PE exchanges data
1988    INTEGER(iwp) ::  tasks_per_node = -9999      !< MPI tasks per compute node
1989    INTEGER(iwp) ::  threads_per_task = 1        !< number of OPENMP threads per MPI task
1990    INTEGER(iwp) ::  type_x                      !< derived MPI datatype for 2-D ghost-point exchange - north / south
1991    INTEGER(iwp) ::  type_xy                     !< derived MPI datatype for 2-D ghost-point exchange - north / south
1992    INTEGER(iwp) ::  type_y                      !< derived MPI datatype for 2-D exchange in atmosphere-ocean coupler
1993
1994    INTEGER(iwp) ::  pdims(2) = 1  !< number of processors along x-y dimension
1995    INTEGER(iwp) ::  req(100)      !< MPI return variable indicating if send-receive operation is finished
1996
1997    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  hor_index_bounds               !< horizontal index bounds
1998    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  hor_index_bounds_previous_run  !< horizontal index bounds of previous run
1999
2000    LOGICAL ::  collective_wait = .FALSE.          !< switch to set an explicit MPI barrier in front of all collective MPI calls
2001
2002#if defined( __parallel )
2003    INTEGER(iwp) ::  ibuf(12)                 !< internal buffer for calculating MPI settings
2004    INTEGER(iwp) ::  pcoord(2)                !< PE coordinates along x and y
2005    INTEGER(iwp) ::  status(MPI_STATUS_SIZE)  !< MPI status variable used in various MPI calls
2006   
2007    INTEGER(iwp), DIMENSION(MPI_STATUS_SIZE,100) ::  wait_stat  !< MPI status variable used in various MPI calls
2008   
2009    INTEGER(iwp) ::  type_x_byte !< derived MPI datatype for 2-D 8-bit integer ghost-point exchange - north / south
2010    INTEGER(iwp) ::  type_y_byte !< derived MPI datatype for 2-D integer ghost-point exchange - left / right
2011   
2012    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_xz      !< number of ghost points in xz-plane on different multigrid level
2013    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_xz_int  !< number of ghost points in xz-plane on different multigrid level
2014    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_yz      !< number of ghost points in yz-plane on different multigrid level
2015    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_yz_int  !< number of ghost points in yz-plane on different multigrid level
2016    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_x_int  !< derived MPI datatype for 2-D integer ghost-point exchange - north / south
2017    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_xz     !< derived MPI datatype for 3-D integer ghost-point exchange - north / south
2018    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_xz_int !< derived MPI datatype for 3-D integer ghost-point exchange - north / south
2019    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_y_int  !< derived MPI datatype for 2-D integer ghost-point exchange - left / right
2020    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_yz     !< derived MPI datatype for 3-D integer ghost-point exchange - left / right
2021    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  type_yz_int !< derived MPI datatype for 3-D integer ghost-point exchange - left / right
2022
2023    LOGICAL ::  left_border_pe  = .FALSE.  !< = .TRUE. if PE is on left border of computational domain
2024    LOGICAL ::  north_border_pe = .FALSE.  !< = .TRUE. if PE is on north border of computational domain
2025    LOGICAL ::  reorder = .TRUE.           !< switch to allow MPI the reorder of ranking (e.g. row-major or column-major)
2026    LOGICAL ::  right_border_pe = .FALSE.  !< = .TRUE. if PE is on right border of computational domain
2027    LOGICAL ::  south_border_pe = .FALSE.  !< = .TRUE. if PE is on south border of computational domain
2028
2029    LOGICAL, DIMENSION(2) ::  cyclic = (/ .TRUE. , .TRUE. /)  !< boundary conditions of the virtual PE grid
2030    LOGICAL, DIMENSION(2) ::  remain_dims                     !< internal array used to determine sub-topologies for transpositions
2031#endif
2032
2033    SAVE
2034
2035 END MODULE pegrid
2036
2037
2038!------------------------------------------------------------------------------!
2039! Description:
2040! ------------
2041!> Definition of variables which control PROFIL-output.
2042!------------------------------------------------------------------------------!
2043 MODULE profil_parameter
2044
2045    USE kinds
2046
2047    INTEGER(iwp), PARAMETER ::  crmax = 100  !< maximum number of coordinate systems for profile output
2048
2049    CHARACTER (LEN=27), DIMENSION(20) ::  cross_ts_profiles = &  !< time series to be plotted into one coordinate system, respectively
2050                           (/ ' E E*                      ', &
2051                              ' dt                        ', &
2052                              ' u* w*                     ', &
2053                              ' th*                       ', &
2054                              ' umax vmax wmax            ', &
2055                              ' div_old div_new           ', &
2056                              ' zi_wtheta zi_theta        ', &
2057                              ' w"theta"0 w"theta" wtheta ', &
2058                              ' theta(0) theta(zp)        ', &
2059                              ' splux spluy spluz         ', &
2060                              ' L                         ', &
2061                            ( '                           ', i9 = 1, 9 ) /)
2062
2063    CHARACTER (LEN=100), DIMENSION(crmax) ::  cross_profiles = &  !< quantities to be plotted into one coordinate system, respectively
2064                          (/ ' u v                                          ', &
2065                             ' pt                                           ', &
2066                             ' w"theta" w*theta* w*theta*BC wtheta wthetaBC ', &
2067                             ' w"u" w*u* wu w"v" w*v* wv                    ', &
2068                             ' km kh                                        ', &
2069                             ' l                                            ', &
2070             ( '                                              ', i9 = 1, 94 ) /)
2071
2072    INTEGER(iwp) ::  profile_columns = 2  !< number of coordinate systems on a profile plot per column
2073    INTEGER(iwp) ::  profile_rows = 3     !< number of coordinate systems on a profile plot per row
2074
2075    INTEGER(iwp) ::  dopr_index(300) = 0                !< index number of respective profile quantity
2076    INTEGER(iwp) ::  dopr_initial_index(300) = 0        !< index number of initial profiles to be output
2077               
2078    SAVE
2079
2080 END MODULE profil_parameter
2081
2082!------------------------------------------------------------------------------!
2083! Description:
2084! ------------
2085!> Definition of statistical quantities, e.g. global sums.
2086!------------------------------------------------------------------------------!
2087 MODULE statistics
2088
2089    USE kinds
2090
2091    CHARACTER (LEN=40) ::  region(0:9) =  &  !< label for statistic region
2092                           'total domain                            '
2093 
2094    INTEGER(iwp) ::  pr_palm = 200          !< maximum number of output profiles
2095    INTEGER(iwp) ::  statistic_regions = 0  !< identifier for statistic regions
2096
2097    INTEGER(iwp) ::  u_max_ijk(3) = -1  !< index values (i,j,k) of location where u_max occurs
2098    INTEGER(iwp) ::  v_max_ijk(3) = -1  !< index values (i,j,k) of location where v_max occurs
2099    INTEGER(iwp) ::  w_max_ijk(3) = -1  !< index values (i,j,k) of location where w_max occurs
2100   
2101    LOGICAL ::  flow_statistics_called = .FALSE.  !< flag that tells other routines if flow statistics was executed
2102                                                  !< (after each timestep)
2103   
2104    REAL(wp) ::  u_max = 0.0_wp  !< maximum of absolute u-veloctiy in entire domain
2105    REAL(wp) ::  v_max = 0.0_wp  !< maximum of absolute v-veloctiy in entire domain
2106    REAL(wp) ::  w_max = 0.0_wp  !< maximum of absolute w-veloctiy in entire domain
2107
2108    REAL(wp), DIMENSION(2) ::  z_i  !< inversion height
2109   
2110    REAL(wp), DIMENSION(:), ALLOCATABLE ::  mean_surface_level_height  !< mean surface level height for the different statistic regions
2111    REAL(wp), DIMENSION(:), ALLOCATABLE ::  sums_divnew_l              !< subdomain sum (_l) of divergence after pressure
2112                                                                       !< solver call (new)
2113    REAL(wp), DIMENSION(:), ALLOCATABLE ::  sums_divold_l              !< subdomain sum (_l) of divergence before pressure
2114                                                                       !< solver call (old)
2115    REAL(wp), DIMENSION(:), ALLOCATABLE ::  weight_substep             !< weighting factor for substeps in timestepping
2116    REAL(wp), DIMENSION(:), ALLOCATABLE ::  weight_pres                !< substep weighting factor for pressure solver
2117   
2118    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums             !< global sum array for the various output quantities
2119    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_salsa_ws_l  !< subdomain sum of vertical salsa flux w's' (5th-order advection scheme only)
2120    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsts_bc_l   !< subdomain sum of sensible heat flux in Bott-Chlond scheme
2121    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ts_value         !< timeseries output array for the various output quantities
2122    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsus_ws_l   !< subdomain sum of vertical momentum flux w'u' (5th-order advection scheme only)
2123    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsvs_ws_l   !< subdomain sum of vertical momentum flux w'v' (5th-order advection scheme only)
2124    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_us2_ws_l    !< subdomain sum of horizontal momentum flux u'u' (5th-order advection scheme only)
2125    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_vs2_ws_l    !< subdomain sum of horizontal momentum flux v'v' (5th-order advection scheme only)
2126    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_ws2_ws_l    !< subdomain sum of vertical momentum flux w'w' (5th-order advection scheme only)
2127    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsncs_ws_l  !< subdomain sum of vertical clouddrop-number concentration flux w'nc' (5th-order advection scheme only)
2128    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsnrs_ws_l  !< subdomain sum of vertical raindrop-number concentration flux w'nr' (5th-order advection scheme only)
2129    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wspts_ws_l  !< subdomain sum of vertical sensible heat flux w'pt' (5th-order advection scheme only)
2130    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqs_ws_l   !< subdomain sum of vertical latent heat flux w'q' (5th-order advection scheme only)
2131    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqcs_ws_l  !< subdomain sum of vertical cloudwater flux w'qc' (5th-order advection scheme only)
2132    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqrs_ws_l  !< subdomain sum of vertical rainwater flux w'qr' (5th-order advection scheme only)
2133    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wssas_ws_l  !< subdomain sum of vertical salinity flux w'sa' (5th-order advection scheme only)
2134    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsss_ws_l   !< subdomain sum of vertical passive scalar flux w's' (5th-order advection scheme only)
2135    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_ls_l        !< subdomain sum of large scale forcing and nudging tendencies
2136                                             
2137    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  hom_sum             !< sum array for horizontal mean
2138    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rmask               !< REAL flag array (0.0 or 1.0) for statistic regions
2139    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  sums_l              !< subdomain sum (_l) gathered for various quantities
2140    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  sums_l_l            !< subdomain sum (_l) of mixing length from diffusivities
2141   
2142    REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  hom  !< horizontal mean of various quantities (profiles/timeseries)
2143
2144    SAVE
2145
2146 END MODULE statistics
2147
2148
2149
2150!------------------------------------------------------------------------------!
2151! Description:
2152! ------------
2153!> Definition of indices for transposed arrays.
2154!------------------------------------------------------------------------------!
2155 MODULE transpose_indices
2156
2157    USE kinds
2158
2159    INTEGER(iwp) ::  nxl_y   !< internal index bound for transpositions
2160    INTEGER(iwp) ::  nxl_yd  !< internal index bound for transpositions
2161    INTEGER(iwp) ::  nxl_z   !< internal index bound for transpositions
2162    INTEGER(iwp) ::  nxr_y   !< internal index bound for transpositions
2163    INTEGER(iwp) ::  nxr_yd  !< internal index bound for transpositions
2164    INTEGER(iwp) ::  nxr_z   !< internal index bound for transpositions
2165    INTEGER(iwp) ::  nyn_x   !< internal index bound for transpositions
2166    INTEGER(iwp) ::  nyn_z   !< internal index bound for transpositions
2167    INTEGER(iwp) ::  nys_x   !< internal index bound for transpositions
2168    INTEGER(iwp) ::  nys_z   !< internal index bound for transpositions
2169    INTEGER(iwp) ::  nzb_x   !< internal index bound for transpositions
2170    INTEGER(iwp) ::  nzb_y   !< internal index bound for transpositions
2171    INTEGER(iwp) ::  nzb_yd  !< internal index bound for transpositions
2172    INTEGER(iwp) ::  nzt_x   !< internal index bound for transpositions
2173    INTEGER(iwp) ::  nzt_y   !< internal index bound for transpositions
2174    INTEGER(iwp) ::  nzt_yd  !< internal index bound for transpositions
2175               
2176    SAVE
2177
2178 END MODULE transpose_indices
Note: See TracBrowser for help on using the repository browser.