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

Last change on this file since 367 was 367, checked in by maronga, 15 years ago

adapted for machine lck

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