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

Last change on this file since 592 was 581, checked in by heinze, 13 years ago

last commit documented

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