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

Last change on this file since 1374 was 1366, checked in by boeske, 10 years ago

last commit documented

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