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

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

last commit documented

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