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

Last change on this file since 1504 was 1504, checked in by maronga, 9 years ago

bugfix in check_parameters.f90

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