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

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

unused variables remove from several routines

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