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

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

New:
---

GPU porting of pres, swap_timelevel. Adjustments of openACC directives.
Further porting of poisfft, which now runs completely on GPU without any
host/device data transfer for serial an parallel runs (but parallel runs
require data transfer before and after the MPI transpositions).
GPU-porting of tridiagonal solver:
tridiagonal routines split into extermal subroutines (instead using CONTAINS),
no distinction between parallel/non-parallel in poisfft and tridia any more,
tridia routines moved to end of file because of probable bug in PGI compiler
(otherwise "invalid device function" is indicated during runtime).
(cuda_fft_interfaces, fft_xy, flow_statistics, init_3d_model, palm, poisfft, pres, prognostic_equations, swap_timelevel, time_integration, transpose)
output of accelerator board information. (header)

optimization of tridia routines: constant elements and coefficients of tri are
stored in seperate arrays ddzuw and tric, last dimension of tri reduced from 5 to 2,
(init_grid, init_3d_model, modules, palm, poisfft)

poisfft_init is now called internally from poisfft,
(Makefile, Makefile_check, init_pegrid, poisfft, poisfft_hybrid)

CPU-time per grid point and timestep is output to CPU_MEASURES file
(cpu_statistics, modules, time_integration)

Changed:


resorting from/to array work changed, work now has 4 dimensions instead of 1 (transpose)
array diss allocated only if required (init_3d_model)

pressure boundary condition "Neumann+inhomo" removed from the code
(check_parameters, header, poisfft, poisfft_hybrid, pres)

Errors:


bugfix: dependency added for cuda_fft_interfaces (Makefile)
bugfix: CUDA fft plans adjusted for domain decomposition (before they always
used total domain) (fft_xy)

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