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

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

last commit documented

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