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

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

last commit documented

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