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

Last change on this file since 4564 was 4564, checked in by raasch, 4 years ago

Vertical nesting method of Huq et al. (2019) removed

  • Property svn:keywords set to Id
  • Property svn:mergeinfo set to False
    /palm/branches/chemistry/SOURCE/check_parameters.f902047-3190,​3218-3297
    /palm/branches/forwind/SOURCE/check_parameters.f901564-1913
    /palm/branches/mosaik_M2/check_parameters.f902360-3471
    /palm/branches/palm4u/SOURCE/check_parameters.f902540-2692
    /palm/branches/rans/SOURCE/check_parameters.f902078-3128
    /palm/branches/resler/SOURCE/check_parameters.f902023-4492
    /palm/branches/salsa/SOURCE/check_parameters.f902503-3581
File size: 139.0 KB
Line 
1!> @file check_parameters.f90
2!--------------------------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
6! Public License as published by the Free Software Foundation, either version 3 of the License, or
7! (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11! Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with PALM. If not, see
14! <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2020 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: check_parameters.f90 4564 2020-06-12 14:03:36Z raasch $
26! Vertical nesting method of Huq et al. (2019) removed
27!
28! 4562 2020-06-12 08:38:47Z raasch
29! bugfix: revised error message for exceeding allow number of time series
30!
31! 4559 2020-06-11 08:51:48Z raasch
32! file re-formatted to follow the PALM coding standard
33!
34! 4536 2020-05-17 17:24:13Z raasch
35! unneccessary query for restart data format removed
36!
37! 4534 2020-05-14 18:35:22Z raasch
38! adjustments for I/O on reduced number of cores using shared memory MPI
39!
40! 4514 2020-04-30 16:29:59Z suehring
41! Enable output of qsurf and ssurf
42!
43! 4513 2020-04-30 13:45:47Z raasch
44! unused modules removed
45!
46! 4511 2020-04-30 12:20:40Z raasch
47! call of chem_boundary_conds removed (respective settings are now done in the chemistry module)
48!
49! 4495 2020-04-13 20:11:20Z raasch
50! check new restart_data_format parameters
51!
52! 4493 2020-04-10 09:49:43Z pavelkrc
53! Kolmogorov length scale eta added to profile output
54!
55! 4444 2020-03-05 15:59:50Z raasch
56! bugfix: cpp-directives for serial mode added
57!
58! 4392 2020-01-31 16:14:57Z pavelkrc
59! Some error numbers revised to prevent double usage
60!
61! 11:55:33Z oliver.maas
62! Checks for closed channel flow implemented
63!
64! 11:55:33Z oliver.maas
65! Move 2-m potential temperature output to diagnostic_output_quantities
66!
67! 11:55:33Z oliver.maas
68! removed message PA0421, concerning old parameter recycling_yshift
69!
70! 11:55:33Z oliver.maas
71! adjust message to the modified parameter recycling_yshift
72!
73! 11:55:33Z oliver.maas
74! Check if a cross section is specified if any output cross-section quantity
75! is given
76!
77! 11:55:33Z oliver.maas
78! Overwrite rotation_angle from namelist by value from static driver
79!
80! 11:55:33Z oliver.maas
81! removed conversion from recycle_absolute_quantities to raq, added check and
82! error message for correct input of recycling_method_for_thermodynamic_quantities
83!
84! 11:55:33Z oliver.maas
85! Corrected "Former revisions" section
86!
87! 11:55:33Z oliver.maas
88! bugfix error message: replaced PA184 by PA0184
89!
90! 11:55:33Z oliver.maas
91! added conversion from recycle_absolute_quantities to raq for recycling of
92! absolute quantities and added error message PA184 for not implemented quantities
93!
94! 4142 2019-08-05 12:38:31Z suehring
95! Consider spinup in number of output timesteps for averaged 2D output (merge
96! from branch resler).
97!
98! 4069 2019-07-01 14:05:51Z Giersch
99! Masked output running index mid has been introduced as a local variable to
100! avoid runtime error (Loop variable has been modified) in time_integration
101!
102! 4048 2019-06-21 21:00:21Z knoop
103! Moved tcm_check_data_output to module_interface
104!
105! 4039 2019-06-18 10:32:41Z suehring
106! Modularize diagnostic output
107!
108! 4017 2019-06-06 12:16:46Z schwenkel
109! output of turbulence intensity added
110!
111! 3933 2019-04-25 12:33:20Z kanani
112! Alphabetical resorting in CASE, condense settings for theta_2m* into one IF clause
113!
114! 3885 2019-04-11 11:29:34Z kanani
115! Changes related to global restructuring of location messages and introduction
116! of additional debug messages
117!
118! 3766 2019-02-26 16:23:41Z raasch
119! trim added to avoid truncation compiler warnings
120!
121! 3761 2019-02-25 15:31:42Z raasch
122! unused variables removed
123!
124! 3735 2019-02-12 09:52:40Z dom_dwd_user
125! Passing variable j (averaged output?) to
126! module_interface.f90:chem_check_data_output.
127!
128! 3705 2019-01-29 19:56:39Z suehring
129! bugfix: renamed thetav_t to vtheta_t
130!
131! 3702 2019-01-28 13:19:30Z gronemeier
132! most_method removed
133!
134! 3655 2019-01-07 16:51:22Z knoop
135! Formatting
136!
137! Revision 1.1  1997/08/26 06:29:23  raasch
138! Initial revision
139!
140!
141! Description:
142! ------------
143!> Check control parameters and deduce further quantities.
144!--------------------------------------------------------------------------------------------------!
145 SUBROUTINE check_parameters
146
147
148    USE arrays_3d
149
150    USE basic_constants_and_equations_mod
151
152    USE bulk_cloud_model_mod,                                                                      &
153        ONLY:  bulk_cloud_model
154
155    USE control_parameters
156
157    USE grid_variables
158
159    USE kinds
160
161    USE indices
162
163    USE model_1d_mod,                                                                              &
164        ONLY:  damp_level_1d, damp_level_ind_1d
165
166    USE module_interface,                                                                          &
167        ONLY:  module_interface_check_data_output,                                                 &
168               module_interface_check_data_output_pr,                                              &
169               module_interface_check_data_output_ts,                                              &
170               module_interface_check_parameters
171
172    USE netcdf_data_input_mod,                                                                     &
173        ONLY:  init_model, input_pids_static, netcdf_data_input_check_dynamic,                     &
174               netcdf_data_input_check_static
175
176    USE netcdf_interface,                                                                          &
177        ONLY:  do2d_unit, do3d_unit, dopr_unit, dots_label, dots_max, dots_num, dots_unit,         &
178               heatflux_output_unit, momentumflux_output_unit, netcdf_data_format,                 &
179               netcdf_data_format_string, waterflux_output_unit
180
181    USE particle_attributes,                                                                       &
182        ONLY:  particle_advection, use_sgs_for_particles
183
184    USE pegrid
185
186    USE pmc_interface,                                                                             &
187        ONLY:  cpl_id, nested_run
188
189    USE profil_parameter
190
191    USE statistics
192
193    USE subsidence_mod
194
195    USE transpose_indices
196
197    IMPLICIT NONE
198
199    CHARACTER (LEN=varnamelength)  ::  var           !< variable name
200    CHARACTER (LEN=7)   ::  unit                     !< unit of variable
201    CHARACTER (LEN=8)   ::  date                     !< current date string
202    CHARACTER (LEN=10)  ::  time                     !< current time string
203    CHARACTER (LEN=20)  ::  ensemble_string          !< string containing number of ensemble member
204    CHARACTER (LEN=15)  ::  nest_string              !< string containing id of nested domain
205    CHARACTER (LEN=40)  ::  coupling_string          !< string containing type of coupling
206    CHARACTER (LEN=100) ::  action                   !< flag string
207
208    INTEGER(iwp) ::  i                               !< loop index
209    INTEGER(iwp) ::  ilen                            !< string length
210    INTEGER(iwp) ::  j                               !< loop index
211    INTEGER(iwp) ::  k                               !< loop index
212    INTEGER(iwp) ::  kk                              !< loop index
213    INTEGER(iwp) ::  mid                             !< masked output running index
214    INTEGER(iwp) ::  netcdf_data_format_save         !< initial value of netcdf_data_format
215    INTEGER(iwp) ::  position                        !< index position of string
216
217    LOGICAL     ::  found                            !< flag, true if output variable is already marked for averaging
218
219    REAL(wp)    ::  gradient                         !< local gradient
220#if defined( __parallel )
221    REAL(wp)    ::  dt_spinup_max                    !< maximum spinup timestep in nested domains
222    REAL(wp)    ::  remote = 0.0_wp                  !< MPI id of remote processor
223    REAL(wp)    ::  spinup_time_max                  !< maximum spinup time in nested domains
224    REAL(wp)    ::  time_to_be_simulated_from_reference_point  !< time to be simulated from reference point
225#endif
226
227
228    CALL location_message( 'checking parameters', 'start' )
229!
230!-- At first, check static and dynamic input for consistency.
231    CALL netcdf_data_input_check_dynamic
232    CALL netcdf_data_input_check_static
233!
234!-- Check for overlap combinations, which are not realized yet
235    IF ( transpose_compute_overlap  .AND. numprocs == 1 )  THEN
236          message_string = 'transpose-compute-overlap not implemented for single PE runs'
237          CALL message( 'check_parameters', 'PA0000', 1, 2, 0, 6, 0 )
238    ENDIF
239
240!
241!-- Check the coupling mode
242    IF ( coupling_mode /= 'uncoupled'            .AND.                                             &
243         coupling_mode /= 'precursor_atmos'      .AND.                                             &
244         coupling_mode /= 'precursor_ocean'      .AND.                                             &
245         coupling_mode /= 'atmosphere_to_ocean'  .AND.                                             &
246         coupling_mode /= 'ocean_to_atmosphere' )  THEN
247       message_string = 'illegal coupling mode: ' // TRIM( coupling_mode )
248       CALL message( 'check_parameters', 'PA0002', 1, 2, 0, 6, 0 )
249    ENDIF
250
251!
252!-- Check if humidity is set to .TRUE. in case of the atmospheric run (for coupled runs)
253    IF ( coupling_mode == 'atmosphere_to_ocean' .AND. .NOT. humidity) THEN
254       message_string = ' Humidity has to be set to .T. in the _p3d file ' //                      &
255                        'for coupled runs between ocean and atmosphere.'
256       CALL message( 'check_parameters', 'PA0476', 1, 2, 0, 6, 0 )
257    ENDIF
258
259!
260!-- Check and set the restart data format variables
261    IF ( TRIM( restart_data_format ) /= 'fortran_binary'  .AND.                                    &
262         TRIM( restart_data_format ) /= 'mpi'             .AND.                                    &
263         TRIM( restart_data_format ) /= 'mpi_shared_memory' )  THEN
264       message_string = 'illegal restart data format "' // TRIM( restart_data_format ) // '"'
265       CALL message( 'check_parameters', 'PA0724', 1, 2, 0, 6, 0 )
266    ENDIF
267
268    IF ( TRIM( restart_data_format_input ) == 'undefined' )  THEN
269       restart_data_format_input = restart_data_format
270    ENDIF
271    IF ( TRIM( restart_data_format_output ) == 'undefined' )  THEN
272       restart_data_format_output = restart_data_format
273    ENDIF
274
275    IF ( TRIM( restart_data_format_input ) /= 'fortran_binary'  .AND.                              &
276         TRIM( restart_data_format_input ) /= 'mpi'             .AND.                              &
277         TRIM( restart_data_format_input ) /= 'mpi_shared_memory' )  THEN
278       message_string = 'illegal restart input data format "' //                                   &
279                        TRIM( restart_data_format_input ) // '"'
280       CALL message( 'check_parameters', 'PA0725', 1, 2, 0, 6, 0 )
281    ENDIF
282    IF ( TRIM( restart_data_format_output ) /= 'fortran_binary'  .AND.                             &
283         TRIM( restart_data_format_output ) /= 'mpi'             .AND.                             &
284         TRIM( restart_data_format_output ) /= 'mpi_shared_memory' )  THEN
285       message_string = 'illegal restart output data format "' //                                  &
286                        TRIM( restart_data_format_output ) // '"'
287       CALL message( 'check_parameters', 'PA0726', 1, 2, 0, 6, 0 )
288    ENDIF
289
290!
291!-- Set flag for including total domain boundaries in the restart data (MPI-IO) in case of
292!-- non-cyclic boundary conditions
293    include_total_domain_boundaries = .NOT. ( bc_lr_cyc  .AND.  bc_ns_cyc )
294
295!
296!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
297    IF ( coupling_mode /= 'uncoupled'        .AND.                                                 &
298         coupling_mode /= 'precursor_atmos'  .AND.                                                 &
299         coupling_mode /= 'precursor_ocean' )  THEN
300
301       IF ( dt_coupling == 9999999.9_wp )  THEN
302          message_string = 'dt_coupling is not set but required for coupling mode "' //            &
303                           TRIM( coupling_mode ) // '"'
304          CALL message( 'check_parameters', 'PA0003', 1, 2, 0, 6, 0 )
305       ENDIF
306
307#if defined( __parallel )
308
309
310       IF ( myid == 0 ) THEN
311          CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, ierr )
312          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 11, comm_inter, status, ierr )
313       ENDIF
314       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
315
316       IF ( dt_coupling /= remote )  THEN
317          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), '": dt_coupling = ',&
318                 dt_coupling, '& is not equal to ', 'dt_coupling_remote = ', remote
319          CALL message( 'check_parameters', 'PA0004', 1, 2, 0, 6, 0 )
320       ENDIF
321       IF ( dt_coupling <= 0.0_wp )  THEN
322
323          IF ( myid == 0  ) THEN
324             CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
325             CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 19, comm_inter, status, ierr )
326          ENDIF
327          CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
328
329          dt_coupling = MAX( dt_max, remote )
330          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                     &
331                 '": dt_coupling <= 0.0 & is not allowed and is reset to ', 'MAX(dt_max(A,O)) = ', &
332                 dt_coupling
333          CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
334       ENDIF
335
336       IF ( myid == 0 ) THEN
337          CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, ierr )
338          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 12, comm_inter, status, ierr )
339       ENDIF
340       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
341
342       IF ( restart_time /= remote )  THEN
343          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                     &
344                 '": restart_time = ', restart_time, '& is not equal to ',                         &
345                 'restart_time_remote = ', remote
346          CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
347       ENDIF
348
349       IF ( myid == 0 ) THEN
350          CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, ierr )
351          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 13, comm_inter, status, ierr )
352       ENDIF
353       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
354
355       IF ( dt_restart /= remote )  THEN
356          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), '": dt_restart = ', &
357                 dt_restart, '& is not equal to ', 'dt_restart_remote = ', remote
358          CALL message( 'check_parameters', 'PA0007', 1, 2, 0, 6, 0 )
359       ENDIF
360
361       time_to_be_simulated_from_reference_point = end_time-coupling_start_time
362
363       IF ( myid == 0 ) THEN
364          CALL MPI_SEND( time_to_be_simulated_from_reference_point, 1, MPI_REAL, target_id, 14,    &
365                         comm_inter, ierr )
366          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 14, comm_inter, status, ierr )
367       ENDIF
368       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
369
370       IF ( time_to_be_simulated_from_reference_point /= remote )  THEN
371          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                     &
372                 '": time_to_be_simulated_from_reference_point = ',                                &
373                 time_to_be_simulated_from_reference_point, '& is not equal ',                     &
374                 'to time_to_be_simulated_from_reference_point_remote = ',                         &
375                 remote
376          CALL message( 'check_parameters', 'PA0008', 1, 2, 0, 6, 0 )
377       ENDIF
378
379       IF ( myid == 0 ) THEN
380          CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
381          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 15, comm_inter, status, ierr )
382       ENDIF
383       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
384
385
386       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
387
388          IF ( dx < remote ) THEN
389             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
390                    '": dx in Atmosphere is not equal to or not larger than dx in ocean'
391             CALL message( 'check_parameters', 'PA0009', 1, 2, 0, 6, 0 )
392          ENDIF
393
394          IF ( (nx_a+1)*dx /= (nx_o+1)*remote )  THEN
395             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
396                    '": Domain size in x-direction is not equal in ocean and atmosphere'
397             CALL message( 'check_parameters', 'PA0010', 1, 2, 0, 6, 0 )
398          ENDIF
399
400       ENDIF
401
402       IF ( myid == 0) THEN
403          CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
404          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 16, comm_inter, status, ierr )
405       ENDIF
406       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
407
408       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
409
410          IF ( dy < remote )  THEN
411             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
412                    '": dy in Atmosphere is not equal to or not larger than dy in ocean'
413             CALL message( 'check_parameters', 'PA0011', 1, 2, 0, 6, 0 )
414          ENDIF
415
416          IF ( (ny_a+1)*dy /= (ny_o+1)*remote )  THEN
417             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
418                    '": Domain size in y-direction is not equal in ocean and atmosphere'
419             CALL message( 'check_parameters', 'PA0012', 1, 2, 0, 6, 0 )
420          ENDIF
421
422          IF ( MOD( nx_o+1, nx_a+1 ) /= 0 )  THEN
423             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
424                    '": nx+1 in ocean is not divisible by nx+1 in', ' atmosphere without remainder'
425             CALL message( 'check_parameters', 'PA0339', 1, 2, 0, 6, 0 )
426          ENDIF
427
428          IF ( MOD(ny_o+1,ny_a+1) /= 0 )  THEN
429             WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ),                  &
430                    '": ny+1 in ocean is not divisible by ny+1 in', ' atmosphere without remainder'
431
432             CALL message( 'check_parameters', 'PA0340', 1, 2, 0, 6, 0 )
433          ENDIF
434
435       ENDIF
436#else
437       WRITE( message_string, * ) 'coupling requires PALM to be compiled with',                    &
438              ' cpp-option "-D__parallel"'
439       CALL message( 'check_parameters', 'PA0141', 1, 2, 0, 6, 0 )
440#endif
441    ENDIF
442
443#if defined( __parallel )
444!
445!-- Exchange via intercommunicator
446    IF ( coupling_mode == 'atmosphere_to_ocean'  .AND.  myid == 0 )  THEN
447       CALL MPI_SEND( humidity, 1, MPI_LOGICAL, target_id, 19, comm_inter, ierr )
448    ELSEIF ( coupling_mode == 'ocean_to_atmosphere'  .AND.  myid == 0)  THEN
449       CALL MPI_RECV( humidity_remote, 1, MPI_LOGICAL, target_id, 19, comm_inter, status, ierr )
450    ENDIF
451    CALL MPI_BCAST( humidity_remote, 1, MPI_LOGICAL, 0, comm2d, ierr)
452
453#endif
454
455!
456!-- User settings for restart times requires that "restart" has been given as file activation
457!-- string. Otherwise, binary output would not be saved by palmrun.
458    IF ( ( restart_time /= 9999999.9_wp  .OR.  dt_restart /= 9999999.9_wp )                        &
459         .AND.  .NOT. write_binary )  THEN
460       WRITE( message_string, * ) 'manual restart settings requires file ',                        &
461                                  'activation string "restart"'
462       CALL message( 'check_parameters', 'PA0001', 1, 2, 0, 6, 0 )
463    ENDIF
464
465
466!
467!-- Generate the file header which is used as a header for most of PALM's output files
468    CALL DATE_AND_TIME( date, time, run_zone )
469    run_date = date(1:4) // '-' // date(5:6) // '-' // date(7:8)
470    run_time = time(1:2) // ':' // time(3:4) // ':' // time(5:6)
471    IF ( coupling_mode == 'uncoupled' )  THEN
472       coupling_string = ''
473    ELSEIF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
474       coupling_string = ' coupled (atmosphere)'
475    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
476       coupling_string = ' coupled (ocean)'
477    ENDIF
478    IF ( ensemble_member_nr /= 0 )  THEN
479       WRITE( ensemble_string, '(2X,A,I2.2)' )  'en-no: ', ensemble_member_nr
480    ELSE
481       ensemble_string = ''
482    ENDIF
483    IF ( nested_run )  THEN
484       WRITE( nest_string, '(2X,A,I2.2)' )  'nest-id: ', cpl_id
485    ELSE
486       nest_string = ''
487    ENDIF
488
489    WRITE ( run_description_header, '(A,2X,A,2X,A,A,A,I2.2,A,A,A,2X,A,A,2X,A,1X,A)' )              &
490          TRIM( version ), TRIM( revision ), 'run: ', TRIM( run_identifier ), '.', runnr,          &
491          TRIM( coupling_string ), TRIM( nest_string ), TRIM( ensemble_string), 'host: ',          &
492          TRIM( host ), run_date, run_time
493
494!
495!-- Check the general loop optimization method
496    SELECT CASE ( TRIM( loop_optimization ) )
497
498       CASE ( 'cache', 'vector' )
499          CONTINUE
500
501       CASE DEFAULT
502          message_string = 'illegal value given for loop_optimization: "' //                       &
503                           TRIM( loop_optimization ) // '"'
504          CALL message( 'check_parameters', 'PA0013', 1, 2, 0, 6, 0 )
505
506    END SELECT
507
508!
509!-- Check topography setting (check for illegal parameter combinations)
510    IF ( topography /= 'flat' )  THEN
511       action = ' '
512       IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' )  THEN
513          WRITE( action, '(A,A)' )  'scalar_advec = ', scalar_advec
514       ENDIF
515       IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' )  THEN
516          WRITE( action, '(A,A)' )  'momentum_advec = ', momentum_advec
517       ENDIF
518       IF ( psolver == 'sor' )  THEN
519          WRITE( action, '(A,A)' )  'psolver = ', psolver
520       ENDIF
521       IF ( sloping_surface )  THEN
522          WRITE( action, '(A)' )  'sloping surface = .TRUE.'
523       ENDIF
524       IF ( galilei_transformation )  THEN
525          WRITE( action, '(A)' )  'galilei_transformation = .TRUE.'
526       ENDIF
527       IF ( cloud_droplets )  THEN
528          WRITE( action, '(A)' )  'cloud_droplets = .TRUE.'
529       ENDIF
530       IF ( .NOT. constant_flux_layer  .AND.  topography /= 'closed_channel' )  THEN
531          WRITE( action, '(A)' )  'constant_flux_layer = .FALSE.'
532       ENDIF
533       IF ( action /= ' ' )  THEN
534          message_string = 'The specified topography does not allow ' // TRIM( action )
535          CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
536       ENDIF
537!
538!--    Check illegal/untested parameter combinations for closed channel
539       If ( topography == 'closed_channel' )  THEN
540          symmetry_flag = 1
541          message_string = 'Bottom and top boundary are treated equal'
542          CALL message( 'check_parameters', 'PA0699', 0, 0, 0, 6, 0 )
543
544          IF ( dz(1) /= dz(COUNT( dz /= -1.0_wp ))  .OR.  dz_stretch_level /= -9999999.9_wp)  THEN
545             WRITE( message_string, * )  'dz should be equal close to the ' //                     &
546                                         'boundaries due to symmetrical problem'
547             CALL message( 'check_parameters', 'PA0700', 1, 2, 0, 6, 0 )
548          ENDIF
549
550          IF ( constant_flux_layer )  THEN
551             WRITE( message_string, * )  'A constant flux layer is not ' //                        &
552                                         'allowed if a closed channel shall be used'
553             CALL message( 'check_parameters', 'PA0701', 1, 2, 0, 6, 0 )
554          ENDIF
555
556          IF ( ocean_mode )  THEN
557             WRITE( message_string, * )  'The ocean mode is not allowed if ' //                    &
558                                         'a closed channel shall be used'
559             CALL message( 'check_parameters', 'PA0702', 1, 2, 0, 6, 0 )
560          ENDIF
561
562          IF ( momentum_advec /= 'ws-scheme'  .OR.                                                 &
563               scalar_advec /= 'ws-scheme' )  THEN
564             WRITE( message_string, * )  'A closed channel require the upwind scheme of Wicker' // &
565                                         ' and Skamarock as the advection scheme'
566             CALL message( 'check_parameters', 'PA0703', 1, 2, 0, 6, 0 )
567          ENDIF
568       ENDIF
569    ENDIF
570
571!
572!-- Check approximation
573    IF ( TRIM( approximation ) /= 'boussinesq'  .AND.  TRIM( approximation ) /= 'anelastic' )  THEN
574       message_string = 'unknown approximation: approximation = "' // TRIM( approximation ) // '"'
575       CALL message( 'check_parameters', 'PA0446', 1, 2, 0, 6, 0 )
576    ENDIF
577
578!
579!-- Check approximation requirements
580    IF ( TRIM( approximation ) == 'anelastic'  .AND.  TRIM( momentum_advec ) /= 'ws-scheme' )  THEN
581       message_string = 'Anelastic approximation requires momentum_advec = "ws-scheme"'
582       CALL message( 'check_parameters', 'PA0447', 1, 2, 0, 6, 0 )
583    ENDIF
584    IF ( TRIM( approximation ) == 'anelastic'  .AND.  TRIM( psolver ) == 'multigrid' )  THEN
585       message_string = 'Anelastic approximation currently only supports psolver = "poisfft", ' // &
586                        'psolver = "sor" and psolver = "multigrid_noopt"'
587       CALL message( 'check_parameters', 'PA0448', 1, 2, 0, 6, 0 )
588    ENDIF
589    IF ( TRIM( approximation ) == 'anelastic'  .AND.  conserve_volume_flow )  THEN
590       message_string = 'Anelastic approximation is not allowed with ' //                          &
591                        'conserve_volume_flow = .TRUE.'
592       CALL message( 'check_parameters', 'PA0449', 1, 2, 0, 6, 0 )
593    ENDIF
594
595!
596!-- Check flux input mode
597    IF ( TRIM( flux_input_mode ) /= 'dynamic'  .AND.  TRIM( flux_input_mode ) /= 'kinematic'       &
598         .AND.  TRIM( flux_input_mode ) /= 'approximation-specific' )  THEN
599       message_string = 'unknown flux input mode: flux_input_mode = "' //                          &
600                        TRIM( flux_input_mode ) // '"'
601       CALL message( 'check_parameters', 'PA0450', 1, 2, 0, 6, 0 )
602    ENDIF
603!
604!-- Set flux input mode according to approximation if applicable
605    IF ( TRIM( flux_input_mode ) == 'approximation-specific' )  THEN
606       IF ( TRIM( approximation ) == 'anelastic' )  THEN
607          flux_input_mode = 'dynamic'
608       ELSEIF ( TRIM( approximation ) == 'boussinesq' )  THEN
609          flux_input_mode = 'kinematic'
610       ENDIF
611    ENDIF
612
613!
614!-- Check flux output mode
615    IF ( TRIM( flux_output_mode ) /= 'dynamic'  .AND.  TRIM( flux_output_mode ) /= 'kinematic'     &
616         .AND.  TRIM( flux_output_mode ) /= 'approximation-specific' )  THEN
617       message_string = 'unknown flux output mode: flux_output_mode = "' //                        &
618                        TRIM( flux_output_mode ) // '"'
619       CALL message( 'check_parameters', 'PA0451', 1, 2, 0, 6, 0 )
620    ENDIF
621!
622!-- Set flux output mode according to approximation if applicable
623    IF ( TRIM( flux_output_mode ) == 'approximation-specific' )  THEN
624       IF ( TRIM( approximation ) == 'anelastic' )  THEN
625          flux_output_mode = 'dynamic'
626       ELSEIF ( TRIM( approximation ) == 'boussinesq' )  THEN
627          flux_output_mode = 'kinematic'
628       ENDIF
629    ENDIF
630
631
632!
633!-- When the land- or urban-surface model is used, the flux output must be dynamic.
634    IF ( land_surface  .OR.  urban_surface )  THEN
635       flux_output_mode = 'dynamic'
636    ENDIF
637
638!
639!-- Set the flux output units according to flux_output_mode
640    IF ( TRIM( flux_output_mode ) == 'kinematic' )  THEN
641        heatflux_output_unit              = 'K m/s'
642        waterflux_output_unit             = 'kg/kg m/s'
643        momentumflux_output_unit          = 'm2/s2'
644    ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' )  THEN
645        heatflux_output_unit              = 'W/m2'
646        waterflux_output_unit             = 'W/m2'
647        momentumflux_output_unit          = 'N/m2'
648    ENDIF
649
650!
651!-- set time series output units for fluxes
652    dots_unit(14:16) = TRIM( heatflux_output_unit )
653    dots_unit(21)    = TRIM( waterflux_output_unit )
654    dots_unit(19:20) = TRIM( momentumflux_output_unit )
655
656!
657!-- Add other module specific timeseries
658    CALL module_interface_check_data_output_ts( dots_max, dots_num, dots_label, dots_unit )
659
660!
661!-- Check if maximum number of allowed timeseries is exceeded
662    IF ( dots_num > dots_max )  THEN
663       WRITE( message_string, * ) 'number of time series quantities exceeds',                      &
664                                  ' its maximum of dots_max = ', dots_max,                         &
665                                  '&Please increase dots_max in netcdf_interface_mod.f90.'
666       CALL message( 'check_parameters', 'PA0194', 1, 2, 0, 6, 0 )
667    ENDIF
668
669!
670!-- Check whether there are any illegal values
671!-- Pressure solver:
672    IF ( psolver /= 'poisfft'  .AND.  psolver /= 'sor'  .AND.  psolver /= 'multigrid'  .AND.       &
673         psolver /= 'multigrid_noopt' )  THEN
674       message_string = 'unknown solver for perturbation pressure: psolver' //                     &
675                        ' = "' // TRIM( psolver ) // '"'
676       CALL message( 'check_parameters', 'PA0016', 1, 2, 0, 6, 0 )
677    ENDIF
678
679    IF ( psolver(1:9) == 'multigrid' )  THEN
680       IF ( cycle_mg == 'w' )  THEN
681          gamma_mg = 2
682       ELSEIF ( cycle_mg == 'v' )  THEN
683          gamma_mg = 1
684       ELSE
685          message_string = 'unknown multigrid cycle: cycle_mg = "' //  TRIM( cycle_mg ) // '"'
686          CALL message( 'check_parameters', 'PA0020', 1, 2, 0, 6, 0 )
687       ENDIF
688    ENDIF
689
690    IF ( fft_method /= 'singleton-algorithm'  .AND.  fft_method /= 'temperton-algorithm'  .AND.    &
691         fft_method /= 'fftw'                 .AND.  fft_method /= 'system-specific' )  THEN
692       message_string = 'unknown fft-algorithm: fft_method = "' // TRIM( fft_method ) // '"'
693       CALL message( 'check_parameters', 'PA0021', 1, 2, 0, 6, 0 )
694    ENDIF
695
696    IF( momentum_advec == 'ws-scheme' .AND.  .NOT. call_psolver_at_all_substeps  ) THEN
697        message_string = 'psolver must be called at each RK3 substep when "'//                     &
698                         TRIM(momentum_advec) // ' "is used for momentum_advec'
699        CALL message( 'check_parameters', 'PA0344', 1, 2, 0, 6, 0 )
700    END IF
701!
702!-- Advection schemes:
703    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme'  .AND.                &
704         momentum_advec /= 'up-scheme' )  THEN
705       message_string = 'unknown advection scheme: momentum_advec = "' //                          &
706                        TRIM( momentum_advec ) // '"'
707       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
708    ENDIF
709    IF ( ( momentum_advec == 'ws-scheme' .OR. scalar_advec == 'ws-scheme' )                        &
710         .AND. ( timestep_scheme == 'euler' .OR.  timestep_scheme == 'runge-kutta-2' ) )  THEN
711       message_string = 'momentum_advec or scalar_advec = "' // TRIM( momentum_advec ) //          &
712                        '" is not allowed with timestep_scheme = "' //                             &
713                        TRIM( timestep_scheme ) // '"'
714       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
715    ENDIF
716    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme'  .AND.                    &
717         scalar_advec /= 'bc-scheme'  .AND.  scalar_advec /= 'up-scheme' )  THEN
718       message_string = 'unknown advection scheme: scalar_advec = "' // TRIM( scalar_advec ) // '"'
719       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
720    ENDIF
721    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' )  THEN
722       message_string = 'advection_scheme scalar_advec = "' // TRIM( scalar_advec ) //             &
723                        '" not implemented for loop_optimization = "' //                           &
724                        TRIM( loop_optimization ) // '"'
725       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
726    ENDIF
727
728    IF ( use_sgs_for_particles  .AND.  .NOT. cloud_droplets  .AND.  .NOT. use_upstream_for_tke     &
729         .AND.  scalar_advec /= 'ws-scheme' )  THEN
730       use_upstream_for_tke = .TRUE.
731       message_string = 'use_upstream_for_tke is set to .TRUE. because ' //                        &
732                        'use_sgs_for_particles = .TRUE. and scalar_advec /= ws-scheme'
733       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
734    ENDIF
735
736!
737!-- Set LOGICAL switches to enhance performance
738    IF ( momentum_advec == 'ws-scheme' )  ws_scheme_mom = .TRUE.
739    IF ( scalar_advec   == 'ws-scheme' )  ws_scheme_sca = .TRUE.
740
741
742!
743!-- Timestep schemes:
744    SELECT CASE ( TRIM( timestep_scheme ) )
745
746       CASE ( 'euler' )
747          intermediate_timestep_count_max = 1
748
749       CASE ( 'runge-kutta-2' )
750          intermediate_timestep_count_max = 2
751
752       CASE ( 'runge-kutta-3' )
753          intermediate_timestep_count_max = 3
754
755       CASE DEFAULT
756          message_string = 'unknown timestep scheme: timestep_scheme = "' //                       &
757                           TRIM( timestep_scheme ) // '"'
758          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
759
760    END SELECT
761
762    IF ( ( momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme' )                     &
763         .AND.  timestep_scheme(1:5) == 'runge' ) THEN
764       message_string = 'momentum advection scheme "' // TRIM( momentum_advec ) //                 &
765                        '" & does not work with timestep_scheme "' // TRIM( timestep_scheme )      &
766                        // '"'
767       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
768    ENDIF
769!
770!-- Check for proper settings for microphysics
771    IF ( bulk_cloud_model  .AND.  cloud_droplets )  THEN
772       message_string = 'bulk_cloud_model = .TRUE. is not allowed with cloud_droplets = .TRUE.'
773       CALL message( 'check_parameters', 'PA0442', 1, 2, 0, 6, 0 )
774    ENDIF
775
776!
777!-- Initializing actions must have been set by the user
778    IF ( TRIM( initializing_actions ) == '' )  THEN
779       message_string = 'no value specified for initializing_actions'
780       CALL message( 'check_parameters', 'PA0149', 1, 2, 0, 6, 0 )
781    ENDIF
782
783    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.                                &
784         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
785!
786!--    No restart run: several initialising actions are possible
787       action = initializing_actions
788       DO  WHILE ( TRIM( action ) /= '' )
789          position = INDEX( action, ' ' )
790          SELECT CASE ( action(1:position-1) )
791
792             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', 'by_user',                   &
793                    'initialize_vortex', 'initialize_ptanom', 'initialize_bubble', 'inifor' )
794                action = action(position+1:)
795
796             CASE DEFAULT
797                message_string = 'initializing_action = "' //                                      &
798                                 TRIM( action ) // '" unknown or not allowed'
799                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
800
801          END SELECT
802       ENDDO
803    ENDIF
804
805    IF ( TRIM( initializing_actions ) == 'initialize_vortex'  .AND.  conserve_volume_flow ) THEN
806         message_string = 'initializing_actions = "initialize_vortex"' //                          &
807                          ' is not allowed with conserve_volume_flow = .T.'
808       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
809    ENDIF
810
811
812    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND.                        &
813         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
814       message_string = 'initializing_actions = "set_constant_profiles"' //                        &
815                        ' and "set_1d-model_profiles" are not allowed simultaneously'
816       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
817    ENDIF
818
819    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND.                        &
820         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
821       message_string = 'initializing_actions = "set_constant_profiles"' //                        &
822                        ' and "by_user" are not allowed simultaneously'
823       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
824    ENDIF
825
826    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND.                                      &
827         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
828       message_string = 'initializing_actions = "by_user" and ' //                                 &
829                        '"set_1d-model_profiles" are not allowed simultaneously'
830       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
831    ENDIF
832!
833!-- In case of spinup and nested run, spinup end time must be identical in order to have
834!-- synchronously running simulations.
835    IF ( nested_run )  THEN
836#if defined( __parallel )
837       CALL MPI_ALLREDUCE( spinup_time, spinup_time_max, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD,     &
838                           ierr )
839       CALL MPI_ALLREDUCE( dt_spinup,   dt_spinup_max,   1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD,     &
840                           ierr )
841
842       IF ( spinup_time /= spinup_time_max  .OR.  dt_spinup /= dt_spinup_max )  THEN
843          message_string = 'In case of nesting, spinup_time and ' //                               &
844                           'dt_spinup must be identical in all parent and child domains.'
845          CALL message( 'check_parameters', 'PA0489', 3, 2, 0, 6, 0 )
846       ENDIF
847#endif
848    ENDIF
849
850    IF ( bulk_cloud_model  .AND.  .NOT. humidity )  THEN
851       WRITE( message_string, * ) 'bulk_cloud_model = ', bulk_cloud_model,                         &
852              ' is not allowed with humidity = ', humidity
853       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
854    ENDIF
855
856    IF ( humidity  .AND.  sloping_surface )  THEN
857       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' //                       &
858                        'are not allowed simultaneously'
859       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
860    ENDIF
861
862!-- Check the module settings
863    CALL module_interface_check_parameters
864
865!
866!-- In case of no restart run, check initialising parameters and calculate further quantities
867    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
868
869!
870!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
871       pt_init = pt_surface
872       IF ( humidity       )  q_init  = q_surface
873       IF ( passive_scalar )  s_init  = s_surface
874
875!--
876!--    If required, compute initial profile of the geostrophic wind (component ug)
877       i = 1
878       gradient = 0.0_wp
879
880       IF ( .NOT. ocean_mode )  THEN
881
882          ug_vertical_gradient_level_ind(1) = 0
883          ug(0) = ug_surface
884          DO  k = 1, nzt+1
885             IF ( i < 11 )  THEN
886                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND.                                  &
887                     ug_vertical_gradient_level(i) >= 0.0_wp )  THEN
888                   gradient = ug_vertical_gradient(i) / 100.0_wp
889                   ug_vertical_gradient_level_ind(i) = k - 1
890                   i = i + 1
891                ENDIF
892             ENDIF
893             IF ( gradient /= 0.0_wp )  THEN
894                IF ( k /= 1 )  THEN
895                   ug(k) = ug(k-1) + dzu(k) * gradient
896                ELSE
897                   ug(k) = ug_surface + dzu(k) * gradient
898                ENDIF
899             ELSE
900                ug(k) = ug(k-1)
901             ENDIF
902          ENDDO
903
904       ELSE
905
906          ug_vertical_gradient_level_ind(1) = nzt+1
907          ug(nzt+1) = ug_surface
908          DO  k = nzt, nzb, -1
909             IF ( i < 11 )  THEN
910                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND.                                  &
911                     ug_vertical_gradient_level(i) <= 0.0_wp )  THEN
912                   gradient = ug_vertical_gradient(i) / 100.0_wp
913                   ug_vertical_gradient_level_ind(i) = k + 1
914                   i = i + 1
915                ENDIF
916             ENDIF
917             IF ( gradient /= 0.0_wp )  THEN
918                IF ( k /= nzt )  THEN
919                   ug(k) = ug(k+1) - dzu(k+1) * gradient
920                ELSE
921                   ug(k)   = ug_surface - 0.5_wp * dzu(k+1) * gradient
922                   ug(k+1) = ug_surface + 0.5_wp * dzu(k+1) * gradient
923                ENDIF
924             ELSE
925                ug(k) = ug(k+1)
926             ENDIF
927          ENDDO
928
929       ENDIF
930
931!
932!--    In case of no given gradients for ug, choose a zero gradient
933       IF ( ug_vertical_gradient_level(1) == -9999999.9_wp )  THEN
934          ug_vertical_gradient_level(1) = 0.0_wp
935       ENDIF
936
937!
938!--
939!--    If required, compute initial profile of the geostrophic wind (component vg)
940       i = 1
941       gradient = 0.0_wp
942
943       IF ( .NOT. ocean_mode )  THEN
944
945          vg_vertical_gradient_level_ind(1) = 0
946          vg(0) = vg_surface
947          DO  k = 1, nzt+1
948             IF ( i < 11 )  THEN
949                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND.                                  &
950                     vg_vertical_gradient_level(i) >= 0.0_wp )  THEN
951                   gradient = vg_vertical_gradient(i) / 100.0_wp
952                   vg_vertical_gradient_level_ind(i) = k - 1
953                   i = i + 1
954                ENDIF
955             ENDIF
956             IF ( gradient /= 0.0_wp )  THEN
957                IF ( k /= 1 )  THEN
958                   vg(k) = vg(k-1) + dzu(k) * gradient
959                ELSE
960                   vg(k) = vg_surface + dzu(k) * gradient
961                ENDIF
962             ELSE
963                vg(k) = vg(k-1)
964             ENDIF
965          ENDDO
966
967       ELSE
968
969          vg_vertical_gradient_level_ind(1) = nzt+1
970          vg(nzt+1) = vg_surface
971          DO  k = nzt, nzb, -1
972             IF ( i < 11 )  THEN
973                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND.                                  &
974                     vg_vertical_gradient_level(i) <= 0.0_wp )  THEN
975                   gradient = vg_vertical_gradient(i) / 100.0_wp
976                   vg_vertical_gradient_level_ind(i) = k + 1
977                   i = i + 1
978                ENDIF
979             ENDIF
980             IF ( gradient /= 0.0_wp )  THEN
981                IF ( k /= nzt )  THEN
982                   vg(k) = vg(k+1) - dzu(k+1) * gradient
983                ELSE
984                   vg(k)   = vg_surface - 0.5_wp * dzu(k+1) * gradient
985                   vg(k+1) = vg_surface + 0.5_wp * dzu(k+1) * gradient
986                ENDIF
987             ELSE
988                vg(k) = vg(k+1)
989             ENDIF
990          ENDDO
991
992       ENDIF
993
994!
995!--    In case of no given gradients for vg, choose a zero gradient
996       IF ( vg_vertical_gradient_level(1) == -9999999.9_wp )  THEN
997          vg_vertical_gradient_level(1) = 0.0_wp
998       ENDIF
999
1000!
1001!--    Let the initial wind profiles be the calculated ug/vg profiles or interpolate them from wind
1002!--    profile data (if given)
1003       IF ( u_profile(1) == 9999999.9_wp  .AND.  v_profile(1) == 9999999.9_wp )  THEN
1004
1005          u_init = ug
1006          v_init = vg
1007
1008       ELSEIF ( u_profile(1) == 0.0_wp  .AND.  v_profile(1) == 0.0_wp )  THEN
1009
1010          IF ( uv_heights(1) /= 0.0_wp )  THEN
1011             message_string = 'uv_heights(1) must be 0.0'
1012             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
1013          ENDIF
1014
1015          IF ( omega /= 0.0_wp )  THEN
1016             message_string = 'Coriolis force must be switched off (by setting omega=0.0)' //      &
1017                              ' when prescribing the forcing by u_profile and v_profile'
1018             CALL message( 'check_parameters', 'PA0347', 1, 2, 0, 6, 0 )
1019          ENDIF
1020
1021          use_prescribed_profile_data = .TRUE.
1022
1023          kk = 1
1024          u_init(0) = 0.0_wp
1025          v_init(0) = 0.0_wp
1026
1027          DO  k = 1, nz+1
1028
1029             IF ( kk < 200 )  THEN
1030                DO  WHILE ( uv_heights(kk+1) <= zu(k) )
1031                   kk = kk + 1
1032                   IF ( kk == 200 )  EXIT
1033                ENDDO
1034             ENDIF
1035
1036             IF ( kk < 200  .AND.  uv_heights(kk+1) /= 9999999.9_wp )  THEN
1037                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /                           &
1038                                            ( uv_heights(kk+1) - uv_heights(kk) ) *                &
1039                                            ( u_profile(kk+1) - u_profile(kk) )
1040                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /                           &
1041                                            ( uv_heights(kk+1) - uv_heights(kk) ) *                &
1042                                            ( v_profile(kk+1) - v_profile(kk) )
1043             ELSE
1044                u_init(k) = u_profile(kk)
1045                v_init(k) = v_profile(kk)
1046             ENDIF
1047
1048          ENDDO
1049
1050       ELSE
1051
1052          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1053          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1054
1055       ENDIF
1056
1057!
1058!--    Compute initial temperature profile using the given temperature gradients
1059       IF (  .NOT.  neutral )  THEN
1060          CALL init_vertical_profiles( pt_vertical_gradient_level_ind, pt_vertical_gradient_level, &
1061                                       pt_vertical_gradient, pt_init, pt_surface, bc_pt_t_val )
1062       ENDIF
1063!
1064!--    Compute initial humidity profile using the given humidity gradients
1065       IF ( humidity )  THEN
1066          CALL init_vertical_profiles( q_vertical_gradient_level_ind, q_vertical_gradient_level,   &
1067                                       q_vertical_gradient, q_init, q_surface, bc_q_t_val )
1068       ENDIF
1069!
1070!--    Compute initial scalar profile using the given scalar gradients
1071       IF ( passive_scalar )  THEN
1072          CALL init_vertical_profiles( s_vertical_gradient_level_ind, s_vertical_gradient_level,   &
1073                                       s_vertical_gradient, s_init, s_surface, bc_s_t_val )
1074       ENDIF
1075!
1076!--    TODO
1077!--    Compute initial chemistry profile using the given chemical species gradients
1078!--    Russo: Is done in chem_init --> kanani: Revise
1079
1080    ENDIF
1081
1082!
1083!-- Check if the control parameter use_subsidence_tendencies is used correctly
1084    IF ( use_subsidence_tendencies  .AND.  .NOT.  large_scale_subsidence )  THEN
1085       message_string = 'The usage of use_subsidence_tendencies ' //                               &
1086                        'requires large_scale_subsidence = .T..'
1087       CALL message( 'check_parameters', 'PA0396', 1, 2, 0, 6, 0 )
1088    ELSEIF ( use_subsidence_tendencies  .AND.  .NOT. large_scale_forcing )  THEN
1089       message_string = 'The usage of use_subsidence_tendencies ' //           &
1090                        'requires large_scale_forcing = .T..'
1091       CALL message( 'check_parameters', 'PA0397', 1, 2, 0, 6, 0 )
1092    ENDIF
1093
1094!
1095!-- Initialize large scale subsidence if required
1096    If ( large_scale_subsidence )  THEN
1097       IF ( subs_vertical_gradient_level(1) /= -9999999.9_wp  .AND. .NOT. large_scale_forcing )    &
1098       THEN
1099          CALL init_w_subsidence
1100       ENDIF
1101!
1102!--    In case large_scale_forcing is used, profiles for subsidence velocity are read in from file
1103!--    LSF_DATA
1104
1105       IF ( subs_vertical_gradient_level(1) == -9999999.9_wp  .AND. .NOT. large_scale_forcing )    &
1106       THEN
1107          message_string = 'There is no default large scale vertical velocity profile set. ' //    &
1108                           'Specify the subsidence velocity profile via subs_vertical_gradient' // &
1109                           ' and subs_vertical_gradient_level.'
1110          CALL message( 'check_parameters', 'PA0380', 1, 2, 0, 6, 0 )
1111       ENDIF
1112    ELSE
1113        IF ( subs_vertical_gradient_level(1) /= -9999999.9_wp )  THEN
1114           message_string = 'Enable usage of large scale subsidence by ' //                        &
1115                            'setting large_scale_subsidence = .T..'
1116          CALL message( 'check_parameters', 'PA0381', 1, 2, 0, 6, 0 )
1117        ENDIF
1118    ENDIF
1119
1120!
1121!-- Overwrite parameters from namelist if necessary and compute Coriolis parameter.
1122!-- @todo - move initialization of f and fs to coriolis_mod.
1123    IF ( input_pids_static )  THEN
1124       latitude       = init_model%latitude
1125       longitude      = init_model%longitude
1126       rotation_angle = init_model%rotation_angle
1127    ENDIF
1128
1129    f  = 2.0_wp * omega * SIN( latitude / 180.0_wp * pi )
1130    fs = 2.0_wp * omega * COS( latitude / 180.0_wp * pi )
1131
1132!
1133!-- Check and set buoyancy related parameters and switches
1134    IF ( reference_state == 'horizontal_average' )  THEN
1135       CONTINUE
1136    ELSEIF ( reference_state == 'initial_profile' )  THEN
1137       use_initial_profile_as_reference = .TRUE.
1138    ELSEIF ( reference_state == 'single_value' )  THEN
1139       use_single_reference_value = .TRUE.
1140       IF ( pt_reference == 9999999.9_wp )  pt_reference = pt_surface
1141       vpt_reference = pt_reference * ( 1.0_wp + 0.61_wp * q_surface )
1142    ELSE
1143       message_string = 'illegal value for reference_state: "' // TRIM( reference_state ) // '"'
1144       CALL message( 'check_parameters', 'PA0056', 1, 2, 0, 6, 0 )
1145    ENDIF
1146
1147!
1148!-- In case of a given slope, compute the relevant quantities
1149    IF ( alpha_surface /= 0.0_wp )  THEN
1150       IF ( ABS( alpha_surface ) > 90.0_wp )  THEN
1151          WRITE( message_string, * ) 'ABS( alpha_surface = ', alpha_surface, ' ) must be < 90.0'
1152          CALL message( 'check_parameters', 'PA0043', 1, 2, 0, 6, 0 )
1153       ENDIF
1154       sloping_surface = .TRUE.
1155       cos_alpha_surface = COS( alpha_surface / 180.0_wp * pi )
1156       sin_alpha_surface = SIN( alpha_surface / 180.0_wp * pi )
1157    ENDIF
1158
1159!
1160!-- Check time step and cfl_factor
1161    IF ( dt /= -1.0_wp )  THEN
1162       IF ( dt <= 0.0_wp )  THEN
1163          WRITE( message_string, * ) 'dt = ', dt , ' <= 0.0'
1164          CALL message( 'check_parameters', 'PA0044', 1, 2, 0, 6, 0 )
1165       ENDIF
1166       dt_3d = dt
1167       dt_fixed = .TRUE.
1168    ENDIF
1169
1170    IF ( cfl_factor <= 0.0_wp  .OR.  cfl_factor > 1.0_wp )  THEN
1171       IF ( cfl_factor == -1.0_wp )  THEN
1172          IF ( timestep_scheme == 'runge-kutta-2' )  THEN
1173             cfl_factor = 0.8_wp
1174          ELSEIF ( timestep_scheme == 'runge-kutta-3' )  THEN
1175             cfl_factor = 0.9_wp
1176          ELSE
1177             cfl_factor = 0.9_wp
1178          ENDIF
1179       ELSE
1180          WRITE( message_string, * ) 'cfl_factor = ', cfl_factor,                                  &
1181                 ' out of range &0.0 < cfl_factor <= 1.0 is required'
1182          CALL message( 'check_parameters', 'PA0045', 1, 2, 0, 6, 0 )
1183       ENDIF
1184    ENDIF
1185
1186!
1187!-- Store simulated time at begin
1188    simulated_time_at_begin = simulated_time
1189
1190!
1191!-- Store reference time for coupled runs and change the coupling flag, if ...
1192    IF ( simulated_time == 0.0_wp )  THEN
1193       IF ( coupling_start_time == 0.0_wp )  THEN
1194          time_since_reference_point = 0.0_wp
1195       ELSEIF ( time_since_reference_point < 0.0_wp )  THEN
1196          run_coupled = .FALSE.
1197       ENDIF
1198    ENDIF
1199
1200!
1201!-- Set wind speed in the Galilei-transformed system
1202    IF ( galilei_transformation )  THEN
1203       IF ( use_ug_for_galilei_tr                    .AND.                                         &
1204            ug_vertical_gradient_level(1) == 0.0_wp  .AND.                                         &
1205            ug_vertical_gradient(1)       == 0.0_wp  .AND.                                         &
1206            vg_vertical_gradient_level(1) == 0.0_wp  .AND.                                         &
1207            vg_vertical_gradient(1)       == 0.0_wp )  THEN
1208          u_gtrans = ug_surface * 0.6_wp
1209          v_gtrans = vg_surface * 0.6_wp
1210       ELSEIF ( use_ug_for_galilei_tr  .AND.  ( ug_vertical_gradient_level(1) /= 0.0_wp .OR.       &
1211                                                ug_vertical_gradient(1) /= 0.0_wp ) )  THEN
1212          message_string = 'baroclinity (ug) not allowed simultaneously' //                        &
1213                           ' with galilei transformation'
1214          CALL message( 'check_parameters', 'PA0046', 1, 2, 0, 6, 0 )
1215       ELSEIF ( use_ug_for_galilei_tr  .AND.  ( vg_vertical_gradient_level(1) /= 0.0_wp  .OR.      &
1216                                                vg_vertical_gradient(1) /= 0.0_wp ) )  THEN
1217          message_string = 'baroclinity (vg) not allowed simultaneously' //                        &
1218                           ' with galilei transformation'
1219          CALL message( 'check_parameters', 'PA0047', 1, 2, 0, 6, 0 )
1220       ELSE
1221          message_string = 'variable translation speed used for Galilei-transformation, which ' // &
1222                           'may cause & instabilities in stably stratified regions'
1223          CALL message( 'check_parameters', 'PA0048', 0, 1, 0, 6, 0 )
1224       ENDIF
1225    ENDIF
1226
1227!
1228!-- In case of using a prandtl-layer, calculated (or prescribed) surface fluxes have to be used in
1229!-- the diffusion-terms
1230    IF ( constant_flux_layer )  use_surface_fluxes = .TRUE.
1231
1232!
1233!-- Check boundary conditions and set internal variables:
1234!-- Attention: the lateral boundary conditions have been already checked in parin
1235!
1236!-- Non-cyclic lateral boundaries require the multigrid method and Piascek-Willimas or
1237!-- Wicker - Skamarock advection scheme. Several schemes and tools do not work with non-cyclic
1238!-- boundary conditions.
1239    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
1240       IF ( psolver(1:9) /= 'multigrid' )  THEN
1241          message_string = 'non-cyclic lateral boundaries do not allow ' // 'psolver = "' //       &
1242                           TRIM( psolver ) // '"'
1243          CALL message( 'check_parameters', 'PA0051', 1, 2, 0, 6, 0 )
1244       ENDIF
1245       IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' )  THEN
1246
1247          message_string = 'non-cyclic lateral boundaries do not allow momentum_advec = "' //      &
1248                           TRIM( momentum_advec ) // '"'
1249          CALL message( 'check_parameters', 'PA0052', 1, 2, 0, 6, 0 )
1250       ENDIF
1251       IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' )  THEN
1252          message_string = 'non-cyclic lateral boundaries do not allow scalar_advec = "' //        &
1253                           TRIM( scalar_advec ) // '"'
1254          CALL message( 'check_parameters', 'PA0053', 1, 2, 0, 6, 0 )
1255       ENDIF
1256       IF ( galilei_transformation )  THEN
1257          message_string = 'non-cyclic lateral boundaries do not allow galilei_transformation = .T.'
1258          CALL message( 'check_parameters', 'PA0054', 1, 2, 0, 6, 0 )
1259       ENDIF
1260    ENDIF
1261
1262!
1263!-- Bottom boundary condition for the turbulent Kinetic energy
1264    IF ( bc_e_b == 'neumann' )  THEN
1265       ibc_e_b = 1
1266    ELSEIF ( bc_e_b == '(u*)**2+neumann' )  THEN
1267       ibc_e_b = 2
1268       IF ( .NOT. constant_flux_layer )  THEN
1269          bc_e_b = 'neumann'
1270          ibc_e_b = 1
1271          message_string = 'boundary condition bc_e_b changed to "' // TRIM( bc_e_b ) // '"'
1272          CALL message( 'check_parameters', 'PA0057', 0, 1, 0, 6, 0 )
1273       ENDIF
1274    ELSE
1275       message_string = 'unknown boundary condition: bc_e_b = "' // TRIM( bc_e_b ) // '"'
1276       CALL message( 'check_parameters', 'PA0058', 1, 2, 0, 6, 0 )
1277    ENDIF
1278
1279!
1280!-- Boundary conditions for perturbation pressure
1281    IF ( bc_p_b == 'dirichlet' )  THEN
1282       ibc_p_b = 0
1283    ELSEIF ( bc_p_b == 'neumann' )  THEN
1284       ibc_p_b = 1
1285    ELSE
1286       message_string = 'unknown boundary condition: bc_p_b = "' // TRIM( bc_p_b ) // '"'
1287       CALL message( 'check_parameters', 'PA0059', 1, 2, 0, 6, 0 )
1288    ENDIF
1289
1290    IF ( bc_p_t == 'dirichlet' )  THEN
1291       ibc_p_t = 0
1292!-- TO_DO: later set bc_p_t to neumann before, in case of nested domain
1293    ELSEIF ( bc_p_t == 'neumann' .OR. bc_p_t == 'nested' )  THEN
1294       ibc_p_t = 1
1295    ELSE
1296       message_string = 'unknown boundary condition: bc_p_t = "' // TRIM( bc_p_t ) // '"'
1297       CALL message( 'check_parameters', 'PA0061', 1, 2, 0, 6, 0 )
1298    ENDIF
1299
1300!
1301!-- Boundary conditions for potential temperature
1302    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1303       ibc_pt_b = 2
1304    ELSE
1305       IF ( bc_pt_b == 'dirichlet' )  THEN
1306          ibc_pt_b = 0
1307       ELSEIF ( bc_pt_b == 'neumann' )  THEN
1308          ibc_pt_b = 1
1309       ELSE
1310          message_string = 'unknown boundary condition: bc_pt_b = "' // TRIM( bc_pt_b ) // '"'
1311          CALL message( 'check_parameters', 'PA0062', 1, 2, 0, 6, 0 )
1312       ENDIF
1313    ENDIF
1314
1315    IF ( bc_pt_t == 'dirichlet' )  THEN
1316       ibc_pt_t = 0
1317    ELSEIF ( bc_pt_t == 'neumann' )  THEN
1318       ibc_pt_t = 1
1319    ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
1320       ibc_pt_t = 2
1321    ELSEIF ( bc_pt_t == 'nested'  .OR.  bc_pt_t == 'nesting_offline' )  THEN
1322       ibc_pt_t = 3
1323    ELSE
1324       message_string = 'unknown boundary condition: bc_pt_t = "' // TRIM( bc_pt_t ) // '"'
1325       CALL message( 'check_parameters', 'PA0063', 1, 2, 0, 6, 0 )
1326    ENDIF
1327
1328    IF ( ANY( wall_heatflux /= 0.0_wp )  .AND.  surface_heatflux == 9999999.9_wp )  THEN
1329       message_string = 'wall_heatflux additionally requires setting of surface_heatflux'
1330       CALL message( 'check_parameters', 'PA0443', 1, 2, 0, 6, 0 )
1331    ENDIF
1332
1333!
1334!   This IF clause needs revision, got too complex!!
1335    IF ( surface_heatflux == 9999999.9_wp  )  THEN
1336       constant_heatflux = .FALSE.
1337       IF ( large_scale_forcing  .OR.  land_surface  .OR.  urban_surface )  THEN
1338          IF ( ibc_pt_b == 0 )  THEN
1339             constant_heatflux = .FALSE.
1340          ELSEIF ( ibc_pt_b == 1 )  THEN
1341             constant_heatflux = .TRUE.
1342             surface_heatflux = 0.0_wp
1343          ENDIF
1344       ENDIF
1345    ELSE
1346       constant_heatflux = .TRUE.
1347    ENDIF
1348
1349    IF ( top_heatflux     == 9999999.9_wp )  constant_top_heatflux = .FALSE.
1350
1351    IF ( neutral )  THEN
1352
1353       IF ( surface_heatflux /= 0.0_wp  .AND.  surface_heatflux /= 9999999.9_wp )  THEN
1354          message_string = 'heatflux must not be set for pure neutral flow'
1355          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1356       ENDIF
1357
1358       IF ( top_heatflux /= 0.0_wp  .AND.  top_heatflux /= 9999999.9_wp )  THEN
1359          message_string = 'heatflux must not be set for pure neutral flow'
1360          CALL message( 'check_parameters', 'PA0351', 1, 2, 0, 6, 0 )
1361       ENDIF
1362
1363    ENDIF
1364
1365    IF ( top_momentumflux_u /= 9999999.9_wp  .AND.  top_momentumflux_v /= 9999999.9_wp )  THEN
1366       constant_top_momentumflux = .TRUE.
1367    ELSEIF ( .NOT. ( top_momentumflux_u == 9999999.9_wp  .AND.                                     &
1368           top_momentumflux_v == 9999999.9_wp ) )  THEN
1369       message_string = 'both, top_momentumflux_u AND top_momentumflux_v must be set'
1370       CALL message( 'check_parameters', 'PA0064', 1, 2, 0, 6, 0 )
1371    ENDIF
1372
1373!
1374!-- A given surface temperature implies Dirichlet boundary condition for temperature. In this case
1375!-- specification of a constant heat flux is forbidden.
1376    IF ( ibc_pt_b == 0  .AND.  constant_heatflux  .AND.  surface_heatflux /= 0.0_wp )  THEN
1377       message_string = 'boundary_condition: bc_pt_b = "' // TRIM( bc_pt_b ) //                    &
1378                        '& is not allowed with constant_heatflux = .TRUE.'
1379       CALL message( 'check_parameters', 'PA0065', 1, 2, 0, 6, 0 )
1380    ENDIF
1381    IF ( constant_heatflux  .AND.  pt_surface_initial_change /= 0.0_wp )  THEN
1382       WRITE ( message_string, * )  'constant_heatflux = .TRUE. is not allo',                      &
1383               'wed with pt_surface_initial_change (/=0) = ', pt_surface_initial_change
1384       CALL message( 'check_parameters', 'PA0066', 1, 2, 0, 6, 0 )
1385    ENDIF
1386
1387!
1388!-- A given temperature at the top implies Dirichlet boundary condition for temperature. In this
1389!-- case specification of a constant heat flux is forbidden.
1390    IF ( ibc_pt_t == 0  .AND.  constant_top_heatflux  .AND.  top_heatflux /= 0.0_wp )  THEN
1391       message_string = 'boundary_condition: bc_pt_t = "' // TRIM( bc_pt_t ) //                    &
1392                        '" is not allowed with constant_top_heatflux = .TRUE.'
1393       CALL message( 'check_parameters', 'PA0067', 1, 2, 0, 6, 0 )
1394    ENDIF
1395
1396!
1397!-- Set boundary conditions for total water content
1398    IF ( humidity )  THEN
1399
1400       IF ( ANY( wall_humidityflux /= 0.0_wp )  .AND.  surface_waterflux == 9999999.9_wp )  THEN
1401          message_string = 'wall_humidityflux additionally requires setting of surface_waterflux'
1402          CALL message( 'check_parameters', 'PA0444', 1, 2, 0, 6, 0 )
1403       ENDIF
1404
1405       CALL set_bc_scalars( 'q', bc_q_b, bc_q_t, ibc_q_b, ibc_q_t, 'PA0071', 'PA0072' )
1406
1407       IF ( surface_waterflux == 9999999.9_wp  )  THEN
1408          constant_waterflux = .FALSE.
1409          IF ( large_scale_forcing .OR. land_surface )  THEN
1410             IF ( ibc_q_b == 0 )  THEN
1411                constant_waterflux = .FALSE.
1412             ELSEIF ( ibc_q_b == 1 )  THEN
1413                constant_waterflux = .TRUE.
1414             ENDIF
1415          ENDIF
1416       ELSE
1417          constant_waterflux = .TRUE.
1418       ENDIF
1419
1420       CALL check_bc_scalars( 'q', bc_q_b, ibc_q_b, 'PA0073', 'PA0074', constant_waterflux,        &
1421                              q_surface_initial_change )
1422
1423    ENDIF
1424
1425    IF ( passive_scalar )  THEN
1426
1427       IF ( ANY( wall_scalarflux /= 0.0_wp )  .AND.  surface_scalarflux == 9999999.9_wp )  THEN
1428          message_string = 'wall_scalarflux additionally requires setting of surface_scalarflux'
1429          CALL message( 'check_parameters', 'PA0445', 1, 2, 0, 6, 0 )
1430       ENDIF
1431
1432       IF ( surface_scalarflux == 9999999.9_wp )  constant_scalarflux = .FALSE.
1433
1434       CALL set_bc_scalars( 's', bc_s_b, bc_s_t, ibc_s_b, ibc_s_t, 'PA0071', 'PA0072' )
1435
1436       CALL check_bc_scalars( 's', bc_s_b, ibc_s_b, 'PA0073', 'PA0074', constant_scalarflux,       &
1437                              s_surface_initial_change )
1438
1439       IF ( top_scalarflux == 9999999.9_wp )  constant_top_scalarflux = .FALSE.
1440!
1441!--    A fixed scalar concentration at the top implies Dirichlet boundary condition for scalar.
1442!--    Hence, in this case specification of a constant scalar flux is forbidden.
1443       IF ( ( ibc_s_t == 0 .OR. ibc_s_t == 2 )  .AND.  constant_top_scalarflux  .AND.              &
1444              top_scalarflux /= 0.0_wp )  THEN
1445          message_string = 'boundary condition: bc_s_t = "' // TRIM( bc_s_t ) //                   &
1446                           '" is not allowed with top_scalarflux /= 0.0'
1447          CALL message( 'check_parameters', 'PA0441', 1, 2, 0, 6, 0 )
1448       ENDIF
1449    ENDIF
1450
1451!
1452!-- Boundary conditions for horizontal components of wind speed
1453    IF ( bc_uv_b == 'dirichlet' )  THEN
1454       ibc_uv_b = 0
1455    ELSEIF ( bc_uv_b == 'neumann' )  THEN
1456       ibc_uv_b = 1
1457       IF ( constant_flux_layer )  THEN
1458          message_string = 'boundary condition: bc_uv_b = "' // TRIM( bc_uv_b ) //                 &
1459                           '" is not allowed with constant_flux_layer = .TRUE.'
1460          CALL message( 'check_parameters', 'PA0075', 1, 2, 0, 6, 0 )
1461       ENDIF
1462    ELSE
1463       message_string = 'unknown boundary condition: bc_uv_b = "' // TRIM( bc_uv_b ) // '"'
1464       CALL message( 'check_parameters', 'PA0076', 1, 2, 0, 6, 0 )
1465    ENDIF
1466!
1467!-- In case of coupled simulations u and v at the ground in atmosphere will be assigned with the u
1468!-- and v values of the ocean surface
1469    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
1470       ibc_uv_b = 2
1471    ENDIF
1472
1473    IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
1474       bc_uv_t = 'neumann'
1475       ibc_uv_t = 1
1476    ELSE
1477       IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
1478          ibc_uv_t = 0
1479          IF ( bc_uv_t == 'dirichlet_0' )  THEN
1480!
1481!--          Velocities for the initial u,v-profiles are set zero at the top in case of dirichlet_0
1482!--          conditions
1483             u_init(nzt+1)    = 0.0_wp
1484             v_init(nzt+1)    = 0.0_wp
1485          ENDIF
1486       ELSEIF ( bc_uv_t == 'neumann' )  THEN
1487          ibc_uv_t = 1
1488       ELSEIF ( bc_uv_t == 'nested'  .OR.  bc_uv_t == 'nesting_offline' )  THEN
1489          ibc_uv_t = 3
1490       ELSE
1491          message_string = 'unknown boundary condition: bc_uv_t = "' // TRIM( bc_uv_t ) // '"'
1492          CALL message( 'check_parameters', 'PA0077', 1, 2, 0, 6, 0 )
1493       ENDIF
1494    ENDIF
1495
1496!
1497!-- Compute and check, respectively, the Rayleigh Damping parameter
1498    IF ( rayleigh_damping_factor == -1.0_wp )  THEN
1499       rayleigh_damping_factor = 0.0_wp
1500    ELSE
1501       IF ( rayleigh_damping_factor < 0.0_wp  .OR.  rayleigh_damping_factor > 1.0_wp )  THEN
1502          WRITE( message_string, * )  'rayleigh_damping_factor = ', rayleigh_damping_factor,       &
1503                 ' out of range [0.0,1.0]'
1504          CALL message( 'check_parameters', 'PA0078', 1, 2, 0, 6, 0 )
1505       ENDIF
1506    ENDIF
1507
1508    IF ( rayleigh_damping_height == -1.0_wp )  THEN
1509       IF ( .NOT. ocean_mode )  THEN
1510          rayleigh_damping_height = 0.66666666666_wp * zu(nzt)
1511       ELSE
1512          rayleigh_damping_height = 0.66666666666_wp * zu(nzb)
1513       ENDIF
1514    ELSE
1515       IF ( .NOT. ocean_mode )  THEN
1516          IF ( rayleigh_damping_height < 0.0_wp  .OR.  rayleigh_damping_height > zu(nzt) )  THEN
1517             WRITE( message_string, * )  'rayleigh_damping_height = ',  rayleigh_damping_height,   &
1518                    ' out of range [0.0,', zu(nzt), ']'
1519             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1520          ENDIF
1521       ELSE
1522          IF ( rayleigh_damping_height > 0.0_wp  .OR.  rayleigh_damping_height < zu(nzb) )  THEN
1523             WRITE( message_string, * )  'rayleigh_damping_height = ', rayleigh_damping_height,    &
1524                    ' out of range [0.0,', zu(nzb), ']'
1525             CALL message( 'check_parameters', 'PA0079', 1, 2, 0, 6, 0 )
1526          ENDIF
1527       ENDIF
1528    ENDIF
1529
1530!
1531!-- Check number of chosen statistic regions
1532    IF ( statistic_regions < 0 )  THEN
1533       WRITE ( message_string, * ) 'number of statistic_regions = ', statistic_regions+1,          &
1534               ' is not allowed'
1535       CALL message( 'check_parameters', 'PA0082', 1, 2, 0, 6, 0 )
1536    ENDIF
1537    IF ( normalizing_region > statistic_regions  .OR.  normalizing_region < 0)  THEN
1538       WRITE ( message_string, * ) 'normalizing_region = ', normalizing_region,                    &
1539               ' must be >= 0 and <= ',statistic_regions, ' (value of statistic_regions)'
1540       CALL message( 'check_parameters', 'PA0083', 1, 2, 0, 6, 0 )
1541    ENDIF
1542
1543!
1544!-- Set the default intervals for data output, if necessary
1545!-- NOTE: dt_dosp has already been set in spectra_parin
1546    IF ( dt_data_output /= 9999999.9_wp )  THEN
1547       IF ( dt_dopr           == 9999999.9_wp )  dt_dopr           = dt_data_output
1548       IF ( dt_dopts          == 9999999.9_wp )  dt_dopts          = dt_data_output
1549       IF ( dt_do2d_xy        == 9999999.9_wp )  dt_do2d_xy        = dt_data_output
1550       IF ( dt_do2d_xz        == 9999999.9_wp )  dt_do2d_xz        = dt_data_output
1551       IF ( dt_do2d_yz        == 9999999.9_wp )  dt_do2d_yz        = dt_data_output
1552       IF ( dt_do3d           == 9999999.9_wp )  dt_do3d           = dt_data_output
1553       IF ( dt_data_output_av == 9999999.9_wp )  dt_data_output_av = dt_data_output
1554       DO  mid = 1, max_masks
1555          IF ( dt_domask(mid) == 9999999.9_wp )  dt_domask(mid)    = dt_data_output
1556       ENDDO
1557    ENDIF
1558
1559!
1560!-- Set the default skip time intervals for data output, if necessary
1561    IF ( skip_time_dopr    == 9999999.9_wp )  skip_time_dopr    = skip_time_data_output
1562    IF ( skip_time_do2d_xy == 9999999.9_wp )  skip_time_do2d_xy = skip_time_data_output
1563    IF ( skip_time_do2d_xz == 9999999.9_wp )  skip_time_do2d_xz = skip_time_data_output
1564    IF ( skip_time_do2d_yz == 9999999.9_wp )  skip_time_do2d_yz = skip_time_data_output
1565    IF ( skip_time_do3d    == 9999999.9_wp )  skip_time_do3d    = skip_time_data_output
1566    IF ( skip_time_data_output_av == 9999999.9_wp )                                                &
1567                                       skip_time_data_output_av = skip_time_data_output
1568    DO  mid = 1, max_masks
1569       IF ( skip_time_domask(mid) == 9999999.9_wp )                                                &
1570                                       skip_time_domask(mid)    = skip_time_data_output
1571    ENDDO
1572
1573!
1574!-- Check the average intervals (first for 3d-data, then for profiles)
1575    IF ( averaging_interval > dt_data_output_av )  THEN
1576       WRITE( message_string, * )  'averaging_interval = ', averaging_interval,                    &
1577              ' must be <= dt_data_output_av = ', dt_data_output_av
1578       CALL message( 'check_parameters', 'PA0085', 1, 2, 0, 6, 0 )
1579    ENDIF
1580
1581    IF ( averaging_interval_pr == 9999999.9_wp )  THEN
1582       averaging_interval_pr = averaging_interval
1583    ENDIF
1584
1585    IF ( averaging_interval_pr > dt_dopr )  THEN
1586       WRITE( message_string, * )  'averaging_interval_pr = ', averaging_interval_pr,              &
1587              ' must be <= dt_dopr = ', dt_dopr
1588       CALL message( 'check_parameters', 'PA0086', 1, 2, 0, 6, 0 )
1589    ENDIF
1590
1591!
1592!-- Set the default interval for profiles entering the temporal average
1593    IF ( dt_averaging_input_pr == 9999999.9_wp )  THEN
1594       dt_averaging_input_pr = dt_averaging_input
1595    ENDIF
1596
1597!
1598!-- Set the default interval for the output of timeseries to a reasonable value (tries to minimize
1599!-- the number of calls of flow_statistics)
1600    IF ( dt_dots == 9999999.9_wp )  THEN
1601       IF ( averaging_interval_pr == 0.0_wp )  THEN
1602          dt_dots = MIN( dt_run_control, dt_dopr )
1603       ELSE
1604          dt_dots = MIN( dt_run_control, dt_averaging_input_pr )
1605       ENDIF
1606    ENDIF
1607
1608!
1609!-- Check the sample rate for averaging (first for 3d-data, then for profiles)
1610    IF ( dt_averaging_input > averaging_interval )  THEN
1611       WRITE( message_string, * )  'dt_averaging_input = ', dt_averaging_input,                    &
1612              ' must be <= averaging_interval = ', averaging_interval
1613       CALL message( 'check_parameters', 'PA0088', 1, 2, 0, 6, 0 )
1614    ENDIF
1615
1616    IF ( dt_averaging_input_pr > averaging_interval_pr )  THEN
1617       WRITE( message_string, * )  'dt_averaging_input_pr = ', dt_averaging_input_pr,              &
1618              ' must be <= averaging_interval_pr = ', averaging_interval_pr
1619       CALL message( 'check_parameters', 'PA0089', 1, 2, 0, 6, 0 )
1620    ENDIF
1621
1622!
1623!-- Determine the number of output profiles and check whether they are permissible
1624    DO  WHILE ( data_output_pr(dopr_n+1) /= '          ' )
1625
1626       dopr_n = dopr_n + 1
1627       i = dopr_n
1628
1629!
1630!--    Determine internal profile number (for hom, homs) and store height levels
1631       SELECT CASE ( TRIM( data_output_pr(i) ) )
1632
1633          CASE ( 'u', '#u' )
1634             dopr_index(i) = 1
1635             dopr_unit(i)  = 'm/s'
1636             hom(:,2,1,:)  = SPREAD( zu, 2, statistic_regions+1 )
1637             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1638                dopr_initial_index(i) = 5
1639                hom(:,2,5,:)          = SPREAD( zu, 2, statistic_regions+1 )
1640                data_output_pr(i)     = data_output_pr(i)(2:)
1641             ENDIF
1642
1643          CASE ( 'v', '#v' )
1644             dopr_index(i) = 2
1645             dopr_unit(i)  = 'm/s'
1646             hom(:,2,2,:)  = SPREAD( zu, 2, statistic_regions+1 )
1647             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1648                dopr_initial_index(i) = 6
1649                hom(:,2,6,:)          = SPREAD( zu, 2, statistic_regions+1 )
1650                data_output_pr(i)     = data_output_pr(i)(2:)
1651             ENDIF
1652
1653          CASE ( 'w' )
1654             dopr_index(i) = 3
1655             dopr_unit(i)  = 'm/s'
1656             hom(:,2,3,:)  = SPREAD( zw, 2, statistic_regions+1 )
1657
1658          CASE ( 'theta', '#theta' )
1659             IF ( .NOT. bulk_cloud_model )  THEN
1660                dopr_index(i) = 4
1661                dopr_unit(i)  = 'K'
1662                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
1663                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1664                   dopr_initial_index(i) = 7
1665                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
1666                   hom(nzb,2,7,:)        = 0.0_wp    ! because zu(nzb) is negative
1667                   data_output_pr(i)     = data_output_pr(i)(2:)
1668                ENDIF
1669             ELSE
1670                dopr_index(i) = 43
1671                dopr_unit(i)  = 'K'
1672                hom(:,2,43,:)  = SPREAD( zu, 2, statistic_regions+1 )
1673                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1674                   dopr_initial_index(i) = 28
1675                   hom(:,2,28,:)         = SPREAD( zu, 2, statistic_regions+1 )
1676                   hom(nzb,2,28,:)       = 0.0_wp    ! because zu(nzb) is negative
1677                   data_output_pr(i)     = data_output_pr(i)(2:)
1678                ENDIF
1679             ENDIF
1680
1681          CASE ( 'e', '#e' )
1682             dopr_index(i)  = 8
1683             dopr_unit(i)   = 'm2/s2'
1684             hom(:,2,8,:)   = SPREAD( zu, 2, statistic_regions+1 )
1685             hom(nzb,2,8,:) = 0.0_wp
1686             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1687                dopr_initial_index(i) = 8
1688                hom(:,2,8,:)          = SPREAD( zu, 2, statistic_regions+1 )
1689                data_output_pr(i)     = data_output_pr(i)(2:)
1690             ENDIF
1691
1692          CASE ( 'km', '#km' )
1693             dopr_index(i)  = 9
1694             dopr_unit(i)   = 'm2/s'
1695             hom(:,2,9,:)   = SPREAD( zu, 2, statistic_regions+1 )
1696             hom(nzb,2,9,:) = 0.0_wp
1697             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1698                dopr_initial_index(i) = 23
1699                hom(:,2,23,:)         = hom(:,2,9,:)
1700                data_output_pr(i)     = data_output_pr(i)(2:)
1701             ENDIF
1702
1703          CASE ( 'kh', '#kh' )
1704             dopr_index(i)   = 10
1705             dopr_unit(i)    = 'm2/s'
1706             hom(:,2,10,:)   = SPREAD( zu, 2, statistic_regions+1 )
1707             hom(nzb,2,10,:) = 0.0_wp
1708             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1709                dopr_initial_index(i) = 24
1710                hom(:,2,24,:)         = hom(:,2,10,:)
1711                data_output_pr(i)     = data_output_pr(i)(2:)
1712             ENDIF
1713
1714          CASE ( 'l', '#l' )
1715             dopr_index(i)   = 11
1716             dopr_unit(i)    = 'm'
1717             hom(:,2,11,:)   = SPREAD( zu, 2, statistic_regions+1 )
1718             hom(nzb,2,11,:) = 0.0_wp
1719             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1720                dopr_initial_index(i) = 25
1721                hom(:,2,25,:)         = hom(:,2,11,:)
1722                data_output_pr(i)     = data_output_pr(i)(2:)
1723             ENDIF
1724
1725          CASE ( 'w"u"' )
1726             dopr_index(i) = 12
1727             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1728             hom(:,2,12,:) = SPREAD( zw, 2, statistic_regions+1 )
1729             IF ( constant_flux_layer )  hom(nzb,2,12,:) = zu(1)
1730
1731          CASE ( 'w*u*' )
1732             dopr_index(i) = 13
1733             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1734             hom(:,2,13,:) = SPREAD( zw, 2, statistic_regions+1 )
1735
1736          CASE ( 'w"v"' )
1737             dopr_index(i) = 14
1738             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1739             hom(:,2,14,:) = SPREAD( zw, 2, statistic_regions+1 )
1740             IF ( constant_flux_layer )  hom(nzb,2,14,:) = zu(1)
1741
1742          CASE ( 'w*v*' )
1743             dopr_index(i) = 15
1744             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1745             hom(:,2,15,:) = SPREAD( zw, 2, statistic_regions+1 )
1746
1747          CASE ( 'w"theta"' )
1748             dopr_index(i) = 16
1749             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1750             hom(:,2,16,:) = SPREAD( zw, 2, statistic_regions+1 )
1751
1752          CASE ( 'w*theta*' )
1753             dopr_index(i) = 17
1754             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1755             hom(:,2,17,:) = SPREAD( zw, 2, statistic_regions+1 )
1756
1757          CASE ( 'wtheta' )
1758             dopr_index(i) = 18
1759             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1760             hom(:,2,18,:) = SPREAD( zw, 2, statistic_regions+1 )
1761
1762          CASE ( 'wu' )
1763             dopr_index(i) = 19
1764             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1765             hom(:,2,19,:) = SPREAD( zw, 2, statistic_regions+1 )
1766             IF ( constant_flux_layer )  hom(nzb,2,19,:) = zu(1)
1767
1768          CASE ( 'wv' )
1769             dopr_index(i) = 20
1770             dopr_unit(i)  = TRIM ( momentumflux_output_unit )
1771             hom(:,2,20,:) = SPREAD( zw, 2, statistic_regions+1 )
1772             IF ( constant_flux_layer )  hom(nzb,2,20,:) = zu(1)
1773
1774          CASE ( 'w*theta*BC' )
1775             dopr_index(i) = 21
1776             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1777             hom(:,2,21,:) = SPREAD( zw, 2, statistic_regions+1 )
1778
1779          CASE ( 'wthetaBC' )
1780             dopr_index(i) = 22
1781             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1782             hom(:,2,22,:) = SPREAD( zw, 2, statistic_regions+1 )
1783
1784          CASE ( 'u*2' )
1785             dopr_index(i) = 30
1786             dopr_unit(i)  = 'm2/s2'
1787             hom(:,2,30,:) = SPREAD( zu, 2, statistic_regions+1 )
1788
1789          CASE ( 'v*2' )
1790             dopr_index(i) = 31
1791             dopr_unit(i)  = 'm2/s2'
1792             hom(:,2,31,:) = SPREAD( zu, 2, statistic_regions+1 )
1793
1794          CASE ( 'w*2' )
1795             dopr_index(i) = 32
1796             dopr_unit(i)  = 'm2/s2'
1797             hom(:,2,32,:) = SPREAD( zw, 2, statistic_regions+1 )
1798
1799          CASE ( 'theta*2' )
1800             dopr_index(i) = 33
1801             dopr_unit(i)  = 'K2'
1802             hom(:,2,33,:) = SPREAD( zu, 2, statistic_regions+1 )
1803
1804          CASE ( 'e*' )
1805             dopr_index(i) = 34
1806             dopr_unit(i)  = 'm2/s2'
1807             hom(:,2,34,:) = SPREAD( zu, 2, statistic_regions+1 )
1808
1809          CASE ( 'w*2theta*' )
1810             dopr_index(i) = 35
1811             dopr_unit(i)  = 'K m2/s2'
1812             hom(:,2,35,:) = SPREAD( zw, 2, statistic_regions+1 )
1813
1814          CASE ( 'w*theta*2' )
1815             dopr_index(i) = 36
1816             dopr_unit(i)  = 'K2 m/s'
1817             hom(:,2,36,:) = SPREAD( zw, 2, statistic_regions+1 )
1818
1819          CASE ( 'w*e*' )
1820             dopr_index(i) = 37
1821             dopr_unit(i)  = 'm3/s3'
1822             hom(:,2,37,:) = SPREAD( zw, 2, statistic_regions+1 )
1823
1824          CASE ( 'w*3' )
1825             dopr_index(i) = 38
1826             dopr_unit(i)  = 'm3/s3'
1827             hom(:,2,38,:) = SPREAD( zw, 2, statistic_regions+1 )
1828
1829          CASE ( 'Sw' )
1830             dopr_index(i) = 39
1831             dopr_unit(i)  = 'none'
1832             hom(:,2,39,:) = SPREAD( zw, 2, statistic_regions+1 )
1833
1834          CASE ( 'p' )
1835             dopr_index(i) = 40
1836             dopr_unit(i)  = 'Pa'
1837             hom(:,2,40,:) = SPREAD( zu, 2, statistic_regions+1 )
1838
1839          CASE ( 'q', '#q' )
1840             IF ( .NOT. humidity )  THEN
1841                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1842                                 ' is not implemented for humidity = .FALSE.'
1843                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
1844             ELSE
1845                dopr_index(i) = 41
1846                dopr_unit(i)  = 'kg/kg'
1847                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
1848                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1849                   dopr_initial_index(i) = 26
1850                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
1851                   hom(nzb,2,26,:)       = 0.0_wp    ! because zu(nzb) is negative
1852                   data_output_pr(i)     = data_output_pr(i)(2:)
1853                ENDIF
1854             ENDIF
1855
1856          CASE ( 's', '#s' )
1857             IF ( .NOT. passive_scalar )  THEN
1858                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1859                                 ' is not implemented for passive_scalar = .FALSE.'
1860                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
1861             ELSE
1862                dopr_index(i) = 115
1863                dopr_unit(i)  = 'kg/m3'
1864                hom(:,2,115,:) = SPREAD( zu, 2, statistic_regions+1 )
1865                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1866                   dopr_initial_index(i) = 121
1867                   hom(:,2,121,:)        = SPREAD( zu, 2, statistic_regions+1 )
1868                   hom(nzb,2,121,:)      = 0.0_wp    ! because zu(nzb) is negative
1869                   data_output_pr(i)     = data_output_pr(i)(2:)
1870                ENDIF
1871             ENDIF
1872
1873          CASE ( 'qv', '#qv' )
1874             IF ( .NOT. bulk_cloud_model ) THEN
1875                dopr_index(i) = 41
1876                dopr_unit(i)  = 'kg/kg'
1877                hom(:,2,41,:) = SPREAD( zu, 2, statistic_regions+1 )
1878                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1879                   dopr_initial_index(i) = 26
1880                   hom(:,2,26,:)         = SPREAD( zu, 2, statistic_regions+1 )
1881                   hom(nzb,2,26,:)       = 0.0_wp    ! because zu(nzb) is negative
1882                   data_output_pr(i)     = data_output_pr(i)(2:)
1883                ENDIF
1884             ELSE
1885                dopr_index(i) = 42
1886                dopr_unit(i)  = 'kg/kg'
1887                hom(:,2,42,:) = SPREAD( zu, 2, statistic_regions+1 )
1888                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1889                   dopr_initial_index(i) = 27
1890                   hom(:,2,27,:)         = SPREAD( zu, 2, statistic_regions+1 )
1891                   hom(nzb,2,27,:)       = 0.0_wp   ! because zu(nzb) is negative
1892                   data_output_pr(i)     = data_output_pr(i)(2:)
1893                ENDIF
1894             ENDIF
1895
1896          CASE ( 'thetal', '#thetal' )
1897             IF ( .NOT. bulk_cloud_model ) THEN
1898                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1899                                 ' is not implemented for bulk_cloud_model = .FALSE.'
1900                CALL message( 'check_parameters', 'PA0094', 1, 2, 0, 6, 0 )
1901             ELSE
1902                dopr_index(i) = 4
1903                dopr_unit(i)  = 'K'
1904                hom(:,2,4,:)  = SPREAD( zu, 2, statistic_regions+1 )
1905                IF ( data_output_pr(i)(1:1) == '#' )  THEN
1906                   dopr_initial_index(i) = 7
1907                   hom(:,2,7,:)          = SPREAD( zu, 2, statistic_regions+1 )
1908                   hom(nzb,2,7,:)        = 0.0_wp    ! because zu(nzb) is negative
1909                   data_output_pr(i)     = data_output_pr(i)(2:)
1910                ENDIF
1911             ENDIF
1912
1913          CASE ( 'thetav', '#thetav' )
1914             dopr_index(i) = 44
1915             dopr_unit(i)  = 'K'
1916             hom(:,2,44,:) = SPREAD( zu, 2, statistic_regions+1 )
1917             IF ( data_output_pr(i)(1:1) == '#' )  THEN
1918                dopr_initial_index(i) = 29
1919                hom(:,2,29,:)         = SPREAD( zu, 2, statistic_regions+1 )
1920                hom(nzb,2,29,:)       = 0.0_wp    ! because zu(nzb) is negative
1921                data_output_pr(i)     = data_output_pr(i)(2:)
1922             ENDIF
1923
1924          CASE ( 'w"thetav"' )
1925             dopr_index(i) = 45
1926             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1927             hom(:,2,45,:) = SPREAD( zw, 2, statistic_regions+1 )
1928
1929          CASE ( 'w*thetav*' )
1930             dopr_index(i) = 46
1931             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1932             hom(:,2,46,:) = SPREAD( zw, 2, statistic_regions+1 )
1933
1934          CASE ( 'wthetav' )
1935             dopr_index(i) = 47
1936             dopr_unit(i)  = TRIM ( heatflux_output_unit )
1937             hom(:,2,47,:) = SPREAD( zw, 2, statistic_regions+1 )
1938
1939          CASE ( 'w"q"' )
1940             IF ( .NOT. humidity )  THEN
1941                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1942                                 ' is not implemented for humidity = .FALSE.'
1943                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
1944             ELSE
1945                dopr_index(i) = 48
1946                dopr_unit(i)  = TRIM ( waterflux_output_unit )
1947                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
1948             ENDIF
1949
1950          CASE ( 'w*q*' )
1951             IF ( .NOT. humidity )  THEN
1952                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1953                                 ' is not implemented for humidity = .FALSE.'
1954                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
1955             ELSE
1956                dopr_index(i) = 49
1957                dopr_unit(i)  = TRIM ( waterflux_output_unit )
1958                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
1959             ENDIF
1960
1961          CASE ( 'wq' )
1962             IF ( .NOT. humidity )  THEN
1963                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1964                                 ' is not implemented for humidity = .FALSE.'
1965                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
1966             ELSE
1967                dopr_index(i) = 50
1968                dopr_unit(i)  = TRIM ( waterflux_output_unit )
1969                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
1970             ENDIF
1971
1972          CASE ( 'w"s"' )
1973             IF ( .NOT. passive_scalar )  THEN
1974                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1975                                 ' is not implemented for passive_scalar = .FALSE.'
1976                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
1977             ELSE
1978                dopr_index(i) = 117
1979                dopr_unit(i)  = 'kg/m3 m/s'
1980                hom(:,2,117,:) = SPREAD( zw, 2, statistic_regions+1 )
1981             ENDIF
1982
1983          CASE ( 'w*s*' )
1984             IF ( .NOT. passive_scalar )  THEN
1985                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1986                                 ' is not implemented for passive_scalar = .FALSE.'
1987                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
1988             ELSE
1989                dopr_index(i) = 114
1990                dopr_unit(i)  = 'kg/m3 m/s'
1991                hom(:,2,114,:) = SPREAD( zw, 2, statistic_regions+1 )
1992             ENDIF
1993
1994          CASE ( 'ws' )
1995             IF ( .NOT. passive_scalar )  THEN
1996                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
1997                                 ' is not implemented for passive_scalar = .FALSE.'
1998                CALL message( 'check_parameters', 'PA0093', 1, 2, 0, 6, 0 )
1999             ELSE
2000                dopr_index(i) = 118
2001                dopr_unit(i)  = 'kg/m3 m/s'
2002                hom(:,2,118,:) = SPREAD( zw, 2, statistic_regions+1 )
2003             ENDIF
2004
2005          CASE ( 'w"qv"' )
2006             IF ( humidity  .AND.  .NOT. bulk_cloud_model )  THEN
2007                dopr_index(i) = 48
2008                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2009                hom(:,2,48,:) = SPREAD( zw, 2, statistic_regions+1 )
2010             ELSEIF ( humidity  .AND.  bulk_cloud_model )  THEN
2011                dopr_index(i) = 51
2012                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2013                hom(:,2,51,:) = SPREAD( zw, 2, statistic_regions+1 )
2014             ELSE
2015                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2016                                 ' is not implemented for bulk_cloud_model = .FALSE. ' //          &
2017                                 'and humidity = .FALSE.'
2018                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2019             ENDIF
2020
2021          CASE ( 'w*qv*' )
2022             IF ( humidity  .AND.  .NOT. bulk_cloud_model )  THEN
2023                dopr_index(i) = 49
2024                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2025                hom(:,2,49,:) = SPREAD( zw, 2, statistic_regions+1 )
2026             ELSEIF( humidity  .AND.  bulk_cloud_model )  THEN
2027                dopr_index(i) = 52
2028                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2029                hom(:,2,52,:) = SPREAD( zw, 2, statistic_regions+1 )
2030             ELSE
2031                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2032                                 ' is not implemented for bulk_cloud_model = .FALSE. ' //          &
2033                                 'and humidity = .FALSE.'
2034                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2035             ENDIF
2036
2037          CASE ( 'wqv' )
2038             IF ( humidity  .AND.  .NOT. bulk_cloud_model )  THEN
2039                dopr_index(i) = 50
2040                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2041                hom(:,2,50,:) = SPREAD( zw, 2, statistic_regions+1 )
2042             ELSEIF ( humidity  .AND.  bulk_cloud_model )  THEN
2043                dopr_index(i) = 53
2044                dopr_unit(i)  = TRIM ( waterflux_output_unit )
2045                hom(:,2,53,:) = SPREAD( zw, 2, statistic_regions+1 )
2046             ELSE
2047                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2048                                 ' is not implemented for bulk_cloud_model = .FALSE. ' //          &
2049                                 'and humidity = .FALSE.'
2050                CALL message( 'check_parameters', 'PA0095', 1, 2, 0, 6, 0 )
2051             ENDIF
2052
2053          CASE ( 'ql' )
2054             IF ( .NOT. bulk_cloud_model  .AND.  .NOT. cloud_droplets )  THEN
2055                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2056                                 ' is not implemented for bulk_cloud_model = .FALSE. ' //          &
2057                                 'and cloud_droplets = .FALSE.'
2058                CALL message( 'check_parameters', 'PA0096', 1, 2, 0, 6, 0 )
2059             ELSE
2060                dopr_index(i) = 54
2061                dopr_unit(i)  = 'kg/kg'
2062                hom(:,2,54,:)  = SPREAD( zu, 2, statistic_regions+1 )
2063             ENDIF
2064
2065          CASE ( 'w*u*u*:dz' )
2066             dopr_index(i) = 55
2067             dopr_unit(i)  = 'm2/s3'
2068             hom(:,2,55,:) = SPREAD( zu, 2, statistic_regions+1 )
2069
2070          CASE ( 'w*p*:dz' )
2071             dopr_index(i) = 56
2072             dopr_unit(i)  = 'm2/s3'
2073             hom(:,2,56,:) = SPREAD( zw, 2, statistic_regions+1 )
2074
2075          CASE ( 'w"e:dz' )
2076             dopr_index(i) = 57
2077             dopr_unit(i)  = 'm2/s3'
2078             hom(:,2,57,:) = SPREAD( zu, 2, statistic_regions+1 )
2079
2080          CASE ( 'u"theta"' )
2081             dopr_index(i) = 58
2082             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2083             hom(:,2,58,:) = SPREAD( zu, 2, statistic_regions+1 )
2084
2085          CASE ( 'u*theta*' )
2086             dopr_index(i) = 59
2087             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2088             hom(:,2,59,:) = SPREAD( zu, 2, statistic_regions+1 )
2089
2090          CASE ( 'utheta_t' )
2091             dopr_index(i) = 60
2092             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2093             hom(:,2,60,:) = SPREAD( zu, 2, statistic_regions+1 )
2094
2095          CASE ( 'v"theta"' )
2096             dopr_index(i) = 61
2097             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2098             hom(:,2,61,:) = SPREAD( zu, 2, statistic_regions+1 )
2099
2100          CASE ( 'v*theta*' )
2101             dopr_index(i) = 62
2102             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2103             hom(:,2,62,:) = SPREAD( zu, 2, statistic_regions+1 )
2104
2105          CASE ( 'vtheta_t' )
2106             dopr_index(i) = 63
2107             dopr_unit(i)  = TRIM ( heatflux_output_unit )
2108             hom(:,2,63,:) = SPREAD( zu, 2, statistic_regions+1 )
2109
2110          CASE ( 'w*p*' )
2111             dopr_index(i) = 68
2112             dopr_unit(i)  = 'm3/s3'
2113             hom(:,2,68,:) = SPREAD( zu, 2, statistic_regions+1 )
2114
2115          CASE ( 'w"e' )
2116             dopr_index(i) = 69
2117             dopr_unit(i)  = 'm3/s3'
2118             hom(:,2,69,:) = SPREAD( zu, 2, statistic_regions+1 )
2119
2120          CASE ( 'q*2' )
2121             IF (  .NOT.  humidity )  THEN
2122                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2123                                 ' is not implemented for humidity = .FALSE.'
2124                CALL message( 'check_parameters', 'PA0092', 1, 2, 0, 6, 0 )
2125             ELSE
2126                dopr_index(i) = 70
2127                dopr_unit(i)  = 'kg2/kg2'
2128                hom(:,2,70,:) = SPREAD( zu, 2, statistic_regions+1 )
2129             ENDIF
2130
2131          CASE ( 'hyp' )
2132             dopr_index(i) = 72
2133             dopr_unit(i)  = 'hPa'
2134             hom(:,2,72,:) = SPREAD( zu, 2, statistic_regions+1 )
2135
2136          CASE ( 'rho' )
2137             dopr_index(i)  = 119
2138             dopr_unit(i)   = 'kg/m3'
2139             hom(:,2,119,:) = SPREAD( zu, 2, statistic_regions+1 )
2140
2141          CASE ( 'rho_zw' )
2142             dopr_index(i)  = 120
2143             dopr_unit(i)   = 'kg/m3'
2144             hom(:,2,120,:) = SPREAD( zw, 2, statistic_regions+1 )
2145
2146          CASE ( 'ug' )
2147             dopr_index(i) = 78
2148             dopr_unit(i)  = 'm/s'
2149             hom(:,2,78,:) = SPREAD( zu, 2, statistic_regions+1 )
2150
2151          CASE ( 'vg' )
2152             dopr_index(i) = 79
2153             dopr_unit(i)  = 'm/s'
2154             hom(:,2,79,:) = SPREAD( zu, 2, statistic_regions+1 )
2155
2156          CASE ( 'w_subs' )
2157             IF (  .NOT.  large_scale_subsidence )  THEN
2158                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2159                                 ' is not implemented for large_scale_subsidence = .FALSE.'
2160                CALL message( 'check_parameters', 'PA0382', 1, 2, 0, 6, 0 )
2161             ELSE
2162                dopr_index(i) = 80
2163                dopr_unit(i)  = 'm/s'
2164                hom(:,2,80,:) = SPREAD( zu, 2, statistic_regions+1 )
2165             ENDIF
2166
2167          CASE ( 's*2' )
2168             IF (  .NOT.  passive_scalar )  THEN
2169                message_string = 'data_output_pr = ' // TRIM( data_output_pr(i) ) //               &
2170                                 ' is not implemented for passive_scalar = .FALSE.'
2171                CALL message( 'check_parameters', 'PA0185', 1, 2, 0, 6, 0 )
2172             ELSE
2173                dopr_index(i) = 116
2174                dopr_unit(i)  = 'kg2/m6'
2175                hom(:,2,116,:) = SPREAD( zu, 2, statistic_regions+1 )
2176             ENDIF
2177
2178           CASE ( 'eta' )
2179              dopr_index(i) = 121
2180              dopr_unit(i)  = 'mm'
2181              hom(:,2,121,:) = SPREAD( zu, 2, statistic_regions+1 )
2182
2183              kolmogorov_length_scale = .TRUE.
2184
2185          CASE DEFAULT
2186             unit = 'illegal'
2187!
2188!--          Check for other modules
2189             CALL module_interface_check_data_output_pr( data_output_pr(i), i, unit, dopr_unit(i) )
2190
2191!
2192!--          No valid quantity found
2193             IF ( unit == 'illegal' )  THEN
2194                IF ( data_output_pr_user(1) /= ' ' )  THEN
2195                   message_string = 'illegal value for data_output_pr or ' //                      &
2196                                    'data_output_pr_user = "' // TRIM( data_output_pr(i) ) // '"'
2197                   CALL message( 'check_parameters', 'PA0097', 1, 2, 0, 6, 0 )
2198                ELSE
2199                   message_string = 'illegal value for data_output_pr = "' //                      &
2200                                    TRIM( data_output_pr(i) ) // '"'
2201                   CALL message( 'check_parameters', 'PA0098', 1, 2, 0, 6, 0 )
2202                ENDIF
2203             ENDIF
2204
2205       END SELECT
2206
2207    ENDDO
2208
2209
2210!
2211!-- Append user-defined data output variables to the standard data output
2212    IF ( data_output_user(1) /= ' ' )  THEN
2213       i = 1
2214       DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 500 )
2215          i = i + 1
2216       ENDDO
2217       j = 1
2218       DO  WHILE ( data_output_user(j) /= ' '  .AND.  j <= 500 )
2219          IF ( i > 500 )  THEN
2220             message_string = 'number of output quantitities given by data' //                     &
2221                              '_output and data_output_user exceeds the limit of 500'
2222             CALL message( 'check_parameters', 'PA0102', 1, 2, 0, 6, 0 )
2223          ENDIF
2224          data_output(i) = data_output_user(j)
2225          i = i + 1
2226          j = j + 1
2227       ENDDO
2228    ENDIF
2229
2230!
2231!-- Check and set steering parameters for 2d/3d data output and averaging
2232    i   = 1
2233    DO  WHILE ( data_output(i) /= ' '  .AND.  i <= 500 )
2234!
2235!--    Check for data averaging
2236       ilen = LEN_TRIM( data_output(i) )
2237       j = 0                                                 ! no data averaging
2238       IF ( ilen > 3 )  THEN
2239          IF ( data_output(i)(ilen-2:ilen) == '_av' )  THEN
2240             j = 1                                           ! data averaging
2241             data_output(i) = data_output(i)(1:ilen-3)
2242          ENDIF
2243       ENDIF
2244!
2245!--    Check for cross section or volume data
2246       ilen = LEN_TRIM( data_output(i) )
2247       k = 0                                                   ! 3d data
2248       var = data_output(i)(1:ilen)
2249       IF ( ilen > 3 )  THEN
2250          IF ( data_output(i)(ilen-2:ilen) == '_xy'  .OR.  data_output(i)(ilen-2:ilen) == '_xz'    &
2251               .OR.  data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2252             k = 1                                             ! 2d data
2253             var = data_output(i)(1:ilen-3)
2254          ENDIF
2255       ENDIF
2256
2257!
2258!--    Check for allowed value and set units
2259       SELECT CASE ( TRIM( var ) )
2260
2261          CASE ( 'e' )
2262             IF ( constant_diffusion )  THEN
2263                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2264                                 'constant_diffusion = .FALSE.'
2265                CALL message( 'check_parameters', 'PA0103', 1, 2, 0, 6, 0 )
2266             ENDIF
2267             unit = 'm2/s2'
2268
2269          CASE ( 'thetal' )
2270             IF ( .NOT. bulk_cloud_model )  THEN
2271                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2272                                 'bulk_cloud_model = .TRUE.'
2273                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2274             ENDIF
2275             unit = 'K'
2276
2277          CASE ( 'pc', 'pr' )
2278             IF ( .NOT. particle_advection )  THEN
2279                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2280                                 'a "particle_parameters"-NAMELIST in the parameter file (PARIN)'
2281                CALL message( 'check_parameters', 'PA0104', 1, 2, 0, 6, 0 )
2282             ENDIF
2283             IF ( TRIM( var ) == 'pc' )  unit = 'number'
2284             IF ( TRIM( var ) == 'pr' )  unit = 'm'
2285
2286          CASE ( 'q', 'thetav' )
2287             IF ( .NOT. humidity )  THEN
2288                message_string = 'output of "' // TRIM( var ) // '" requires humidity = .TRUE.'
2289                CALL message( 'check_parameters', 'PA0105', 1, 2, 0, 6, 0 )
2290             ENDIF
2291             IF ( TRIM( var ) == 'q'   )  unit = 'kg/kg'
2292             IF ( TRIM( var ) == 'thetav' )  unit = 'K'
2293
2294          CASE ( 'ql' )
2295             IF ( .NOT.  ( bulk_cloud_model  .OR.  cloud_droplets ) )  THEN
2296                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2297                                 'bulk_cloud_model = .TRUE. or cloud_droplets = .TRUE.'
2298                CALL message( 'check_parameters', 'PA0106', 1, 2, 0, 6, 0 )
2299             ENDIF
2300             unit = 'kg/kg'
2301
2302          CASE ( 'ql_c', 'ql_v', 'ql_vp' )
2303             IF ( .NOT. cloud_droplets )  THEN
2304                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2305                                 'cloud_droplets = .TRUE.'
2306                CALL message( 'check_parameters', 'PA0107', 1, 2, 0, 6, 0 )
2307             ENDIF
2308             IF ( TRIM( var ) == 'ql_c'  )  unit = 'kg/kg'
2309             IF ( TRIM( var ) == 'ql_v'  )  unit = 'm3'
2310             IF ( TRIM( var ) == 'ql_vp' )  unit = 'none'
2311
2312          CASE ( 'qv' )
2313             IF ( .NOT. bulk_cloud_model )  THEN
2314                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2315                                 'bulk_cloud_model = .TRUE.'
2316                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2317             ENDIF
2318             unit = 'kg/kg'
2319
2320          CASE ( 's' )
2321             IF ( .NOT. passive_scalar )  THEN
2322                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2323                                 'passive_scalar = .TRUE.'
2324                CALL message( 'check_parameters', 'PA0110', 1, 2, 0, 6, 0 )
2325             ENDIF
2326             unit = 'kg/m3'
2327
2328          CASE ( 'p', 'theta', 'u', 'v', 'w' )
2329             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
2330             IF ( TRIM( var ) == 'theta' )  unit = 'K'
2331             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
2332             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
2333             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
2334             CONTINUE
2335
2336          CASE ( 'ghf*', 'lwp*', 'ol*', 'qsurf*', 'qsws*', 'r_a*', 'shf*', 'ssurf*', 'ssws*', 't*',&
2337                 'tsurf*', 'us*', 'z0*', 'z0h*', 'z0q*' )
2338             IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
2339                message_string = 'illegal value for data_output: "' // TRIM( var ) //              &
2340                                 '" & only 2d-horizontal cross sections are allowed for this value'
2341                CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
2342             ENDIF
2343
2344             IF ( TRIM( var ) == 'lwp*'  .AND.  .NOT. bulk_cloud_model )  THEN
2345                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2346                                 'bulk_cloud_model = .TRUE.'
2347                CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
2348             ENDIF
2349             IF ( TRIM( var ) == 'qsws*'  .AND.  .NOT.  humidity )  THEN
2350                message_string = 'output of "' // TRIM( var ) // '" requires humidity = .TRUE.'
2351                CALL message( 'check_parameters', 'PA0322', 1, 2, 0, 6, 0 )
2352             ENDIF
2353
2354             IF ( TRIM( var ) == 'ghf*'  .AND.  .NOT.  land_surface )  THEN
2355                message_string = 'output of "' // TRIM( var ) // '" requires land_surface = .TRUE.'
2356                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
2357             ENDIF
2358
2359             IF ( (  TRIM( var ) == 'r_a*' .OR. TRIM( var ) == 'ghf*' )  .AND.  .NOT. land_surface &
2360                   .AND.  .NOT. urban_surface )  THEN
2361                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2362                                 'land_surface = .TRUE. or ' // 'urban_surface = .TRUE.'
2363                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
2364             ENDIF
2365
2366             IF ( TRIM( var ) == 'ssws*'  .AND.  .NOT. passive_scalar )  THEN
2367                message_string = 'output of "' // TRIM( var ) // '" requires ' //                  &
2368                                 'passive_scalar = .TRUE.'
2369                CALL message( 'check_parameters', 'PA0361', 1, 2, 0, 6, 0 )
2370             ENDIF
2371
2372             IF ( TRIM( var ) == 'ghf*'   )  unit = 'W/m2'
2373             IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/m2'
2374             IF ( TRIM( var ) == 'ol*'    )  unit = 'm'
2375             IF ( TRIM( var ) == 'qsurf*' )  unit = 'kg/kg'
2376             IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
2377             IF ( TRIM( var ) == 'r_a*'   )  unit = 's/m'
2378             IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
2379             IF ( TRIM( var ) == 'ssurf*' )  unit = 'kg/kg'
2380             IF ( TRIM( var ) == 'ssws*'  )  unit = 'kg/m2*s'
2381             IF ( TRIM( var ) == 't*'     )  unit = 'K'
2382             IF ( TRIM( var ) == 'tsurf*' )  unit = 'K'
2383             IF ( TRIM( var ) == 'us*'    )  unit = 'm/s'
2384             IF ( TRIM( var ) == 'z0*'    )  unit = 'm'
2385             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm'
2386!
2387!--          Output of surface latent and sensible heat flux will be in W/m2 in case of natural- and
2388!--          urban-type surfaces, even if flux_output_mode is set to kinematic units.
2389             IF ( land_surface  .OR.  urban_surface )  THEN
2390                IF ( TRIM( var ) == 'shf*'   )  unit = 'W/m2'
2391                IF ( TRIM( var ) == 'qsws*'  )  unit = 'W/m2'
2392             ENDIF
2393
2394          CASE DEFAULT
2395!
2396!--          Check for other modules
2397             CALL module_interface_check_data_output( var, unit, i, j, ilen, k )
2398
2399             IF ( unit == 'illegal' )  THEN
2400                IF ( data_output_user(1) /= ' ' )  THEN
2401                   message_string = 'illegal value for data_output or ' //                         &
2402                                    'data_output_user = "' // TRIM( data_output(i) ) // '"'
2403                   CALL message( 'check_parameters', 'PA0114', 1, 2, 0, 6, 0 )
2404                ELSE
2405                   message_string = 'illegal value for data_output = "' //                         &
2406                                    TRIM( data_output(i) ) // '"'
2407                   CALL message( 'check_parameters', 'PA0115', 1, 2, 0, 6, 0 )
2408                ENDIF
2409             ENDIF
2410
2411       END SELECT
2412!
2413!--    Set the internal steering parameters appropriately
2414       IF ( k == 0 )  THEN
2415          do3d_no(j)              = do3d_no(j) + 1
2416          do3d(j,do3d_no(j))      = data_output(i)
2417          do3d_unit(j,do3d_no(j)) = unit
2418       ELSE
2419          do2d_no(j)              = do2d_no(j) + 1
2420          do2d(j,do2d_no(j))      = data_output(i)
2421          do2d_unit(j,do2d_no(j)) = unit
2422          IF ( data_output(i)(ilen-2:ilen) == '_xy' )  THEN
2423             data_output_xy(j) = .TRUE.
2424          ENDIF
2425          IF ( data_output(i)(ilen-2:ilen) == '_xz' )  THEN
2426             data_output_xz(j) = .TRUE.
2427          ENDIF
2428          IF ( data_output(i)(ilen-2:ilen) == '_yz' )  THEN
2429             data_output_yz(j) = .TRUE.
2430          ENDIF
2431       ENDIF
2432
2433       IF ( j == 1 )  THEN
2434!
2435!--       Check, if variable is already subject to averaging
2436          found = .FALSE.
2437          DO  k = 1, doav_n
2438             IF ( TRIM( doav(k) ) == TRIM( var ) )  found = .TRUE.
2439          ENDDO
2440
2441          IF ( .NOT. found )  THEN
2442             doav_n = doav_n + 1
2443             doav(doav_n) = var
2444          ENDIF
2445       ENDIF
2446
2447       i = i + 1
2448    ENDDO
2449
2450!
2451!-- Averaged 2d or 3d output requires that an averaging interval has been set
2452    IF ( doav_n > 0  .AND.  averaging_interval == 0.0_wp )  THEN
2453       WRITE( message_string, * )  'output of averaged quantity "', TRIM( doav(1) ),               &
2454                                   '_av" requires to set a ', 'non-zero averaging interval'
2455       CALL message( 'check_parameters', 'PA0323', 1, 2, 0, 6, 0 )
2456    ENDIF
2457
2458!
2459!-- Check sectional planes and store them in one shared array
2460    IF ( ANY( section_xy > nz + 1 ) )  THEN
2461       WRITE( message_string, * )  'section_xy must be <= nz + 1 = ', nz + 1
2462       CALL message( 'check_parameters', 'PA0319', 1, 2, 0, 6, 0 )
2463    ENDIF
2464    IF ( ANY( section_xz > ny + 1 ) )  THEN
2465       WRITE( message_string, * )  'section_xz must be <= ny + 1 = ', ny + 1
2466       CALL message( 'check_parameters', 'PA0320', 1, 2, 0, 6, 0 )
2467    ENDIF
2468    IF ( ANY( section_yz > nx + 1 ) )  THEN
2469       WRITE( message_string, * )  'section_yz must be <= nx + 1 = ', nx + 1
2470       CALL message( 'check_parameters', 'PA0321', 1, 2, 0, 6, 0 )
2471    ENDIF
2472    section(:,1) = section_xy
2473    section(:,2) = section_xz
2474    section(:,3) = section_yz
2475
2476    IF ( ANY( data_output_xy )  .AND.  .NOT. ANY( section(:,1) /= -9999 ) )  THEN
2477       WRITE( message_string, * )  'section_xy not defined for requested xy-cross section ' //     &
2478                                   'output.&At least one cross section must be given.'
2479       CALL message( 'check_parameters', 'PA0681', 1, 2, 0, 6, 0 )
2480    ENDIF
2481    IF ( ANY( data_output_xz )  .AND.  .NOT. ANY( section(:,2) /= -9999 ) )  THEN
2482       WRITE( message_string, * )  'section_xz not defined for requested xz-cross section ' //     &
2483                                   'output.&At least one cross section must be given.'
2484       CALL message( 'check_parameters', 'PA0681', 1, 2, 0, 6, 0 )
2485    ENDIF
2486    IF ( ANY( data_output_yz )  .AND.  .NOT. ANY( section(:,3) /= -9999 ) )  THEN
2487       WRITE( message_string, * )  'section_yz not defined for requested yz-cross section ' //     &
2488                                   'output.&At least one cross section must be given.'
2489       CALL message( 'check_parameters', 'PA0681', 1, 2, 0, 6, 0 )
2490    ENDIF
2491!
2492!-- Upper plot limit for 3D arrays
2493    IF ( nz_do3d == -9999 )  nz_do3d = nzt + 1
2494
2495!
2496!-- Set output format string (used in header)
2497    SELECT CASE ( netcdf_data_format )
2498       CASE ( 1 )
2499          netcdf_data_format_string = 'netCDF classic'
2500       CASE ( 2 )
2501          netcdf_data_format_string = 'netCDF 64bit offset'
2502       CASE ( 3 )
2503          netcdf_data_format_string = 'netCDF4/HDF5'
2504       CASE ( 4 )
2505          netcdf_data_format_string = 'netCDF4/HDF5 classic'
2506       CASE ( 5 )
2507          netcdf_data_format_string = 'parallel netCDF4/HDF5'
2508       CASE ( 6 )
2509          netcdf_data_format_string = 'parallel netCDF4/HDF5 classic'
2510
2511    END SELECT
2512
2513!
2514!-- Check mask conditions
2515    DO mid = 1, max_masks
2516       IF ( data_output_masks(mid,1) /= ' '  .OR.  data_output_masks_user(mid,1) /= ' ' )  THEN
2517          masks = masks + 1
2518       ENDIF
2519    ENDDO
2520
2521    IF ( masks < 0  .OR.  masks > max_masks )  THEN
2522       WRITE( message_string, * )  'illegal value: masks must be >= 0 and ', '<= ', max_masks,     &
2523              ' (=max_masks)'
2524       CALL message( 'check_parameters', 'PA0325', 1, 2, 0, 6, 0 )
2525    ENDIF
2526    IF ( masks > 0 )  THEN
2527       mask_scale(1) = mask_scale_x
2528       mask_scale(2) = mask_scale_y
2529       mask_scale(3) = mask_scale_z
2530       IF ( ANY( mask_scale <= 0.0_wp ) )  THEN
2531          WRITE( message_string, * )  'illegal value: mask_scale_x, mask_scale_y and mask_scale_z',&
2532                 'must be > 0.0'
2533          CALL message( 'check_parameters', 'PA0326', 1, 2, 0, 6, 0 )
2534       ENDIF
2535!
2536!--    Generate masks for masked data output.
2537!--    Parallel netcdf output is not tested so far for masked data, hence netcdf_data_format is
2538!--    switched back to non-parallel output.
2539       netcdf_data_format_save = netcdf_data_format
2540       IF ( netcdf_data_format > 4 )  THEN
2541          IF ( netcdf_data_format == 5 ) netcdf_data_format = 3
2542          IF ( netcdf_data_format == 6 ) netcdf_data_format = 4
2543          message_string = 'netCDF file formats '// '5 (parallel netCDF 4) and 6 (parallel ' //    &
2544                           'netCDF 4 Classic model) & are currently not supported (not yet ' //    &
2545                           'tested) for masked data. &Using respective non-parallel' //            &
2546                           ' output for masked data.'
2547          CALL message( 'check_parameters', 'PA0383', 0, 0, 0, 6, 0 )
2548       ENDIF
2549       CALL init_masks
2550       netcdf_data_format = netcdf_data_format_save
2551    ENDIF
2552
2553!
2554!-- Check the NetCDF data format
2555    IF ( netcdf_data_format > 2 )  THEN
2556#if defined( __netcdf4 )
2557       CONTINUE
2558#else
2559       message_string = 'netCDF: netCDF4 format requested but no ' //                              &
2560                        'cpp-directive __netcdf4 given & switch back to 64-bit offset format'
2561       CALL message( 'check_parameters', 'PA0171', 0, 1, 0, 6, 0 )
2562       netcdf_data_format = 2
2563#endif
2564    ENDIF
2565    IF ( netcdf_data_format > 4 )  THEN
2566#if defined( __netcdf4 ) && defined( __netcdf4_parallel )
2567       CONTINUE
2568#else
2569       message_string = 'netCDF: netCDF4 parallel output requested but no ' //                     &
2570                        'cpp-directive __netcdf4_parallel given & switch ' //                      &
2571                        'back to netCDF4 non-parallel output'
2572       CALL message( 'check_parameters', 'PA0099', 0, 1, 0, 6, 0 )
2573       netcdf_data_format = netcdf_data_format - 2
2574#endif
2575    ENDIF
2576
2577!
2578!-- Calculate fixed number of output time levels for parallel netcdf output.
2579!-- The time dimension has to be defined as limited for parallel output, because otherwise the I/O
2580!-- performance drops significantly.
2581    IF ( netcdf_data_format > 4 )  THEN
2582
2583!
2584!--    Check if any of the follwoing data output interval is 0.0s, which is not allowed for parallel
2585!--    output.
2586       CALL check_dt_do( dt_do3d,           'dt_do3d'           )
2587       CALL check_dt_do( dt_do2d_xy,        'dt_do2d_xy'        )
2588       CALL check_dt_do( dt_do2d_xz,        'dt_do2d_xz'        )
2589       CALL check_dt_do( dt_do2d_yz,        'dt_do2d_yz'        )
2590       CALL check_dt_do( dt_data_output_av, 'dt_data_output_av' )
2591
2592!--    Set needed time levels (ntdim) to saved time levels + to be saved time levels.
2593       ntdim_3d(0) = do3d_time_count(0) + CEILING(                                                 &
2594                     ( end_time - MAX(                                                             &
2595                         MERGE( skip_time_do3d, skip_time_do3d + spinup_time,                      &
2596                                data_output_during_spinup ),                                       &
2597                         simulated_time_at_begin )                                                 &
2598                     ) / dt_do3d )
2599       IF ( do3d_at_begin ) ntdim_3d(0) = ntdim_3d(0) + 1
2600
2601       ntdim_3d(1) = do3d_time_count(1) + CEILING(                                                 &
2602                     ( end_time - MAX(                                                             &
2603                         MERGE( skip_time_data_output_av, skip_time_data_output_av + spinup_time,  &
2604                                data_output_during_spinup ),                                       &
2605                         simulated_time_at_begin )                                                 &
2606                     ) / dt_data_output_av )
2607
2608       ntdim_2d_xy(0) = do2d_xy_time_count(0) + CEILING(                                           &
2609                        ( end_time - MAX(                                                          &
2610                            MERGE( skip_time_do2d_xy, skip_time_do2d_xy + spinup_time,             &
2611                                   data_output_during_spinup ),                                    &
2612                            simulated_time_at_begin )                                              &
2613                        ) / dt_do2d_xy )
2614
2615       ntdim_2d_xz(0) = do2d_xz_time_count(0) + CEILING(                                           &
2616                        ( end_time - MAX(                                                          &
2617                            MERGE( skip_time_do2d_xz, skip_time_do2d_xz + spinup_time,             &
2618                                   data_output_during_spinup ),                                    &
2619                            simulated_time_at_begin )                                              &
2620                        ) / dt_do2d_xz )
2621
2622       ntdim_2d_yz(0) = do2d_yz_time_count(0) + CEILING(                                           &
2623                        ( end_time - MAX(                                                          &
2624                            MERGE( skip_time_do2d_yz, skip_time_do2d_yz + spinup_time,             &
2625                                   data_output_during_spinup ),                                    &
2626                            simulated_time_at_begin )                                              &
2627                        ) / dt_do2d_yz )
2628
2629       IF ( do2d_at_begin )  THEN
2630          ntdim_2d_xy(0) = ntdim_2d_xy(0) + 1
2631          ntdim_2d_xz(0) = ntdim_2d_xz(0) + 1
2632          ntdim_2d_yz(0) = ntdim_2d_yz(0) + 1
2633       ENDIF
2634!
2635!--    Please note, for averaged 2D data skip_time_data_output_av is the relavant output control
2636!--    parameter.
2637       ntdim_2d_xy(1) = do2d_xy_time_count(1) + CEILING(                                           &
2638                        ( end_time - MAX( MERGE( skip_time_data_output_av,                         &
2639                                                 skip_time_data_output_av + spinup_time,           &
2640                                                 data_output_during_spinup ),                      &
2641                                          simulated_time_at_begin )                                &
2642                        ) / dt_data_output_av )
2643
2644       ntdim_2d_xz(1) = do2d_xz_time_count(1) + CEILING(                                           &
2645                        ( end_time - MAX( MERGE( skip_time_data_output_av,                         &
2646                                                 skip_time_data_output_av + spinup_time,           &
2647                                                 data_output_during_spinup ),                      &
2648                                          simulated_time_at_begin )                                &
2649                        ) / dt_data_output_av )
2650
2651       ntdim_2d_yz(1) = do2d_yz_time_count(1) + CEILING(                                           &
2652                        ( end_time - MAX( MERGE( skip_time_data_output_av,                         &
2653                                                 skip_time_data_output_av + spinup_time,           &
2654                                                 data_output_during_spinup ),                      &
2655                                          simulated_time_at_begin )                                &
2656                        ) / dt_data_output_av )
2657
2658    ENDIF
2659
2660!
2661!-- Check, whether a constant diffusion coefficient shall be used
2662    IF ( km_constant /= -1.0_wp )  THEN
2663       IF ( km_constant < 0.0_wp )  THEN
2664          WRITE( message_string, * )  'km_constant = ', km_constant, ' < 0.0'
2665          CALL message( 'check_parameters', 'PA0121', 1, 2, 0, 6, 0 )
2666       ELSE
2667          IF ( prandtl_number < 0.0_wp )  THEN
2668             WRITE( message_string, * )  'prandtl_number = ', prandtl_number, ' < 0.0'
2669             CALL message( 'check_parameters', 'PA0122', 1, 2, 0, 6, 0 )
2670          ENDIF
2671          constant_diffusion = .TRUE.
2672
2673          IF ( constant_flux_layer )  THEN
2674             message_string = 'constant_flux_layer is not allowed with fixed value of km'
2675             CALL message( 'check_parameters', 'PA0123', 1, 2, 0, 6, 0 )
2676          ENDIF
2677       ENDIF
2678    ENDIF
2679
2680!
2681!-- In case of non-cyclic lateral boundaries and a damping layer for the potential temperature,
2682!-- check the width of the damping layer
2683    IF ( bc_lr /= 'cyclic' ) THEN
2684       IF ( pt_damping_width < 0.0_wp  .OR.  pt_damping_width > REAL( (nx+1) * dx ) )  THEN
2685          message_string = 'pt_damping_width out of range'
2686          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
2687       ENDIF
2688    ENDIF
2689
2690    IF ( bc_ns /= 'cyclic' )  THEN
2691       IF ( pt_damping_width < 0.0_wp  .OR.  pt_damping_width > REAL( (ny+1) * dy ) )  THEN
2692          message_string = 'pt_damping_width out of range'
2693          CALL message( 'check_parameters', 'PA0124', 1, 2, 0, 6, 0 )
2694       ENDIF
2695    ENDIF
2696
2697!
2698!-- Check value range for zeta = z/L
2699    IF ( zeta_min >= zeta_max )  THEN
2700       WRITE( message_string, * )  'zeta_min = ', zeta_min, ' must be less ', 'than zeta_max = ',  &
2701              zeta_max
2702       CALL message( 'check_parameters', 'PA0125', 1, 2, 0, 6, 0 )
2703    ENDIF
2704
2705!
2706!-- Check random generator
2707    IF ( (random_generator /= 'system-specific'      .AND.                                         &
2708          random_generator /= 'random-parallel'   )  .AND.                                         &
2709          random_generator /= 'numerical-recipes' )  THEN
2710       message_string = 'unknown random generator: random_generator = "' //                        &
2711                        TRIM( random_generator ) // '"'
2712       CALL message( 'check_parameters', 'PA0135', 1, 2, 0, 6, 0 )
2713    ENDIF
2714
2715!
2716!-- Determine upper and lower hight level indices for random perturbations
2717    IF ( disturbance_level_b == -9999999.9_wp )  THEN
2718       IF ( ocean_mode )  THEN
2719          disturbance_level_b     = zu((nzt*2)/3)
2720          disturbance_level_ind_b = ( nzt * 2 ) / 3
2721       ELSE
2722          disturbance_level_b     = zu(nzb+3)
2723          disturbance_level_ind_b = nzb + 3
2724       ENDIF
2725    ELSEIF ( disturbance_level_b < zu(3) )  THEN
2726       WRITE( message_string, * )  'disturbance_level_b = ', disturbance_level_b, ' must be >= ',  &
2727              zu(3), '(zu(3))'
2728       CALL message( 'check_parameters', 'PA0126', 1, 2, 0, 6, 0 )
2729    ELSEIF ( disturbance_level_b > zu(nzt-2) )  THEN
2730       WRITE( message_string, * )  'disturbance_level_b = ', disturbance_level_b, ' must be <= ',  &
2731              zu(nzt-2), '(zu(nzt-2))'
2732       CALL message( 'check_parameters', 'PA0127', 1, 2, 0, 6, 0 )
2733    ELSE
2734       DO  k = 3, nzt-2
2735          IF ( disturbance_level_b <= zu(k) )  THEN
2736             disturbance_level_ind_b = k
2737             EXIT
2738          ENDIF
2739       ENDDO
2740    ENDIF
2741
2742    IF ( disturbance_level_t == -9999999.9_wp )  THEN
2743       IF ( ocean_mode )  THEN
2744          disturbance_level_t     = zu(nzt-3)
2745          disturbance_level_ind_t = nzt - 3
2746       ELSE
2747          disturbance_level_t     = zu(nzt/3)
2748          disturbance_level_ind_t = nzt / 3
2749       ENDIF
2750    ELSEIF ( disturbance_level_t > zu(nzt-2) )  THEN
2751       WRITE( message_string, * )  'disturbance_level_t = ', disturbance_level_t, ' must be <= ',  &
2752              zu(nzt-2), '(zu(nzt-2))'
2753       CALL message( 'check_parameters', 'PA0128', 1, 2, 0, 6, 0 )
2754    ELSEIF ( disturbance_level_t < disturbance_level_b )  THEN
2755       WRITE( message_string, * )  'disturbance_level_t = ', disturbance_level_t,                  &
2756             ' must be >= disturbance_level_b = ', disturbance_level_b
2757       CALL message( 'check_parameters', 'PA0129', 1, 2, 0, 6, 0 )
2758    ELSE
2759       DO  k = 3, nzt-2
2760          IF ( disturbance_level_t <= zu(k) )  THEN
2761             disturbance_level_ind_t = k
2762             EXIT
2763          ENDIF
2764       ENDDO
2765    ENDIF
2766
2767!
2768!-- Check again whether the levels determined this way are ok.
2769!-- Error may occur at automatic determination and too few grid points in z-direction.
2770    IF ( disturbance_level_ind_t < disturbance_level_ind_b )  THEN
2771       WRITE( message_string, * )  'disturbance_level_ind_t = ', disturbance_level_ind_t,          &
2772              ' must be >= ', 'disturbance_level_ind_b = ', disturbance_level_ind_b
2773       CALL message( 'check_parameters', 'PA0130', 1, 2, 0, 6, 0 )
2774    ENDIF
2775
2776!
2777!-- Determine the horizontal index range for random perturbations.
2778!-- In case of non-cyclic horizontal boundaries, no perturbations are imposed near the inflow and
2779!-- the perturbation area is further limited to ...(1) after the initial phase of the flow.
2780
2781    IF ( bc_lr /= 'cyclic' )  THEN
2782       IF ( inflow_disturbance_begin == -1 )  THEN
2783          inflow_disturbance_begin = MIN( 10, nx/2 )
2784       ENDIF
2785       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > nx )  THEN
2786          message_string = 'inflow_disturbance_begin out of range'
2787          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
2788       ENDIF
2789       IF ( inflow_disturbance_end == -1 )  THEN
2790          inflow_disturbance_end = MIN( 100, 3*nx/4 )
2791       ENDIF
2792       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > nx )  THEN
2793          message_string = 'inflow_disturbance_end out of range'
2794          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
2795       ENDIF
2796    ELSEIF ( bc_ns /= 'cyclic' )  THEN
2797       IF ( inflow_disturbance_begin == -1 )  THEN
2798          inflow_disturbance_begin = MIN( 10, ny/2 )
2799       ENDIF
2800       IF ( inflow_disturbance_begin < 0  .OR.  inflow_disturbance_begin > ny )  THEN
2801          message_string = 'inflow_disturbance_begin out of range'
2802          CALL message( 'check_parameters', 'PA0131', 1, 2, 0, 6, 0 )
2803       ENDIF
2804       IF ( inflow_disturbance_end == -1 )  THEN
2805          inflow_disturbance_end = MIN( 100, 3*ny/4 )
2806       ENDIF
2807       IF ( inflow_disturbance_end < 0  .OR.  inflow_disturbance_end > ny )  THEN
2808          message_string = 'inflow_disturbance_end out of range'
2809          CALL message( 'check_parameters', 'PA0132', 1, 2, 0, 6, 0 )
2810       ENDIF
2811    ENDIF
2812
2813    IF ( random_generator == 'random-parallel' )  THEN
2814       dist_nxl = nxl;  dist_nxr = nxr
2815       dist_nys = nys;  dist_nyn = nyn
2816       IF ( bc_lr == 'radiation/dirichlet' )  THEN
2817          dist_nxr    = MIN( nx - inflow_disturbance_begin, nxr )
2818          dist_nxl(1) = MAX( nx - inflow_disturbance_end, nxl )
2819       ELSEIF ( bc_lr == 'dirichlet/radiation' )  THEN
2820          dist_nxl    = MAX( inflow_disturbance_begin, nxl )
2821          dist_nxr(1) = MIN( inflow_disturbance_end, nxr )
2822       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
2823          dist_nxl    = MAX( inflow_disturbance_begin, nxl )
2824          dist_nxr    = MIN( nx - inflow_disturbance_begin, nxr )
2825       ENDIF
2826       IF ( bc_ns == 'dirichlet/radiation' )  THEN
2827          dist_nyn    = MIN( ny - inflow_disturbance_begin, nyn )
2828          dist_nys(1) = MAX( ny - inflow_disturbance_end, nys )
2829       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
2830          dist_nys    = MAX( inflow_disturbance_begin, nys )
2831          dist_nyn(1) = MIN( inflow_disturbance_end, nyn )
2832       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
2833          dist_nys    = MAX( inflow_disturbance_begin, nys )
2834          dist_nyn    = MIN( ny - inflow_disturbance_begin, nyn )
2835       ENDIF
2836    ELSE
2837       dist_nxl = 0;  dist_nxr = nx
2838       dist_nys = 0;  dist_nyn = ny
2839       IF ( bc_lr == 'radiation/dirichlet' )  THEN
2840          dist_nxr    = nx - inflow_disturbance_begin
2841          dist_nxl(1) = nx - inflow_disturbance_end
2842       ELSEIF ( bc_lr == 'dirichlet/radiation' )  THEN
2843          dist_nxl    = inflow_disturbance_begin
2844          dist_nxr(1) = inflow_disturbance_end
2845       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
2846          dist_nxr    = nx - inflow_disturbance_begin
2847          dist_nxl    = inflow_disturbance_begin
2848       ENDIF
2849       IF ( bc_ns == 'dirichlet/radiation' )  THEN
2850          dist_nyn    = ny - inflow_disturbance_begin
2851          dist_nys(1) = ny - inflow_disturbance_end
2852       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
2853          dist_nys    = inflow_disturbance_begin
2854          dist_nyn(1) = inflow_disturbance_end
2855       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
2856          dist_nyn    = ny - inflow_disturbance_begin
2857          dist_nys    = inflow_disturbance_begin
2858       ENDIF
2859    ENDIF
2860
2861!
2862!-- A turbulent inflow requires Dirichlet conditions at the respective inflow boundary (so far, a
2863!-- turbulent inflow is realized from the left side only).
2864    IF ( turbulent_inflow  .AND.  bc_lr /= 'dirichlet/radiation' )  THEN
2865       message_string = 'turbulent_inflow = .T. requires a Dirichlet ' //                          &
2866                        'condition at the inflow boundary'
2867       CALL message( 'check_parameters', 'PA0133', 1, 2, 0, 6, 0 )
2868    ENDIF
2869
2870!
2871!-- Turbulent inflow requires that 3d arrays have been cyclically filled with data from prerun in
2872!-- the first main run
2873    IF ( turbulent_inflow  .AND.  initializing_actions /= 'cyclic_fill'  .AND.                     &
2874         initializing_actions /= 'read_restart_data' )  THEN
2875       message_string = 'turbulent_inflow = .T. requires ' //                                      &
2876                        'initializing_actions = ''cyclic_fill'' or ' //                            &
2877                        'initializing_actions = ''read_restart_data'' '
2878       CALL message( 'check_parameters', 'PA0055', 1, 2, 0, 6, 0 )
2879    ENDIF
2880
2881!
2882!-- In case of turbulent inflow
2883    IF ( turbulent_inflow )  THEN
2884
2885!
2886!--    Calculate the index of the recycling plane
2887       IF ( recycling_width <= dx  .OR.  recycling_width >= nx * dx )  THEN
2888          WRITE( message_string, * )  'illegal value for recycling_width: ', recycling_width
2889          CALL message( 'check_parameters', 'PA0134', 1, 2, 0, 6, 0 )
2890       ENDIF
2891!
2892!--    Calculate the index
2893       recycling_plane = recycling_width / dx
2894!
2895!--   Check for correct input of recycling method for thermodynamic quantities
2896       IF ( TRIM( recycling_method_for_thermodynamic_quantities ) /= 'turbulent_fluctuation'  .AND.&
2897            TRIM( recycling_method_for_thermodynamic_quantities ) /= 'absolute_value' )  THEN
2898          WRITE( message_string, * )  'unknown recycling method for thermodynamic quantities: ',   &
2899               TRIM( recycling_method_for_thermodynamic_quantities )
2900          CALL message( 'check_parameters', 'PA0184', 1, 2, 0, 6, 0 )
2901       ENDIF
2902
2903    ENDIF
2904
2905
2906    IF ( turbulent_outflow )  THEN
2907!
2908!--    Turbulent outflow requires Dirichlet conditions at the respective inflow boundary (so far, a
2909!--    turbulent outflow is realized at the right side only).
2910       IF ( bc_lr /= 'dirichlet/radiation' )  THEN
2911          message_string = 'turbulent_outflow = .T. requires bc_lr = "dirichlet/radiation"'
2912          CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
2913       ENDIF
2914!
2915!--    The ouflow-source plane must lay inside the model domain
2916       IF ( outflow_source_plane < dx  .OR.  outflow_source_plane > nx * dx )  THEN
2917          WRITE( message_string, * )  'illegal value for outflow_source'// '_plane: ',             &
2918                 outflow_source_plane
2919          CALL message( 'check_parameters', 'PA0145', 1, 2, 0, 6, 0 )
2920       ENDIF
2921    ENDIF
2922
2923!
2924!-- Determine damping level index for 1D model
2925    IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
2926       IF ( damp_level_1d == -1.0_wp )  THEN
2927          damp_level_1d     = zu(nzt+1)
2928          damp_level_ind_1d = nzt + 1
2929       ELSEIF ( damp_level_1d < 0.0_wp  .OR.  damp_level_1d > zu(nzt+1) )  THEN
2930          WRITE( message_string, * )  'damp_level_1d = ', damp_level_1d, ' must be >= 0.0 and <= ',&
2931                 zu(nzt+1), '(zu(nzt+1))'
2932          CALL message( 'check_parameters', 'PA0136', 1, 2, 0, 6, 0 )
2933       ELSE
2934          DO  k = 1, nzt+1
2935             IF ( damp_level_1d <= zu(k) )  THEN
2936                damp_level_ind_1d = k
2937                EXIT
2938             ENDIF
2939          ENDDO
2940       ENDIF
2941    ENDIF
2942
2943!
2944!-- Check some other 1d-model parameters
2945    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND.                                       &
2946         TRIM( mixing_length_1d ) /= 'blackadar' )  THEN
2947       message_string = 'mixing_length_1d = "' // TRIM( mixing_length_1d ) // '" is unknown'
2948       CALL message( 'check_parameters', 'PA0137', 1, 2, 0, 6, 0 )
2949    ENDIF
2950    IF ( TRIM( dissipation_1d ) /= 'as_in_3d_model'  .AND.                                         &
2951         TRIM( dissipation_1d ) /= 'detering'        .AND.                                         &
2952         TRIM( dissipation_1d ) /= 'prognostic' )  THEN
2953       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) // '" is unknown'
2954       CALL message( 'check_parameters', 'PA0138', 1, 2, 0, 6, 0 )
2955    ENDIF
2956    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND.                                       &
2957         TRIM( dissipation_1d ) == 'as_in_3d_model' )  THEN
2958       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) //                          &
2959                        '" requires mixing_length_1d = "as_in_3d_model"'
2960       CALL message( 'check_parameters', 'PA0485', 1, 2, 0, 6, 0 )
2961    ENDIF
2962
2963!
2964!-- Set time for the next user defined restart (time_restart is the internal parameter for steering
2965!-- restart events)
2966    IF ( restart_time /= 9999999.9_wp )  THEN
2967       IF ( restart_time > time_since_reference_point )  THEN
2968          time_restart = restart_time
2969       ENDIF
2970    ELSE
2971!
2972!--    In case of a restart run, set internal parameter to default (no restart) if the
2973!--    NAMELIST-parameter restart_time is omitted
2974       time_restart = 9999999.9_wp
2975    ENDIF
2976
2977!
2978!-- Check pressure gradient conditions
2979    IF ( dp_external  .AND.  conserve_volume_flow )  THEN
2980       WRITE( message_string, * )  'Both dp_external and conserve_volume_flo',                     &
2981              'w are .TRUE. but one of them must be .FALSE.'
2982       CALL message( 'check_parameters', 'PA0150', 1, 2, 0, 6, 0 )
2983    ENDIF
2984    IF ( dp_external )  THEN
2985       IF ( dp_level_b < zu(nzb)  .OR.  dp_level_b > zu(nzt) )  THEN
2986          WRITE( message_string, * )  'dp_level_b = ', dp_level_b, ' is out ',                     &
2987                 ' of range [zu(nzb), zu(nzt)]'
2988          CALL message( 'check_parameters', 'PA0151', 1, 2, 0, 6, 0 )
2989       ENDIF
2990       IF ( .NOT. ANY( dpdxy /= 0.0_wp ) )  THEN
2991          WRITE( message_string, * )  'dp_external is .TRUE. but dpdxy is ze',                     &
2992                 'ro, i.e. the external pressure gradient will not be applied'
2993          CALL message( 'check_parameters', 'PA0152', 0, 1, 0, 6, 0 )
2994       ENDIF
2995    ENDIF
2996    IF ( ANY( dpdxy /= 0.0_wp )  .AND.  .NOT.  dp_external )  THEN
2997       WRITE( message_string, * )  'dpdxy is nonzero but dp_external is ',                         &
2998              '.FALSE., i.e. the external pressure gradient & will not be applied'
2999       CALL message( 'check_parameters', 'PA0153', 0, 1, 0, 6, 0 )
3000    ENDIF
3001    IF ( conserve_volume_flow )  THEN
3002       IF ( TRIM( conserve_volume_flow_mode ) == 'default' )  THEN
3003
3004          conserve_volume_flow_mode = 'initial_profiles'
3005
3006       ELSEIF ( TRIM( conserve_volume_flow_mode ) /= 'initial_profiles'  .AND.                     &
3007                TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' )  THEN
3008          WRITE( message_string, * )  'unknown conserve_volume_flow_mode: ',                       &
3009                 conserve_volume_flow_mode
3010          CALL message( 'check_parameters', 'PA0154', 1, 2, 0, 6, 0 )
3011       ENDIF
3012       IF ( ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic')  .AND.                                   &
3013            TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
3014          WRITE( message_string, * )  'non-cyclic boundary conditions ',                           &
3015                 'require  conserve_volume_flow_mode = ''initial_profiles'''
3016          CALL message( 'check_parameters', 'PA0155', 1, 2, 0, 6, 0 )
3017       ENDIF
3018    ENDIF
3019    IF ( ( u_bulk /= 0.0_wp .OR. v_bulk /= 0.0_wp )  .AND.                                         &
3020         ( .NOT. conserve_volume_flow .OR. TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' ) )&
3021    THEN
3022       WRITE( message_string, * )  'nonzero bulk velocity requires ',                              &
3023              'conserve_volume_flow = .T. and ', 'conserve_volume_flow_mode = ''bulk_velocity'''
3024       CALL message( 'check_parameters', 'PA0157', 1, 2, 0, 6, 0 )
3025    ENDIF
3026
3027!
3028!-- Prevent empty time records in volume, cross-section and masked data in case of non-parallel
3029!-- netcdf-output in restart runs
3030    IF ( netcdf_data_format < 5 )  THEN
3031       IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
3032          do3d_time_count    = 0
3033          do2d_xy_time_count = 0
3034          do2d_xz_time_count = 0
3035          do2d_yz_time_count = 0
3036          domask_time_count  = 0
3037       ENDIF
3038    ENDIF
3039
3040
3041!
3042!-- Check roughness length, which has to be smaller than dz/2
3043    IF ( ( constant_flux_layer .OR. INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  &
3044         .AND.  roughness_length >= 0.5 * dz(1) )  THEN
3045       message_string = 'roughness_length must be smaller than dz/2'
3046       CALL message( 'check_parameters', 'PA0424', 1, 2, 0, 6, 0 )
3047    ENDIF
3048
3049!
3050!-- Check if topography is read from file in case of complex terrain simulations
3051    IF ( complex_terrain  .AND.  TRIM( topography ) /= 'read_from_file' )  THEN
3052       message_string = 'complex_terrain requires topography = ''read_from_file'''
3053       CALL message( 'check_parameters', 'PA0295', 1, 2, 0, 6, 0 )
3054    ENDIF
3055
3056!
3057!-- Check if vertical grid stretching is switched off in case of complex terrain simulations
3058    IF ( complex_terrain  .AND.  ANY( dz_stretch_level_start /= -9999999.9_wp ) )  THEN
3059       message_string = 'Vertical grid stretching is not allowed for complex_terrain = .TRUE.'
3060       CALL message( 'check_parameters', 'PA0473', 1, 2, 0, 6, 0 )
3061    ENDIF
3062
3063    CALL location_message( 'checking parameters', 'finished' )
3064
3065 CONTAINS
3066
3067!--------------------------------------------------------------------------------------------------!
3068! Description:
3069! ------------
3070!> Check the length of data output intervals. In case of parallel NetCDF output the time levels of
3071!> the output files need to be fixed. Therefore setting the output interval to 0.0s (usually used to
3072!> output each timestep) is not possible as long as a non-fixed timestep is used.
3073!--------------------------------------------------------------------------------------------------!
3074
3075    SUBROUTINE check_dt_do( dt_do, dt_do_name )
3076
3077       IMPLICIT NONE
3078
3079       CHARACTER (LEN=*), INTENT (IN) :: dt_do_name !< parin variable name
3080
3081       REAL(wp), INTENT (INOUT)       :: dt_do      !< data output interval
3082
3083       IF ( dt_do == 0.0_wp )  THEN
3084          IF ( dt_fixed )  THEN
3085             WRITE( message_string, '(A,F9.4,A)' )  'Output at every timestep is wanted (' //      &
3086                    dt_do_name // ' = 0.0).&'//                                                    &
3087                    'The output interval is set to the fixed timestep dt '// '= ', dt, 's.'
3088             CALL message( 'check_parameters', 'PA0060', 0, 0, 0, 6, 0 )
3089             dt_do = dt
3090          ELSE
3091             message_string = dt_do_name // ' = 0.0 while using a ' //                             &
3092                              'variable timestep and parallel netCDF4 is not allowed.'
3093             CALL message( 'check_parameters', 'PA0081', 1, 2, 0, 6, 0 )
3094          ENDIF
3095       ENDIF
3096
3097    END SUBROUTINE check_dt_do
3098
3099
3100
3101!--------------------------------------------------------------------------------------------------!
3102! Description:
3103! ------------
3104!> Set the bottom and top boundary conditions for humidity and scalars.
3105!--------------------------------------------------------------------------------------------------!
3106
3107    SUBROUTINE set_bc_scalars( sq, bc_b, bc_t, ibc_b, ibc_t, err_nr_b, err_nr_t )
3108
3109
3110       IMPLICIT NONE
3111
3112       CHARACTER (LEN=*)   ::  bc_b       !< bottom boundary condition
3113       CHARACTER (LEN=*)   ::  bc_t       !< top boundary condition
3114       CHARACTER (LEN=*)   ::  err_nr_b   !< error number if bottom bc is unknown
3115       CHARACTER (LEN=*)   ::  err_nr_t   !< error number if top bc is unknown
3116       CHARACTER (LEN=1)   ::  sq         !< name of scalar quantity
3117
3118
3119       INTEGER(iwp)        ::  ibc_b      !< index for bottom boundary condition
3120       INTEGER(iwp)        ::  ibc_t      !< index for top boundary condition
3121
3122!
3123!--    Set Integer flags and check for possilbe errorneous settings for bottom boundary condition
3124       IF ( bc_b == 'dirichlet' )  THEN
3125          ibc_b = 0
3126       ELSEIF ( bc_b == 'neumann' )  THEN
3127          ibc_b = 1
3128       ELSE
3129          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // '_b ="' //           &
3130                           TRIM( bc_b ) // '"'
3131          CALL message( 'check_parameters', err_nr_b, 1, 2, 0, 6, 0 )
3132       ENDIF
3133!
3134!--    Set Integer flags and check for possilbe errorneous settings for top boundary condition
3135       IF ( bc_t == 'dirichlet' )  THEN
3136          ibc_t = 0
3137       ELSEIF ( bc_t == 'neumann' )  THEN
3138          ibc_t = 1
3139       ELSEIF ( bc_t == 'initial_gradient' )  THEN
3140          ibc_t = 2
3141       ELSEIF ( bc_t == 'nested'  .OR.  bc_t == 'nesting_offline' )  THEN
3142          ibc_t = 3
3143       ELSE
3144          message_string = 'unknown boundary condition: bc_' // TRIM( sq ) // '_t ="' //           &
3145                           TRIM( bc_t ) // '"'
3146          CALL message( 'check_parameters', err_nr_t, 1, 2, 0, 6, 0 )
3147       ENDIF
3148
3149
3150    END SUBROUTINE set_bc_scalars
3151
3152
3153
3154!--------------------------------------------------------------------------------------------------!
3155! Description:
3156! ------------
3157!> Check for consistent settings of bottom boundary conditions for humidity and scalars.
3158!--------------------------------------------------------------------------------------------------!
3159
3160    SUBROUTINE check_bc_scalars( sq, bc_b, ibc_b, err_nr_1, err_nr_2, constant_flux,               &
3161                                 surface_initial_change )
3162
3163
3164       IMPLICIT NONE
3165
3166       CHARACTER (LEN=*)   ::  bc_b                     !< bottom boundary condition
3167       CHARACTER (LEN=*)   ::  err_nr_1                 !< error number of first error
3168       CHARACTER (LEN=*)   ::  err_nr_2                 !< error number of second error
3169       CHARACTER (LEN=1)   ::  sq                       !< name of scalar quantity
3170
3171
3172       INTEGER(iwp)        ::  ibc_b                    !< index of bottom boundary condition
3173
3174       LOGICAL             ::  constant_flux            !< flag for constant-flux layer
3175
3176       REAL(wp)            ::  surface_initial_change   !< value of initial change at the surface
3177
3178!
3179!--    A given surface value implies Dirichlet boundary condition for the respective quantity. In
3180!--    this case specification of a constant flux is forbidden. However, an exception is made for
3181!--    large-scale forcing as well as land-surface model.
3182       IF ( .NOT. land_surface  .AND.  .NOT. large_scale_forcing )  THEN
3183          IF ( ibc_b == 0  .AND.  constant_flux )  THEN
3184             message_string = 'boundary condition: bc_' // TRIM( sq ) // '_b = "' //               &
3185                              TRIM( bc_b ) // '" is not allowed with prescribed surface flux'
3186             CALL message( 'check_parameters', err_nr_1, 1, 2, 0, 6, 0 )
3187          ENDIF
3188       ENDIF
3189       IF ( constant_flux  .AND.  surface_initial_change /= 0.0_wp )  THEN
3190          WRITE( message_string, * )  'a prescribed surface flux is not allo', 'wed with ', sq,    &
3191                '_surface_initial_change (/=0) = ', surface_initial_change
3192          CALL message( 'check_parameters', err_nr_2, 1, 2, 0, 6, 0 )
3193       ENDIF
3194
3195
3196    END SUBROUTINE check_bc_scalars
3197
3198
3199
3200 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.