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

Last change on this file since 698 was 690, checked in by gryschka, 13 years ago

last commit documented

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