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

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

last commit documented

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