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

Last change on this file since 1402 was 1402, checked in by raasch, 10 years ago

output of location messages complemented, output of location bar added
(Makefile, check_parameters, cpulog, init_pegrid, init_3d_model, message, palm, parin, time_integration, new: progress_bar)
preprocessor switch intel_compiler added, -r8 compiler options removed
(.mrun.config.default, .mrun.config.imuk, .mrun.config.kiaps)

batch_job added to envpar-NAMELIST
(mrun, parin)

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