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

Last change on this file since 550 was 532, checked in by heinze, 14 years ago

NCL scripts allow the output of png files

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