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

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

last commit documented

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