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

Last change on this file since 554 was 554, checked in by weinreis, 14 years ago

last commit documented

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