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

Last change on this file since 1003 was 1003, checked in by raasch, 12 years ago

subdomains must have identical size, i.e. grid_matching = "match" not allowed any more
parameter grid_matching removed
some obsolete variables removed

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