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

Last change on this file since 1036 was 1036, checked in by raasch, 12 years ago

code has been put under the GNU General Public License (v3)

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