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

Last change on this file since 1054 was 1054, checked in by hoffmann, 11 years ago

last commit documented

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