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

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

precompilation mechanism completely revised: now one depository per configuration block, further change of output messages

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