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

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

revisions r1031 and r1034 documented

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