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

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

last commit documented

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