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

Last change on this file since 151 was 151, checked in by raasch, 16 years ago

preliminary update for the turbulence recycling method

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