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

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

last version documented

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