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

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

last commit documented

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