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

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

netCDF4 without parallel file support implemented
additional define string netcdf4_parallel is required to switch on parallel file support

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