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

Last change on this file since 1500 was 1500, checked in by maronga, 9 years ago

bugfixes and adjustments in land surface model

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