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

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

temperature equation can be switched off; bugfix of tridia_1dd for current Intel (12.1) compilers

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