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

Last change on this file since 1175 was 1175, checked in by gryschka, 11 years ago

last commit documented

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