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

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

last commit documented

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