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

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

last commit documented

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