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

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

changes for coupling with independent precursor runs; z_i calculation with Sullivan criterion

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