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

Last change on this file since 965 was 965, checked in by raasch, 12 years ago

last commit documented

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