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

Last change on this file since 116 was 116, checked in by raasch, 17 years ago

further preliminary updates concerning particle sorting and documentation

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