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

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

Changed:


-s real64 removed (.mrun.config.hlrnIII)
-r8 removed (.mrun.config.imuk)
deleted: .mrun.config.imuk_ice2_netcdf4 .mrun.config.imuk_hlrn

REAL constants defined as wp-kind in modules

"baroclinicity" renamed "baroclinity", "ocean version" replaced by
"ocean mode"

code parts concerning old output formats "iso2d" and "avs" removed.
netCDF is the only remaining output format.

Errors:


bugfix: duplicate error message 56 removed

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