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

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

small bugfixes; mrun and subjob scripts are made bash compatible; further adjustments for lckyuh

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