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

Last change on this file since 1242 was 1242, checked in by heinze, 10 years ago

Last commmit documented

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