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

Last change on this file since 1114 was 1112, checked in by raasch, 11 years ago

last commit documented

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