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

Last change on this file since 1159 was 1159, checked in by fricke, 11 years ago

Bugfix: In case of non-cyclic lateral boundary conditions, Neumann boundary conditions for the velocity components at the outflow are in fact radiation boundary conditions using the maximum phase velocity that ensures numerical stability (CFL-condition).
Logical operator use_cmax is now used instead of bc_lr_dirneu/_neudir.

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