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

Last change on this file since 523 was 494, checked in by raasch, 14 years ago

last commit documented; configuration example file for netcdf4 added

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