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

Last change on this file since 565 was 565, checked in by helmke, 14 years ago

last commit documented

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