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

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

REAL functions and a lot of REAL constants provided with KIND-attribute,
some small bugfixes

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