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

Last change on this file since 1400 was 1400, checked in by knoop, 10 years ago

Parallel random number generator added (preliminary version).

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