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

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

New:
---

In case of multigrid method, on coarse grid levels, gathered data are
identically processed on all PEs (before, on PE0 only), so that the subsequent
scattering of data is not neccessary any more. (modules, init_pegrid, poismg)

Changed:


Calculation of weighted average of p is now handled in the same way
regardless of the number of ghost layers (advection scheme). (pres)

multigrid and sor method are using p_loc for iterative
advancements of pressure. p_sub removed. (init_3d_model, modules, poismg, pres, sor)

bc_lr and bc_ns replaced by bc_lr_dirrad, bc_lr_raddir, bc_ns_dirrad, bc_ns_raddir
for speed optimization. (calc_spectra, check_parameters, exchange_horiz,
exchange_horiz_2d, header, init_3d_model, init_grid, init_pegrid, modules,
poismg, pres, sor, time_integration, timestep)

grid_level directly used as index for MPI data type arrays. (exchange_horiz,
poismg)

initial assignments of zero to array p for iterative solvers only (init_3d_model)

Errors:


localsum calculation modified for proper OpenMP reduction. (pres)

Bugfix: bottom (nzb) and top (nzt+1) boundary conditions set in routines
resid and restrict. They were missed before, which may have led to
unpredictable results. (poismg)

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