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

Last change on this file since 978 was 978, checked in by fricke, 12 years ago

merge fricke branch back into trunk

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