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

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

routines for nudging and large scale forcing from external file added

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