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

Last change on this file since 1060 was 1060, checked in by raasch, 11 years ago

additional check for parameter turbulent_inflow

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