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

Last change on this file since 366 was 366, checked in by raasch, 15 years ago

speed optomizations +bugfix in init_ocean

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