source: palm/trunk/SOURCE/check_parameters.f90 @ 1319

Last change on this file since 1319 was 1310, checked in by raasch, 10 years ago

update of GPL copyright

  • Property svn:keywords set to Id
File size: 148.0 KB
Line 
1 SUBROUTINE check_parameters
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: check_parameters.f90 1310 2014-03-14 08:01:56Z raasch $
27!
28! 1308 2014-03-13 14:58:42Z fricke
29! +netcdf_data_format_save
30! Calculate fixed number of output time levels for parallel netcdf output.
31! For masked data, parallel netcdf output is not tested so far, hence
32! netcdf_data_format is switched back to non-paralell output.
33!
34! 1299 2014-03-06 13:15:21Z heinze
35! enable usage of large_scale subsidence in combination with large_scale_forcing
36! output for profile of large scale vertical velocity w_subs added
37!
38! 1276 2014-01-15 13:40:41Z heinze
39! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars
40!
41! 1241 2013-10-30 11:36:58Z heinze
42! output for profiles of ug and vg added
43! set surface_heatflux and surface_waterflux also in dependence on
44! large_scale_forcing
45! checks for nudging and large scale forcing from external file
46!
47! 1236 2013-09-27 07:21:13Z raasch
48! check number of spectra levels
49!
50! 1216 2013-08-26 09:31:42Z raasch
51! check for transpose_compute_overlap (temporary)
52!
53! 1214 2013-08-21 12:29:17Z kanani
54! additional check for simultaneous use of vertical grid stretching
55! and particle advection
56!
57! 1212 2013-08-15 08:46:27Z raasch
58! checks for poisfft_hybrid removed
59!
60! 1210 2013-08-14 10:58:20Z raasch
61! check for fftw
62!
63! 1179 2013-06-14 05:57:58Z raasch
64! checks and settings of buoyancy parameters and switches revised,
65! initial profile for rho added to hom (id=77)
66!
67! 1174 2013-05-31 10:28:08Z gryschka
68! Bugfix in computing initial profiles for ug, vg, lad, q in case of Atmosphere
69!
70! 1159 2013-05-21 11:58:22Z fricke
71! bc_lr/ns_dirneu/neudir removed
72!
73! 1115 2013-03-26 18:16:16Z hoffmann
74! unused variables removed
75! drizzle can be used without precipitation
76!
77! 1111 2013-03-08 23:54:10Z raasch
78! ibc_p_b = 2 removed
79!
80! 1103 2013-02-20 02:15:53Z raasch
81! Bugfix: turbulent inflow must not require cyclic fill in restart runs
82!
83! 1092 2013-02-02 11:24:22Z raasch
84! unused variables removed
85!
86! 1069 2012-11-28 16:18:43Z maronga
87! allow usage of topography in combination with cloud physics
88!
89! 1065 2012-11-22 17:42:36Z hoffmann
90! Bugfix: It is not allowed to use cloud_scheme = seifert_beheng without
91!         precipitation in order to save computational resources.
92!
93! 1060 2012-11-21 07:19:51Z raasch
94! additional check for parameter turbulent_inflow
95!
96! 1053 2012-11-13 17:11:03Z hoffmann
97! necessary changes for the new two-moment cloud physics scheme added:
98! - check cloud physics scheme (Kessler or Seifert and Beheng)
99! - plant_canopy is not allowed
100! - currently, only cache loop_optimization is allowed
101! - initial profiles of nr, qr
102! - boundary condition of nr, qr
103! - check output quantities (qr, nr, prr)
104!
105! 1036 2012-10-22 13:43:42Z raasch
106! code put under GPL (PALM 3.9)
107!
108! 1031/1034 2012-10-22 11:32:49Z raasch
109! check of netcdf4 parallel file support
110!
111! 1019 2012-09-28 06:46:45Z raasch
112! non-optimized version of prognostic_equations not allowed any more
113!
114! 1015 2012-09-27 09:23:24Z raasch
115! acc allowed for loop optimization,
116! checks for adjustment of mixing length to the Prandtl mixing length removed
117!
118! 1003 2012-09-14 14:35:53Z raasch
119! checks for cases with unequal subdomain sizes removed
120!
121! 1001 2012-09-13 14:08:46Z raasch
122! all actions concerning leapfrog- and upstream-spline-scheme removed
123!
124! 996 2012-09-07 10:41:47Z raasch
125! little reformatting
126
127! 978 2012-08-09 08:28:32Z fricke
128! setting of bc_lr/ns_dirneu/neudir
129! outflow damping layer removed
130! check for z0h*
131! check for pt_damping_width
132!
133! 964 2012-07-26 09:14:24Z raasch
134! check of old profil-parameters removed
135!
136! 940 2012-07-09 14:31:00Z raasch
137! checks for parameter neutral
138!
139! 924 2012-06-06 07:44:41Z maronga
140! Bugfix: preprocessor directives caused error during compilation
141!
142! 892 2012-05-02 13:51:44Z maronga
143! Bugfix for parameter file check ( excluding __netcdf4 )
144!
145! 866 2012-03-28 06:44:41Z raasch
146! use only 60% of the geostrophic wind as translation speed in case of Galilean
147! transformation and use_ug_for_galilei_tr = .T. in order to mimimize the
148! timestep
149!
150! 861 2012-03-26 14:18:34Z suehring
151! Check for topography and ws-scheme removed.
152! Check for loop_optimization = 'vector' and ws-scheme removed.
153!
154! 845 2012-03-07 10:23:05Z maronga
155! Bugfix: exclude __netcdf4 directive part from namelist file check compilation
156!
157! 828 2012-02-21 12:00:36Z raasch
158! check of collision_kernel extended
159!
160! 825 2012-02-19 03:03:44Z raasch
161! check for collision_kernel and curvature_solution_effects
162!
163! 809 2012-01-30 13:32:58Z maronga
164! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
165!
166! 807 2012-01-25 11:53:51Z maronga
167! New cpp directive "__check" implemented which is used by check_namelist_files
168!
169! 774 2011-10-27 13:34:16Z letzel
170! bugfix for prescribed u,v-profiles
171!
172! 767 2011-10-14 06:39:12Z raasch
173! Calculating u,v-profiles from given profiles by linear interpolation.
174! bugfix: dirichlet_0 conditions for ug/vg moved from init_3d_model to here
175!
176! 707 2011-03-29 11:39:40Z raasch
177! setting of bc_lr/ns_dirrad/raddir
178!
179! 689 2011-02-20 19:31:12z gryschka
180! Bugfix for some logical expressions
181! (syntax was not compatible with all compilers)
182!
183! 680 2011-02-04 23:16:06Z gryschka
184! init_vortex is not allowed with volume_flow_control
185!
186! 673 2011-01-18 16:19:48Z suehring
187! Declaration of ws_scheme_sca and ws_scheme_mom added (moved from advec_ws).
188!
189! 667 2010-12-23 12:06:00Z suehring/gryschka
190! Exchange of parameters between ocean and atmosphere via PE0
191! Check for illegal combination of ws-scheme and timestep scheme.
192! Check for topography and ws-scheme.
193! Check for not cyclic boundary conditions in combination with ws-scheme and
194! loop_optimization = 'vector'.
195! Check for call_psolver_at_all_substeps and ws-scheme for momentum_advec.
196! Different processor/grid topology in atmosphere and ocean is now allowed!
197! Bugfixes in checking for conserve_volume_flow_mode
198! 600 2010-11-24 16:10:51Z raasch
199! change due to new default value of surface_waterflux
200! 580 2010-10-05 13:59:11Z heinze
201! renaming of ws_vertical_gradient_level to subs_vertical_gradient_level
202!
203! 567 2010-10-01 10:46:30Z helmke
204! calculating masks changed
205!
206! 564 2010-09-30 13:18:59Z helmke
207! palm message identifiers of masked output changed, 20 replaced by max_masks
208!
209! 553 2010-09-01 14:09:06Z weinreis
210! masks is calculated and removed from inipar
211!
212! 531 2010-04-21 06:47:21Z heinze
213! Bugfix: unit of hyp changed to dbar
214!
215! 524 2010-03-30 02:04:51Z raasch
216! Bugfix: "/" in netcdf profile variable names replaced by ":"
217!
218! 493 2010-03-01 08:30:24Z raasch
219! netcdf_data_format is checked
220!
221! 411 2009-12-11 14:15:58Z heinze
222! Enabled passive scalar/humidity wall fluxes for non-flat topography
223! Initialization of large scale vertical motion (subsidence/ascent)
224!
225! 410 2009-12-04 17:05:40Z letzel
226! masked data output
227!
228! 388 2009-09-23 09:40:33Z raasch
229! Check profiles fpr prho and hyp.
230! Bugfix: output of averaged 2d/3d quantities requires that an avaraging
231! interval has been set, respective error message is included
232! bc_lr_cyc and bc_ns_cyc are set,
233! initializing_actions='read_data_for_recycling' renamed to 'cyclic_fill'
234! Check for illegal entries in section_xy|xz|yz that exceed nz+1|ny+1|nx+1
235! Coupling with independent precursor runs.
236! Check particle_color, particle_dvrpsize, color_interval, dvrpsize_interval
237! Bugfix: pressure included for profile output
238! Check pressure gradient conditions
239! topography_grid_convention moved from user_check_parameters
240! 'single_street_canyon'
241! Added shf* and qsws* to the list of available output data
242!
243! 222 2009-01-12 16:04:16Z letzel
244! +user_check_parameters
245! Output of messages replaced by message handling routine.
246! Implementation of an MPI-1 coupling: replaced myid with target_id,
247! deleted __mpi2 directives
248! Check that PALM is called with mrun -K parallel for coupling
249!
250! 197 2008-09-16 15:29:03Z raasch
251! Bug fix: Construction of vertical profiles when 10 gradients have been
252! specified in the parameter list (ug, vg, pt, q, sa, lad)
253!   
254! Strict grid matching along z is not needed for mg-solver.
255! Leaf area density (LAD) explicitly set to its surface value at k=0
256! Case of reading data for recycling included in initializing_actions,
257! check of turbulent_inflow and calculation of recycling_plane.
258! q*2 profile added
259!
260! 138 2007-11-28 10:03:58Z letzel
261! Plant canopy added
262! Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
263! Multigrid solver allows topography, checking of dt_sort_particles
264! Bugfix: initializing u_init and v_init in case of ocean runs
265!
266! 109 2007-08-28 15:26:47Z letzel
267! Check coupling_mode and set default (obligatory) values (like boundary
268! conditions for temperature and fluxes) in case of coupled runs.
269! +profiles for w*p* and w"e
270! Bugfix: Error message concerning output of particle concentration (pc)
271! modified
272! More checks and more default values for coupled runs
273! allow data_output_pr= q, wq, w"q", w*q* for humidity = .T. (instead of
274! cloud_physics = .T.)
275! Rayleigh damping for ocean fixed.
276! Check and, if necessary, set default value for dt_coupling
277!
278! 97 2007-06-21 08:23:15Z raasch
279! Initial salinity profile is calculated, salinity boundary conditions are
280! checked,
281! z_max_do1d is checked only in case of ocean = .f.,
282! +initial temperature and geostrophic velocity profiles for the ocean version,
283! use_pt_reference renamed use_reference
284!
285! 89 2007-05-25 12:08:31Z raasch
286! Check for user-defined profiles
287!
288! 75 2007-03-22 09:54:05Z raasch
289! "by_user" allowed as initializing action, -data_output_ts,
290! leapfrog with non-flat topography not allowed any more, loop_optimization
291! and pt_reference are checked, moisture renamed humidity,
292! output of precipitation amount/rate and roughnes length + check
293! possible negative humidities are avoided in initial profile,
294! dirichlet/neumann changed to dirichlet/radiation, etc.,
295! revision added to run_description_header
296!
297! 20 2007-02-26 00:12:32Z raasch
298! Temperature and humidity gradients at top are now calculated for nzt+1,
299! top_heatflux and respective boundary condition bc_pt_t is checked
300!
301! RCS Log replace by Id keyword, revision history cleaned up
302!
303! Revision 1.61  2006/08/04 14:20:25  raasch
304! do2d_unit and do3d_unit now defined as 2d-arrays, check of
305! use_upstream_for_tke, default value for dt_dopts,
306! generation of file header moved from routines palm and header to here
307!
308! Revision 1.1  1997/08/26 06:29:23  raasch
309! Initial revision
310!
311!
312! Description:
313! ------------
314! Check control parameters and deduce further quantities.
315!------------------------------------------------------------------------------!
316
317    USE arrays_3d
318    USE cloud_parameters
319    USE constants
320    USE control_parameters
321    USE dvrp_variables
322    USE grid_variables
323    USE indices
324    USE model_1d
325    USE netcdf_control
326    USE particle_attributes
327    USE pegrid
328    USE profil_parameter
329    USE spectrum
330    USE statistics
331    USE subsidence_mod
332    USE statistics
333    USE transpose_indices
334
335    IMPLICIT NONE
336
337    CHARACTER (LEN=1)   ::  sq
338    CHARACTER (LEN=6)   ::  var
339    CHARACTER (LEN=7)   ::  unit
340    CHARACTER (LEN=8)   ::  date
341    CHARACTER (LEN=10)  ::  time
342    CHARACTER (LEN=40)  ::  coupling_string
343    CHARACTER (LEN=100) ::  action
344
345    INTEGER ::  i, ilen, iremote = 0, j, k, kk, netcdf_data_format_save, &
346                position, prec
347    LOGICAL ::  found, ldum
348    REAL    ::  gradient, remote = 0.0, simulation_time_since_reference
349
350!
351!-- Check for overlap combinations, which are not realized yet
352    IF ( transpose_compute_overlap )  THEN
353       IF ( numprocs == 1 )  STOP '+++ transpose-compute-overlap not implemented for single PE runs'
354#if defined( __openacc )
355       STOP '+++ transpose-compute-overlap not implemented for GPU usage'
356#endif
357    ENDIF
358
359!
360!-- Warning, if host is not set
361    IF ( host(1:1) == ' ' )  THEN
362       message_string = '"host" is not set. Please check that environment ' // &
363                        'variable "localhost" & is set before running PALM'
364       CALL message( 'check_parameters', 'PA0001', 0, 0, 0, 6, 0 )
365    ENDIF
366
367!
368!-- Check the coupling mode
369    IF ( coupling_mode /= 'uncoupled'            .AND.  &
370         coupling_mode /= 'atmosphere_to_ocean'  .AND.  &
371         coupling_mode /= 'ocean_to_atmosphere' )  THEN
372       message_string = 'illegal coupling mode: ' // TRIM( coupling_mode )
373       CALL message( 'check_parameters', 'PA0002', 1, 2, 0, 6, 0 )
374    ENDIF
375
376!
377!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
378    IF ( coupling_mode /= 'uncoupled')  THEN
379
380       IF ( dt_coupling == 9999999.9 )  THEN
381          message_string = 'dt_coupling is not set but required for coup' // &
382                           'ling mode "' //  TRIM( coupling_mode ) // '"'
383          CALL message( 'check_parameters', 'PA0003', 1, 2, 0, 6, 0 )
384       ENDIF
385
386#if defined( __parallel )
387
388!
389!--    NOTE: coupled runs have not been implemented in the check_namelist_files
390!--    program.
391!--    check_namelist_files will need the following information of the other
392!--    model (atmosphere/ocean).
393!       dt_coupling = remote
394!       dt_max = remote
395!       restart_time = remote
396!       dt_restart= remote
397!       simulation_time_since_reference = remote
398!       dx = remote
399
400
401#if ! defined( __check )
402       IF ( myid == 0 ) THEN
403          CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, &
404                         ierr )
405          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 11, comm_inter, &
406                         status, ierr )
407       ENDIF
408       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
409#endif     
410       IF ( dt_coupling /= remote )  THEN
411          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
412                 '": dt_coupling = ', dt_coupling, '& is not equal to ',       &
413                 'dt_coupling_remote = ', remote
414          CALL message( 'check_parameters', 'PA0004', 1, 2, 0, 6, 0 )
415       ENDIF
416       IF ( dt_coupling <= 0.0 )  THEN
417#if ! defined( __check )
418          IF ( myid == 0  ) THEN
419             CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
420             CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 19, comm_inter, &
421                            status, ierr )
422          ENDIF   
423          CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
424#endif         
425          dt_coupling = MAX( dt_max, remote )
426          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
427                 '": dt_coupling <= 0.0 & is not allowed and is reset to ',    &
428                 'MAX(dt_max(A,O)) = ', dt_coupling
429          CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
430       ENDIF
431#if ! defined( __check )
432       IF ( myid == 0 ) THEN
433          CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, &
434                         ierr )
435          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 12, comm_inter, &
436                         status, ierr )
437       ENDIF
438       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
439#endif     
440       IF ( restart_time /= remote )  THEN
441          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
442                 '": restart_time = ', restart_time, '& is not equal to ',     &
443                 'restart_time_remote = ', remote
444          CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
445       ENDIF
446#if ! defined( __check )
447       IF ( myid == 0 ) THEN
448          CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, &
449                         ierr )
450          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 13, comm_inter, &
451                         status, ierr )
452       ENDIF   
453       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
454#endif     
455       IF ( dt_restart /= remote )  THEN
456          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
457                 '": dt_restart = ', dt_restart, '& is not equal to ',         &
458                 'dt_restart_remote = ', remote
459          CALL message( 'check_parameters', 'PA0007', 1, 2, 0, 6, 0 )
460       ENDIF
461
462       simulation_time_since_reference = end_time - coupling_start_time
463#if ! defined( __check )
464       IF  ( myid == 0 ) THEN
465          CALL MPI_SEND( simulation_time_since_reference, 1, MPI_REAL, target_id, &
466                         14, comm_inter, ierr )
467          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 14, comm_inter, &
468                         status, ierr )   
469       ENDIF
470       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
471#endif     
472       IF ( simulation_time_since_reference /= remote )  THEN
473          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
474                 '": simulation_time_since_reference = ',                      &
475                 simulation_time_since_reference, '& is not equal to ',        &
476                 'simulation_time_since_reference_remote = ', remote
477          CALL message( 'check_parameters', 'PA0008', 1, 2, 0, 6, 0 )
478       ENDIF
479
480#if ! defined( __check )
481       IF ( myid == 0 ) THEN
482          CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
483          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 15, comm_inter, &
484                                                             status, ierr )
485       ENDIF
486       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
487
488#endif
489       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
490
491          IF ( dx < remote ) THEN
492             WRITE( message_string, * ) 'coupling mode "', &
493                   TRIM( coupling_mode ),                  &
494           '": dx in Atmosphere is not equal to or not larger then dx in ocean'
495             CALL message( 'check_parameters', 'PA0009', 1, 2, 0, 6, 0 )
496          ENDIF
497
498          IF ( (nx_a+1)*dx /= (nx_o+1)*remote )  THEN
499             WRITE( message_string, * ) 'coupling mode "', &
500                    TRIM( coupling_mode ), &
501             '": Domain size in x-direction is not equal in ocean and atmosphere'
502             CALL message( 'check_parameters', 'PA0010', 1, 2, 0, 6, 0 )
503          ENDIF
504
505       ENDIF
506
507#if ! defined( __check )
508       IF ( myid == 0) THEN
509          CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
510          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 16, comm_inter, &
511                         status, ierr )
512       ENDIF
513       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
514#endif
515       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
516
517          IF ( dy < remote )  THEN
518             WRITE( message_string, * ) 'coupling mode "', &
519                    TRIM( coupling_mode ), &
520                 '": dy in Atmosphere is not equal to or not larger then dy in ocean'
521             CALL message( 'check_parameters', 'PA0011', 1, 2, 0, 6, 0 )
522          ENDIF
523
524          IF ( (ny_a+1)*dy /= (ny_o+1)*remote )  THEN
525             WRITE( message_string, * ) 'coupling mode "', &
526                   TRIM( coupling_mode ), &
527             '": Domain size in y-direction is not equal in ocean and atmosphere'
528             CALL message( 'check_parameters', 'PA0012', 1, 2, 0, 6, 0 )
529          ENDIF
530
531          IF ( MOD(nx_o+1,nx_a+1) /= 0 )  THEN
532             WRITE( message_string, * ) 'coupling mode "', &
533                   TRIM( coupling_mode ), &
534             '": nx+1 in ocean is not divisible without remainder with nx+1 in', & 
535             ' atmosphere'
536             CALL message( 'check_parameters', 'PA0339', 1, 2, 0, 6, 0 )
537          ENDIF
538
539          IF ( MOD(ny_o+1,ny_a+1) /= 0 )  THEN
540             WRITE( message_string, * ) 'coupling mode "', &
541                   TRIM( coupling_mode ), &
542             '": ny+1 in ocean is not divisible without remainder with ny+1 in', & 
543             ' atmosphere'
544             CALL message( 'check_parameters', 'PA0340', 1, 2, 0, 6, 0 )
545          ENDIF
546
547       ENDIF
548#else
549       WRITE( message_string, * ) 'coupling requires PALM to be called with', &
550            ' ''mrun -K parallel'''
551       CALL message( 'check_parameters', 'PA0141', 1, 2, 0, 6, 0 )
552#endif
553    ENDIF
554
555#if defined( __parallel ) && ! defined ( __check )
556!
557!-- Exchange via intercommunicator
558    IF ( coupling_mode == 'atmosphere_to_ocean' .AND. myid == 0 )  THEN
559       CALL MPI_SEND( humidity, 1, MPI_LOGICAL, target_id, 19, comm_inter, &
560                      ierr )
561    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' .AND. myid == 0)  THEN
562       CALL MPI_RECV( humidity_remote, 1, MPI_LOGICAL, target_id, 19, &
563                      comm_inter, status, ierr )
564    ENDIF
565    CALL MPI_BCAST( humidity_remote, 1, MPI_LOGICAL, 0, comm2d, ierr)
566   
567#endif
568
569
570!
571!-- Generate the file header which is used as a header for most of PALM's
572!-- output files
573    CALL DATE_AND_TIME( date, time )
574    run_date = date(7:8)//'-'//date(5:6)//'-'//date(3:4)
575    run_time = time(1:2)//':'//time(3:4)//':'//time(5:6)
576    IF ( coupling_mode == 'uncoupled' )  THEN
577       coupling_string = ''
578    ELSEIF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
579       coupling_string = ' coupled (atmosphere)'
580    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
581       coupling_string = ' coupled (ocean)'
582    ENDIF       
583
584    WRITE ( run_description_header,                                        &
585                             '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' ) &
586              TRIM( version ), TRIM( revision ), 'run: ',                  &
587              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ), &
588              'host: ', TRIM( host ), run_date, run_time
589
590!
591!-- Check the general loop optimization method
592    IF ( loop_optimization == 'default' )  THEN
593       IF ( host(1:3) == 'nec' )  THEN
594          loop_optimization = 'vector'
595       ELSE
596          loop_optimization = 'cache'
597       ENDIF
598    ENDIF
599
600    SELECT CASE ( TRIM( loop_optimization ) )
601
602       CASE ( 'acc', 'cache', 'vector' )
603          CONTINUE
604
605       CASE DEFAULT
606          message_string = 'illegal value given for loop_optimization: "' // &
607                           TRIM( loop_optimization ) // '"'
608          CALL message( 'check_parameters', 'PA0013', 1, 2, 0, 6, 0 )
609
610    END SELECT
611
612!
613!-- Check if vertical grid stretching is used together with particles
614    IF ( dz_stretch_level < 100000.0 .AND. particle_advection )  THEN
615       message_string = 'Vertical grid stretching is not allowed together ' // &
616                        'with particle advection.'
617       CALL message( 'check_parameters', 'PA0017', 1, 2, 0, 6, 0 )
618    ENDIF
619
620!
621!-- Check topography setting (check for illegal parameter combinations)
622    IF ( topography /= 'flat' )  THEN
623       action = ' '
624       IF ( scalar_advec /= 'pw-scheme' .AND. scalar_advec /= 'ws-scheme')  THEN
625          WRITE( action, '(A,A)' )  'scalar_advec = ', scalar_advec
626       ENDIF
627       IF ( momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme' ) &
628       THEN
629          WRITE( action, '(A,A)' )  'momentum_advec = ', momentum_advec
630       ENDIF
631       IF ( psolver == 'sor' )  THEN
632          WRITE( action, '(A,A)' )  'psolver = ', psolver
633       ENDIF
634       IF ( sloping_surface )  THEN
635          WRITE( action, '(A)' )  'sloping surface = .TRUE.'
636       ENDIF
637       IF ( galilei_transformation )  THEN
638          WRITE( action, '(A)' )  'galilei_transformation = .TRUE.'
639       ENDIF
640       IF ( cloud_physics )  THEN
641          WRITE( action, '(A)' )  'cloud_physics = .TRUE.'
642       ENDIF
643       IF ( cloud_droplets )  THEN
644          WRITE( action, '(A)' )  'cloud_droplets = .TRUE.'
645       ENDIF
646       IF ( .NOT. prandtl_layer )  THEN
647          WRITE( action, '(A)' )  'prandtl_layer = .FALSE.'
648       ENDIF
649       IF ( action /= ' ' )  THEN
650          message_string = 'a non-flat topography does not allow ' // &
651                           TRIM( action )
652          CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
653       ENDIF
654!
655!--    In case of non-flat topography, check whether the convention how to
656!--    define the topography grid has been set correctly, or whether the default
657!--    is applicable. If this is not possible, abort.
658       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
659          IF ( TRIM( topography ) /= 'single_building' .AND.  &
660               TRIM( topography ) /= 'single_street_canyon' .AND.  &
661               TRIM( topography ) /= 'read_from_file' )  THEN
662!--          The default value is not applicable here, because it is only valid
663!--          for the two standard cases 'single_building' and 'read_from_file'
664!--          defined in init_grid.
665             WRITE( message_string, * )  &
666                  'The value for "topography_grid_convention" ',  &
667                  'is not set. Its default value is & only valid for ',  &
668                  '"topography" = ''single_building'', ',  &
669                  '''single_street_canyon'' & or ''read_from_file''.',  &
670                  ' & Choose ''cell_edge'' or ''cell_center''.'
671             CALL message( 'user_check_parameters', 'PA0239', 1, 2, 0, 6, 0 )
672          ELSE
673!--          The default value is applicable here.
674!--          Set convention according to topography.
675             IF ( TRIM( topography ) == 'single_building' .OR.  &
676                  TRIM( topography ) == 'single_street_canyon' )  THEN
677                topography_grid_convention = 'cell_edge'
678             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
679                topography_grid_convention = 'cell_center'
680             ENDIF
681          ENDIF
682       ELSEIF ( TRIM( topography_grid_convention ) /= 'cell_edge' .AND.  &
683                TRIM( topography_grid_convention ) /= 'cell_center' )  THEN
684          WRITE( message_string, * )  &
685               'The value for "topography_grid_convention" is ', &
686               'not recognized. & Choose ''cell_edge'' or ''cell_center''.'
687          CALL message( 'user_check_parameters', 'PA0240', 1, 2, 0, 6, 0 )
688       ENDIF
689
690    ENDIF
691
692!
693!-- Check ocean setting
694    IF ( ocean )  THEN
695
696       action = ' '
697       IF ( action /= ' ' )  THEN
698          message_string = 'ocean = .T. does not allow ' // TRIM( action )
699          CALL message( 'check_parameters', 'PA0015', 1, 2, 0, 6, 0 )
700       ENDIF
701
702    ELSEIF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.  &
703             TRIM( coupling_char ) == '_O' )  THEN
704
705!
706!--    Check whether an (uncoupled) atmospheric run has been declared as an
707!--    ocean run (this setting is done via mrun-option -y)
708
709       message_string = 'ocean = .F. does not allow coupling_char = "' // &
710                        TRIM( coupling_char ) // '" set by mrun-option "-y"'
711       CALL message( 'check_parameters', 'PA0317', 1, 2, 0, 6, 0 )
712
713    ENDIF
714!
715!-- Check cloud scheme
716    IF ( cloud_scheme == 'seifert_beheng' )  THEN
717       icloud_scheme = 0
718    ELSEIF ( cloud_scheme == 'kessler' )  THEN
719       icloud_scheme = 1
720    ELSE
721       message_string = 'unknown cloud microphysics scheme cloud_scheme ="' // &
722                        TRIM( cloud_scheme ) // '"'
723       CALL message( 'check_parameters', 'PA0357', 1, 2, 0, 6, 0 )
724    ENDIF
725!
726!-- Check whether there are any illegal values
727!-- Pressure solver:
728    IF ( psolver /= 'poisfft'  .AND. &
729         psolver /= 'sor'  .AND.  psolver /= 'multigrid' )  THEN
730       message_string = 'unknown solver for perturbation pressure: psolver' // &
731                        ' = "' // TRIM( psolver ) // '"'
732       CALL message( 'check_parameters', 'PA0016', 1, 2, 0, 6, 0 )
733    ENDIF
734
735    IF ( psolver == 'multigrid' )  THEN
736       IF ( cycle_mg == 'w' )  THEN
737          gamma_mg = 2
738       ELSEIF ( cycle_mg == 'v' )  THEN
739          gamma_mg = 1
740       ELSE
741          message_string = 'unknown multigrid cycle: cycle_mg = "' // &
742                           TRIM( cycle_mg ) // '"'
743          CALL message( 'check_parameters', 'PA0020', 1, 2, 0, 6, 0 )
744       ENDIF
745    ENDIF
746
747    IF ( fft_method /= 'singleton-algorithm'  .AND.  &
748         fft_method /= 'temperton-algorithm'  .AND.  &
749         fft_method /= 'fftw'                 .AND.  &
750         fft_method /= 'system-specific' )  THEN
751       message_string = 'unknown fft-algorithm: fft_method = "' // &
752                        TRIM( fft_method ) // '"'
753       CALL message( 'check_parameters', 'PA0021', 1, 2, 0, 6, 0 )
754    ENDIF
755   
756    IF( momentum_advec == 'ws-scheme' .AND. & 
757        .NOT. call_psolver_at_all_substeps  ) THEN
758        message_string = 'psolver must be called at each RK3 substep when "'//&
759                      TRIM(momentum_advec) // ' "is used for momentum_advec'
760        CALL message( 'check_parameters', 'PA0344', 1, 2, 0, 6, 0 )
761    END IF
762!
763!-- Advection schemes:
764    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' ) &
765    THEN
766       message_string = 'unknown advection scheme: momentum_advec = "' // &
767                        TRIM( momentum_advec ) // '"'
768       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
769    ENDIF
770    IF ( ( momentum_advec == 'ws-scheme' .OR.  scalar_advec == 'ws-scheme' )   &
771           .AND. ( timestep_scheme == 'euler' .OR.                             &
772                   timestep_scheme == 'runge-kutta-2' ) )                      &
773    THEN
774       message_string = 'momentum_advec or scalar_advec = "' &
775         // TRIM( momentum_advec ) // '" is not allowed with timestep_scheme = "' // &
776         TRIM( timestep_scheme ) // '"'
777       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
778    ENDIF
779    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' .AND. &
780         scalar_advec /= 'bc-scheme' )                                         &
781    THEN
782       message_string = 'unknown advection scheme: scalar_advec = "' // &
783                        TRIM( scalar_advec ) // '"'
784       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
785    ENDIF
786    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' ) &
787    THEN
788       message_string = 'advection_scheme scalar_advec = "' &
789         // TRIM( scalar_advec ) // '" not implemented for & loop_optimization = "' // &
790         TRIM( loop_optimization ) // '"'
791       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
792    ENDIF
793
794    IF ( use_sgs_for_particles  .AND.  .NOT. use_upstream_for_tke )  THEN
795       use_upstream_for_tke = .TRUE.
796       message_string = 'use_upstream_for_tke set .TRUE. because ' // &
797                        'use_sgs_for_particles = .TRUE.'
798       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
799    ENDIF
800
801    IF ( use_sgs_for_particles  .AND.  curvature_solution_effects )  THEN
802       message_string = 'use_sgs_for_particles = .TRUE. not allowed with ' // &
803                        'curvature_solution_effects = .TRUE.'
804       CALL message( 'check_parameters', 'PA0349', 1, 2, 0, 6, 0 )
805    ENDIF
806
807!
808!-- Set LOGICAL switches to enhance performance
809    IF ( momentum_advec == 'ws-scheme' )    ws_scheme_mom = .TRUE.
810    IF ( scalar_advec   == 'ws-scheme'   )  ws_scheme_sca = .TRUE.
811
812!
813!-- Timestep schemes:
814    SELECT CASE ( TRIM( timestep_scheme ) )
815
816       CASE ( 'euler' )
817          intermediate_timestep_count_max = 1
818
819       CASE ( 'runge-kutta-2' )
820          intermediate_timestep_count_max = 2
821
822       CASE ( 'runge-kutta-3' )
823          intermediate_timestep_count_max = 3
824
825       CASE DEFAULT
826          message_string = 'unknown timestep scheme: timestep_scheme = "' // &
827                           TRIM( timestep_scheme ) // '"'
828          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
829
830    END SELECT
831
832    IF ( (momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme') &
833         .AND. timestep_scheme(1:5) == 'runge' ) THEN
834       message_string = 'momentum advection scheme "' // &
835                        TRIM( momentum_advec ) // '" & does not work with ' // &
836                        'timestep_scheme "' // TRIM( timestep_scheme ) // '"'
837       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
838    ENDIF
839
840!
841!-- Collision kernels:
842    SELECT CASE ( TRIM( collision_kernel ) )
843
844       CASE ( 'hall', 'hall_fast' )
845          hall_kernel = .TRUE.
846
847       CASE ( 'palm' )
848          palm_kernel = .TRUE.
849
850       CASE ( 'wang', 'wang_fast' )
851          wang_kernel = .TRUE.
852
853       CASE ( 'none' )
854
855
856       CASE DEFAULT
857          message_string = 'unknown collision kernel: collision_kernel = "' // &
858                           TRIM( collision_kernel ) // '"'
859          CALL message( 'check_parameters', 'PA0350', 1, 2, 0, 6, 0 )
860
861    END SELECT
862    IF ( collision_kernel(6:9) == 'fast' )  use_kernel_tables = .TRUE.
863
864    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.  &
865         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
866!
867!--    No restart run: several initialising actions are possible
868       action = initializing_actions
869       DO WHILE ( TRIM( action ) /= '' )
870          position = INDEX( action, ' ' )
871          SELECT CASE ( action(1:position-1) )
872
873             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', &
874                    'by_user', 'initialize_vortex',     'initialize_ptanom' )
875                action = action(position+1:)
876
877             CASE DEFAULT
878                message_string = 'initializing_action = "' // &
879                                 TRIM( action ) // '" unkown or not allowed'
880                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
881
882          END SELECT
883       ENDDO
884    ENDIF
885
886    IF ( TRIM( initializing_actions ) == 'initialize_vortex' .AND. &
887         conserve_volume_flow ) THEN
888         message_string = 'initializing_actions = "initialize_vortex"' // &
889                        ' ist not allowed with conserve_volume_flow = .T.'
890       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
891    ENDIF       
892
893
894    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
895         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
896       message_string = 'initializing_actions = "set_constant_profiles"' // &
897                        ' and "set_1d-model_profiles" are not allowed ' //  &
898                        'simultaneously'
899       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
900    ENDIF
901
902    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
903         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
904       message_string = 'initializing_actions = "set_constant_profiles"' // &
905                        ' and "by_user" are not allowed simultaneously'
906       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
907    ENDIF
908
909    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND. &
910         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
911       message_string = 'initializing_actions = "by_user" and ' // &
912                        '"set_1d-model_profiles" are not allowed simultaneously'
913       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
914    ENDIF
915
916    IF ( cloud_physics  .AND.  .NOT. humidity )  THEN
917       WRITE( message_string, * ) 'cloud_physics = ', cloud_physics, ' is ', &
918              'not allowed with humidity = ', humidity
919       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
920    ENDIF
921
922    IF ( precipitation  .AND.  .NOT.  cloud_physics )  THEN
923       WRITE( message_string, * ) 'precipitation = ', precipitation, ' is ', &
924              'not allowed with cloud_physics = ', cloud_physics
925       CALL message( 'check_parameters', 'PA0035', 1, 2, 0, 6, 0 )
926    ENDIF
927
928    IF ( humidity  .AND.  sloping_surface )  THEN
929       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' // &
930                        'are not allowed simultaneously'
931       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
932    ENDIF
933
934    IF ( passive_scalar  .AND.  humidity )  THEN
935       message_string = 'humidity = .TRUE. and passive_scalar = .TRUE. ' // &
936                        'is not allowed simultaneously'
937       CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
938    ENDIF
939
940    IF ( plant_canopy .AND. ( drag_coefficient == 0.0 ) ) THEN
941       message_string = 'plant_canopy = .TRUE. requires a non-zero drag ' // &
942                        'coefficient & given value is drag_coefficient = 0.0'
943       CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
944    ENDIF
945
946    IF ( plant_canopy  .AND.  cloud_physics  .AND.  icloud_scheme == 0 ) THEN
947       message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' //  &
948                        ' seifert_beheng'
949       CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
950    ENDIF
951
952    IF ( loop_optimization /= 'cache' .AND.  cloud_physics  .AND.            &
953         icloud_scheme == 0 ) THEN
954       message_string = 'cloud_scheme = seifert_beheng requires ' // &
955                        'loop_optimization = cache'
956       CALL message( 'check_parameters', 'PA0362', 1, 2, 0, 6, 0 )
957    ENDIF 
958
959!    IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
960!         .NOT. precipitation  .AND.  .NOT. drizzle ) THEN
961!       message_string = 'cloud_scheme = seifert_beheng requires ' // &
962!                        'precipitation = .TRUE. or drizzle = .TRUE.'
963!       CALL message( 'check_parameters', 'PA0363', 1, 2, 0, 6, 0 )
964!    ENDIF
965
966!
967!-- In case of no model continuation run, check initialising parameters and
968!-- deduce further quantities
969    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
970
971!
972!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
973       pt_init = pt_surface
974       IF ( humidity )  THEN
975          q_init  = q_surface
976       ENDIF
977       IF ( ocean )           sa_init = sa_surface
978       IF ( passive_scalar )  q_init  = s_surface
979       IF ( plant_canopy )    lad = 0.0
980
981!
982!--
983!--    If required, compute initial profile of the geostrophic wind
984!--    (component ug)
985       i = 1
986       gradient = 0.0
987
988       IF ( .NOT. ocean )  THEN
989
990          ug_vertical_gradient_level_ind(1) = 0
991          ug(0) = ug_surface
992          DO  k = 1, nzt+1
993             IF ( i < 11 ) THEN
994                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND. &
995                     ug_vertical_gradient_level(i) >= 0.0 )  THEN
996                   gradient = ug_vertical_gradient(i) / 100.0
997                   ug_vertical_gradient_level_ind(i) = k - 1
998                   i = i + 1
999                ENDIF
1000             ENDIF       
1001             IF ( gradient /= 0.0 )  THEN
1002                IF ( k /= 1 )  THEN
1003                   ug(k) = ug(k-1) + dzu(k) * gradient
1004                ELSE
1005                   ug(k) = ug_surface + dzu(k) * gradient
1006                ENDIF
1007             ELSE
1008                ug(k) = ug(k-1)
1009             ENDIF
1010          ENDDO
1011
1012       ELSE
1013
1014          ug_vertical_gradient_level_ind(1) = nzt+1
1015          ug(nzt+1) = ug_surface
1016          DO  k = nzt, nzb, -1
1017             IF ( i < 11 ) THEN
1018                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND. &
1019                     ug_vertical_gradient_level(i) <= 0.0 )  THEN
1020                   gradient = ug_vertical_gradient(i) / 100.0
1021                   ug_vertical_gradient_level_ind(i) = k + 1
1022                   i = i + 1
1023                ENDIF
1024             ENDIF
1025             IF ( gradient /= 0.0 )  THEN
1026                IF ( k /= nzt )  THEN
1027                   ug(k) = ug(k+1) - dzu(k+1) * gradient
1028                ELSE
1029                   ug(k)   = ug_surface - 0.5 * dzu(k+1) * gradient
1030                   ug(k+1) = ug_surface + 0.5 * dzu(k+1) * gradient
1031                ENDIF
1032             ELSE
1033                ug(k) = ug(k+1)
1034             ENDIF
1035          ENDDO
1036
1037       ENDIF
1038
1039!
1040!--    In case of no given gradients for ug, choose a zero gradient
1041       IF ( ug_vertical_gradient_level(1) == -9999999.9 )  THEN
1042          ug_vertical_gradient_level(1) = 0.0
1043       ENDIF 
1044
1045!
1046!--
1047!--    If required, compute initial profile of the geostrophic wind
1048!--    (component vg)
1049       i = 1
1050       gradient = 0.0
1051
1052       IF ( .NOT. ocean )  THEN
1053
1054          vg_vertical_gradient_level_ind(1) = 0
1055          vg(0) = vg_surface
1056          DO  k = 1, nzt+1
1057             IF ( i < 11 ) THEN
1058                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND. &
1059                     vg_vertical_gradient_level(i) >= 0.0 )  THEN
1060                   gradient = vg_vertical_gradient(i) / 100.0
1061                   vg_vertical_gradient_level_ind(i) = k - 1
1062                   i = i + 1
1063                ENDIF
1064             ENDIF
1065             IF ( gradient /= 0.0 )  THEN
1066                IF ( k /= 1 )  THEN
1067                   vg(k) = vg(k-1) + dzu(k) * gradient
1068                ELSE
1069                   vg(k) = vg_surface + dzu(k) * gradient
1070                ENDIF
1071             ELSE
1072                vg(k) = vg(k-1)
1073             ENDIF
1074          ENDDO
1075
1076       ELSE
1077
1078          vg_vertical_gradient_level_ind(1) = nzt+1
1079          vg(nzt+1) = vg_surface
1080          DO  k = nzt, nzb, -1
1081             IF ( i < 11 ) THEN
1082                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND. &
1083                     vg_vertical_gradient_level(i) <= 0.0 )  THEN
1084                   gradient = vg_vertical_gradient(i) / 100.0
1085                   vg_vertical_gradient_level_ind(i) = k + 1
1086                   i = i + 1
1087                ENDIF
1088             ENDIF
1089             IF ( gradient /= 0.0 )  THEN
1090                IF ( k /= nzt )  THEN
1091                   vg(k) = vg(k+1) - dzu(k+1) * gradient
1092                ELSE
1093                   vg(k)   = vg_surface - 0.5 * dzu(k+1) * gradient
1094                   vg(k+1) = vg_surface + 0.5 * dzu(k+1) * gradient
1095                ENDIF
1096             ELSE
1097                vg(k) = vg(k+1)
1098             ENDIF
1099          ENDDO
1100
1101       ENDIF
1102
1103!
1104!--    In case of no given gradients for vg, choose a zero gradient
1105       IF ( vg_vertical_gradient_level(1) == -9999999.9 )  THEN
1106          vg_vertical_gradient_level(1) = 0.0
1107       ENDIF
1108
1109!
1110!--    Let the initial wind profiles be the calculated ug/vg profiles or
1111!--    interpolate them from wind profile data (if given)
1112       IF ( u_profile(1) == 9999999.9  .AND.  v_profile(1) == 9999999.9 )  THEN
1113
1114          u_init = ug
1115          v_init = vg
1116
1117       ELSEIF ( u_profile(1) == 0.0  .AND.  v_profile(1) == 0.0 )  THEN
1118
1119          IF ( uv_heights(1) /= 0.0 )  THEN
1120             message_string = 'uv_heights(1) must be 0.0'
1121             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
1122          ENDIF
1123
1124          use_prescribed_profile_data = .TRUE.
1125
1126          kk = 1
1127          u_init(0) = 0.0
1128          v_init(0) = 0.0
1129
1130          DO  k = 1, nz+1
1131
1132             IF ( kk < 100 )  THEN
1133                DO WHILE ( uv_heights(kk+1) <= zu(k) )
1134                   kk = kk + 1
1135                   IF ( kk == 100 )  EXIT
1136                ENDDO
1137             ENDIF
1138
1139             IF ( kk < 100 .AND. uv_heights(kk+1) /= 9999999.9 )  THEN
1140                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1141                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1142                                       ( u_profile(kk+1) - u_profile(kk) )
1143                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1144                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1145                                       ( v_profile(kk+1) - v_profile(kk) )
1146             ELSE
1147                u_init(k) = u_profile(kk)
1148                v_init(k) = v_profile(kk)
1149             ENDIF
1150
1151          ENDDO
1152
1153       ELSE
1154
1155          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1156          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1157
1158       ENDIF
1159
1160!
1161!--    Compute initial temperature profile using the given temperature gradients
1162       IF ( .NOT. neutral )  THEN
1163
1164          i = 1
1165          gradient = 0.0
1166
1167          IF ( .NOT. ocean )  THEN
1168
1169             pt_vertical_gradient_level_ind(1) = 0
1170             DO  k = 1, nzt+1
1171                IF ( i < 11 ) THEN
1172                   IF ( pt_vertical_gradient_level(i) < zu(k)  .AND. &
1173                        pt_vertical_gradient_level(i) >= 0.0 )  THEN
1174                      gradient = pt_vertical_gradient(i) / 100.0
1175                      pt_vertical_gradient_level_ind(i) = k - 1
1176                      i = i + 1
1177                   ENDIF
1178                ENDIF
1179                IF ( gradient /= 0.0 )  THEN
1180                   IF ( k /= 1 )  THEN
1181                      pt_init(k) = pt_init(k-1) + dzu(k) * gradient
1182                   ELSE
1183                      pt_init(k) = pt_surface   + dzu(k) * gradient
1184                   ENDIF
1185                ELSE
1186                   pt_init(k) = pt_init(k-1)
1187                ENDIF
1188             ENDDO
1189
1190          ELSE
1191
1192             pt_vertical_gradient_level_ind(1) = nzt+1
1193             DO  k = nzt, 0, -1
1194                IF ( i < 11 ) THEN
1195                   IF ( pt_vertical_gradient_level(i) > zu(k)  .AND. &
1196                        pt_vertical_gradient_level(i) <= 0.0 )  THEN
1197                      gradient = pt_vertical_gradient(i) / 100.0
1198                      pt_vertical_gradient_level_ind(i) = k + 1
1199                      i = i + 1
1200                   ENDIF
1201                ENDIF
1202                IF ( gradient /= 0.0 )  THEN
1203                   IF ( k /= nzt )  THEN
1204                      pt_init(k) = pt_init(k+1) - dzu(k+1) * gradient
1205                   ELSE
1206                      pt_init(k)   = pt_surface - 0.5 * dzu(k+1) * gradient
1207                      pt_init(k+1) = pt_surface + 0.5 * dzu(k+1) * gradient
1208                   ENDIF
1209                ELSE
1210                   pt_init(k) = pt_init(k+1)
1211                ENDIF
1212             ENDDO
1213
1214          ENDIF
1215
1216       ENDIF
1217
1218!
1219!--    In case of no given temperature gradients, choose gradient of neutral
1220!--    stratification
1221       IF ( pt_vertical_gradient_level(1) == -9999999.9 )  THEN
1222          pt_vertical_gradient_level(1) = 0.0
1223       ENDIF
1224
1225!
1226!--    Store temperature gradient at the top boundary for possible Neumann
1227!--    boundary condition
1228       bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1)
1229
1230!
1231!--    If required, compute initial humidity or scalar profile using the given
1232!--    humidity/scalar gradient. In case of scalar transport, initially store
1233!--    values of the scalar parameters on humidity parameters
1234       IF ( passive_scalar )  THEN
1235          bc_q_b                    = bc_s_b
1236          bc_q_t                    = bc_s_t
1237          q_surface                 = s_surface
1238          q_surface_initial_change  = s_surface_initial_change
1239          q_vertical_gradient       = s_vertical_gradient
1240          q_vertical_gradient_level = s_vertical_gradient_level
1241          surface_waterflux         = surface_scalarflux
1242          wall_humidityflux         = wall_scalarflux
1243       ENDIF
1244
1245       IF ( humidity  .OR.  passive_scalar )  THEN
1246
1247          i = 1
1248          gradient = 0.0
1249          q_vertical_gradient_level_ind(1) = 0
1250          DO  k = 1, nzt+1
1251             IF ( i < 11 ) THEN
1252                IF ( q_vertical_gradient_level(i) < zu(k)  .AND. &
1253                     q_vertical_gradient_level(i) >= 0.0 )  THEN
1254                   gradient = q_vertical_gradient(i) / 100.0
1255                   q_vertical_gradient_level_ind(i) = k - 1
1256                   i = i + 1
1257                ENDIF
1258             ENDIF
1259             IF ( gradient /= 0.0 )  THEN
1260                IF ( k /= 1 )  THEN
1261                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1262                ELSE
1263                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1264                ENDIF
1265             ELSE
1266                q_init(k) = q_init(k-1)
1267             ENDIF
1268!
1269!--          Avoid negative humidities
1270             IF ( q_init(k) < 0.0 )  THEN
1271                q_init(k) = 0.0
1272             ENDIF
1273          ENDDO
1274
1275!
1276!--       In case of no given humidity gradients, choose zero gradient
1277!--       conditions
1278          IF ( q_vertical_gradient_level(1) == -1.0 )  THEN
1279             q_vertical_gradient_level(1) = 0.0
1280          ENDIF
1281!
1282!--       Store humidity, rain water content and rain drop concentration
1283!--       gradient at the top boundary for possile Neumann boundary condition
1284          bc_q_t_val  = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
1285       ENDIF
1286
1287!
1288!--    If required, compute initial salinity profile using the given salinity
1289!--    gradients
1290       IF ( ocean )  THEN
1291
1292          i = 1
1293          gradient = 0.0
1294
1295          sa_vertical_gradient_level_ind(1) = nzt+1
1296          DO  k = nzt, 0, -1
1297             IF ( i < 11 ) THEN
1298                IF ( sa_vertical_gradient_level(i) > zu(k)  .AND. &
1299                     sa_vertical_gradient_level(i) <= 0.0 )  THEN
1300                   gradient = sa_vertical_gradient(i) / 100.0
1301                   sa_vertical_gradient_level_ind(i) = k + 1
1302                   i = i + 1
1303                ENDIF
1304             ENDIF
1305             IF ( gradient /= 0.0 )  THEN
1306                IF ( k /= nzt )  THEN
1307                   sa_init(k) = sa_init(k+1) - dzu(k+1) * gradient
1308                ELSE
1309                   sa_init(k)   = sa_surface - 0.5 * dzu(k+1) * gradient
1310                   sa_init(k+1) = sa_surface + 0.5 * dzu(k+1) * gradient
1311                ENDIF
1312             ELSE
1313                sa_init(k) = sa_init(k+1)
1314             ENDIF
1315          ENDDO
1316
1317       ENDIF
1318
1319!
1320!--    If required compute the profile of leaf area density used in the plant
1321!--    canopy model
1322       IF ( plant_canopy ) THEN
1323       
1324          i = 1
1325          gradient = 0.0
1326
1327          IF ( .NOT. ocean ) THEN
1328
1329             lad(0) = lad_surface
1330 
1331             lad_vertical_gradient_level_ind(1) = 0
1332             DO k = 1, pch_index
1333                IF ( i < 11 ) THEN
1334                   IF ( lad_vertical_gradient_level(i) < zu(k) .AND.  &
1335                        lad_vertical_gradient_level(i) >= 0.0 ) THEN
1336                      gradient = lad_vertical_gradient(i)
1337                      lad_vertical_gradient_level_ind(i) = k - 1
1338                      i = i + 1
1339                   ENDIF
1340                ENDIF
1341                IF ( gradient /= 0.0 ) THEN
1342                   IF ( k /= 1 ) THEN
1343                      lad(k) = lad(k-1) + dzu(k) * gradient
1344                   ELSE
1345                      lad(k) = lad_surface + dzu(k) *gradient
1346                   ENDIF
1347                ELSE
1348                   lad(k) = lad(k-1)
1349                ENDIF
1350             ENDDO
1351
1352          ENDIF
1353
1354!
1355!--       In case of no given leaf area density gradients, choose a vanishing
1356!--       gradient
1357          IF ( lad_vertical_gradient_level(1) == -9999999.9 ) THEN
1358             lad_vertical_gradient_level(1) = 0.0
1359          ENDIF
1360
1361       ENDIF
1362         
1363    ENDIF
1364
1365!
1366!-- Initialize large scale subsidence if required
1367    If ( large_scale_subsidence )  THEN
1368       IF ( subs_vertical_gradient_level(1) /= -9999999.9 .AND. &
1369                                     .NOT. large_scale_forcing )  THEN
1370          CALL init_w_subsidence
1371       ENDIF
1372!
1373!--    In case large_scale_forcing is used, profiles for subsidence velocity
1374!--    are read in from file LSF_DATA
1375
1376       IF ( subs_vertical_gradient_level(1) == -9999999.9 .AND. &
1377                                     .NOT. large_scale_forcing )  THEN
1378          message_string = 'There is no default large scale vertical ' // &
1379                           'velocity profile set. Specify the subsidence ' // &
1380                           'velocity profile via subs_vertical_gradient and ' // &
1381                           'subs_vertical_gradient_level.'
1382          CALL message( 'check_parameters', 'PA0380', 1, 2, 0, 6, 0 )
1383       ENDIF
1384    ELSE
1385        IF ( subs_vertical_gradient_level(1) /= -9999999.9 )  THEN
1386           message_string = 'Enable usage of large scale subsidence by ' // &
1387                            'setting large_scale_subsidence = .T..'
1388          CALL message( 'check_parameters', 'PA0381', 1, 2, 0, 6, 0 )
1389        ENDIF
1390    ENDIF   
1391
1392!
1393!-- Compute Coriolis parameter
1394    f  = 2.0 * omega * SIN( phi / 180.0 * pi )
1395    fs = 2.0 * omega * COS( phi / 180.0 * pi )
1396
1397!
1398!-- Check and set buoyancy related parameters and switches
1399    IF ( reference_state == 'horizontal_average' )  THEN
1400       CONTINUE
1401    ELSEIF ( reference_state == 'initial_profile' )  THEN
1402       use_initial_profile_as_reference = .TRUE.
1403    ELSEIF ( reference_state == 'single_value' )  THEN
1404       use_single_reference_value = .TRUE.
1405       IF ( pt_reference == 9999999.9 )  pt_reference = pt_surface
1406       vpt_reference = pt_reference * ( 1.0 + 0.61 * q_surface )
1407    ELSE
1408       message_string = 'illegal value for reference_state: "' // &
1409                        TRIM( reference_state ) // '"'
1410       CALL message( 'check_parameters', 'PA0056', 1, 2, 0, 6, 0 )
1411    ENDIF
1412
1413!
1414!-- Ocean runs always use reference values in the buoyancy term
1415    IF ( ocean )  THEN
1416       reference_state = 'single_value'
1417       use_single_reference_value = .TRUE.
1418    ENDIF
1419
1420!
1421!-- Sign of buoyancy/stability terms
1422    IF ( ocean )  atmos_ocean_sign = -1.0
1423
1424!
1425!-- Ocean version must use flux boundary conditions at the top
1426    IF ( ocean .AND. .NOT. use_top_fluxes )  THEN
1427       message_string = 'use_top_fluxes must be .TRUE. in ocean version'
1428       CALL message( 'check_parameters', 'PA0042', 1, 2, 0, 6, 0 )
1429    ENDIF
1430
1431!
1432!-- In case of a given slope, compute the relevant quantities
1433    IF ( alpha_surface /= 0.0 )  THEN
1434       IF ( ABS( alpha_surface ) > 90.0 )  THEN
1435          WRITE( message_string, * ) 'ABS( alpha_surface = ', alpha_surface, &
1436                                     ' ) must be < 90.0'
1437          CALL message( 'check_parameters', 'PA0043', 1, 2, 0, 6, 0 )
1438       ENDIF
1439       sloping_surface = .TRUE.
1440       cos_alpha_surface = COS( alpha_surface / 180.0 * pi )
1441       sin_alpha_surface = SIN( alpha_surface / 180.0 * pi )
1442    ENDIF
1443
1444!
1445!-- Check time step and cfl_factor
1446    IF ( dt /= -1.0 )  THEN
1447       IF ( dt <= 0.0  .AND.  dt /= -1.0 )  THEN
1448          WRITE( message_string, * ) 'dt = ', dt , ' <= 0.0'
1449          CALL message( 'check_parameters', 'PA0044', 1, 2, 0, 6, 0 )
1450       ENDIF
1451       dt_3d = dt
1452       dt_fixed = .TRUE.
1453    ENDIF
1454
1455    IF ( cfl_factor <= 0.0  .OR.  cfl_factor > 1.0 )  THEN
1456       IF ( cfl_factor == -1.0 )  THEN
1457          IF ( timestep_scheme == 'runge-kutta-2' )  THEN
1458             cfl_factor = 0.8
1459          ELSEIF ( timestep_scheme == 'runge-kutta-3' )  THEN
1460             cfl_factor = 0.9
1461          ELSE
1462             cfl_factor = 0.9
1463          ENDIF
1464       ELSE
1465          WRITE( message_string, * ) 'cfl_factor = ', cfl_factor, &
1466                 ' out of range & 0.0 < cfl_factor <= 1.0 is required'
1467          CALL message( 'check_parameters', 'PA0045', 1, 2, 0, 6, 0 )
1468       ENDIF
1469    ENDIF
1470
1471!
1472!-- Store simulated time at begin
1473    simulated_time_at_begin = simulated_time
1474
1475!
1476!-- Store reference time for coupled runs and change the coupling flag,
1477!-- if ...
1478    IF ( simulated_time == 0.0 )  THEN
1479       IF ( coupling_start_time == 0.0 )  THEN
1480          time_since_reference_point = 0.0
1481       ELSEIF ( time_since_reference_point < 0.0 )  THEN
1482          run_coupled = .FALSE.
1483       ENDIF
1484    ENDIF
1485
1486!
1487!-- Set wind speed in the Galilei-transformed system
1488    IF ( galilei_transformation )  THEN
1489       IF ( use_ug_for_galilei_tr .AND.                  &
1490            ug_vertical_gradient_level(1) == 0.0  .AND.  &
1491            ug_vertical_gradient(1) == 0.0  .AND.        & 
1492            vg_vertical_gradient_level(1) == 0.0  .AND.  &
1493            vg_vertical_gradient(1) == 0.0 )  THEN
1494          u_gtrans = ug_surface * 0.6
1495          v_gtrans = vg_surface * 0.6
1496       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1497                ( ug_vertical_gradient_level(1) /= 0.0  .OR.  &
1498                ug_vertical_gradient(1) /= 0.0 ) )  THEN
1499          message_string = 'baroclinicity (ug) not allowed simultaneously' // &
1500                           ' with galilei transformation'
1501          CALL message( 'check_parameters', 'PA0046', 1, 2, 0, 6, 0 )
1502       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1503                ( vg_vertical_gradient_level(1) /= 0.0  .OR.  &
1504                vg_vertical_gradient(1) /= 0.0 ) )  THEN
1505          message_string = 'baroclinicity (vg) not allowed simultaneously' // &
1506                           ' with galilei transformation'
1507          CALL message( 'check_parameters', 'PA0047', 1, 2, 0, 6, 0 )
1508       ELSE
1509          message_string = 'variable translation speed used for galilei-' // &
1510             'transformation, which may cause & instabilities in stably ' // &
1511             'stratified regions'
1512          CALL message( 'check_parameters', 'PA0048', 0, 1, 0, 6, 0 )
1513       ENDIF
1514    ENDIF
1515
1516!
1517!-- In case of using a prandtl-layer, calculated (or prescribed) surface
1518!-- fluxes have to be used in the diffusion-terms
1519    IF ( prandtl_layer )  use_surface_fluxes = .TRUE.
1520
1521!
1522!-- Check boundary conditions and set internal variables:
1523!-- Lateral boundary conditions
1524    IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
1525         bc_lr /= 'radiation/dirichlet' )  THEN
1526       message_string = 'unknown boundary condition: bc_lr = "' // &
1527                        TRIM( bc_lr ) // '"'
1528       CALL message( 'check_parameters', 'PA0049', 1, 2, 0, 6, 0 )
1529    ENDIF
1530    IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
1531         bc_ns /= 'radiation/dirichlet' )  THEN
1532       message_string = 'unknown boundary condition: bc_ns = "' // &
1533                        TRIM( bc_ns ) // '"'
1534       CALL message( 'check_parameters', 'PA0050', 1, 2, 0, 6, 0 )
1535    ENDIF
1536
1537!
1538!-- Internal variables used for speed optimization in if clauses
1539    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
1540    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
1541    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
1542    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
1543    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
1544    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
1545
1546!
1547!-- Non-cyclic lateral boundaries require the multigrid method and Piascek-
1548!-- Willimas or Wicker - Skamarock advection scheme. Several schemes
1549!-- and tools do not work with non-cyclic boundary conditions.
1550    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
1551       IF ( psolver /= 'multigrid' )  THEN
1552          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1553                           'psolver = "' // TRIM( psolver ) // '"'
1554          CALL message( 'check_parameters', 'PA0051', 1, 2, 0, 6, 0 )
1555       ENDIF
1556       IF ( momentum_advec /= 'pw-scheme' .AND. &
1557            momentum_advec /= 'ws-scheme')  THEN
1558          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1559                           'momentum_advec = "' // TRIM( momentum_advec ) // '"'
1560          CALL message( 'check_parameters', 'PA0052', 1, 2, 0, 6, 0 )
1561       ENDIF
1562       IF ( scalar_advec /= 'pw-scheme' .AND. &
1563            scalar_advec /= 'ws-scheme' )  THEN
1564          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1565                           'scalar_advec = "' // TRIM( scalar_advec ) // '"'
1566          CALL message( 'check_parameters', 'PA0053', 1, 2, 0, 6, 0 )
1567       ENDIF
1568       IF ( galilei_transformation )  THEN
1569          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1570                           'galilei_transformation = .T.'
1571          CALL message( 'check_parameters', 'PA0054', 1, 2, 0, 6, 0 )
1572       ENDIF
1573    ENDIF
1574
1575!
1576!-- Bottom boundary condition for the turbulent Kinetic energy
1577    IF ( bc_e_b == 'neumann' )  THEN
1578       ibc_e_b = 1
1579    ELSEIF ( bc_e_b == '(u*)**2+neumann' )  THEN
1580       ibc_e_b = 2
1581       IF ( prandtl_layer )  THEN
1582          message_string = 'adjust mixing length = FALSE and bc_e_b = "' // &
1583                           TRIM( bc_e_b ) // '"'
1584          CALL message( 'check_parameters', 'PA0056', 0, 1, 0, 6, 0 )
1585       ENDIF
1586       IF ( .NOT. prandtl_layer )  THEN
1587          bc_e_b = 'neumann'
1588          ibc_e_b = 1
1589          message_string = 'boundary condition bc_e_b changed to "' // &
1590                           TRIM( bc_e_b ) // '"'
1591          CALL message( 'check_parameters', 'PA0057', 0, 1, 0, 6, 0 )
1592       ENDIF
1593    ELSE
1594       message_string = 'unknown boundary condition: bc_e_b = "' // &
1595                        TRIM( bc_e_b ) // '"'
1596       CALL message( 'check_parameters', 'PA0058', 1, 2, 0, 6, 0 )
1597    ENDIF
1598
1599!
1600!-- Boundary conditions for perturbation pressure
1601    IF ( bc_p_b == 'dirichlet' )  THEN
1602       ibc_p_b = 0
1603    ELSEIF ( bc_p_b == 'neumann' )  THEN
1604       ibc_p_b = 1
1605    ELSE
1606       message_string = 'unknown boundary condition: bc_p_b = "' // &
1607                        TRIM( bc_p_b ) // '"'
1608       CALL message( 'check_parameters', 'PA0059', 1, 2, 0, 6, 0 )
1609    ENDIF
1610
1611    IF ( bc_p_t == 'dirichlet' )  THEN
1612       ibc_p_t = 0
1613    ELSEIF ( bc_p_t == 'neumann' )  THEN
1614       ibc_p_t = 1
1615    ELSE
1616       message_string = 'unknown boundary condition: bc_p_t = "' // &
1617                        TRIM( bc_p_t ) // '"'
1618       CALL message( 'check_parameters', 'PA0061', 1, 2, 0, 6, 0 )
1619    ENDIF
1620
1621!
1622!-- Boundary conditions for potential temperature
1623    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1624       ibc_pt_b = 2
1625    ELSE
1626       IF ( bc_pt_b == 'dirichlet' )  THEN
1627          ibc_pt_b = 0
1628       ELSEIF ( bc_pt_b == 'neumann' )  THEN
1629          ibc_pt_b = 1
1630       ELSE
1631          message_string = 'unknown boundary condition: bc_pt_b = "' // &
1632                           TRIM( bc_pt_b ) // '"'
1633          CALL message( 'check_parameters', 'PA0062', 1, 2, 0, 6, 0 )
1634       ENDIF
1635    ENDIF
1636
1637    IF ( bc_pt_t == 'dirichlet' )  THEN
1638       ibc_pt_t = 0
1639    ELSEIF ( bc_pt_t == 'neumann' )  THEN
1640       ibc_pt_t = 1
1641    ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
1642       ibc_pt_t = 2
1643    ELSE
1644       message_string = 'unknown boundary condition: bc_pt_t = "' // &
1645                        TRIM( bc_pt_t ) // '"'
1646       CALL message( 'check_parameters', 'PA0063', 1, 2, 0, 6, 0 )
1647    ENDIF
1648
1649    IF ( surface_heatflux == 9999999.9  )  THEN
1650       constant_heatflux = .FALSE.
1651       IF ( large_scale_forcing )  THEN
1652          IF ( ibc_pt_b == 0 )  THEN
1653             constant_heatflux = .FALSE.
1654          ELSEIF ( ibc_pt_b == 1 )  THEN
1655             constant_heatflux = .TRUE.
1656             IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1657                surface_heatflux = shf_surf(1)
1658             ENDIF
1659          ENDIF
1660       ENDIF
1661    ELSE
1662        constant_heatflux = .TRUE.
1663        IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. &
1664               large_scale_forcing ) THEN
1665           surface_heatflux = shf_surf(1)
1666        ENDIF
1667    ENDIF
1668
1669    IF ( top_heatflux     == 9999999.9 )  constant_top_heatflux = .FALSE.
1670
1671    IF ( neutral )  THEN
1672
1673       IF ( surface_heatflux /= 0.0  .AND.  surface_heatflux /= 9999999.9 ) &
1674       THEN
1675          message_string = 'heatflux must not be set for pure neutral flow'
1676          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1677       ENDIF
1678
1679       IF ( top_heatflux /= 0.0  .AND.  top_heatflux /= 9999999.9 ) &
1680       THEN
1681          message_string = 'heatflux must not be set for pure neutral flow'
1682          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1683       ENDIF
1684
1685    ENDIF
1686
1687    IF ( top_momentumflux_u /= 9999999.9  .AND.  &
1688         top_momentumflux_v /= 9999999.9 )  THEN
1689       constant_top_momentumflux = .TRUE.
1690    ELSEIF (  .NOT. ( top_momentumflux_u == 9999999.9  .AND.  &
1691           top_momentumflux_v == 9999999.9 ) )  THEN
1692       message_string = 'both, top_momentumflux_u AND top_momentumflux_v ' // &
1693                        'must be set'
1694       CALL message( 'check_parameters', 'PA0064', 1, 2, 0, 6, 0 )
1695    ENDIF
1696
1697!
1698!-- A given surface temperature implies Dirichlet boundary condition for
1699!-- temperature. In this case specification of a constant heat flux is
1700!-- forbidden.
1701    IF ( ibc_pt_b == 0  .AND.   constant_heatflux  .AND. &
1702         surface_heatflux /= 0.0 )  THEN
1703       message_string = 'boundary_condition: bc_pt_b = "' // TRIM( bc_pt_b ) //&
1704                        '& is not allowed with constant_heatflux = .TRUE.'
1705       CALL message( 'check_parameters', 'PA0065', 1, 2, 0, 6, 0 )
1706    ENDIF
1707    IF ( constant_heatflux  .AND.  pt_surface_initial_change /= 0.0 )  THEN
1708       WRITE ( message_string, * )  'constant_heatflux = .TRUE. is not allo', &
1709               'wed with pt_surface_initial_change (/=0) = ', &
1710               pt_surface_initial_change
1711       CALL message( 'check_parameters', 'PA0066', 1, 2, 0, 6, 0 )
1712    ENDIF
1713
1714!
1715!-- A given temperature at the top implies Dirichlet boundary condition for
1716!-- temperature. In this case specification of a constant heat flux is
1717!-- forbidden.
1718    IF ( ibc_pt_t == 0  .AND.   constant_top_heatflux  .AND. &
1719         top_heatflux /= 0.0 )  THEN
1720       message_string = 'boundary_condition: bc_pt_t = "' // TRIM( bc_pt_t ) //&
1721                        '" is not allowed with constant_top_heatflux = .TRUE.'
1722       CALL message( 'check_parameters', 'PA0067', 1, 2, 0, 6, 0 )
1723    ENDIF
1724
1725!
1726!-- Boundary conditions for salinity
1727    IF ( ocean )  THEN
1728       IF ( bc_sa_t == 'dirichlet' )  THEN
1729          ibc_sa_t = 0
1730       ELSEIF ( bc_sa_t == 'neumann' )  THEN
1731          ibc_sa_t = 1
1732       ELSE
1733          message_string = 'unknown boundary condition: bc_sa_t = "' // &
1734                           TRIM( bc_sa_t ) // '"'
1735          CALL message( 'check_parameters', 'PA0068', 1, 2, 0, 6, 0 )
1736       ENDIF
1737
1738       IF ( top_salinityflux == 9999999.9 )  constant_top_salinityflux = .FALSE.
1739       IF ( ibc_sa_t == 1  .AND.   top_salinityflux == 9999999.9 )  THEN
1740          message_string = 'boundary condition: bc_sa_t = "' // &
1741                           TRIM( bc_sa_t ) // '" requires to set ' // &
1742                           'top_salinityflux'
1743          CALL message( 'check_parameters', 'PA0069', 1, 2, 0, 6, 0 )
1744       ENDIF
1745
1746!
1747!--    A fixed salinity at the top implies Dirichlet boundary condition for
1748!--    salinity. In this case specification of a constant salinity flux is
1749!--    forbidden.
1750       IF ( ibc_sa_t == 0  .AND.   constant_top_salinityflux  .AND. &
1751            top_salinityflux /= 0.0 )  THEN
1752          message_string = 'boundary condition: bc_sa_t = "' // &
1753                           TRIM( bc_sa_t ) // '" is not allowed with ' // &
1754                           'constant_top_salinityflux = .TRUE.'
1755          CALL message( 'check_parameters', 'PA0070', 1, 2, 0, 6, 0 )
1756       ENDIF
1757
1758    ENDIF
1759
1760!
1761!-- In case of humidity or passive scalar, set boundary conditions for total
1762!-- water content / scalar
1763    IF ( humidity  .OR.  passive_scalar ) THEN
1764       IF ( humidity )  THEN
1765          sq = 'q'
1766       ELSE
1767          sq = 's'
1768       ENDIF
1769       IF ( bc_q_b == 'dirichlet' )  THEN
1770          ibc_q_b = 0
1771       ELSEIF ( bc_q_b == 'neumann' )  THEN
1772          ibc_q_b = 1
1773       ELSE
1774          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1775                           '_b ="' // TRIM( bc_q_b ) // '"'
1776          CALL message( 'check_parameters', 'PA0071', 1, 2, 0, 6, 0 )
1777       ENDIF
1778       IF ( bc_q_t == 'dirichlet' )  THEN
1779          ibc_q_t = 0
1780       ELSEIF ( bc_q_t == 'neumann' )  THEN
1781          ibc_q_t = 1
1782       ELSE
1783          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1784                           '_t ="' // TRIM( bc_q_t ) // '"'
1785          CALL message( 'check_parameters', 'PA0072', 1, 2, 0, 6, 0 )
1786       ENDIF
1787
1788       IF ( surface_waterflux == 9999999.9  )  THEN
1789          constant_waterflux = .FALSE.
1790          IF ( large_scale_forcing )  THEN
1791             IF ( ibc_q_b == 0 )  THEN
1792                constant_waterflux = .FALSE.
1793             ELSEIF ( ibc_q_b == 1 )  THEN
1794                constant_waterflux = .TRUE.
1795                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1796                   surface_waterflux = qsws_surf(1)
1797                ENDIF
1798             ENDIF
1799          ENDIF
1800       ELSE
1801          constant_waterflux = .TRUE.
1802          IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. &
1803                 large_scale_forcing ) THEN
1804             surface_waterflux = qsws_surf(1)
1805          ENDIF
1806       ENDIF
1807
1808!
1809!--    A given surface humidity implies Dirichlet boundary condition for
1810!--    humidity. In this case specification of a constant water flux is
1811!--    forbidden.
1812       IF ( ibc_q_b == 0  .AND.  constant_waterflux )  THEN
1813          message_string = 'boundary condition: bc_' // TRIM( sq ) // '_b ' // &
1814                           '= "' // TRIM( bc_q_b ) // '" is not allowed wi' // &
1815                           'th prescribed surface flux'
1816          CALL message( 'check_parameters', 'PA0073', 1, 2, 0, 6, 0 )
1817       ENDIF
1818       IF ( constant_waterflux  .AND.  q_surface_initial_change /= 0.0 )  THEN
1819          WRITE( message_string, * )  'a prescribed surface flux is not allo', &
1820                 'wed with ', sq, '_surface_initial_change (/=0) = ', &
1821                 q_surface_initial_change
1822          CALL message( 'check_parameters', 'PA0074', 1, 2, 0, 6, 0 )
1823       ENDIF
1824
1825    ENDIF
1826!
1827!-- Boundary conditions for horizontal components of wind speed
1828    IF ( bc_uv_b == 'dirichlet' )  THEN
1829       ibc_uv_b = 0
1830    ELSEIF ( bc_uv_b == 'neumann' )  THEN
1831       ibc_uv_b = 1
1832       IF ( prandtl_layer )  THEN
1833          message_string = 'boundary condition: bc_uv_b = "' // &
1834               TRIM( bc_uv_b ) // '" is not allowed with prandtl_layer = .TRUE.'
1835          CALL message( 'check_parameters', 'PA0075', 1, 2, 0, 6, 0 )
1836       ENDIF
1837    ELSE
1838       message_string = 'unknown boundary condition: bc_uv_b = "' // &
1839                        TRIM( bc_uv_b ) // '"'
1840       CALL message( 'check_parameters', 'PA0076', 1, 2, 0, 6, 0 )
1841    ENDIF
1842!
1843!-- In case of coupled simulations u and v at the ground in atmosphere will be
1844!-- assigned with the u and v values of the ocean surface
1845    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1846       ibc_uv_b = 2
1847    ENDIF
1848
1849    IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
1850       bc_uv_t = 'neumann'
1851       ibc_uv_t = 1
1852    ELSE
1853       IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
1854          ibc_uv_t = 0
1855          IF ( bc_uv_t == 'dirichlet_0' )  THEN
1856!
1857!--          Velocities for the initial u,v-profiles are set zero at the top
1858!--          in case of dirichlet_0 conditions
1859             u_init(nzt+1)    = 0.0
1860             v_init(nzt+1)    = 0.0
1861          ENDIF
1862       ELSEIF ( bc_uv_t == 'neumann' )  THEN
1863          ibc_uv_t = 1
1864       ELSE
1865          message_string = 'unknown boundary condition: bc_uv_t = "' // &
1866                           TRIM( bc_uv_t ) // '"'
1867          CALL message( 'check_parameters', 'PA0077', 1, 2, 0, 6, 0 )
1868       ENDIF
1869    ENDIF
1870
1871!
1872!-- Compute and check, respectively, the Rayleigh Damping parameter
1873    IF ( rayleigh_damping_factor == -1.0 )  THEN
1874       rayleigh_damping_factor = 0.0
1875    ELSE
1876       IF ( rayleigh_damping_factor < 0.0 .OR. rayleigh_damping_factor > 1.0 ) &
1877       THEN
1878          WRITE( message_string, * )  'rayleigh_damping_factor = ', &
1879                              rayleigh_damping_factor, ' out of range [0.0,1.0]'
1880          CALL message( 'check_parameters', 'PA0078', 1, 2, 0, 6, 0 )
1881       ENDIF
1882    ENDIF
1883
1884    IF ( rayleigh_damping_height == -1.0 )  THEN
1885       IF ( .NOT. ocean )  THEN
1886          rayleigh_damping_height = 0.66666666666 * zu(nzt)
1887       ELSE
1888          rayleigh_damping_height = 0.66666666666 * zu(nzb)
1889       ENDIF
1890    ELSE
1891       IF ( .NOT. ocean )  THEN
1892          IF ( rayleigh_damping_height < 0.0  .OR. &
1893               rayleigh_damping_height > zu(nzt) )  THEN
1894             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1895                   rayleigh_damping_height, ' out of range [0.0,', zu(nzt), ']'
1896             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1897          ENDIF
1898       ELSE
1899          IF ( rayleigh_damping_height > 0.0  .OR. &
1900               rayleigh_damping_height < zu(nzb) )  THEN
1901             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1902                   rayleigh_damping_height, ' out of range [0.0,', zu(nzb), ']'
1903             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1904          ENDIF
1905       ENDIF
1906    ENDIF
1907
1908!
1909!-- Check number of chosen statistic regions. More than 10 regions are not
1910!-- allowed, because so far no more than 10 corresponding output files can
1911!-- be opened (cf. check_open)
1912    IF ( statistic_regions > 9  .OR.  statistic_regions < 0 )  THEN
1913       WRITE ( message_string, * ) 'number of statistic_regions = ', &
1914                   statistic_regions+1, ' but only 10 regions are allowed'
1915       CALL message( 'check_parameters', 'PA0082', 1, 2, 0, 6, 0 )
1916    ENDIF
1917    IF ( normalizing_region > statistic_regions  .OR. &
1918         normalizing_region < 0)  THEN
1919       WRITE ( message_string, * ) 'normalizing_region = ', &
1920                normalizing_region, ' must be >= 0 and <= ',statistic_regions, &
1921                ' (value of statistic_regions)'
1922       CALL message( 'check_parameters', 'PA0083', 1, 2, 0, 6, 0 )
1923    ENDIF
1924
1925!
1926!-- Check the interval for sorting particles.
1927!-- Using particles as cloud droplets requires sorting after each timestep.
1928    IF ( dt_sort_particles /= 0.0  .AND.  cloud_droplets )  THEN
1929       dt_sort_particles = 0.0
1930       message_string = 'dt_sort_particles is reset to 0.0 because of cloud' //&
1931                        '_droplets = .TRUE.'
1932       CALL message( 'check_parameters', 'PA0084', 0, 1, 0, 6, 0 )
1933    ENDIF
1934
1935!
1936!-- Set the default intervals for data output, if necessary
1937!-- NOTE: dt_dosp has already been set in package_parin
1938    IF ( dt_data_output /= 9999999.9 )  THEN
1939       IF ( dt_dopr           == 9999999.9 )  dt_dopr           = dt_data_output
1940       IF ( dt_dopts          == 9999999.9 )  dt_dopts          = dt_data_output
1941       IF ( dt_do2d_xy        == 9999999.9 )  dt_do2d_xy        = dt_data_output
1942       IF ( dt_do2d_xz        == 9999999.9 )  dt_do2d_xz        = dt_data_output
1943       IF ( dt_do2d_yz        == 9999999.9 )  dt_do2d_yz        = dt_data_output
1944       IF ( dt_do3d           == 9999999.9 )  dt_do3d           = dt_data_output
1945       IF ( dt_data_output_av == 9999999.9 )  dt_data_output_av = dt_data_output
1946       DO  mid = 1, max_masks
1947          IF ( dt_domask(mid) == 9999999.9 )  dt_domask(mid)    = dt_data_output
1948       ENDDO
1949    ENDIF
1950
1951!
1952!-- Set the default skip time intervals for data output, if necessary
1953    IF ( skip_time_dopr    == 9999999.9 ) &
1954                                       skip_time_dopr    = skip_time_data_output
1955    IF ( skip_time_dosp    == 9999999.9 ) &
1956                                       skip_time_dosp    = skip_time_data_output
1957    IF ( skip_time_do2d_xy == 9999999.9 ) &
1958                                       skip_time_do2d_xy = skip_time_data_output
1959    IF ( skip_time_do2d_xz == 9999999.9 ) &
1960                                       skip_time_do2d_xz = skip_time_data_output
1961    IF ( skip_time_do2d_yz == 9999999.9 ) &
1962                                       skip_time_do2d_yz = skip_time_data_output
1963    IF ( skip_time_do3d    == 9999999.9 ) &
1964                                       skip_time_do3d    = skip_time_data_output
1965    IF ( skip_time_data_output_av == 9999999.9 ) &
1966                                skip_time_data_output_av = skip_time_data_output
1967    DO  mid = 1, max_masks
1968       IF ( skip_time_domask(mid) == 9999999.9 ) &
1969                                skip_time_domask(mid)    = skip_time_data_output
1970    ENDDO
1971
1972!
1973!-- Check the average intervals (first for 3d-data, then for profiles and
1974!-- spectra)
1975    IF ( averaging_interval > dt_data_output_av )  THEN
1976       WRITE( message_string, * )  'averaging_interval = ', &
1977             averaging_interval, ' must be <= dt_data_output = ', dt_data_output
1978       CALL message( 'check_parameters', 'PA0085', 1, 2, 0, 6, 0 )
1979    ENDIF
1980
1981    IF ( averaging_interval_pr == 9999999.9 )  THEN
1982       averaging_interval_pr = averaging_interval
1983    ENDIF
1984
1985    IF ( averaging_interval_pr > dt_dopr )  THEN
1986       WRITE( message_string, * )  'averaging_interval_pr = ', &
1987             averaging_interval_pr, ' must be <= dt_dopr = ', dt_dopr
1988       CALL message( 'check_parameters', 'PA0086', 1, 2, 0, 6, 0 )
1989    ENDIF
1990
1991    IF ( averaging_interval_sp == 9999999.9 )  THEN
1992       averaging_interval_sp = averaging_interval
1993    ENDIF
1994
1995    IF ( averaging_interval_sp > dt_dosp )  THEN
1996       WRITE( message_string, * )  'averaging_interval_sp = ', &
1997             averaging_interval_sp, ' must be <= dt_dosp = ', dt_dosp
1998       CALL message( 'check_parameters', 'PA0087', 1, 2, 0, 6, 0 )
1999    ENDIF
2000
2001!
2002!-- Set the default interval for profiles entering the temporal average
2003    IF ( dt_averaging_input_pr == 9999999.9 )  THEN
2004       dt_averaging_input_pr = dt_averaging_input
2005    ENDIF
2006
2007!
2008!-- Set the default interval for the output of timeseries to a reasonable
2009!-- value (tries to minimize the number of calls of flow_statistics)
2010    IF ( dt_dots == 9999999.9 )  THEN
2011       IF ( averaging_interval_pr == 0.0 )  THEN
2012          dt_dots = MIN( dt_run_control, dt_dopr )
2013       ELSE
2014          dt_dots = MIN( dt_run_control, dt_averaging_input_pr )
2015       ENDIF
2016    ENDIF
2017
2018!
2019!-- Check the sample rate for averaging (first for 3d-data, then for profiles)
2020    IF ( dt_averaging_input > averaging_interval )  THEN
2021       WRITE( message_string, * )  'dt_averaging_input = ', &
2022                dt_averaging_input, ' must be <= averaging_interval = ', &
2023                averaging_interval
2024       CALL message( 'check_parameters', 'PA0088', 1, 2, 0, 6, 0 )
2025    ENDIF
2026
2027    IF ( dt_averaging_input_pr > averaging_interval_pr )  THEN
2028       WRITE( message_string, * )  'dt_averaging_input_pr = ', &
2029                dt_averaging_input_pr, ' must be <= averaging_interval_pr = ', &
2030                averaging_interval_pr
2031       CALL message( 'check_parameters', 'PA0089', 1, 2, 0, 6, 0 )
2032    ENDIF
2033
2034!
2035!-- Set the default value for the integration interval of precipitation amount
2036    IF ( precipitation )  THEN
2037       IF ( precipitation_amount_interval == 9999999.9 )  THEN
2038          precipitation_amount_interval = dt_do2d_xy
2039       ELSE
2040          IF ( precipitation_amount_interval > dt_do2d_xy )  THEN
2041             WRITE( message_string, * )  'precipitation_amount_interval = ', &
2042                 precipitation_amount_interval, ' must not be larger than ', &
2043                 'dt_do2d_xy = ', dt_do2d_xy
2044             CALL message( 'check_parameters', 'PA0090', 1, 2, 0, 6, 0 )
2045          ENDIF
2046       ENDIF
2047    ENDIF
2048
2049!
2050!-- Determine the number of output profiles and check whether they are
2051!-- permissible
2052    DO  WHILE ( data_output_pr(dopr_n+1) /= '          ' )
2053
2054       dopr_n = dopr_n + 1
2055       i = dopr_n
2056
2057!
2058!--    Determine internal profile number (for hom, homs)
2059!--    and store height levels
2060       SELECT CASE ( TRIM( data_output_pr(i) ) )
2061
2062          CASE ( 'u', '#u' )
2063             dopr_index(i) = 1
2064             dopr_unit(i)  = 'm/s'
2065             hom(:,2,1,:)  = SPREAD( zu, 2, statistic_regions+1 )
2066             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2067                dopr_initial_index(i) = 5
2068                hom(:,2,5,:)          = SPREAD( zu, 2, statistic_regions+1 )
2069                data_output_pr(i)     = data_output_pr(i)(2:)
2070             ENDIF
2071
2072          CASE ( 'v', '#v' )
2073             dopr_index(i) = 2
2074             dopr_unit(i)  = 'm/s'
2075             hom(:,2,2,:)  = SPREAD( zu, 2, statistic_regions+1 )
2076             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2077                dopr_initial_index(i) = 6
2078                hom(:,2,6,:)          = SPREAD( zu, 2, statistic_regions+1 )
2079                data_output_pr(i)     = data_output_pr(i)(2:)
2080             ENDIF
2081
2082          CASE ( 'w' )
2083             dopr_index(i) = 3
2084             dopr_unit(i)  = 'm/s'
2085             hom(:,2,3,:)  = SPREAD( zw, 2, statistic_regions+1 )
2086
2087          CASE ( 'pt', '#pt' )
2088             IF ( .NOT. cloud_physics ) THEN
2089                dopr_index(i) = 4
2090                dopr_unit(i)  = 'K'
2091                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
2092                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2093                   dopr_initial_index(i) = 7
2094                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
2095                   hom(nzb,2,7,:)        = 0.0    ! because zu(nzb) is negative
2096                   data_output_pr(i)     = data_output_pr(i)(2:)
2097                ENDIF
2098             ELSE
2099                dopr_index(i) = 43
2100                dopr_unit(i)  = 'K'
2101                hom(:,2,43,:)  = SPREAD( zu, 2, statistic_regions+1 )
2102                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2103                   dopr_initial_index(i) = 28
2104                   hom(:,2,28,:)         = SPREAD( zu, 2, statistic_regions+1 )
2105                   hom(nzb,2,28,:)       = 0.0    ! because zu(nzb) is negative
2106                   data_output_pr(i)     = data_output_pr(i)(2:)
2107                ENDIF
2108             ENDIF
2109
2110          CASE ( 'e' )
2111             dopr_index(i)  = 8
2112             dopr_unit(i)   = 'm2/s2'
2113             hom(:,2,8,:)   = SPREAD( zu, 2, statistic_regions+1 )
2114             hom(nzb,2,8,:) = 0.0
2115
2116          CASE ( 'km', '#km' )
2117             dopr_index(i)  = 9
2118             dopr_unit(i)   = 'm2/s'
2119             hom(:,2,9,:)   = SPREAD( zu, 2, statistic_regions+1 )
2120             hom(nzb,2,9,:) = 0.0
2121             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2122                dopr_initial_index(i) = 23
2123                hom(:,2,23,:)         = hom(:,2,9,:)
2124                data_output_pr(i)     = data_output_pr(i)(2:)
2125             ENDIF
2126
2127          CASE ( 'kh', '#kh' )
2128             dopr_index(i)   = 10
2129             dopr_unit(i)    = 'm2/s'
2130             hom(:,2,10,:)   = SPREAD( zu, 2, statistic_regions+1 )
2131             hom(nzb,2,10,:) = 0.0
2132             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2133                dopr_initial_index(i) = 24
2134                hom(:,2,24,:)         = hom(:,2,10,:)
2135                data_output_pr(i)     = data_output_pr(i)(2:)
2136             ENDIF
2137
2138          CASE ( 'l', '#l' )
2139             dopr_index(i)   = 11
2140             dopr_unit(i)    = 'm'
2141             hom(:,2,11,:)   = SPREAD( zu, 2, statistic_regions+1 )
2142             hom(nzb,2,11,:) = 0.0
2143             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2144                dopr_initial_index(i) = 25
2145                hom(:,2,25,:)         = hom(:,2,11,:)
2146                data_output_pr(i)     = data_output_pr(i)(2:)
2147             ENDIF
2148
2149          CASE ( 'w"u"' )
2150             dopr_index(i) = 12
2151             dopr_unit(i)  = 'm2/s2'
2152             hom(:,2,12,:) = SPREAD( zw, 2, statistic_regions+1 )
2153             IF ( prandtl_layer )  hom(nzb,2,12,:) = zu(1)
2154
2155          CASE ( 'w*u*' )
2156             dopr_index(i) = 13
2157             dopr_unit(i)  = 'm2/s2'
2158             hom(:,2,13,:) = SPREAD( zw, 2, statistic_regions+1 )
2159
2160          CASE ( 'w"v"' )
2161             dopr_index(i) = 14
2162             dopr_unit(i)  = 'm2/s2'
2163             hom(:,2,14,:) = SPREAD( zw, 2, statistic_regions+1 )
2164             IF ( prandtl_layer )  hom(nzb,2,14,:) = zu(1)
2165
2166          CASE ( 'w*v*' )
2167             dopr_index(i) = 15
2168             dopr_unit(i)  = 'm2/s2'
2169             hom(:,2,15,:) = SPREAD( zw, 2, statistic_regions+1 )
2170
2171          CASE ( 'w"pt"' )
2172             dopr_index(i) = 16
2173             dopr_unit(i)  = 'K m/s'
2174             hom(:,2,16,:) = SPREAD( zw, 2, statistic_regions+1 )
2175
2176          CASE ( 'w*pt*' )
2177             dopr_index(i) = 17
2178             dopr_unit(i)  = 'K m/s'
2179             hom(:,2,17,:) = SPREAD( zw, 2, statistic_regions+1 )
2180
2181          CASE ( 'wpt' )
2182             dopr_index(i) = 18
2183             dopr_unit(i)  = 'K m/s'
2184             hom(:,2,18,:) = SPREAD( zw, 2, statistic_regions+1 )
2185
2186          CASE ( 'wu' )
2187             dopr_index(i) = 19
2188             dopr_unit(i)  = 'm2/s2'
2189             hom(:,2,19,:) = SPREAD( zw, 2, statistic_regions+1 )
2190             IF ( prandtl_layer )  hom(nzb,2,19,:) = zu(1)
2191
2192          CASE ( 'wv' )
2193             dopr_index(i) = 20
2194             dopr_unit(i)  = 'm2/s2'
2195             hom(:,2,20,:) = SPREAD( zw, 2, statistic_regions+1 )
2196             IF ( prandtl_layer )  hom(nzb,2,20,:) = zu(1)
2197
2198          CASE ( 'w*pt*BC' )
2199             dopr_index(i) = 21
2200             dopr_unit(i)  = 'K m/s'
2201             hom(:,2,21,:) = SPREAD( zw, 2, statistic_regions+1 )
2202
2203          CASE ( 'wptBC' )
2204             dopr_index(i) = 22
2205             dopr_unit(i)  = 'K m/s'
2206             hom(:,2,22,:) = SPREAD( zw, 2, statistic_regions+1 )
2207
2208          CASE ( 'sa', '#sa' )
2209             IF ( .NOT. ocean )  THEN
2210                message_string = 'data_output_pr = ' // &
2211                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2212                                 'lemented for ocean = .FALSE.'
2213                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2214             ELSE
2215                dopr_index(i) = 23
2216                dopr_unit(i)  = 'psu'
2217                hom(:,2,23,:) = SPREAD( zu, 2, statistic_regions+1 )
2218                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2219                   dopr_initial_index(i) = 26
2220                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2221                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2222                   data_output_pr(i)     = data_output_pr(i)(2:)
2223                ENDIF
2224             ENDIF
2225
2226          CASE ( 'u*2' )
2227             dopr_index(i) = 30
2228             dopr_unit(i)  = 'm2/s2'
2229             hom(:,2,30,:) = SPREAD( zu, 2, statistic_regions+1 )
2230
2231          CASE ( 'v*2' )
2232             dopr_index(i) = 31
2233             dopr_unit(i)  = 'm2/s2'
2234             hom(:,2,31,:) = SPREAD( zu, 2, statistic_regions+1 )
2235
2236          CASE ( 'w*2' )
2237             dopr_index(i) = 32
2238             dopr_unit(i)  = 'm2/s2'
2239             hom(:,2,32,:) = SPREAD( zw, 2, statistic_regions+1 )
2240
2241          CASE ( 'pt*2' )
2242             dopr_index(i) = 33
2243             dopr_unit(i)  = 'K2'
2244             hom(:,2,33,:) = SPREAD( zu, 2, statistic_regions+1 )
2245
2246          CASE ( 'e*' )
2247             dopr_index(i) = 34
2248             dopr_unit(i)  = 'm2/s2'
2249             hom(:,2,34,:) = SPREAD( zu, 2, statistic_regions+1 )
2250
2251          CASE ( 'w*2pt*' )
2252             dopr_index(i) = 35
2253             dopr_unit(i)  = 'K m2/s2'
2254             hom(:,2,35,:) = SPREAD( zw, 2, statistic_regions+1 )
2255
2256          CASE ( 'w*pt*2' )
2257             dopr_index(i) = 36
2258             dopr_unit(i)  = 'K2 m/s'
2259             hom(:,2,36,:) = SPREAD( zw, 2, statistic_regions+1 )
2260
2261          CASE ( 'w*e*' )
2262             dopr_index(i) = 37
2263             dopr_unit(i)  = 'm3/s3'
2264             hom(:,2,37,:) = SPREAD( zw, 2, statistic_regions+1 )
2265
2266          CASE ( 'w*3' )
2267             dopr_index(i) = 38
2268             dopr_unit(i)  = 'm3/s3'
2269             hom(:,2,38,:) = SPREAD( zw, 2, statistic_regions+1 )
2270
2271          CASE ( 'Sw' )
2272             dopr_index(i) = 39
2273             dopr_unit(i)  = 'none'
2274             hom(:,2,39,:) = SPREAD( zw, 2, statistic_regions+1 )
2275
2276          CASE ( 'p' )
2277             dopr_index(i) = 40
2278             dopr_unit(i)  = 'Pa'
2279             hom(:,2,40,:) = SPREAD( zu, 2, statistic_regions+1 )
2280
2281          CASE ( 'q', '#q' )
2282             IF ( .NOT. humidity )  THEN
2283                message_string = 'data_output_pr = ' // &
2284                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2285                                 'lemented for humidity = .FALSE.'
2286                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2287             ELSE
2288                dopr_index(i) = 41
2289                dopr_unit(i)  = 'kg/kg'
2290                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2291                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2292                   dopr_initial_index(i) = 26
2293                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2294                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2295                   data_output_pr(i)     = data_output_pr(i)(2:)
2296                ENDIF
2297             ENDIF
2298
2299          CASE ( 's', '#s' )
2300             IF ( .NOT. passive_scalar )  THEN
2301                message_string = 'data_output_pr = ' // &
2302                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2303                                 'lemented for passive_scalar = .FALSE.'
2304                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2305             ELSE
2306                dopr_index(i) = 41
2307                dopr_unit(i)  = 'kg/m3'
2308                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2309                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2310                   dopr_initial_index(i) = 26
2311                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2312                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2313                   data_output_pr(i)     = data_output_pr(i)(2:)
2314                ENDIF
2315             ENDIF
2316
2317          CASE ( 'qv', '#qv' )
2318             IF ( .NOT. cloud_physics ) THEN
2319                dopr_index(i) = 41
2320                dopr_unit(i)  = 'kg/kg'
2321                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2322                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2323                   dopr_initial_index(i) = 26
2324                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2325                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2326                   data_output_pr(i)     = data_output_pr(i)(2:)
2327                ENDIF
2328             ELSE
2329                dopr_index(i) = 42
2330                dopr_unit(i)  = 'kg/kg'
2331                hom(:,2,42,:) = SPREAD( zu, 2, statistic_regions+1 )
2332                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2333                   dopr_initial_index(i) = 27
2334                   hom(:,2,27,:)         = SPREAD( zu, 2, statistic_regions+1 )
2335                   hom(nzb,2,27,:)       = 0.0    ! weil zu(nzb) negativ ist
2336                   data_output_pr(i)     = data_output_pr(i)(2:)
2337                ENDIF
2338             ENDIF
2339
2340          CASE ( 'lpt', '#lpt' )
2341             IF ( .NOT. cloud_physics ) THEN
2342                message_string = 'data_output_pr = ' // &
2343                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2344                                 'lemented for cloud_physics = .FALSE.'
2345                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2346             ELSE
2347                dopr_index(i) = 4
2348                dopr_unit(i)  = 'K'
2349                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
2350                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2351                   dopr_initial_index(i) = 7
2352                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
2353                   hom(nzb,2,7,:)        = 0.0    ! weil zu(nzb) negativ ist
2354                   data_output_pr(i)     = data_output_pr(i)(2:)
2355                ENDIF
2356             ENDIF
2357
2358          CASE ( 'vpt', '#vpt' )
2359             dopr_index(i) = 44
2360             dopr_unit(i)  = 'K'
2361             hom(:,2,44,:) = SPREAD( zu, 2, statistic_regions+1 )
2362             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2363                dopr_initial_index(i) = 29
2364                hom(:,2,29,:)         = SPREAD( zu, 2, statistic_regions+1 )
2365                hom(nzb,2,29,:)       = 0.0    ! weil zu(nzb) negativ ist
2366                data_output_pr(i)     = data_output_pr(i)(2:)
2367             ENDIF
2368
2369          CASE ( 'w"vpt"' )
2370             dopr_index(i) = 45
2371             dopr_unit(i)  = 'K m/s'
2372             hom(:,2,45,:) = SPREAD( zw, 2, statistic_regions+1 )
2373
2374          CASE ( 'w*vpt*' )
2375             dopr_index(i) = 46
2376             dopr_unit(i)  = 'K m/s'
2377             hom(:,2,46,:) = SPREAD( zw, 2, statistic_regions+1 )
2378
2379          CASE ( 'wvpt' )
2380             dopr_index(i) = 47
2381             dopr_unit(i)  = 'K m/s'
2382             hom(:,2,47,:) = SPREAD( zw, 2, statistic_regions+1 )
2383
2384          CASE ( 'w"q"' )
2385             IF ( .NOT. humidity )  THEN
2386                message_string = 'data_output_pr = ' // &
2387                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2388                                 'lemented for humidity = .FALSE.'
2389                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2390             ELSE
2391                dopr_index(i) = 48
2392                dopr_unit(i)  = 'kg/kg m/s'
2393                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2394             ENDIF
2395
2396          CASE ( 'w*q*' )
2397             IF ( .NOT. humidity )  THEN
2398                message_string = 'data_output_pr = ' // &
2399                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2400                                 'lemented for humidity = .FALSE.'
2401                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2402             ELSE
2403                dopr_index(i) = 49
2404                dopr_unit(i)  = 'kg/kg m/s'
2405                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2406             ENDIF
2407
2408          CASE ( 'wq' )
2409             IF ( .NOT. humidity )  THEN
2410                message_string = 'data_output_pr = ' // &
2411                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2412                                 'lemented for humidity = .FALSE.'
2413                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2414             ELSE
2415                dopr_index(i) = 50
2416                dopr_unit(i)  = 'kg/kg m/s'
2417                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2418             ENDIF
2419
2420          CASE ( 'w"s"' )
2421             IF ( .NOT. passive_scalar ) THEN
2422                message_string = 'data_output_pr = ' // &
2423                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2424                                 'lemented for passive_scalar = .FALSE.'
2425                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2426             ELSE
2427                dopr_index(i) = 48
2428                dopr_unit(i)  = 'kg/m3 m/s'
2429                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2430             ENDIF
2431
2432          CASE ( 'w*s*' )
2433             IF ( .NOT. passive_scalar ) THEN
2434                message_string = 'data_output_pr = ' // &
2435                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2436                                 'lemented for passive_scalar = .FALSE.'
2437                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2438             ELSE
2439                dopr_index(i) = 49
2440                dopr_unit(i)  = 'kg/m3 m/s'
2441                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2442             ENDIF
2443
2444          CASE ( 'ws' )
2445             IF ( .NOT. passive_scalar ) THEN
2446                message_string = 'data_output_pr = ' // &
2447                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2448                                 'lemented for passive_scalar = .FALSE.'
2449                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2450             ELSE
2451                dopr_index(i) = 50
2452                dopr_unit(i)  = 'kg/m3 m/s'
2453                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2454             ENDIF
2455
2456          CASE ( 'w"qv"' )
2457             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2458             THEN
2459                dopr_index(i) = 48
2460                dopr_unit(i)  = 'kg/kg m/s'
2461                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2462             ELSEIF( humidity .AND. cloud_physics ) THEN
2463                dopr_index(i) = 51
2464                dopr_unit(i)  = 'kg/kg m/s'
2465                hom(:,2,51,:) = SPREAD( zw, 2, statistic_regions+1 )
2466             ELSE
2467                message_string = 'data_output_pr = ' // &
2468                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2469                                 'lemented for cloud_physics = .FALSE. an&' // &
2470                                 'd humidity = .FALSE.'
2471                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2472             ENDIF
2473
2474          CASE ( 'w*qv*' )
2475             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2476             THEN
2477                dopr_index(i) = 49
2478                dopr_unit(i)  = 'kg/kg m/s'
2479                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2480             ELSEIF( humidity .AND. cloud_physics ) THEN
2481                dopr_index(i) = 52
2482                dopr_unit(i)  = 'kg/kg m/s'
2483                hom(:,2,52,:) = SPREAD( zw, 2, statistic_regions+1 )
2484             ELSE
2485                message_string = 'data_output_pr = ' // &
2486                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2487                                 'lemented for cloud_physics = .FALSE. an&' // &
2488                                 'd humidity = .FALSE.'
2489                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2490             ENDIF
2491
2492          CASE ( 'wqv' )
2493             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2494             THEN
2495                dopr_index(i) = 50
2496                dopr_unit(i)  = 'kg/kg m/s'
2497                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2498             ELSEIF( humidity .AND. cloud_physics ) THEN
2499                dopr_index(i) = 53
2500                dopr_unit(i)  = 'kg/kg m/s'
2501                hom(:,2,53,:) = SPREAD( zw, 2, statistic_regions+1 )
2502             ELSE
2503                message_string = 'data_output_pr = ' // &
2504                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2505                                 'lemented for cloud_physics = .FALSE. an&' // &
2506                                 'd humidity = .FALSE.'
2507                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2508             ENDIF
2509
2510          CASE ( 'ql' )
2511             IF ( .NOT. cloud_physics  .AND.  .NOT. cloud_droplets )  THEN
2512                message_string = 'data_output_pr = ' // &
2513                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2514                                 'lemented for cloud_physics = .FALSE. or'  // &
2515                                 '&cloud_droplets = .FALSE.'
2516                CALL message( 'check_parameters', 'PA0096', 1, 2, 0, 6, 0 )
2517             ELSE
2518                dopr_index(i) = 54
2519                dopr_unit(i)  = 'kg/kg'
2520                hom(:,2,54,:)  = SPREAD( zu, 2, statistic_regions+1 )
2521             ENDIF
2522
2523          CASE ( 'w*u*u*:dz' )
2524             dopr_index(i) = 55
2525             dopr_unit(i)  = 'm2/s3'
2526             hom(:,2,55,:) = SPREAD( zu, 2, statistic_regions+1 )
2527
2528          CASE ( 'w*p*:dz' )
2529             dopr_index(i) = 56
2530             dopr_unit(i)  = 'm2/s3'
2531             hom(:,2,56,:) = SPREAD( zw, 2, statistic_regions+1 )
2532
2533          CASE ( 'w"e:dz' )
2534             dopr_index(i) = 57
2535             dopr_unit(i)  = 'm2/s3'
2536             hom(:,2,57,:) = SPREAD( zu, 2, statistic_regions+1 )
2537
2538
2539          CASE ( 'u"pt"' )
2540             dopr_index(i) = 58
2541             dopr_unit(i)  = 'K m/s'
2542             hom(:,2,58,:) = SPREAD( zu, 2, statistic_regions+1 )
2543
2544          CASE ( 'u*pt*' )
2545             dopr_index(i) = 59
2546             dopr_unit(i)  = 'K m/s'
2547             hom(:,2,59,:) = SPREAD( zu, 2, statistic_regions+1 )
2548
2549          CASE ( 'upt_t' )
2550             dopr_index(i) = 60
2551             dopr_unit(i)  = 'K m/s'
2552             hom(:,2,60,:) = SPREAD( zu, 2, statistic_regions+1 )
2553
2554          CASE ( 'v"pt"' )
2555             dopr_index(i) = 61
2556             dopr_unit(i)  = 'K m/s'
2557             hom(:,2,61,:) = SPREAD( zu, 2, statistic_regions+1 )
2558             
2559          CASE ( 'v*pt*' )
2560             dopr_index(i) = 62
2561             dopr_unit(i)  = 'K m/s'
2562             hom(:,2,62,:) = SPREAD( zu, 2, statistic_regions+1 )
2563
2564          CASE ( 'vpt_t' )
2565             dopr_index(i) = 63
2566             dopr_unit(i)  = 'K m/s'
2567             hom(:,2,63,:) = SPREAD( zu, 2, statistic_regions+1 )
2568
2569          CASE ( 'rho' )
2570             IF ( .NOT. ocean ) THEN
2571                message_string = 'data_output_pr = ' // &
2572                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2573                                 'lemented for ocean = .FALSE.'
2574                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2575             ELSE
2576                dopr_index(i) = 64
2577                dopr_unit(i)  = 'kg/m3'
2578                hom(:,2,64,:) = SPREAD( zu, 2, statistic_regions+1 )
2579                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2580                   dopr_initial_index(i) = 77
2581                   hom(:,2,77,:)         = SPREAD( zu, 2, statistic_regions+1 )
2582                   hom(nzb,2,77,:)       = 0.0    ! because zu(nzb) is negative
2583                   data_output_pr(i)     = data_output_pr(i)(2:)
2584                ENDIF
2585             ENDIF
2586
2587          CASE ( 'w"sa"' )
2588             IF ( .NOT. ocean ) THEN
2589                message_string = 'data_output_pr = ' // &
2590                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2591                                 'lemented for ocean = .FALSE.'
2592                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2593             ELSE
2594                dopr_index(i) = 65
2595                dopr_unit(i)  = 'psu m/s'
2596                hom(:,2,65,:) = SPREAD( zw, 2, statistic_regions+1 )
2597             ENDIF
2598
2599          CASE ( 'w*sa*' )
2600             IF ( .NOT. ocean ) THEN
2601                message_string = 'data_output_pr = ' // &
2602                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2603                                 'lemented for ocean = .FALSE.'
2604                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2605             ELSE
2606                dopr_index(i) = 66
2607                dopr_unit(i)  = 'psu m/s'
2608                hom(:,2,66,:) = SPREAD( zw, 2, statistic_regions+1 )
2609             ENDIF
2610
2611          CASE ( 'wsa' )
2612             IF ( .NOT. ocean ) THEN
2613                message_string = 'data_output_pr = ' // &
2614                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2615                                 'lemented for ocean = .FALSE.'
2616                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2617             ELSE
2618                dopr_index(i) = 67
2619                dopr_unit(i)  = 'psu m/s'
2620                hom(:,2,67,:) = SPREAD( zw, 2, statistic_regions+1 )
2621             ENDIF
2622
2623          CASE ( 'w*p*' )
2624             dopr_index(i) = 68
2625             dopr_unit(i)  = 'm3/s3'
2626             hom(:,2,68,:) = SPREAD( zu, 2, statistic_regions+1 )
2627
2628          CASE ( 'w"e' )
2629             dopr_index(i) = 69
2630             dopr_unit(i)  = 'm3/s3'
2631             hom(:,2,69,:) = SPREAD( zu, 2, statistic_regions+1 )
2632
2633          CASE ( 'q*2' )
2634             IF ( .NOT. humidity )  THEN
2635                message_string = 'data_output_pr = ' // &
2636                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2637                                 'lemented for humidity = .FALSE.'
2638                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2639             ELSE
2640                dopr_index(i) = 70
2641                dopr_unit(i)  = 'kg2/kg2'
2642                hom(:,2,70,:) = SPREAD( zu, 2, statistic_regions+1 )
2643             ENDIF
2644
2645          CASE ( 'prho' )
2646             IF ( .NOT. ocean ) THEN
2647                message_string = 'data_output_pr = ' // &
2648                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2649                                 'lemented for ocean = .FALSE.'
2650                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2651             ELSE
2652                dopr_index(i) = 71
2653                dopr_unit(i)  = 'kg/m3'
2654                hom(:,2,71,:) = SPREAD( zu, 2, statistic_regions+1 )
2655             ENDIF
2656
2657          CASE ( 'hyp' )
2658             dopr_index(i) = 72
2659             dopr_unit(i)  = 'dbar'
2660             hom(:,2,72,:) = SPREAD( zu, 2, statistic_regions+1 )
2661
2662          CASE ( 'nr' )
2663             IF ( .NOT. cloud_physics )  THEN
2664                message_string = 'data_output_pr = ' // &
2665                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2666                                 'lemented for cloud_physics = .FALSE.'
2667                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2668             ELSEIF ( icloud_scheme /= 0 )  THEN
2669                message_string = 'data_output_pr = ' // &
2670                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2671                                 'lemented for cloud_scheme /= seifert_beheng'
2672                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2673             ELSEIF ( .NOT. precipitation )  THEN
2674                message_string = 'data_output_pr = ' // &
2675                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2676                                 'lemented for precipitation = .FALSE.'
2677                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2678             ELSE
2679                dopr_index(i) = 73
2680                dopr_unit(i)  = '1/m3'
2681                hom(:,2,73,:)  = SPREAD( zu, 2, statistic_regions+1 )
2682             ENDIF
2683
2684          CASE ( 'qr' )
2685             IF ( .NOT. cloud_physics )  THEN
2686                message_string = 'data_output_pr = ' // &
2687                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2688                                 'lemented for cloud_physics = .FALSE.'
2689                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2690             ELSEIF ( icloud_scheme /= 0 )  THEN
2691                message_string = 'data_output_pr = ' // &
2692                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2693                                 'lemented for cloud_scheme /= seifert_beheng'
2694                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2695             ELSEIF ( .NOT. precipitation )  THEN
2696                message_string = 'data_output_pr = ' // &
2697                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2698                                 'lemented for precipitation = .FALSE.'
2699                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2700             ELSE
2701                dopr_index(i) = 74
2702                dopr_unit(i)  = 'kg/kg'
2703                hom(:,2,74,:)  = SPREAD( zu, 2, statistic_regions+1 )
2704             ENDIF
2705
2706          CASE ( 'qc' )
2707             IF ( .NOT. cloud_physics )  THEN
2708                message_string = 'data_output_pr = ' // &
2709                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2710                                 'lemented for cloud_physics = .FALSE.'
2711                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2712             ELSEIF ( icloud_scheme /= 0 )  THEN
2713                message_string = 'data_output_pr = ' // &
2714                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2715                                 'lemented for cloud_scheme /= seifert_beheng'
2716                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2717             ELSE
2718                dopr_index(i) = 75
2719                dopr_unit(i)  = 'kg/kg'
2720                hom(:,2,75,:)  = SPREAD( zu, 2, statistic_regions+1 )
2721             ENDIF
2722
2723          CASE ( 'prr' )
2724             IF ( .NOT. cloud_physics )  THEN
2725                message_string = 'data_output_pr = ' // &
2726                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2727                                 'lemented for cloud_physics = .FALSE.'
2728                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2729             ELSEIF ( icloud_scheme /= 0 )  THEN
2730                message_string = 'data_output_pr = ' // &
2731                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2732                                 'lemented for cloud_scheme /= seifert_beheng'
2733                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2734             ELSEIF ( .NOT. precipitation )  THEN
2735                message_string = 'data_output_pr = ' // &
2736                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2737                                 'lemented for precipitation = .FALSE.'
2738                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2739
2740             ELSE
2741                dopr_index(i) = 76
2742                dopr_unit(i)  = 'kg/kg m/s'
2743                hom(:,2,76,:)  = SPREAD( zu, 2, statistic_regions+1 )
2744             ENDIF
2745
2746          CASE ( 'ug' )
2747             dopr_index(i) = 78
2748             dopr_unit(i)  = 'm/s'
2749             hom(:,2,78,:) = SPREAD( zu, 2, statistic_regions+1 )
2750
2751          CASE ( 'vg' )
2752             dopr_index(i) = 79
2753             dopr_unit(i)  = 'm/s'
2754             hom(:,2,79,:) = SPREAD( zu, 2, statistic_regions+1 )
2755
2756          CASE ( 'w_subs' )
2757             IF ( .NOT. large_scale_subsidence )  THEN
2758                message_string = 'data_output_pr = ' // &
2759                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2760                                 'lemented for large_scale_subsidence = .FALSE.'
2761                CALL message( 'check_parameters', 'PA0382', 1, 2, 0, 6, 0 )
2762             ELSE
2763                dopr_index(i) = 80
2764                dopr_unit(i)  = 'm/s'
2765                hom(:,2,80,:) = SPREAD( zu, 2, statistic_regions+1 )
2766             ENDIF
2767
2768          CASE DEFAULT
2769
2770             CALL user_check_data_output_pr( data_output_pr(i), i, unit )
2771
2772             IF ( unit == 'illegal' )  THEN
2773                IF ( data_output_pr_user(1) /= ' ' )  THEN
2774                   message_string = 'illegal value for data_output_pr or ' // &
2775                                    'data_output_pr_user = "' // &
2776                                    TRIM( data_output_pr(i) ) // '"'
2777                   CALL message( 'check_parameters', 'PA0097', 1, 2, 0, 6, 0 )
2778                ELSE
2779                   message_string = 'illegal value for data_output_pr = "' // &
2780                                    TRIM( data_output_pr(i) ) // '"'
2781                   CALL message( 'check_parameters', 'PA0098', 1, 2, 0, 6, 0 )
2782                ENDIF
2783             ENDIF
2784
2785       END SELECT
2786
2787    ENDDO
2788
2789
2790!
2791!-- Append user-defined data output variables to the standard data output
2792    IF ( data_output_user(1) /= ' ' )  THEN
2793       i = 1
2794       DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2795          i = i + 1
2796       ENDDO
2797       j = 1
2798       DO  WHILE ( data_output_user(j) /= ' '  .AND.  j <= 100 )
2799          IF ( i > 100 )  THEN
2800             message_string = 'number of output quantitities given by data' // &
2801                '_output and data_output_user exceeds the limit of 100'
2802             CALL message( 'check_parameters', 'PA0102', 1, 2, 0, 6, 0 )
2803          ENDIF
2804          data_output(i) = data_output_user(j)
2805          i = i + 1
2806          j = j + 1
2807       ENDDO
2808    ENDIF
2809
2810!
2811!-- Check and set steering parameters for 2d/3d data output and averaging
2812    i   = 1
2813    DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2814!
2815!--    Check for data averaging
2816       ilen = LEN_TRIM( data_output(i) )
2817       j = 0                                                 ! no data averaging
2818       IF ( ilen > 3 )  THEN
2819          IF ( data_output(i)(ilen-2:ilen) == '_av' )  THEN
2820             j = 1                                           ! data averaging
2821             data_output(i) = data_output(i)(1:ilen-3)
2822          ENDIF
2823       ENDIF
2824!
2825!--    Check for cross section or volume data
2826       ilen = LEN_TRIM( data_output(i) )
2827       k = 0                                                   ! 3d data
2828       var = data_output(i)(1:ilen)
2829       IF ( ilen > 3 )  THEN
2830          IF ( data_output(i)(ilen-2:ilen) == '_xy'  .OR. &
2831               data_output(i)(ilen-2:ilen) == '_xz'  .OR. &
2832               data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2833             k = 1                                             ! 2d data
2834             var = data_output(i)(1:ilen-3)
2835          ENDIF
2836       ENDIF
2837!
2838!--    Check for allowed value and set units
2839       SELECT CASE ( TRIM( var ) )
2840
2841          CASE ( 'e' )
2842             IF ( constant_diffusion )  THEN
2843                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2844                                 'res constant_diffusion = .FALSE.'
2845                CALL message( 'check_parameters', 'PA0103', 1, 2, 0, 6, 0 )
2846             ENDIF
2847             unit = 'm2/s2'
2848
2849          CASE ( 'lpt' )
2850             IF ( .NOT. cloud_physics )  THEN
2851                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2852                         'res cloud_physics = .TRUE.'
2853                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2854             ENDIF
2855             unit = 'K'
2856
2857          CASE ( 'nr' )
2858             IF ( .NOT. cloud_physics )  THEN
2859                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2860                         'res cloud_physics = .TRUE.'
2861                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2862             ELSEIF ( icloud_scheme /= 0 )  THEN
2863                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2864                         'res cloud_scheme = seifert_beheng'
2865                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2866             ENDIF
2867             unit = '1/m3'
2868
2869          CASE ( 'pc', 'pr' )
2870             IF ( .NOT. particle_advection )  THEN
2871                message_string = 'output of "' // TRIM( var ) // '" requir' // &
2872                   'es a "particles_par"-NAMELIST in the parameter file (PARIN)'
2873                CALL message( 'check_parameters', 'PA0104', 1, 2, 0, 6, 0 )
2874             ENDIF
2875             IF ( TRIM( var ) == 'pc' )  unit = 'number'
2876             IF ( TRIM( var ) == 'pr' )  unit = 'm'
2877
2878          CASE ( 'prr' )
2879             IF ( .NOT. cloud_physics )  THEN
2880                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2881                         'res cloud_physics = .TRUE.'
2882                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2883             ELSEIF ( icloud_scheme /= 0 )  THEN
2884                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2885                         'res cloud_scheme = seifert_beheng'
2886                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2887             ELSEIF ( .NOT. precipitation )  THEN
2888                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2889                                 'res precipitation = .TRUE.'
2890                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2891             ENDIF
2892             unit = 'kg/kg m/s'
2893
2894          CASE ( 'q', 'vpt' )
2895             IF ( .NOT. humidity )  THEN
2896                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2897                                 'res humidity = .TRUE.'
2898                CALL message( 'check_parameters', 'PA0105', 1, 2, 0, 6, 0 )
2899             ENDIF
2900             IF ( TRIM( var ) == 'q'   )  unit = 'kg/kg'
2901             IF ( TRIM( var ) == 'vpt' )  unit = 'K'
2902
2903          CASE ( 'qc' )
2904             IF ( .NOT. cloud_physics )  THEN
2905                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2906                         'res cloud_physics = .TRUE.'
2907                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2908             ELSEIF ( icloud_scheme /= 0 ) THEN
2909                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2910                         'res cloud_scheme = seifert_beheng'
2911                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2912             ENDIF
2913             unit = 'kg/kg'
2914
2915          CASE ( 'ql' )
2916             IF ( .NOT. ( cloud_physics  .OR.  cloud_droplets ) )  THEN
2917                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2918                         'res cloud_physics = .TRUE. or cloud_droplets = .TRUE.'
2919                CALL message( 'check_parameters', 'PA0106', 1, 2, 0, 6, 0 )
2920             ENDIF
2921             unit = 'kg/kg'
2922
2923          CASE ( 'ql_c', 'ql_v', 'ql_vp' )
2924             IF ( .NOT. cloud_droplets )  THEN
2925                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2926                                 'res cloud_droplets = .TRUE.'
2927                CALL message( 'check_parameters', 'PA0107', 1, 2, 0, 6, 0 )
2928             ENDIF
2929             IF ( TRIM( var ) == 'ql_c'  )  unit = 'kg/kg'
2930             IF ( TRIM( var ) == 'ql_v'  )  unit = 'm3'
2931             IF ( TRIM( var ) == 'ql_vp' )  unit = 'none'
2932
2933          CASE ( 'qr' )
2934             IF ( .NOT. cloud_physics )  THEN
2935                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2936                         'res cloud_physics = .TRUE.'
2937                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2938             ELSEIF ( icloud_scheme /= 0 ) THEN
2939                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2940                         'res cloud_scheme = seifert_beheng'
2941                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2942             ELSEIF ( .NOT. precipitation )  THEN
2943                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2944                                 'res precipitation = .TRUE.'
2945                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2946             ENDIF
2947             unit = 'kg/kg'
2948
2949          CASE ( 'qv' )
2950             IF ( .NOT. cloud_physics )  THEN
2951                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2952                                 'res cloud_physics = .TRUE.'
2953                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2954             ENDIF
2955             unit = 'kg/kg'
2956
2957          CASE ( 'rho' )
2958             IF ( .NOT. ocean )  THEN
2959                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2960                                 'res ocean = .TRUE.'
2961                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2962             ENDIF
2963             unit = 'kg/m3'
2964
2965          CASE ( 's' )
2966             IF ( .NOT. passive_scalar )  THEN
2967                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2968                                 'res passive_scalar = .TRUE.'
2969                CALL message( 'check_parameters', 'PA0110', 1, 2, 0, 6, 0 )
2970             ENDIF
2971             unit = 'conc'
2972
2973          CASE ( 'sa' )
2974             IF ( .NOT. ocean )  THEN
2975                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2976                                 'res ocean = .TRUE.'
2977                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2978             ENDIF
2979             unit = 'psu'
2980
2981          CASE ( 'u*', 't*', 'lwp*', 'pra*', 'prr*', 'qsws*', 'shf*', 'z0*', 'z0h*' )
2982             IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
2983                message_string = 'illegal value for data_output: "' // &
2984                                 TRIM( var ) // '" & only 2d-horizontal ' // &
2985                                 'cross sections are allowed for this value'
2986                CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
2987             ENDIF
2988             IF ( TRIM( var ) == 'lwp*'  .AND.  .NOT. cloud_physics )  THEN
2989                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2990                                 'res cloud_physics = .TRUE.'
2991                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2992             ENDIF
2993             IF ( TRIM( var ) == 'pra*'  .AND.  .NOT. precipitation )  THEN
2994                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2995                                 'res precipitation = .TRUE.'
2996                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2997             ENDIF
2998             IF ( TRIM( var ) == 'pra*'  .AND.  j == 1 )  THEN
2999                message_string = 'temporal averaging of precipitation ' // &
3000                          'amount "' // TRIM( var ) // '" is not possible'
3001                CALL message( 'check_parameters', 'PA0113', 1, 2, 0, 6, 0 )
3002             ENDIF
3003             IF ( TRIM( var ) == 'prr*'  .AND.  .NOT. precipitation )  THEN
3004                message_string = 'output of "' // TRIM( var ) // '" requi' // &
3005                                 'res precipitation = .TRUE.'
3006                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
3007             ENDIF
3008             IF ( TRIM( var ) == 'qsws*'  .AND.  .NOT. humidity )  THEN
3009                message_string = 'output of "' // TRIM( var ) // '" requi' // &
3010                                 'res humidity = .TRUE.'
3011                CALL message( 'check_parameters', 'PA0322', 1, 2, 0, 6, 0 )
3012             ENDIF
3013
3014             IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/kg*m'
3015             IF ( TRIM( var ) == 'pra*'   )  unit = 'mm'
3016             IF ( TRIM( var ) == 'prr*'   )  unit = 'mm/s'
3017             IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
3018             IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
3019             IF ( TRIM( var ) == 't*'     )  unit = 'K'
3020             IF ( TRIM( var ) == 'u*'     )  unit = 'm/s'
3021             IF ( TRIM( var ) == 'z0*'    )  unit = 'm'
3022             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm'
3023
3024
3025          CASE ( 'p', 'pt', 'u', 'v', 'w' )
3026             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
3027             IF ( TRIM( var ) == 'pt' )  unit = 'K'
3028             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
3029             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
3030             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
3031             CONTINUE
3032
3033          CASE DEFAULT
3034             CALL user_check_data_output( var, unit )
3035
3036             IF ( unit == 'illegal' )  THEN
3037                IF ( data_output_user(1) /= ' ' )  THEN
3038                   message_string = 'illegal value for data_output or ' // &
3039                         'data_output_user = "' // TRIM( data_output(i) ) // '"'
3040                   CALL message( 'check_parameters', 'PA0114', 1, 2, 0, 6, 0 )
3041                ELSE
3042                   message_string = 'illegal value for data_output =' // &
3043                                    TRIM( data_output(i) ) // '"'
3044                   CALL message( 'check_parameters', 'PA0115', 1, 2, 0, 6, 0 )
3045                ENDIF
3046             ENDIF
3047
3048       END SELECT
3049!
3050!--    Set the internal steering parameters appropriately
3051       IF ( k == 0 )  THEN
3052          do3d_no(j)              = do3d_no(j) + 1
3053          do3d(j,do3d_no(j))      = data_output(i)
3054          do3d_unit(j,do3d_no(j)) = unit
3055       ELSE
3056          do2d_no(j)              = do2d_no(j) + 1
3057          do2d(j,do2d_no(j))      = data_output(i)
3058          do2d_unit(j,do2d_no(j)) = unit
3059          IF ( data_output(i)(ilen-2:ilen) == '_xy' )  THEN
3060             data_output_xy(j) = .TRUE.
3061          ENDIF
3062          IF ( data_output(i)(ilen-2:ilen) == '_xz' )  THEN
3063             data_output_xz(j) = .TRUE.
3064          ENDIF
3065          IF ( data_output(i)(ilen-2:ilen) == '_yz' )  THEN
3066             data_output_yz(j) = .TRUE.
3067          ENDIF
3068       ENDIF
3069
3070       IF ( j == 1 )  THEN
3071!
3072!--       Check, if variable is already subject to averaging
3073          found = .FALSE.
3074          DO  k = 1, doav_n
3075             IF ( TRIM( doav(k) ) == TRIM( var ) )  found = .TRUE.
3076          ENDDO
3077
3078          IF ( .NOT. found )  THEN
3079             doav_n = doav_n + 1
3080             doav(doav_n) = var
3081          ENDIF
3082       ENDIF
3083
3084       i = i + 1
3085    ENDDO
3086
3087!
3088!-- Averaged 2d or 3d output requires that an averaging interval has been set
3089    IF ( doav_n > 0  .AND.  averaging_interval == 0.0 )  THEN
3090       WRITE( message_string, * )  'output of averaged quantity "',            &
3091                                   TRIM( doav(1) ), '_av" requires to set a ', &
3092                                   'non-zero & averaging interval'
3093       CALL message( 'check_parameters', 'PA0323', 1, 2, 0, 6, 0 )
3094    ENDIF
3095
3096!
3097!-- Check sectional planes and store them in one shared array
3098    IF ( ANY( section_xy > nz + 1 ) )  THEN
3099       WRITE( message_string, * )  'section_xy must be <= nz + 1 = ', nz + 1
3100       CALL message( 'check_parameters', 'PA0319', 1, 2, 0, 6, 0 )
3101    ENDIF
3102    IF ( ANY( section_xz > ny + 1 ) )  THEN
3103       WRITE( message_string, * )  'section_xz must be <= ny + 1 = ', ny + 1
3104       CALL message( 'check_parameters', 'PA0320', 1, 2, 0, 6, 0 )
3105    ENDIF
3106    IF ( ANY( section_yz > nx + 1 ) )  THEN
3107       WRITE( message_string, * )  'section_yz must be <= nx + 1 = ', nx + 1
3108       CALL message( 'check_parameters', 'PA0321', 1, 2, 0, 6, 0 )
3109    ENDIF
3110    section(:,1) = section_xy
3111    section(:,2) = section_xz
3112    section(:,3) = section_yz
3113
3114!
3115!-- Upper plot limit for 2D vertical sections
3116    IF ( z_max_do2d == -1.0 )  z_max_do2d = zu(nzt)
3117    IF ( z_max_do2d < zu(nzb+1)  .OR.  z_max_do2d > zu(nzt) )  THEN
3118       WRITE( message_string, * )  'z_max_do2d = ', z_max_do2d, &
3119                    ' must be >= ', zu(nzb+1), '(zu(nzb+1)) and <= ', zu(nzt), &
3120                    ' (zu(nzt))'
3121       CALL message( 'check_parameters', 'PA0116', 1, 2, 0, 6, 0 )
3122    ENDIF
3123
3124!
3125!-- Upper plot limit for 3D arrays
3126    IF ( nz_do3d == -9999 )  nz_do3d = nzt + 1
3127
3128!
3129!-- Determine and check accuracy for compressed 3D plot output
3130    IF ( do3d_compress )  THEN
3131!
3132!--    Compression only permissible on T3E machines
3133       IF ( host(1:3) /= 't3e' )  THEN
3134          message_string = 'do3d_compress = .TRUE. not allowed on host "' // &
3135                           TRIM( host ) // '"'
3136          CALL message( 'check_parameters', 'PA0117', 1, 2, 0, 6, 0 )
3137       ENDIF
3138
3139       i = 1
3140       DO  WHILE ( do3d_comp_prec(i) /= ' ' )
3141
3142          ilen = LEN_TRIM( do3d_comp_prec(i) )
3143          IF ( LLT( do3d_comp_prec(i)(ilen:ilen), '0' ) .OR. &
3144               LGT( do3d_comp_prec(i)(ilen:ilen), '9' ) )  THEN
3145             WRITE( message_string, * )  'illegal precision: do3d_comp_prec', &
3146                                   '(', i, ') = "', TRIM(do3d_comp_prec(i)),'"'
3147             CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
3148          ENDIF
3149
3150          prec = IACHAR( do3d_comp_prec(i)(ilen:ilen) ) - IACHAR( '0' )
3151          var = do3d_comp_prec(i)(1:ilen-1)
3152
3153          SELECT CASE ( var )
3154
3155             CASE ( 'u' )
3156                j = 1
3157             CASE ( 'v' )
3158                j = 2
3159             CASE ( 'w' )
3160                j = 3
3161             CASE ( 'p' )
3162                j = 4
3163             CASE ( 'pt' )
3164                j = 5
3165
3166             CASE DEFAULT
3167                WRITE( message_string, * )  'unknown variable "', &
3168                     TRIM( do3d_comp_prec(i) ), '" given for do3d_comp_prec(', &
3169                     i, ')'
3170                CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
3171
3172          END SELECT
3173
3174          plot_3d_precision(j)%precision = prec
3175          i = i + 1
3176
3177       ENDDO
3178    ENDIF
3179
3180!
3181!-- Check the data output format(s)
3182    IF ( data_output_format(1) == ' ' )  THEN
3183!
3184!--    Default value
3185       netcdf_output = .TRUE.
3186    ELSE
3187       i = 1
3188       DO  WHILE ( data_output_format(i) /= ' ' )
3189
3190          SELECT CASE ( data_output_format(i) )
3191
3192             CASE ( 'netcdf' )
3193                netcdf_output = .TRUE.
3194             CASE ( 'iso2d' )
3195                iso2d_output  = .TRUE.
3196             CASE ( 'avs' )
3197                avs_output    = .TRUE.
3198
3199             CASE DEFAULT
3200                message_string = 'unknown value for data_output_format "' // &
3201                                 TRIM( data_output_format(i) ) // '"'
3202                CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
3203
3204          END SELECT
3205
3206          i = i + 1
3207          IF ( i > 10 )  EXIT
3208
3209       ENDDO
3210    ENDIF
3211
3212!
3213!-- Set output format string (used in header)
3214    IF ( netcdf_output )  THEN
3215
3216       SELECT CASE ( netcdf_data_format )
3217          CASE ( 1 )
3218             output_format_netcdf = 'netCDF classic'
3219          CASE ( 2 )
3220             output_format_netcdf = 'netCDF 64bit offset'
3221          CASE ( 3 )
3222             output_format_netcdf = 'netCDF4/HDF5'
3223          CASE ( 4 )
3224             output_format_netcdf = 'netCDF4/HDF5 classic'
3225          CASE ( 5 )
3226             output_format_netcdf = 'parallel netCDF4/HDF5'
3227          CASE ( 6 )
3228             output_format_netcdf = 'parallel netCDF4/HDF5 classic'
3229
3230       END SELECT
3231
3232    ENDIF
3233
3234#if defined( __spectra )
3235!
3236!-- Check the number of spectra level to be output
3237    i = 1
3238    DO WHILE ( comp_spectra_level(i) /= 999999  .AND.  i <= 100 )
3239       i = i + 1
3240    ENDDO
3241    i = i - 1
3242    IF ( i == 0 )  THEN
3243       WRITE( message_string, * )  'no spectra levels given'
3244       CALL message( 'check_parameters', 'PA0019', 1, 2, 0, 6, 0 )
3245    ENDIF
3246#endif
3247
3248!
3249!-- Check mask conditions
3250    DO mid = 1, max_masks
3251       IF ( data_output_masks(mid,1) /= ' ' .OR.   &
3252            data_output_masks_user(mid,1) /= ' ' ) THEN
3253          masks = masks + 1
3254       ENDIF
3255    ENDDO
3256   
3257    IF ( masks < 0 .OR. masks > max_masks )  THEN
3258       WRITE( message_string, * )  'illegal value: masks must be >= 0 and ', &
3259            '<= ', max_masks, ' (=max_masks)'
3260       CALL message( 'check_parameters', 'PA0325', 1, 2, 0, 6, 0 )
3261    ENDIF
3262    IF ( masks > 0 )  THEN
3263       mask_scale(1) = mask_scale_x
3264       mask_scale(2) = mask_scale_y
3265       mask_scale(3) = mask_scale_z
3266       IF ( ANY( mask_scale <= 0.0 ) )  THEN
3267          WRITE( message_string, * )  &
3268               'illegal value: mask_scale_x, mask_scale_y and mask_scale_z', &
3269               'must be > 0.0'
3270          CALL message( 'check_parameters', 'PA0326', 1, 2, 0, 6, 0 )
3271       ENDIF
3272!
3273!--    Generate masks for masked data output
3274!--    Parallel netcdf output is not tested so far for masked data, hence
3275!--    netcdf_data_format is switched back to non-paralell output.
3276       netcdf_data_format_save = netcdf_data_format
3277       IF ( netcdf_data_format > 4 )  THEN
3278          IF ( netcdf_data_format == 5 ) netcdf_data_format = 3
3279          IF ( netcdf_data_format == 6 ) netcdf_data_format = 4
3280          message_string = 'netCDF file formats '//                            &
3281                           '5 (parallel netCDF 4) and ' //                     &
3282                           '6 (parallel netCDF 4 Classic model) '//            &
3283                           '&are currently not supported (not yet tested) ' // &
3284                           'for masked data.&Using respective non-parallel' // & 
3285                           ' output for masked data.'
3286          CALL message( 'check_parameters', 'PA0383', 0, 0, 0, 6, 0 )
3287       ENDIF
3288       CALL init_masks
3289       netcdf_data_format = netcdf_data_format_save
3290    ENDIF
3291
3292!
3293!-- Check the NetCDF data format
3294#if ! defined ( __check )
3295    IF ( netcdf_data_format > 2 )  THEN
3296#if defined( __netcdf4 )
3297       CONTINUE
3298#else
3299       message_string = 'netCDF: netCDF4 format requested but no ' // &
3300                        'cpp-directive __netcdf4 given & switch '  // &
3301                        'back to 64-bit offset format'
3302       CALL message( 'check_parameters', 'PA0171', 0, 1, 0, 6, 0 )
3303       netcdf_data_format = 2
3304#endif
3305    ENDIF
3306    IF ( netcdf_data_format > 4 )  THEN
3307#if defined( __netcdf4 ) && defined( __netcdf4_parallel )
3308       CONTINUE
3309#else
3310       message_string = 'netCDF: netCDF4 parallel output requested but no ' // &
3311                        'cpp-directive __netcdf4_parallel given & switch '  // &
3312                        'back to netCDF4 non-parallel output'
3313       CALL message( 'check_parameters', 'PA0099', 0, 1, 0, 6, 0 )
3314       netcdf_data_format = netcdf_data_format - 2
3315#endif
3316    ENDIF
3317#endif
3318
3319!
3320!-- Calculate fixed number of output time levels for parallel netcdf output.
3321!-- The time dimension has to be limited for paralell output, otherwise the
3322!-- performance drops significantly.
3323    IF ( netcdf_output )  THEN
3324       IF ( netcdf_data_format > 4 )  THEN
3325          ntdim_3d(0) = INT( ( end_time - skip_time_do3d ) / dt_do3d )
3326          IF ( do3d_at_begin ) ntdim_3d(0) = ntdim_3d(0) + 1
3327          ntdim_3d(1) = INT( ( end_time - skip_time_data_output_av ) &
3328                              / dt_data_output_av )
3329          ntdim_2d_xy(0) = INT( ( end_time - skip_time_do2d_xy ) / dt_do2d_xy )
3330          ntdim_2d_xz(0) = INT( ( end_time - skip_time_do2d_xz ) / dt_do2d_xz )
3331          ntdim_2d_yz(0) = INT( ( end_time - skip_time_do2d_yz ) / dt_do2d_yz )
3332          IF ( do2d_at_begin )  THEN
3333             ntdim_2d_xy(0) = ntdim_2d_xy(0) + 1
3334             ntdim_2d_xz(0) = ntdim_2d_xz(0) + 1
3335             ntdim_2d_yz(0) = ntdim_2d_yz(0) + 1
3336          ENDIF
3337          ntdim_2d_xy(1) = ntdim_3d(1)
3338          ntdim_2d_xz(1) = ntdim_3d(1)
3339          ntdim_2d_yz(1) = ntdim_3d(1)
3340       ENDIF
3341    ENDIF
3342
3343#if ! defined( __check )
3344!
3345!-- Check netcdf precison
3346    ldum = .FALSE.
3347    CALL define_netcdf_header( 'ch', ldum, 0 )
3348#endif
3349!
3350!-- Check, whether a constant diffusion coefficient shall be used
3351    IF ( km_constant /= -1.0 )  THEN
3352       IF ( km_constant < 0.0 )  THEN
3353          WRITE( message_string, * )  'km_constant = ', km_constant, ' < 0.0'
3354          CALL message( 'check_parameters', 'PA0121', 1, 2, 0, 6, 0 )
3355       ELSE
3356          IF ( prandtl_number < 0.0 )  THEN
3357             WRITE( message_string, * )  'prandtl_number = ', prandtl_number, &
3358                                         ' < 0.0'
3359             CALL message( 'check_parameters', 'PA0122', 1, 2, 0, 6, 0 )
3360          ENDIF
3361          constant_diffusion = .TRUE.
3362
3363          IF ( prandtl_layer )  THEN
3364             message_string = 'prandtl_layer is not allowed with fixed ' // &
3365                              'value of km'
3366             CALL message( 'check_parameters', 'PA0123', 1, 2, 0, 6, 0 )
3367          ENDIF
3368       ENDIF
3369    ENDIF
3370
3371!
3372!-- In case of non-cyclic lateral boundaries and a damping layer for the
3373!-- potential temperature, check the width of the damping layer
3374    IF ( bc_lr /= 'cyclic' ) THEN
3375       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( nx * dx ) )  THEN
3376          message_string = 'pt_damping_width out of range'
3377          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
3378       ENDIF
3379    ENDIF
3380
3381    IF ( bc_ns /= 'cyclic' )  THEN
3382       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( ny * dy ) )  THEN
3383          message_string = 'pt_damping_width out of range'
3384          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
3385       ENDIF
3386    ENDIF
3387
3388!
3389!-- Check value range for rif
3390    IF ( rif_min >= rif_max )  THEN
3391       WRITE( message_string, * )  'rif_min = ', rif_min, ' must be less ', &
3392                                   'than rif_max = ', rif_max
3393       CALL message( 'check_parameters', 'PA0125', 1, 2, 0, 6, 0 )
3394    ENDIF
3395
3396!
3397!-- Determine upper and lower hight level indices for random perturbations
3398    IF ( disturbance_level_b == -9999999.9 )  THEN
3399       IF ( ocean ) THEN
3400          disturbance_level_b     = zu((nzt*2)/3)
3401          disturbance_level_ind_b = ( nzt * 2 ) / 3
3402       ELSE
3403          disturbance_level_b     = zu(nzb+3)
3404          disturbance_level_ind_b = nzb + 3
3405       ENDIF
3406    ELSEIF ( disturbance_level_b < zu(3) )  THEN
3407       WRITE( message_string, * )  'disturbance_level_b = ', &
3408                           disturbance_level_b, ' must be >= ', zu(3), '(zu(3))'
3409       CALL message( 'check_parameters', 'PA0126', 1, 2, 0, 6, 0 )
3410    ELSEIF ( disturbance_level_b > zu(nzt-2) )  THEN
3411       WRITE( message_string, * )  'disturbance_level_b = ', &
3412                   disturbance_level_b, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
3413       CALL message( 'check_parameters', 'PA0127', 1, 2, 0, 6, 0 )
3414    ELSE
3415       DO  k = 3, nzt-2
3416          IF ( disturbance_level_b <= zu(k) )  THEN
3417             disturbance_level_ind_b = k
3418             EXIT
3419          ENDIF
3420       ENDDO
3421    ENDIF
3422
3423    IF ( disturbance_level_t == -9999999.9 )  THEN
3424       IF ( ocean )  THEN
3425          disturbance_level_t     = zu(nzt-3)
3426          disturbance_level_ind_t = nzt - 3
3427       ELSE
3428          disturbance_level_t     = zu(nzt/3)
3429          disturbance_level_ind_t = nzt / 3
3430       ENDIF
3431    ELSEIF ( disturbance_level_t > zu(nzt-2) )  THEN
3432       WRITE( message_string, * )  'disturbance_level_t = ', &
3433                   disturbance_level_t, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
3434       CALL message( 'check_parameters', 'PA0128', 1, 2, 0, 6, 0 )
3435    ELSEIF ( disturbance_level_t < disturbance_level_b )  THEN
3436       WRITE( message_string, * )  'disturbance_level_t = ', &
3437                   disturbance_level_t, ' must be >= disturbance_level_b = ', &
3438                   disturbance_level_b
3439       CALL message( 'check_parameters', 'PA0129', 1, 2, 0, 6, 0 )
3440    ELSE
3441       DO  k = 3, nzt-2
3442          IF ( disturbance_level_t <= zu(k) )  THEN
3443             disturbance_level_ind_t = k
3444             EXIT
3445          ENDIF
3446       ENDDO
3447    ENDIF
3448
3449!
3450!-- Check again whether the levels determined this way are ok.
3451!-- Error may occur at automatic determination and too few grid points in
3452!-- z-direction.
3453    IF ( disturbance_level_ind_t < disturbance_level_ind_b )  THEN
3454       WRITE( message_string, * )  'disturbance_level_ind_t = ', &
3455                disturbance_level_ind_t, ' must be >= disturbance_level_b = ', &
3456                disturbance_level_b
3457       CALL message( 'check_parameters', 'PA0130', 1, 2, 0, 6, 0 )
3458    ENDIF
3459
3460!
3461!-- Determine the horizontal index range for random perturbations.
3462!-- In case of non-cyclic horizontal boundaries, no perturbations are imposed
3463!-- near the inflow and the perturbation area is further limited to ...(1)
3464!-- after the initial phase of the flow.
3465    dist_nxl = 0;  dist_nxr = nx
3466    dist_nys = 0;  dist_nyn = ny
3467    IF ( bc_lr /= 'cyclic' )  THEN
3468       IF ( inflow_disturbance_begin == -1 )  THEN
3469          inflow_disturbance_begin = MIN( 10, nx/2 )
3470       ENDIF
3471       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > nx )&
3472       THEN
3473          message_string = 'inflow_disturbance_begin out of range'
3474          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3475       ENDIF
3476       IF ( inflow_disturbance_end == -1 )  THEN
3477          inflow_disturbance_end = MIN( 100, 3*nx/4 )
3478       ENDIF
3479       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > nx )    &
3480       THEN
3481          message_string = 'inflow_disturbance_end out of range'
3482          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3483       ENDIF
3484    ELSEIF ( bc_ns /= 'cyclic' )  THEN
3485       IF ( inflow_disturbance_begin == -1 )  THEN
3486          inflow_disturbance_begin = MIN( 10, ny/2 )
3487       ENDIF
3488       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > ny )&
3489       THEN
3490          message_string = 'inflow_disturbance_begin out of range'
3491          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3492       ENDIF
3493       IF ( inflow_disturbance_end == -1 )  THEN
3494          inflow_disturbance_end = MIN( 100, 3*ny/4 )
3495       ENDIF
3496       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > ny )    &
3497       THEN
3498          message_string = 'inflow_disturbance_end out of range'
3499          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3500       ENDIF
3501    ENDIF
3502
3503    IF ( bc_lr == 'radiation/dirichlet' )  THEN
3504       dist_nxr    = nx - inflow_disturbance_begin
3505       dist_nxl(1) = nx - inflow_disturbance_end
3506    ELSEIF ( bc_lr == 'dirichlet/radiation' )  THEN
3507       dist_nxl    = inflow_disturbance_begin
3508       dist_nxr(1) = inflow_disturbance_end
3509    ENDIF
3510    IF ( bc_ns == 'dirichlet/radiation' )  THEN
3511       dist_nyn    = ny - inflow_disturbance_begin
3512       dist_nys(1) = ny - inflow_disturbance_end
3513    ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
3514       dist_nys    = inflow_disturbance_begin
3515       dist_nyn(1) = inflow_disturbance_end
3516    ENDIF
3517
3518!
3519!-- A turbulent inflow requires Dirichlet conditions at the respective inflow
3520!-- boundary (so far, a turbulent inflow is realized from the left side only)
3521    IF ( turbulent_inflow  .AND.  bc_lr /= 'dirichlet/radiation' )  THEN
3522       message_string = 'turbulent_inflow = .T. requires a Dirichlet ' // &
3523                        'condition at the inflow boundary'
3524       CALL message( 'check_parameters', 'PA0133', 1, 2, 0, 6, 0 )
3525    ENDIF
3526
3527!
3528!-- Turbulent inflow requires that 3d arrays have been cyclically filled with
3529!-- data from prerun in the first main run
3530    IF ( turbulent_inflow  .AND.  initializing_actions /= 'cyclic_fill'  .AND. &
3531         initializing_actions /= 'read_restart_data' )  THEN
3532       message_string = 'turbulent_inflow = .T. requires ' // &
3533                        'initializing_actions = ''cyclic_fill'' '
3534       CALL message( 'check_parameters', 'PA0055', 1, 2, 0, 6, 0 )
3535    ENDIF
3536
3537!
3538!-- In case of turbulent inflow calculate the index of the recycling plane
3539    IF ( turbulent_inflow )  THEN
3540       IF ( recycling_width == 9999999.9 )  THEN
3541!
3542!--       Set the default value for the width of the recycling domain
3543          recycling_width = 0.1 * nx * dx
3544       ELSE
3545          IF ( recycling_width < dx  .OR.  recycling_width > nx * dx )  THEN
3546             WRITE( message_string, * )  'illegal value for recycling_width:', &
3547                                         ' ', recycling_width
3548             CALL message( 'check_parameters', 'PA0134', 1, 2, 0, 6, 0 )
3549          ENDIF
3550       ENDIF
3551!
3552!--    Calculate the index
3553       recycling_plane = recycling_width / dx
3554    ENDIF
3555
3556!
3557!-- Check random generator
3558    IF ( random_generator /= 'system-specific'  .AND. &
3559         random_generator /= 'numerical-recipes' )  THEN
3560       message_string = 'unknown random generator: random_generator = "' // &
3561                        TRIM( random_generator ) // '"'
3562       CALL message( 'check_parameters', 'PA0135', 1, 2, 0, 6, 0 )
3563    ENDIF
3564
3565!
3566!-- Determine damping level index for 1D model
3567    IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
3568       IF ( damp_level_1d == -1.0 )  THEN
3569          damp_level_1d     = zu(nzt+1)
3570          damp_level_ind_1d = nzt + 1
3571       ELSEIF ( damp_level_1d < 0.0  .OR.  damp_level_1d > zu(nzt+1) )  THEN
3572          WRITE( message_string, * )  'damp_level_1d = ', damp_level_1d, &
3573                 ' must be > 0.0 and < ', zu(nzt+1), '(zu(nzt+1))'
3574          CALL message( 'check_parameters', 'PA0136', 1, 2, 0, 6, 0 )
3575       ELSE
3576          DO  k = 1, nzt+1
3577             IF ( damp_level_1d <= zu(k) )  THEN
3578                damp_level_ind_1d = k
3579                EXIT
3580             ENDIF
3581          ENDDO
3582       ENDIF
3583    ENDIF
3584
3585!
3586!-- Check some other 1d-model parameters
3587    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND. &
3588         TRIM( mixing_length_1d ) /= 'blackadar' )  THEN
3589       message_string = 'mixing_length_1d = "' // TRIM( mixing_length_1d ) // &
3590                        '" is unknown'
3591       CALL message( 'check_parameters', 'PA0137', 1, 2, 0, 6, 0 )
3592    ENDIF
3593    IF ( TRIM( dissipation_1d ) /= 'as_in_3d_model'  .AND. &
3594         TRIM( dissipation_1d ) /= 'detering' )  THEN
3595       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) // &
3596                        '" is unknown'
3597       CALL message( 'check_parameters', 'PA0138', 1, 2, 0, 6, 0 )
3598    ENDIF
3599
3600!
3601!-- Set time for the next user defined restart (time_restart is the
3602!-- internal parameter for steering restart events)
3603    IF ( restart_time /= 9999999.9 )  THEN
3604       IF ( restart_time > time_since_reference_point )  THEN
3605          time_restart = restart_time
3606       ENDIF
3607    ELSE
3608!
3609!--    In case of a restart run, set internal parameter to default (no restart)
3610!--    if the NAMELIST-parameter restart_time is omitted
3611       time_restart = 9999999.9
3612    ENDIF
3613
3614!
3615!-- Set default value of the time needed to terminate a model run
3616    IF ( termination_time_needed == -1.0 )  THEN
3617       IF ( host(1:3) == 'ibm' )  THEN
3618          termination_time_needed = 300.0
3619       ELSE
3620          termination_time_needed = 35.0
3621       ENDIF
3622    ENDIF
3623
3624!
3625!-- Check the time needed to terminate a model run
3626    IF ( host(1:3) == 't3e' )  THEN
3627!
3628!--    Time needed must be at least 30 seconds on all CRAY machines, because
3629!--    MPP_TREMAIN gives the remaining CPU time only in steps of 30 seconds
3630       IF ( termination_time_needed <= 30.0 )  THEN
3631          WRITE( message_string, * )  'termination_time_needed = ', &
3632                 termination_time_needed, ' must be > 30.0 on host "', &
3633                 TRIM( host ), '"'
3634          CALL message( 'check_parameters', 'PA0139', 1, 2, 0, 6, 0 )
3635       ENDIF
3636    ELSEIF ( host(1:3) == 'ibm' )  THEN
3637!
3638!--    On IBM-regatta machines the time should be at least 300 seconds,
3639!--    because the job time consumed before executing palm (for compiling,
3640!--    copying of files, etc.) has to be regarded
3641       IF ( termination_time_needed < 300.0 )  THEN
3642          WRITE( message_string, * )  'termination_time_needed = ', &
3643                 termination_time_needed, ' should be >= 300.0 on host "', &
3644                 TRIM( host ), '"'
3645          CALL message( 'check_parameters', 'PA0140', 1, 2, 0, 6, 0 )
3646       ENDIF
3647    ENDIF
3648
3649!
3650!-- Check pressure gradient conditions
3651    IF ( dp_external .AND. conserve_volume_flow )  THEN
3652       WRITE( message_string, * )  'Both dp_external and conserve_volume_flo', &
3653            'w are .TRUE. but one of them must be .FALSE.'
3654       CALL message( 'check_parameters', 'PA0150', 1, 2, 0, 6, 0 )
3655    ENDIF
3656    IF ( dp_external )  THEN
3657       IF ( dp_level_b < zu(nzb) .OR. dp_level_b > zu(nzt) )  THEN
3658          WRITE( message_string, * )  'dp_level_b = ', dp_level_b, ' is out ', &
3659               ' of range'
3660          CALL message( 'check_parameters', 'PA0151', 1, 2, 0, 6, 0 )
3661       ENDIF
3662       IF ( .NOT. ANY( dpdxy /= 0.0 ) )  THEN
3663          WRITE( message_string, * )  'dp_external is .TRUE. but dpdxy is ze', &
3664               'ro, i.e. the external pressure gradient & will not be applied'
3665          CALL message( 'check_parameters', 'PA0152', 0, 1, 0, 6, 0 )
3666       ENDIF
3667    ENDIF
3668    IF ( ANY( dpdxy /= 0.0 ) .AND. .NOT. dp_external )  THEN
3669       WRITE( message_string, * )  'dpdxy is nonzero but dp_external is ', &
3670            '.FALSE., i.e. the external pressure gradient & will not be applied'
3671       CALL message( 'check_parameters', 'PA0153', 0, 1, 0, 6, 0 )
3672    ENDIF
3673    IF ( conserve_volume_flow )  THEN
3674       IF ( TRIM( conserve_volume_flow_mode ) == 'default' )  THEN
3675
3676          conserve_volume_flow_mode = 'initial_profiles'
3677
3678       ELSEIF ( TRIM( conserve_volume_flow_mode ) /= 'initial_profiles' .AND.  &
3679            TRIM( conserve_volume_flow_mode ) /= 'inflow_profile' .AND.  &
3680            TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' )  THEN
3681          WRITE( message_string, * )  'unknown conserve_volume_flow_mode: ', &
3682               conserve_volume_flow_mode
3683          CALL message( 'check_parameters', 'PA0154', 1, 2, 0, 6, 0 )
3684       ENDIF
3685       IF ( (bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic')  .AND. &
3686          TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
3687          WRITE( message_string, * )  'non-cyclic boundary conditions ', &
3688               'require  conserve_volume_flow_mode = ''initial_profiles'''
3689          CALL message( 'check_parameters', 'PA0155', 1, 2, 0, 6, 0 )
3690       ENDIF
3691       IF ( bc_lr == 'cyclic'  .AND.  bc_ns == 'cyclic'  .AND.  &
3692            TRIM( conserve_volume_flow_mode ) == 'inflow_profile' )  THEN
3693          WRITE( message_string, * )  'cyclic boundary conditions ', &
3694               'require conserve_volume_flow_mode = ''initial_profiles''', &
3695               ' or ''bulk_velocity'''
3696          CALL message( 'check_parameters', 'PA0156', 1, 2, 0, 6, 0 )
3697       ENDIF
3698    ENDIF
3699    IF ( ( u_bulk /= 0.0 .OR. v_bulk /= 0.0 ) .AND.  &
3700         ( .NOT. conserve_volume_flow .OR.  &
3701         TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' ) )  THEN
3702       WRITE( message_string, * )  'nonzero bulk velocity requires ', &
3703            'conserve_volume_flow = .T. and ', &
3704            'conserve_volume_flow_mode = ''bulk_velocity'''
3705       CALL message( 'check_parameters', 'PA0157', 1, 2, 0, 6, 0 )
3706    ENDIF
3707
3708!
3709!-- Check particle attributes
3710    IF ( particle_color /= 'none' )  THEN
3711       IF ( particle_color /= 'absuv'  .AND.  particle_color /= 'pt*'  .AND.  &
3712            particle_color /= 'z' )  THEN
3713          message_string = 'illegal value for parameter particle_color: ' // &
3714                           TRIM( particle_color)
3715          CALL message( 'check_parameters', 'PA0313', 1, 2, 0, 6, 0 )
3716       ELSE
3717          IF ( color_interval(2) <= color_interval(1) )  THEN
3718             message_string = 'color_interval(2) <= color_interval(1)'
3719             CALL message( 'check_parameters', 'PA0315', 1, 2, 0, 6, 0 )
3720          ENDIF
3721       ENDIF
3722    ENDIF
3723
3724    IF ( particle_dvrpsize /= 'none' )  THEN
3725       IF ( particle_dvrpsize /= 'absw' )  THEN
3726          message_string = 'illegal value for parameter particle_dvrpsize:' // &
3727                           ' ' // TRIM( particle_color)
3728          CALL message( 'check_parameters', 'PA0314', 1, 2, 0, 6, 0 )
3729       ELSE
3730          IF ( dvrpsize_interval(2) <= dvrpsize_interval(1) )  THEN
3731             message_string = 'dvrpsize_interval(2) <= dvrpsize_interval(1)'
3732             CALL message( 'check_parameters', 'PA0316', 1, 2, 0, 6, 0 )
3733          ENDIF
3734       ENDIF
3735    ENDIF
3736
3737!
3738!-- Check nudging and large scale forcing from external file
3739    IF ( nudging .AND. ( .NOT. large_scale_forcing ) )  THEN
3740       message_string = 'Nudging requires large_scale_forcing = .T.. &'// &
3741                        'Surface fluxes and geostrophic wind should be &'// &
3742                        'prescribed in file LSF_DATA'
3743       CALL message( 'check_parameters', 'PA0374', 1, 2, 0, 6, 0 )
3744    ENDIF
3745
3746    IF ( large_scale_forcing .AND. ( bc_lr /= 'cyclic'  .OR. &
3747                                    bc_ns /= 'cyclic' ) )  THEN
3748       message_string = 'Non-cyclic lateral boundaries do not allow for &' // &
3749                        'the usage of large scale forcing from external file.'
3750       CALL message( 'check_parameters', 'PA0375', 1, 2, 0, 6, 0 )
3751     ENDIF
3752
3753    IF ( large_scale_forcing .AND. ( .NOT. humidity ) )  THEN
3754       message_string = 'The usage of large scale forcing from external &'//& 
3755                        'file LSF_DATA requires humidity = .T..'
3756       CALL message( 'check_parameters', 'PA0376', 1, 2, 0, 6, 0 )
3757     ENDIF
3758
3759    IF ( large_scale_forcing .AND. topography /= 'flat' )  THEN
3760       message_string = 'The usage of large scale forcing from external &'//& 
3761                        'file LSF_DATA is not implemented for non-flat topography'
3762       CALL message( 'check_parameters', 'PA0377', 1, 2, 0, 6, 0 )
3763    ENDIF
3764
3765    IF ( large_scale_forcing .AND.  ocean  )  THEN
3766       message_string = 'The usage of large scale forcing from external &'//& 
3767                        'file LSF_DATA is not implemented for ocean runs'
3768       CALL message( 'check_parameters', 'PA0378', 1, 2, 0, 6, 0 )
3769    ENDIF
3770!
3771!-- Check &userpar parameters
3772    CALL user_check_parameters
3773
3774
3775
3776 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.