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

Last change on this file since 482 was 449, checked in by raasch, 14 years ago

branch revision comments from Marcus (rev 410) replaced by normal revision comments

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