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

Last change on this file since 1365 was 1365, checked in by boeske, 10 years ago

large scale forcing enabled

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