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

Last change on this file since 674 was 674, checked in by suehring, 13 years ago

last commit documented

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