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

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

message string

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