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

Last change on this file since 1354 was 1354, checked in by heinze, 10 years ago

last commit documented

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