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

Last change on this file since 979 was 979, checked in by fricke, 12 years ago

last commit documented

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