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

Last change on this file since 1484 was 1484, checked in by kanani, 10 years ago

New:
---
Subroutine init_plant_canopy added to module plant_canopy_model_mod. (plant_canopy_model)
Alternative method for lad-profile construction added, also, new parameters added.
(header, package_parin, plant_canopy_model, read_var_list, write_var_list)
plant_canopy_model-dependency added to several subroutines. (Makefile)
New package/namelist canopy_par for canopy-related parameters added. (package_parin)

Changed:
---
Code structure of the plant canopy model changed, all canopy-model related code
combined to module plant_canopy_model_mod. (check_parameters, init_3d_model,
modules, timestep)
Module plant_canopy_model_mod added in USE-lists of some subroutines. (check_parameters,
header, init_3d_model, package_parin, read_var_list, user_init_plant_canopy, write_var_list)
Canopy initialization moved to new subroutine init_plant_canopy. (check_parameters,
init_3d_model, plant_canopy_model)
Calculation of canopy timestep-criterion removed, instead, the canopy
drag is now directly limited in the calculation of the canopy tendency terms.
(plant_canopy_model, timestep)
Some parameters renamed. (check_parameters, header, init_plant_canopy,
plant_canopy_model, read_var_list, write_var_list)
Unnecessary 3d-arrays removed. (init_plant_canopy, plant_canopy_model, user_init_plant_canopy)
Parameter checks regarding canopy initialization added. (check_parameters)
All canopy steering parameters moved from namelist inipar to canopy_par. (package_parin, parin)
Some redundant MPI communication removed. (init_plant_canopy)

Bugfix:
---
Missing KIND-attribute for REAL constant added. (check_parameters)
DO-WHILE-loop for lad-profile output restricted. (header)
Removed double-listing of use_upstream_for_tke in ONLY-list of module
control_parameters. (prognostic_equations)

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