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

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

last commit documented

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