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

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

New:
---

droplet growth by condensation may include curvature and solution effects.
Steered by new inipar-parameter curvature_solution_effects.
(advec_particles, check_parameters, header, init_cloud_physics, init_particles, modules, parin, read_var_list, write_var_list)

mean/min/max particle radius added as output quantity. (data_output_ptseries, modules)

Changed:


Initialisation of temporary particle array for resorting removed.
(advec_particles)

particle attributes speed_x|y|z_sgs renamed rvar1|2|3.
(advec_particles, data_output_ptseries, modules, init_particles, particle_boundary_conds)

routine wang_kernel and respective module renamed lpm_collision_kernels.
Package (particle) parameters wang_collision_kernel and turbulence_effects_on_collision
replaced by parameter collision_kernel.
(Makefile, advec_particles, check_parameters, diffusion_e, init_3d_model, modules, package_parin, time_integration, new: lpm_collision_kernels, deleted: wang_kernel)

Errors:


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