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

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

Bugifx: Replaced == by .EQ. in logical expressions

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