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

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

last commit documented

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