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

Last change on this file since 1307 was 1300, checked in by heinze, 10 years ago

last commit documented

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