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

Last change on this file since 1343 was 1331, checked in by suehring, 10 years ago

last commit documented

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