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

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

Bugfix in calculation of u_init and v_init for ocean runs

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