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

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

Ensemble run capability added to parallel random number generator.

  • Property svn:keywords set to Id
File size: 150.4 KB
Line 
1 SUBROUTINE check_parameters
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22! run_description_header exended to provide ensemble_member_nr if specified
23!
24! Former revisions:
25! -----------------
26! $Id: check_parameters.f90 1429 2014-07-15 12:53:45Z knoop $
27!
28! 1425 2014-07-05 10:57:53Z knoop
29! bugfix: perturbation domain modified for parallel random number generator
30!
31! 1402 2014-05-09 14:25:13Z raasch
32! location messages modified
33!
34! 1400 2014-05-09 14:03:54Z knoop
35! Check random generator extended by option random-parallel
36!
37! 1384 2014-05-02 14:31:06Z raasch
38! location messages added
39!
40! 1365 2014-04-22 15:03:56Z boeske
41! Usage of large scale forcing for pt and q enabled:
42! output for profiles of large scale advection (td_lsa_lpt, td_lsa_q),
43! large scale subsidence (td_sub_lpt, td_sub_q)
44! and nudging tendencies (td_nud_lpt, td_nud_q, td_nud_u and td_nud_v) added,
45! check if use_subsidence_tendencies is used correctly
46!
47! 1361 2014-04-16 15:17:48Z hoffmann
48! PA0363 removed
49! PA0362 changed
50!
51! 1359 2014-04-11 17:15:14Z hoffmann
52! Do not allow the execution of PALM with use_particle_tails, since particle
53! tails are currently not supported by our new particle structure.
54!
55! PA0084 not necessary for new particle structure
56!
57! 1353 2014-04-08 15:21:23Z heinze
58! REAL constants provided with KIND-attribute
59!
60! 1330 2014-03-24 17:29:32Z suehring
61! In case of SGS-particle velocity advection of TKE is also allowed with
62! dissipative 5th-order scheme.
63!
64! 1327 2014-03-21 11:00:16Z raasch
65! "baroclinicity" renamed "baroclinity", "ocean version" replaced by "ocean mode"
66! bugfix: duplicate error message 56 removed,
67! check of data_output_format and do3d_compress removed
68!
69! 1322 2014-03-20 16:38:49Z raasch
70! some REAL constants defined as wp-kind
71!
72! 1320 2014-03-20 08:40:49Z raasch
73! Kind-parameters added to all INTEGER and REAL declaration statements,
74! kinds are defined in new module kinds,
75! revision history before 2012 removed,
76! comment fields (!:) to be used for variable explanations added to
77! all variable declaration statements
78!
79! 1308 2014-03-13 14:58:42Z fricke
80! +netcdf_data_format_save
81! Calculate fixed number of output time levels for parallel netcdf output.
82! For masked data, parallel netcdf output is not tested so far, hence
83! netcdf_data_format is switched back to non-paralell output.
84!
85! 1299 2014-03-06 13:15:21Z heinze
86! enable usage of large_scale subsidence in combination with large_scale_forcing
87! output for profile of large scale vertical velocity w_subs added
88!
89! 1276 2014-01-15 13:40:41Z heinze
90! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars
91!
92! 1241 2013-10-30 11:36:58Z heinze
93! output for profiles of ug and vg added
94! set surface_heatflux and surface_waterflux also in dependence on
95! large_scale_forcing
96! checks for nudging and large scale forcing from external file
97!
98! 1236 2013-09-27 07:21:13Z raasch
99! check number of spectra levels
100!
101! 1216 2013-08-26 09:31:42Z raasch
102! check for transpose_compute_overlap (temporary)
103!
104! 1214 2013-08-21 12:29:17Z kanani
105! additional check for simultaneous use of vertical grid stretching
106! and particle advection
107!
108! 1212 2013-08-15 08:46:27Z raasch
109! checks for poisfft_hybrid removed
110!
111! 1210 2013-08-14 10:58:20Z raasch
112! check for fftw
113!
114! 1179 2013-06-14 05:57:58Z raasch
115! checks and settings of buoyancy parameters and switches revised,
116! initial profile for rho added to hom (id=77)
117!
118! 1174 2013-05-31 10:28:08Z gryschka
119! Bugfix in computing initial profiles for ug, vg, lad, q in case of Atmosphere
120!
121! 1159 2013-05-21 11:58:22Z fricke
122! bc_lr/ns_dirneu/neudir removed
123!
124! 1115 2013-03-26 18:16:16Z hoffmann
125! unused variables removed
126! drizzle can be used without precipitation
127!
128! 1111 2013-03-08 23:54:10Z raasch
129! ibc_p_b = 2 removed
130!
131! 1103 2013-02-20 02:15:53Z raasch
132! Bugfix: turbulent inflow must not require cyclic fill in restart runs
133!
134! 1092 2013-02-02 11:24:22Z raasch
135! unused variables removed
136!
137! 1069 2012-11-28 16:18:43Z maronga
138! allow usage of topography in combination with cloud physics
139!
140! 1065 2012-11-22 17:42:36Z hoffmann
141! Bugfix: It is not allowed to use cloud_scheme = seifert_beheng without
142!         precipitation in order to save computational resources.
143!
144! 1060 2012-11-21 07:19:51Z raasch
145! additional check for parameter turbulent_inflow
146!
147! 1053 2012-11-13 17:11:03Z hoffmann
148! necessary changes for the new two-moment cloud physics scheme added:
149! - check cloud physics scheme (Kessler or Seifert and Beheng)
150! - plant_canopy is not allowed
151! - currently, only cache loop_optimization is allowed
152! - initial profiles of nr, qr
153! - boundary condition of nr, qr
154! - check output quantities (qr, nr, prr)
155!
156! 1036 2012-10-22 13:43:42Z raasch
157! code put under GPL (PALM 3.9)
158!
159! 1031/1034 2012-10-22 11:32:49Z raasch
160! check of netcdf4 parallel file support
161!
162! 1019 2012-09-28 06:46:45Z raasch
163! non-optimized version of prognostic_equations not allowed any more
164!
165! 1015 2012-09-27 09:23:24Z raasch
166! acc allowed for loop optimization,
167! checks for adjustment of mixing length to the Prandtl mixing length removed
168!
169! 1003 2012-09-14 14:35:53Z raasch
170! checks for cases with unequal subdomain sizes removed
171!
172! 1001 2012-09-13 14:08:46Z raasch
173! all actions concerning leapfrog- and upstream-spline-scheme removed
174!
175! 996 2012-09-07 10:41:47Z raasch
176! little reformatting
177
178! 978 2012-08-09 08:28:32Z fricke
179! setting of bc_lr/ns_dirneu/neudir
180! outflow damping layer removed
181! check for z0h*
182! check for pt_damping_width
183!
184! 964 2012-07-26 09:14:24Z raasch
185! check of old profil-parameters removed
186!
187! 940 2012-07-09 14:31:00Z raasch
188! checks for parameter neutral
189!
190! 924 2012-06-06 07:44:41Z maronga
191! Bugfix: preprocessor directives caused error during compilation
192!
193! 892 2012-05-02 13:51:44Z maronga
194! Bugfix for parameter file check ( excluding __netcdf4 )
195!
196! 866 2012-03-28 06:44:41Z raasch
197! use only 60% of the geostrophic wind as translation speed in case of Galilean
198! transformation and use_ug_for_galilei_tr = .T. in order to mimimize the
199! timestep
200!
201! 861 2012-03-26 14:18:34Z suehring
202! Check for topography and ws-scheme removed.
203! Check for loop_optimization = 'vector' and ws-scheme removed.
204!
205! 845 2012-03-07 10:23:05Z maronga
206! Bugfix: exclude __netcdf4 directive part from namelist file check compilation
207!
208! 828 2012-02-21 12:00:36Z raasch
209! check of collision_kernel extended
210!
211! 825 2012-02-19 03:03:44Z raasch
212! check for collision_kernel and curvature_solution_effects
213!
214! 809 2012-01-30 13:32:58Z maronga
215! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
216!
217! 807 2012-01-25 11:53:51Z maronga
218! New cpp directive "__check" implemented which is used by check_namelist_files
219!
220! Revision 1.1  1997/08/26 06:29:23  raasch
221! Initial revision
222!
223!
224! Description:
225! ------------
226! Check control parameters and deduce further quantities.
227!------------------------------------------------------------------------------!
228
229    USE arrays_3d
230    USE cloud_parameters
231    USE constants
232    USE control_parameters
233    USE dvrp_variables
234    USE grid_variables
235    USE indices
236    USE kinds
237    USE model_1d
238    USE netcdf_control
239    USE particle_attributes
240    USE pegrid
241    USE profil_parameter
242    USE spectrum
243    USE statistics
244    USE subsidence_mod
245    USE statistics
246    USE transpose_indices
247
248    IMPLICIT NONE
249
250    CHARACTER (LEN=1)   ::  sq                       !:
251    CHARACTER (LEN=6)   ::  var                      !:
252    CHARACTER (LEN=7)   ::  unit                     !:
253    CHARACTER (LEN=8)   ::  date                     !:
254    CHARACTER (LEN=10)  ::  time                     !:
255    CHARACTER (LEN=40)  ::  coupling_string          !:
256    CHARACTER (LEN=100) ::  action                   !:
257
258    INTEGER(iwp) ::  i                               !:
259    INTEGER(iwp) ::  ilen                            !:
260    INTEGER(iwp) ::  iremote = 0                     !:
261    INTEGER(iwp) ::  j                               !:
262    INTEGER(iwp) ::  k                               !:
263    INTEGER(iwp) ::  kk                              !:
264    INTEGER(iwp) ::  netcdf_data_format_save         !:
265    INTEGER(iwp) ::  position                        !:
266    INTEGER(iwp) ::  prec                            !:
267   
268    LOGICAL     ::  found                            !:
269    LOGICAL     ::  ldum                             !:
270   
271    REAL(wp)    ::  gradient                         !:
272    REAL(wp)    ::  remote = 0.0_wp                  !:
273    REAL(wp)    ::  simulation_time_since_reference  !:
274
275
276    CALL location_message( 'checking parameters', .FALSE. )
277
278!
279!-- Check for overlap combinations, which are not realized yet
280    IF ( transpose_compute_overlap )  THEN
281       IF ( numprocs == 1 )  STOP '+++ transpose-compute-overlap not implemented for single PE runs'
282#if defined( __openacc )
283       STOP '+++ transpose-compute-overlap not implemented for GPU usage'
284#endif
285    ENDIF
286
287!
288!-- Warning, if host is not set
289    IF ( host(1:1) == ' ' )  THEN
290       message_string = '"host" is not set. Please check that environment ' // &
291                        'variable "localhost" & is set before running PALM'
292       CALL message( 'check_parameters', 'PA0001', 0, 0, 0, 6, 0 )
293    ENDIF
294
295!
296!-- Check the coupling mode
297    IF ( coupling_mode /= 'uncoupled'            .AND.  &
298         coupling_mode /= 'atmosphere_to_ocean'  .AND.  &
299         coupling_mode /= 'ocean_to_atmosphere' )  THEN
300       message_string = 'illegal coupling mode: ' // TRIM( coupling_mode )
301       CALL message( 'check_parameters', 'PA0002', 1, 2, 0, 6, 0 )
302    ENDIF
303
304!
305!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
306    IF ( coupling_mode /= 'uncoupled')  THEN
307
308       IF ( dt_coupling == 9999999.9_wp )  THEN
309          message_string = 'dt_coupling is not set but required for coup' // &
310                           'ling mode "' //  TRIM( coupling_mode ) // '"'
311          CALL message( 'check_parameters', 'PA0003', 1, 2, 0, 6, 0 )
312       ENDIF
313
314#if defined( __parallel )
315
316!
317!--    NOTE: coupled runs have not been implemented in the check_namelist_files
318!--    program.
319!--    check_namelist_files will need the following information of the other
320!--    model (atmosphere/ocean).
321!       dt_coupling = remote
322!       dt_max = remote
323!       restart_time = remote
324!       dt_restart= remote
325!       simulation_time_since_reference = remote
326!       dx = remote
327
328
329#if ! defined( __check )
330       IF ( myid == 0 ) THEN
331          CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, &
332                         ierr )
333          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 11, comm_inter, &
334                         status, ierr )
335       ENDIF
336       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
337#endif     
338       IF ( dt_coupling /= remote )  THEN
339          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
340                 '": dt_coupling = ', dt_coupling, '& is not equal to ',       &
341                 'dt_coupling_remote = ', remote
342          CALL message( 'check_parameters', 'PA0004', 1, 2, 0, 6, 0 )
343       ENDIF
344       IF ( dt_coupling <= 0.0_wp )  THEN
345#if ! defined( __check )
346          IF ( myid == 0  ) THEN
347             CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
348             CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 19, comm_inter, &
349                            status, ierr )
350          ENDIF   
351          CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
352#endif         
353          dt_coupling = MAX( dt_max, remote )
354          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
355                 '": dt_coupling <= 0.0 & is not allowed and is reset to ',    &
356                 'MAX(dt_max(A,O)) = ', dt_coupling
357          CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
358       ENDIF
359#if ! defined( __check )
360       IF ( myid == 0 ) THEN
361          CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, &
362                         ierr )
363          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 12, comm_inter, &
364                         status, ierr )
365       ENDIF
366       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
367#endif     
368       IF ( restart_time /= remote )  THEN
369          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
370                 '": restart_time = ', restart_time, '& is not equal to ',     &
371                 'restart_time_remote = ', remote
372          CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
373       ENDIF
374#if ! defined( __check )
375       IF ( myid == 0 ) THEN
376          CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, &
377                         ierr )
378          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 13, comm_inter, &
379                         status, ierr )
380       ENDIF   
381       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
382#endif     
383       IF ( dt_restart /= remote )  THEN
384          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
385                 '": dt_restart = ', dt_restart, '& is not equal to ',         &
386                 'dt_restart_remote = ', remote
387          CALL message( 'check_parameters', 'PA0007', 1, 2, 0, 6, 0 )
388       ENDIF
389
390       simulation_time_since_reference = end_time - coupling_start_time
391#if ! defined( __check )
392       IF  ( myid == 0 ) THEN
393          CALL MPI_SEND( simulation_time_since_reference, 1, MPI_REAL, target_id, &
394                         14, comm_inter, ierr )
395          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 14, comm_inter, &
396                         status, ierr )   
397       ENDIF
398       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
399#endif     
400       IF ( simulation_time_since_reference /= remote )  THEN
401          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
402                 '": simulation_time_since_reference = ',                      &
403                 simulation_time_since_reference, '& is not equal to ',        &
404                 'simulation_time_since_reference_remote = ', remote
405          CALL message( 'check_parameters', 'PA0008', 1, 2, 0, 6, 0 )
406       ENDIF
407
408#if ! defined( __check )
409       IF ( myid == 0 ) THEN
410          CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
411          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 15, comm_inter, &
412                                                             status, ierr )
413       ENDIF
414       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
415
416#endif
417       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
418
419          IF ( dx < remote ) THEN
420             WRITE( message_string, * ) 'coupling mode "', &
421                   TRIM( coupling_mode ),                  &
422           '": dx in Atmosphere is not equal to or not larger then dx in ocean'
423             CALL message( 'check_parameters', 'PA0009', 1, 2, 0, 6, 0 )
424          ENDIF
425
426          IF ( (nx_a+1)*dx /= (nx_o+1)*remote )  THEN
427             WRITE( message_string, * ) 'coupling mode "', &
428                    TRIM( coupling_mode ), &
429             '": Domain size in x-direction is not equal in ocean and atmosphere'
430             CALL message( 'check_parameters', 'PA0010', 1, 2, 0, 6, 0 )
431          ENDIF
432
433       ENDIF
434
435#if ! defined( __check )
436       IF ( myid == 0) THEN
437          CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
438          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 16, comm_inter, &
439                         status, ierr )
440       ENDIF
441       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
442#endif
443       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
444
445          IF ( dy < remote )  THEN
446             WRITE( message_string, * ) 'coupling mode "', &
447                    TRIM( coupling_mode ), &
448                 '": dy in Atmosphere is not equal to or not larger then dy in ocean'
449             CALL message( 'check_parameters', 'PA0011', 1, 2, 0, 6, 0 )
450          ENDIF
451
452          IF ( (ny_a+1)*dy /= (ny_o+1)*remote )  THEN
453             WRITE( message_string, * ) 'coupling mode "', &
454                   TRIM( coupling_mode ), &
455             '": Domain size in y-direction is not equal in ocean and atmosphere'
456             CALL message( 'check_parameters', 'PA0012', 1, 2, 0, 6, 0 )
457          ENDIF
458
459          IF ( MOD(nx_o+1,nx_a+1) /= 0 )  THEN
460             WRITE( message_string, * ) 'coupling mode "', &
461                   TRIM( coupling_mode ), &
462             '": nx+1 in ocean is not divisible without remainder with nx+1 in', & 
463             ' atmosphere'
464             CALL message( 'check_parameters', 'PA0339', 1, 2, 0, 6, 0 )
465          ENDIF
466
467          IF ( MOD(ny_o+1,ny_a+1) /= 0 )  THEN
468             WRITE( message_string, * ) 'coupling mode "', &
469                   TRIM( coupling_mode ), &
470             '": ny+1 in ocean is not divisible without remainder with ny+1 in', & 
471             ' atmosphere'
472             CALL message( 'check_parameters', 'PA0340', 1, 2, 0, 6, 0 )
473          ENDIF
474
475       ENDIF
476#else
477       WRITE( message_string, * ) 'coupling requires PALM to be called with', &
478            ' ''mrun -K parallel'''
479       CALL message( 'check_parameters', 'PA0141', 1, 2, 0, 6, 0 )
480#endif
481    ENDIF
482
483#if defined( __parallel ) && ! defined ( __check )
484!
485!-- Exchange via intercommunicator
486    IF ( coupling_mode == 'atmosphere_to_ocean' .AND. myid == 0 )  THEN
487       CALL MPI_SEND( humidity, 1, MPI_LOGICAL, target_id, 19, comm_inter, &
488                      ierr )
489    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' .AND. myid == 0)  THEN
490       CALL MPI_RECV( humidity_remote, 1, MPI_LOGICAL, target_id, 19, &
491                      comm_inter, status, ierr )
492    ENDIF
493    CALL MPI_BCAST( humidity_remote, 1, MPI_LOGICAL, 0, comm2d, ierr)
494   
495#endif
496
497
498!
499!-- Generate the file header which is used as a header for most of PALM's
500!-- output files
501    CALL DATE_AND_TIME( date, time )
502    run_date = date(7:8)//'-'//date(5:6)//'-'//date(3:4)
503    run_time = time(1:2)//':'//time(3:4)//':'//time(5:6)
504    IF ( coupling_mode == 'uncoupled' )  THEN
505       coupling_string = ''
506    ELSEIF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
507       coupling_string = ' coupled (atmosphere)'
508    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
509       coupling_string = ' coupled (ocean)'
510    ENDIF       
511
512    IF ( ensemble_member_nr /= 0 )  THEN
513       WRITE ( run_description_header,                                         &
514                  '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,I2.2,2X,A,A,2X,A,1X,A)' )      &
515              TRIM( version ), TRIM( revision ), 'run: ',                      &
516              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ),     &
517              'en-no: ', ensemble_member_nr,'host: ', TRIM( host ),            &
518              run_date, run_time
519    ELSE
520       WRITE ( run_description_header,                                         &
521                  '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' )                &
522              TRIM( version ), TRIM( revision ), 'run: ',                      &
523              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ),     &
524              'host: ', TRIM( host ), run_date, run_time
525    ENDIF
526!
527!-- Check the general loop optimization method
528    IF ( loop_optimization == 'default' )  THEN
529       IF ( host(1:3) == 'nec' )  THEN
530          loop_optimization = 'vector'
531       ELSE
532          loop_optimization = 'cache'
533       ENDIF
534    ENDIF
535
536    SELECT CASE ( TRIM( loop_optimization ) )
537
538       CASE ( 'acc', 'cache', 'vector' )
539          CONTINUE
540
541       CASE DEFAULT
542          message_string = 'illegal value given for loop_optimization: "' // &
543                           TRIM( loop_optimization ) // '"'
544          CALL message( 'check_parameters', 'PA0013', 1, 2, 0, 6, 0 )
545
546    END SELECT
547
548!
549!-- Check if vertical grid stretching is used together with particles
550    IF ( dz_stretch_level < 100000.0_wp .AND. particle_advection )  THEN
551       message_string = 'Vertical grid stretching is not allowed together ' // &
552                        'with particle advection.'
553       CALL message( 'check_parameters', 'PA0017', 1, 2, 0, 6, 0 )
554    ENDIF
555
556!
557!--
558    IF ( use_particle_tails )  THEN
559       message_string = 'Particle tails are currently not available due ' //   &
560                        'to the new particle structure.'
561       CALL message( 'check_parameters', 'PA0392', 1, 2, 0, 6, 0 )
562    ENDIF
563
564!
565!-- Check topography setting (check for illegal parameter combinations)
566    IF ( topography /= 'flat' )  THEN
567       action = ' '
568       IF ( scalar_advec /= 'pw-scheme' .AND. scalar_advec /= 'ws-scheme')  THEN
569          WRITE( action, '(A,A)' )  'scalar_advec = ', scalar_advec
570       ENDIF
571       IF ( momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme' ) &
572       THEN
573          WRITE( action, '(A,A)' )  'momentum_advec = ', momentum_advec
574       ENDIF
575       IF ( psolver == 'sor' )  THEN
576          WRITE( action, '(A,A)' )  'psolver = ', psolver
577       ENDIF
578       IF ( sloping_surface )  THEN
579          WRITE( action, '(A)' )  'sloping surface = .TRUE.'
580       ENDIF
581       IF ( galilei_transformation )  THEN
582          WRITE( action, '(A)' )  'galilei_transformation = .TRUE.'
583       ENDIF
584       IF ( cloud_physics )  THEN
585          WRITE( action, '(A)' )  'cloud_physics = .TRUE.'
586       ENDIF
587       IF ( cloud_droplets )  THEN
588          WRITE( action, '(A)' )  'cloud_droplets = .TRUE.'
589       ENDIF
590       IF ( .NOT. prandtl_layer )  THEN
591          WRITE( action, '(A)' )  'prandtl_layer = .FALSE.'
592       ENDIF
593       IF ( action /= ' ' )  THEN
594          message_string = 'a non-flat topography does not allow ' // &
595                           TRIM( action )
596          CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
597       ENDIF
598!
599!--    In case of non-flat topography, check whether the convention how to
600!--    define the topography grid has been set correctly, or whether the default
601!--    is applicable. If this is not possible, abort.
602       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
603          IF ( TRIM( topography ) /= 'single_building' .AND.  &
604               TRIM( topography ) /= 'single_street_canyon' .AND.  &
605               TRIM( topography ) /= 'read_from_file' )  THEN
606!--          The default value is not applicable here, because it is only valid
607!--          for the two standard cases 'single_building' and 'read_from_file'
608!--          defined in init_grid.
609             WRITE( message_string, * )  &
610                  'The value for "topography_grid_convention" ',  &
611                  'is not set. Its default value is & only valid for ',  &
612                  '"topography" = ''single_building'', ',  &
613                  '''single_street_canyon'' & or ''read_from_file''.',  &
614                  ' & Choose ''cell_edge'' or ''cell_center''.'
615             CALL message( 'user_check_parameters', 'PA0239', 1, 2, 0, 6, 0 )
616          ELSE
617!--          The default value is applicable here.
618!--          Set convention according to topography.
619             IF ( TRIM( topography ) == 'single_building' .OR.  &
620                  TRIM( topography ) == 'single_street_canyon' )  THEN
621                topography_grid_convention = 'cell_edge'
622             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
623                topography_grid_convention = 'cell_center'
624             ENDIF
625          ENDIF
626       ELSEIF ( TRIM( topography_grid_convention ) /= 'cell_edge' .AND.  &
627                TRIM( topography_grid_convention ) /= 'cell_center' )  THEN
628          WRITE( message_string, * )  &
629               'The value for "topography_grid_convention" is ', &
630               'not recognized. & Choose ''cell_edge'' or ''cell_center''.'
631          CALL message( 'user_check_parameters', 'PA0240', 1, 2, 0, 6, 0 )
632       ENDIF
633
634    ENDIF
635
636!
637!-- Check ocean setting
638    IF ( ocean )  THEN
639
640       action = ' '
641       IF ( action /= ' ' )  THEN
642          message_string = 'ocean = .T. does not allow ' // TRIM( action )
643          CALL message( 'check_parameters', 'PA0015', 1, 2, 0, 6, 0 )
644       ENDIF
645
646    ELSEIF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.  &
647             TRIM( coupling_char ) == '_O' )  THEN
648
649!
650!--    Check whether an (uncoupled) atmospheric run has been declared as an
651!--    ocean run (this setting is done via mrun-option -y)
652
653       message_string = 'ocean = .F. does not allow coupling_char = "' // &
654                        TRIM( coupling_char ) // '" set by mrun-option "-y"'
655       CALL message( 'check_parameters', 'PA0317', 1, 2, 0, 6, 0 )
656
657    ENDIF
658!
659!-- Check cloud scheme
660    IF ( cloud_scheme == 'seifert_beheng' )  THEN
661       icloud_scheme = 0
662    ELSEIF ( cloud_scheme == 'kessler' )  THEN
663       icloud_scheme = 1
664    ELSE
665       message_string = 'unknown cloud microphysics scheme cloud_scheme ="' // &
666                        TRIM( cloud_scheme ) // '"'
667       CALL message( 'check_parameters', 'PA0357', 1, 2, 0, 6, 0 )
668    ENDIF
669!
670!-- Check whether there are any illegal values
671!-- Pressure solver:
672    IF ( psolver /= 'poisfft'  .AND. &
673         psolver /= 'sor'  .AND.  psolver /= 'multigrid' )  THEN
674       message_string = 'unknown solver for perturbation pressure: psolver' // &
675                        ' = "' // TRIM( psolver ) // '"'
676       CALL message( 'check_parameters', 'PA0016', 1, 2, 0, 6, 0 )
677    ENDIF
678
679    IF ( psolver == 'multigrid' )  THEN
680       IF ( cycle_mg == 'w' )  THEN
681          gamma_mg = 2
682       ELSEIF ( cycle_mg == 'v' )  THEN
683          gamma_mg = 1
684       ELSE
685          message_string = 'unknown multigrid cycle: cycle_mg = "' // &
686                           TRIM( cycle_mg ) // '"'
687          CALL message( 'check_parameters', 'PA0020', 1, 2, 0, 6, 0 )
688       ENDIF
689    ENDIF
690
691    IF ( fft_method /= 'singleton-algorithm'  .AND.  &
692         fft_method /= 'temperton-algorithm'  .AND.  &
693         fft_method /= 'fftw'                 .AND.  &
694         fft_method /= 'system-specific' )  THEN
695       message_string = 'unknown fft-algorithm: fft_method = "' // &
696                        TRIM( fft_method ) // '"'
697       CALL message( 'check_parameters', 'PA0021', 1, 2, 0, 6, 0 )
698    ENDIF
699   
700    IF( momentum_advec == 'ws-scheme' .AND. & 
701        .NOT. call_psolver_at_all_substeps  ) THEN
702        message_string = 'psolver must be called at each RK3 substep when "'//&
703                      TRIM(momentum_advec) // ' "is used for momentum_advec'
704        CALL message( 'check_parameters', 'PA0344', 1, 2, 0, 6, 0 )
705    END IF
706!
707!-- Advection schemes:
708    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' ) &
709    THEN
710       message_string = 'unknown advection scheme: momentum_advec = "' // &
711                        TRIM( momentum_advec ) // '"'
712       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
713    ENDIF
714    IF ( ( momentum_advec == 'ws-scheme' .OR.  scalar_advec == 'ws-scheme' )   &
715           .AND. ( timestep_scheme == 'euler' .OR.                             &
716                   timestep_scheme == 'runge-kutta-2' ) )                      &
717    THEN
718       message_string = 'momentum_advec or scalar_advec = "' &
719         // TRIM( momentum_advec ) // '" is not allowed with timestep_scheme = "' // &
720         TRIM( timestep_scheme ) // '"'
721       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
722    ENDIF
723    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' .AND. &
724         scalar_advec /= 'bc-scheme' )                                         &
725    THEN
726       message_string = 'unknown advection scheme: scalar_advec = "' // &
727                        TRIM( scalar_advec ) // '"'
728       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
729    ENDIF
730    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' )    &
731    THEN
732       message_string = 'advection_scheme scalar_advec = "' &
733         // TRIM( scalar_advec ) // '" not implemented for & loop_optimization = "' // &
734         TRIM( loop_optimization ) // '"'
735       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
736    ENDIF
737
738    IF ( use_sgs_for_particles  .AND.  .NOT. use_upstream_for_tke .AND.        &
739         scalar_advec /= 'ws-scheme' )  THEN
740       use_upstream_for_tke = .TRUE.
741       message_string = 'use_upstream_for_tke set .TRUE. because ' //          &
742                        'use_sgs_for_particles = .TRUE. '          //          &
743                        'and scalar_advec /= ws-scheme'
744       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
745    ENDIF
746
747    IF ( use_sgs_for_particles  .AND.  curvature_solution_effects )  THEN
748       message_string = 'use_sgs_for_particles = .TRUE. not allowed with ' //  &
749                        'curvature_solution_effects = .TRUE.'
750       CALL message( 'check_parameters', 'PA0349', 1, 2, 0, 6, 0 )
751    ENDIF
752
753!
754!-- Set LOGICAL switches to enhance performance
755    IF ( momentum_advec == 'ws-scheme' )    ws_scheme_mom = .TRUE.
756    IF ( scalar_advec   == 'ws-scheme'   )  ws_scheme_sca = .TRUE.
757
758!
759!-- Timestep schemes:
760    SELECT CASE ( TRIM( timestep_scheme ) )
761
762       CASE ( 'euler' )
763          intermediate_timestep_count_max = 1
764
765       CASE ( 'runge-kutta-2' )
766          intermediate_timestep_count_max = 2
767
768       CASE ( 'runge-kutta-3' )
769          intermediate_timestep_count_max = 3
770
771       CASE DEFAULT
772          message_string = 'unknown timestep scheme: timestep_scheme = "' //   &
773                           TRIM( timestep_scheme ) // '"'
774          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
775
776    END SELECT
777
778    IF ( (momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme')   &
779         .AND. timestep_scheme(1:5) == 'runge' ) THEN
780       message_string = 'momentum advection scheme "' // &
781                        TRIM( momentum_advec ) // '" & does not work with ' // &
782                        'timestep_scheme "' // TRIM( timestep_scheme ) // '"'
783       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
784    ENDIF
785
786!
787!-- Collision kernels:
788    SELECT CASE ( TRIM( collision_kernel ) )
789
790       CASE ( 'hall', 'hall_fast' )
791          hall_kernel = .TRUE.
792
793       CASE ( 'palm' )
794          palm_kernel = .TRUE.
795
796       CASE ( 'wang', 'wang_fast' )
797          wang_kernel = .TRUE.
798
799       CASE ( 'none' )
800
801
802       CASE DEFAULT
803          message_string = 'unknown collision kernel: collision_kernel = "' // &
804                           TRIM( collision_kernel ) // '"'
805          CALL message( 'check_parameters', 'PA0350', 1, 2, 0, 6, 0 )
806
807    END SELECT
808    IF ( collision_kernel(6:9) == 'fast' )  use_kernel_tables = .TRUE.
809
810    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.  &
811         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
812!
813!--    No restart run: several initialising actions are possible
814       action = initializing_actions
815       DO WHILE ( TRIM( action ) /= '' )
816          position = INDEX( action, ' ' )
817          SELECT CASE ( action(1:position-1) )
818
819             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', &
820                    'by_user', 'initialize_vortex',     'initialize_ptanom' )
821                action = action(position+1:)
822
823             CASE DEFAULT
824                message_string = 'initializing_action = "' // &
825                                 TRIM( action ) // '" unkown or not allowed'
826                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
827
828          END SELECT
829       ENDDO
830    ENDIF
831
832    IF ( TRIM( initializing_actions ) == 'initialize_vortex' .AND. &
833         conserve_volume_flow ) THEN
834         message_string = 'initializing_actions = "initialize_vortex"' // &
835                        ' ist not allowed with conserve_volume_flow = .T.'
836       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
837    ENDIF       
838
839
840    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
841         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
842       message_string = 'initializing_actions = "set_constant_profiles"' // &
843                        ' and "set_1d-model_profiles" are not allowed ' //  &
844                        'simultaneously'
845       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
846    ENDIF
847
848    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
849         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
850       message_string = 'initializing_actions = "set_constant_profiles"' // &
851                        ' and "by_user" are not allowed simultaneously'
852       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
853    ENDIF
854
855    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND. &
856         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
857       message_string = 'initializing_actions = "by_user" and ' // &
858                        '"set_1d-model_profiles" are not allowed simultaneously'
859       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
860    ENDIF
861
862    IF ( cloud_physics  .AND.  .NOT. humidity )  THEN
863       WRITE( message_string, * ) 'cloud_physics = ', cloud_physics, ' is ', &
864              'not allowed with humidity = ', humidity
865       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
866    ENDIF
867
868    IF ( precipitation  .AND.  .NOT.  cloud_physics )  THEN
869       WRITE( message_string, * ) 'precipitation = ', precipitation, ' is ', &
870              'not allowed with cloud_physics = ', cloud_physics
871       CALL message( 'check_parameters', 'PA0035', 1, 2, 0, 6, 0 )
872    ENDIF
873
874    IF ( humidity  .AND.  sloping_surface )  THEN
875       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' // &
876                        'are not allowed simultaneously'
877       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
878    ENDIF
879
880    IF ( passive_scalar  .AND.  humidity )  THEN
881       message_string = 'humidity = .TRUE. and passive_scalar = .TRUE. ' // &
882                        'is not allowed simultaneously'
883       CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
884    ENDIF
885
886    IF ( plant_canopy .AND. ( drag_coefficient == 0.0_wp ) ) THEN
887       message_string = 'plant_canopy = .TRUE. requires a non-zero drag ' // &
888                        'coefficient & given value is drag_coefficient = 0.0'
889       CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
890    ENDIF
891
892    IF ( plant_canopy  .AND.  cloud_physics  .AND.  icloud_scheme == 0 ) THEN
893       message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' //  &
894                        ' seifert_beheng'
895       CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
896    ENDIF
897
898    IF ( .NOT. ( loop_optimization == 'cache'  .OR.                            &
899                 loop_optimization == 'vector' )                               &
900         .AND.  cloud_physics  .AND.  icloud_scheme == 0 )  THEN
901       message_string = 'cloud_scheme = seifert_beheng requires ' // &
902                        'loop_optimization = "cache" or "vector"'
903       CALL message( 'check_parameters', 'PA0362', 1, 2, 0, 6, 0 )
904    ENDIF 
905
906!
907!-- In case of no model continuation run, check initialising parameters and
908!-- deduce further quantities
909    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
910
911!
912!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
913       pt_init = pt_surface
914       IF ( humidity )  THEN
915          q_init  = q_surface
916       ENDIF
917       IF ( ocean )           sa_init = sa_surface
918       IF ( passive_scalar )  q_init  = s_surface
919       IF ( plant_canopy )    lad = 0.0_wp
920
921!
922!--
923!--    If required, compute initial profile of the geostrophic wind
924!--    (component ug)
925       i = 1
926       gradient = 0.0_wp
927
928       IF ( .NOT. ocean )  THEN
929
930          ug_vertical_gradient_level_ind(1) = 0
931          ug(0) = ug_surface
932          DO  k = 1, nzt+1
933             IF ( i < 11 ) THEN
934                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND. &
935                     ug_vertical_gradient_level(i) >= 0.0_wp )  THEN
936                   gradient = ug_vertical_gradient(i) / 100.0_wp
937                   ug_vertical_gradient_level_ind(i) = k - 1
938                   i = i + 1
939                ENDIF
940             ENDIF       
941             IF ( gradient /= 0.0_wp )  THEN
942                IF ( k /= 1 )  THEN
943                   ug(k) = ug(k-1) + dzu(k) * gradient
944                ELSE
945                   ug(k) = ug_surface + dzu(k) * gradient
946                ENDIF
947             ELSE
948                ug(k) = ug(k-1)
949             ENDIF
950          ENDDO
951
952       ELSE
953
954          ug_vertical_gradient_level_ind(1) = nzt+1
955          ug(nzt+1) = ug_surface
956          DO  k = nzt, nzb, -1
957             IF ( i < 11 ) THEN
958                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND. &
959                     ug_vertical_gradient_level(i) <= 0.0_wp )  THEN
960                   gradient = ug_vertical_gradient(i) / 100.0_wp
961                   ug_vertical_gradient_level_ind(i) = k + 1
962                   i = i + 1
963                ENDIF
964             ENDIF
965             IF ( gradient /= 0.0_wp )  THEN
966                IF ( k /= nzt )  THEN
967                   ug(k) = ug(k+1) - dzu(k+1) * gradient
968                ELSE
969                   ug(k)   = ug_surface - 0.5_wp * dzu(k+1) * gradient
970                   ug(k+1) = ug_surface + 0.5_wp * dzu(k+1) * gradient
971                ENDIF
972             ELSE
973                ug(k) = ug(k+1)
974             ENDIF
975          ENDDO
976
977       ENDIF
978
979!
980!--    In case of no given gradients for ug, choose a zero gradient
981       IF ( ug_vertical_gradient_level(1) == -9999999.9_wp )  THEN
982          ug_vertical_gradient_level(1) = 0.0_wp
983       ENDIF 
984
985!
986!--
987!--    If required, compute initial profile of the geostrophic wind
988!--    (component vg)
989       i = 1
990       gradient = 0.0_wp
991
992       IF ( .NOT. ocean )  THEN
993
994          vg_vertical_gradient_level_ind(1) = 0
995          vg(0) = vg_surface
996          DO  k = 1, nzt+1
997             IF ( i < 11 ) THEN
998                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND. &
999                     vg_vertical_gradient_level(i) >= 0.0_wp )  THEN
1000                   gradient = vg_vertical_gradient(i) / 100.0_wp
1001                   vg_vertical_gradient_level_ind(i) = k - 1
1002                   i = i + 1
1003                ENDIF
1004             ENDIF
1005             IF ( gradient /= 0.0_wp )  THEN
1006                IF ( k /= 1 )  THEN
1007                   vg(k) = vg(k-1) + dzu(k) * gradient
1008                ELSE
1009                   vg(k) = vg_surface + dzu(k) * gradient
1010                ENDIF
1011             ELSE
1012                vg(k) = vg(k-1)
1013             ENDIF
1014          ENDDO
1015
1016       ELSE
1017
1018          vg_vertical_gradient_level_ind(1) = nzt+1
1019          vg(nzt+1) = vg_surface
1020          DO  k = nzt, nzb, -1
1021             IF ( i < 11 ) THEN
1022                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND. &
1023                     vg_vertical_gradient_level(i) <= 0.0_wp )  THEN
1024                   gradient = vg_vertical_gradient(i) / 100.0_wp
1025                   vg_vertical_gradient_level_ind(i) = k + 1
1026                   i = i + 1
1027                ENDIF
1028             ENDIF
1029             IF ( gradient /= 0.0_wp )  THEN
1030                IF ( k /= nzt )  THEN
1031                   vg(k) = vg(k+1) - dzu(k+1) * gradient
1032                ELSE
1033                   vg(k)   = vg_surface - 0.5_wp * dzu(k+1) * gradient
1034                   vg(k+1) = vg_surface + 0.5_wp * dzu(k+1) * gradient
1035                ENDIF
1036             ELSE
1037                vg(k) = vg(k+1)
1038             ENDIF
1039          ENDDO
1040
1041       ENDIF
1042
1043!
1044!--    In case of no given gradients for vg, choose a zero gradient
1045       IF ( vg_vertical_gradient_level(1) == -9999999.9_wp )  THEN
1046          vg_vertical_gradient_level(1) = 0.0_wp
1047       ENDIF
1048
1049!
1050!--    Let the initial wind profiles be the calculated ug/vg profiles or
1051!--    interpolate them from wind profile data (if given)
1052       IF ( u_profile(1) == 9999999.9_wp  .AND.  v_profile(1) == 9999999.9_wp )  THEN
1053
1054          u_init = ug
1055          v_init = vg
1056
1057       ELSEIF ( u_profile(1) == 0.0_wp  .AND.  v_profile(1) == 0.0_wp )  THEN
1058
1059          IF ( uv_heights(1) /= 0.0_wp )  THEN
1060             message_string = 'uv_heights(1) must be 0.0'
1061             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
1062          ENDIF
1063
1064          use_prescribed_profile_data = .TRUE.
1065
1066          kk = 1
1067          u_init(0) = 0.0_wp
1068          v_init(0) = 0.0_wp
1069
1070          DO  k = 1, nz+1
1071
1072             IF ( kk < 100 )  THEN
1073                DO WHILE ( uv_heights(kk+1) <= zu(k) )
1074                   kk = kk + 1
1075                   IF ( kk == 100 )  EXIT
1076                ENDDO
1077             ENDIF
1078
1079             IF ( kk < 100 .AND. uv_heights(kk+1) /= 9999999.9_wp )  THEN
1080                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1081                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1082                                       ( u_profile(kk+1) - u_profile(kk) )
1083                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1084                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1085                                       ( v_profile(kk+1) - v_profile(kk) )
1086             ELSE
1087                u_init(k) = u_profile(kk)
1088                v_init(k) = v_profile(kk)
1089             ENDIF
1090
1091          ENDDO
1092
1093       ELSE
1094
1095          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1096          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1097
1098       ENDIF
1099
1100!
1101!--    Compute initial temperature profile using the given temperature gradients
1102       IF ( .NOT. neutral )  THEN
1103
1104          i = 1
1105          gradient = 0.0_wp
1106
1107          IF ( .NOT. ocean )  THEN
1108
1109             pt_vertical_gradient_level_ind(1) = 0
1110             DO  k = 1, nzt+1
1111                IF ( i < 11 ) THEN
1112                   IF ( pt_vertical_gradient_level(i) < zu(k)  .AND. &
1113                        pt_vertical_gradient_level(i) >= 0.0_wp )  THEN
1114                      gradient = pt_vertical_gradient(i) / 100.0_wp
1115                      pt_vertical_gradient_level_ind(i) = k - 1
1116                      i = i + 1
1117                   ENDIF
1118                ENDIF
1119                IF ( gradient /= 0.0_wp )  THEN
1120                   IF ( k /= 1 )  THEN
1121                      pt_init(k) = pt_init(k-1) + dzu(k) * gradient
1122                   ELSE
1123                      pt_init(k) = pt_surface   + dzu(k) * gradient
1124                   ENDIF
1125                ELSE
1126                   pt_init(k) = pt_init(k-1)
1127                ENDIF
1128             ENDDO
1129
1130          ELSE
1131
1132             pt_vertical_gradient_level_ind(1) = nzt+1
1133             DO  k = nzt, 0, -1
1134                IF ( i < 11 ) THEN
1135                   IF ( pt_vertical_gradient_level(i) > zu(k)  .AND. &
1136                        pt_vertical_gradient_level(i) <= 0.0_wp )  THEN
1137                      gradient = pt_vertical_gradient(i) / 100.0_wp
1138                      pt_vertical_gradient_level_ind(i) = k + 1
1139                      i = i + 1
1140                   ENDIF
1141                ENDIF
1142                IF ( gradient /= 0.0_wp )  THEN
1143                   IF ( k /= nzt )  THEN
1144                      pt_init(k) = pt_init(k+1) - dzu(k+1) * gradient
1145                   ELSE
1146                      pt_init(k)   = pt_surface - 0.5_wp * dzu(k+1) * gradient
1147                      pt_init(k+1) = pt_surface + 0.5_wp * dzu(k+1) * gradient
1148                   ENDIF
1149                ELSE
1150                   pt_init(k) = pt_init(k+1)
1151                ENDIF
1152             ENDDO
1153
1154          ENDIF
1155
1156       ENDIF
1157
1158!
1159!--    In case of no given temperature gradients, choose gradient of neutral
1160!--    stratification
1161       IF ( pt_vertical_gradient_level(1) == -9999999.9_wp )  THEN
1162          pt_vertical_gradient_level(1) = 0.0_wp
1163       ENDIF
1164
1165!
1166!--    Store temperature gradient at the top boundary for possible Neumann
1167!--    boundary condition
1168       bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1)
1169
1170!
1171!--    If required, compute initial humidity or scalar profile using the given
1172!--    humidity/scalar gradient. In case of scalar transport, initially store
1173!--    values of the scalar parameters on humidity parameters
1174       IF ( passive_scalar )  THEN
1175          bc_q_b                    = bc_s_b
1176          bc_q_t                    = bc_s_t
1177          q_surface                 = s_surface
1178          q_surface_initial_change  = s_surface_initial_change
1179          q_vertical_gradient       = s_vertical_gradient
1180          q_vertical_gradient_level = s_vertical_gradient_level
1181          surface_waterflux         = surface_scalarflux
1182          wall_humidityflux         = wall_scalarflux
1183       ENDIF
1184
1185       IF ( humidity  .OR.  passive_scalar )  THEN
1186
1187          i = 1
1188          gradient = 0.0_wp
1189          q_vertical_gradient_level_ind(1) = 0
1190          DO  k = 1, nzt+1
1191             IF ( i < 11 ) THEN
1192                IF ( q_vertical_gradient_level(i) < zu(k)  .AND. &
1193                     q_vertical_gradient_level(i) >= 0.0_wp )  THEN
1194                   gradient = q_vertical_gradient(i) / 100.0_wp
1195                   q_vertical_gradient_level_ind(i) = k - 1
1196                   i = i + 1
1197                ENDIF
1198             ENDIF
1199             IF ( gradient /= 0.0_wp )  THEN
1200                IF ( k /= 1 )  THEN
1201                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1202                ELSE
1203                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1204                ENDIF
1205             ELSE
1206                q_init(k) = q_init(k-1)
1207             ENDIF
1208!
1209!--          Avoid negative humidities
1210             IF ( q_init(k) < 0.0_wp )  THEN
1211                q_init(k) = 0.0_wp
1212             ENDIF
1213          ENDDO
1214
1215!
1216!--       In case of no given humidity gradients, choose zero gradient
1217!--       conditions
1218          IF ( q_vertical_gradient_level(1) == -1.0_wp )  THEN
1219             q_vertical_gradient_level(1) = 0.0_wp
1220          ENDIF
1221!
1222!--       Store humidity, rain water content and rain drop concentration
1223!--       gradient at the top boundary for possile Neumann boundary condition
1224          bc_q_t_val  = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
1225       ENDIF
1226
1227!
1228!--    If required, compute initial salinity profile using the given salinity
1229!--    gradients
1230       IF ( ocean )  THEN
1231
1232          i = 1
1233          gradient = 0.0_wp
1234
1235          sa_vertical_gradient_level_ind(1) = nzt+1
1236          DO  k = nzt, 0, -1
1237             IF ( i < 11 ) THEN
1238                IF ( sa_vertical_gradient_level(i) > zu(k)  .AND. &
1239                     sa_vertical_gradient_level(i) <= 0.0_wp )  THEN
1240                   gradient = sa_vertical_gradient(i) / 100.0_wp
1241                   sa_vertical_gradient_level_ind(i) = k + 1
1242                   i = i + 1
1243                ENDIF
1244             ENDIF
1245             IF ( gradient /= 0.0_wp )  THEN
1246                IF ( k /= nzt )  THEN
1247                   sa_init(k) = sa_init(k+1) - dzu(k+1) * gradient
1248                ELSE
1249                   sa_init(k)   = sa_surface - 0.5_wp * dzu(k+1) * gradient
1250                   sa_init(k+1) = sa_surface + 0.5_wp * dzu(k+1) * gradient
1251                ENDIF
1252             ELSE
1253                sa_init(k) = sa_init(k+1)
1254             ENDIF
1255          ENDDO
1256
1257       ENDIF
1258
1259!
1260!--    If required compute the profile of leaf area density used in the plant
1261!--    canopy model
1262       IF ( plant_canopy ) THEN
1263       
1264          i = 1
1265          gradient = 0.0_wp
1266
1267          IF ( .NOT. ocean ) THEN
1268
1269             lad(0) = lad_surface
1270 
1271             lad_vertical_gradient_level_ind(1) = 0
1272             DO k = 1, pch_index
1273                IF ( i < 11 ) THEN
1274                   IF ( lad_vertical_gradient_level(i) < zu(k) .AND.  &
1275                        lad_vertical_gradient_level(i) >= 0.0_wp ) THEN
1276                      gradient = lad_vertical_gradient(i)
1277                      lad_vertical_gradient_level_ind(i) = k - 1
1278                      i = i + 1
1279                   ENDIF
1280                ENDIF
1281                IF ( gradient /= 0.0_wp ) THEN
1282                   IF ( k /= 1 ) THEN
1283                      lad(k) = lad(k-1) + dzu(k) * gradient
1284                   ELSE
1285                      lad(k) = lad_surface + dzu(k) *gradient
1286                   ENDIF
1287                ELSE
1288                   lad(k) = lad(k-1)
1289                ENDIF
1290             ENDDO
1291
1292          ENDIF
1293
1294!
1295!--       In case of no given leaf area density gradients, choose a vanishing
1296!--       gradient
1297          IF ( lad_vertical_gradient_level(1) == -9999999.9_wp ) THEN
1298             lad_vertical_gradient_level(1) = 0.0_wp
1299          ENDIF
1300
1301       ENDIF
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  .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 .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!-- Check &userpar parameters
3744    CALL user_check_parameters
3745
3746
3747 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.