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

Last change on this file since 1359 was 1359, checked in by hoffmann, 10 years ago

new Lagrangian particle structure integrated

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