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

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

last commit documented

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