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

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

land surface model released

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