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

Last change on this file since 421 was 411, checked in by heinze, 14 years ago

Large scale vertical motion (subsidence/ascent) can be applied to the prognostic equation for the potential temperature

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