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

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

New:
---

Changed:


Optimization of collision kernels. Collision tables can be calculated once at
simulation start for defined radius (and dissipation) classes instead of
re-calculating them at every timestep and for the particle ensemble in
every gridbox.
For this purpose the particle feature color is renamed class.
New parpar parameters radius_classes and dissipation_classes.
(Makefile, advec_particles, check_parameters, data_output_dvrp, header, init_particles, lpm_collision_kernels, modules, package_parin, set_particle_attributes)

Lower limit for droplet radius changed from 1E-7 to 1E-8.
(advec_particles)

Complete re-formatting of collision code (including changes in names of
variables, modules and subroutines).
(advec_particles, lpm_collision_kernels)

Errors:


Bugfix: transformation factor for dissipation changed from 1E5 to 1E4
(advec_particles, lpm_collision_kernels)

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