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

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