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

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