source: palm/tags/release-3.9/SOURCE/check_parameters.f90 @ 4095

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

last commit documented

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