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

Last change on this file since 1323 was 1323, checked in by raasch, 10 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 143.7 KB
Line 
1 SUBROUTINE check_parameters
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: check_parameters.f90 1323 2014-03-20 17:09:54Z raasch $
27!
28! 1322 2014-03-20 16:38:49Z raasch
29! some REAL constants defined as wp-kind
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! Kind-parameters added to all INTEGER and REAL declaration statements,
33! kinds are defined in new module kinds,
34! revision history before 2012 removed,
35! comment fields (!:) to be used for variable explanations added to
36! all variable declaration statements
37!
38! 1308 2014-03-13 14:58:42Z fricke
39! +netcdf_data_format_save
40! Calculate fixed number of output time levels for parallel netcdf output.
41! For masked data, parallel netcdf output is not tested so far, hence
42! netcdf_data_format is switched back to non-paralell output.
43!
44! 1299 2014-03-06 13:15:21Z heinze
45! enable usage of large_scale subsidence in combination with large_scale_forcing
46! output for profile of large scale vertical velocity w_subs added
47!
48! 1276 2014-01-15 13:40:41Z heinze
49! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars
50!
51! 1241 2013-10-30 11:36:58Z heinze
52! output for profiles of ug and vg added
53! set surface_heatflux and surface_waterflux also in dependence on
54! large_scale_forcing
55! checks for nudging and large scale forcing from external file
56!
57! 1236 2013-09-27 07:21:13Z raasch
58! check number of spectra levels
59!
60! 1216 2013-08-26 09:31:42Z raasch
61! check for transpose_compute_overlap (temporary)
62!
63! 1214 2013-08-21 12:29:17Z kanani
64! additional check for simultaneous use of vertical grid stretching
65! and particle advection
66!
67! 1212 2013-08-15 08:46:27Z raasch
68! checks for poisfft_hybrid removed
69!
70! 1210 2013-08-14 10:58:20Z raasch
71! check for fftw
72!
73! 1179 2013-06-14 05:57:58Z raasch
74! checks and settings of buoyancy parameters and switches revised,
75! initial profile for rho added to hom (id=77)
76!
77! 1174 2013-05-31 10:28:08Z gryschka
78! Bugfix in computing initial profiles for ug, vg, lad, q in case of Atmosphere
79!
80! 1159 2013-05-21 11:58:22Z fricke
81! bc_lr/ns_dirneu/neudir removed
82!
83! 1115 2013-03-26 18:16:16Z hoffmann
84! unused variables removed
85! drizzle can be used without precipitation
86!
87! 1111 2013-03-08 23:54:10Z raasch
88! ibc_p_b = 2 removed
89!
90! 1103 2013-02-20 02:15:53Z raasch
91! Bugfix: turbulent inflow must not require cyclic fill in restart runs
92!
93! 1092 2013-02-02 11:24:22Z raasch
94! unused variables removed
95!
96! 1069 2012-11-28 16:18:43Z maronga
97! allow usage of topography in combination with cloud physics
98!
99! 1065 2012-11-22 17:42:36Z hoffmann
100! Bugfix: It is not allowed to use cloud_scheme = seifert_beheng without
101!         precipitation in order to save computational resources.
102!
103! 1060 2012-11-21 07:19:51Z raasch
104! additional check for parameter turbulent_inflow
105!
106! 1053 2012-11-13 17:11:03Z hoffmann
107! necessary changes for the new two-moment cloud physics scheme added:
108! - check cloud physics scheme (Kessler or Seifert and Beheng)
109! - plant_canopy is not allowed
110! - currently, only cache loop_optimization is allowed
111! - initial profiles of nr, qr
112! - boundary condition of nr, qr
113! - check output quantities (qr, nr, prr)
114!
115! 1036 2012-10-22 13:43:42Z raasch
116! code put under GPL (PALM 3.9)
117!
118! 1031/1034 2012-10-22 11:32:49Z raasch
119! check of netcdf4 parallel file support
120!
121! 1019 2012-09-28 06:46:45Z raasch
122! non-optimized version of prognostic_equations not allowed any more
123!
124! 1015 2012-09-27 09:23:24Z raasch
125! acc allowed for loop optimization,
126! checks for adjustment of mixing length to the Prandtl mixing length removed
127!
128! 1003 2012-09-14 14:35:53Z raasch
129! checks for cases with unequal subdomain sizes removed
130!
131! 1001 2012-09-13 14:08:46Z raasch
132! all actions concerning leapfrog- and upstream-spline-scheme removed
133!
134! 996 2012-09-07 10:41:47Z raasch
135! little reformatting
136
137! 978 2012-08-09 08:28:32Z fricke
138! setting of bc_lr/ns_dirneu/neudir
139! outflow damping layer removed
140! check for z0h*
141! check for pt_damping_width
142!
143! 964 2012-07-26 09:14:24Z raasch
144! check of old profil-parameters removed
145!
146! 940 2012-07-09 14:31:00Z raasch
147! checks for parameter neutral
148!
149! 924 2012-06-06 07:44:41Z maronga
150! Bugfix: preprocessor directives caused error during compilation
151!
152! 892 2012-05-02 13:51:44Z maronga
153! Bugfix for parameter file check ( excluding __netcdf4 )
154!
155! 866 2012-03-28 06:44:41Z raasch
156! use only 60% of the geostrophic wind as translation speed in case of Galilean
157! transformation and use_ug_for_galilei_tr = .T. in order to mimimize the
158! timestep
159!
160! 861 2012-03-26 14:18:34Z suehring
161! Check for topography and ws-scheme removed.
162! Check for loop_optimization = 'vector' and ws-scheme removed.
163!
164! 845 2012-03-07 10:23:05Z maronga
165! Bugfix: exclude __netcdf4 directive part from namelist file check compilation
166!
167! 828 2012-02-21 12:00:36Z raasch
168! check of collision_kernel extended
169!
170! 825 2012-02-19 03:03:44Z raasch
171! check for collision_kernel and curvature_solution_effects
172!
173! 809 2012-01-30 13:32:58Z maronga
174! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
175!
176! 807 2012-01-25 11:53:51Z maronga
177! New cpp directive "__check" implemented which is used by check_namelist_files
178!
179! Revision 1.1  1997/08/26 06:29:23  raasch
180! Initial revision
181!
182!
183! Description:
184! ------------
185! Check control parameters and deduce further quantities.
186!------------------------------------------------------------------------------!
187
188    USE arrays_3d
189    USE cloud_parameters
190    USE constants
191    USE control_parameters
192    USE dvrp_variables
193    USE grid_variables
194    USE indices
195    USE kinds
196    USE model_1d
197    USE netcdf_control
198    USE particle_attributes
199    USE pegrid
200    USE profil_parameter
201    USE spectrum
202    USE statistics
203    USE subsidence_mod
204    USE statistics
205    USE transpose_indices
206
207    IMPLICIT NONE
208
209    CHARACTER (LEN=1)   ::  sq                       !:
210    CHARACTER (LEN=6)   ::  var                      !:
211    CHARACTER (LEN=7)   ::  unit                     !:
212    CHARACTER (LEN=8)   ::  date                     !:
213    CHARACTER (LEN=10)  ::  time                     !:
214    CHARACTER (LEN=40)  ::  coupling_string          !:
215    CHARACTER (LEN=100) ::  action                   !:
216
217    INTEGER(iwp) ::  i                               !:
218    INTEGER(iwp) ::  ilen                            !:
219    INTEGER(iwp) ::  iremote = 0                     !:
220    INTEGER(iwp) ::  j                               !:
221    INTEGER(iwp) ::  k                               !:
222    INTEGER(iwp) ::  kk                              !:
223    INTEGER(iwp) ::  netcdf_data_format_save         !:
224    INTEGER(iwp) ::  position                        !:
225    INTEGER(iwp) ::  prec                            !:
226   
227    LOGICAL     ::  found                            !:
228    LOGICAL     ::  ldum                             !:
229   
230    REAL(wp)    ::  gradient                         !:
231    REAL(wp)    ::  remote = 0.0                     !:
232    REAL(wp)    ::  simulation_time_since_reference  !:
233
234!
235!-- Check for overlap combinations, which are not realized yet
236    IF ( transpose_compute_overlap )  THEN
237       IF ( numprocs == 1 )  STOP '+++ transpose-compute-overlap not implemented for single PE runs'
238#if defined( __openacc )
239       STOP '+++ transpose-compute-overlap not implemented for GPU usage'
240#endif
241    ENDIF
242
243!
244!-- Warning, if host is not set
245    IF ( host(1:1) == ' ' )  THEN
246       message_string = '"host" is not set. Please check that environment ' // &
247                        'variable "localhost" & is set before running PALM'
248       CALL message( 'check_parameters', 'PA0001', 0, 0, 0, 6, 0 )
249    ENDIF
250
251!
252!-- Check the coupling mode
253    IF ( coupling_mode /= 'uncoupled'            .AND.  &
254         coupling_mode /= 'atmosphere_to_ocean'  .AND.  &
255         coupling_mode /= 'ocean_to_atmosphere' )  THEN
256       message_string = 'illegal coupling mode: ' // TRIM( coupling_mode )
257       CALL message( 'check_parameters', 'PA0002', 1, 2, 0, 6, 0 )
258    ENDIF
259
260!
261!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
262    IF ( coupling_mode /= 'uncoupled')  THEN
263
264       IF ( dt_coupling == 9999999.9_wp )  THEN
265          message_string = 'dt_coupling is not set but required for coup' // &
266                           'ling mode "' //  TRIM( coupling_mode ) // '"'
267          CALL message( 'check_parameters', 'PA0003', 1, 2, 0, 6, 0 )
268       ENDIF
269
270#if defined( __parallel )
271
272!
273!--    NOTE: coupled runs have not been implemented in the check_namelist_files
274!--    program.
275!--    check_namelist_files will need the following information of the other
276!--    model (atmosphere/ocean).
277!       dt_coupling = remote
278!       dt_max = remote
279!       restart_time = remote
280!       dt_restart= remote
281!       simulation_time_since_reference = remote
282!       dx = remote
283
284
285#if ! defined( __check )
286       IF ( myid == 0 ) THEN
287          CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, &
288                         ierr )
289          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 11, comm_inter, &
290                         status, ierr )
291       ENDIF
292       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
293#endif     
294       IF ( dt_coupling /= remote )  THEN
295          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
296                 '": dt_coupling = ', dt_coupling, '& is not equal to ',       &
297                 'dt_coupling_remote = ', remote
298          CALL message( 'check_parameters', 'PA0004', 1, 2, 0, 6, 0 )
299       ENDIF
300       IF ( dt_coupling <= 0.0 )  THEN
301#if ! defined( __check )
302          IF ( myid == 0  ) THEN
303             CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
304             CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 19, comm_inter, &
305                            status, ierr )
306          ENDIF   
307          CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
308#endif         
309          dt_coupling = MAX( dt_max, remote )
310          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
311                 '": dt_coupling <= 0.0 & is not allowed and is reset to ',    &
312                 'MAX(dt_max(A,O)) = ', dt_coupling
313          CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
314       ENDIF
315#if ! defined( __check )
316       IF ( myid == 0 ) THEN
317          CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, &
318                         ierr )
319          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 12, comm_inter, &
320                         status, ierr )
321       ENDIF
322       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
323#endif     
324       IF ( restart_time /= remote )  THEN
325          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
326                 '": restart_time = ', restart_time, '& is not equal to ',     &
327                 'restart_time_remote = ', remote
328          CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
329       ENDIF
330#if ! defined( __check )
331       IF ( myid == 0 ) THEN
332          CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, &
333                         ierr )
334          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 13, comm_inter, &
335                         status, ierr )
336       ENDIF   
337       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
338#endif     
339       IF ( dt_restart /= remote )  THEN
340          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
341                 '": dt_restart = ', dt_restart, '& is not equal to ',         &
342                 'dt_restart_remote = ', remote
343          CALL message( 'check_parameters', 'PA0007', 1, 2, 0, 6, 0 )
344       ENDIF
345
346       simulation_time_since_reference = end_time - coupling_start_time
347#if ! defined( __check )
348       IF  ( myid == 0 ) THEN
349          CALL MPI_SEND( simulation_time_since_reference, 1, MPI_REAL, target_id, &
350                         14, comm_inter, ierr )
351          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 14, comm_inter, &
352                         status, ierr )   
353       ENDIF
354       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
355#endif     
356       IF ( simulation_time_since_reference /= remote )  THEN
357          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
358                 '": simulation_time_since_reference = ',                      &
359                 simulation_time_since_reference, '& is not equal to ',        &
360                 'simulation_time_since_reference_remote = ', remote
361          CALL message( 'check_parameters', 'PA0008', 1, 2, 0, 6, 0 )
362       ENDIF
363
364#if ! defined( __check )
365       IF ( myid == 0 ) THEN
366          CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
367          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 15, comm_inter, &
368                                                             status, ierr )
369       ENDIF
370       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
371
372#endif
373       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
374
375          IF ( dx < remote ) THEN
376             WRITE( message_string, * ) 'coupling mode "', &
377                   TRIM( coupling_mode ),                  &
378           '": dx in Atmosphere is not equal to or not larger then dx in ocean'
379             CALL message( 'check_parameters', 'PA0009', 1, 2, 0, 6, 0 )
380          ENDIF
381
382          IF ( (nx_a+1)*dx /= (nx_o+1)*remote )  THEN
383             WRITE( message_string, * ) 'coupling mode "', &
384                    TRIM( coupling_mode ), &
385             '": Domain size in x-direction is not equal in ocean and atmosphere'
386             CALL message( 'check_parameters', 'PA0010', 1, 2, 0, 6, 0 )
387          ENDIF
388
389       ENDIF
390
391#if ! defined( __check )
392       IF ( myid == 0) THEN
393          CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
394          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 16, comm_inter, &
395                         status, ierr )
396       ENDIF
397       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
398#endif
399       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
400
401          IF ( dy < remote )  THEN
402             WRITE( message_string, * ) 'coupling mode "', &
403                    TRIM( coupling_mode ), &
404                 '": dy in Atmosphere is not equal to or not larger then dy in ocean'
405             CALL message( 'check_parameters', 'PA0011', 1, 2, 0, 6, 0 )
406          ENDIF
407
408          IF ( (ny_a+1)*dy /= (ny_o+1)*remote )  THEN
409             WRITE( message_string, * ) 'coupling mode "', &
410                   TRIM( coupling_mode ), &
411             '": Domain size in y-direction is not equal in ocean and atmosphere'
412             CALL message( 'check_parameters', 'PA0012', 1, 2, 0, 6, 0 )
413          ENDIF
414
415          IF ( MOD(nx_o+1,nx_a+1) /= 0 )  THEN
416             WRITE( message_string, * ) 'coupling mode "', &
417                   TRIM( coupling_mode ), &
418             '": nx+1 in ocean is not divisible without remainder with nx+1 in', & 
419             ' atmosphere'
420             CALL message( 'check_parameters', 'PA0339', 1, 2, 0, 6, 0 )
421          ENDIF
422
423          IF ( MOD(ny_o+1,ny_a+1) /= 0 )  THEN
424             WRITE( message_string, * ) 'coupling mode "', &
425                   TRIM( coupling_mode ), &
426             '": ny+1 in ocean is not divisible without remainder with ny+1 in', & 
427             ' atmosphere'
428             CALL message( 'check_parameters', 'PA0340', 1, 2, 0, 6, 0 )
429          ENDIF
430
431       ENDIF
432#else
433       WRITE( message_string, * ) 'coupling requires PALM to be called with', &
434            ' ''mrun -K parallel'''
435       CALL message( 'check_parameters', 'PA0141', 1, 2, 0, 6, 0 )
436#endif
437    ENDIF
438
439#if defined( __parallel ) && ! defined ( __check )
440!
441!-- Exchange via intercommunicator
442    IF ( coupling_mode == 'atmosphere_to_ocean' .AND. myid == 0 )  THEN
443       CALL MPI_SEND( humidity, 1, MPI_LOGICAL, target_id, 19, comm_inter, &
444                      ierr )
445    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' .AND. myid == 0)  THEN
446       CALL MPI_RECV( humidity_remote, 1, MPI_LOGICAL, target_id, 19, &
447                      comm_inter, status, ierr )
448    ENDIF
449    CALL MPI_BCAST( humidity_remote, 1, MPI_LOGICAL, 0, comm2d, ierr)
450   
451#endif
452
453
454!
455!-- Generate the file header which is used as a header for most of PALM's
456!-- output files
457    CALL DATE_AND_TIME( date, time )
458    run_date = date(7:8)//'-'//date(5:6)//'-'//date(3:4)
459    run_time = time(1:2)//':'//time(3:4)//':'//time(5:6)
460    IF ( coupling_mode == 'uncoupled' )  THEN
461       coupling_string = ''
462    ELSEIF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
463       coupling_string = ' coupled (atmosphere)'
464    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
465       coupling_string = ' coupled (ocean)'
466    ENDIF       
467
468    WRITE ( run_description_header,                                        &
469                             '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' ) &
470              TRIM( version ), TRIM( revision ), 'run: ',                  &
471              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ), &
472              'host: ', TRIM( host ), run_date, run_time
473
474!
475!-- Check the general loop optimization method
476    IF ( loop_optimization == 'default' )  THEN
477       IF ( host(1:3) == 'nec' )  THEN
478          loop_optimization = 'vector'
479       ELSE
480          loop_optimization = 'cache'
481       ENDIF
482    ENDIF
483
484    SELECT CASE ( TRIM( loop_optimization ) )
485
486       CASE ( 'acc', 'cache', 'vector' )
487          CONTINUE
488
489       CASE DEFAULT
490          message_string = 'illegal value given for loop_optimization: "' // &
491                           TRIM( loop_optimization ) // '"'
492          CALL message( 'check_parameters', 'PA0013', 1, 2, 0, 6, 0 )
493
494    END SELECT
495
496!
497!-- Check if vertical grid stretching is used together with particles
498    IF ( dz_stretch_level < 100000.0 .AND. particle_advection )  THEN
499       message_string = 'Vertical grid stretching is not allowed together ' // &
500                        'with particle advection.'
501       CALL message( 'check_parameters', 'PA0017', 1, 2, 0, 6, 0 )
502    ENDIF
503
504!
505!-- Check topography setting (check for illegal parameter combinations)
506    IF ( topography /= 'flat' )  THEN
507       action = ' '
508       IF ( scalar_advec /= 'pw-scheme' .AND. scalar_advec /= 'ws-scheme')  THEN
509          WRITE( action, '(A,A)' )  'scalar_advec = ', scalar_advec
510       ENDIF
511       IF ( momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme' ) &
512       THEN
513          WRITE( action, '(A,A)' )  'momentum_advec = ', momentum_advec
514       ENDIF
515       IF ( psolver == 'sor' )  THEN
516          WRITE( action, '(A,A)' )  'psolver = ', psolver
517       ENDIF
518       IF ( sloping_surface )  THEN
519          WRITE( action, '(A)' )  'sloping surface = .TRUE.'
520       ENDIF
521       IF ( galilei_transformation )  THEN
522          WRITE( action, '(A)' )  'galilei_transformation = .TRUE.'
523       ENDIF
524       IF ( cloud_physics )  THEN
525          WRITE( action, '(A)' )  'cloud_physics = .TRUE.'
526       ENDIF
527       IF ( cloud_droplets )  THEN
528          WRITE( action, '(A)' )  'cloud_droplets = .TRUE.'
529       ENDIF
530       IF ( .NOT. prandtl_layer )  THEN
531          WRITE( action, '(A)' )  'prandtl_layer = .FALSE.'
532       ENDIF
533       IF ( action /= ' ' )  THEN
534          message_string = 'a non-flat topography does not allow ' // &
535                           TRIM( action )
536          CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
537       ENDIF
538!
539!--    In case of non-flat topography, check whether the convention how to
540!--    define the topography grid has been set correctly, or whether the default
541!--    is applicable. If this is not possible, abort.
542       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
543          IF ( TRIM( topography ) /= 'single_building' .AND.  &
544               TRIM( topography ) /= 'single_street_canyon' .AND.  &
545               TRIM( topography ) /= 'read_from_file' )  THEN
546!--          The default value is not applicable here, because it is only valid
547!--          for the two standard cases 'single_building' and 'read_from_file'
548!--          defined in init_grid.
549             WRITE( message_string, * )  &
550                  'The value for "topography_grid_convention" ',  &
551                  'is not set. Its default value is & only valid for ',  &
552                  '"topography" = ''single_building'', ',  &
553                  '''single_street_canyon'' & or ''read_from_file''.',  &
554                  ' & Choose ''cell_edge'' or ''cell_center''.'
555             CALL message( 'user_check_parameters', 'PA0239', 1, 2, 0, 6, 0 )
556          ELSE
557!--          The default value is applicable here.
558!--          Set convention according to topography.
559             IF ( TRIM( topography ) == 'single_building' .OR.  &
560                  TRIM( topography ) == 'single_street_canyon' )  THEN
561                topography_grid_convention = 'cell_edge'
562             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
563                topography_grid_convention = 'cell_center'
564             ENDIF
565          ENDIF
566       ELSEIF ( TRIM( topography_grid_convention ) /= 'cell_edge' .AND.  &
567                TRIM( topography_grid_convention ) /= 'cell_center' )  THEN
568          WRITE( message_string, * )  &
569               'The value for "topography_grid_convention" is ', &
570               'not recognized. & Choose ''cell_edge'' or ''cell_center''.'
571          CALL message( 'user_check_parameters', 'PA0240', 1, 2, 0, 6, 0 )
572       ENDIF
573
574    ENDIF
575
576!
577!-- Check ocean setting
578    IF ( ocean )  THEN
579
580       action = ' '
581       IF ( action /= ' ' )  THEN
582          message_string = 'ocean = .T. does not allow ' // TRIM( action )
583          CALL message( 'check_parameters', 'PA0015', 1, 2, 0, 6, 0 )
584       ENDIF
585
586    ELSEIF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.  &
587             TRIM( coupling_char ) == '_O' )  THEN
588
589!
590!--    Check whether an (uncoupled) atmospheric run has been declared as an
591!--    ocean run (this setting is done via mrun-option -y)
592
593       message_string = 'ocean = .F. does not allow coupling_char = "' // &
594                        TRIM( coupling_char ) // '" set by mrun-option "-y"'
595       CALL message( 'check_parameters', 'PA0317', 1, 2, 0, 6, 0 )
596
597    ENDIF
598!
599!-- Check cloud scheme
600    IF ( cloud_scheme == 'seifert_beheng' )  THEN
601       icloud_scheme = 0
602    ELSEIF ( cloud_scheme == 'kessler' )  THEN
603       icloud_scheme = 1
604    ELSE
605       message_string = 'unknown cloud microphysics scheme cloud_scheme ="' // &
606                        TRIM( cloud_scheme ) // '"'
607       CALL message( 'check_parameters', 'PA0357', 1, 2, 0, 6, 0 )
608    ENDIF
609!
610!-- Check whether there are any illegal values
611!-- Pressure solver:
612    IF ( psolver /= 'poisfft'  .AND. &
613         psolver /= 'sor'  .AND.  psolver /= 'multigrid' )  THEN
614       message_string = 'unknown solver for perturbation pressure: psolver' // &
615                        ' = "' // TRIM( psolver ) // '"'
616       CALL message( 'check_parameters', 'PA0016', 1, 2, 0, 6, 0 )
617    ENDIF
618
619    IF ( psolver == 'multigrid' )  THEN
620       IF ( cycle_mg == 'w' )  THEN
621          gamma_mg = 2
622       ELSEIF ( cycle_mg == 'v' )  THEN
623          gamma_mg = 1
624       ELSE
625          message_string = 'unknown multigrid cycle: cycle_mg = "' // &
626                           TRIM( cycle_mg ) // '"'
627          CALL message( 'check_parameters', 'PA0020', 1, 2, 0, 6, 0 )
628       ENDIF
629    ENDIF
630
631    IF ( fft_method /= 'singleton-algorithm'  .AND.  &
632         fft_method /= 'temperton-algorithm'  .AND.  &
633         fft_method /= 'fftw'                 .AND.  &
634         fft_method /= 'system-specific' )  THEN
635       message_string = 'unknown fft-algorithm: fft_method = "' // &
636                        TRIM( fft_method ) // '"'
637       CALL message( 'check_parameters', 'PA0021', 1, 2, 0, 6, 0 )
638    ENDIF
639   
640    IF( momentum_advec == 'ws-scheme' .AND. & 
641        .NOT. call_psolver_at_all_substeps  ) THEN
642        message_string = 'psolver must be called at each RK3 substep when "'//&
643                      TRIM(momentum_advec) // ' "is used for momentum_advec'
644        CALL message( 'check_parameters', 'PA0344', 1, 2, 0, 6, 0 )
645    END IF
646!
647!-- Advection schemes:
648    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' ) &
649    THEN
650       message_string = 'unknown advection scheme: momentum_advec = "' // &
651                        TRIM( momentum_advec ) // '"'
652       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
653    ENDIF
654    IF ( ( momentum_advec == 'ws-scheme' .OR.  scalar_advec == 'ws-scheme' )   &
655           .AND. ( timestep_scheme == 'euler' .OR.                             &
656                   timestep_scheme == 'runge-kutta-2' ) )                      &
657    THEN
658       message_string = 'momentum_advec or scalar_advec = "' &
659         // TRIM( momentum_advec ) // '" is not allowed with timestep_scheme = "' // &
660         TRIM( timestep_scheme ) // '"'
661       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
662    ENDIF
663    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' .AND. &
664         scalar_advec /= 'bc-scheme' )                                         &
665    THEN
666       message_string = 'unknown advection scheme: scalar_advec = "' // &
667                        TRIM( scalar_advec ) // '"'
668       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
669    ENDIF
670    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' ) &
671    THEN
672       message_string = 'advection_scheme scalar_advec = "' &
673         // TRIM( scalar_advec ) // '" not implemented for & loop_optimization = "' // &
674         TRIM( loop_optimization ) // '"'
675       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
676    ENDIF
677
678    IF ( use_sgs_for_particles  .AND.  .NOT. use_upstream_for_tke )  THEN
679       use_upstream_for_tke = .TRUE.
680       message_string = 'use_upstream_for_tke set .TRUE. because ' // &
681                        'use_sgs_for_particles = .TRUE.'
682       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
683    ENDIF
684
685    IF ( use_sgs_for_particles  .AND.  curvature_solution_effects )  THEN
686       message_string = 'use_sgs_for_particles = .TRUE. not allowed with ' // &
687                        'curvature_solution_effects = .TRUE.'
688       CALL message( 'check_parameters', 'PA0349', 1, 2, 0, 6, 0 )
689    ENDIF
690
691!
692!-- Set LOGICAL switches to enhance performance
693    IF ( momentum_advec == 'ws-scheme' )    ws_scheme_mom = .TRUE.
694    IF ( scalar_advec   == 'ws-scheme'   )  ws_scheme_sca = .TRUE.
695
696!
697!-- Timestep schemes:
698    SELECT CASE ( TRIM( timestep_scheme ) )
699
700       CASE ( 'euler' )
701          intermediate_timestep_count_max = 1
702
703       CASE ( 'runge-kutta-2' )
704          intermediate_timestep_count_max = 2
705
706       CASE ( 'runge-kutta-3' )
707          intermediate_timestep_count_max = 3
708
709       CASE DEFAULT
710          message_string = 'unknown timestep scheme: timestep_scheme = "' // &
711                           TRIM( timestep_scheme ) // '"'
712          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
713
714    END SELECT
715
716    IF ( (momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme') &
717         .AND. timestep_scheme(1:5) == 'runge' ) THEN
718       message_string = 'momentum advection scheme "' // &
719                        TRIM( momentum_advec ) // '" & does not work with ' // &
720                        'timestep_scheme "' // TRIM( timestep_scheme ) // '"'
721       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
722    ENDIF
723
724!
725!-- Collision kernels:
726    SELECT CASE ( TRIM( collision_kernel ) )
727
728       CASE ( 'hall', 'hall_fast' )
729          hall_kernel = .TRUE.
730
731       CASE ( 'palm' )
732          palm_kernel = .TRUE.
733
734       CASE ( 'wang', 'wang_fast' )
735          wang_kernel = .TRUE.
736
737       CASE ( 'none' )
738
739
740       CASE DEFAULT
741          message_string = 'unknown collision kernel: collision_kernel = "' // &
742                           TRIM( collision_kernel ) // '"'
743          CALL message( 'check_parameters', 'PA0350', 1, 2, 0, 6, 0 )
744
745    END SELECT
746    IF ( collision_kernel(6:9) == 'fast' )  use_kernel_tables = .TRUE.
747
748    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.  &
749         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
750!
751!--    No restart run: several initialising actions are possible
752       action = initializing_actions
753       DO WHILE ( TRIM( action ) /= '' )
754          position = INDEX( action, ' ' )
755          SELECT CASE ( action(1:position-1) )
756
757             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', &
758                    'by_user', 'initialize_vortex',     'initialize_ptanom' )
759                action = action(position+1:)
760
761             CASE DEFAULT
762                message_string = 'initializing_action = "' // &
763                                 TRIM( action ) // '" unkown or not allowed'
764                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
765
766          END SELECT
767       ENDDO
768    ENDIF
769
770    IF ( TRIM( initializing_actions ) == 'initialize_vortex' .AND. &
771         conserve_volume_flow ) THEN
772         message_string = 'initializing_actions = "initialize_vortex"' // &
773                        ' ist not allowed with conserve_volume_flow = .T.'
774       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
775    ENDIF       
776
777
778    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
779         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
780       message_string = 'initializing_actions = "set_constant_profiles"' // &
781                        ' and "set_1d-model_profiles" are not allowed ' //  &
782                        'simultaneously'
783       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
784    ENDIF
785
786    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
787         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
788       message_string = 'initializing_actions = "set_constant_profiles"' // &
789                        ' and "by_user" are not allowed simultaneously'
790       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
791    ENDIF
792
793    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND. &
794         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
795       message_string = 'initializing_actions = "by_user" and ' // &
796                        '"set_1d-model_profiles" are not allowed simultaneously'
797       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
798    ENDIF
799
800    IF ( cloud_physics  .AND.  .NOT. humidity )  THEN
801       WRITE( message_string, * ) 'cloud_physics = ', cloud_physics, ' is ', &
802              'not allowed with humidity = ', humidity
803       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
804    ENDIF
805
806    IF ( precipitation  .AND.  .NOT.  cloud_physics )  THEN
807       WRITE( message_string, * ) 'precipitation = ', precipitation, ' is ', &
808              'not allowed with cloud_physics = ', cloud_physics
809       CALL message( 'check_parameters', 'PA0035', 1, 2, 0, 6, 0 )
810    ENDIF
811
812    IF ( humidity  .AND.  sloping_surface )  THEN
813       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' // &
814                        'are not allowed simultaneously'
815       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
816    ENDIF
817
818    IF ( passive_scalar  .AND.  humidity )  THEN
819       message_string = 'humidity = .TRUE. and passive_scalar = .TRUE. ' // &
820                        'is not allowed simultaneously'
821       CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
822    ENDIF
823
824    IF ( plant_canopy .AND. ( drag_coefficient == 0.0 ) ) THEN
825       message_string = 'plant_canopy = .TRUE. requires a non-zero drag ' // &
826                        'coefficient & given value is drag_coefficient = 0.0'
827       CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
828    ENDIF
829
830    IF ( plant_canopy  .AND.  cloud_physics  .AND.  icloud_scheme == 0 ) THEN
831       message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' //  &
832                        ' seifert_beheng'
833       CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
834    ENDIF
835
836    IF ( loop_optimization /= 'cache' .AND.  cloud_physics  .AND.            &
837         icloud_scheme == 0 ) THEN
838       message_string = 'cloud_scheme = seifert_beheng requires ' // &
839                        'loop_optimization = cache'
840       CALL message( 'check_parameters', 'PA0362', 1, 2, 0, 6, 0 )
841    ENDIF 
842
843!    IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
844!         .NOT. precipitation  .AND.  .NOT. drizzle ) THEN
845!       message_string = 'cloud_scheme = seifert_beheng requires ' // &
846!                        'precipitation = .TRUE. or drizzle = .TRUE.'
847!       CALL message( 'check_parameters', 'PA0363', 1, 2, 0, 6, 0 )
848!    ENDIF
849
850!
851!-- In case of no model continuation run, check initialising parameters and
852!-- deduce further quantities
853    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
854
855!
856!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
857       pt_init = pt_surface
858       IF ( humidity )  THEN
859          q_init  = q_surface
860       ENDIF
861       IF ( ocean )           sa_init = sa_surface
862       IF ( passive_scalar )  q_init  = s_surface
863       IF ( plant_canopy )    lad = 0.0
864
865!
866!--
867!--    If required, compute initial profile of the geostrophic wind
868!--    (component ug)
869       i = 1
870       gradient = 0.0
871
872       IF ( .NOT. ocean )  THEN
873
874          ug_vertical_gradient_level_ind(1) = 0
875          ug(0) = ug_surface
876          DO  k = 1, nzt+1
877             IF ( i < 11 ) THEN
878                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND. &
879                     ug_vertical_gradient_level(i) >= 0.0 )  THEN
880                   gradient = ug_vertical_gradient(i) / 100.0
881                   ug_vertical_gradient_level_ind(i) = k - 1
882                   i = i + 1
883                ENDIF
884             ENDIF       
885             IF ( gradient /= 0.0 )  THEN
886                IF ( k /= 1 )  THEN
887                   ug(k) = ug(k-1) + dzu(k) * gradient
888                ELSE
889                   ug(k) = ug_surface + dzu(k) * gradient
890                ENDIF
891             ELSE
892                ug(k) = ug(k-1)
893             ENDIF
894          ENDDO
895
896       ELSE
897
898          ug_vertical_gradient_level_ind(1) = nzt+1
899          ug(nzt+1) = ug_surface
900          DO  k = nzt, nzb, -1
901             IF ( i < 11 ) THEN
902                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND. &
903                     ug_vertical_gradient_level(i) <= 0.0 )  THEN
904                   gradient = ug_vertical_gradient(i) / 100.0
905                   ug_vertical_gradient_level_ind(i) = k + 1
906                   i = i + 1
907                ENDIF
908             ENDIF
909             IF ( gradient /= 0.0 )  THEN
910                IF ( k /= nzt )  THEN
911                   ug(k) = ug(k+1) - dzu(k+1) * gradient
912                ELSE
913                   ug(k)   = ug_surface - 0.5 * dzu(k+1) * gradient
914                   ug(k+1) = ug_surface + 0.5 * dzu(k+1) * gradient
915                ENDIF
916             ELSE
917                ug(k) = ug(k+1)
918             ENDIF
919          ENDDO
920
921       ENDIF
922
923!
924!--    In case of no given gradients for ug, choose a zero gradient
925       IF ( ug_vertical_gradient_level(1) == -9999999.9_wp )  THEN
926          ug_vertical_gradient_level(1) = 0.0
927       ENDIF 
928
929!
930!--
931!--    If required, compute initial profile of the geostrophic wind
932!--    (component vg)
933       i = 1
934       gradient = 0.0
935
936       IF ( .NOT. ocean )  THEN
937
938          vg_vertical_gradient_level_ind(1) = 0
939          vg(0) = vg_surface
940          DO  k = 1, nzt+1
941             IF ( i < 11 ) THEN
942                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND. &
943                     vg_vertical_gradient_level(i) >= 0.0 )  THEN
944                   gradient = vg_vertical_gradient(i) / 100.0
945                   vg_vertical_gradient_level_ind(i) = k - 1
946                   i = i + 1
947                ENDIF
948             ENDIF
949             IF ( gradient /= 0.0 )  THEN
950                IF ( k /= 1 )  THEN
951                   vg(k) = vg(k-1) + dzu(k) * gradient
952                ELSE
953                   vg(k) = vg_surface + dzu(k) * gradient
954                ENDIF
955             ELSE
956                vg(k) = vg(k-1)
957             ENDIF
958          ENDDO
959
960       ELSE
961
962          vg_vertical_gradient_level_ind(1) = nzt+1
963          vg(nzt+1) = vg_surface
964          DO  k = nzt, nzb, -1
965             IF ( i < 11 ) THEN
966                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND. &
967                     vg_vertical_gradient_level(i) <= 0.0 )  THEN
968                   gradient = vg_vertical_gradient(i) / 100.0
969                   vg_vertical_gradient_level_ind(i) = k + 1
970                   i = i + 1
971                ENDIF
972             ENDIF
973             IF ( gradient /= 0.0 )  THEN
974                IF ( k /= nzt )  THEN
975                   vg(k) = vg(k+1) - dzu(k+1) * gradient
976                ELSE
977                   vg(k)   = vg_surface - 0.5 * dzu(k+1) * gradient
978                   vg(k+1) = vg_surface + 0.5 * dzu(k+1) * gradient
979                ENDIF
980             ELSE
981                vg(k) = vg(k+1)
982             ENDIF
983          ENDDO
984
985       ENDIF
986
987!
988!--    In case of no given gradients for vg, choose a zero gradient
989       IF ( vg_vertical_gradient_level(1) == -9999999.9_wp )  THEN
990          vg_vertical_gradient_level(1) = 0.0
991       ENDIF
992
993!
994!--    Let the initial wind profiles be the calculated ug/vg profiles or
995!--    interpolate them from wind profile data (if given)
996       IF ( u_profile(1) == 9999999.9_wp  .AND.  v_profile(1) == 9999999.9_wp )  THEN
997
998          u_init = ug
999          v_init = vg
1000
1001       ELSEIF ( u_profile(1) == 0.0  .AND.  v_profile(1) == 0.0 )  THEN
1002
1003          IF ( uv_heights(1) /= 0.0 )  THEN
1004             message_string = 'uv_heights(1) must be 0.0'
1005             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
1006          ENDIF
1007
1008          use_prescribed_profile_data = .TRUE.
1009
1010          kk = 1
1011          u_init(0) = 0.0
1012          v_init(0) = 0.0
1013
1014          DO  k = 1, nz+1
1015
1016             IF ( kk < 100 )  THEN
1017                DO WHILE ( uv_heights(kk+1) <= zu(k) )
1018                   kk = kk + 1
1019                   IF ( kk == 100 )  EXIT
1020                ENDDO
1021             ENDIF
1022
1023             IF ( kk < 100 .AND. uv_heights(kk+1) /= 9999999.9_wp )  THEN
1024                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1025                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1026                                       ( u_profile(kk+1) - u_profile(kk) )
1027                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1028                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1029                                       ( v_profile(kk+1) - v_profile(kk) )
1030             ELSE
1031                u_init(k) = u_profile(kk)
1032                v_init(k) = v_profile(kk)
1033             ENDIF
1034
1035          ENDDO
1036
1037       ELSE
1038
1039          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1040          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1041
1042       ENDIF
1043
1044!
1045!--    Compute initial temperature profile using the given temperature gradients
1046       IF ( .NOT. neutral )  THEN
1047
1048          i = 1
1049          gradient = 0.0
1050
1051          IF ( .NOT. ocean )  THEN
1052
1053             pt_vertical_gradient_level_ind(1) = 0
1054             DO  k = 1, nzt+1
1055                IF ( i < 11 ) THEN
1056                   IF ( pt_vertical_gradient_level(i) < zu(k)  .AND. &
1057                        pt_vertical_gradient_level(i) >= 0.0 )  THEN
1058                      gradient = pt_vertical_gradient(i) / 100.0
1059                      pt_vertical_gradient_level_ind(i) = k - 1
1060                      i = i + 1
1061                   ENDIF
1062                ENDIF
1063                IF ( gradient /= 0.0 )  THEN
1064                   IF ( k /= 1 )  THEN
1065                      pt_init(k) = pt_init(k-1) + dzu(k) * gradient
1066                   ELSE
1067                      pt_init(k) = pt_surface   + dzu(k) * gradient
1068                   ENDIF
1069                ELSE
1070                   pt_init(k) = pt_init(k-1)
1071                ENDIF
1072             ENDDO
1073
1074          ELSE
1075
1076             pt_vertical_gradient_level_ind(1) = nzt+1
1077             DO  k = nzt, 0, -1
1078                IF ( i < 11 ) THEN
1079                   IF ( pt_vertical_gradient_level(i) > zu(k)  .AND. &
1080                        pt_vertical_gradient_level(i) <= 0.0 )  THEN
1081                      gradient = pt_vertical_gradient(i) / 100.0
1082                      pt_vertical_gradient_level_ind(i) = k + 1
1083                      i = i + 1
1084                   ENDIF
1085                ENDIF
1086                IF ( gradient /= 0.0 )  THEN
1087                   IF ( k /= nzt )  THEN
1088                      pt_init(k) = pt_init(k+1) - dzu(k+1) * gradient
1089                   ELSE
1090                      pt_init(k)   = pt_surface - 0.5 * dzu(k+1) * gradient
1091                      pt_init(k+1) = pt_surface + 0.5 * dzu(k+1) * gradient
1092                   ENDIF
1093                ELSE
1094                   pt_init(k) = pt_init(k+1)
1095                ENDIF
1096             ENDDO
1097
1098          ENDIF
1099
1100       ENDIF
1101
1102!
1103!--    In case of no given temperature gradients, choose gradient of neutral
1104!--    stratification
1105       IF ( pt_vertical_gradient_level(1) == -9999999.9_wp )  THEN
1106          pt_vertical_gradient_level(1) = 0.0
1107       ENDIF
1108
1109!
1110!--    Store temperature gradient at the top boundary for possible Neumann
1111!--    boundary condition
1112       bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1)
1113
1114!
1115!--    If required, compute initial humidity or scalar profile using the given
1116!--    humidity/scalar gradient. In case of scalar transport, initially store
1117!--    values of the scalar parameters on humidity parameters
1118       IF ( passive_scalar )  THEN
1119          bc_q_b                    = bc_s_b
1120          bc_q_t                    = bc_s_t
1121          q_surface                 = s_surface
1122          q_surface_initial_change  = s_surface_initial_change
1123          q_vertical_gradient       = s_vertical_gradient
1124          q_vertical_gradient_level = s_vertical_gradient_level
1125          surface_waterflux         = surface_scalarflux
1126          wall_humidityflux         = wall_scalarflux
1127       ENDIF
1128
1129       IF ( humidity  .OR.  passive_scalar )  THEN
1130
1131          i = 1
1132          gradient = 0.0
1133          q_vertical_gradient_level_ind(1) = 0
1134          DO  k = 1, nzt+1
1135             IF ( i < 11 ) THEN
1136                IF ( q_vertical_gradient_level(i) < zu(k)  .AND. &
1137                     q_vertical_gradient_level(i) >= 0.0 )  THEN
1138                   gradient = q_vertical_gradient(i) / 100.0
1139                   q_vertical_gradient_level_ind(i) = k - 1
1140                   i = i + 1
1141                ENDIF
1142             ENDIF
1143             IF ( gradient /= 0.0 )  THEN
1144                IF ( k /= 1 )  THEN
1145                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1146                ELSE
1147                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1148                ENDIF
1149             ELSE
1150                q_init(k) = q_init(k-1)
1151             ENDIF
1152!
1153!--          Avoid negative humidities
1154             IF ( q_init(k) < 0.0 )  THEN
1155                q_init(k) = 0.0
1156             ENDIF
1157          ENDDO
1158
1159!
1160!--       In case of no given humidity gradients, choose zero gradient
1161!--       conditions
1162          IF ( q_vertical_gradient_level(1) == -1.0 )  THEN
1163             q_vertical_gradient_level(1) = 0.0
1164          ENDIF
1165!
1166!--       Store humidity, rain water content and rain drop concentration
1167!--       gradient at the top boundary for possile Neumann boundary condition
1168          bc_q_t_val  = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
1169       ENDIF
1170
1171!
1172!--    If required, compute initial salinity profile using the given salinity
1173!--    gradients
1174       IF ( ocean )  THEN
1175
1176          i = 1
1177          gradient = 0.0
1178
1179          sa_vertical_gradient_level_ind(1) = nzt+1
1180          DO  k = nzt, 0, -1
1181             IF ( i < 11 ) THEN
1182                IF ( sa_vertical_gradient_level(i) > zu(k)  .AND. &
1183                     sa_vertical_gradient_level(i) <= 0.0 )  THEN
1184                   gradient = sa_vertical_gradient(i) / 100.0
1185                   sa_vertical_gradient_level_ind(i) = k + 1
1186                   i = i + 1
1187                ENDIF
1188             ENDIF
1189             IF ( gradient /= 0.0 )  THEN
1190                IF ( k /= nzt )  THEN
1191                   sa_init(k) = sa_init(k+1) - dzu(k+1) * gradient
1192                ELSE
1193                   sa_init(k)   = sa_surface - 0.5 * dzu(k+1) * gradient
1194                   sa_init(k+1) = sa_surface + 0.5 * dzu(k+1) * gradient
1195                ENDIF
1196             ELSE
1197                sa_init(k) = sa_init(k+1)
1198             ENDIF
1199          ENDDO
1200
1201       ENDIF
1202
1203!
1204!--    If required compute the profile of leaf area density used in the plant
1205!--    canopy model
1206       IF ( plant_canopy ) THEN
1207       
1208          i = 1
1209          gradient = 0.0
1210
1211          IF ( .NOT. ocean ) THEN
1212
1213             lad(0) = lad_surface
1214 
1215             lad_vertical_gradient_level_ind(1) = 0
1216             DO k = 1, pch_index
1217                IF ( i < 11 ) THEN
1218                   IF ( lad_vertical_gradient_level(i) < zu(k) .AND.  &
1219                        lad_vertical_gradient_level(i) >= 0.0 ) THEN
1220                      gradient = lad_vertical_gradient(i)
1221                      lad_vertical_gradient_level_ind(i) = k - 1
1222                      i = i + 1
1223                   ENDIF
1224                ENDIF
1225                IF ( gradient /= 0.0 ) THEN
1226                   IF ( k /= 1 ) THEN
1227                      lad(k) = lad(k-1) + dzu(k) * gradient
1228                   ELSE
1229                      lad(k) = lad_surface + dzu(k) *gradient
1230                   ENDIF
1231                ELSE
1232                   lad(k) = lad(k-1)
1233                ENDIF
1234             ENDDO
1235
1236          ENDIF
1237
1238!
1239!--       In case of no given leaf area density gradients, choose a vanishing
1240!--       gradient
1241          IF ( lad_vertical_gradient_level(1) == -9999999.9_wp ) THEN
1242             lad_vertical_gradient_level(1) = 0.0
1243          ENDIF
1244
1245       ENDIF
1246         
1247    ENDIF
1248
1249!
1250!-- Initialize large scale subsidence if required
1251    If ( large_scale_subsidence )  THEN
1252       IF ( subs_vertical_gradient_level(1) /= -9999999.9_wp .AND. &
1253                                     .NOT. large_scale_forcing )  THEN
1254          CALL init_w_subsidence
1255       ENDIF
1256!
1257!--    In case large_scale_forcing is used, profiles for subsidence velocity
1258!--    are read in from file LSF_DATA
1259
1260       IF ( subs_vertical_gradient_level(1) == -9999999.9_wp .AND. &
1261                                     .NOT. large_scale_forcing )  THEN
1262          message_string = 'There is no default large scale vertical ' // &
1263                           'velocity profile set. Specify the subsidence ' // &
1264                           'velocity profile via subs_vertical_gradient and ' // &
1265                           'subs_vertical_gradient_level.'
1266          CALL message( 'check_parameters', 'PA0380', 1, 2, 0, 6, 0 )
1267       ENDIF
1268    ELSE
1269        IF ( subs_vertical_gradient_level(1) /= -9999999.9_wp )  THEN
1270           message_string = 'Enable usage of large scale subsidence by ' // &
1271                            'setting large_scale_subsidence = .T..'
1272          CALL message( 'check_parameters', 'PA0381', 1, 2, 0, 6, 0 )
1273        ENDIF
1274    ENDIF   
1275
1276!
1277!-- Compute Coriolis parameter
1278    f  = 2.0 * omega * SIN( phi / 180.0 * pi )
1279    fs = 2.0 * omega * COS( phi / 180.0 * pi )
1280
1281!
1282!-- Check and set buoyancy related parameters and switches
1283    IF ( reference_state == 'horizontal_average' )  THEN
1284       CONTINUE
1285    ELSEIF ( reference_state == 'initial_profile' )  THEN
1286       use_initial_profile_as_reference = .TRUE.
1287    ELSEIF ( reference_state == 'single_value' )  THEN
1288       use_single_reference_value = .TRUE.
1289       IF ( pt_reference == 9999999.9_wp )  pt_reference = pt_surface
1290       vpt_reference = pt_reference * ( 1.0 + 0.61 * q_surface )
1291    ELSE
1292       message_string = 'illegal value for reference_state: "' // &
1293                        TRIM( reference_state ) // '"'
1294       CALL message( 'check_parameters', 'PA0056', 1, 2, 0, 6, 0 )
1295    ENDIF
1296
1297!
1298!-- Ocean runs always use reference values in the buoyancy term
1299    IF ( ocean )  THEN
1300       reference_state = 'single_value'
1301       use_single_reference_value = .TRUE.
1302    ENDIF
1303
1304!
1305!-- Sign of buoyancy/stability terms
1306    IF ( ocean )  atmos_ocean_sign = -1.0
1307
1308!
1309!-- Ocean version must use flux boundary conditions at the top
1310    IF ( ocean .AND. .NOT. use_top_fluxes )  THEN
1311       message_string = 'use_top_fluxes must be .TRUE. in ocean version'
1312       CALL message( 'check_parameters', 'PA0042', 1, 2, 0, 6, 0 )
1313    ENDIF
1314
1315!
1316!-- In case of a given slope, compute the relevant quantities
1317    IF ( alpha_surface /= 0.0 )  THEN
1318       IF ( ABS( alpha_surface ) > 90.0 )  THEN
1319          WRITE( message_string, * ) 'ABS( alpha_surface = ', alpha_surface, &
1320                                     ' ) must be < 90.0'
1321          CALL message( 'check_parameters', 'PA0043', 1, 2, 0, 6, 0 )
1322       ENDIF
1323       sloping_surface = .TRUE.
1324       cos_alpha_surface = COS( alpha_surface / 180.0 * pi )
1325       sin_alpha_surface = SIN( alpha_surface / 180.0 * pi )
1326    ENDIF
1327
1328!
1329!-- Check time step and cfl_factor
1330    IF ( dt /= -1.0 )  THEN
1331       IF ( dt <= 0.0  .AND.  dt /= -1.0 )  THEN
1332          WRITE( message_string, * ) 'dt = ', dt , ' <= 0.0'
1333          CALL message( 'check_parameters', 'PA0044', 1, 2, 0, 6, 0 )
1334       ENDIF
1335       dt_3d = dt
1336       dt_fixed = .TRUE.
1337    ENDIF
1338
1339    IF ( cfl_factor <= 0.0  .OR.  cfl_factor > 1.0 )  THEN
1340       IF ( cfl_factor == -1.0 )  THEN
1341          IF ( timestep_scheme == 'runge-kutta-2' )  THEN
1342             cfl_factor = 0.8
1343          ELSEIF ( timestep_scheme == 'runge-kutta-3' )  THEN
1344             cfl_factor = 0.9
1345          ELSE
1346             cfl_factor = 0.9
1347          ENDIF
1348       ELSE
1349          WRITE( message_string, * ) 'cfl_factor = ', cfl_factor, &
1350                 ' out of range & 0.0 < cfl_factor <= 1.0 is required'
1351          CALL message( 'check_parameters', 'PA0045', 1, 2, 0, 6, 0 )
1352       ENDIF
1353    ENDIF
1354
1355!
1356!-- Store simulated time at begin
1357    simulated_time_at_begin = simulated_time
1358
1359!
1360!-- Store reference time for coupled runs and change the coupling flag,
1361!-- if ...
1362    IF ( simulated_time == 0.0 )  THEN
1363       IF ( coupling_start_time == 0.0 )  THEN
1364          time_since_reference_point = 0.0
1365       ELSEIF ( time_since_reference_point < 0.0 )  THEN
1366          run_coupled = .FALSE.
1367       ENDIF
1368    ENDIF
1369
1370!
1371!-- Set wind speed in the Galilei-transformed system
1372    IF ( galilei_transformation )  THEN
1373       IF ( use_ug_for_galilei_tr .AND.                  &
1374            ug_vertical_gradient_level(1) == 0.0  .AND.  &
1375            ug_vertical_gradient(1) == 0.0  .AND.        & 
1376            vg_vertical_gradient_level(1) == 0.0  .AND.  &
1377            vg_vertical_gradient(1) == 0.0 )  THEN
1378          u_gtrans = ug_surface * 0.6
1379          v_gtrans = vg_surface * 0.6
1380       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1381                ( ug_vertical_gradient_level(1) /= 0.0  .OR.  &
1382                ug_vertical_gradient(1) /= 0.0 ) )  THEN
1383          message_string = 'baroclinicity (ug) not allowed simultaneously' // &
1384                           ' with galilei transformation'
1385          CALL message( 'check_parameters', 'PA0046', 1, 2, 0, 6, 0 )
1386       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1387                ( vg_vertical_gradient_level(1) /= 0.0  .OR.  &
1388                vg_vertical_gradient(1) /= 0.0 ) )  THEN
1389          message_string = 'baroclinicity (vg) not allowed simultaneously' // &
1390                           ' with galilei transformation'
1391          CALL message( 'check_parameters', 'PA0047', 1, 2, 0, 6, 0 )
1392       ELSE
1393          message_string = 'variable translation speed used for galilei-' // &
1394             'transformation, which may cause & instabilities in stably ' // &
1395             'stratified regions'
1396          CALL message( 'check_parameters', 'PA0048', 0, 1, 0, 6, 0 )
1397       ENDIF
1398    ENDIF
1399
1400!
1401!-- In case of using a prandtl-layer, calculated (or prescribed) surface
1402!-- fluxes have to be used in the diffusion-terms
1403    IF ( prandtl_layer )  use_surface_fluxes = .TRUE.
1404
1405!
1406!-- Check boundary conditions and set internal variables:
1407!-- Lateral boundary conditions
1408    IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
1409         bc_lr /= 'radiation/dirichlet' )  THEN
1410       message_string = 'unknown boundary condition: bc_lr = "' // &
1411                        TRIM( bc_lr ) // '"'
1412       CALL message( 'check_parameters', 'PA0049', 1, 2, 0, 6, 0 )
1413    ENDIF
1414    IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
1415         bc_ns /= 'radiation/dirichlet' )  THEN
1416       message_string = 'unknown boundary condition: bc_ns = "' // &
1417                        TRIM( bc_ns ) // '"'
1418       CALL message( 'check_parameters', 'PA0050', 1, 2, 0, 6, 0 )
1419    ENDIF
1420
1421!
1422!-- Internal variables used for speed optimization in if clauses
1423    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
1424    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
1425    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
1426    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
1427    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
1428    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
1429
1430!
1431!-- Non-cyclic lateral boundaries require the multigrid method and Piascek-
1432!-- Willimas or Wicker - Skamarock advection scheme. Several schemes
1433!-- and tools do not work with non-cyclic boundary conditions.
1434    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
1435       IF ( psolver /= 'multigrid' )  THEN
1436          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1437                           'psolver = "' // TRIM( psolver ) // '"'
1438          CALL message( 'check_parameters', 'PA0051', 1, 2, 0, 6, 0 )
1439       ENDIF
1440       IF ( momentum_advec /= 'pw-scheme' .AND. &
1441            momentum_advec /= 'ws-scheme')  THEN
1442          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1443                           'momentum_advec = "' // TRIM( momentum_advec ) // '"'
1444          CALL message( 'check_parameters', 'PA0052', 1, 2, 0, 6, 0 )
1445       ENDIF
1446       IF ( scalar_advec /= 'pw-scheme' .AND. &
1447            scalar_advec /= 'ws-scheme' )  THEN
1448          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1449                           'scalar_advec = "' // TRIM( scalar_advec ) // '"'
1450          CALL message( 'check_parameters', 'PA0053', 1, 2, 0, 6, 0 )
1451       ENDIF
1452       IF ( galilei_transformation )  THEN
1453          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1454                           'galilei_transformation = .T.'
1455          CALL message( 'check_parameters', 'PA0054', 1, 2, 0, 6, 0 )
1456       ENDIF
1457    ENDIF
1458
1459!
1460!-- Bottom boundary condition for the turbulent Kinetic energy
1461    IF ( bc_e_b == 'neumann' )  THEN
1462       ibc_e_b = 1
1463    ELSEIF ( bc_e_b == '(u*)**2+neumann' )  THEN
1464       ibc_e_b = 2
1465       IF ( prandtl_layer )  THEN
1466          message_string = 'adjust mixing length = FALSE and bc_e_b = "' // &
1467                           TRIM( bc_e_b ) // '"'
1468          CALL message( 'check_parameters', 'PA0056', 0, 1, 0, 6, 0 )
1469       ENDIF
1470       IF ( .NOT. prandtl_layer )  THEN
1471          bc_e_b = 'neumann'
1472          ibc_e_b = 1
1473          message_string = 'boundary condition bc_e_b changed to "' // &
1474                           TRIM( bc_e_b ) // '"'
1475          CALL message( 'check_parameters', 'PA0057', 0, 1, 0, 6, 0 )
1476       ENDIF
1477    ELSE
1478       message_string = 'unknown boundary condition: bc_e_b = "' // &
1479                        TRIM( bc_e_b ) // '"'
1480       CALL message( 'check_parameters', 'PA0058', 1, 2, 0, 6, 0 )
1481    ENDIF
1482
1483!
1484!-- Boundary conditions for perturbation pressure
1485    IF ( bc_p_b == 'dirichlet' )  THEN
1486       ibc_p_b = 0
1487    ELSEIF ( bc_p_b == 'neumann' )  THEN
1488       ibc_p_b = 1
1489    ELSE
1490       message_string = 'unknown boundary condition: bc_p_b = "' // &
1491                        TRIM( bc_p_b ) // '"'
1492       CALL message( 'check_parameters', 'PA0059', 1, 2, 0, 6, 0 )
1493    ENDIF
1494
1495    IF ( bc_p_t == 'dirichlet' )  THEN
1496       ibc_p_t = 0
1497    ELSEIF ( bc_p_t == 'neumann' )  THEN
1498       ibc_p_t = 1
1499    ELSE
1500       message_string = 'unknown boundary condition: bc_p_t = "' // &
1501                        TRIM( bc_p_t ) // '"'
1502       CALL message( 'check_parameters', 'PA0061', 1, 2, 0, 6, 0 )
1503    ENDIF
1504
1505!
1506!-- Boundary conditions for potential temperature
1507    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1508       ibc_pt_b = 2
1509    ELSE
1510       IF ( bc_pt_b == 'dirichlet' )  THEN
1511          ibc_pt_b = 0
1512       ELSEIF ( bc_pt_b == 'neumann' )  THEN
1513          ibc_pt_b = 1
1514       ELSE
1515          message_string = 'unknown boundary condition: bc_pt_b = "' // &
1516                           TRIM( bc_pt_b ) // '"'
1517          CALL message( 'check_parameters', 'PA0062', 1, 2, 0, 6, 0 )
1518       ENDIF
1519    ENDIF
1520
1521    IF ( bc_pt_t == 'dirichlet' )  THEN
1522       ibc_pt_t = 0
1523    ELSEIF ( bc_pt_t == 'neumann' )  THEN
1524       ibc_pt_t = 1
1525    ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
1526       ibc_pt_t = 2
1527    ELSE
1528       message_string = 'unknown boundary condition: bc_pt_t = "' // &
1529                        TRIM( bc_pt_t ) // '"'
1530       CALL message( 'check_parameters', 'PA0063', 1, 2, 0, 6, 0 )
1531    ENDIF
1532
1533    IF ( surface_heatflux == 9999999.9_wp  )  THEN
1534       constant_heatflux = .FALSE.
1535       IF ( large_scale_forcing )  THEN
1536          IF ( ibc_pt_b == 0 )  THEN
1537             constant_heatflux = .FALSE.
1538          ELSEIF ( ibc_pt_b == 1 )  THEN
1539             constant_heatflux = .TRUE.
1540             IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1541                surface_heatflux = shf_surf(1)
1542             ENDIF
1543          ENDIF
1544       ENDIF
1545    ELSE
1546        constant_heatflux = .TRUE.
1547        IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. &
1548               large_scale_forcing ) THEN
1549           surface_heatflux = shf_surf(1)
1550        ENDIF
1551    ENDIF
1552
1553    IF ( top_heatflux     == 9999999.9_wp )  constant_top_heatflux = .FALSE.
1554
1555    IF ( neutral )  THEN
1556
1557       IF ( surface_heatflux /= 0.0  .AND.  surface_heatflux /= 9999999.9_wp ) &
1558       THEN
1559          message_string = 'heatflux must not be set for pure neutral flow'
1560          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1561       ENDIF
1562
1563       IF ( top_heatflux /= 0.0  .AND.  top_heatflux /= 9999999.9_wp ) &
1564       THEN
1565          message_string = 'heatflux must not be set for pure neutral flow'
1566          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1567       ENDIF
1568
1569    ENDIF
1570
1571    IF ( top_momentumflux_u /= 9999999.9_wp  .AND.  &
1572         top_momentumflux_v /= 9999999.9_wp )  THEN
1573       constant_top_momentumflux = .TRUE.
1574    ELSEIF (  .NOT. ( top_momentumflux_u == 9999999.9_wp  .AND.  &
1575           top_momentumflux_v == 9999999.9_wp ) )  THEN
1576       message_string = 'both, top_momentumflux_u AND top_momentumflux_v ' // &
1577                        'must be set'
1578       CALL message( 'check_parameters', 'PA0064', 1, 2, 0, 6, 0 )
1579    ENDIF
1580
1581!
1582!-- A given surface temperature implies Dirichlet boundary condition for
1583!-- temperature. In this case specification of a constant heat flux is
1584!-- forbidden.
1585    IF ( ibc_pt_b == 0  .AND.   constant_heatflux  .AND. &
1586         surface_heatflux /= 0.0 )  THEN
1587       message_string = 'boundary_condition: bc_pt_b = "' // TRIM( bc_pt_b ) //&
1588                        '& is not allowed with constant_heatflux = .TRUE.'
1589       CALL message( 'check_parameters', 'PA0065', 1, 2, 0, 6, 0 )
1590    ENDIF
1591    IF ( constant_heatflux  .AND.  pt_surface_initial_change /= 0.0 )  THEN
1592       WRITE ( message_string, * )  'constant_heatflux = .TRUE. is not allo', &
1593               'wed with pt_surface_initial_change (/=0) = ', &
1594               pt_surface_initial_change
1595       CALL message( 'check_parameters', 'PA0066', 1, 2, 0, 6, 0 )
1596    ENDIF
1597
1598!
1599!-- A given temperature at the top implies Dirichlet boundary condition for
1600!-- temperature. In this case specification of a constant heat flux is
1601!-- forbidden.
1602    IF ( ibc_pt_t == 0  .AND.   constant_top_heatflux  .AND. &
1603         top_heatflux /= 0.0 )  THEN
1604       message_string = 'boundary_condition: bc_pt_t = "' // TRIM( bc_pt_t ) //&
1605                        '" is not allowed with constant_top_heatflux = .TRUE.'
1606       CALL message( 'check_parameters', 'PA0067', 1, 2, 0, 6, 0 )
1607    ENDIF
1608
1609!
1610!-- Boundary conditions for salinity
1611    IF ( ocean )  THEN
1612       IF ( bc_sa_t == 'dirichlet' )  THEN
1613          ibc_sa_t = 0
1614       ELSEIF ( bc_sa_t == 'neumann' )  THEN
1615          ibc_sa_t = 1
1616       ELSE
1617          message_string = 'unknown boundary condition: bc_sa_t = "' // &
1618                           TRIM( bc_sa_t ) // '"'
1619          CALL message( 'check_parameters', 'PA0068', 1, 2, 0, 6, 0 )
1620       ENDIF
1621
1622       IF ( top_salinityflux == 9999999.9_wp )  constant_top_salinityflux = .FALSE.
1623       IF ( ibc_sa_t == 1  .AND.   top_salinityflux == 9999999.9_wp )  THEN
1624          message_string = 'boundary condition: bc_sa_t = "' // &
1625                           TRIM( bc_sa_t ) // '" requires to set ' // &
1626                           'top_salinityflux'
1627          CALL message( 'check_parameters', 'PA0069', 1, 2, 0, 6, 0 )
1628       ENDIF
1629
1630!
1631!--    A fixed salinity at the top implies Dirichlet boundary condition for
1632!--    salinity. In this case specification of a constant salinity flux is
1633!--    forbidden.
1634       IF ( ibc_sa_t == 0  .AND.   constant_top_salinityflux  .AND. &
1635            top_salinityflux /= 0.0 )  THEN
1636          message_string = 'boundary condition: bc_sa_t = "' // &
1637                           TRIM( bc_sa_t ) // '" is not allowed with ' // &
1638                           'constant_top_salinityflux = .TRUE.'
1639          CALL message( 'check_parameters', 'PA0070', 1, 2, 0, 6, 0 )
1640       ENDIF
1641
1642    ENDIF
1643
1644!
1645!-- In case of humidity or passive scalar, set boundary conditions for total
1646!-- water content / scalar
1647    IF ( humidity  .OR.  passive_scalar ) THEN
1648       IF ( humidity )  THEN
1649          sq = 'q'
1650       ELSE
1651          sq = 's'
1652       ENDIF
1653       IF ( bc_q_b == 'dirichlet' )  THEN
1654          ibc_q_b = 0
1655       ELSEIF ( bc_q_b == 'neumann' )  THEN
1656          ibc_q_b = 1
1657       ELSE
1658          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1659                           '_b ="' // TRIM( bc_q_b ) // '"'
1660          CALL message( 'check_parameters', 'PA0071', 1, 2, 0, 6, 0 )
1661       ENDIF
1662       IF ( bc_q_t == 'dirichlet' )  THEN
1663          ibc_q_t = 0
1664       ELSEIF ( bc_q_t == 'neumann' )  THEN
1665          ibc_q_t = 1
1666       ELSE
1667          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // &
1668                           '_t ="' // TRIM( bc_q_t ) // '"'
1669          CALL message( 'check_parameters', 'PA0072', 1, 2, 0, 6, 0 )
1670       ENDIF
1671
1672       IF ( surface_waterflux == 9999999.9_wp  )  THEN
1673          constant_waterflux = .FALSE.
1674          IF ( large_scale_forcing )  THEN
1675             IF ( ibc_q_b == 0 )  THEN
1676                constant_waterflux = .FALSE.
1677             ELSEIF ( ibc_q_b == 1 )  THEN
1678                constant_waterflux = .TRUE.
1679                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
1680                   surface_waterflux = qsws_surf(1)
1681                ENDIF
1682             ENDIF
1683          ENDIF
1684       ELSE
1685          constant_waterflux = .TRUE.
1686          IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. &
1687                 large_scale_forcing ) THEN
1688             surface_waterflux = qsws_surf(1)
1689          ENDIF
1690       ENDIF
1691
1692!
1693!--    A given surface humidity implies Dirichlet boundary condition for
1694!--    humidity. In this case specification of a constant water flux is
1695!--    forbidden.
1696       IF ( ibc_q_b == 0  .AND.  constant_waterflux )  THEN
1697          message_string = 'boundary condition: bc_' // TRIM( sq ) // '_b ' // &
1698                           '= "' // TRIM( bc_q_b ) // '" is not allowed wi' // &
1699                           'th prescribed surface flux'
1700          CALL message( 'check_parameters', 'PA0073', 1, 2, 0, 6, 0 )
1701       ENDIF
1702       IF ( constant_waterflux  .AND.  q_surface_initial_change /= 0.0 )  THEN
1703          WRITE( message_string, * )  'a prescribed surface flux is not allo', &
1704                 'wed with ', sq, '_surface_initial_change (/=0) = ', &
1705                 q_surface_initial_change
1706          CALL message( 'check_parameters', 'PA0074', 1, 2, 0, 6, 0 )
1707       ENDIF
1708
1709    ENDIF
1710!
1711!-- Boundary conditions for horizontal components of wind speed
1712    IF ( bc_uv_b == 'dirichlet' )  THEN
1713       ibc_uv_b = 0
1714    ELSEIF ( bc_uv_b == 'neumann' )  THEN
1715       ibc_uv_b = 1
1716       IF ( prandtl_layer )  THEN
1717          message_string = 'boundary condition: bc_uv_b = "' // &
1718               TRIM( bc_uv_b ) // '" is not allowed with prandtl_layer = .TRUE.'
1719          CALL message( 'check_parameters', 'PA0075', 1, 2, 0, 6, 0 )
1720       ENDIF
1721    ELSE
1722       message_string = 'unknown boundary condition: bc_uv_b = "' // &
1723                        TRIM( bc_uv_b ) // '"'
1724       CALL message( 'check_parameters', 'PA0076', 1, 2, 0, 6, 0 )
1725    ENDIF
1726!
1727!-- In case of coupled simulations u and v at the ground in atmosphere will be
1728!-- assigned with the u and v values of the ocean surface
1729    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1730       ibc_uv_b = 2
1731    ENDIF
1732
1733    IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
1734       bc_uv_t = 'neumann'
1735       ibc_uv_t = 1
1736    ELSE
1737       IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
1738          ibc_uv_t = 0
1739          IF ( bc_uv_t == 'dirichlet_0' )  THEN
1740!
1741!--          Velocities for the initial u,v-profiles are set zero at the top
1742!--          in case of dirichlet_0 conditions
1743             u_init(nzt+1)    = 0.0
1744             v_init(nzt+1)    = 0.0
1745          ENDIF
1746       ELSEIF ( bc_uv_t == 'neumann' )  THEN
1747          ibc_uv_t = 1
1748       ELSE
1749          message_string = 'unknown boundary condition: bc_uv_t = "' // &
1750                           TRIM( bc_uv_t ) // '"'
1751          CALL message( 'check_parameters', 'PA0077', 1, 2, 0, 6, 0 )
1752       ENDIF
1753    ENDIF
1754
1755!
1756!-- Compute and check, respectively, the Rayleigh Damping parameter
1757    IF ( rayleigh_damping_factor == -1.0 )  THEN
1758       rayleigh_damping_factor = 0.0
1759    ELSE
1760       IF ( rayleigh_damping_factor < 0.0 .OR. rayleigh_damping_factor > 1.0 ) &
1761       THEN
1762          WRITE( message_string, * )  'rayleigh_damping_factor = ', &
1763                              rayleigh_damping_factor, ' out of range [0.0,1.0]'
1764          CALL message( 'check_parameters', 'PA0078', 1, 2, 0, 6, 0 )
1765       ENDIF
1766    ENDIF
1767
1768    IF ( rayleigh_damping_height == -1.0 )  THEN
1769       IF ( .NOT. ocean )  THEN
1770          rayleigh_damping_height = 0.66666666666 * zu(nzt)
1771       ELSE
1772          rayleigh_damping_height = 0.66666666666 * zu(nzb)
1773       ENDIF
1774    ELSE
1775       IF ( .NOT. ocean )  THEN
1776          IF ( rayleigh_damping_height < 0.0  .OR. &
1777               rayleigh_damping_height > zu(nzt) )  THEN
1778             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1779                   rayleigh_damping_height, ' out of range [0.0,', zu(nzt), ']'
1780             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1781          ENDIF
1782       ELSE
1783          IF ( rayleigh_damping_height > 0.0  .OR. &
1784               rayleigh_damping_height < zu(nzb) )  THEN
1785             WRITE( message_string, * )  'rayleigh_damping_height = ', &
1786                   rayleigh_damping_height, ' out of range [0.0,', zu(nzb), ']'
1787             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1788          ENDIF
1789       ENDIF
1790    ENDIF
1791
1792!
1793!-- Check number of chosen statistic regions. More than 10 regions are not
1794!-- allowed, because so far no more than 10 corresponding output files can
1795!-- be opened (cf. check_open)
1796    IF ( statistic_regions > 9  .OR.  statistic_regions < 0 )  THEN
1797       WRITE ( message_string, * ) 'number of statistic_regions = ', &
1798                   statistic_regions+1, ' but only 10 regions are allowed'
1799       CALL message( 'check_parameters', 'PA0082', 1, 2, 0, 6, 0 )
1800    ENDIF
1801    IF ( normalizing_region > statistic_regions  .OR. &
1802         normalizing_region < 0)  THEN
1803       WRITE ( message_string, * ) 'normalizing_region = ', &
1804                normalizing_region, ' must be >= 0 and <= ',statistic_regions, &
1805                ' (value of statistic_regions)'
1806       CALL message( 'check_parameters', 'PA0083', 1, 2, 0, 6, 0 )
1807    ENDIF
1808
1809!
1810!-- Check the interval for sorting particles.
1811!-- Using particles as cloud droplets requires sorting after each timestep.
1812    IF ( dt_sort_particles /= 0.0  .AND.  cloud_droplets )  THEN
1813       dt_sort_particles = 0.0
1814       message_string = 'dt_sort_particles is reset to 0.0 because of cloud' //&
1815                        '_droplets = .TRUE.'
1816       CALL message( 'check_parameters', 'PA0084', 0, 1, 0, 6, 0 )
1817    ENDIF
1818
1819!
1820!-- Set the default intervals for data output, if necessary
1821!-- NOTE: dt_dosp has already been set in package_parin
1822    IF ( dt_data_output /= 9999999.9_wp )  THEN
1823       IF ( dt_dopr           == 9999999.9_wp )  dt_dopr           = dt_data_output
1824       IF ( dt_dopts          == 9999999.9_wp )  dt_dopts          = dt_data_output
1825       IF ( dt_do2d_xy        == 9999999.9_wp )  dt_do2d_xy        = dt_data_output
1826       IF ( dt_do2d_xz        == 9999999.9_wp )  dt_do2d_xz        = dt_data_output
1827       IF ( dt_do2d_yz        == 9999999.9_wp )  dt_do2d_yz        = dt_data_output
1828       IF ( dt_do3d           == 9999999.9_wp )  dt_do3d           = dt_data_output
1829       IF ( dt_data_output_av == 9999999.9_wp )  dt_data_output_av = dt_data_output
1830       DO  mid = 1, max_masks
1831          IF ( dt_domask(mid) == 9999999.9_wp )  dt_domask(mid)    = dt_data_output
1832       ENDDO
1833    ENDIF
1834
1835!
1836!-- Set the default skip time intervals for data output, if necessary
1837    IF ( skip_time_dopr    == 9999999.9_wp ) &
1838                                       skip_time_dopr    = skip_time_data_output
1839    IF ( skip_time_dosp    == 9999999.9_wp ) &
1840                                       skip_time_dosp    = skip_time_data_output
1841    IF ( skip_time_do2d_xy == 9999999.9_wp ) &
1842                                       skip_time_do2d_xy = skip_time_data_output
1843    IF ( skip_time_do2d_xz == 9999999.9_wp ) &
1844                                       skip_time_do2d_xz = skip_time_data_output
1845    IF ( skip_time_do2d_yz == 9999999.9_wp ) &
1846                                       skip_time_do2d_yz = skip_time_data_output
1847    IF ( skip_time_do3d    == 9999999.9_wp ) &
1848                                       skip_time_do3d    = skip_time_data_output
1849    IF ( skip_time_data_output_av == 9999999.9_wp ) &
1850                                skip_time_data_output_av = skip_time_data_output
1851    DO  mid = 1, max_masks
1852       IF ( skip_time_domask(mid) == 9999999.9_wp ) &
1853                                skip_time_domask(mid)    = skip_time_data_output
1854    ENDDO
1855
1856!
1857!-- Check the average intervals (first for 3d-data, then for profiles and
1858!-- spectra)
1859    IF ( averaging_interval > dt_data_output_av )  THEN
1860       WRITE( message_string, * )  'averaging_interval = ', &
1861             averaging_interval, ' must be <= dt_data_output = ', dt_data_output
1862       CALL message( 'check_parameters', 'PA0085', 1, 2, 0, 6, 0 )
1863    ENDIF
1864
1865    IF ( averaging_interval_pr == 9999999.9_wp )  THEN
1866       averaging_interval_pr = averaging_interval
1867    ENDIF
1868
1869    IF ( averaging_interval_pr > dt_dopr )  THEN
1870       WRITE( message_string, * )  'averaging_interval_pr = ', &
1871             averaging_interval_pr, ' must be <= dt_dopr = ', dt_dopr
1872       CALL message( 'check_parameters', 'PA0086', 1, 2, 0, 6, 0 )
1873    ENDIF
1874
1875    IF ( averaging_interval_sp == 9999999.9_wp )  THEN
1876       averaging_interval_sp = averaging_interval
1877    ENDIF
1878
1879    IF ( averaging_interval_sp > dt_dosp )  THEN
1880       WRITE( message_string, * )  'averaging_interval_sp = ', &
1881             averaging_interval_sp, ' must be <= dt_dosp = ', dt_dosp
1882       CALL message( 'check_parameters', 'PA0087', 1, 2, 0, 6, 0 )
1883    ENDIF
1884
1885!
1886!-- Set the default interval for profiles entering the temporal average
1887    IF ( dt_averaging_input_pr == 9999999.9_wp )  THEN
1888       dt_averaging_input_pr = dt_averaging_input
1889    ENDIF
1890
1891!
1892!-- Set the default interval for the output of timeseries to a reasonable
1893!-- value (tries to minimize the number of calls of flow_statistics)
1894    IF ( dt_dots == 9999999.9_wp )  THEN
1895       IF ( averaging_interval_pr == 0.0 )  THEN
1896          dt_dots = MIN( dt_run_control, dt_dopr )
1897       ELSE
1898          dt_dots = MIN( dt_run_control, dt_averaging_input_pr )
1899       ENDIF
1900    ENDIF
1901
1902!
1903!-- Check the sample rate for averaging (first for 3d-data, then for profiles)
1904    IF ( dt_averaging_input > averaging_interval )  THEN
1905       WRITE( message_string, * )  'dt_averaging_input = ', &
1906                dt_averaging_input, ' must be <= averaging_interval = ', &
1907                averaging_interval
1908       CALL message( 'check_parameters', 'PA0088', 1, 2, 0, 6, 0 )
1909    ENDIF
1910
1911    IF ( dt_averaging_input_pr > averaging_interval_pr )  THEN
1912       WRITE( message_string, * )  'dt_averaging_input_pr = ', &
1913                dt_averaging_input_pr, ' must be <= averaging_interval_pr = ', &
1914                averaging_interval_pr
1915       CALL message( 'check_parameters', 'PA0089', 1, 2, 0, 6, 0 )
1916    ENDIF
1917
1918!
1919!-- Set the default value for the integration interval of precipitation amount
1920    IF ( precipitation )  THEN
1921       IF ( precipitation_amount_interval == 9999999.9_wp )  THEN
1922          precipitation_amount_interval = dt_do2d_xy
1923       ELSE
1924          IF ( precipitation_amount_interval > dt_do2d_xy )  THEN
1925             WRITE( message_string, * )  'precipitation_amount_interval = ', &
1926                 precipitation_amount_interval, ' must not be larger than ', &
1927                 'dt_do2d_xy = ', dt_do2d_xy
1928             CALL message( 'check_parameters', 'PA0090', 1, 2, 0, 6, 0 )
1929          ENDIF
1930       ENDIF
1931    ENDIF
1932
1933!
1934!-- Determine the number of output profiles and check whether they are
1935!-- permissible
1936    DO  WHILE ( data_output_pr(dopr_n+1) /= '          ' )
1937
1938       dopr_n = dopr_n + 1
1939       i = dopr_n
1940
1941!
1942!--    Determine internal profile number (for hom, homs)
1943!--    and store height levels
1944       SELECT CASE ( TRIM( data_output_pr(i) ) )
1945
1946          CASE ( 'u', '#u' )
1947             dopr_index(i) = 1
1948             dopr_unit(i)  = 'm/s'
1949             hom(:,2,1,:)  = SPREAD( zu, 2, statistic_regions+1 )
1950             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1951                dopr_initial_index(i) = 5
1952                hom(:,2,5,:)          = SPREAD( zu, 2, statistic_regions+1 )
1953                data_output_pr(i)     = data_output_pr(i)(2:)
1954             ENDIF
1955
1956          CASE ( 'v', '#v' )
1957             dopr_index(i) = 2
1958             dopr_unit(i)  = 'm/s'
1959             hom(:,2,2,:)  = SPREAD( zu, 2, statistic_regions+1 )
1960             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1961                dopr_initial_index(i) = 6
1962                hom(:,2,6,:)          = SPREAD( zu, 2, statistic_regions+1 )
1963                data_output_pr(i)     = data_output_pr(i)(2:)
1964             ENDIF
1965
1966          CASE ( 'w' )
1967             dopr_index(i) = 3
1968             dopr_unit(i)  = 'm/s'
1969             hom(:,2,3,:)  = SPREAD( zw, 2, statistic_regions+1 )
1970
1971          CASE ( 'pt', '#pt' )
1972             IF ( .NOT. cloud_physics ) THEN
1973                dopr_index(i) = 4
1974                dopr_unit(i)  = 'K'
1975                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
1976                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1977                   dopr_initial_index(i) = 7
1978                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
1979                   hom(nzb,2,7,:)        = 0.0    ! because zu(nzb) is negative
1980                   data_output_pr(i)     = data_output_pr(i)(2:)
1981                ENDIF
1982             ELSE
1983                dopr_index(i) = 43
1984                dopr_unit(i)  = 'K'
1985                hom(:,2,43,:)  = SPREAD( zu, 2, statistic_regions+1 )
1986                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1987                   dopr_initial_index(i) = 28
1988                   hom(:,2,28,:)         = SPREAD( zu, 2, statistic_regions+1 )
1989                   hom(nzb,2,28,:)       = 0.0    ! because zu(nzb) is negative
1990                   data_output_pr(i)     = data_output_pr(i)(2:)
1991                ENDIF
1992             ENDIF
1993
1994          CASE ( 'e' )
1995             dopr_index(i)  = 8
1996             dopr_unit(i)   = 'm2/s2'
1997             hom(:,2,8,:)   = SPREAD( zu, 2, statistic_regions+1 )
1998             hom(nzb,2,8,:) = 0.0
1999
2000          CASE ( 'km', '#km' )
2001             dopr_index(i)  = 9
2002             dopr_unit(i)   = 'm2/s'
2003             hom(:,2,9,:)   = SPREAD( zu, 2, statistic_regions+1 )
2004             hom(nzb,2,9,:) = 0.0
2005             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2006                dopr_initial_index(i) = 23
2007                hom(:,2,23,:)         = hom(:,2,9,:)
2008                data_output_pr(i)     = data_output_pr(i)(2:)
2009             ENDIF
2010
2011          CASE ( 'kh', '#kh' )
2012             dopr_index(i)   = 10
2013             dopr_unit(i)    = 'm2/s'
2014             hom(:,2,10,:)   = SPREAD( zu, 2, statistic_regions+1 )
2015             hom(nzb,2,10,:) = 0.0
2016             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2017                dopr_initial_index(i) = 24
2018                hom(:,2,24,:)         = hom(:,2,10,:)
2019                data_output_pr(i)     = data_output_pr(i)(2:)
2020             ENDIF
2021
2022          CASE ( 'l', '#l' )
2023             dopr_index(i)   = 11
2024             dopr_unit(i)    = 'm'
2025             hom(:,2,11,:)   = SPREAD( zu, 2, statistic_regions+1 )
2026             hom(nzb,2,11,:) = 0.0
2027             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2028                dopr_initial_index(i) = 25
2029                hom(:,2,25,:)         = hom(:,2,11,:)
2030                data_output_pr(i)     = data_output_pr(i)(2:)
2031             ENDIF
2032
2033          CASE ( 'w"u"' )
2034             dopr_index(i) = 12
2035             dopr_unit(i)  = 'm2/s2'
2036             hom(:,2,12,:) = SPREAD( zw, 2, statistic_regions+1 )
2037             IF ( prandtl_layer )  hom(nzb,2,12,:) = zu(1)
2038
2039          CASE ( 'w*u*' )
2040             dopr_index(i) = 13
2041             dopr_unit(i)  = 'm2/s2'
2042             hom(:,2,13,:) = SPREAD( zw, 2, statistic_regions+1 )
2043
2044          CASE ( 'w"v"' )
2045             dopr_index(i) = 14
2046             dopr_unit(i)  = 'm2/s2'
2047             hom(:,2,14,:) = SPREAD( zw, 2, statistic_regions+1 )
2048             IF ( prandtl_layer )  hom(nzb,2,14,:) = zu(1)
2049
2050          CASE ( 'w*v*' )
2051             dopr_index(i) = 15
2052             dopr_unit(i)  = 'm2/s2'
2053             hom(:,2,15,:) = SPREAD( zw, 2, statistic_regions+1 )
2054
2055          CASE ( 'w"pt"' )
2056             dopr_index(i) = 16
2057             dopr_unit(i)  = 'K m/s'
2058             hom(:,2,16,:) = SPREAD( zw, 2, statistic_regions+1 )
2059
2060          CASE ( 'w*pt*' )
2061             dopr_index(i) = 17
2062             dopr_unit(i)  = 'K m/s'
2063             hom(:,2,17,:) = SPREAD( zw, 2, statistic_regions+1 )
2064
2065          CASE ( 'wpt' )
2066             dopr_index(i) = 18
2067             dopr_unit(i)  = 'K m/s'
2068             hom(:,2,18,:) = SPREAD( zw, 2, statistic_regions+1 )
2069
2070          CASE ( 'wu' )
2071             dopr_index(i) = 19
2072             dopr_unit(i)  = 'm2/s2'
2073             hom(:,2,19,:) = SPREAD( zw, 2, statistic_regions+1 )
2074             IF ( prandtl_layer )  hom(nzb,2,19,:) = zu(1)
2075
2076          CASE ( 'wv' )
2077             dopr_index(i) = 20
2078             dopr_unit(i)  = 'm2/s2'
2079             hom(:,2,20,:) = SPREAD( zw, 2, statistic_regions+1 )
2080             IF ( prandtl_layer )  hom(nzb,2,20,:) = zu(1)
2081
2082          CASE ( 'w*pt*BC' )
2083             dopr_index(i) = 21
2084             dopr_unit(i)  = 'K m/s'
2085             hom(:,2,21,:) = SPREAD( zw, 2, statistic_regions+1 )
2086
2087          CASE ( 'wptBC' )
2088             dopr_index(i) = 22
2089             dopr_unit(i)  = 'K m/s'
2090             hom(:,2,22,:) = SPREAD( zw, 2, statistic_regions+1 )
2091
2092          CASE ( 'sa', '#sa' )
2093             IF ( .NOT. ocean )  THEN
2094                message_string = 'data_output_pr = ' // &
2095                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2096                                 'lemented for ocean = .FALSE.'
2097                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2098             ELSE
2099                dopr_index(i) = 23
2100                dopr_unit(i)  = 'psu'
2101                hom(:,2,23,:) = SPREAD( zu, 2, statistic_regions+1 )
2102                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2103                   dopr_initial_index(i) = 26
2104                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2105                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2106                   data_output_pr(i)     = data_output_pr(i)(2:)
2107                ENDIF
2108             ENDIF
2109
2110          CASE ( 'u*2' )
2111             dopr_index(i) = 30
2112             dopr_unit(i)  = 'm2/s2'
2113             hom(:,2,30,:) = SPREAD( zu, 2, statistic_regions+1 )
2114
2115          CASE ( 'v*2' )
2116             dopr_index(i) = 31
2117             dopr_unit(i)  = 'm2/s2'
2118             hom(:,2,31,:) = SPREAD( zu, 2, statistic_regions+1 )
2119
2120          CASE ( 'w*2' )
2121             dopr_index(i) = 32
2122             dopr_unit(i)  = 'm2/s2'
2123             hom(:,2,32,:) = SPREAD( zw, 2, statistic_regions+1 )
2124
2125          CASE ( 'pt*2' )
2126             dopr_index(i) = 33
2127             dopr_unit(i)  = 'K2'
2128             hom(:,2,33,:) = SPREAD( zu, 2, statistic_regions+1 )
2129
2130          CASE ( 'e*' )
2131             dopr_index(i) = 34
2132             dopr_unit(i)  = 'm2/s2'
2133             hom(:,2,34,:) = SPREAD( zu, 2, statistic_regions+1 )
2134
2135          CASE ( 'w*2pt*' )
2136             dopr_index(i) = 35
2137             dopr_unit(i)  = 'K m2/s2'
2138             hom(:,2,35,:) = SPREAD( zw, 2, statistic_regions+1 )
2139
2140          CASE ( 'w*pt*2' )
2141             dopr_index(i) = 36
2142             dopr_unit(i)  = 'K2 m/s'
2143             hom(:,2,36,:) = SPREAD( zw, 2, statistic_regions+1 )
2144
2145          CASE ( 'w*e*' )
2146             dopr_index(i) = 37
2147             dopr_unit(i)  = 'm3/s3'
2148             hom(:,2,37,:) = SPREAD( zw, 2, statistic_regions+1 )
2149
2150          CASE ( 'w*3' )
2151             dopr_index(i) = 38
2152             dopr_unit(i)  = 'm3/s3'
2153             hom(:,2,38,:) = SPREAD( zw, 2, statistic_regions+1 )
2154
2155          CASE ( 'Sw' )
2156             dopr_index(i) = 39
2157             dopr_unit(i)  = 'none'
2158             hom(:,2,39,:) = SPREAD( zw, 2, statistic_regions+1 )
2159
2160          CASE ( 'p' )
2161             dopr_index(i) = 40
2162             dopr_unit(i)  = 'Pa'
2163             hom(:,2,40,:) = SPREAD( zu, 2, statistic_regions+1 )
2164
2165          CASE ( 'q', '#q' )
2166             IF ( .NOT. humidity )  THEN
2167                message_string = 'data_output_pr = ' // &
2168                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2169                                 'lemented for humidity = .FALSE.'
2170                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2171             ELSE
2172                dopr_index(i) = 41
2173                dopr_unit(i)  = 'kg/kg'
2174                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2175                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2176                   dopr_initial_index(i) = 26
2177                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2178                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2179                   data_output_pr(i)     = data_output_pr(i)(2:)
2180                ENDIF
2181             ENDIF
2182
2183          CASE ( 's', '#s' )
2184             IF ( .NOT. passive_scalar )  THEN
2185                message_string = 'data_output_pr = ' // &
2186                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2187                                 'lemented for passive_scalar = .FALSE.'
2188                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2189             ELSE
2190                dopr_index(i) = 41
2191                dopr_unit(i)  = 'kg/m3'
2192                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2193                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2194                   dopr_initial_index(i) = 26
2195                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2196                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2197                   data_output_pr(i)     = data_output_pr(i)(2:)
2198                ENDIF
2199             ENDIF
2200
2201          CASE ( 'qv', '#qv' )
2202             IF ( .NOT. cloud_physics ) THEN
2203                dopr_index(i) = 41
2204                dopr_unit(i)  = 'kg/kg'
2205                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
2206                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2207                   dopr_initial_index(i) = 26
2208                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
2209                   hom(nzb,2,26,:)       = 0.0    ! weil zu(nzb) negativ ist
2210                   data_output_pr(i)     = data_output_pr(i)(2:)
2211                ENDIF
2212             ELSE
2213                dopr_index(i) = 42
2214                dopr_unit(i)  = 'kg/kg'
2215                hom(:,2,42,:) = SPREAD( zu, 2, statistic_regions+1 )
2216                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2217                   dopr_initial_index(i) = 27
2218                   hom(:,2,27,:)         = SPREAD( zu, 2, statistic_regions+1 )
2219                   hom(nzb,2,27,:)       = 0.0    ! weil zu(nzb) negativ ist
2220                   data_output_pr(i)     = data_output_pr(i)(2:)
2221                ENDIF
2222             ENDIF
2223
2224          CASE ( 'lpt', '#lpt' )
2225             IF ( .NOT. cloud_physics ) THEN
2226                message_string = 'data_output_pr = ' // &
2227                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2228                                 'lemented for cloud_physics = .FALSE.'
2229                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2230             ELSE
2231                dopr_index(i) = 4
2232                dopr_unit(i)  = 'K'
2233                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
2234                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2235                   dopr_initial_index(i) = 7
2236                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
2237                   hom(nzb,2,7,:)        = 0.0    ! weil zu(nzb) negativ ist
2238                   data_output_pr(i)     = data_output_pr(i)(2:)
2239                ENDIF
2240             ENDIF
2241
2242          CASE ( 'vpt', '#vpt' )
2243             dopr_index(i) = 44
2244             dopr_unit(i)  = 'K'
2245             hom(:,2,44,:) = SPREAD( zu, 2, statistic_regions+1 )
2246             IF ( data_output_pr(i)(1:1) == '#' )  THEN
2247                dopr_initial_index(i) = 29
2248                hom(:,2,29,:)         = SPREAD( zu, 2, statistic_regions+1 )
2249                hom(nzb,2,29,:)       = 0.0    ! weil zu(nzb) negativ ist
2250                data_output_pr(i)     = data_output_pr(i)(2:)
2251             ENDIF
2252
2253          CASE ( 'w"vpt"' )
2254             dopr_index(i) = 45
2255             dopr_unit(i)  = 'K m/s'
2256             hom(:,2,45,:) = SPREAD( zw, 2, statistic_regions+1 )
2257
2258          CASE ( 'w*vpt*' )
2259             dopr_index(i) = 46
2260             dopr_unit(i)  = 'K m/s'
2261             hom(:,2,46,:) = SPREAD( zw, 2, statistic_regions+1 )
2262
2263          CASE ( 'wvpt' )
2264             dopr_index(i) = 47
2265             dopr_unit(i)  = 'K m/s'
2266             hom(:,2,47,:) = SPREAD( zw, 2, statistic_regions+1 )
2267
2268          CASE ( 'w"q"' )
2269             IF ( .NOT. humidity )  THEN
2270                message_string = 'data_output_pr = ' // &
2271                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2272                                 'lemented for humidity = .FALSE.'
2273                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2274             ELSE
2275                dopr_index(i) = 48
2276                dopr_unit(i)  = 'kg/kg m/s'
2277                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2278             ENDIF
2279
2280          CASE ( 'w*q*' )
2281             IF ( .NOT. humidity )  THEN
2282                message_string = 'data_output_pr = ' // &
2283                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2284                                 'lemented for humidity = .FALSE.'
2285                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2286             ELSE
2287                dopr_index(i) = 49
2288                dopr_unit(i)  = 'kg/kg m/s'
2289                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2290             ENDIF
2291
2292          CASE ( 'wq' )
2293             IF ( .NOT. humidity )  THEN
2294                message_string = 'data_output_pr = ' // &
2295                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2296                                 'lemented for humidity = .FALSE.'
2297                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2298             ELSE
2299                dopr_index(i) = 50
2300                dopr_unit(i)  = 'kg/kg m/s'
2301                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2302             ENDIF
2303
2304          CASE ( 'w"s"' )
2305             IF ( .NOT. passive_scalar ) THEN
2306                message_string = 'data_output_pr = ' // &
2307                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2308                                 'lemented for passive_scalar = .FALSE.'
2309                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2310             ELSE
2311                dopr_index(i) = 48
2312                dopr_unit(i)  = 'kg/m3 m/s'
2313                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2314             ENDIF
2315
2316          CASE ( 'w*s*' )
2317             IF ( .NOT. passive_scalar ) THEN
2318                message_string = 'data_output_pr = ' // &
2319                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2320                                 'lemented for passive_scalar = .FALSE.'
2321                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2322             ELSE
2323                dopr_index(i) = 49
2324                dopr_unit(i)  = 'kg/m3 m/s'
2325                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2326             ENDIF
2327
2328          CASE ( 'ws' )
2329             IF ( .NOT. passive_scalar ) THEN
2330                message_string = 'data_output_pr = ' // &
2331                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2332                                 'lemented for passive_scalar = .FALSE.'
2333                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
2334             ELSE
2335                dopr_index(i) = 50
2336                dopr_unit(i)  = 'kg/m3 m/s'
2337                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2338             ENDIF
2339
2340          CASE ( 'w"qv"' )
2341             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2342             THEN
2343                dopr_index(i) = 48
2344                dopr_unit(i)  = 'kg/kg m/s'
2345                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2346             ELSEIF( humidity .AND. cloud_physics ) THEN
2347                dopr_index(i) = 51
2348                dopr_unit(i)  = 'kg/kg m/s'
2349                hom(:,2,51,:) = SPREAD( zw, 2, statistic_regions+1 )
2350             ELSE
2351                message_string = 'data_output_pr = ' // &
2352                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2353                                 'lemented for cloud_physics = .FALSE. an&' // &
2354                                 'd humidity = .FALSE.'
2355                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2356             ENDIF
2357
2358          CASE ( 'w*qv*' )
2359             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2360             THEN
2361                dopr_index(i) = 49
2362                dopr_unit(i)  = 'kg/kg m/s'
2363                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2364             ELSEIF( humidity .AND. cloud_physics ) THEN
2365                dopr_index(i) = 52
2366                dopr_unit(i)  = 'kg/kg m/s'
2367                hom(:,2,52,:) = SPREAD( zw, 2, statistic_regions+1 )
2368             ELSE
2369                message_string = 'data_output_pr = ' // &
2370                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2371                                 'lemented for cloud_physics = .FALSE. an&' // &
2372                                 'd humidity = .FALSE.'
2373                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2374             ENDIF
2375
2376          CASE ( 'wqv' )
2377             IF ( humidity  .AND.  .NOT. cloud_physics ) &
2378             THEN
2379                dopr_index(i) = 50
2380                dopr_unit(i)  = 'kg/kg m/s'
2381                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2382             ELSEIF( humidity .AND. cloud_physics ) THEN
2383                dopr_index(i) = 53
2384                dopr_unit(i)  = 'kg/kg m/s'
2385                hom(:,2,53,:) = SPREAD( zw, 2, statistic_regions+1 )
2386             ELSE
2387                message_string = 'data_output_pr = ' // &
2388                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2389                                 'lemented for cloud_physics = .FALSE. an&' // &
2390                                 'd humidity = .FALSE.'
2391                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2392             ENDIF
2393
2394          CASE ( 'ql' )
2395             IF ( .NOT. cloud_physics  .AND.  .NOT. cloud_droplets )  THEN
2396                message_string = 'data_output_pr = ' // &
2397                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2398                                 'lemented for cloud_physics = .FALSE. or'  // &
2399                                 '&cloud_droplets = .FALSE.'
2400                CALL message( 'check_parameters', 'PA0096', 1, 2, 0, 6, 0 )
2401             ELSE
2402                dopr_index(i) = 54
2403                dopr_unit(i)  = 'kg/kg'
2404                hom(:,2,54,:)  = SPREAD( zu, 2, statistic_regions+1 )
2405             ENDIF
2406
2407          CASE ( 'w*u*u*:dz' )
2408             dopr_index(i) = 55
2409             dopr_unit(i)  = 'm2/s3'
2410             hom(:,2,55,:) = SPREAD( zu, 2, statistic_regions+1 )
2411
2412          CASE ( 'w*p*:dz' )
2413             dopr_index(i) = 56
2414             dopr_unit(i)  = 'm2/s3'
2415             hom(:,2,56,:) = SPREAD( zw, 2, statistic_regions+1 )
2416
2417          CASE ( 'w"e:dz' )
2418             dopr_index(i) = 57
2419             dopr_unit(i)  = 'm2/s3'
2420             hom(:,2,57,:) = SPREAD( zu, 2, statistic_regions+1 )
2421
2422
2423          CASE ( 'u"pt"' )
2424             dopr_index(i) = 58
2425             dopr_unit(i)  = 'K m/s'
2426             hom(:,2,58,:) = SPREAD( zu, 2, statistic_regions+1 )
2427
2428          CASE ( 'u*pt*' )
2429             dopr_index(i) = 59
2430             dopr_unit(i)  = 'K m/s'
2431             hom(:,2,59,:) = SPREAD( zu, 2, statistic_regions+1 )
2432
2433          CASE ( 'upt_t' )
2434             dopr_index(i) = 60
2435             dopr_unit(i)  = 'K m/s'
2436             hom(:,2,60,:) = SPREAD( zu, 2, statistic_regions+1 )
2437
2438          CASE ( 'v"pt"' )
2439             dopr_index(i) = 61
2440             dopr_unit(i)  = 'K m/s'
2441             hom(:,2,61,:) = SPREAD( zu, 2, statistic_regions+1 )
2442             
2443          CASE ( 'v*pt*' )
2444             dopr_index(i) = 62
2445             dopr_unit(i)  = 'K m/s'
2446             hom(:,2,62,:) = SPREAD( zu, 2, statistic_regions+1 )
2447
2448          CASE ( 'vpt_t' )
2449             dopr_index(i) = 63
2450             dopr_unit(i)  = 'K m/s'
2451             hom(:,2,63,:) = SPREAD( zu, 2, statistic_regions+1 )
2452
2453          CASE ( 'rho' )
2454             IF ( .NOT. ocean ) THEN
2455                message_string = 'data_output_pr = ' // &
2456                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2457                                 'lemented for ocean = .FALSE.'
2458                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2459             ELSE
2460                dopr_index(i) = 64
2461                dopr_unit(i)  = 'kg/m3'
2462                hom(:,2,64,:) = SPREAD( zu, 2, statistic_regions+1 )
2463                IF ( data_output_pr(i)(1:1) == '#' )  THEN
2464                   dopr_initial_index(i) = 77
2465                   hom(:,2,77,:)         = SPREAD( zu, 2, statistic_regions+1 )
2466                   hom(nzb,2,77,:)       = 0.0    ! because zu(nzb) is negative
2467                   data_output_pr(i)     = data_output_pr(i)(2:)
2468                ENDIF
2469             ENDIF
2470
2471          CASE ( 'w"sa"' )
2472             IF ( .NOT. ocean ) THEN
2473                message_string = 'data_output_pr = ' // &
2474                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2475                                 'lemented for ocean = .FALSE.'
2476                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2477             ELSE
2478                dopr_index(i) = 65
2479                dopr_unit(i)  = 'psu m/s'
2480                hom(:,2,65,:) = SPREAD( zw, 2, statistic_regions+1 )
2481             ENDIF
2482
2483          CASE ( 'w*sa*' )
2484             IF ( .NOT. ocean ) THEN
2485                message_string = 'data_output_pr = ' // &
2486                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2487                                 'lemented for ocean = .FALSE.'
2488                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2489             ELSE
2490                dopr_index(i) = 66
2491                dopr_unit(i)  = 'psu m/s'
2492                hom(:,2,66,:) = SPREAD( zw, 2, statistic_regions+1 )
2493             ENDIF
2494
2495          CASE ( 'wsa' )
2496             IF ( .NOT. ocean ) THEN
2497                message_string = 'data_output_pr = ' // &
2498                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2499                                 'lemented for ocean = .FALSE.'
2500                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2501             ELSE
2502                dopr_index(i) = 67
2503                dopr_unit(i)  = 'psu m/s'
2504                hom(:,2,67,:) = SPREAD( zw, 2, statistic_regions+1 )
2505             ENDIF
2506
2507          CASE ( 'w*p*' )
2508             dopr_index(i) = 68
2509             dopr_unit(i)  = 'm3/s3'
2510             hom(:,2,68,:) = SPREAD( zu, 2, statistic_regions+1 )
2511
2512          CASE ( 'w"e' )
2513             dopr_index(i) = 69
2514             dopr_unit(i)  = 'm3/s3'
2515             hom(:,2,69,:) = SPREAD( zu, 2, statistic_regions+1 )
2516
2517          CASE ( 'q*2' )
2518             IF ( .NOT. humidity )  THEN
2519                message_string = 'data_output_pr = ' // &
2520                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2521                                 'lemented for humidity = .FALSE.'
2522                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2523             ELSE
2524                dopr_index(i) = 70
2525                dopr_unit(i)  = 'kg2/kg2'
2526                hom(:,2,70,:) = SPREAD( zu, 2, statistic_regions+1 )
2527             ENDIF
2528
2529          CASE ( 'prho' )
2530             IF ( .NOT. ocean ) THEN
2531                message_string = 'data_output_pr = ' // &
2532                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2533                                 'lemented for ocean = .FALSE.'
2534                CALL message( 'check_parameters', 'PA0091', 1, 2, 0, 6, 0 )
2535             ELSE
2536                dopr_index(i) = 71
2537                dopr_unit(i)  = 'kg/m3'
2538                hom(:,2,71,:) = SPREAD( zu, 2, statistic_regions+1 )
2539             ENDIF
2540
2541          CASE ( 'hyp' )
2542             dopr_index(i) = 72
2543             dopr_unit(i)  = 'dbar'
2544             hom(:,2,72,:) = SPREAD( zu, 2, statistic_regions+1 )
2545
2546          CASE ( 'nr' )
2547             IF ( .NOT. cloud_physics )  THEN
2548                message_string = 'data_output_pr = ' // &
2549                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2550                                 'lemented for cloud_physics = .FALSE.'
2551                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2552             ELSEIF ( icloud_scheme /= 0 )  THEN
2553                message_string = 'data_output_pr = ' // &
2554                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2555                                 'lemented for cloud_scheme /= seifert_beheng'
2556                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2557             ELSEIF ( .NOT. precipitation )  THEN
2558                message_string = 'data_output_pr = ' // &
2559                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2560                                 'lemented for precipitation = .FALSE.'
2561                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2562             ELSE
2563                dopr_index(i) = 73
2564                dopr_unit(i)  = '1/m3'
2565                hom(:,2,73,:)  = SPREAD( zu, 2, statistic_regions+1 )
2566             ENDIF
2567
2568          CASE ( 'qr' )
2569             IF ( .NOT. cloud_physics )  THEN
2570                message_string = 'data_output_pr = ' // &
2571                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2572                                 'lemented for cloud_physics = .FALSE.'
2573                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2574             ELSEIF ( icloud_scheme /= 0 )  THEN
2575                message_string = 'data_output_pr = ' // &
2576                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2577                                 'lemented for cloud_scheme /= seifert_beheng'
2578                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2579             ELSEIF ( .NOT. precipitation )  THEN
2580                message_string = 'data_output_pr = ' // &
2581                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2582                                 'lemented for precipitation = .FALSE.'
2583                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2584             ELSE
2585                dopr_index(i) = 74
2586                dopr_unit(i)  = 'kg/kg'
2587                hom(:,2,74,:)  = SPREAD( zu, 2, statistic_regions+1 )
2588             ENDIF
2589
2590          CASE ( 'qc' )
2591             IF ( .NOT. cloud_physics )  THEN
2592                message_string = 'data_output_pr = ' // &
2593                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2594                                 'lemented for cloud_physics = .FALSE.'
2595                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2596             ELSEIF ( icloud_scheme /= 0 )  THEN
2597                message_string = 'data_output_pr = ' // &
2598                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2599                                 'lemented for cloud_scheme /= seifert_beheng'
2600                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2601             ELSE
2602                dopr_index(i) = 75
2603                dopr_unit(i)  = 'kg/kg'
2604                hom(:,2,75,:)  = SPREAD( zu, 2, statistic_regions+1 )
2605             ENDIF
2606
2607          CASE ( 'prr' )
2608             IF ( .NOT. cloud_physics )  THEN
2609                message_string = 'data_output_pr = ' // &
2610                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2611                                 'lemented for cloud_physics = .FALSE.'
2612                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
2613             ELSEIF ( icloud_scheme /= 0 )  THEN
2614                message_string = 'data_output_pr = ' // &
2615                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2616                                 'lemented for cloud_scheme /= seifert_beheng'
2617                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
2618             ELSEIF ( .NOT. precipitation )  THEN
2619                message_string = 'data_output_pr = ' // &
2620                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2621                                 'lemented for precipitation = .FALSE.'
2622                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2623
2624             ELSE
2625                dopr_index(i) = 76
2626                dopr_unit(i)  = 'kg/kg m/s'
2627                hom(:,2,76,:)  = SPREAD( zu, 2, statistic_regions+1 )
2628             ENDIF
2629
2630          CASE ( 'ug' )
2631             dopr_index(i) = 78
2632             dopr_unit(i)  = 'm/s'
2633             hom(:,2,78,:) = SPREAD( zu, 2, statistic_regions+1 )
2634
2635          CASE ( 'vg' )
2636             dopr_index(i) = 79
2637             dopr_unit(i)  = 'm/s'
2638             hom(:,2,79,:) = SPREAD( zu, 2, statistic_regions+1 )
2639
2640          CASE ( 'w_subs' )
2641             IF ( .NOT. large_scale_subsidence )  THEN
2642                message_string = 'data_output_pr = ' // &
2643                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
2644                                 'lemented for large_scale_subsidence = .FALSE.'
2645                CALL message( 'check_parameters', 'PA0382', 1, 2, 0, 6, 0 )
2646             ELSE
2647                dopr_index(i) = 80
2648                dopr_unit(i)  = 'm/s'
2649                hom(:,2,80,:) = SPREAD( zu, 2, statistic_regions+1 )
2650             ENDIF
2651
2652          CASE DEFAULT
2653
2654             CALL user_check_data_output_pr( data_output_pr(i), i, unit )
2655
2656             IF ( unit == 'illegal' )  THEN
2657                IF ( data_output_pr_user(1) /= ' ' )  THEN
2658                   message_string = 'illegal value for data_output_pr or ' // &
2659                                    'data_output_pr_user = "' // &
2660                                    TRIM( data_output_pr(i) ) // '"'
2661                   CALL message( 'check_parameters', 'PA0097', 1, 2, 0, 6, 0 )
2662                ELSE
2663                   message_string = 'illegal value for data_output_pr = "' // &
2664                                    TRIM( data_output_pr(i) ) // '"'
2665                   CALL message( 'check_parameters', 'PA0098', 1, 2, 0, 6, 0 )
2666                ENDIF
2667             ENDIF
2668
2669       END SELECT
2670
2671    ENDDO
2672
2673
2674!
2675!-- Append user-defined data output variables to the standard data output
2676    IF ( data_output_user(1) /= ' ' )  THEN
2677       i = 1
2678       DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2679          i = i + 1
2680       ENDDO
2681       j = 1
2682       DO  WHILE ( data_output_user(j) /= ' '  .AND.  j <= 100 )
2683          IF ( i > 100 )  THEN
2684             message_string = 'number of output quantitities given by data' // &
2685                '_output and data_output_user exceeds the limit of 100'
2686             CALL message( 'check_parameters', 'PA0102', 1, 2, 0, 6, 0 )
2687          ENDIF
2688          data_output(i) = data_output_user(j)
2689          i = i + 1
2690          j = j + 1
2691       ENDDO
2692    ENDIF
2693
2694!
2695!-- Check and set steering parameters for 2d/3d data output and averaging
2696    i   = 1
2697    DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 100 )
2698!
2699!--    Check for data averaging
2700       ilen = LEN_TRIM( data_output(i) )
2701       j = 0                                                 ! no data averaging
2702       IF ( ilen > 3 )  THEN
2703          IF ( data_output(i)(ilen-2:ilen) == '_av' )  THEN
2704             j = 1                                           ! data averaging
2705             data_output(i) = data_output(i)(1:ilen-3)
2706          ENDIF
2707       ENDIF
2708!
2709!--    Check for cross section or volume data
2710       ilen = LEN_TRIM( data_output(i) )
2711       k = 0                                                   ! 3d data
2712       var = data_output(i)(1:ilen)
2713       IF ( ilen > 3 )  THEN
2714          IF ( data_output(i)(ilen-2:ilen) == '_xy'  .OR. &
2715               data_output(i)(ilen-2:ilen) == '_xz'  .OR. &
2716               data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2717             k = 1                                             ! 2d data
2718             var = data_output(i)(1:ilen-3)
2719          ENDIF
2720       ENDIF
2721!
2722!--    Check for allowed value and set units
2723       SELECT CASE ( TRIM( var ) )
2724
2725          CASE ( 'e' )
2726             IF ( constant_diffusion )  THEN
2727                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2728                                 'res constant_diffusion = .FALSE.'
2729                CALL message( 'check_parameters', 'PA0103', 1, 2, 0, 6, 0 )
2730             ENDIF
2731             unit = 'm2/s2'
2732
2733          CASE ( 'lpt' )
2734             IF ( .NOT. cloud_physics )  THEN
2735                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2736                         'res cloud_physics = .TRUE.'
2737                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2738             ENDIF
2739             unit = 'K'
2740
2741          CASE ( 'nr' )
2742             IF ( .NOT. cloud_physics )  THEN
2743                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2744                         'res cloud_physics = .TRUE.'
2745                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2746             ELSEIF ( icloud_scheme /= 0 )  THEN
2747                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2748                         'res cloud_scheme = seifert_beheng'
2749                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2750             ENDIF
2751             unit = '1/m3'
2752
2753          CASE ( 'pc', 'pr' )
2754             IF ( .NOT. particle_advection )  THEN
2755                message_string = 'output of "' // TRIM( var ) // '" requir' // &
2756                   'es a "particles_par"-NAMELIST in the parameter file (PARIN)'
2757                CALL message( 'check_parameters', 'PA0104', 1, 2, 0, 6, 0 )
2758             ENDIF
2759             IF ( TRIM( var ) == 'pc' )  unit = 'number'
2760             IF ( TRIM( var ) == 'pr' )  unit = 'm'
2761
2762          CASE ( 'prr' )
2763             IF ( .NOT. cloud_physics )  THEN
2764                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2765                         'res cloud_physics = .TRUE.'
2766                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2767             ELSEIF ( icloud_scheme /= 0 )  THEN
2768                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2769                         'res cloud_scheme = seifert_beheng'
2770                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2771             ELSEIF ( .NOT. precipitation )  THEN
2772                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2773                                 'res precipitation = .TRUE.'
2774                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2775             ENDIF
2776             unit = 'kg/kg m/s'
2777
2778          CASE ( 'q', 'vpt' )
2779             IF ( .NOT. humidity )  THEN
2780                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2781                                 'res humidity = .TRUE.'
2782                CALL message( 'check_parameters', 'PA0105', 1, 2, 0, 6, 0 )
2783             ENDIF
2784             IF ( TRIM( var ) == 'q'   )  unit = 'kg/kg'
2785             IF ( TRIM( var ) == 'vpt' )  unit = 'K'
2786
2787          CASE ( 'qc' )
2788             IF ( .NOT. cloud_physics )  THEN
2789                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2790                         'res cloud_physics = .TRUE.'
2791                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2792             ELSEIF ( icloud_scheme /= 0 ) THEN
2793                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2794                         'res cloud_scheme = seifert_beheng'
2795                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2796             ENDIF
2797             unit = 'kg/kg'
2798
2799          CASE ( 'ql' )
2800             IF ( .NOT. ( cloud_physics  .OR.  cloud_droplets ) )  THEN
2801                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2802                         'res cloud_physics = .TRUE. or cloud_droplets = .TRUE.'
2803                CALL message( 'check_parameters', 'PA0106', 1, 2, 0, 6, 0 )
2804             ENDIF
2805             unit = 'kg/kg'
2806
2807          CASE ( 'ql_c', 'ql_v', 'ql_vp' )
2808             IF ( .NOT. cloud_droplets )  THEN
2809                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2810                                 'res cloud_droplets = .TRUE.'
2811                CALL message( 'check_parameters', 'PA0107', 1, 2, 0, 6, 0 )
2812             ENDIF
2813             IF ( TRIM( var ) == 'ql_c'  )  unit = 'kg/kg'
2814             IF ( TRIM( var ) == 'ql_v'  )  unit = 'm3'
2815             IF ( TRIM( var ) == 'ql_vp' )  unit = 'none'
2816
2817          CASE ( 'qr' )
2818             IF ( .NOT. cloud_physics )  THEN
2819                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2820                         'res cloud_physics = .TRUE.'
2821                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2822             ELSEIF ( icloud_scheme /= 0 ) THEN
2823                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2824                         'res cloud_scheme = seifert_beheng'
2825                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
2826             ELSEIF ( .NOT. precipitation )  THEN
2827                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2828                                 'res precipitation = .TRUE.'
2829                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2830             ENDIF
2831             unit = 'kg/kg'
2832
2833          CASE ( 'qv' )
2834             IF ( .NOT. cloud_physics )  THEN
2835                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2836                                 'res cloud_physics = .TRUE.'
2837                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2838             ENDIF
2839             unit = 'kg/kg'
2840
2841          CASE ( 'rho' )
2842             IF ( .NOT. ocean )  THEN
2843                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2844                                 'res ocean = .TRUE.'
2845                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2846             ENDIF
2847             unit = 'kg/m3'
2848
2849          CASE ( 's' )
2850             IF ( .NOT. passive_scalar )  THEN
2851                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2852                                 'res passive_scalar = .TRUE.'
2853                CALL message( 'check_parameters', 'PA0110', 1, 2, 0, 6, 0 )
2854             ENDIF
2855             unit = 'conc'
2856
2857          CASE ( 'sa' )
2858             IF ( .NOT. ocean )  THEN
2859                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2860                                 'res ocean = .TRUE.'
2861                CALL message( 'check_parameters', 'PA0109', 1, 2, 0, 6, 0 )
2862             ENDIF
2863             unit = 'psu'
2864
2865          CASE ( 'u*', 't*', 'lwp*', 'pra*', 'prr*', 'qsws*', 'shf*', 'z0*', 'z0h*' )
2866             IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
2867                message_string = 'illegal value for data_output: "' // &
2868                                 TRIM( var ) // '" & only 2d-horizontal ' // &
2869                                 'cross sections are allowed for this value'
2870                CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
2871             ENDIF
2872             IF ( TRIM( var ) == 'lwp*'  .AND.  .NOT. cloud_physics )  THEN
2873                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2874                                 'res cloud_physics = .TRUE.'
2875                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2876             ENDIF
2877             IF ( TRIM( var ) == 'pra*'  .AND.  .NOT. precipitation )  THEN
2878                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2879                                 'res precipitation = .TRUE.'
2880                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2881             ENDIF
2882             IF ( TRIM( var ) == 'pra*'  .AND.  j == 1 )  THEN
2883                message_string = 'temporal averaging of precipitation ' // &
2884                          'amount "' // TRIM( var ) // '" is not possible'
2885                CALL message( 'check_parameters', 'PA0113', 1, 2, 0, 6, 0 )
2886             ENDIF
2887             IF ( TRIM( var ) == 'prr*'  .AND.  .NOT. precipitation )  THEN
2888                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2889                                 'res precipitation = .TRUE.'
2890                CALL message( 'check_parameters', 'PA0112', 1, 2, 0, 6, 0 )
2891             ENDIF
2892             IF ( TRIM( var ) == 'qsws*'  .AND.  .NOT. humidity )  THEN
2893                message_string = 'output of "' // TRIM( var ) // '" requi' // &
2894                                 'res humidity = .TRUE.'
2895                CALL message( 'check_parameters', 'PA0322', 1, 2, 0, 6, 0 )
2896             ENDIF
2897
2898             IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/kg*m'
2899             IF ( TRIM( var ) == 'pra*'   )  unit = 'mm'
2900             IF ( TRIM( var ) == 'prr*'   )  unit = 'mm/s'
2901             IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
2902             IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
2903             IF ( TRIM( var ) == 't*'     )  unit = 'K'
2904             IF ( TRIM( var ) == 'u*'     )  unit = 'm/s'
2905             IF ( TRIM( var ) == 'z0*'    )  unit = 'm'
2906             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm'
2907
2908
2909          CASE ( 'p', 'pt', 'u', 'v', 'w' )
2910             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
2911             IF ( TRIM( var ) == 'pt' )  unit = 'K'
2912             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
2913             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
2914             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
2915             CONTINUE
2916
2917          CASE DEFAULT
2918             CALL user_check_data_output( var, unit )
2919
2920             IF ( unit == 'illegal' )  THEN
2921                IF ( data_output_user(1) /= ' ' )  THEN
2922                   message_string = 'illegal value for data_output or ' // &
2923                         'data_output_user = "' // TRIM( data_output(i) ) // '"'
2924                   CALL message( 'check_parameters', 'PA0114', 1, 2, 0, 6, 0 )
2925                ELSE
2926                   message_string = 'illegal value for data_output =' // &
2927                                    TRIM( data_output(i) ) // '"'
2928                   CALL message( 'check_parameters', 'PA0115', 1, 2, 0, 6, 0 )
2929                ENDIF
2930             ENDIF
2931
2932       END SELECT
2933!
2934!--    Set the internal steering parameters appropriately
2935       IF ( k == 0 )  THEN
2936          do3d_no(j)              = do3d_no(j) + 1
2937          do3d(j,do3d_no(j))      = data_output(i)
2938          do3d_unit(j,do3d_no(j)) = unit
2939       ELSE
2940          do2d_no(j)              = do2d_no(j) + 1
2941          do2d(j,do2d_no(j))      = data_output(i)
2942          do2d_unit(j,do2d_no(j)) = unit
2943          IF ( data_output(i)(ilen-2:ilen) == '_xy' )  THEN
2944             data_output_xy(j) = .TRUE.
2945          ENDIF
2946          IF ( data_output(i)(ilen-2:ilen) == '_xz' )  THEN
2947             data_output_xz(j) = .TRUE.
2948          ENDIF
2949          IF ( data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2950             data_output_yz(j) = .TRUE.
2951          ENDIF
2952       ENDIF
2953
2954       IF ( j == 1 )  THEN
2955!
2956!--       Check, if variable is already subject to averaging
2957          found = .FALSE.
2958          DO  k = 1, doav_n
2959             IF ( TRIM( doav(k) ) == TRIM( var ) )  found = .TRUE.
2960          ENDDO
2961
2962          IF ( .NOT. found )  THEN
2963             doav_n = doav_n + 1
2964             doav(doav_n) = var
2965          ENDIF
2966       ENDIF
2967
2968       i = i + 1
2969    ENDDO
2970
2971!
2972!-- Averaged 2d or 3d output requires that an averaging interval has been set
2973    IF ( doav_n > 0  .AND.  averaging_interval == 0.0 )  THEN
2974       WRITE( message_string, * )  'output of averaged quantity "',            &
2975                                   TRIM( doav(1) ), '_av" requires to set a ', &
2976                                   'non-zero & averaging interval'
2977       CALL message( 'check_parameters', 'PA0323', 1, 2, 0, 6, 0 )
2978    ENDIF
2979
2980!
2981!-- Check sectional planes and store them in one shared array
2982    IF ( ANY( section_xy > nz + 1 ) )  THEN
2983       WRITE( message_string, * )  'section_xy must be <= nz + 1 = ', nz + 1
2984       CALL message( 'check_parameters', 'PA0319', 1, 2, 0, 6, 0 )
2985    ENDIF
2986    IF ( ANY( section_xz > ny + 1 ) )  THEN
2987       WRITE( message_string, * )  'section_xz must be <= ny + 1 = ', ny + 1
2988       CALL message( 'check_parameters', 'PA0320', 1, 2, 0, 6, 0 )
2989    ENDIF
2990    IF ( ANY( section_yz > nx + 1 ) )  THEN
2991       WRITE( message_string, * )  'section_yz must be <= nx + 1 = ', nx + 1
2992       CALL message( 'check_parameters', 'PA0321', 1, 2, 0, 6, 0 )
2993    ENDIF
2994    section(:,1) = section_xy
2995    section(:,2) = section_xz
2996    section(:,3) = section_yz
2997
2998!
2999!-- Upper plot limit for 2D vertical sections
3000    IF ( z_max_do2d == -1.0 )  z_max_do2d = zu(nzt)
3001    IF ( z_max_do2d < zu(nzb+1)  .OR.  z_max_do2d > zu(nzt) )  THEN
3002       WRITE( message_string, * )  'z_max_do2d = ', z_max_do2d, &
3003                    ' must be >= ', zu(nzb+1), '(zu(nzb+1)) and <= ', zu(nzt), &
3004                    ' (zu(nzt))'
3005       CALL message( 'check_parameters', 'PA0116', 1, 2, 0, 6, 0 )
3006    ENDIF
3007
3008!
3009!-- Upper plot limit for 3D arrays
3010    IF ( nz_do3d == -9999 )  nz_do3d = nzt + 1
3011
3012!
3013!-- Determine and check accuracy for compressed 3D plot output
3014    IF ( do3d_compress )  THEN
3015!
3016!--    Compression only permissible on T3E machines
3017       IF ( host(1:3) /= 't3e' )  THEN
3018          message_string = 'do3d_compress = .TRUE. not allowed on host "' // &
3019                           TRIM( host ) // '"'
3020          CALL message( 'check_parameters', 'PA0117', 1, 2, 0, 6, 0 )
3021       ENDIF
3022
3023       i = 1
3024       DO  WHILE ( do3d_comp_prec(i) /= ' ' )
3025
3026          ilen = LEN_TRIM( do3d_comp_prec(i) )
3027          IF ( LLT( do3d_comp_prec(i)(ilen:ilen), '0' ) .OR. &
3028               LGT( do3d_comp_prec(i)(ilen:ilen), '9' ) )  THEN
3029             WRITE( message_string, * )  'illegal precision: do3d_comp_prec', &
3030                                   '(', i, ') = "', TRIM(do3d_comp_prec(i)),'"'
3031             CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
3032          ENDIF
3033
3034          prec = IACHAR( do3d_comp_prec(i)(ilen:ilen) ) - IACHAR( '0' )
3035          var = do3d_comp_prec(i)(1:ilen-1)
3036
3037          SELECT CASE ( var )
3038
3039             CASE ( 'u' )
3040                j = 1
3041             CASE ( 'v' )
3042                j = 2
3043             CASE ( 'w' )
3044                j = 3
3045             CASE ( 'p' )
3046                j = 4
3047             CASE ( 'pt' )
3048                j = 5
3049
3050             CASE DEFAULT
3051                WRITE( message_string, * )  'unknown variable "', &
3052                     TRIM( do3d_comp_prec(i) ), '" given for do3d_comp_prec(', &
3053                     i, ')'
3054                CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
3055
3056          END SELECT
3057
3058          plot_3d_precision(j)%precision = prec
3059          i = i + 1
3060
3061       ENDDO
3062    ENDIF
3063
3064!
3065!-- Check the data output format(s)
3066    IF ( data_output_format(1) == ' ' )  THEN
3067!
3068!--    Default value
3069       netcdf_output = .TRUE.
3070    ELSE
3071       i = 1
3072       DO  WHILE ( data_output_format(i) /= ' ' )
3073
3074          SELECT CASE ( data_output_format(i) )
3075
3076             CASE ( 'netcdf' )
3077                netcdf_output = .TRUE.
3078             CASE ( 'iso2d' )
3079                iso2d_output  = .TRUE.
3080             CASE ( 'avs' )
3081                avs_output    = .TRUE.
3082
3083             CASE DEFAULT
3084                message_string = 'unknown value for data_output_format "' // &
3085                                 TRIM( data_output_format(i) ) // '"'
3086                CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
3087
3088          END SELECT
3089
3090          i = i + 1
3091          IF ( i > 10 )  EXIT
3092
3093       ENDDO
3094    ENDIF
3095
3096!
3097!-- Set output format string (used in header)
3098    IF ( netcdf_output )  THEN
3099
3100       SELECT CASE ( netcdf_data_format )
3101          CASE ( 1 )
3102             output_format_netcdf = 'netCDF classic'
3103          CASE ( 2 )
3104             output_format_netcdf = 'netCDF 64bit offset'
3105          CASE ( 3 )
3106             output_format_netcdf = 'netCDF4/HDF5'
3107          CASE ( 4 )
3108             output_format_netcdf = 'netCDF4/HDF5 classic'
3109          CASE ( 5 )
3110             output_format_netcdf = 'parallel netCDF4/HDF5'
3111          CASE ( 6 )
3112             output_format_netcdf = 'parallel netCDF4/HDF5 classic'
3113
3114       END SELECT
3115
3116    ENDIF
3117
3118#if defined( __spectra )
3119!
3120!-- Check the number of spectra level to be output
3121    i = 1
3122    DO WHILE ( comp_spectra_level(i) /= 999999  .AND.  i <= 100 )
3123       i = i + 1
3124    ENDDO
3125    i = i - 1
3126    IF ( i == 0 )  THEN
3127       WRITE( message_string, * )  'no spectra levels given'
3128       CALL message( 'check_parameters', 'PA0019', 1, 2, 0, 6, 0 )
3129    ENDIF
3130#endif
3131
3132!
3133!-- Check mask conditions
3134    DO mid = 1, max_masks
3135       IF ( data_output_masks(mid,1) /= ' ' .OR.   &
3136            data_output_masks_user(mid,1) /= ' ' ) THEN
3137          masks = masks + 1
3138       ENDIF
3139    ENDDO
3140   
3141    IF ( masks < 0 .OR. masks > max_masks )  THEN
3142       WRITE( message_string, * )  'illegal value: masks must be >= 0 and ', &
3143            '<= ', max_masks, ' (=max_masks)'
3144       CALL message( 'check_parameters', 'PA0325', 1, 2, 0, 6, 0 )
3145    ENDIF
3146    IF ( masks > 0 )  THEN
3147       mask_scale(1) = mask_scale_x
3148       mask_scale(2) = mask_scale_y
3149       mask_scale(3) = mask_scale_z
3150       IF ( ANY( mask_scale <= 0.0 ) )  THEN
3151          WRITE( message_string, * )  &
3152               'illegal value: mask_scale_x, mask_scale_y and mask_scale_z', &
3153               'must be > 0.0'
3154          CALL message( 'check_parameters', 'PA0326', 1, 2, 0, 6, 0 )
3155       ENDIF
3156!
3157!--    Generate masks for masked data output
3158!--    Parallel netcdf output is not tested so far for masked data, hence
3159!--    netcdf_data_format is switched back to non-paralell output.
3160       netcdf_data_format_save = netcdf_data_format
3161       IF ( netcdf_data_format > 4 )  THEN
3162          IF ( netcdf_data_format == 5 ) netcdf_data_format = 3
3163          IF ( netcdf_data_format == 6 ) netcdf_data_format = 4
3164          message_string = 'netCDF file formats '//                            &
3165                           '5 (parallel netCDF 4) and ' //                     &
3166                           '6 (parallel netCDF 4 Classic model) '//            &
3167                           '&are currently not supported (not yet tested) ' // &
3168                           'for masked data.&Using respective non-parallel' // & 
3169                           ' output for masked data.'
3170          CALL message( 'check_parameters', 'PA0383', 0, 0, 0, 6, 0 )
3171       ENDIF
3172       CALL init_masks
3173       netcdf_data_format = netcdf_data_format_save
3174    ENDIF
3175
3176!
3177!-- Check the NetCDF data format
3178#if ! defined ( __check )
3179    IF ( netcdf_data_format > 2 )  THEN
3180#if defined( __netcdf4 )
3181       CONTINUE
3182#else
3183       message_string = 'netCDF: netCDF4 format requested but no ' // &
3184                        'cpp-directive __netcdf4 given & switch '  // &
3185                        'back to 64-bit offset format'
3186       CALL message( 'check_parameters', 'PA0171', 0, 1, 0, 6, 0 )
3187       netcdf_data_format = 2
3188#endif
3189    ENDIF
3190    IF ( netcdf_data_format > 4 )  THEN
3191#if defined( __netcdf4 ) && defined( __netcdf4_parallel )
3192       CONTINUE
3193#else
3194       message_string = 'netCDF: netCDF4 parallel output requested but no ' // &
3195                        'cpp-directive __netcdf4_parallel given & switch '  // &
3196                        'back to netCDF4 non-parallel output'
3197       CALL message( 'check_parameters', 'PA0099', 0, 1, 0, 6, 0 )
3198       netcdf_data_format = netcdf_data_format - 2
3199#endif
3200    ENDIF
3201#endif
3202
3203!
3204!-- Calculate fixed number of output time levels for parallel netcdf output.
3205!-- The time dimension has to be limited for paralell output, otherwise the
3206!-- performance drops significantly.
3207    IF ( netcdf_output )  THEN
3208       IF ( netcdf_data_format > 4 )  THEN
3209          ntdim_3d(0) = INT( ( end_time - skip_time_do3d ) / dt_do3d )
3210          IF ( do3d_at_begin ) ntdim_3d(0) = ntdim_3d(0) + 1
3211          ntdim_3d(1) = INT( ( end_time - skip_time_data_output_av ) &
3212                              / dt_data_output_av )
3213          ntdim_2d_xy(0) = INT( ( end_time - skip_time_do2d_xy ) / dt_do2d_xy )
3214          ntdim_2d_xz(0) = INT( ( end_time - skip_time_do2d_xz ) / dt_do2d_xz )
3215          ntdim_2d_yz(0) = INT( ( end_time - skip_time_do2d_yz ) / dt_do2d_yz )
3216          IF ( do2d_at_begin )  THEN
3217             ntdim_2d_xy(0) = ntdim_2d_xy(0) + 1
3218             ntdim_2d_xz(0) = ntdim_2d_xz(0) + 1
3219             ntdim_2d_yz(0) = ntdim_2d_yz(0) + 1
3220          ENDIF
3221          ntdim_2d_xy(1) = ntdim_3d(1)
3222          ntdim_2d_xz(1) = ntdim_3d(1)
3223          ntdim_2d_yz(1) = ntdim_3d(1)
3224       ENDIF
3225    ENDIF
3226
3227#if ! defined( __check )
3228!
3229!-- Check netcdf precison
3230    ldum = .FALSE.
3231    CALL define_netcdf_header( 'ch', ldum, 0 )
3232#endif
3233!
3234!-- Check, whether a constant diffusion coefficient shall be used
3235    IF ( km_constant /= -1.0 )  THEN
3236       IF ( km_constant < 0.0 )  THEN
3237          WRITE( message_string, * )  'km_constant = ', km_constant, ' < 0.0'
3238          CALL message( 'check_parameters', 'PA0121', 1, 2, 0, 6, 0 )
3239       ELSE
3240          IF ( prandtl_number < 0.0 )  THEN
3241             WRITE( message_string, * )  'prandtl_number = ', prandtl_number, &
3242                                         ' < 0.0'
3243             CALL message( 'check_parameters', 'PA0122', 1, 2, 0, 6, 0 )
3244          ENDIF
3245          constant_diffusion = .TRUE.
3246
3247          IF ( prandtl_layer )  THEN
3248             message_string = 'prandtl_layer is not allowed with fixed ' // &
3249                              'value of km'
3250             CALL message( 'check_parameters', 'PA0123', 1, 2, 0, 6, 0 )
3251          ENDIF
3252       ENDIF
3253    ENDIF
3254
3255!
3256!-- In case of non-cyclic lateral boundaries and a damping layer for the
3257!-- potential temperature, check the width of the damping layer
3258    IF ( bc_lr /= 'cyclic' ) THEN
3259       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( nx * dx ) )  THEN
3260          message_string = 'pt_damping_width out of range'
3261          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
3262       ENDIF
3263    ENDIF
3264
3265    IF ( bc_ns /= 'cyclic' )  THEN
3266       IF ( pt_damping_width < 0.0  .OR.  pt_damping_width > REAL( ny * dy ) )  THEN
3267          message_string = 'pt_damping_width out of range'
3268          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
3269       ENDIF
3270    ENDIF
3271
3272!
3273!-- Check value range for rif
3274    IF ( rif_min >= rif_max )  THEN
3275       WRITE( message_string, * )  'rif_min = ', rif_min, ' must be less ', &
3276                                   'than rif_max = ', rif_max
3277       CALL message( 'check_parameters', 'PA0125', 1, 2, 0, 6, 0 )
3278    ENDIF
3279
3280!
3281!-- Determine upper and lower hight level indices for random perturbations
3282    IF ( disturbance_level_b == -9999999.9_wp )  THEN
3283       IF ( ocean ) THEN
3284          disturbance_level_b     = zu((nzt*2)/3)
3285          disturbance_level_ind_b = ( nzt * 2 ) / 3
3286       ELSE
3287          disturbance_level_b     = zu(nzb+3)
3288          disturbance_level_ind_b = nzb + 3
3289       ENDIF
3290    ELSEIF ( disturbance_level_b < zu(3) )  THEN
3291       WRITE( message_string, * )  'disturbance_level_b = ', &
3292                           disturbance_level_b, ' must be >= ', zu(3), '(zu(3))'
3293       CALL message( 'check_parameters', 'PA0126', 1, 2, 0, 6, 0 )
3294    ELSEIF ( disturbance_level_b > zu(nzt-2) )  THEN
3295       WRITE( message_string, * )  'disturbance_level_b = ', &
3296                   disturbance_level_b, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
3297       CALL message( 'check_parameters', 'PA0127', 1, 2, 0, 6, 0 )
3298    ELSE
3299       DO  k = 3, nzt-2
3300          IF ( disturbance_level_b <= zu(k) )  THEN
3301             disturbance_level_ind_b = k
3302             EXIT
3303          ENDIF
3304       ENDDO
3305    ENDIF
3306
3307    IF ( disturbance_level_t == -9999999.9_wp )  THEN
3308       IF ( ocean )  THEN
3309          disturbance_level_t     = zu(nzt-3)
3310          disturbance_level_ind_t = nzt - 3
3311       ELSE
3312          disturbance_level_t     = zu(nzt/3)
3313          disturbance_level_ind_t = nzt / 3
3314       ENDIF
3315    ELSEIF ( disturbance_level_t > zu(nzt-2) )  THEN
3316       WRITE( message_string, * )  'disturbance_level_t = ', &
3317                   disturbance_level_t, ' must be <= ', zu(nzt-2), '(zu(nzt-2))'
3318       CALL message( 'check_parameters', 'PA0128', 1, 2, 0, 6, 0 )
3319    ELSEIF ( disturbance_level_t < disturbance_level_b )  THEN
3320       WRITE( message_string, * )  'disturbance_level_t = ', &
3321                   disturbance_level_t, ' must be >= disturbance_level_b = ', &
3322                   disturbance_level_b
3323       CALL message( 'check_parameters', 'PA0129', 1, 2, 0, 6, 0 )
3324    ELSE
3325       DO  k = 3, nzt-2
3326          IF ( disturbance_level_t <= zu(k) )  THEN
3327             disturbance_level_ind_t = k
3328             EXIT
3329          ENDIF
3330       ENDDO
3331    ENDIF
3332
3333!
3334!-- Check again whether the levels determined this way are ok.
3335!-- Error may occur at automatic determination and too few grid points in
3336!-- z-direction.
3337    IF ( disturbance_level_ind_t < disturbance_level_ind_b )  THEN
3338       WRITE( message_string, * )  'disturbance_level_ind_t = ', &
3339                disturbance_level_ind_t, ' must be >= disturbance_level_b = ', &
3340                disturbance_level_b
3341       CALL message( 'check_parameters', 'PA0130', 1, 2, 0, 6, 0 )
3342    ENDIF
3343
3344!
3345!-- Determine the horizontal index range for random perturbations.
3346!-- In case of non-cyclic horizontal boundaries, no perturbations are imposed
3347!-- near the inflow and the perturbation area is further limited to ...(1)
3348!-- after the initial phase of the flow.
3349    dist_nxl = 0;  dist_nxr = nx
3350    dist_nys = 0;  dist_nyn = ny
3351    IF ( bc_lr /= 'cyclic' )  THEN
3352       IF ( inflow_disturbance_begin == -1 )  THEN
3353          inflow_disturbance_begin = MIN( 10, nx/2 )
3354       ENDIF
3355       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > nx )&
3356       THEN
3357          message_string = 'inflow_disturbance_begin out of range'
3358          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3359       ENDIF
3360       IF ( inflow_disturbance_end == -1 )  THEN
3361          inflow_disturbance_end = MIN( 100, 3*nx/4 )
3362       ENDIF
3363       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > nx )    &
3364       THEN
3365          message_string = 'inflow_disturbance_end out of range'
3366          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3367       ENDIF
3368    ELSEIF ( bc_ns /= 'cyclic' )  THEN
3369       IF ( inflow_disturbance_begin == -1 )  THEN
3370          inflow_disturbance_begin = MIN( 10, ny/2 )
3371       ENDIF
3372       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > ny )&
3373       THEN
3374          message_string = 'inflow_disturbance_begin out of range'
3375          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
3376       ENDIF
3377       IF ( inflow_disturbance_end == -1 )  THEN
3378          inflow_disturbance_end = MIN( 100, 3*ny/4 )
3379       ENDIF
3380       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > ny )    &
3381       THEN
3382          message_string = 'inflow_disturbance_end out of range'
3383          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
3384       ENDIF
3385    ENDIF
3386
3387    IF ( bc_lr == 'radiation/dirichlet' )  THEN
3388       dist_nxr    = nx - inflow_disturbance_begin
3389       dist_nxl(1) = nx - inflow_disturbance_end
3390    ELSEIF ( bc_lr == 'dirichlet/radiation' )  THEN
3391       dist_nxl    = inflow_disturbance_begin
3392       dist_nxr(1) = inflow_disturbance_end
3393    ENDIF
3394    IF ( bc_ns == 'dirichlet/radiation' )  THEN
3395       dist_nyn    = ny - inflow_disturbance_begin
3396       dist_nys(1) = ny - inflow_disturbance_end
3397    ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
3398       dist_nys    = inflow_disturbance_begin
3399       dist_nyn(1) = inflow_disturbance_end
3400    ENDIF
3401
3402!
3403!-- A turbulent inflow requires Dirichlet conditions at the respective inflow
3404!-- boundary (so far, a turbulent inflow is realized from the left side only)
3405    IF ( turbulent_inflow  .AND.  bc_lr /= 'dirichlet/radiation' )  THEN
3406       message_string = 'turbulent_inflow = .T. requires a Dirichlet ' // &
3407                        'condition at the inflow boundary'
3408       CALL message( 'check_parameters', 'PA0133', 1, 2, 0, 6, 0 )
3409    ENDIF
3410
3411!
3412!-- Turbulent inflow requires that 3d arrays have been cyclically filled with
3413!-- data from prerun in the first main run
3414    IF ( turbulent_inflow  .AND.  initializing_actions /= 'cyclic_fill'  .AND. &
3415         initializing_actions /= 'read_restart_data' )  THEN
3416       message_string = 'turbulent_inflow = .T. requires ' // &
3417                        'initializing_actions = ''cyclic_fill'' '
3418       CALL message( 'check_parameters', 'PA0055', 1, 2, 0, 6, 0 )
3419    ENDIF
3420
3421!
3422!-- In case of turbulent inflow calculate the index of the recycling plane
3423    IF ( turbulent_inflow )  THEN
3424       IF ( recycling_width == 9999999.9_wp )  THEN
3425!
3426!--       Set the default value for the width of the recycling domain
3427          recycling_width = 0.1 * nx * dx
3428       ELSE
3429          IF ( recycling_width < dx  .OR.  recycling_width > nx * dx )  THEN
3430             WRITE( message_string, * )  'illegal value for recycling_width:', &
3431                                         ' ', recycling_width
3432             CALL message( 'check_parameters', 'PA0134', 1, 2, 0, 6, 0 )
3433          ENDIF
3434       ENDIF
3435!
3436!--    Calculate the index
3437       recycling_plane = recycling_width / dx
3438    ENDIF
3439
3440!
3441!-- Check random generator
3442    IF ( random_generator /= 'system-specific'  .AND. &
3443         random_generator /= 'numerical-recipes' )  THEN
3444       message_string = 'unknown random generator: random_generator = "' // &
3445                        TRIM( random_generator ) // '"'
3446       CALL message( 'check_parameters', 'PA0135', 1, 2, 0, 6, 0 )
3447    ENDIF
3448
3449!
3450!-- Determine damping level index for 1D model
3451    IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
3452       IF ( damp_level_1d == -1.0 )  THEN
3453          damp_level_1d     = zu(nzt+1)
3454          damp_level_ind_1d = nzt + 1
3455       ELSEIF ( damp_level_1d < 0.0  .OR.  damp_level_1d > zu(nzt+1) )  THEN
3456          WRITE( message_string, * )  'damp_level_1d = ', damp_level_1d, &
3457                 ' must be > 0.0 and < ', zu(nzt+1), '(zu(nzt+1))'
3458          CALL message( 'check_parameters', 'PA0136', 1, 2, 0, 6, 0 )
3459       ELSE
3460          DO  k = 1, nzt+1
3461             IF ( damp_level_1d <= zu(k) )  THEN
3462                damp_level_ind_1d = k
3463                EXIT
3464             ENDIF
3465          ENDDO
3466       ENDIF
3467    ENDIF
3468
3469!
3470!-- Check some other 1d-model parameters
3471    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND. &
3472         TRIM( mixing_length_1d ) /= 'blackadar' )  THEN
3473       message_string = 'mixing_length_1d = "' // TRIM( mixing_length_1d ) // &
3474                        '" is unknown'
3475       CALL message( 'check_parameters', 'PA0137', 1, 2, 0, 6, 0 )
3476    ENDIF
3477    IF ( TRIM( dissipation_1d ) /= 'as_in_3d_model'  .AND. &
3478         TRIM( dissipation_1d ) /= 'detering' )  THEN
3479       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) // &
3480                        '" is unknown'
3481       CALL message( 'check_parameters', 'PA0138', 1, 2, 0, 6, 0 )
3482    ENDIF
3483
3484!
3485!-- Set time for the next user defined restart (time_restart is the
3486!-- internal parameter for steering restart events)
3487    IF ( restart_time /= 9999999.9_wp )  THEN
3488       IF ( restart_time > time_since_reference_point )  THEN
3489          time_restart = restart_time
3490       ENDIF
3491    ELSE
3492!
3493!--    In case of a restart run, set internal parameter to default (no restart)
3494!--    if the NAMELIST-parameter restart_time is omitted
3495       time_restart = 9999999.9_wp
3496    ENDIF
3497
3498!
3499!-- Set default value of the time needed to terminate a model run
3500    IF ( termination_time_needed == -1.0 )  THEN
3501       IF ( host(1:3) == 'ibm' )  THEN
3502          termination_time_needed = 300.0
3503       ELSE
3504          termination_time_needed = 35.0
3505       ENDIF
3506    ENDIF
3507
3508!
3509!-- Check the time needed to terminate a model run
3510    IF ( host(1:3) == 't3e' )  THEN
3511!
3512!--    Time needed must be at least 30 seconds on all CRAY machines, because
3513!--    MPP_TREMAIN gives the remaining CPU time only in steps of 30 seconds
3514       IF ( termination_time_needed <= 30.0 )  THEN
3515          WRITE( message_string, * )  'termination_time_needed = ', &
3516                 termination_time_needed, ' must be > 30.0 on host "', &
3517                 TRIM( host ), '"'
3518          CALL message( 'check_parameters', 'PA0139', 1, 2, 0, 6, 0 )
3519       ENDIF
3520    ELSEIF ( host(1:3) == 'ibm' )  THEN
3521!
3522!--    On IBM-regatta machines the time should be at least 300 seconds,
3523!--    because the job time consumed before executing palm (for compiling,
3524!--    copying of files, etc.) has to be regarded
3525       IF ( termination_time_needed < 300.0 )  THEN
3526          WRITE( message_string, * )  'termination_time_needed = ', &
3527                 termination_time_needed, ' should be >= 300.0 on host "', &
3528                 TRIM( host ), '"'
3529          CALL message( 'check_parameters', 'PA0140', 1, 2, 0, 6, 0 )
3530       ENDIF
3531    ENDIF
3532
3533!
3534!-- Check pressure gradient conditions
3535    IF ( dp_external .AND. conserve_volume_flow )  THEN
3536       WRITE( message_string, * )  'Both dp_external and conserve_volume_flo', &
3537            'w are .TRUE. but one of them must be .FALSE.'
3538       CALL message( 'check_parameters', 'PA0150', 1, 2, 0, 6, 0 )
3539    ENDIF
3540    IF ( dp_external )  THEN
3541       IF ( dp_level_b < zu(nzb) .OR. dp_level_b > zu(nzt) )  THEN
3542          WRITE( message_string, * )  'dp_level_b = ', dp_level_b, ' is out ', &
3543               ' of range'
3544          CALL message( 'check_parameters', 'PA0151', 1, 2, 0, 6, 0 )
3545       ENDIF
3546       IF ( .NOT. ANY( dpdxy /= 0.0 ) )  THEN
3547          WRITE( message_string, * )  'dp_external is .TRUE. but dpdxy is ze', &
3548               'ro, i.e. the external pressure gradient & will not be applied'
3549          CALL message( 'check_parameters', 'PA0152', 0, 1, 0, 6, 0 )
3550       ENDIF
3551    ENDIF
3552    IF ( ANY( dpdxy /= 0.0 ) .AND. .NOT. dp_external )  THEN
3553       WRITE( message_string, * )  'dpdxy is nonzero but dp_external is ', &
3554            '.FALSE., i.e. the external pressure gradient & will not be applied'
3555       CALL message( 'check_parameters', 'PA0153', 0, 1, 0, 6, 0 )
3556    ENDIF
3557    IF ( conserve_volume_flow )  THEN
3558       IF ( TRIM( conserve_volume_flow_mode ) == 'default' )  THEN
3559
3560          conserve_volume_flow_mode = 'initial_profiles'
3561
3562       ELSEIF ( TRIM( conserve_volume_flow_mode ) /= 'initial_profiles' .AND.  &
3563            TRIM( conserve_volume_flow_mode ) /= 'inflow_profile' .AND.  &
3564            TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' )  THEN
3565          WRITE( message_string, * )  'unknown conserve_volume_flow_mode: ', &
3566               conserve_volume_flow_mode
3567          CALL message( 'check_parameters', 'PA0154', 1, 2, 0, 6, 0 )
3568       ENDIF
3569       IF ( (bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic')  .AND. &
3570          TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
3571          WRITE( message_string, * )  'non-cyclic boundary conditions ', &
3572               'require  conserve_volume_flow_mode = ''initial_profiles'''
3573          CALL message( 'check_parameters', 'PA0155', 1, 2, 0, 6, 0 )
3574       ENDIF
3575       IF ( bc_lr == 'cyclic'  .AND.  bc_ns == 'cyclic'  .AND.  &
3576            TRIM( conserve_volume_flow_mode ) == 'inflow_profile' )  THEN
3577          WRITE( message_string, * )  'cyclic boundary conditions ', &
3578               'require conserve_volume_flow_mode = ''initial_profiles''', &
3579               ' or ''bulk_velocity'''
3580          CALL message( 'check_parameters', 'PA0156', 1, 2, 0, 6, 0 )
3581       ENDIF
3582    ENDIF
3583    IF ( ( u_bulk /= 0.0 .OR. v_bulk /= 0.0 ) .AND.  &
3584         ( .NOT. conserve_volume_flow .OR.  &
3585         TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' ) )  THEN
3586       WRITE( message_string, * )  'nonzero bulk velocity requires ', &
3587            'conserve_volume_flow = .T. and ', &
3588            'conserve_volume_flow_mode = ''bulk_velocity'''
3589       CALL message( 'check_parameters', 'PA0157', 1, 2, 0, 6, 0 )
3590    ENDIF
3591
3592!
3593!-- Check particle attributes
3594    IF ( particle_color /= 'none' )  THEN
3595       IF ( particle_color /= 'absuv'  .AND.  particle_color /= 'pt*'  .AND.  &
3596            particle_color /= 'z' )  THEN
3597          message_string = 'illegal value for parameter particle_color: ' // &
3598                           TRIM( particle_color)
3599          CALL message( 'check_parameters', 'PA0313', 1, 2, 0, 6, 0 )
3600       ELSE
3601          IF ( color_interval(2) <= color_interval(1) )  THEN
3602             message_string = 'color_interval(2) <= color_interval(1)'
3603             CALL message( 'check_parameters', 'PA0315', 1, 2, 0, 6, 0 )
3604          ENDIF
3605       ENDIF
3606    ENDIF
3607
3608    IF ( particle_dvrpsize /= 'none' )  THEN
3609       IF ( particle_dvrpsize /= 'absw' )  THEN
3610          message_string = 'illegal value for parameter particle_dvrpsize:' // &
3611                           ' ' // TRIM( particle_color)
3612          CALL message( 'check_parameters', 'PA0314', 1, 2, 0, 6, 0 )
3613       ELSE
3614          IF ( dvrpsize_interval(2) <= dvrpsize_interval(1) )  THEN
3615             message_string = 'dvrpsize_interval(2) <= dvrpsize_interval(1)'
3616             CALL message( 'check_parameters', 'PA0316', 1, 2, 0, 6, 0 )
3617          ENDIF
3618       ENDIF
3619    ENDIF
3620
3621!
3622!-- Check nudging and large scale forcing from external file
3623    IF ( nudging .AND. ( .NOT. large_scale_forcing ) )  THEN
3624       message_string = 'Nudging requires large_scale_forcing = .T.. &'// &
3625                        'Surface fluxes and geostrophic wind should be &'// &
3626                        'prescribed in file LSF_DATA'
3627       CALL message( 'check_parameters', 'PA0374', 1, 2, 0, 6, 0 )
3628    ENDIF
3629
3630    IF ( large_scale_forcing .AND. ( bc_lr /= 'cyclic'  .OR. &
3631                                    bc_ns /= 'cyclic' ) )  THEN
3632       message_string = 'Non-cyclic lateral boundaries do not allow for &' // &
3633                        'the usage of large scale forcing from external file.'
3634       CALL message( 'check_parameters', 'PA0375', 1, 2, 0, 6, 0 )
3635     ENDIF
3636
3637    IF ( large_scale_forcing .AND. ( .NOT. humidity ) )  THEN
3638       message_string = 'The usage of large scale forcing from external &'//& 
3639                        'file LSF_DATA requires humidity = .T..'
3640       CALL message( 'check_parameters', 'PA0376', 1, 2, 0, 6, 0 )
3641     ENDIF
3642
3643    IF ( large_scale_forcing .AND. topography /= 'flat' )  THEN
3644       message_string = 'The usage of large scale forcing from external &'//& 
3645                        'file LSF_DATA is not implemented for non-flat topography'
3646       CALL message( 'check_parameters', 'PA0377', 1, 2, 0, 6, 0 )
3647    ENDIF
3648
3649    IF ( large_scale_forcing .AND.  ocean  )  THEN
3650       message_string = 'The usage of large scale forcing from external &'//& 
3651                        'file LSF_DATA is not implemented for ocean runs'
3652       CALL message( 'check_parameters', 'PA0378', 1, 2, 0, 6, 0 )
3653    ENDIF
3654!
3655!-- Check &userpar parameters
3656    CALL user_check_parameters
3657
3658
3659
3660 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.