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

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

last commit documented

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