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

Last change on this file since 1077 was 1070, checked in by maronga, 11 years ago

last commit documented

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