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

Last change on this file since 601 was 601, checked in by raasch, 13 years ago

last commit documented

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