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

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

subroutine prognostic_equations_noopt has been removed

  • Property svn:keywords set to Id
File size: 127.0 KB
Line 
1 SUBROUTINE check_parameters
2
3!------------------------------------------------------------------------------!
4! Current revisions:
5! -----------------
6! non-optimized version of prognostic_equations not allowed any more
7!
8! Former revisions:
9! -----------------
10! $Id: check_parameters.f90 1019 2012-09-28 06:46:45Z 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', '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    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' ) &
649    THEN
650       message_string = 'unknown advection scheme: momentum_advec = "' // &
651                        TRIM( momentum_advec ) // '"'
652       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
653    ENDIF
654    IF ( ( momentum_advec == 'ws-scheme' .OR.  scalar_advec == 'ws-scheme' )   &
655           .AND. ( timestep_scheme == 'euler' .OR.                             &
656                   timestep_scheme == 'runge-kutta-2' ) )                      &
657    THEN
658       message_string = 'momentum_advec or scalar_advec = "' &
659         // TRIM( momentum_advec ) // '" is not allowed with timestep_scheme = "' // &
660         TRIM( timestep_scheme ) // '"'
661       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
662    ENDIF
663    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' .AND. &
664         scalar_advec /= 'bc-scheme' )                                         &
665    THEN
666       message_string = 'unknown advection scheme: scalar_advec = "' // &
667                        TRIM( scalar_advec ) // '"'
668       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
669    ENDIF
670    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' ) &
671    THEN
672       message_string = 'advection_scheme scalar_advec = "' &
673         // TRIM( scalar_advec ) // '" not implemented for & loop_optimization = "' // &
674         TRIM( loop_optimization ) // '"'
675       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
676    ENDIF
677
678    IF ( use_sgs_for_particles  .AND.  .NOT. use_upstream_for_tke )  THEN
679       use_upstream_for_tke = .TRUE.
680       message_string = 'use_upstream_for_tke set .TRUE. because ' // &
681                        'use_sgs_for_particles = .TRUE.'
682       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
683    ENDIF
684
685    IF ( use_sgs_for_particles  .AND.  curvature_solution_effects )  THEN
686       message_string = 'use_sgs_for_particles = .TRUE. not allowed with ' // &
687                        'curvature_solution_effects = .TRUE.'
688       CALL message( 'check_parameters', 'PA0349', 1, 2, 0, 6, 0 )
689    ENDIF
690
691!
692!-- Set LOGICAL switches to enhance performance
693    IF ( momentum_advec == 'ws-scheme' )    ws_scheme_mom = .TRUE.
694    IF ( scalar_advec   == 'ws-scheme'   )  ws_scheme_sca = .TRUE.
695
696!
697!-- Timestep schemes:
698    SELECT CASE ( TRIM( timestep_scheme ) )
699
700       CASE ( 'euler' )
701          intermediate_timestep_count_max = 1
702
703       CASE ( 'runge-kutta-2' )
704          intermediate_timestep_count_max = 2
705
706       CASE ( 'runge-kutta-3' )
707          intermediate_timestep_count_max = 3
708
709       CASE DEFAULT
710          message_string = 'unknown timestep scheme: timestep_scheme = "' // &
711                           TRIM( timestep_scheme ) // '"'
712          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
713
714    END SELECT
715
716    IF ( (momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme') &
717         .AND. timestep_scheme(1:5) == 'runge' ) THEN
718       message_string = 'momentum advection scheme "' // &
719                        TRIM( momentum_advec ) // '" & does not work with ' // &
720                        'timestep_scheme "' // TRIM( timestep_scheme ) // '"'
721       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
722    ENDIF
723
724!
725!-- Collision kernels:
726    SELECT CASE ( TRIM( collision_kernel ) )
727
728       CASE ( 'hall', 'hall_fast' )
729          hall_kernel = .TRUE.
730
731       CASE ( 'palm' )
732          palm_kernel = .TRUE.
733
734       CASE ( 'wang', 'wang_fast' )
735          wang_kernel = .TRUE.
736
737       CASE ( 'none' )
738
739
740       CASE DEFAULT
741          message_string = 'unknown collision kernel: collision_kernel = "' // &
742                           TRIM( collision_kernel ) // '"'
743          CALL message( 'check_parameters', 'PA0350', 1, 2, 0, 6, 0 )
744
745    END SELECT
746    IF ( collision_kernel(6:9) == 'fast' )  use_kernel_tables = .TRUE.
747
748    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.  &
749         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
750!
751!--    No restart run: several initialising actions are possible
752       action = initializing_actions
753       DO WHILE ( TRIM( action ) /= '' )
754          position = INDEX( action, ' ' )
755          SELECT CASE ( action(1:position-1) )
756
757             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', &
758                    'by_user', 'initialize_vortex',     'initialize_ptanom' )
759                action = action(position+1:)
760
761             CASE DEFAULT
762                message_string = 'initializing_action = "' // &
763                                 TRIM( action ) // '" unkown or not allowed'
764                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
765
766          END SELECT
767       ENDDO
768    ENDIF
769
770    IF ( TRIM( initializing_actions ) == 'initialize_vortex' .AND. &
771         conserve_volume_flow ) THEN
772         message_string = 'initializing_actions = "initialize_vortex"' // &
773                        ' ist not allowed with conserve_volume_flow = .T.'
774       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
775    ENDIF       
776
777
778    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
779         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
780       message_string = 'initializing_actions = "set_constant_profiles"' // &
781                        ' and "set_1d-model_profiles" are not allowed ' //  &
782                        'simultaneously'
783       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
784    ENDIF
785
786    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
787         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
788       message_string = 'initializing_actions = "set_constant_profiles"' // &
789                        ' and "by_user" are not allowed simultaneously'
790       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
791    ENDIF
792
793    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND. &
794         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
795       message_string = 'initializing_actions = "by_user" and ' // &
796                        '"set_1d-model_profiles" are not allowed simultaneously'
797       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
798    ENDIF
799
800    IF ( cloud_physics  .AND.  .NOT. humidity )  THEN
801       WRITE( message_string, * ) 'cloud_physics = ', cloud_physics, ' is ', &
802              'not allowed with humidity = ', humidity
803       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
804    ENDIF
805
806    IF ( precipitation  .AND.  .NOT.  cloud_physics )  THEN
807       WRITE( message_string, * ) 'precipitation = ', precipitation, ' is ', &
808              'not allowed with cloud_physics = ', cloud_physics
809       CALL message( 'check_parameters', 'PA0035', 1, 2, 0, 6, 0 )
810    ENDIF
811
812    IF ( humidity  .AND.  sloping_surface )  THEN
813       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' // &
814                        'are not allowed simultaneously'
815       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
816    ENDIF
817
818    IF ( passive_scalar  .AND.  humidity )  THEN
819       message_string = 'humidity = .TRUE. and passive_scalar = .TRUE. ' // &
820                        'is not allowed simultaneously'
821       CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
822    ENDIF
823
824    IF ( plant_canopy .AND. ( drag_coefficient == 0.0 ) ) THEN
825       message_string = 'plant_canopy = .TRUE. requires a non-zero drag ' // &
826                        'coefficient & given value is drag_coefficient = 0.0'
827       CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
828    ENDIF 
829
830!
831!-- In case of no model continuation run, check initialising parameters and
832!-- deduce further quantities
833    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
834
835!
836!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
837       pt_init = pt_surface
838       IF ( humidity )        q_init  = q_surface
839       IF ( ocean )           sa_init = sa_surface
840       IF ( passive_scalar )  q_init  = s_surface
841       IF ( plant_canopy )    lad = 0.0
842
843!
844!--
845!--    If required, compute initial profile of the geostrophic wind
846!--    (component ug)
847       i = 1
848       gradient = 0.0
849
850       IF ( .NOT. ocean )  THEN
851
852          ug_vertical_gradient_level_ind(1) = 0
853          ug(0) = ug_surface
854          DO  k = 1, nzt+1
855             IF ( i < 11 ) THEN
856                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND. &
857                     ug_vertical_gradient_level(i) >= 0.0 )  THEN
858                   gradient = ug_vertical_gradient(i) / 100.0
859                   ug_vertical_gradient_level_ind(i) = k - 1
860                   i = i + 1
861                ENDIF
862             ENDIF       
863             IF ( gradient /= 0.0 )  THEN
864                IF ( k /= 1 )  THEN
865                   ug(k) = ug(k-1) + dzu(k) * gradient
866                ELSE
867                   ug(k) = ug_surface + 0.5 * dzu(k) * gradient
868                ENDIF
869             ELSE
870                ug(k) = ug(k-1)
871             ENDIF
872          ENDDO
873
874       ELSE
875
876          ug_vertical_gradient_level_ind(1) = nzt+1
877          ug(nzt+1) = ug_surface
878          DO  k = nzt, nzb, -1
879             IF ( i < 11 ) THEN
880                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND. &
881                     ug_vertical_gradient_level(i) <= 0.0 )  THEN
882                   gradient = ug_vertical_gradient(i) / 100.0
883                   ug_vertical_gradient_level_ind(i) = k + 1
884                   i = i + 1
885                ENDIF
886             ENDIF
887             IF ( gradient /= 0.0 )  THEN
888                IF ( k /= nzt )  THEN
889                   ug(k) = ug(k+1) - dzu(k+1) * gradient
890                ELSE
891                   ug(k)   = ug_surface - 0.5 * dzu(k+1) * gradient
892                   ug(k+1) = ug_surface + 0.5 * dzu(k+1) * gradient
893                ENDIF
894             ELSE
895                ug(k) = ug(k+1)
896             ENDIF
897          ENDDO
898
899       ENDIF
900
901!
902!--    In case of no given gradients for ug, choose a zero gradient
903       IF ( ug_vertical_gradient_level(1) == -9999999.9 )  THEN
904          ug_vertical_gradient_level(1) = 0.0
905       ENDIF 
906
907!
908!--
909!--    If required, compute initial profile of the geostrophic wind
910!--    (component vg)
911       i = 1
912       gradient = 0.0
913
914       IF ( .NOT. ocean )  THEN
915
916          vg_vertical_gradient_level_ind(1) = 0
917          vg(0) = vg_surface
918          DO  k = 1, nzt+1
919             IF ( i < 11 ) THEN
920                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND. &
921                     vg_vertical_gradient_level(i) >= 0.0 )  THEN
922                   gradient = vg_vertical_gradient(i) / 100.0
923                   vg_vertical_gradient_level_ind(i) = k - 1
924                   i = i + 1
925                ENDIF
926             ENDIF
927             IF ( gradient /= 0.0 )  THEN
928                IF ( k /= 1 )  THEN
929                   vg(k) = vg(k-1) + dzu(k) * gradient
930                ELSE
931                   vg(k) = vg_surface + 0.5 * dzu(k) * gradient
932                ENDIF
933             ELSE
934                vg(k) = vg(k-1)
935             ENDIF
936          ENDDO
937
938       ELSE
939
940          vg_vertical_gradient_level_ind(1) = nzt+1
941          vg(nzt+1) = vg_surface
942          DO  k = nzt, nzb, -1
943             IF ( i < 11 ) THEN
944                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND. &
945                     vg_vertical_gradient_level(i) <= 0.0 )  THEN
946                   gradient = vg_vertical_gradient(i) / 100.0
947                   vg_vertical_gradient_level_ind(i) = k + 1
948                   i = i + 1
949                ENDIF
950             ENDIF
951             IF ( gradient /= 0.0 )  THEN
952                IF ( k /= nzt )  THEN
953                   vg(k) = vg(k+1) - dzu(k+1) * gradient
954                ELSE
955                   vg(k)   = vg_surface - 0.5 * dzu(k+1) * gradient
956                   vg(k+1) = vg_surface + 0.5 * dzu(k+1) * gradient
957                ENDIF
958             ELSE
959                vg(k) = vg(k+1)
960             ENDIF
961          ENDDO
962
963       ENDIF
964
965!
966!--    In case of no given gradients for vg, choose a zero gradient
967       IF ( vg_vertical_gradient_level(1) == -9999999.9 )  THEN
968          vg_vertical_gradient_level(1) = 0.0
969       ENDIF
970
971!
972!--    Let the initial wind profiles be the calculated ug/vg profiles or
973!--    interpolate them from wind profile data (if given)
974       IF ( u_profile(1) == 9999999.9  .AND.  v_profile(1) == 9999999.9 )  THEN
975
976          u_init = ug
977          v_init = vg
978
979       ELSEIF ( u_profile(1) == 0.0  .AND.  v_profile(1) == 0.0 )  THEN
980
981          IF ( uv_heights(1) /= 0.0 )  THEN
982             message_string = 'uv_heights(1) must be 0.0'
983             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
984          ENDIF
985
986          use_prescribed_profile_data = .TRUE.
987
988          kk = 1
989          u_init(0) = 0.0
990          v_init(0) = 0.0
991
992          DO  k = 1, nz+1
993
994             IF ( kk < 100 )  THEN
995                DO WHILE ( uv_heights(kk+1) <= zu(k) )
996                   kk = kk + 1
997                   IF ( kk == 100 )  EXIT
998                ENDDO
999             ENDIF
1000
1001             IF ( kk < 100 .AND. uv_heights(kk+1) /= 9999999.9 )  THEN
1002                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1003                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1004                                       ( u_profile(kk+1) - u_profile(kk) )
1005                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1006                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1007                                       ( v_profile(kk+1) - v_profile(kk) )
1008             ELSE
1009                u_init(k) = u_profile(kk)
1010                v_init(k) = v_profile(kk)
1011             ENDIF
1012
1013          ENDDO
1014
1015       ELSE
1016
1017          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1018          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1019
1020       ENDIF
1021
1022!
1023!--    Compute initial temperature profile using the given temperature gradients
1024       IF ( .NOT. neutral )  THEN
1025
1026          i = 1
1027          gradient = 0.0
1028
1029          IF ( .NOT. ocean )  THEN
1030
1031             pt_vertical_gradient_level_ind(1) = 0
1032             DO  k = 1, nzt+1
1033                IF ( i < 11 ) THEN
1034                   IF ( pt_vertical_gradient_level(i) < zu(k)  .AND. &
1035                        pt_vertical_gradient_level(i) >= 0.0 )  THEN
1036                      gradient = pt_vertical_gradient(i) / 100.0
1037                      pt_vertical_gradient_level_ind(i) = k - 1
1038                      i = i + 1
1039                   ENDIF
1040                ENDIF
1041                IF ( gradient /= 0.0 )  THEN
1042                   IF ( k /= 1 )  THEN
1043                      pt_init(k) = pt_init(k-1) + dzu(k) * gradient
1044                   ELSE
1045                      pt_init(k) = pt_surface   + 0.5 * dzu(k) * gradient
1046                   ENDIF
1047                ELSE
1048                   pt_init(k) = pt_init(k-1)
1049                ENDIF
1050             ENDDO
1051
1052          ELSE
1053
1054             pt_vertical_gradient_level_ind(1) = nzt+1
1055             DO  k = nzt, 0, -1
1056                IF ( i < 11 ) THEN
1057                   IF ( pt_vertical_gradient_level(i) > zu(k)  .AND. &
1058                        pt_vertical_gradient_level(i) <= 0.0 )  THEN
1059                      gradient = pt_vertical_gradient(i) / 100.0
1060                      pt_vertical_gradient_level_ind(i) = k + 1
1061                      i = i + 1
1062                   ENDIF
1063                ENDIF
1064                IF ( gradient /= 0.0 )  THEN
1065                   IF ( k /= nzt )  THEN
1066                      pt_init(k) = pt_init(k+1) - dzu(k+1) * gradient
1067                   ELSE
1068                      pt_init(k)   = pt_surface - 0.5 * dzu(k+1) * gradient
1069                      pt_init(k+1) = pt_surface + 0.5 * dzu(k+1) * gradient
1070                   ENDIF
1071                ELSE
1072                   pt_init(k) = pt_init(k+1)
1073                ENDIF
1074             ENDDO
1075
1076          ENDIF
1077
1078       ENDIF
1079
1080!
1081!--    In case of no given temperature gradients, choose gradient of neutral
1082!--    stratification
1083       IF ( pt_vertical_gradient_level(1) == -9999999.9 )  THEN
1084          pt_vertical_gradient_level(1) = 0.0
1085       ENDIF
1086
1087!
1088!--    Store temperature gradient at the top boundary for possible Neumann
1089!--    boundary condition
1090       bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1)
1091
1092!
1093!--    If required, compute initial humidity or scalar profile using the given
1094!--    humidity/scalar gradient. In case of scalar transport, initially store
1095!--    values of the scalar parameters on humidity parameters
1096       IF ( passive_scalar )  THEN
1097          bc_q_b                    = bc_s_b
1098          bc_q_t                    = bc_s_t
1099          q_surface                 = s_surface
1100          q_surface_initial_change  = s_surface_initial_change
1101          q_vertical_gradient       = s_vertical_gradient
1102          q_vertical_gradient_level = s_vertical_gradient_level
1103          surface_waterflux         = surface_scalarflux
1104          wall_humidityflux         = wall_scalarflux
1105       ENDIF
1106
1107       IF ( humidity  .OR.  passive_scalar )  THEN
1108
1109          i = 1
1110          gradient = 0.0
1111          q_vertical_gradient_level_ind(1) = 0
1112          DO  k = 1, nzt+1
1113             IF ( i < 11 ) THEN
1114                IF ( q_vertical_gradient_level(i) < zu(k)  .AND. &
1115                     q_vertical_gradient_level(i) >= 0.0 )  THEN
1116                   gradient = q_vertical_gradient(i) / 100.0
1117                   q_vertical_gradient_level_ind(i) = k - 1
1118                   i = i + 1
1119                ENDIF
1120             ENDIF
1121             IF ( gradient /= 0.0 )  THEN
1122                IF ( k /= 1 )  THEN
1123                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1124                ELSE
1125                   q_init(k) = q_init(k-1) + 0.5 * dzu(k) * gradient
1126                ENDIF
1127             ELSE
1128                q_init(k) = q_init(k-1)
1129             ENDIF
1130!
1131!--          Avoid negative humidities
1132             IF ( q_init(k) < 0.0 )  THEN
1133                q_init(k) = 0.0
1134             ENDIF
1135          ENDDO
1136
1137!
1138!--       In case of no given humidity gradients, choose zero gradient
1139!--       conditions
1140          IF ( q_vertical_gradient_level(1) == -1.0 )  THEN
1141             q_vertical_gradient_level(1) = 0.0
1142          ENDIF
1143
1144!
1145!--       Store humidity gradient at the top boundary for possile Neumann
1146!--       boundary condition
1147          bc_q_t_val = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
1148
1149       ENDIF
1150
1151!
1152!--    If required, compute initial salinity profile using the given salinity
1153!--    gradients
1154       IF ( ocean )  THEN
1155
1156          i = 1
1157          gradient = 0.0
1158
1159          sa_vertical_gradient_level_ind(1) = nzt+1
1160          DO  k = nzt, 0, -1
1161             IF ( i < 11 ) THEN
1162                IF ( sa_vertical_gradient_level(i) > zu(k)  .AND. &
1163                     sa_vertical_gradient_level(i) <= 0.0 )  THEN
1164                   gradient = sa_vertical_gradient(i) / 100.0
1165                   sa_vertical_gradient_level_ind(i) = k + 1
1166                   i = i + 1
1167                ENDIF
1168             ENDIF
1169             IF ( gradient /= 0.0 )  THEN
1170                IF ( k /= nzt )  THEN
1171                   sa_init(k) = sa_init(k+1) - dzu(k+1) * gradient
1172                ELSE
1173                   sa_init(k)   = sa_surface - 0.5 * dzu(k+1) * gradient
1174                   sa_init(k+1) = sa_surface + 0.5 * dzu(k+1) * gradient
1175                ENDIF
1176             ELSE
1177                sa_init(k) = sa_init(k+1)
1178             ENDIF
1179          ENDDO
1180
1181       ENDIF
1182
1183!
1184!--    If required compute the profile of leaf area density used in the plant
1185!--    canopy model
1186       IF ( plant_canopy ) THEN
1187       
1188          i = 1
1189          gradient = 0.0
1190
1191          IF ( .NOT. ocean ) THEN
1192
1193             lad(0) = lad_surface
1194 
1195             lad_vertical_gradient_level_ind(1) = 0
1196             DO k = 1, pch_index
1197                IF ( i < 11 ) THEN
1198                   IF ( lad_vertical_gradient_level(i) < zu(k) .AND.  &
1199                        lad_vertical_gradient_level(i) >= 0.0 ) THEN
1200                      gradient = lad_vertical_gradient(i)
1201                      lad_vertical_gradient_level_ind(i) = k - 1
1202                      i = i + 1
1203                   ENDIF
1204                ENDIF
1205                IF ( gradient /= 0.0 ) THEN
1206                   IF ( k /= 1 ) THEN
1207                      lad(k) = lad(k-1) + dzu(k) * gradient
1208                   ELSE
1209                      lad(k) = lad_surface + 0.5 * dzu(k) *gradient
1210                   ENDIF
1211                ELSE
1212                   lad(k) = lad(k-1)
1213                ENDIF
1214             ENDDO
1215
1216          ENDIF
1217
1218!
1219!--       In case of no given leaf area density gradients, choose a vanishing
1220!--       gradient
1221          IF ( lad_vertical_gradient_level(1) == -9999999.9 ) THEN
1222             lad_vertical_gradient_level(1) = 0.0
1223          ENDIF
1224
1225       ENDIF
1226         
1227    ENDIF
1228
1229!
1230!-- Initialize large scale subsidence if required
1231    IF ( subs_vertical_gradient_level(1) /= -9999999.9 )  THEN
1232       large_scale_subsidence = .TRUE.
1233       CALL init_w_subsidence
1234    END IF
1235 
1236             
1237
1238!
1239!-- Compute Coriolis parameter
1240    f  = 2.0 * omega * SIN( phi / 180.0 * pi )
1241    fs = 2.0 * omega * COS( phi / 180.0 * pi )
1242
1243!
1244!-- Ocean runs always use reference values in the buoyancy term. Therefore
1245!-- set the reference temperature equal to the surface temperature.
1246    IF ( ocean  .AND.  pt_reference == 9999999.9 )  pt_reference = pt_surface
1247
1248!
1249!-- Reference value has to be used in buoyancy terms
1250    IF ( pt_reference /= 9999999.9 )  use_reference = .TRUE.
1251
1252!
1253!-- Sign of buoyancy/stability terms
1254    IF ( ocean )  atmos_ocean_sign = -1.0
1255
1256!
1257!-- Ocean version must use flux boundary conditions at the top
1258    IF ( ocean .AND. .NOT. use_top_fluxes )  THEN
1259       message_string = 'use_top_fluxes must be .TRUE. in ocean version'
1260       CALL message( 'check_parameters', 'PA0042', 1, 2, 0, 6, 0 )
1261    ENDIF
1262
1263!
1264!-- In case of a given slope, compute the relevant quantities
1265    IF ( alpha_surface /= 0.0 )  THEN
1266       IF ( ABS( alpha_surface ) > 90.0 )  THEN
1267          WRITE( message_string, * ) 'ABS( alpha_surface = ', alpha_surface, &
1268                                     ' ) must be < 90.0'
1269          CALL message( 'check_parameters', 'PA0043', 1, 2, 0, 6, 0 )
1270       ENDIF
1271       sloping_surface = .TRUE.
1272       cos_alpha_surface = COS( alpha_surface / 180.0 * pi )
1273       sin_alpha_surface = SIN( alpha_surface / 180.0 * pi )
1274    ENDIF
1275
1276!
1277!-- Check time step and cfl_factor
1278    IF ( dt /= -1.0 )  THEN
1279       IF ( dt <= 0.0  .AND.  dt /= -1.0 )  THEN
1280          WRITE( message_string, * ) 'dt = ', dt , ' <= 0.0'
1281          CALL message( 'check_parameters', 'PA0044', 1, 2, 0, 6, 0 )
1282       ENDIF
1283       dt_3d = dt
1284       dt_fixed = .TRUE.
1285    ENDIF
1286
1287    IF ( cfl_factor <= 0.0  .OR.  cfl_factor > 1.0 )  THEN
1288       IF ( cfl_factor == -1.0 )  THEN
1289          IF ( timestep_scheme == 'runge-kutta-2' )  THEN
1290             cfl_factor = 0.8
1291          ELSEIF ( timestep_scheme == 'runge-kutta-3' )  THEN
1292             cfl_factor = 0.9
1293          ELSE
1294             cfl_factor = 0.9
1295          ENDIF
1296       ELSE
1297          WRITE( message_string, * ) 'cfl_factor = ', cfl_factor, &
1298                 ' out of range & 0.0 < cfl_factor <= 1.0 is required'
1299          CALL message( 'check_parameters', 'PA0045', 1, 2, 0, 6, 0 )
1300       ENDIF
1301    ENDIF
1302
1303!
1304!-- Store simulated time at begin
1305    simulated_time_at_begin = simulated_time
1306
1307!
1308!-- Store reference time for coupled runs and change the coupling flag,
1309!-- if ...
1310    IF ( simulated_time == 0.0 )  THEN
1311       IF ( coupling_start_time == 0.0 )  THEN
1312          time_since_reference_point = 0.0
1313       ELSEIF ( time_since_reference_point < 0.0 )  THEN
1314          run_coupled = .FALSE.
1315       ENDIF
1316    ENDIF
1317
1318!
1319!-- Set wind speed in the Galilei-transformed system
1320    IF ( galilei_transformation )  THEN
1321       IF ( use_ug_for_galilei_tr .AND.                &
1322            ug_vertical_gradient_level(1) == 0.0 .AND. & 
1323            vg_vertical_gradient_level(1) == 0.0 )  THEN
1324          u_gtrans = ug_surface * 0.6
1325          v_gtrans = vg_surface * 0.6
1326       ELSEIF ( use_ug_for_galilei_tr .AND.                &
1327                ug_vertical_gradient_level(1) /= 0.0 )  THEN
1328          message_string = 'baroclinicity (ug) not allowed simultaneously' // &
1329                           ' with galilei transformation'
1330          CALL message( 'check_parameters', 'PA0046', 1, 2, 0, 6, 0 )
1331       ELSEIF ( use_ug_for_galilei_tr .AND.                &
1332                vg_vertical_gradient_level(1) /= 0.0 )  THEN
1333          message_string = 'baroclinicity (vg) not allowed simultaneously' // &
1334                           ' with galilei transformation'
1335          CALL message( 'check_parameters', 'PA0047', 1, 2, 0, 6, 0 )
1336       ELSE
1337          message_string = 'variable translation speed used for galilei-' // &
1338             'transformation, which may cause & instabilities in stably ' // &
1339             'stratified regions'
1340          CALL message( 'check_parameters', 'PA0048', 0, 1, 0, 6, 0 )
1341       ENDIF
1342    ENDIF
1343
1344!
1345!-- In case of using a prandtl-layer, calculated (or prescribed) surface
1346!-- fluxes have to be used in the diffusion-terms
1347    IF ( prandtl_layer )  use_surface_fluxes = .TRUE.
1348
1349!
1350!-- Check boundary conditions and set internal variables:
1351!-- Lateral boundary conditions
1352    IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
1353         bc_lr /= 'radiation/dirichlet' .AND. bc_lr /= 'dirichlet/neumann' &
1354         .AND. bc_lr /= 'neumann/dirichlet' )  THEN
1355       message_string = 'unknown boundary condition: bc_lr = "' // &
1356                        TRIM( bc_lr ) // '"'
1357       CALL message( 'check_parameters', 'PA0049', 1, 2, 0, 6, 0 )
1358    ENDIF
1359    IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
1360         bc_ns /= 'radiation/dirichlet' .AND. bc_ns /= 'dirichlet/neumann' &
1361         .AND. bc_ns /= 'neumann/dirichlet' )  THEN
1362       message_string = 'unknown boundary condition: bc_ns = "' // &
1363                        TRIM( bc_ns ) // '"'
1364       CALL message( 'check_parameters', 'PA0050', 1, 2, 0, 6, 0 )
1365    ENDIF
1366
1367!
1368!-- Internal variables used for speed optimization in if clauses
1369    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
1370    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
1371    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
1372    IF ( bc_lr == 'dirichlet/neumann' )    bc_lr_dirneu = .TRUE.
1373    IF ( bc_lr == 'neumann/dirichlet' )    bc_lr_neudir = .TRUE.
1374    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
1375    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
1376    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
1377    IF ( bc_ns == 'dirichlet/neumann' )    bc_ns_dirneu = .TRUE.
1378    IF ( bc_ns == 'neumann/dirichlet' )    bc_ns_neudir = .TRUE.
1379
1380!
1381!-- Non-cyclic lateral boundaries require the multigrid method and Piascek-
1382!-- Willimas or Wicker - Skamarock advection scheme. Several schemes
1383!-- and tools do not work with non-cyclic boundary conditions.
1384    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
1385       IF ( psolver /= 'multigrid' )  THEN
1386          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1387                           'psolver = "' // TRIM( psolver ) // '"'
1388          CALL message( 'check_parameters', 'PA0051', 1, 2, 0, 6, 0 )
1389       ENDIF
1390       IF ( momentum_advec /= 'pw-scheme' .AND. &
1391            momentum_advec /= 'ws-scheme')  THEN
1392          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1393                           'momentum_advec = "' // TRIM( momentum_advec ) // '"'
1394          CALL message( 'check_parameters', 'PA0052', 1, 2, 0, 6, 0 )
1395       ENDIF
1396       IF ( scalar_advec /= 'pw-scheme' .AND. &
1397            scalar_advec /= 'ws-scheme' )  THEN
1398          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1399                           'scalar_advec = "' // TRIM( scalar_advec ) // '"'
1400          CALL message( 'check_parameters', 'PA0053', 1, 2, 0, 6, 0 )
1401       ENDIF
1402       IF ( galilei_transformation )  THEN
1403          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1404                           'galilei_transformation = .T.'
1405          CALL message( 'check_parameters', 'PA0054', 1, 2, 0, 6, 0 )
1406       ENDIF
1407    ENDIF
1408
1409!
1410!-- Bottom boundary condition for the turbulent Kinetic energy
1411    IF ( bc_e_b == 'neumann' )  THEN
1412       ibc_e_b = 1
1413    ELSEIF ( bc_e_b == '(u*)**2+neumann' )  THEN
1414       ibc_e_b = 2
1415       IF ( prandtl_layer )  THEN
1416          message_string = 'adjust mixing length = FALSE and bc_e_b = "' // &
1417                           TRIM( bc_e_b ) // '"'
1418          CALL message( 'check_parameters', 'PA0056', 0, 1, 0, 6, 0 )
1419       ENDIF
1420       IF ( .NOT. prandtl_layer )  THEN
1421          bc_e_b = 'neumann'
1422          ibc_e_b = 1
1423          message_string = 'boundary condition bc_e_b changed to "' // &
1424                           TRIM( bc_e_b ) // '"'
1425          CALL message( 'check_parameters', 'PA0057', 0, 1, 0, 6, 0 )
1426       ENDIF
1427    ELSE
1428       message_string = 'unknown boundary condition: bc_e_b = "' // &
1429                        TRIM( bc_e_b ) // '"'
1430       CALL message( 'check_parameters', 'PA0058', 1, 2, 0, 6, 0 )
1431    ENDIF
1432
1433!
1434!-- Boundary conditions for perturbation pressure
1435    IF ( bc_p_b == 'dirichlet' )  THEN
1436       ibc_p_b = 0
1437    ELSEIF ( bc_p_b == 'neumann' )  THEN
1438       ibc_p_b = 1
1439    ELSEIF ( bc_p_b == 'neumann+inhomo' )  THEN
1440       ibc_p_b = 2
1441    ELSE
1442       message_string = 'unknown boundary condition: bc_p_b = "' // &
1443                        TRIM( bc_p_b ) // '"'
1444       CALL message( 'check_parameters', 'PA0059', 1, 2, 0, 6, 0 )
1445    ENDIF
1446    IF ( ibc_p_b == 2  .AND.  .NOT. prandtl_layer )  THEN
1447       message_string = 'boundary condition: bc_p_b = "' // TRIM( bc_p_b ) // &
1448                        '" not allowed with prandtl_layer = .FALSE.'
1449       CALL message( 'check_parameters', 'PA0060', 1, 2, 0, 6, 0 )
1450    ENDIF
1451    IF ( bc_p_t == 'dirichlet' )  THEN
1452       ibc_p_t = 0
1453    ELSEIF ( bc_p_t == 'neumann' )  THEN
1454       ibc_p_t = 1
1455    ELSE
1456       message_string = 'unknown boundary condition: bc_p_t = "' // &
1457                        TRIM( bc_p_t ) // '"'
1458       CALL message( 'check_parameters', 'PA0061', 1, 2, 0, 6, 0 )
1459    ENDIF
1460
1461!
1462!-- Boundary conditions for potential temperature
1463    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1464       ibc_pt_b = 2
1465    ELSE
1466       IF ( bc_pt_b == 'dirichlet' )  THEN
1467          ibc_pt_b = 0
1468       ELSEIF ( bc_pt_b == 'neumann' )  THEN
1469          ibc_pt_b = 1
1470       ELSE
1471          message_string = 'unknown boundary condition: bc_pt_b = "' // &
1472                           TRIM( bc_pt_b ) // '"'
1473          CALL message( 'check_parameters', 'PA0062', 1, 2, 0, 6, 0 )
1474       ENDIF
1475    ENDIF
1476
1477    IF ( bc_pt_t == 'dirichlet' )  THEN
1478       ibc_pt_t = 0
1479    ELSEIF ( bc_pt_t == 'neumann' )  THEN
1480       ibc_pt_t = 1
1481    ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
1482       ibc_pt_t = 2
1483    ELSE
1484       message_string = 'unknown boundary condition: bc_pt_t = "' // &
1485                        TRIM( bc_pt_t ) // '"'
1486       CALL message( 'check_parameters', 'PA0063', 1, 2, 0, 6, 0 )
1487    ENDIF
1488
1489    IF ( surface_heatflux == 9999999.9 )  constant_heatflux     = .FALSE.
1490    IF ( top_heatflux     == 9999999.9 )  constant_top_heatflux = .FALSE.
1491
1492    IF ( neutral )  THEN
1493
1494       IF ( surface_heatflux /= 0.0  .AND.  surface_heatflux /= 9999999.9 ) &
1495       THEN
1496          message_string = 'heatflux must not be set for pure neutral flow'
1497          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1498       ENDIF
1499
1500       IF ( top_heatflux /= 0.0  .AND.  top_heatflux /= 9999999.9 ) &
1501       THEN
1502          message_string = 'heatflux must not be set for pure neutral flow'
1503          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1504       ENDIF
1505
1506    ENDIF
1507
1508    IF ( top_momentumflux_u /= 9999999.9  .AND.  &
1509         top_momentumflux_v /= 9999999.9 )  THEN
1510       constant_top_momentumflux = .TRUE.
1511    ELSEIF (  .NOT. ( top_momentumflux_u == 9999999.9  .AND.  &
1512           top_momentumflux_v == 9999999.9 ) )  THEN
1513       message_string = 'both, top_momentumflux_u AND top_momentumflux_v ' // &
1514                        'must be set'
1515       CALL message( 'check_parameters', 'PA0064', 1, 2, 0, 6, 0 )
1516    ENDIF
1517
1518!
1519!-- A given surface temperature implies Dirichlet boundary condition for
1520!-- temperature. In this case specification of a constant heat flux is
1521!-- forbidden.
1522    IF ( ibc_pt_b == 0  .AND.   constant_heatflux  .AND. &
1523         surface_heatflux /= 0.0 )  THEN
1524       message_string = 'boundary_condition: bc_pt_b = "' // TRIM( bc_pt_b ) //&
1525                        '& is not allowed with constant_heatflux = .TRUE.'
1526       CALL message( 'check_parameters', 'PA0065', 1, 2, 0, 6, 0 )
1527    ENDIF
1528    IF ( constant_heatflux  .AND.  pt_surface_initial_change /= 0.0 )  THEN
1529       WRITE ( message_string, * )  'constant_heatflux = .TRUE. is not allo', &
1530               'wed with pt_surface_initial_change (/=0) = ', &
1531               pt_surface_initial_change
1532       CALL message( 'check_parameters', 'PA0066', 1, 2, 0, 6, 0 )
1533    ENDIF
1534
1535!
1536!-- A given temperature at the top implies Dirichlet boundary condition for
1537!-- temperature. In this case specification of a constant heat flux is
1538!-- forbidden.
1539    IF ( ibc_pt_t == 0  .AND.   constant_top_heatflux  .AND. &
1540         top_heatflux /= 0.0 )  THEN
1541       message_string = 'boundary_condition: bc_pt_t = "' // TRIM( bc_pt_t ) //&
1542                        '" is not allowed with constant_top_heatflux = .TRUE.'
1543       CALL message( 'check_parameters', 'PA0067', 1, 2, 0, 6, 0 )
1544    ENDIF
1545
1546!
1547!-- Boundary conditions for salinity
1548    IF ( ocean )  THEN
1549       IF ( bc_sa_t == 'dirichlet' )  THEN
1550          ibc_sa_t = 0
1551       ELSEIF ( bc_sa_t == 'neumann' )  THEN
1552          ibc_sa_t = 1
1553       ELSE
1554          message_string = 'unknown boundary condition: bc_sa_t = "' // &
1555                           TRIM( bc_sa_t ) // '"'
1556          CALL message( 'check_parameters', 'PA0068', 1, 2, 0, 6, 0 )
1557       ENDIF
1558
1559       IF ( top_salinityflux == 9999999.9 )  constant_top_salinityflux = .FALSE.
1560       IF ( ibc_sa_t == 1  .AND.   top_salinityflux == 9999999.9 )  THEN
1561          message_string = 'boundary condition: bc_sa_t = "' // &
1562                           TRIM( bc_sa_t ) // '" requires to set ' // &
1563                           'top_salinityflux'
1564          CALL message( 'check_parameters', 'PA0069', 1, 2, 0, 6, 0 )
1565       ENDIF
1566
1567!
1568!--    A fixed salinity at the top implies Dirichlet boundary condition for
1569!--    salinity. In this case specification of a constant salinity flux is
1570!--    forbidden.
1571       IF ( ibc_sa_t == 0  .AND.   constant_top_salinityflux  .AND. &
1572            top_salinityflux /= 0.0 )  THEN
1573          message_string = 'boundary condition: bc_sa_t = "' // &
1574                           TRIM( bc_sa_t ) // '" is not allowed with ' // &
1575                           'constant_top_salinityflux = .TRUE.'
1576          CALL message( 'check_parameters', 'PA0070', 1, 2, 0, 6, 0 )
1577       ENDIF
1578
1579    ENDIF
1580
1581!
1582!-- In case of humidity or passive scalar, set boundary conditions for total
1583!-- water content / scalar
1584    IF ( humidity  .OR.  passive_scalar ) THEN
1585       IF ( humidity )  THEN
1586          sq = 'q'
1587       ELSE
1588          sq = 's'
1589       ENDIF
1590       IF ( bc_q_b == 'dirichlet' )  THEN
1591          ibc_q_b = 0
1592       ELSEIF ( bc_q_b == 'neumann' )  THEN
1593          ibc_q_b = 1
1594       ELSE
1595          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1596                           '_b ="' // TRIM( bc_q_b ) // '"'
1597          CALL message( 'check_parameters', 'PA0071', 1, 2, 0, 6, 0 )
1598       ENDIF
1599       IF ( bc_q_t == 'dirichlet' )  THEN
1600          ibc_q_t = 0
1601       ELSEIF ( bc_q_t == 'neumann' )  THEN
1602          ibc_q_t = 1
1603       ELSE
1604          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1605                           '_t ="' // TRIM( bc_q_t ) // '"'
1606          CALL message( 'check_parameters', 'PA0072', 1, 2, 0, 6, 0 )
1607       ENDIF
1608
1609       IF ( surface_waterflux == 9999999.9 )  constant_waterflux = .FALSE.
1610
1611!
1612!--    A given surface humidity implies Dirichlet boundary condition for
1613!--    humidity. In this case specification of a constant water flux is
1614!--    forbidden.
1615       IF ( ibc_q_b == 0  .AND.  constant_waterflux )  THEN
1616          message_string = 'boundary condition: bc_' // TRIM( sq ) // '_b ' // &
1617                           '= "' // TRIM( bc_q_b ) // '" is not allowed wi' // &
1618                           'th prescribed surface flux'
1619          CALL message( 'check_parameters', 'PA0073', 1, 2, 0, 6, 0 )
1620       ENDIF
1621       IF ( constant_waterflux  .AND.  q_surface_initial_change /= 0.0 )  THEN
1622          WRITE( message_string, * )  'a prescribed surface flux is not allo', &
1623                 'wed with ', sq, '_surface_initial_change (/=0) = ', &
1624                 q_surface_initial_change
1625          CALL message( 'check_parameters', 'PA0074', 1, 2, 0, 6, 0 )
1626       ENDIF
1627       
1628    ENDIF
1629
1630!
1631!-- Boundary conditions for horizontal components of wind speed
1632    IF ( bc_uv_b == 'dirichlet' )  THEN
1633       ibc_uv_b = 0
1634    ELSEIF ( bc_uv_b == 'neumann' )  THEN
1635       ibc_uv_b = 1
1636       IF ( prandtl_layer )  THEN
1637          message_string = 'boundary condition: bc_uv_b = "' // &
1638               TRIM( bc_uv_b ) // '" is not allowed with prandtl_layer = .TRUE.'
1639          CALL message( 'check_parameters', 'PA0075', 1, 2, 0, 6, 0 )
1640       ENDIF
1641    ELSE
1642       message_string = 'unknown boundary condition: bc_uv_b = "' // &
1643                        TRIM( bc_uv_b ) // '"'
1644       CALL message( 'check_parameters', 'PA0076', 1, 2, 0, 6, 0 )
1645    ENDIF
1646!
1647!-- In case of coupled simulations u and v at the ground in atmosphere will be
1648!-- assigned with the u and v values of the ocean surface
1649    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1650       ibc_uv_b = 2
1651    ENDIF
1652
1653    IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
1654       bc_uv_t = 'neumann'
1655       ibc_uv_t = 1
1656    ELSE
1657       IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
1658          ibc_uv_t = 0
1659          IF ( bc_uv_t == 'dirichlet_0' )  THEN
1660!
1661!--          Velocities for the initial u,v-profiles are set zero at the top
1662!--          in case of dirichlet_0 conditions
1663             u_init(nzt+1)    = 0.0
1664             v_init(nzt+1)    = 0.0
1665          ENDIF
1666       ELSEIF ( bc_uv_t == 'neumann' )  THEN
1667          ibc_uv_t = 1
1668       ELSE
1669          message_string = 'unknown boundary condition: bc_uv_t = "' // &
1670                           TRIM( bc_uv_t ) // '"'
1671          CALL message( 'check_parameters', 'PA0077', 1, 2, 0, 6, 0 )
1672       ENDIF
1673    ENDIF
1674
1675!
1676!-- Compute and check, respectively, the Rayleigh Damping parameter
1677    IF ( rayleigh_damping_factor == -1.0 )  THEN
1678       rayleigh_damping_factor = 0.0
1679    ELSE
1680       IF ( rayleigh_damping_factor < 0.0 .OR. rayleigh_damping_factor > 1.0 ) &
1681       THEN
1682          WRITE( message_string, * )  'rayleigh_damping_factor = ', &
1683                              rayleigh_damping_factor, ' out of range [0.0,1.0]'
1684          CALL message( 'check_parameters', 'PA0078', 1, 2, 0, 6, 0 )
1685       ENDIF
1686    ENDIF
1687
1688    IF ( rayleigh_damping_height == -1.0 )  THEN
1689       IF ( .NOT. ocean )  THEN
1690          rayleigh_damping_height = 0.66666666666 * zu(nzt)
1691       ELSE
1692          rayleigh_damping_height = 0.66666666666 * zu(nzb)
1693       ENDIF
1694    ELSE
1695       IF ( .NOT. ocean )  THEN
1696          IF ( rayleigh_damping_height < 0.0  .OR. &
1697               rayleigh_damping_height > zu(nzt) )  THEN
1698             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1699                   rayleigh_damping_height, ' out of range [0.0,', zu(nzt), ']'
1700             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1701          ENDIF
1702       ELSE
1703          IF ( rayleigh_damping_height > 0.0  .OR. &
1704               rayleigh_damping_height < zu(nzb) )  THEN
1705             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1706                   rayleigh_damping_height, ' out of range [0.0,', zu(nzb), ']'
1707             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1708          ENDIF
1709       ENDIF
1710    ENDIF
1711
1712!
1713!-- Check number of chosen statistic regions. More than 10 regions are not
1714!-- allowed, because so far no more than 10 corresponding output files can
1715!-- be opened (cf. check_open)
1716    IF ( statistic_regions > 9  .OR.  statistic_regions < 0 )  THEN
1717       WRITE ( message_string, * ) 'number of statistic_regions = ', &
1718                   statistic_regions+1, ' but only 10 regions are allowed'
1719       CALL message( 'check_parameters', 'PA0082', 1, 2, 0, 6, 0 )
1720    ENDIF
1721    IF ( normalizing_region > statistic_regions  .OR. &
1722         normalizing_region < 0)  THEN
1723       WRITE ( message_string, * ) 'normalizing_region = ', &
1724                normalizing_region, ' must be >= 0 and <= ',statistic_regions, &
1725                ' (value of statistic_regions)'
1726       CALL message( 'check_parameters', 'PA0083', 1, 2, 0, 6, 0 )
1727    ENDIF
1728
1729!
1730!-- Check the interval for sorting particles.
1731!-- Using particles as cloud droplets requires sorting after each timestep.
1732    IF ( dt_sort_particles /= 0.0  .AND.  cloud_droplets )  THEN
1733       dt_sort_particles = 0.0
1734       message_string = 'dt_sort_particles is reset to 0.0 because of cloud' //&
1735                        '_droplets = .TRUE.'
1736       CALL message( 'check_parameters', 'PA0084', 0, 1, 0, 6, 0 )
1737    ENDIF
1738
1739!
1740!-- Set the default intervals for data output, if necessary
1741!-- NOTE: dt_dosp has already been set in package_parin
1742    IF ( dt_data_output /= 9999999.9 )  THEN
1743       IF ( dt_dopr           == 9999999.9 )  dt_dopr           = dt_data_output
1744       IF ( dt_dopts          == 9999999.9 )  dt_dopts          = dt_data_output
1745       IF ( dt_do2d_xy        == 9999999.9 )  dt_do2d_xy        = dt_data_output
1746       IF ( dt_do2d_xz        == 9999999.9 )  dt_do2d_xz        = dt_data_output
1747       IF ( dt_do2d_yz        == 9999999.9 )  dt_do2d_yz        = dt_data_output
1748       IF ( dt_do3d           == 9999999.9 )  dt_do3d           = dt_data_output
1749       IF ( dt_data_output_av == 9999999.9 )  dt_data_output_av = dt_data_output
1750       DO  mid = 1, max_masks
1751          IF ( dt_domask(mid) == 9999999.9 )  dt_domask(mid)    = dt_data_output
1752       ENDDO
1753    ENDIF
1754
1755!
1756!-- Set the default skip time intervals for data output, if necessary
1757    IF ( skip_time_dopr    == 9999999.9 ) &
1758                                       skip_time_dopr    = skip_time_data_output
1759    IF ( skip_time_dosp    == 9999999.9 ) &
1760                                       skip_time_dosp    = skip_time_data_output
1761    IF ( skip_time_do2d_xy == 9999999.9 ) &
1762                                       skip_time_do2d_xy = skip_time_data_output
1763    IF ( skip_time_do2d_xz == 9999999.9 ) &
1764                                       skip_time_do2d_xz = skip_time_data_output
1765    IF ( skip_time_do2d_yz == 9999999.9 ) &
1766                                       skip_time_do2d_yz = skip_time_data_output
1767    IF ( skip_time_do3d    == 9999999.9 ) &
1768                                       skip_time_do3d    = skip_time_data_output
1769    IF ( skip_time_data_output_av == 9999999.9 ) &
1770                                skip_time_data_output_av = skip_time_data_output
1771    DO  mid = 1, max_masks
1772       IF ( skip_time_domask(mid) == 9999999.9 ) &
1773                                skip_time_domask(mid)    = skip_time_data_output
1774    ENDDO
1775
1776!
1777!-- Check the average intervals (first for 3d-data, then for profiles and
1778!-- spectra)
1779    IF ( averaging_interval > dt_data_output_av )  THEN
1780       WRITE( message_string, * )  'averaging_interval = ', &
1781             averaging_interval, ' must be <= dt_data_output = ', dt_data_output
1782       CALL message( 'check_parameters', 'PA0085', 1, 2, 0, 6, 0 )
1783    ENDIF
1784
1785    IF ( averaging_interval_pr == 9999999.9 )  THEN
1786       averaging_interval_pr = averaging_interval
1787    ENDIF
1788
1789    IF ( averaging_interval_pr > dt_dopr )  THEN
1790       WRITE( message_string, * )  'averaging_interval_pr = ', &
1791             averaging_interval_pr, ' must be <= dt_dopr = ', dt_dopr
1792       CALL message( 'check_parameters', 'PA0086', 1, 2, 0, 6, 0 )
1793    ENDIF
1794
1795    IF ( averaging_interval_sp == 9999999.9 )  THEN
1796       averaging_interval_sp = averaging_interval
1797    ENDIF
1798
1799    IF ( averaging_interval_sp > dt_dosp )  THEN
1800       WRITE( message_string, * )  'averaging_interval_sp = ', &
1801             averaging_interval_sp, ' must be <= dt_dosp = ', dt_dosp
1802       CALL message( 'check_parameters', 'PA0087', 1, 2, 0, 6, 0 )
1803    ENDIF
1804
1805!
1806!-- Set the default interval for profiles entering the temporal average
1807    IF ( dt_averaging_input_pr == 9999999.9 )  THEN
1808       dt_averaging_input_pr = dt_averaging_input
1809    ENDIF
1810
1811!
1812!-- Set the default interval for the output of timeseries to a reasonable
1813!-- value (tries to minimize the number of calls of flow_statistics)
1814    IF ( dt_dots == 9999999.9 )  THEN
1815       IF ( averaging_interval_pr == 0.0 )  THEN
1816          dt_dots = MIN( dt_run_control, dt_dopr )
1817       ELSE
1818          dt_dots = MIN( dt_run_control, dt_averaging_input_pr )
1819       ENDIF
1820    ENDIF
1821
1822!
1823!-- Check the sample rate for averaging (first for 3d-data, then for profiles)
1824    IF ( dt_averaging_input > averaging_interval )  THEN
1825       WRITE( message_string, * )  'dt_averaging_input = ', &
1826                dt_averaging_input, ' must be <= averaging_interval = ', &
1827                averaging_interval
1828       CALL message( 'check_parameters', 'PA0088', 1, 2, 0, 6, 0 )
1829    ENDIF
1830
1831    IF ( dt_averaging_input_pr > averaging_interval_pr )  THEN
1832       WRITE( message_string, * )  'dt_averaging_input_pr = ', &
1833                dt_averaging_input_pr, ' must be <= averaging_interval_pr = ', &
1834                averaging_interval_pr
1835       CALL message( 'check_parameters', 'PA0089', 1, 2, 0, 6, 0 )
1836    ENDIF
1837
1838!
1839!-- Set the default value for the integration interval of precipitation amount
1840    IF ( precipitation )  THEN
1841       IF ( precipitation_amount_interval == 9999999.9 )  THEN
1842          precipitation_amount_interval = dt_do2d_xy
1843       ELSE
1844          IF ( precipitation_amount_interval > dt_do2d_xy )  THEN
1845             WRITE( message_string, * )  'precipitation_amount_interval = ', &
1846                 precipitation_amount_interval, ' must not be larger than ', &
1847                 'dt_do2d_xy = ', dt_do2d_xy
1848             CALL message( 'check_parameters', 'PA0090', 1, 2, 0, 6, 0 )
1849          ENDIF
1850       ENDIF
1851    ENDIF
1852
1853!
1854!-- Determine the number of output profiles and check whether they are
1855!-- permissible
1856    DO  WHILE ( data_output_pr(dopr_n+1) /= '          ' )
1857
1858       dopr_n = dopr_n + 1
1859       i = dopr_n
1860
1861!
1862!--    Determine internal profile number (for hom, homs)
1863!--    and store height levels
1864       SELECT CASE ( TRIM( data_output_pr(i) ) )
1865
1866          CASE ( 'u', '#u' )
1867             dopr_index(i) = 1
1868             dopr_unit(i)  = 'm/s'
1869             hom(:,2,1,:)  = SPREAD( zu, 2, statistic_regions+1 )
1870             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1871                dopr_initial_index(i) = 5
1872                hom(:,2,5,:)          = SPREAD( zu, 2, statistic_regions+1 )
1873                data_output_pr(i)     = data_output_pr(i)(2:)
1874             ENDIF
1875
1876          CASE ( 'v', '#v' )
1877             dopr_index(i) = 2
1878             dopr_unit(i)  = 'm/s'
1879             hom(:,2,2,:)  = SPREAD( zu, 2, statistic_regions+1 )
1880             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1881                dopr_initial_index(i) = 6
1882                hom(:,2,6,:)          = SPREAD( zu, 2, statistic_regions+1 )
1883                data_output_pr(i)     = data_output_pr(i)(2:)
1884             ENDIF
1885
1886          CASE ( 'w' )
1887             dopr_index(i) = 3
1888             dopr_unit(i)  = 'm/s'
1889             hom(:,2,3,:)  = SPREAD( zw, 2, statistic_regions+1 )
1890
1891          CASE ( 'pt', '#pt' )
1892             IF ( .NOT. cloud_physics ) THEN
1893                dopr_index(i) = 4
1894                dopr_unit(i)  = 'K'
1895                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
1896                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1897                   dopr_initial_index(i) = 7
1898                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
1899                   hom(nzb,2,7,:)        = 0.0    ! because zu(nzb) is negative
1900                   data_output_pr(i)     = data_output_pr(i)(2:)
1901                ENDIF
1902             ELSE
1903                dopr_index(i) = 43
1904                dopr_unit(i)  = 'K'
1905                hom(:,2,43,:)  = SPREAD( zu, 2, statistic_regions+1 )
1906                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1907                   dopr_initial_index(i) = 28
1908                   hom(:,2,28,:)         = SPREAD( zu, 2, statistic_regions+1 )
1909                   hom(nzb,2,28,:)       = 0.0    ! because zu(nzb) is negative
1910                   data_output_pr(i)     = data_output_pr(i)(2:)
1911                ENDIF
1912             ENDIF
1913
1914          CASE ( 'e' )
1915             dopr_index(i)  = 8
1916             dopr_unit(i)   = 'm2/s2'
1917             hom(:,2,8,:)   = SPREAD( zu, 2, statistic_regions+1 )
1918             hom(nzb,2,8,:) = 0.0
1919
1920          CASE ( 'km', '#km' )
1921             dopr_index(i)  = 9
1922             dopr_unit(i)   = 'm2/s'
1923             hom(:,2,9,:)   = SPREAD( zu, 2, statistic_regions+1 )
1924             hom(nzb,2,9,:) = 0.0
1925             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1926                dopr_initial_index(i) = 23
1927                hom(:,2,23,:)         = hom(:,2,9,:)
1928                data_output_pr(i)     = data_output_pr(i)(2:)
1929             ENDIF
1930
1931          CASE ( 'kh', '#kh' )
1932             dopr_index(i)   = 10
1933             dopr_unit(i)    = 'm2/s'
1934             hom(:,2,10,:)   = SPREAD( zu, 2, statistic_regions+1 )
1935             hom(nzb,2,10,:) = 0.0
1936             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1937                dopr_initial_index(i) = 24
1938                hom(:,2,24,:)         = hom(:,2,10,:)
1939                data_output_pr(i)     = data_output_pr(i)(2:)
1940             ENDIF
1941
1942          CASE ( 'l', '#l' )
1943             dopr_index(i)   = 11
1944             dopr_unit(i)    = 'm'
1945             hom(:,2,11,:)   = SPREAD( zu, 2, statistic_regions+1 )
1946             hom(nzb,2,11,:) = 0.0
1947             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1948                dopr_initial_index(i) = 25
1949                hom(:,2,25,:)         = hom(:,2,11,:)
1950                data_output_pr(i)     = data_output_pr(i)(2:)
1951             ENDIF
1952
1953          CASE ( 'w"u"' )
1954             dopr_index(i) = 12
1955             dopr_unit(i)  = 'm2/s2'
1956             hom(:,2,12,:) = SPREAD( zw, 2, statistic_regions+1 )
1957             IF ( prandtl_layer )  hom(nzb,2,12,:) = zu(1)
1958
1959          CASE ( 'w*u*' )
1960             dopr_index(i) = 13
1961             dopr_unit(i)  = 'm2/s2'
1962             hom(:,2,13,:) = SPREAD( zw, 2, statistic_regions+1 )
1963
1964          CASE ( 'w"v"' )
1965             dopr_index(i) = 14
1966             dopr_unit(i)  = 'm2/s2'
1967             hom(:,2,14,:) = SPREAD( zw, 2, statistic_regions+1 )
1968             IF ( prandtl_layer )  hom(nzb,2,14,:) = zu(1)
1969
1970          CASE ( 'w*v*' )
1971             dopr_index(i) = 15
1972             dopr_unit(i)  = 'm2/s2'
1973             hom(:,2,15,:) = SPREAD( zw, 2, statistic_regions+1 )
1974
1975          CASE ( 'w"pt"' )
1976             dopr_index(i) = 16
1977             dopr_unit(i)  = 'K m/s'
1978             hom(:,2,16,:) = SPREAD( zw, 2, statistic_regions+1 )
1979
1980          CASE ( 'w*pt*' )
1981             dopr_index(i) = 17
1982             dopr_unit(i)  = 'K m/s'
1983             hom(:,2,17,:) = SPREAD( zw, 2, statistic_regions+1 )
1984
1985          CASE ( 'wpt' )
1986             dopr_index(i) = 18
1987             dopr_unit(i)  = 'K m/s'
1988             hom(:,2,18,:) = SPREAD( zw, 2, statistic_regions+1 )
1989
1990          CASE ( 'wu' )
1991             dopr_index(i) = 19
1992             dopr_unit(i)  = 'm2/s2'
1993             hom(:,2,19,:) = SPREAD( zw, 2, statistic_regions+1 )
1994             IF ( prandtl_layer )  hom(nzb,2,19,:) = zu(1)
1995
1996          CASE ( 'wv' )
1997             dopr_index(i) = 20
1998             dopr_unit(i)  = 'm2/s2'
1999             hom(:,2,20,:) = SPREAD( zw, 2, statistic_regions+1 )
2000             IF ( prandtl_layer )  hom(nzb,2,20,:) = zu(1)
2001
2002          CASE ( 'w*pt*BC' )
2003             dopr_index(i) = 21
2004             dopr_unit(i)  = 'K m/s'
2005             hom(:,2,21,:) = SPREAD( zw, 2, statistic_regions+1 )
2006
2007          CASE ( 'wptBC' )
2008             dopr_index(i) = 22
2009             dopr_unit(i)  = 'K m/s'
2010             hom(:,2,22,:) = SPREAD( zw, 2, statistic_regions+1 )
2011
2012          CASE ( 'sa', '#sa' )
2013             IF ( .NOT. ocean )  THEN
2014                message_string = 'data_output_pr = ' // &
2015                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2016                                 'lemented for ocean = .FALSE.'
2017                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2018             ELSE
2019                dopr_index(i) = 23
2020                dopr_unit(i)  = 'psu'
2021                hom(:,2,23,:) = SPREAD( zu, 2, statistic_regions+1 )
2022                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2023                   dopr_initial_index(i) = 26
2024                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2025                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2026                   data_output_pr(i)     = data_output_pr(i)(2:)
2027                ENDIF
2028             ENDIF
2029
2030          CASE ( 'u*2' )
2031             dopr_index(i) = 30
2032             dopr_unit(i)  = 'm2/s2'
2033             hom(:,2,30,:) = SPREAD( zu, 2, statistic_regions+1 )
2034
2035          CASE ( 'v*2' )
2036             dopr_index(i) = 31
2037             dopr_unit(i)  = 'm2/s2'
2038             hom(:,2,31,:) = SPREAD( zu, 2, statistic_regions+1 )
2039
2040          CASE ( 'w*2' )
2041             dopr_index(i) = 32
2042             dopr_unit(i)  = 'm2/s2'
2043             hom(:,2,32,:) = SPREAD( zw, 2, statistic_regions+1 )
2044
2045          CASE ( 'pt*2' )
2046             dopr_index(i) = 33
2047             dopr_unit(i)  = 'K2'
2048             hom(:,2,33,:) = SPREAD( zu, 2, statistic_regions+1 )
2049
2050          CASE ( 'e*' )
2051             dopr_index(i) = 34
2052             dopr_unit(i)  = 'm2/s2'
2053             hom(:,2,34,:) = SPREAD( zu, 2, statistic_regions+1 )
2054
2055          CASE ( 'w*2pt*' )
2056             dopr_index(i) = 35
2057             dopr_unit(i)  = 'K m2/s2'
2058             hom(:,2,35,:) = SPREAD( zw, 2, statistic_regions+1 )
2059
2060          CASE ( 'w*pt*2' )
2061             dopr_index(i) = 36
2062             dopr_unit(i)  = 'K2 m/s'
2063             hom(:,2,36,:) = SPREAD( zw, 2, statistic_regions+1 )
2064
2065          CASE ( 'w*e*' )
2066             dopr_index(i) = 37
2067             dopr_unit(i)  = 'm3/s3'
2068             hom(:,2,37,:) = SPREAD( zw, 2, statistic_regions+1 )
2069
2070          CASE ( 'w*3' )
2071             dopr_index(i) = 38
2072             dopr_unit(i)  = 'm3/s3'
2073             hom(:,2,38,:) = SPREAD( zw, 2, statistic_regions+1 )
2074
2075          CASE ( 'Sw' )
2076             dopr_index(i) = 39
2077             dopr_unit(i)  = 'none'
2078             hom(:,2,39,:) = SPREAD( zw, 2, statistic_regions+1 )
2079
2080          CASE ( 'p' )
2081             dopr_index(i) = 40
2082             dopr_unit(i)  = 'Pa'
2083             hom(:,2,40,:) = SPREAD( zu, 2, statistic_regions+1 )
2084
2085          CASE ( 'q', '#q' )
2086             IF ( .NOT. humidity )  THEN
2087                message_string = 'data_output_pr = ' // &
2088                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2089                                 'lemented for humidity = .FALSE.'
2090                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2091             ELSE
2092                dopr_index(i) = 41
2093                dopr_unit(i)  = 'kg/kg'
2094                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2095                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2096                   dopr_initial_index(i) = 26
2097                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2098                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2099                   data_output_pr(i)     = data_output_pr(i)(2:)
2100                ENDIF
2101             ENDIF
2102
2103          CASE ( 's', '#s' )
2104             IF ( .NOT. passive_scalar )  THEN
2105                message_string = 'data_output_pr = ' // &
2106                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2107                                 'lemented for passive_scalar = .FALSE.'
2108                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2109             ELSE
2110                dopr_index(i) = 41
2111                dopr_unit(i)  = 'kg/m3'
2112                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2113                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2114                   dopr_initial_index(i) = 26
2115                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2116                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2117                   data_output_pr(i)     = data_output_pr(i)(2:)
2118                ENDIF
2119             ENDIF
2120
2121          CASE ( 'qv', '#qv' )
2122             IF ( .NOT. cloud_physics ) THEN
2123                dopr_index(i) = 41
2124                dopr_unit(i)  = 'kg/kg'
2125                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2126                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2127                   dopr_initial_index(i) = 26
2128                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2129                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2130                   data_output_pr(i)     = data_output_pr(i)(2:)
2131                ENDIF
2132             ELSE
2133                dopr_index(i) = 42
2134                dopr_unit(i)  = 'kg/kg'
2135                hom(:,2,42,:) = SPREAD( zu, 2, statistic_regions+1 )
2136                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2137                   dopr_initial_index(i) = 27
2138                   hom(:,2,27,:)         = SPREAD( zu, 2, statistic_regions+1 )
2139                   hom(nzb,2,27,:)       = 0.0    ! weil zu(nzb) negativ ist
2140                   data_output_pr(i)     = data_output_pr(i)(2:)
2141                ENDIF
2142             ENDIF
2143
2144          CASE ( 'lpt', '#lpt' )
2145             IF ( .NOT. cloud_physics ) THEN
2146                message_string = 'data_output_pr = ' // &
2147                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2148                                 'lemented for cloud_physics = .FALSE.'
2149                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2150             ELSE
2151                dopr_index(i) = 4
2152                dopr_unit(i)  = 'K'
2153                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
2154                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2155                   dopr_initial_index(i) = 7
2156                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
2157                   hom(nzb,2,7,:)        = 0.0    ! weil zu(nzb) negativ ist
2158                   data_output_pr(i)     = data_output_pr(i)(2:)
2159                ENDIF
2160             ENDIF
2161
2162          CASE ( 'vpt', '#vpt' )
2163             dopr_index(i) = 44
2164             dopr_unit(i)  = 'K'
2165             hom(:,2,44,:) = SPREAD( zu, 2, statistic_regions+1 )
2166             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2167                dopr_initial_index(i) = 29
2168                hom(:,2,29,:)         = SPREAD( zu, 2, statistic_regions+1 )
2169                hom(nzb,2,29,:)       = 0.0    ! weil zu(nzb) negativ ist
2170                data_output_pr(i)     = data_output_pr(i)(2:)
2171             ENDIF
2172
2173          CASE ( 'w"vpt"' )
2174             dopr_index(i) = 45
2175             dopr_unit(i)  = 'K m/s'
2176             hom(:,2,45,:) = SPREAD( zw, 2, statistic_regions+1 )
2177
2178          CASE ( 'w*vpt*' )
2179             dopr_index(i) = 46
2180             dopr_unit(i)  = 'K m/s'
2181             hom(:,2,46,:) = SPREAD( zw, 2, statistic_regions+1 )
2182
2183          CASE ( 'wvpt' )
2184             dopr_index(i) = 47
2185             dopr_unit(i)  = 'K m/s'
2186             hom(:,2,47,:) = SPREAD( zw, 2, statistic_regions+1 )
2187
2188          CASE ( 'w"q"' )
2189             IF ( .NOT. humidity )  THEN
2190                message_string = 'data_output_pr = ' // &
2191                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2192                                 'lemented for humidity = .FALSE.'
2193                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2194             ELSE
2195                dopr_index(i) = 48
2196                dopr_unit(i)  = 'kg/kg m/s'
2197                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2198             ENDIF
2199
2200          CASE ( 'w*q*' )
2201             IF ( .NOT. humidity )  THEN
2202                message_string = 'data_output_pr = ' // &
2203                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2204                                 'lemented for humidity = .FALSE.'
2205                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2206             ELSE
2207                dopr_index(i) = 49
2208                dopr_unit(i)  = 'kg/kg m/s'
2209                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2210             ENDIF
2211
2212          CASE ( 'wq' )
2213             IF ( .NOT. humidity )  THEN
2214                message_string = 'data_output_pr = ' // &
2215                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2216                                 'lemented for humidity = .FALSE.'
2217                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2218             ELSE
2219                dopr_index(i) = 50
2220                dopr_unit(i)  = 'kg/kg m/s'
2221                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2222             ENDIF
2223
2224          CASE ( 'w"s"' )
2225             IF ( .NOT. passive_scalar ) THEN
2226                message_string = 'data_output_pr = ' // &
2227                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2228                                 'lemented for passive_scalar = .FALSE.'
2229                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2230             ELSE
2231                dopr_index(i) = 48
2232                dopr_unit(i)  = 'kg/m3 m/s'
2233                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2234             ENDIF
2235
2236          CASE ( 'w*s*' )
2237             IF ( .NOT. passive_scalar ) THEN
2238                message_string = 'data_output_pr = ' // &
2239                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2240                                 'lemented for passive_scalar = .FALSE.'
2241                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2242             ELSE
2243                dopr_index(i) = 49
2244                dopr_unit(i)  = 'kg/m3 m/s'
2245                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2246             ENDIF
2247
2248          CASE ( 'ws' )
2249             IF ( .NOT. passive_scalar ) THEN
2250                message_string = 'data_output_pr = ' // &
2251                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2252                                 'lemented for passive_scalar = .FALSE.'
2253                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2254             ELSE
2255                dopr_index(i) = 50
2256                dopr_unit(i)  = 'kg/m3 m/s'
2257                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2258             ENDIF
2259
2260          CASE ( 'w"qv"' )
2261             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2262             THEN
2263                dopr_index(i) = 48
2264                dopr_unit(i)  = 'kg/kg m/s'
2265                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2266             ELSEIF( humidity .AND. cloud_physics ) THEN
2267                dopr_index(i) = 51
2268                dopr_unit(i)  = 'kg/kg m/s'
2269                hom(:,2,51,:) = SPREAD( zw, 2, statistic_regions+1 )
2270             ELSE
2271                message_string = 'data_output_pr = ' // &
2272                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2273                                 'lemented for cloud_physics = .FALSE. an&' // &
2274                                 'd humidity = .FALSE.'
2275                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2276             ENDIF
2277
2278          CASE ( 'w*qv*' )
2279             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2280             THEN
2281                dopr_index(i) = 49
2282                dopr_unit(i)  = 'kg/kg m/s'
2283                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2284             ELSEIF( humidity .AND. cloud_physics ) THEN
2285                dopr_index(i) = 52
2286                dopr_unit(i)  = 'kg/kg m/s'
2287                hom(:,2,52,:) = SPREAD( zw, 2, statistic_regions+1 )
2288             ELSE
2289                message_string = 'data_output_pr = ' // &
2290                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2291                                 'lemented for cloud_physics = .FALSE. an&' // &
2292                                 'd humidity = .FALSE.'
2293                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2294             ENDIF
2295
2296          CASE ( 'wqv' )
2297             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2298             THEN
2299                dopr_index(i) = 50
2300                dopr_unit(i)  = 'kg/kg m/s'
2301                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2302             ELSEIF( humidity .AND. cloud_physics ) THEN
2303                dopr_index(i) = 53
2304                dopr_unit(i)  = 'kg/kg m/s'
2305                hom(:,2,53,:) = SPREAD( zw, 2, statistic_regions+1 )
2306             ELSE
2307                message_string = 'data_output_pr = ' // &
2308                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2309                                 'lemented for cloud_physics = .FALSE. an&' // &
2310                                 'd humidity = .FALSE.'
2311                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2312             ENDIF
2313
2314          CASE ( 'ql' )
2315             IF ( .NOT. cloud_physics  .AND.  .NOT. cloud_droplets )  THEN
2316                message_string = 'data_output_pr = ' // &
2317                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2318                                 'lemented for cloud_physics = .FALSE. or'  // &
2319                                 '&cloud_droplets = .FALSE.'
2320                CALL message( 'check_parameters', 'PA0096', 1, 2, 0, 6, 0 )
2321             ELSE
2322                dopr_index(i) = 54
2323                dopr_unit(i)  = 'kg/kg'
2324                hom(:,2,54,:)  = SPREAD( zu, 2, statistic_regions+1 )
2325             ENDIF
2326
2327          CASE ( 'w*u*u*:dz' )
2328             dopr_index(i) = 55
2329             dopr_unit(i)  = 'm2/s3'
2330             hom(:,2,55,:) = SPREAD( zu, 2, statistic_regions+1 )
2331
2332          CASE ( 'w*p*:dz' )
2333             dopr_index(i) = 56
2334             dopr_unit(i)  = 'm2/s3'
2335             hom(:,2,56,:) = SPREAD( zw, 2, statistic_regions+1 )
2336
2337          CASE ( 'w"e:dz' )
2338             dopr_index(i) = 57
2339             dopr_unit(i)  = 'm2/s3'
2340             hom(:,2,57,:) = SPREAD( zu, 2, statistic_regions+1 )
2341
2342
2343          CASE ( 'u"pt"' )
2344             dopr_index(i) = 58
2345             dopr_unit(i)  = 'K m/s'
2346             hom(:,2,58,:) = SPREAD( zu, 2, statistic_regions+1 )
2347
2348          CASE ( 'u*pt*' )
2349             dopr_index(i) = 59
2350             dopr_unit(i)  = 'K m/s'
2351             hom(:,2,59,:) = SPREAD( zu, 2, statistic_regions+1 )
2352
2353          CASE ( 'upt_t' )
2354             dopr_index(i) = 60
2355             dopr_unit(i)  = 'K m/s'
2356             hom(:,2,60,:) = SPREAD( zu, 2, statistic_regions+1 )
2357
2358          CASE ( 'v"pt"' )
2359             dopr_index(i) = 61
2360             dopr_unit(i)  = 'K m/s'
2361             hom(:,2,61,:) = SPREAD( zu, 2, statistic_regions+1 )
2362             
2363          CASE ( 'v*pt*' )
2364             dopr_index(i) = 62
2365             dopr_unit(i)  = 'K m/s'
2366             hom(:,2,62,:) = SPREAD( zu, 2, statistic_regions+1 )
2367
2368          CASE ( 'vpt_t' )
2369             dopr_index(i) = 63
2370             dopr_unit(i)  = 'K m/s'
2371             hom(:,2,63,:) = SPREAD( zu, 2, statistic_regions+1 )
2372
2373          CASE ( 'rho' )
2374             IF ( .NOT. ocean ) THEN
2375                message_string = 'data_output_pr = ' // &
2376                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2377                                 'lemented for ocean = .FALSE.'
2378                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2379             ELSE
2380                dopr_index(i) = 64
2381                dopr_unit(i)  = 'kg/m3'
2382                hom(:,2,64,:) = SPREAD( zu, 2, statistic_regions+1 )
2383             ENDIF
2384
2385          CASE ( 'w"sa"' )
2386             IF ( .NOT. ocean ) THEN
2387                message_string = 'data_output_pr = ' // &
2388                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2389                                 'lemented for ocean = .FALSE.'
2390                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2391             ELSE
2392                dopr_index(i) = 65
2393                dopr_unit(i)  = 'psu m/s'
2394                hom(:,2,65,:) = SPREAD( zw, 2, statistic_regions+1 )
2395             ENDIF
2396
2397          CASE ( 'w*sa*' )
2398             IF ( .NOT. ocean ) THEN
2399                message_string = 'data_output_pr = ' // &
2400                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2401                                 'lemented for ocean = .FALSE.'
2402                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2403             ELSE
2404                dopr_index(i) = 66
2405                dopr_unit(i)  = 'psu m/s'
2406                hom(:,2,66,:) = SPREAD( zw, 2, statistic_regions+1 )
2407             ENDIF
2408
2409          CASE ( 'wsa' )
2410             IF ( .NOT. ocean ) THEN
2411                message_string = 'data_output_pr = ' // &
2412                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2413                                 'lemented for ocean = .FALSE.'
2414                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2415             ELSE
2416                dopr_index(i) = 67
2417                dopr_unit(i)  = 'psu m/s'
2418                hom(:,2,67,:) = SPREAD( zw, 2, statistic_regions+1 )
2419             ENDIF
2420
2421          CASE ( 'w*p*' )
2422             dopr_index(i) = 68
2423             dopr_unit(i)  = 'm3/s3'
2424             hom(:,2,68,:) = SPREAD( zu, 2, statistic_regions+1 )
2425
2426          CASE ( 'w"e' )
2427             dopr_index(i) = 69
2428             dopr_unit(i)  = 'm3/s3'
2429             hom(:,2,69,:) = SPREAD( zu, 2, statistic_regions+1 )
2430
2431          CASE ( 'q*2' )
2432             IF ( .NOT. humidity )  THEN
2433                message_string = 'data_output_pr = ' // &
2434                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2435                                 'lemented for humidity = .FALSE.'
2436                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2437             ELSE
2438                dopr_index(i) = 70
2439                dopr_unit(i)  = 'kg2/kg2'
2440                hom(:,2,70,:) = SPREAD( zu, 2, statistic_regions+1 )
2441             ENDIF
2442
2443          CASE ( 'prho' )
2444             IF ( .NOT. ocean ) THEN
2445                message_string = 'data_output_pr = ' // &
2446                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2447                                 'lemented for ocean = .FALSE.'
2448                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2449             ELSE
2450                dopr_index(i) = 71
2451                dopr_unit(i)  = 'kg/m3'
2452                hom(:,2,71,:) = SPREAD( zu, 2, statistic_regions+1 )
2453             ENDIF
2454
2455          CASE ( 'hyp' )
2456             dopr_index(i) = 72
2457             dopr_unit(i)  = 'dbar'
2458             hom(:,2,72,:) = SPREAD( zu, 2, statistic_regions+1 )
2459
2460          CASE DEFAULT
2461
2462             CALL user_check_data_output_pr( data_output_pr(i), i, unit )
2463
2464             IF ( unit == 'illegal' )  THEN
2465                IF ( data_output_pr_user(1) /= ' ' )  THEN
2466                   message_string = 'illegal value for data_output_pr or ' // &
2467                                    'data_output_pr_user = "' // &
2468                                    TRIM( data_output_pr(i) ) // '"'
2469                   CALL message( 'check_parameters', 'PA0097', 1, 2, 0, 6, 0 )
2470                ELSE
2471                   message_string = 'illegal value for data_output_pr = "' // &
2472                                    TRIM( data_output_pr(i) ) // '"'
2473                   CALL message( 'check_parameters', 'PA0098', 1, 2, 0, 6, 0 )
2474                ENDIF
2475             ENDIF
2476
2477       END SELECT
2478
2479    ENDDO
2480
2481
2482!
2483!-- Append user-defined data output variables to the standard data output
2484    IF ( data_output_user(1) /= ' ' )  THEN
2485       i = 1
2486       DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2487          i = i + 1
2488       ENDDO
2489       j = 1
2490       DO  WHILE ( data_output_user(j) /= ' '  .AND.  j <= 100 )
2491          IF ( i > 100 )  THEN
2492             message_string = 'number of output quantitities given by data' // &
2493                '_output and data_output_user exceeds the limit of 100'
2494             CALL message( 'check_parameters', 'PA0102', 1, 2, 0, 6, 0 )
2495          ENDIF
2496          data_output(i) = data_output_user(j)
2497          i = i + 1
2498          j = j + 1
2499       ENDDO
2500    ENDIF
2501
2502!
2503!-- Check and set steering parameters for 2d/3d data output and averaging
2504    i   = 1
2505    DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2506!
2507!--    Check for data averaging
2508       ilen = LEN_TRIM( data_output(i) )
2509       j = 0                                                 ! no data averaging
2510       IF ( ilen > 3 )  THEN
2511          IF ( data_output(i)(ilen-2:ilen) == '_av' )  THEN
2512             j = 1                                           ! data averaging
2513             data_output(i) = data_output(i)(1:ilen-3)
2514          ENDIF
2515       ENDIF
2516!
2517!--    Check for cross section or volume data
2518       ilen = LEN_TRIM( data_output(i) )
2519       k = 0                                                   ! 3d data
2520       var = data_output(i)(1:ilen)
2521       IF ( ilen > 3 )  THEN
2522          IF ( data_output(i)(ilen-2:ilen) == '_xy'  .OR. &
2523               data_output(i)(ilen-2:ilen) == '_xz'  .OR. &
2524               data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2525             k = 1                                             ! 2d data
2526             var = data_output(i)(1:ilen-3)
2527          ENDIF
2528       ENDIF
2529!
2530!--    Check for allowed value and set units
2531       SELECT CASE ( TRIM( var ) )
2532
2533          CASE ( 'e' )
2534             IF ( constant_diffusion )  THEN
2535                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2536                                 'res constant_diffusion = .FALSE.'
2537                CALL message( 'check_parameters', 'PA0103', 1, 2, 0, 6, 0 )
2538             ENDIF
2539             unit = 'm2/s2'
2540
2541          CASE ( 'lpt' )
2542             IF ( .NOT. cloud_physics )  THEN
2543                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2544                         'res cloud_physics = .TRUE.'
2545                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2546             ENDIF
2547             unit = 'K'
2548
2549          CASE ( 'pc', 'pr' )
2550             IF ( .NOT. particle_advection )  THEN
2551                message_string = 'output of "' // TRIM( var ) // '" requir' // &
2552                   'es a "particles_par"-NAMELIST in the parameter file (PARIN)'
2553                CALL message( 'check_parameters', 'PA0104', 1, 2, 0, 6, 0 )
2554             ENDIF
2555             IF ( TRIM( var ) == 'pc' )  unit = 'number'
2556             IF ( TRIM( var ) == 'pr' )  unit = 'm'
2557
2558          CASE ( 'q', 'vpt' )
2559             IF ( .NOT. humidity )  THEN
2560                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2561                                 'res humidity = .TRUE.'
2562                CALL message( 'check_parameters', 'PA0105', 1, 2, 0, 6, 0 )
2563             ENDIF
2564             IF ( TRIM( var ) == 'q'   )  unit = 'kg/kg'
2565             IF ( TRIM( var ) == 'vpt' )  unit = 'K'
2566
2567          CASE ( 'ql' )
2568             IF ( .NOT. ( cloud_physics  .OR.  cloud_droplets ) )  THEN
2569                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2570                         'res cloud_physics = .TRUE. or cloud_droplets = .TRUE.'
2571                CALL message( 'check_parameters', 'PA0106', 1, 2, 0, 6, 0 )
2572             ENDIF
2573             unit = 'kg/kg'
2574
2575          CASE ( 'ql_c', 'ql_v', 'ql_vp' )
2576             IF ( .NOT. cloud_droplets )  THEN
2577                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2578                                 'res cloud_droplets = .TRUE.'
2579                CALL message( 'check_parameters', 'PA0107', 1, 2, 0, 6, 0 )
2580             ENDIF
2581             IF ( TRIM( var ) == 'ql_c'  )  unit = 'kg/kg'
2582             IF ( TRIM( var ) == 'ql_v'  )  unit = 'm3'
2583             IF ( TRIM( var ) == 'ql_vp' )  unit = 'none'
2584
2585          CASE ( 'qv' )
2586             IF ( .NOT. cloud_physics )  THEN
2587                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2588                                 'res cloud_physics = .TRUE.'
2589                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2590             ENDIF
2591             unit = 'kg/kg'
2592
2593          CASE ( 'rho' )
2594             IF ( .NOT. ocean )  THEN
2595                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2596                                 'res ocean = .TRUE.'
2597                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2598             ENDIF
2599             unit = 'kg/m3'
2600
2601          CASE ( 's' )
2602             IF ( .NOT. passive_scalar )  THEN
2603                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2604                                 'res passive_scalar = .TRUE.'
2605                CALL message( 'check_parameters', 'PA0110', 1, 2, 0, 6, 0 )
2606             ENDIF
2607             unit = 'conc'
2608
2609          CASE ( 'sa' )
2610             IF ( .NOT. ocean )  THEN
2611                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2612                                 'res ocean = .TRUE.'
2613                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2614             ENDIF
2615             unit = 'psu'
2616
2617          CASE ( 'u*', 't*', 'lwp*', 'pra*', 'prr*', 'qsws*', 'shf*', 'z0*', 'z0h*' )
2618             IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
2619                message_string = 'illegal value for data_output: "' // &
2620                                 TRIM( var ) // '" & only 2d-horizontal ' // &
2621                                 'cross sections are allowed for this value'
2622                CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
2623             ENDIF
2624             IF ( TRIM( var ) == 'lwp*'  .AND.  .NOT. cloud_physics )  THEN
2625                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2626                                 'res cloud_physics = .TRUE.'
2627                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2628             ENDIF
2629             IF ( TRIM( var ) == 'pra*'  .AND.  .NOT. precipitation )  THEN
2630                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2631                                 'res precipitation = .TRUE.'
2632                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2633             ENDIF
2634             IF ( TRIM( var ) == 'pra*'  .AND.  j == 1 )  THEN
2635                message_string = 'temporal averaging of precipitation ' // &
2636                          'amount "' // TRIM( var ) // '" is not possible'
2637                CALL message( 'check_parameters', 'PA0113', 1, 2, 0, 6, 0 )
2638             ENDIF
2639             IF ( TRIM( var ) == 'prr*'  .AND.  .NOT. precipitation )  THEN
2640                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2641                                 'res precipitation = .TRUE.'
2642                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2643             ENDIF
2644             IF ( TRIM( var ) == 'qsws*'  .AND.  .NOT. humidity )  THEN
2645                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2646                                 'res humidity = .TRUE.'
2647                CALL message( 'check_parameters', 'PA0322', 1, 2, 0, 6, 0 )
2648             ENDIF
2649
2650             IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/kg*m'
2651             IF ( TRIM( var ) == 'pra*'   )  unit = 'mm'
2652             IF ( TRIM( var ) == 'prr*'   )  unit = 'mm/s'
2653             IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
2654             IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
2655             IF ( TRIM( var ) == 't*'     )  unit = 'K'
2656             IF ( TRIM( var ) == 'u*'     )  unit = 'm/s'
2657             IF ( TRIM( var ) == 'z0*'    )  unit = 'm'
2658             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm'
2659
2660
2661          CASE ( 'p', 'pt', 'u', 'v', 'w' )
2662             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
2663             IF ( TRIM( var ) == 'pt' )  unit = 'K'
2664             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
2665             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
2666             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
2667             CONTINUE
2668
2669          CASE DEFAULT
2670             CALL user_check_data_output( var, unit )
2671
2672             IF ( unit == 'illegal' )  THEN
2673                IF ( data_output_user(1) /= ' ' )  THEN
2674                   message_string = 'illegal value for data_output or ' // &
2675                         'data_output_user = "' // TRIM( data_output(i) ) // '"'
2676                   CALL message( 'check_parameters', 'PA0114', 1, 2, 0, 6, 0 )
2677                ELSE
2678                   message_string = 'illegal value for data_output =' // &
2679                                    TRIM( data_output(i) ) // '"'
2680                   CALL message( 'check_parameters', 'PA0115', 1, 2, 0, 6, 0 )
2681                ENDIF
2682             ENDIF
2683
2684       END SELECT
2685!
2686!--    Set the internal steering parameters appropriately
2687       IF ( k == 0 )  THEN
2688          do3d_no(j)              = do3d_no(j) + 1
2689          do3d(j,do3d_no(j))      = data_output(i)
2690          do3d_unit(j,do3d_no(j)) = unit
2691       ELSE
2692          do2d_no(j)              = do2d_no(j) + 1
2693          do2d(j,do2d_no(j))      = data_output(i)
2694          do2d_unit(j,do2d_no(j)) = unit
2695          IF ( data_output(i)(ilen-2:ilen) == '_xy' )  THEN
2696             data_output_xy(j) = .TRUE.
2697          ENDIF
2698          IF ( data_output(i)(ilen-2:ilen) == '_xz' )  THEN
2699             data_output_xz(j) = .TRUE.
2700          ENDIF
2701          IF ( data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2702             data_output_yz(j) = .TRUE.
2703          ENDIF
2704       ENDIF
2705
2706       IF ( j == 1 )  THEN
2707!
2708!--       Check, if variable is already subject to averaging
2709          found = .FALSE.
2710          DO  k = 1, doav_n
2711             IF ( TRIM( doav(k) ) == TRIM( var ) )  found = .TRUE.
2712          ENDDO
2713
2714          IF ( .NOT. found )  THEN
2715             doav_n = doav_n + 1
2716             doav(doav_n) = var
2717          ENDIF
2718       ENDIF
2719
2720       i = i + 1
2721    ENDDO
2722
2723!
2724!-- Averaged 2d or 3d output requires that an averaging interval has been set
2725    IF ( doav_n > 0  .AND.  averaging_interval == 0.0 )  THEN
2726       WRITE( message_string, * )  'output of averaged quantity "',            &
2727                                   TRIM( doav(1) ), '_av" requires to set a ', &
2728                                   'non-zero & averaging interval'
2729       CALL message( 'check_parameters', 'PA0323', 1, 2, 0, 6, 0 )
2730    ENDIF
2731
2732!
2733!-- Check sectional planes and store them in one shared array
2734    IF ( ANY( section_xy > nz + 1 ) )  THEN
2735       WRITE( message_string, * )  'section_xy must be <= nz + 1 = ', nz + 1
2736       CALL message( 'check_parameters', 'PA0319', 1, 2, 0, 6, 0 )
2737    ENDIF
2738    IF ( ANY( section_xz > ny + 1 ) )  THEN
2739       WRITE( message_string, * )  'section_xz must be <= ny + 1 = ', ny + 1
2740       CALL message( 'check_parameters', 'PA0320', 1, 2, 0, 6, 0 )
2741    ENDIF
2742    IF ( ANY( section_yz > nx + 1 ) )  THEN
2743       WRITE( message_string, * )  'section_yz must be <= nx + 1 = ', nx + 1
2744       CALL message( 'check_parameters', 'PA0321', 1, 2, 0, 6, 0 )
2745    ENDIF
2746    section(:,1) = section_xy
2747    section(:,2) = section_xz
2748    section(:,3) = section_yz
2749
2750!
2751!-- Upper plot limit for 2D vertical sections
2752    IF ( z_max_do2d == -1.0 )  z_max_do2d = zu(nzt)
2753    IF ( z_max_do2d < zu(nzb+1)  .OR.  z_max_do2d > zu(nzt) )  THEN
2754       WRITE( message_string, * )  'z_max_do2d = ', z_max_do2d, &
2755                    ' must be >= ', zu(nzb+1), '(zu(nzb+1)) and <= ', zu(nzt), &
2756                    ' (zu(nzt))'
2757       CALL message( 'check_parameters', 'PA0116', 1, 2, 0, 6, 0 )
2758    ENDIF
2759
2760!
2761!-- Upper plot limit for 3D arrays
2762    IF ( nz_do3d == -9999 )  nz_do3d = nzt + 1
2763
2764!
2765!-- Determine and check accuracy for compressed 3D plot output
2766    IF ( do3d_compress )  THEN
2767!
2768!--    Compression only permissible on T3E machines
2769       IF ( host(1:3) /= 't3e' )  THEN
2770          message_string = 'do3d_compress = .TRUE. not allowed on host "' // &
2771                           TRIM( host ) // '"'
2772          CALL message( 'check_parameters', 'PA0117', 1, 2, 0, 6, 0 )
2773       ENDIF
2774
2775       i = 1
2776       DO  WHILE ( do3d_comp_prec(i) /= ' ' )
2777
2778          ilen = LEN_TRIM( do3d_comp_prec(i) )
2779          IF ( LLT( do3d_comp_prec(i)(ilen:ilen), '0' ) .OR. &
2780               LGT( do3d_comp_prec(i)(ilen:ilen), '9' ) )  THEN
2781             WRITE( message_string, * )  'illegal precision: do3d_comp_prec', &
2782                                   '(', i, ') = "', TRIM(do3d_comp_prec(i)),'"'
2783             CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
2784          ENDIF
2785
2786          prec = IACHAR( do3d_comp_prec(i)(ilen:ilen) ) - IACHAR( '0' )
2787          var = do3d_comp_prec(i)(1:ilen-1)
2788
2789          SELECT CASE ( var )
2790
2791             CASE ( 'u' )
2792                j = 1
2793             CASE ( 'v' )
2794                j = 2
2795             CASE ( 'w' )
2796                j = 3
2797             CASE ( 'p' )
2798                j = 4
2799             CASE ( 'pt' )
2800                j = 5
2801
2802             CASE DEFAULT
2803                WRITE( message_string, * )  'unknown variable "', &
2804                     TRIM( do3d_comp_prec(i) ), '" given for do3d_comp_prec(', &
2805                     i, ')'
2806                CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
2807
2808          END SELECT
2809
2810          plot_3d_precision(j)%precision = prec
2811          i = i + 1
2812
2813       ENDDO
2814    ENDIF
2815
2816!
2817!-- Check the data output format(s)
2818    IF ( data_output_format(1) == ' ' )  THEN
2819!
2820!--    Default value
2821       netcdf_output = .TRUE.
2822    ELSE
2823       i = 1
2824       DO  WHILE ( data_output_format(i) /= ' ' )
2825
2826          SELECT CASE ( data_output_format(i) )
2827
2828             CASE ( 'netcdf' )
2829                netcdf_output = .TRUE.
2830             CASE ( 'iso2d' )
2831                iso2d_output  = .TRUE.
2832             CASE ( 'avs' )
2833                avs_output    = .TRUE.
2834
2835             CASE DEFAULT
2836                message_string = 'unknown value for data_output_format "' // &
2837                                 TRIM( data_output_format(i) ) // '"'
2838                CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
2839
2840          END SELECT
2841
2842          i = i + 1
2843          IF ( i > 10 )  EXIT
2844
2845       ENDDO
2846
2847    ENDIF
2848
2849!
2850!-- Check mask conditions
2851    DO mid = 1, max_masks
2852       IF ( data_output_masks(mid,1) /= ' ' .OR.   &
2853            data_output_masks_user(mid,1) /= ' ' ) THEN
2854          masks = masks + 1
2855       ENDIF
2856    ENDDO
2857   
2858    IF ( masks < 0 .OR. masks > max_masks )  THEN
2859       WRITE( message_string, * )  'illegal value: masks must be >= 0 and ', &
2860            '<= ', max_masks, ' (=max_masks)'
2861       CALL message( 'check_parameters', 'PA0325', 1, 2, 0, 6, 0 )
2862    ENDIF
2863    IF ( masks > 0 )  THEN
2864       mask_scale(1) = mask_scale_x
2865       mask_scale(2) = mask_scale_y
2866       mask_scale(3) = mask_scale_z
2867       IF ( ANY( mask_scale <= 0.0 ) )  THEN
2868          WRITE( message_string, * )  &
2869               'illegal value: mask_scale_x, mask_scale_y and mask_scale_z', &
2870               'must be > 0.0'
2871          CALL message( 'check_parameters', 'PA0326', 1, 2, 0, 6, 0 )
2872       ENDIF
2873!
2874!--    Generate masks for masked data output
2875       CALL init_masks
2876    ENDIF
2877
2878!
2879!-- Check the NetCDF data format
2880#if ! defined ( __check )
2881    IF ( netcdf_data_format > 2 )  THEN
2882#if defined( __netcdf4 )
2883       CONTINUE
2884#else
2885       message_string = 'NetCDF: NetCDF4 format requested but no ' // &
2886                        'cpp-directive __netcdf4 given & switch '  // &
2887                        'back to 64-bit offset format'
2888       CALL message( 'check_parameters', 'PA0171', 0, 1, 0, 6, 0 )
2889       netcdf_data_format = 2
2890#endif
2891    ENDIF
2892#endif
2893!
2894
2895#if ! defined( __check )
2896!-- Check netcdf precison
2897    ldum = .FALSE.
2898    CALL define_netcdf_header( 'ch', ldum, 0 )
2899#endif
2900!
2901!-- Check, whether a constant diffusion coefficient shall be used
2902    IF ( km_constant /= -1.0 )  THEN
2903       IF ( km_constant < 0.0 )  THEN
2904          WRITE( message_string, * )  'km_constant = ', km_constant, ' < 0.0'
2905          CALL message( 'check_parameters', 'PA0121', 1, 2, 0, 6, 0 )
2906       ELSE
2907          IF ( prandtl_number < 0.0 )  THEN
2908             WRITE( message_string, * )  'prandtl_number = ', prandtl_number, &
2909                                         ' < 0.0'
2910             CALL message( 'check_parameters', 'PA0122', 1, 2, 0, 6, 0 )
2911          ENDIF
2912          constant_diffusion = .TRUE.
2913
2914          IF ( prandtl_layer )  THEN
2915             message_string = 'prandtl_layer is not allowed with fixed ' // &
2916                              'value of km'
2917             CALL message( 'check_parameters', 'PA0123', 1, 2, 0, 6, 0 )
2918          ENDIF
2919       ENDIF
2920    ENDIF
2921
2922!
2923!-- In case of non-cyclic lateral boundaries and a damping layer for the
2924!-- potential temperature, check the width of the damping layer
2925    IF ( bc_lr /= 'cyclic' ) THEN
2926       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( nx * dx ) )  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    IF ( bc_ns /= 'cyclic' )  THEN
2933       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( ny * dy ) )  THEN
2934          message_string = 'pt_damping_width out of range'
2935          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
2936       ENDIF
2937    ENDIF
2938
2939!
2940!-- Check value range for rif
2941    IF ( rif_min >= rif_max )  THEN
2942       WRITE( message_string, * )  'rif_min = ', rif_min, ' must be less ', &
2943                                   'than rif_max = ', rif_max
2944       CALL message( 'check_parameters', 'PA0125', 1, 2, 0, 6, 0 )
2945    ENDIF
2946
2947!
2948!-- Determine upper and lower hight level indices for random perturbations
2949    IF ( disturbance_level_b == -9999999.9 )  THEN
2950       IF ( ocean ) THEN
2951          disturbance_level_b     = zu((nzt*2)/3)
2952          disturbance_level_ind_b = ( nzt * 2 ) / 3
2953       ELSE
2954          disturbance_level_b     = zu(nzb+3)
2955          disturbance_level_ind_b = nzb + 3
2956       ENDIF
2957    ELSEIF ( disturbance_level_b < zu(3) )  THEN
2958       WRITE( message_string, * )  'disturbance_level_b = ', &
2959                           disturbance_level_b, ' must be >= ', zu(3), '(zu(3))'
2960       CALL message( 'check_parameters', 'PA0126', 1, 2, 0, 6, 0 )
2961    ELSEIF ( disturbance_level_b > zu(nzt-2) )  THEN
2962       WRITE( message_string, * )  'disturbance_level_b = ', &
2963                   disturbance_level_b, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
2964       CALL message( 'check_parameters', 'PA0127', 1, 2, 0, 6, 0 )
2965    ELSE
2966       DO  k = 3, nzt-2
2967          IF ( disturbance_level_b <= zu(k) )  THEN
2968             disturbance_level_ind_b = k
2969             EXIT
2970          ENDIF
2971       ENDDO
2972    ENDIF
2973
2974    IF ( disturbance_level_t == -9999999.9 )  THEN
2975       IF ( ocean )  THEN
2976          disturbance_level_t     = zu(nzt-3)
2977          disturbance_level_ind_t = nzt - 3
2978       ELSE
2979          disturbance_level_t     = zu(nzt/3)
2980          disturbance_level_ind_t = nzt / 3
2981       ENDIF
2982    ELSEIF ( disturbance_level_t > zu(nzt-2) )  THEN
2983       WRITE( message_string, * )  'disturbance_level_t = ', &
2984                   disturbance_level_t, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
2985       CALL message( 'check_parameters', 'PA0128', 1, 2, 0, 6, 0 )
2986    ELSEIF ( disturbance_level_t < disturbance_level_b )  THEN
2987       WRITE( message_string, * )  'disturbance_level_t = ', &
2988                   disturbance_level_t, ' must be >= disturbance_level_b = ', &
2989                   disturbance_level_b
2990       CALL message( 'check_parameters', 'PA0129', 1, 2, 0, 6, 0 )
2991    ELSE
2992       DO  k = 3, nzt-2
2993          IF ( disturbance_level_t <= zu(k) )  THEN
2994             disturbance_level_ind_t = k
2995             EXIT
2996          ENDIF
2997       ENDDO
2998    ENDIF
2999
3000!
3001!-- Check again whether the levels determined this way are ok.
3002!-- Error may occur at automatic determination and too few grid points in
3003!-- z-direction.
3004    IF ( disturbance_level_ind_t < disturbance_level_ind_b )  THEN
3005       WRITE( message_string, * )  'disturbance_level_ind_t = ', &
3006                disturbance_level_ind_t, ' must be >= disturbance_level_b = ', &
3007                disturbance_level_b
3008       CALL message( 'check_parameters', 'PA0130', 1, 2, 0, 6, 0 )
3009    ENDIF
3010
3011!
3012!-- Determine the horizontal index range for random perturbations.
3013!-- In case of non-cyclic horizontal boundaries, no perturbations are imposed
3014!-- near the inflow and the perturbation area is further limited to ...(1)
3015!-- after the initial phase of the flow.
3016    dist_nxl = 0;  dist_nxr = nx
3017    dist_nys = 0;  dist_nyn = ny
3018    IF ( bc_lr /= 'cyclic' )  THEN
3019       IF ( inflow_disturbance_begin == -1 )  THEN
3020          inflow_disturbance_begin = MIN( 10, nx/2 )
3021       ENDIF
3022       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > nx )&
3023       THEN
3024          message_string = 'inflow_disturbance_begin out of range'
3025          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3026       ENDIF
3027       IF ( inflow_disturbance_end == -1 )  THEN
3028          inflow_disturbance_end = MIN( 100, 3*nx/4 )
3029       ENDIF
3030       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > nx )    &
3031       THEN
3032          message_string = 'inflow_disturbance_end out of range'
3033          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3034       ENDIF
3035    ELSEIF ( bc_ns /= 'cyclic' )  THEN
3036       IF ( inflow_disturbance_begin == -1 )  THEN
3037          inflow_disturbance_begin = MIN( 10, ny/2 )
3038       ENDIF
3039       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > ny )&
3040       THEN
3041          message_string = 'inflow_disturbance_begin out of range'
3042          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3043       ENDIF
3044       IF ( inflow_disturbance_end == -1 )  THEN
3045          inflow_disturbance_end = MIN( 100, 3*ny/4 )
3046       ENDIF
3047       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > ny )    &
3048       THEN
3049          message_string = 'inflow_disturbance_end out of range'
3050          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3051       ENDIF
3052    ENDIF
3053
3054    IF ( bc_lr == 'radiation/dirichlet' .OR. bc_lr == 'neumann/dirichlet' )  THEN
3055       dist_nxr    = nx - inflow_disturbance_begin
3056       dist_nxl(1) = nx - inflow_disturbance_end
3057    ELSEIF ( bc_lr == 'dirichlet/radiation' .OR. bc_lr == 'dirichlet/neumann' )  THEN
3058       dist_nxl    = inflow_disturbance_begin
3059       dist_nxr(1) = inflow_disturbance_end
3060    ENDIF
3061    IF ( bc_ns == 'dirichlet/radiation' .OR. bc_ns == 'dirichlet/neumann' )  THEN
3062       dist_nyn    = ny - inflow_disturbance_begin
3063       dist_nys(1) = ny - inflow_disturbance_end
3064    ELSEIF ( bc_ns == 'radiation/dirichlet' .OR. bc_ns == 'neumann/dirichlet' )  THEN
3065       dist_nys    = inflow_disturbance_begin
3066       dist_nyn(1) = inflow_disturbance_end
3067    ENDIF
3068
3069!
3070!-- A turbulent inflow requires Dirichlet conditions at the respective inflow
3071!-- boundary (so far, a turbulent inflow is realized from the left side only)
3072    IF ( turbulent_inflow  .AND.  bc_lr /= 'dirichlet/radiation' .AND.  bc_lr /= 'dirichlet/neumann' )  THEN
3073       message_string = 'turbulent_inflow = .T. requires a Dirichlet ' // &
3074                        'condition at the inflow boundary'
3075       CALL message( 'check_parameters', 'PA0133', 1, 2, 0, 6, 0 )
3076    ENDIF
3077
3078!
3079!-- In case of turbulent inflow calculate the index of the recycling plane
3080    IF ( turbulent_inflow )  THEN
3081       IF ( recycling_width == 9999999.9 )  THEN
3082!
3083!--       Set the default value for the width of the recycling domain
3084          recycling_width = 0.1 * nx * dx
3085       ELSE
3086          IF ( recycling_width < dx  .OR.  recycling_width > nx * dx )  THEN
3087             WRITE( message_string, * )  'illegal value for recycling_width:', &
3088                                         ' ', recycling_width
3089             CALL message( 'check_parameters', 'PA0134', 1, 2, 0, 6, 0 )
3090          ENDIF
3091       ENDIF
3092!
3093!--    Calculate the index
3094       recycling_plane = recycling_width / dx
3095    ENDIF
3096
3097!
3098!-- Check random generator
3099    IF ( random_generator /= 'system-specific'  .AND. &
3100         random_generator /= 'numerical-recipes' )  THEN
3101       message_string = 'unknown random generator: random_generator = "' // &
3102                        TRIM( random_generator ) // '"'
3103       CALL message( 'check_parameters', 'PA0135', 1, 2, 0, 6, 0 )
3104    ENDIF
3105
3106!
3107!-- Determine damping level index for 1D model
3108    IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
3109       IF ( damp_level_1d == -1.0 )  THEN
3110          damp_level_1d     = zu(nzt+1)
3111          damp_level_ind_1d = nzt + 1
3112       ELSEIF ( damp_level_1d < 0.0  .OR.  damp_level_1d > zu(nzt+1) )  THEN
3113          WRITE( message_string, * )  'damp_level_1d = ', damp_level_1d, &
3114                 ' must be > 0.0 and < ', zu(nzt+1), '(zu(nzt+1))'
3115          CALL message( 'check_parameters', 'PA0136', 1, 2, 0, 6, 0 )
3116       ELSE
3117          DO  k = 1, nzt+1
3118             IF ( damp_level_1d <= zu(k) )  THEN
3119                damp_level_ind_1d = k
3120                EXIT
3121             ENDIF
3122          ENDDO
3123       ENDIF
3124    ENDIF
3125
3126!
3127!-- Check some other 1d-model parameters
3128    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND. &
3129         TRIM( mixing_length_1d ) /= 'blackadar' )  THEN
3130       message_string = 'mixing_length_1d = "' // TRIM( mixing_length_1d ) // &
3131                        '" is unknown'
3132       CALL message( 'check_parameters', 'PA0137', 1, 2, 0, 6, 0 )
3133    ENDIF
3134    IF ( TRIM( dissipation_1d ) /= 'as_in_3d_model'  .AND. &
3135         TRIM( dissipation_1d ) /= 'detering' )  THEN
3136       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) // &
3137                        '" is unknown'
3138       CALL message( 'check_parameters', 'PA0138', 1, 2, 0, 6, 0 )
3139    ENDIF
3140
3141!
3142!-- Set time for the next user defined restart (time_restart is the
3143!-- internal parameter for steering restart events)
3144    IF ( restart_time /= 9999999.9 )  THEN
3145       IF ( restart_time > time_since_reference_point )  THEN
3146          time_restart = restart_time
3147       ENDIF
3148    ELSE
3149!
3150!--    In case of a restart run, set internal parameter to default (no restart)
3151!--    if the NAMELIST-parameter restart_time is omitted
3152       time_restart = 9999999.9
3153    ENDIF
3154
3155!
3156!-- Set default value of the time needed to terminate a model run
3157    IF ( termination_time_needed == -1.0 )  THEN
3158       IF ( host(1:3) == 'ibm' )  THEN
3159          termination_time_needed = 300.0
3160       ELSE
3161          termination_time_needed = 35.0
3162       ENDIF
3163    ENDIF
3164
3165!
3166!-- Check the time needed to terminate a model run
3167    IF ( host(1:3) == 't3e' )  THEN
3168!
3169!--    Time needed must be at least 30 seconds on all CRAY machines, because
3170!--    MPP_TREMAIN gives the remaining CPU time only in steps of 30 seconds
3171       IF ( termination_time_needed <= 30.0 )  THEN
3172          WRITE( message_string, * )  'termination_time_needed = ', &
3173                 termination_time_needed, ' must be > 30.0 on host "', &
3174                 TRIM( host ), '"'
3175          CALL message( 'check_parameters', 'PA0139', 1, 2, 0, 6, 0 )
3176       ENDIF
3177    ELSEIF ( host(1:3) == 'ibm' )  THEN
3178!
3179!--    On IBM-regatta machines the time should be at least 300 seconds,
3180!--    because the job time consumed before executing palm (for compiling,
3181!--    copying of files, etc.) has to be regarded
3182       IF ( termination_time_needed < 300.0 )  THEN
3183          WRITE( message_string, * )  'termination_time_needed = ', &
3184                 termination_time_needed, ' should be >= 300.0 on host "', &
3185                 TRIM( host ), '"'
3186          CALL message( 'check_parameters', 'PA0140', 1, 2, 0, 6, 0 )
3187       ENDIF
3188    ENDIF
3189
3190!
3191!-- Check pressure gradient conditions
3192    IF ( dp_external .AND. conserve_volume_flow )  THEN
3193       WRITE( message_string, * )  'Both dp_external and conserve_volume_flo', &
3194            'w are .TRUE. but one of them must be .FALSE.'
3195       CALL message( 'check_parameters', 'PA0150', 1, 2, 0, 6, 0 )
3196    ENDIF
3197    IF ( dp_external )  THEN
3198       IF ( dp_level_b < zu(nzb) .OR. dp_level_b > zu(nzt) )  THEN
3199          WRITE( message_string, * )  'dp_level_b = ', dp_level_b, ' is out ', &
3200               ' of range'
3201          CALL message( 'check_parameters', 'PA0151', 1, 2, 0, 6, 0 )
3202       ENDIF
3203       IF ( .NOT. ANY( dpdxy /= 0.0 ) )  THEN
3204          WRITE( message_string, * )  'dp_external is .TRUE. but dpdxy is ze', &
3205               'ro, i.e. the external pressure gradient & will not be applied'
3206          CALL message( 'check_parameters', 'PA0152', 0, 1, 0, 6, 0 )
3207       ENDIF
3208    ENDIF
3209    IF ( ANY( dpdxy /= 0.0 ) .AND. .NOT. dp_external )  THEN
3210       WRITE( message_string, * )  'dpdxy is nonzero but dp_external is ', &
3211            '.FALSE., i.e. the external pressure gradient & will not be applied'
3212       CALL message( 'check_parameters', 'PA0153', 0, 1, 0, 6, 0 )
3213    ENDIF
3214    IF ( conserve_volume_flow )  THEN
3215       IF ( TRIM( conserve_volume_flow_mode ) == 'default' )  THEN
3216
3217          conserve_volume_flow_mode = 'initial_profiles'
3218
3219       ELSEIF ( TRIM( conserve_volume_flow_mode ) /= 'initial_profiles' .AND.  &
3220            TRIM( conserve_volume_flow_mode ) /= 'inflow_profile' .AND.  &
3221            TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' )  THEN
3222          WRITE( message_string, * )  'unknown conserve_volume_flow_mode: ', &
3223               conserve_volume_flow_mode
3224          CALL message( 'check_parameters', 'PA0154', 1, 2, 0, 6, 0 )
3225       ENDIF
3226       IF ( (bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic')  .AND. &
3227          TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
3228          WRITE( message_string, * )  'non-cyclic boundary conditions ', &
3229               'require  conserve_volume_flow_mode = ''initial_profiles'''
3230          CALL message( 'check_parameters', 'PA0155', 1, 2, 0, 6, 0 )
3231       ENDIF
3232       IF ( bc_lr == 'cyclic'  .AND.  bc_ns == 'cyclic'  .AND.  &
3233            TRIM( conserve_volume_flow_mode ) == 'inflow_profile' )  THEN
3234          WRITE( message_string, * )  'cyclic boundary conditions ', &
3235               'require conserve_volume_flow_mode = ''initial_profiles''', &
3236               ' or ''bulk_velocity'''
3237          CALL message( 'check_parameters', 'PA0156', 1, 2, 0, 6, 0 )
3238       ENDIF
3239    ENDIF
3240    IF ( ( u_bulk /= 0.0 .OR. v_bulk /= 0.0 ) .AND.  &
3241         ( .NOT. conserve_volume_flow .OR.  &
3242         TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' ) )  THEN
3243       WRITE( message_string, * )  'nonzero bulk velocity requires ', &
3244            'conserve_volume_flow = .T. and ', &
3245            'conserve_volume_flow_mode = ''bulk_velocity'''
3246       CALL message( 'check_parameters', 'PA0157', 1, 2, 0, 6, 0 )
3247    ENDIF
3248
3249!
3250!-- Check particle attributes
3251    IF ( particle_color /= 'none' )  THEN
3252       IF ( particle_color /= 'absuv'  .AND.  particle_color /= 'pt*'  .AND.  &
3253            particle_color /= 'z' )  THEN
3254          message_string = 'illegal value for parameter particle_color: ' // &
3255                           TRIM( particle_color)
3256          CALL message( 'check_parameters', 'PA0313', 1, 2, 0, 6, 0 )
3257       ELSE
3258          IF ( color_interval(2) <= color_interval(1) )  THEN
3259             message_string = 'color_interval(2) <= color_interval(1)'
3260             CALL message( 'check_parameters', 'PA0315', 1, 2, 0, 6, 0 )
3261          ENDIF
3262       ENDIF
3263    ENDIF
3264
3265    IF ( particle_dvrpsize /= 'none' )  THEN
3266       IF ( particle_dvrpsize /= 'absw' )  THEN
3267          message_string = 'illegal value for parameter particle_dvrpsize:' // &
3268                           ' ' // TRIM( particle_color)
3269          CALL message( 'check_parameters', 'PA0314', 1, 2, 0, 6, 0 )
3270       ELSE
3271          IF ( dvrpsize_interval(2) <= dvrpsize_interval(1) )  THEN
3272             message_string = 'dvrpsize_interval(2) <= dvrpsize_interval(1)'
3273             CALL message( 'check_parameters', 'PA0316', 1, 2, 0, 6, 0 )
3274          ENDIF
3275       ENDIF
3276    ENDIF
3277
3278!
3279!-- Check &userpar parameters
3280    CALL user_check_parameters
3281
3282
3283
3284 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.