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

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

leapfrog timestep scheme and upstream-spline advection scheme completely removed from the code,
reading of dt_fixed from restart file removed

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