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

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

last commit documented

  • Property svn:keywords set to Id
File size: 142.6 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! -----------------
[1093]22!
[1054]23!
24! Former revisions:
25! -----------------
26! $Id: check_parameters.f90 1093 2013-02-02 12:58:49Z raasch $
27!
[1093]28! 1092 2013-02-02 11:24:22Z raasch
29! unused variables removed
30!
[1070]31! 1069 2012-11-28 16:18:43Z maronga
32! allow usage of topography in combination with cloud physics
33!
[1066]34! 1065 2012-11-22 17:42:36Z hoffmann
35! Bugfix: It is not allowed to use cloud_scheme = seifert_beheng without
36!         precipitation in order to save computational resources.
37!
[1061]38! 1060 2012-11-21 07:19:51Z raasch
39! additional check for parameter turbulent_inflow
40!
[1054]41! 1053 2012-11-13 17:11:03Z hoffmann
[1053]42! necessary changes for the new two-moment cloud physics scheme added:
43! - check cloud physics scheme (Kessler or Seifert and Beheng)
44! - plant_canopy is not allowed
45! - currently, only cache loop_optimization is allowed
46! - initial profiles of nr, qr
47! - boundary condition of nr, qr
48! - check output quantities (qr, nr, prr)
[979]49!
[1037]50! 1036 2012-10-22 13:43:42Z raasch
51! code put under GPL (PALM 3.9)
52!
[1035]53! 1031/1034 2012-10-22 11:32:49Z raasch
54! check of netcdf4 parallel file support
55!
[1020]56! 1019 2012-09-28 06:46:45Z raasch
57! non-optimized version of prognostic_equations not allowed any more
58!
[1017]59! 1015 2012-09-27 09:23:24Z raasch
60! acc allowed for loop optimization,
61! checks for adjustment of mixing length to the Prandtl mixing length removed
62!
[1004]63! 1003 2012-09-14 14:35:53Z raasch
64! checks for cases with unequal subdomain sizes removed
65!
[1002]66! 1001 2012-09-13 14:08:46Z raasch
67! all actions concerning leapfrog- and upstream-spline-scheme removed
68!
[997]69! 996 2012-09-07 10:41:47Z raasch
70! little reformatting
[1001]71
[979]72! 978 2012-08-09 08:28:32Z fricke
[978]73! setting of bc_lr/ns_dirneu/neudir
74! outflow damping layer removed
75! check for z0h*
76! check for pt_damping_width
[667]77!
[965]78! 964 2012-07-26 09:14:24Z raasch
79! check of old profil-parameters removed
80!
[941]81! 940 2012-07-09 14:31:00Z raasch
82! checks for parameter neutral
83!
[925]84! 924 2012-06-06 07:44:41Z maronga
85! Bugfix: preprocessor directives caused error during compilation
86!
[893]87! 892 2012-05-02 13:51:44Z maronga
88! Bugfix for parameter file check ( excluding __netcdf4 )
89!
[867]90! 866 2012-03-28 06:44:41Z raasch
91! use only 60% of the geostrophic wind as translation speed in case of Galilean
92! transformation and use_ug_for_galilei_tr = .T. in order to mimimize the
93! timestep
94!
[863]95! 861 2012-03-26 14:18:34Z suehring
96! Check for topography and ws-scheme removed.
97! Check for loop_optimization = 'vector' and ws-scheme removed.
98!
[846]99! 845 2012-03-07 10:23:05Z maronga
100! Bugfix: exclude __netcdf4 directive part from namelist file check compilation
101!
[829]102! 828 2012-02-21 12:00:36Z raasch
103! check of collision_kernel extended
104!
[826]105! 825 2012-02-19 03:03:44Z raasch
106! check for collision_kernel and curvature_solution_effects
107!
[810]108! 809 2012-01-30 13:32:58Z maronga
109! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
110!
[808]111! 807 2012-01-25 11:53:51Z maronga
112! New cpp directive "__check" implemented which is used by check_namelist_files
113!
[775]114! 774 2011-10-27 13:34:16Z letzel
115! bugfix for prescribed u,v-profiles
116!
[768]117! 767 2011-10-14 06:39:12Z raasch
118! Calculating u,v-profiles from given profiles by linear interpolation.
119! bugfix: dirichlet_0 conditions for ug/vg moved from init_3d_model to here
120!
[708]121! 707 2011-03-29 11:39:40Z raasch
122! setting of bc_lr/ns_dirrad/raddir
123!
124! 689 2011-02-20 19:31:12z gryschka
[690]125! Bugfix for some logical expressions
126! (syntax was not compatible with all compilers)
[687]127!
[690]128! 680 2011-02-04 23:16:06Z gryschka
[681]129! init_vortex is not allowed with volume_flow_control
[668]130!
[674]131! 673 2011-01-18 16:19:48Z suehring
132! Declaration of ws_scheme_sca and ws_scheme_mom added (moved from advec_ws).
133!
[668]134! 667 2010-12-23 12:06:00Z suehring/gryschka
[667]135! Exchange of parameters between ocean and atmosphere via PE0
136! Check for illegal combination of ws-scheme and timestep scheme.
137! Check for topography and ws-scheme.
138! Check for not cyclic boundary conditions in combination with ws-scheme and
139! loop_optimization = 'vector'.
140! Check for call_psolver_at_all_substeps and ws-scheme for momentum_advec.
141! Different processor/grid topology in atmosphere and ocean is now allowed!
142! Bugfixes in checking for conserve_volume_flow_mode
[601]143! 600 2010-11-24 16:10:51Z raasch
144! change due to new default value of surface_waterflux
[581]145! 580 2010-10-05 13:59:11Z heinze
[601]146! renaming of ws_vertical_gradient_level to subs_vertical_gradient_level
[581]147!
[568]148! 567 2010-10-01 10:46:30Z helmke
149! calculating masks changed
150!
[565]151! 564 2010-09-30 13:18:59Z helmke
152! palm message identifiers of masked output changed, 20 replaced by max_masks
153!
[554]154! 553 2010-09-01 14:09:06Z weinreis
155! masks is calculated and removed from inipar
[532]156!
157! 531 2010-04-21 06:47:21Z heinze
158! Bugfix: unit of hyp changed to dbar
[392]159!
[525]160! 524 2010-03-30 02:04:51Z raasch
161! Bugfix: "/" in netcdf profile variable names replaced by ":"
162!
[494]163! 493 2010-03-01 08:30:24Z raasch
164! netcdf_data_format is checked
165!
[449]166! 411 2009-12-11 14:15:58Z heinze
167! Enabled passive scalar/humidity wall fluxes for non-flat topography
168! Initialization of large scale vertical motion (subsidence/ascent)
169!
170! 410 2009-12-04 17:05:40Z letzel
171! masked data output
172!
[392]173! 388 2009-09-23 09:40:33Z raasch
[388]174! Check profiles fpr prho and hyp.
[376]175! Bugfix: output of averaged 2d/3d quantities requires that an avaraging
176! interval has been set, respective error message is included
[366]177! bc_lr_cyc and bc_ns_cyc are set,
[328]178! initializing_actions='read_data_for_recycling' renamed to 'cyclic_fill'
[308]179! Check for illegal entries in section_xy|xz|yz that exceed nz+1|ny+1|nx+1
[291]180! Coupling with independent precursor runs.
[264]181! Check particle_color, particle_dvrpsize, color_interval, dvrpsize_interval
[232]182! Bugfix: pressure included for profile output
[240]183! Check pressure gradient conditions
[256]184! topography_grid_convention moved from user_check_parameters
185! 'single_street_canyon'
[367]186! Added shf* and qsws* to the list of available output data
[226]187!
188! 222 2009-01-12 16:04:16Z letzel
[217]189! +user_check_parameters
[213]190! Output of messages replaced by message handling routine.
[206]191! Implementation of an MPI-1 coupling: replaced myid with target_id,
192! deleted __mpi2 directives
[222]193! Check that PALM is called with mrun -K parallel for coupling
[198]194!
195! 197 2008-09-16 15:29:03Z raasch
[177]196! Bug fix: Construction of vertical profiles when 10 gradients have been
[181]197! specified in the parameter list (ug, vg, pt, q, sa, lad)
198!   
199! Strict grid matching along z is not needed for mg-solver.
[153]200! Leaf area density (LAD) explicitly set to its surface value at k=0
[151]201! Case of reading data for recycling included in initializing_actions,
[197]202! check of turbulent_inflow and calculation of recycling_plane.
203! q*2 profile added
[139]204!
205! 138 2007-11-28 10:03:58Z letzel
[138]206! Plant canopy added
[132]207! Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
[116]208! Multigrid solver allows topography, checking of dt_sort_particles
[121]209! Bugfix: initializing u_init and v_init in case of ocean runs
[110]210!
211! 109 2007-08-28 15:26:47Z letzel
[102]212! Check coupling_mode and set default (obligatory) values (like boundary
[106]213! conditions for temperature and fluxes) in case of coupled runs.
214! +profiles for w*p* and w"e
[104]215! Bugfix: Error message concerning output of particle concentration (pc)
216! modified
[108]217! More checks and more default values for coupled runs
218! allow data_output_pr= q, wq, w"q", w*q* for humidity = .T. (instead of
219! cloud_physics = .T.)
220! Rayleigh damping for ocean fixed.
[109]221! Check and, if necessary, set default value for dt_coupling
[98]222!
223! 97 2007-06-21 08:23:15Z raasch
[97]224! Initial salinity profile is calculated, salinity boundary conditions are
225! checked,
[94]226! z_max_do1d is checked only in case of ocean = .f.,
[97]227! +initial temperature and geostrophic velocity profiles for the ocean version,
228! use_pt_reference renamed use_reference
[77]229!
[90]230! 89 2007-05-25 12:08:31Z raasch
231! Check for user-defined profiles
232!
[77]233! 75 2007-03-22 09:54:05Z raasch
[51]234! "by_user" allowed as initializing action, -data_output_ts,
[63]235! leapfrog with non-flat topography not allowed any more, loop_optimization
[75]236! and pt_reference are checked, moisture renamed humidity,
[72]237! output of precipitation amount/rate and roughnes length + check
[73]238! possible negative humidities are avoided in initial profile,
[75]239! dirichlet/neumann changed to dirichlet/radiation, etc.,
240! revision added to run_description_header
[1]241!
[39]242! 20 2007-02-26 00:12:32Z raasch
243! Temperature and humidity gradients at top are now calculated for nzt+1,
244! top_heatflux and respective boundary condition bc_pt_t is checked
245!
[3]246! RCS Log replace by Id keyword, revision history cleaned up
247!
[1]248! Revision 1.61  2006/08/04 14:20:25  raasch
249! do2d_unit and do3d_unit now defined as 2d-arrays, check of
250! use_upstream_for_tke, default value for dt_dopts,
251! generation of file header moved from routines palm and header to here
252!
253! Revision 1.1  1997/08/26 06:29:23  raasch
254! Initial revision
255!
256!
257! Description:
258! ------------
259! Check control parameters and deduce further quantities.
260!------------------------------------------------------------------------------!
261
262    USE arrays_3d
[824]263    USE cloud_parameters
[1]264    USE constants
265    USE control_parameters
[264]266    USE dvrp_variables
[1]267    USE grid_variables
268    USE indices
269    USE model_1d
270    USE netcdf_control
271    USE particle_attributes
272    USE pegrid
273    USE profil_parameter
[411]274    USE subsidence_mod
[1]275    USE statistics
276    USE transpose_indices
277
278    IMPLICIT NONE
279
280    CHARACTER (LEN=1)   ::  sq
281    CHARACTER (LEN=6)   ::  var
282    CHARACTER (LEN=7)   ::  unit
283    CHARACTER (LEN=8)   ::  date
284    CHARACTER (LEN=10)  ::  time
[102]285    CHARACTER (LEN=40)  ::  coupling_string
[1]286    CHARACTER (LEN=100) ::  action
287
[1092]288    INTEGER ::  i, ilen, iremote = 0, j, k, kk, position, prec
[1]289    LOGICAL ::  found, ldum
[1092]290    REAL    ::  gradient, remote = 0.0, simulation_time_since_reference
[1]291
292!
293!-- Warning, if host is not set
294    IF ( host(1:1) == ' ' )  THEN
[213]295       message_string = '"host" is not set. Please check that environment ' // &
296                        'variable "localhost" & is set before running PALM'
[226]297       CALL message( 'check_parameters', 'PA0001', 0, 0, 0, 6, 0 )
[1]298    ENDIF
299
300!
[102]301!-- Check the coupling mode
302    IF ( coupling_mode /= 'uncoupled'            .AND.  &
303         coupling_mode /= 'atmosphere_to_ocean'  .AND.  &
304         coupling_mode /= 'ocean_to_atmosphere' )  THEN
[213]305       message_string = 'illegal coupling mode: ' // TRIM( coupling_mode )
[226]306       CALL message( 'check_parameters', 'PA0002', 1, 2, 0, 6, 0 )
[102]307    ENDIF
308
309!
[108]310!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
[667]311    IF ( coupling_mode /= 'uncoupled')  THEN
[213]312
[108]313       IF ( dt_coupling == 9999999.9 )  THEN
[213]314          message_string = 'dt_coupling is not set but required for coup' // &
315                           'ling mode "' //  TRIM( coupling_mode ) // '"'
[226]316          CALL message( 'check_parameters', 'PA0003', 1, 2, 0, 6, 0 )
[108]317       ENDIF
[213]318
[206]319#if defined( __parallel )
[807]320
321!
322!--    NOTE: coupled runs have not been implemented in the check_namelist_files
323!--    program.
324!--    check_namelist_files will need the following information of the other
325!--    model (atmosphere/ocean).
[845]326!       dt_coupling = remote
327!       dt_max = remote
328!       restart_time = remote
329!       dt_restart= remote
330!       simulation_time_since_reference = remote
331!       dx = remote
[807]332
333
[809]334#if ! defined( __check )
[667]335       IF ( myid == 0 ) THEN
336          CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, &
337                         ierr )
338          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 11, comm_inter, &
339                         status, ierr )
340       ENDIF
341       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]342#endif     
[108]343       IF ( dt_coupling /= remote )  THEN
[213]344          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
345                 '": dt_coupling = ', dt_coupling, '& is not equal to ',       &
346                 'dt_coupling_remote = ', remote
[226]347          CALL message( 'check_parameters', 'PA0004', 1, 2, 0, 6, 0 )
[108]348       ENDIF
[109]349       IF ( dt_coupling <= 0.0 )  THEN
[809]350#if ! defined( __check )
[667]351          IF ( myid == 0  ) THEN
352             CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
353             CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 19, comm_inter, &
354                            status, ierr )
355          ENDIF   
356          CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]357#endif         
[109]358          dt_coupling = MAX( dt_max, remote )
[213]359          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
360                 '": dt_coupling <= 0.0 & is not allowed and is reset to ',    &
361                 'MAX(dt_max(A,O)) = ', dt_coupling
[226]362          CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
[109]363       ENDIF
[809]364#if ! defined( __check )
[667]365       IF ( myid == 0 ) THEN
366          CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, &
367                         ierr )
368          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 12, comm_inter, &
369                         status, ierr )
370       ENDIF
371       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]372#endif     
[108]373       IF ( restart_time /= remote )  THEN
[213]374          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
375                 '": restart_time = ', restart_time, '& is not equal to ',     &
376                 'restart_time_remote = ', remote
[226]377          CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
[108]378       ENDIF
[809]379#if ! defined( __check )
[667]380       IF ( myid == 0 ) THEN
381          CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, &
382                         ierr )
383          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 13, comm_inter, &
384                         status, ierr )
385       ENDIF   
386       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]387#endif     
[108]388       IF ( dt_restart /= remote )  THEN
[213]389          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
390                 '": dt_restart = ', dt_restart, '& is not equal to ',         &
391                 'dt_restart_remote = ', remote
[226]392          CALL message( 'check_parameters', 'PA0007', 1, 2, 0, 6, 0 )
[108]393       ENDIF
[213]394
[291]395       simulation_time_since_reference = end_time - coupling_start_time
[809]396#if ! defined( __check )
[667]397       IF  ( myid == 0 ) THEN
398          CALL MPI_SEND( simulation_time_since_reference, 1, MPI_REAL, target_id, &
399                         14, comm_inter, ierr )
400          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 14, comm_inter, &
401                         status, ierr )   
402       ENDIF
403       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]404#endif     
[291]405       IF ( simulation_time_since_reference /= remote )  THEN
[213]406          WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
[291]407                 '": simulation_time_since_reference = ',                      &
408                 simulation_time_since_reference, '& is not equal to ',        &
409                 'simulation_time_since_reference_remote = ', remote
[226]410          CALL message( 'check_parameters', 'PA0008', 1, 2, 0, 6, 0 )
[108]411       ENDIF
[213]412
[809]413#if ! defined( __check )
[667]414       IF ( myid == 0 ) THEN
415          CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
416          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 15, comm_inter, &
417                                                             status, ierr )
[108]418       ENDIF
[667]419       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[213]420
[807]421#endif
[667]422       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
423
424          IF ( dx < remote ) THEN
425             WRITE( message_string, * ) 'coupling mode "', &
426                   TRIM( coupling_mode ),                  &
427           '": dx in Atmosphere is not equal to or not larger then dx in ocean'
428             CALL message( 'check_parameters', 'PA0009', 1, 2, 0, 6, 0 )
429          ENDIF
430
431          IF ( (nx_a+1)*dx /= (nx_o+1)*remote )  THEN
432             WRITE( message_string, * ) 'coupling mode "', &
433                    TRIM( coupling_mode ), &
434             '": Domain size in x-direction is not equal in ocean and atmosphere'
435             CALL message( 'check_parameters', 'PA0010', 1, 2, 0, 6, 0 )
436          ENDIF
437
[108]438       ENDIF
[213]439
[809]440#if ! defined( __check )
[667]441       IF ( myid == 0) THEN
442          CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
443          CALL MPI_RECV( remote, 1, MPI_REAL, target_id, 16, comm_inter, &
444                         status, ierr )
[108]445       ENDIF
[667]446       CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
[807]447#endif
[667]448       IF ( coupling_mode == 'atmosphere_to_ocean') THEN
449
450          IF ( dy < remote )  THEN
451             WRITE( message_string, * ) 'coupling mode "', &
452                    TRIM( coupling_mode ), &
453                 '": dy in Atmosphere is not equal to or not larger then dy in ocean'
454             CALL message( 'check_parameters', 'PA0011', 1, 2, 0, 6, 0 )
455          ENDIF
456
457          IF ( (ny_a+1)*dy /= (ny_o+1)*remote )  THEN
458             WRITE( message_string, * ) 'coupling mode "', &
459                   TRIM( coupling_mode ), &
460             '": Domain size in y-direction is not equal in ocean and atmosphere'
461             CALL message( 'check_parameters', 'PA0012', 1, 2, 0, 6, 0 )
462          ENDIF
463
464          IF ( MOD(nx_o+1,nx_a+1) /= 0 )  THEN
465             WRITE( message_string, * ) 'coupling mode "', &
466                   TRIM( coupling_mode ), &
467             '": nx+1 in ocean is not divisible without remainder with nx+1 in', & 
468             ' atmosphere'
469             CALL message( 'check_parameters', 'PA0339', 1, 2, 0, 6, 0 )
470          ENDIF
471
472          IF ( MOD(ny_o+1,ny_a+1) /= 0 )  THEN
473             WRITE( message_string, * ) 'coupling mode "', &
474                   TRIM( coupling_mode ), &
475             '": ny+1 in ocean is not divisible without remainder with ny+1 in', & 
476             ' atmosphere'
477             CALL message( 'check_parameters', 'PA0340', 1, 2, 0, 6, 0 )
478          ENDIF
479
[108]480       ENDIF
[222]481#else
482       WRITE( message_string, * ) 'coupling requires PALM to be called with', &
483            ' ''mrun -K parallel'''
[226]484       CALL message( 'check_parameters', 'PA0141', 1, 2, 0, 6, 0 )
[108]485#endif
486    ENDIF
487
[809]488#if defined( __parallel ) && ! defined ( __check )
[108]489!
490!-- Exchange via intercommunicator
[667]491    IF ( coupling_mode == 'atmosphere_to_ocean' .AND. myid == 0 )  THEN
[206]492       CALL MPI_SEND( humidity, 1, MPI_LOGICAL, target_id, 19, comm_inter, &
493                      ierr )
[667]494    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' .AND. myid == 0)  THEN
[206]495       CALL MPI_RECV( humidity_remote, 1, MPI_LOGICAL, target_id, 19, &
496                      comm_inter, status, ierr )
[108]497    ENDIF
[667]498    CALL MPI_BCAST( humidity_remote, 1, MPI_LOGICAL, 0, comm2d, ierr)
499   
[108]500#endif
501
502
503!
[1]504!-- Generate the file header which is used as a header for most of PALM's
505!-- output files
506    CALL DATE_AND_TIME( date, time )
507    run_date = date(7:8)//'-'//date(5:6)//'-'//date(3:4)
508    run_time = time(1:2)//':'//time(3:4)//':'//time(5:6)
[102]509    IF ( coupling_mode == 'uncoupled' )  THEN
510       coupling_string = ''
511    ELSEIF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
512       coupling_string = ' coupled (atmosphere)'
513    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
514       coupling_string = ' coupled (ocean)'
515    ENDIF       
[1]516
[102]517    WRITE ( run_description_header,                                        &
518                             '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' ) &
519              TRIM( version ), TRIM( revision ), 'run: ',                  &
520              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ), &
521              'host: ', TRIM( host ), run_date, run_time
[1]522
523!
[63]524!-- Check the general loop optimization method
525    IF ( loop_optimization == 'default' )  THEN
526       IF ( host(1:3) == 'nec' )  THEN
527          loop_optimization = 'vector'
528       ELSE
529          loop_optimization = 'cache'
530       ENDIF
531    ENDIF
532
[1015]533    SELECT CASE ( TRIM( loop_optimization ) )
534
[1019]535       CASE ( 'acc', 'cache', 'vector' )
[1015]536          CONTINUE
537
538       CASE DEFAULT
539          message_string = 'illegal value given for loop_optimization: "' // &
540                           TRIM( loop_optimization ) // '"'
541          CALL message( 'check_parameters', 'PA0013', 1, 2, 0, 6, 0 )
542
543    END SELECT
544
[63]545!
[1]546!-- Check topography setting (check for illegal parameter combinations)
547    IF ( topography /= 'flat' )  THEN
548       action = ' '
[861]549       IF ( scalar_advec /= 'pw-scheme' .AND. scalar_advec /= 'ws-scheme')  THEN
[1]550          WRITE( action, '(A,A)' )  'scalar_advec = ', scalar_advec
551       ENDIF
[861]552       IF ( momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme' ) &
553       THEN
[1]554          WRITE( action, '(A,A)' )  'momentum_advec = ', momentum_advec
555       ENDIF
[114]556       IF ( psolver == 'sor' )  THEN
[1]557          WRITE( action, '(A,A)' )  'psolver = ', psolver
558       ENDIF
559       IF ( sloping_surface )  THEN
560          WRITE( action, '(A)' )  'sloping surface = .TRUE.'
561       ENDIF
562       IF ( galilei_transformation )  THEN
563          WRITE( action, '(A)' )  'galilei_transformation = .TRUE.'
564       ENDIF
565       IF ( cloud_droplets )  THEN
[1069]566          WRITE( action, '(A)' )  'cloud_droplets = .TRUE. (has not been tested)'
[1]567       ENDIF
568       IF ( .NOT. prandtl_layer )  THEN
569          WRITE( action, '(A)' )  'prandtl_layer = .FALSE.'
570       ENDIF
571       IF ( action /= ' ' )  THEN
[213]572          message_string = 'a non-flat topography does not allow ' // &
573                           TRIM( action )
[226]574          CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
[1]575       ENDIF
[256]576!
577!--    In case of non-flat topography, check whether the convention how to
578!--    define the topography grid has been set correctly, or whether the default
579!--    is applicable. If this is not possible, abort.
580       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
581          IF ( TRIM( topography ) /= 'single_building' .AND.  &
582               TRIM( topography ) /= 'single_street_canyon' .AND.  &
583               TRIM( topography ) /= 'read_from_file' )  THEN
584!--          The default value is not applicable here, because it is only valid
585!--          for the two standard cases 'single_building' and 'read_from_file'
586!--          defined in init_grid.
587             WRITE( message_string, * )  &
588                  'The value for "topography_grid_convention" ',  &
589                  'is not set. Its default value is & only valid for ',  &
590                  '"topography" = ''single_building'', ',  &
591                  '''single_street_canyon'' & or ''read_from_file''.',  &
592                  ' & Choose ''cell_edge'' or ''cell_center''.'
593             CALL message( 'user_check_parameters', 'PA0239', 1, 2, 0, 6, 0 )
594          ELSE
595!--          The default value is applicable here.
596!--          Set convention according to topography.
597             IF ( TRIM( topography ) == 'single_building' .OR.  &
598                  TRIM( topography ) == 'single_street_canyon' )  THEN
599                topography_grid_convention = 'cell_edge'
600             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
601                topography_grid_convention = 'cell_center'
602             ENDIF
603          ENDIF
604       ELSEIF ( TRIM( topography_grid_convention ) /= 'cell_edge' .AND.  &
605                TRIM( topography_grid_convention ) /= 'cell_center' )  THEN
606          WRITE( message_string, * )  &
607               'The value for "topography_grid_convention" is ', &
608               'not recognized. & Choose ''cell_edge'' or ''cell_center''.'
609          CALL message( 'user_check_parameters', 'PA0240', 1, 2, 0, 6, 0 )
610       ENDIF
611
[1]612    ENDIF
[94]613
[1]614!
[94]615!-- Check ocean setting
616    IF ( ocean )  THEN
[332]617
[94]618       action = ' '
619       IF ( action /= ' ' )  THEN
[213]620          message_string = 'ocean = .T. does not allow ' // TRIM( action )
[226]621          CALL message( 'check_parameters', 'PA0015', 1, 2, 0, 6, 0 )
[94]622       ENDIF
623
[332]624    ELSEIF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.  &
625             TRIM( coupling_char ) == '_O' )  THEN
[343]626
[94]627!
[332]628!--    Check whether an (uncoupled) atmospheric run has been declared as an
629!--    ocean run (this setting is done via mrun-option -y)
[343]630
[291]631       message_string = 'ocean = .F. does not allow coupling_char = "' // &
632                        TRIM( coupling_char ) // '" set by mrun-option "-y"'
633       CALL message( 'check_parameters', 'PA0317', 1, 2, 0, 6, 0 )
[332]634
[291]635    ENDIF
636!
[1053]637!-- Check cloud scheme
638    IF ( cloud_scheme == 'seifert_beheng' )  THEN
639       icloud_scheme = 0
640    ELSEIF ( cloud_scheme == 'kessler' )  THEN
641       icloud_scheme = 1
642    ELSE
643       message_string = 'unknown cloud microphysics scheme cloud_scheme ="' // &
644                        TRIM( cloud_scheme ) // '"'
645       CALL message( 'check_parameters', 'PA0357', 1, 2, 0, 6, 0 )
646    ENDIF
647!
[1]648!-- Check whether there are any illegal values
649!-- Pressure solver:
650    IF ( psolver /= 'poisfft'  .AND.  psolver /= 'poisfft_hybrid'  .AND. &
651         psolver /= 'sor'  .AND.  psolver /= 'multigrid' )  THEN
[213]652       message_string = 'unknown solver for perturbation pressure: psolver' // &
653                        ' = "' // TRIM( psolver ) // '"'
[226]654       CALL message( 'check_parameters', 'PA0016', 1, 2, 0, 6, 0 )
[1]655    ENDIF
656
657#if defined( __parallel )
658    IF ( psolver == 'poisfft_hybrid'  .AND.  pdims(2) /= 1 )  THEN
[213]659       message_string = 'psolver = "' // TRIM( psolver ) // '" only works ' // &
660                        'for a 1d domain-decomposition along x & please do' // &
661                        ' not set npey/=1 in the parameter file'
[226]662       CALL message( 'check_parameters', 'PA0017', 1, 2, 0, 6, 0 )
[1]663    ENDIF
664#else
665    IF ( psolver == 'poisfft_hybrid' )  THEN
[213]666       message_string = 'psolver = "' // TRIM( psolver ) // '" only works' // &
667                        ' for a parallel environment'
[226]668       CALL message( 'check_parameters', 'PA0019', 1, 2, 0, 6, 0 )
[1]669    ENDIF
670#endif
671
672    IF ( psolver == 'multigrid' )  THEN
673       IF ( cycle_mg == 'w' )  THEN
674          gamma_mg = 2
675       ELSEIF ( cycle_mg == 'v' )  THEN
676          gamma_mg = 1
677       ELSE
[213]678          message_string = 'unknown multigrid cycle: cycle_mg = "' // &
679                           TRIM( cycle_mg ) // '"'
[226]680          CALL message( 'check_parameters', 'PA0020', 1, 2, 0, 6, 0 )
[1]681       ENDIF
682    ENDIF
683
684    IF ( fft_method /= 'singleton-algorithm'  .AND.  &
685         fft_method /= 'temperton-algorithm'  .AND.  &
686         fft_method /= 'system-specific' )  THEN
[213]687       message_string = 'unknown fft-algorithm: fft_method = "' // &
688                        TRIM( fft_method ) // '"'
[226]689       CALL message( 'check_parameters', 'PA0021', 1, 2, 0, 6, 0 )
[1]690    ENDIF
[667]691   
692    IF( momentum_advec == 'ws-scheme' .AND. & 
[688]693        .NOT. call_psolver_at_all_substeps  ) THEN
[667]694        message_string = 'psolver must be called at each RK3 substep when "'//&
695                      TRIM(momentum_advec) // ' "is used for momentum_advec'
[685]696        CALL message( 'check_parameters', 'PA0344', 1, 2, 0, 6, 0 )
[667]697    END IF
[1]698!
699!-- Advection schemes:
[1001]700    IF ( momentum_advec /= 'pw-scheme'  .AND.  momentum_advec /= 'ws-scheme' ) &
701    THEN
[214]702       message_string = 'unknown advection scheme: momentum_advec = "' // &
703                        TRIM( momentum_advec ) // '"'
[226]704       CALL message( 'check_parameters', 'PA0022', 1, 2, 0, 6, 0 )
[1]705    ENDIF
[1001]706    IF ( ( momentum_advec == 'ws-scheme' .OR.  scalar_advec == 'ws-scheme' )   &
707           .AND. ( timestep_scheme == 'euler' .OR.                             &
708                   timestep_scheme == 'runge-kutta-2' ) )                      &
709    THEN
[667]710       message_string = 'momentum_advec or scalar_advec = "' &
711         // TRIM( momentum_advec ) // '" is not allowed with timestep_scheme = "' // &
712         TRIM( timestep_scheme ) // '"'
[226]713       CALL message( 'check_parameters', 'PA0023', 1, 2, 0, 6, 0 )
[1]714    ENDIF
[667]715    IF ( scalar_advec /= 'pw-scheme'  .AND.  scalar_advec /= 'ws-scheme' .AND. &
[1001]716         scalar_advec /= 'bc-scheme' )                                         &
717    THEN
[214]718       message_string = 'unknown advection scheme: scalar_advec = "' // &
719                        TRIM( scalar_advec ) // '"'
[226]720       CALL message( 'check_parameters', 'PA0024', 1, 2, 0, 6, 0 )
[1]721    ENDIF
[1019]722    IF ( scalar_advec == 'bc-scheme'  .AND.  loop_optimization == 'cache' ) &
723    THEN
724       message_string = 'advection_scheme scalar_advec = "' &
725         // TRIM( scalar_advec ) // '" not implemented for & loop_optimization = "' // &
726         TRIM( loop_optimization ) // '"'
727       CALL message( 'check_parameters', 'PA0026', 1, 2, 0, 6, 0 )
728    ENDIF
[1]729
730    IF ( use_sgs_for_particles  .AND.  .NOT. use_upstream_for_tke )  THEN
731       use_upstream_for_tke = .TRUE.
[214]732       message_string = 'use_upstream_for_tke set .TRUE. because ' // &
733                        'use_sgs_for_particles = .TRUE.'
[226]734       CALL message( 'check_parameters', 'PA0025', 0, 1, 0, 6, 0 )
[1]735    ENDIF
736
[824]737    IF ( use_sgs_for_particles  .AND.  curvature_solution_effects )  THEN
738       message_string = 'use_sgs_for_particles = .TRUE. not allowed with ' // &
739                        'curvature_solution_effects = .TRUE.'
740       CALL message( 'check_parameters', 'PA0349', 1, 2, 0, 6, 0 )
741    ENDIF
742
[1]743!
[1019]744!-- Set LOGICAL switches to enhance performance
745    IF ( momentum_advec == 'ws-scheme' )    ws_scheme_mom = .TRUE.
746    IF ( scalar_advec   == 'ws-scheme'   )  ws_scheme_sca = .TRUE.
747
748!
[1]749!-- Timestep schemes:
750    SELECT CASE ( TRIM( timestep_scheme ) )
751
752       CASE ( 'euler' )
753          intermediate_timestep_count_max = 1
754
755       CASE ( 'runge-kutta-2' )
756          intermediate_timestep_count_max = 2
757
758       CASE ( 'runge-kutta-3' )
759          intermediate_timestep_count_max = 3
760
761       CASE DEFAULT
[214]762          message_string = 'unknown timestep scheme: timestep_scheme = "' // &
763                           TRIM( timestep_scheme ) // '"'
[226]764          CALL message( 'check_parameters', 'PA0027', 1, 2, 0, 6, 0 )
[1]765
766    END SELECT
767
[667]768    IF ( (momentum_advec /= 'pw-scheme' .AND. momentum_advec /= 'ws-scheme') &
769         .AND. timestep_scheme(1:5) == 'runge' ) THEN
[214]770       message_string = 'momentum advection scheme "' // &
771                        TRIM( momentum_advec ) // '" & does not work with ' // &
772                        'timestep_scheme "' // TRIM( timestep_scheme ) // '"'
[226]773       CALL message( 'check_parameters', 'PA0029', 1, 2, 0, 6, 0 )
[1]774    ENDIF
775
[825]776!
777!-- Collision kernels:
778    SELECT CASE ( TRIM( collision_kernel ) )
779
[828]780       CASE ( 'hall', 'hall_fast' )
[825]781          hall_kernel = .TRUE.
782
783       CASE ( 'palm' )
784          palm_kernel = .TRUE.
785
[828]786       CASE ( 'wang', 'wang_fast' )
[825]787          wang_kernel = .TRUE.
788
789       CASE ( 'none' )
790
791
792       CASE DEFAULT
793          message_string = 'unknown collision kernel: collision_kernel = "' // &
794                           TRIM( collision_kernel ) // '"'
795          CALL message( 'check_parameters', 'PA0350', 1, 2, 0, 6, 0 )
796
797    END SELECT
[828]798    IF ( collision_kernel(6:9) == 'fast' )  use_kernel_tables = .TRUE.
[825]799
[147]800    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.  &
[328]801         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
[1]802!
[214]803!--    No restart run: several initialising actions are possible
[1]804       action = initializing_actions
805       DO WHILE ( TRIM( action ) /= '' )
806          position = INDEX( action, ' ' )
807          SELECT CASE ( action(1:position-1) )
808
809             CASE ( 'set_constant_profiles', 'set_1d-model_profiles', &
[46]810                    'by_user', 'initialize_vortex',     'initialize_ptanom' )
[1]811                action = action(position+1:)
812
813             CASE DEFAULT
[214]814                message_string = 'initializing_action = "' // &
815                                 TRIM( action ) // '" unkown or not allowed'
[226]816                CALL message( 'check_parameters', 'PA0030', 1, 2, 0, 6, 0 )
[1]817
818          END SELECT
819       ENDDO
820    ENDIF
[214]821
[680]822    IF ( TRIM( initializing_actions ) == 'initialize_vortex' .AND. &
823         conserve_volume_flow ) THEN
824         message_string = 'initializing_actions = "initialize_vortex"' // &
825                        ' ist not allowed with conserve_volume_flow = .T.'
826       CALL message( 'check_parameters', 'PA0343', 1, 2, 0, 6, 0 )
827    ENDIF       
828
829
[1]830    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
831         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
[214]832       message_string = 'initializing_actions = "set_constant_profiles"' // &
833                        ' and "set_1d-model_profiles" are not allowed ' //  &
834                        'simultaneously'
[226]835       CALL message( 'check_parameters', 'PA0031', 1, 2, 0, 6, 0 )
[1]836    ENDIF
[214]837
[46]838    IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0  .AND. &
839         INDEX( initializing_actions, 'by_user' ) /= 0 )  THEN
[214]840       message_string = 'initializing_actions = "set_constant_profiles"' // &
841                        ' and "by_user" are not allowed simultaneously'
[226]842       CALL message( 'check_parameters', 'PA0032', 1, 2, 0, 6, 0 )
[46]843    ENDIF
[214]844
[46]845    IF ( INDEX( initializing_actions, 'by_user' ) /= 0  .AND. &
846         INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
[214]847       message_string = 'initializing_actions = "by_user" and ' // &
848                        '"set_1d-model_profiles" are not allowed simultaneously'
[226]849       CALL message( 'check_parameters', 'PA0033', 1, 2, 0, 6, 0 )
[46]850    ENDIF
[1]851
[75]852    IF ( cloud_physics  .AND.  .NOT. humidity )  THEN
[214]853       WRITE( message_string, * ) 'cloud_physics = ', cloud_physics, ' is ', &
854              'not allowed with humidity = ', humidity
[226]855       CALL message( 'check_parameters', 'PA0034', 1, 2, 0, 6, 0 )
[1]856    ENDIF
857
[72]858    IF ( precipitation  .AND.  .NOT.  cloud_physics )  THEN
[214]859       WRITE( message_string, * ) 'precipitation = ', precipitation, ' is ', &
860              'not allowed with cloud_physics = ', cloud_physics
[226]861       CALL message( 'check_parameters', 'PA0035', 1, 2, 0, 6, 0 )
[72]862    ENDIF
863
[75]864    IF ( humidity  .AND.  sloping_surface )  THEN
[214]865       message_string = 'humidity = .TRUE. and sloping_surface = .TRUE. ' // &
866                        'are not allowed simultaneously'
[226]867       CALL message( 'check_parameters', 'PA0036', 1, 2, 0, 6, 0 )
[1]868    ENDIF
869
[75]870    IF ( passive_scalar  .AND.  humidity )  THEN
[214]871       message_string = 'humidity = .TRUE. and passive_scalar = .TRUE. ' // &
872                        'is not allowed simultaneously'
[226]873       CALL message( 'check_parameters', 'PA0038', 1, 2, 0, 6, 0 )
[1]874    ENDIF
875
[138]876    IF ( plant_canopy .AND. ( drag_coefficient == 0.0 ) ) THEN
[214]877       message_string = 'plant_canopy = .TRUE. requires a non-zero drag ' // &
878                        'coefficient & given value is drag_coefficient = 0.0'
[226]879       CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
[138]880    ENDIF
881
[1053]882    IF ( plant_canopy  .AND.  cloud_physics  .AND.  icloud_scheme == 0 ) THEN
883       message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' //  &
884                        ' seifert_beheng'
885       CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
886    ENDIF
887
888    IF ( loop_optimization /= 'cache' .AND.  cloud_physics  .AND.            &
889         icloud_scheme == 0 ) THEN
890       message_string = 'cloud_scheme = seifert_beheng requires ' // &
891                        'loop_optimization = cache'
892       CALL message( 'check_parameters', 'PA0362', 1, 2, 0, 6, 0 )
893    ENDIF
894
[1065]895    IF ( cloud_physics  .AND. icloud_scheme == 0  .AND.                      &
896         .NOT. precipitation ) THEN
897       message_string = 'cloud_scheme = seifert_beheng requires ' // &
898                        'precipitation = .TRUE.'
899       CALL message( 'check_parameters', 'PA0363', 1, 2, 0, 6, 0 )
900    ENDIF 
901
[1]902!
903!-- In case of no model continuation run, check initialising parameters and
904!-- deduce further quantities
905    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
906
907!
[767]908!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
[1]909       pt_init = pt_surface
[1053]910       IF ( humidity )  THEN
911          q_init  = q_surface
912!
913!--       It is not allowed to choose initial profiles of rain water content
914!--       and rain drop concentration. They are set to 0.0.
915          IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN
916             qr_init = 0.0
917             nr_init = 0.0
918          ENDIF
919       ENDIF
[94]920       IF ( ocean )           sa_init = sa_surface
921       IF ( passive_scalar )  q_init  = s_surface
[138]922       IF ( plant_canopy )    lad = 0.0
[1]923
924!
925!--
926!--    If required, compute initial profile of the geostrophic wind
927!--    (component ug)
928       i = 1
929       gradient = 0.0
[97]930
931       IF ( .NOT. ocean )  THEN
932
933          ug_vertical_gradient_level_ind(1) = 0
934          ug(0) = ug_surface
935          DO  k = 1, nzt+1
[177]936             IF ( i < 11 ) THEN
937                IF ( ug_vertical_gradient_level(i) < zu(k)  .AND. &
938                     ug_vertical_gradient_level(i) >= 0.0 )  THEN
939                   gradient = ug_vertical_gradient(i) / 100.0
940                   ug_vertical_gradient_level_ind(i) = k - 1
941                   i = i + 1
[1]942                ENDIF
[177]943             ENDIF       
[97]944             IF ( gradient /= 0.0 )  THEN
945                IF ( k /= 1 )  THEN
946                   ug(k) = ug(k-1) + dzu(k) * gradient
947                ELSE
948                   ug(k) = ug_surface + 0.5 * dzu(k) * gradient
949                ENDIF
[1]950             ELSE
[97]951                ug(k) = ug(k-1)
[1]952             ENDIF
[97]953          ENDDO
[1]954
[97]955       ELSE
956
957          ug_vertical_gradient_level_ind(1) = nzt+1
[121]958          ug(nzt+1) = ug_surface
[667]959          DO  k = nzt, nzb, -1
[177]960             IF ( i < 11 ) THEN
961                IF ( ug_vertical_gradient_level(i) > zu(k)  .AND. &
962                     ug_vertical_gradient_level(i) <= 0.0 )  THEN
963                   gradient = ug_vertical_gradient(i) / 100.0
964                   ug_vertical_gradient_level_ind(i) = k + 1
965                   i = i + 1
[97]966                ENDIF
967             ENDIF
968             IF ( gradient /= 0.0 )  THEN
969                IF ( k /= nzt )  THEN
970                   ug(k) = ug(k+1) - dzu(k+1) * gradient
971                ELSE
972                   ug(k)   = ug_surface - 0.5 * dzu(k+1) * gradient
973                   ug(k+1) = ug_surface + 0.5 * dzu(k+1) * gradient
974                ENDIF
975             ELSE
976                ug(k) = ug(k+1)
977             ENDIF
978          ENDDO
979
980       ENDIF
981
[1]982!
[767]983!--    In case of no given gradients for ug, choose a zero gradient
[97]984       IF ( ug_vertical_gradient_level(1) == -9999999.9 )  THEN
[1]985          ug_vertical_gradient_level(1) = 0.0
986       ENDIF 
987
988!
989!--
990!--    If required, compute initial profile of the geostrophic wind
991!--    (component vg)
992       i = 1
993       gradient = 0.0
[97]994
995       IF ( .NOT. ocean )  THEN
996
997          vg_vertical_gradient_level_ind(1) = 0
998          vg(0) = vg_surface
999          DO  k = 1, nzt+1
[177]1000             IF ( i < 11 ) THEN
1001                IF ( vg_vertical_gradient_level(i) < zu(k)  .AND. &
1002                     vg_vertical_gradient_level(i) >= 0.0 )  THEN
1003                   gradient = vg_vertical_gradient(i) / 100.0
1004                   vg_vertical_gradient_level_ind(i) = k - 1
1005                   i = i + 1
[1]1006                ENDIF
1007             ENDIF
[97]1008             IF ( gradient /= 0.0 )  THEN
1009                IF ( k /= 1 )  THEN
1010                   vg(k) = vg(k-1) + dzu(k) * gradient
1011                ELSE
1012                   vg(k) = vg_surface + 0.5 * dzu(k) * gradient
1013                ENDIF
[1]1014             ELSE
[97]1015                vg(k) = vg(k-1)
[1]1016             ENDIF
[97]1017          ENDDO
[1]1018
[97]1019       ELSE
1020
[121]1021          vg_vertical_gradient_level_ind(1) = nzt+1
1022          vg(nzt+1) = vg_surface
[667]1023          DO  k = nzt, nzb, -1
[177]1024             IF ( i < 11 ) THEN
1025                IF ( vg_vertical_gradient_level(i) > zu(k)  .AND. &
1026                     vg_vertical_gradient_level(i) <= 0.0 )  THEN
1027                   gradient = vg_vertical_gradient(i) / 100.0
1028                   vg_vertical_gradient_level_ind(i) = k + 1
1029                   i = i + 1
[97]1030                ENDIF
1031             ENDIF
1032             IF ( gradient /= 0.0 )  THEN
1033                IF ( k /= nzt )  THEN
1034                   vg(k) = vg(k+1) - dzu(k+1) * gradient
1035                ELSE
1036                   vg(k)   = vg_surface - 0.5 * dzu(k+1) * gradient
1037                   vg(k+1) = vg_surface + 0.5 * dzu(k+1) * gradient
1038                ENDIF
1039             ELSE
1040                vg(k) = vg(k+1)
1041             ENDIF
1042          ENDDO
1043
1044       ENDIF
1045
[1]1046!
[767]1047!--    In case of no given gradients for vg, choose a zero gradient
[97]1048       IF ( vg_vertical_gradient_level(1) == -9999999.9 )  THEN
[1]1049          vg_vertical_gradient_level(1) = 0.0
1050       ENDIF
1051
1052!
[767]1053!--    Let the initial wind profiles be the calculated ug/vg profiles or
1054!--    interpolate them from wind profile data (if given)
1055       IF ( u_profile(1) == 9999999.9  .AND.  v_profile(1) == 9999999.9 )  THEN
1056
1057          u_init = ug
1058          v_init = vg
1059
1060       ELSEIF ( u_profile(1) == 0.0  .AND.  v_profile(1) == 0.0 )  THEN
1061
1062          IF ( uv_heights(1) /= 0.0 )  THEN
1063             message_string = 'uv_heights(1) must be 0.0'
1064             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
1065          ENDIF
1066
1067          use_prescribed_profile_data = .TRUE.
1068
1069          kk = 1
1070          u_init(0) = 0.0
1071          v_init(0) = 0.0
1072
1073          DO  k = 1, nz+1
1074
1075             IF ( kk < 100 )  THEN
1076                DO WHILE ( uv_heights(kk+1) <= zu(k) )
1077                   kk = kk + 1
1078                   IF ( kk == 100 )  EXIT
1079                ENDDO
1080             ENDIF
1081
[774]1082             IF ( kk < 100 .AND. uv_heights(kk+1) /= 9999999.9 )  THEN
[767]1083                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1084                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1085                                       ( u_profile(kk+1) - u_profile(kk) )
1086                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
1087                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
1088                                       ( v_profile(kk+1) - v_profile(kk) )
1089             ELSE
1090                u_init(k) = u_profile(kk)
1091                v_init(k) = v_profile(kk)
1092             ENDIF
1093
1094          ENDDO
1095
1096       ELSE
1097
1098          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
1099          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
1100
1101       ENDIF
1102
1103!
[94]1104!--    Compute initial temperature profile using the given temperature gradients
[940]1105       IF ( .NOT. neutral )  THEN
[94]1106
[940]1107          i = 1
1108          gradient = 0.0
[94]1109
[940]1110          IF ( .NOT. ocean )  THEN
1111
1112             pt_vertical_gradient_level_ind(1) = 0
1113             DO  k = 1, nzt+1
1114                IF ( i < 11 ) THEN
1115                   IF ( pt_vertical_gradient_level(i) < zu(k)  .AND. &
1116                        pt_vertical_gradient_level(i) >= 0.0 )  THEN
1117                      gradient = pt_vertical_gradient(i) / 100.0
1118                      pt_vertical_gradient_level_ind(i) = k - 1
1119                      i = i + 1
1120                   ENDIF
[1]1121                ENDIF
[940]1122                IF ( gradient /= 0.0 )  THEN
1123                   IF ( k /= 1 )  THEN
1124                      pt_init(k) = pt_init(k-1) + dzu(k) * gradient
1125                   ELSE
1126                      pt_init(k) = pt_surface   + 0.5 * dzu(k) * gradient
1127                   ENDIF
[94]1128                ELSE
[940]1129                   pt_init(k) = pt_init(k-1)
[94]1130                ENDIF
[940]1131             ENDDO
[1]1132
[940]1133          ELSE
[94]1134
[940]1135             pt_vertical_gradient_level_ind(1) = nzt+1
1136             DO  k = nzt, 0, -1
1137                IF ( i < 11 ) THEN
1138                   IF ( pt_vertical_gradient_level(i) > zu(k)  .AND. &
1139                        pt_vertical_gradient_level(i) <= 0.0 )  THEN
1140                      gradient = pt_vertical_gradient(i) / 100.0
1141                      pt_vertical_gradient_level_ind(i) = k + 1
1142                      i = i + 1
1143                   ENDIF
[94]1144                ENDIF
[940]1145                IF ( gradient /= 0.0 )  THEN
1146                   IF ( k /= nzt )  THEN
1147                      pt_init(k) = pt_init(k+1) - dzu(k+1) * gradient
1148                   ELSE
1149                      pt_init(k)   = pt_surface - 0.5 * dzu(k+1) * gradient
1150                      pt_init(k+1) = pt_surface + 0.5 * dzu(k+1) * gradient
1151                   ENDIF
[94]1152                ELSE
[940]1153                   pt_init(k) = pt_init(k+1)
[94]1154                ENDIF
[940]1155             ENDDO
[94]1156
[940]1157          ENDIF
1158
[94]1159       ENDIF
1160
[1]1161!
1162!--    In case of no given temperature gradients, choose gradient of neutral
1163!--    stratification
[94]1164       IF ( pt_vertical_gradient_level(1) == -9999999.9 )  THEN
[1]1165          pt_vertical_gradient_level(1) = 0.0
1166       ENDIF
1167
1168!
[94]1169!--    Store temperature gradient at the top boundary for possible Neumann
[1]1170!--    boundary condition
[19]1171       bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1)
[1]1172
1173!
1174!--    If required, compute initial humidity or scalar profile using the given
1175!--    humidity/scalar gradient. In case of scalar transport, initially store
1176!--    values of the scalar parameters on humidity parameters
1177       IF ( passive_scalar )  THEN
1178          bc_q_b                    = bc_s_b
1179          bc_q_t                    = bc_s_t
1180          q_surface                 = s_surface
1181          q_surface_initial_change  = s_surface_initial_change
1182          q_vertical_gradient       = s_vertical_gradient
1183          q_vertical_gradient_level = s_vertical_gradient_level
1184          surface_waterflux         = surface_scalarflux
[407]1185          wall_humidityflux         = wall_scalarflux
[1]1186       ENDIF
1187
[75]1188       IF ( humidity  .OR.  passive_scalar )  THEN
[1]1189
1190          i = 1
1191          gradient = 0.0
1192          q_vertical_gradient_level_ind(1) = 0
1193          DO  k = 1, nzt+1
[177]1194             IF ( i < 11 ) THEN
1195                IF ( q_vertical_gradient_level(i) < zu(k)  .AND. &
1196                     q_vertical_gradient_level(i) >= 0.0 )  THEN
1197                   gradient = q_vertical_gradient(i) / 100.0
1198                   q_vertical_gradient_level_ind(i) = k - 1
1199                   i = i + 1
[1]1200                ENDIF
1201             ENDIF
1202             IF ( gradient /= 0.0 )  THEN
1203                IF ( k /= 1 )  THEN
1204                   q_init(k) = q_init(k-1) + dzu(k) * gradient
1205                ELSE
1206                   q_init(k) = q_init(k-1) + 0.5 * dzu(k) * gradient
1207                ENDIF
1208             ELSE
1209                q_init(k) = q_init(k-1)
1210             ENDIF
[72]1211!
1212!--          Avoid negative humidities
1213             IF ( q_init(k) < 0.0 )  THEN
1214                q_init(k) = 0.0
1215             ENDIF
[1]1216          ENDDO
1217
1218!
1219!--       In case of no given humidity gradients, choose zero gradient
1220!--       conditions
1221          IF ( q_vertical_gradient_level(1) == -1.0 )  THEN
1222             q_vertical_gradient_level(1) = 0.0
1223          ENDIF
1224
[1053]1225          IF ( cloud_physics .AND. icloud_scheme == 0 )  THEN
1226
1227             i = 1
1228             gradient = 0.0
1229             qr_vertical_gradient_level_ind(1) = 0
1230             DO  k = 1, nzt+1
1231                IF ( i < 11 ) THEN
1232                   IF ( qr_vertical_gradient_level(i) < zu(k)  .AND. &
1233                        qr_vertical_gradient_level(i) >= 0.0 )  THEN
1234                      gradient = qr_vertical_gradient(i) / 100.0
1235                      qr_vertical_gradient_level_ind(i) = k - 1
1236                      i = i + 1
1237                   ENDIF
1238                ENDIF
1239                IF ( gradient /= 0.0 )  THEN
1240                   IF ( k /= 1 )  THEN
1241                      qr_init(k) = qr_init(k-1) + dzu(k) * gradient
1242                   ELSE
1243                      qr_init(k) = qr_init(k-1) + 0.5 * dzu(k) * gradient
1244                   ENDIF
1245                ELSE
1246                   qr_init(k) = qr_init(k-1)
1247                ENDIF
[1]1248!
[1053]1249!--             Avoid negative rain water content
1250                IF ( qr_init(k) < 0.0 )  THEN
1251                   qr_init(k) = 0.0
1252                ENDIF
1253             ENDDO
1254!
1255!--          In case of no given rain water content gradients, choose zero gradient
1256!--          conditions
1257             IF ( qr_vertical_gradient_level(1) == -1.0 )  THEN
1258                qr_vertical_gradient_level(1) = 0.0
1259             ENDIF
[1]1260
[1053]1261             i = 1
1262             gradient = 0.0
1263             nr_vertical_gradient_level_ind(1) = 0
1264             DO  k = 1, nzt+1
1265                IF ( i < 11 ) THEN
1266                   IF ( nr_vertical_gradient_level(i) < zu(k)  .AND. &
1267                        nr_vertical_gradient_level(i) >= 0.0 )  THEN
1268                      gradient = nr_vertical_gradient(i) / 100.0
1269                      nr_vertical_gradient_level_ind(i) = k - 1
1270                      i = i + 1
1271                   ENDIF
1272                ENDIF
1273                IF ( gradient /= 0.0 )  THEN
1274                   IF ( k /= 1 )  THEN
1275                      nr_init(k) = nr_init(k-1) + dzu(k) * gradient
1276                   ELSE
1277                      nr_init(k) = nr_init(k-1) + 0.5 * dzu(k) * gradient
1278                   ENDIF
1279                ELSE
1280                   nr_init(k) = nr_init(k-1)
1281                ENDIF
1282!
1283!--             Avoid negative rain water content
1284                IF ( nr_init(k) < 0.0 )  THEN
1285                   nr_init(k) = 0.0
1286                ENDIF
1287             ENDDO
1288!
1289!--          In case of no given rain water content gradients, choose zero gradient
1290!--          conditions
1291             IF ( nr_vertical_gradient_level(1) == -1.0 )  THEN
1292                nr_vertical_gradient_level(1) = 0.0
1293             ENDIF
1294
1295          ENDIF
1296!
1297!--       Store humidity, rain water content and rain drop concentration
1298!--       gradient at the top boundary for possile Neumann boundary condition
1299          bc_q_t_val  = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
1300           
1301          IF ( cloud_physics .AND. icloud_scheme == 0 )  THEN
1302             bc_qr_t_val = ( qr_init(nzt+1) - qr_init(nzt) ) / dzu(nzt+1)
1303             bc_nr_t_val = ( nr_init(nzt+1) - nr_init(nzt) ) / dzu(nzt+1)
1304          ENDIF
1305
[1]1306       ENDIF
1307
[94]1308!
1309!--    If required, compute initial salinity profile using the given salinity
1310!--    gradients
1311       IF ( ocean )  THEN
1312
1313          i = 1
1314          gradient = 0.0
1315
1316          sa_vertical_gradient_level_ind(1) = nzt+1
1317          DO  k = nzt, 0, -1
[177]1318             IF ( i < 11 ) THEN
1319                IF ( sa_vertical_gradient_level(i) > zu(k)  .AND. &
1320                     sa_vertical_gradient_level(i) <= 0.0 )  THEN
1321                   gradient = sa_vertical_gradient(i) / 100.0
1322                   sa_vertical_gradient_level_ind(i) = k + 1
1323                   i = i + 1
[94]1324                ENDIF
1325             ENDIF
1326             IF ( gradient /= 0.0 )  THEN
1327                IF ( k /= nzt )  THEN
1328                   sa_init(k) = sa_init(k+1) - dzu(k+1) * gradient
1329                ELSE
1330                   sa_init(k)   = sa_surface - 0.5 * dzu(k+1) * gradient
1331                   sa_init(k+1) = sa_surface + 0.5 * dzu(k+1) * gradient
1332                ENDIF
1333             ELSE
1334                sa_init(k) = sa_init(k+1)
1335             ENDIF
1336          ENDDO
1337
1338       ENDIF
1339
[138]1340!
[388]1341!--    If required compute the profile of leaf area density used in the plant
1342!--    canopy model
[138]1343       IF ( plant_canopy ) THEN
1344       
1345          i = 1
1346          gradient = 0.0
[1]1347
[138]1348          IF ( .NOT. ocean ) THEN
[153]1349
1350             lad(0) = lad_surface
[138]1351 
1352             lad_vertical_gradient_level_ind(1) = 0
1353             DO k = 1, pch_index
[177]1354                IF ( i < 11 ) THEN
1355                   IF ( lad_vertical_gradient_level(i) < zu(k) .AND.  &
1356                        lad_vertical_gradient_level(i) >= 0.0 ) THEN
1357                      gradient = lad_vertical_gradient(i)
1358                      lad_vertical_gradient_level_ind(i) = k - 1
1359                      i = i + 1
[138]1360                   ENDIF
1361                ENDIF
1362                IF ( gradient /= 0.0 ) THEN
1363                   IF ( k /= 1 ) THEN
1364                      lad(k) = lad(k-1) + dzu(k) * gradient
1365                   ELSE
1366                      lad(k) = lad_surface + 0.5 * dzu(k) *gradient
1367                   ENDIF
1368                ELSE
1369                   lad(k) = lad(k-1)
1370                ENDIF
1371             ENDDO
1372
1373          ENDIF
1374
[1]1375!
[388]1376!--       In case of no given leaf area density gradients, choose a vanishing
1377!--       gradient
[138]1378          IF ( lad_vertical_gradient_level(1) == -9999999.9 ) THEN
1379             lad_vertical_gradient_level(1) = 0.0
1380          ENDIF
1381
1382       ENDIF
1383         
1384    ENDIF
[411]1385
1386!
1387!-- Initialize large scale subsidence if required
[580]1388    IF ( subs_vertical_gradient_level(1) /= -9999999.9 )  THEN
[411]1389       large_scale_subsidence = .TRUE.
1390       CALL init_w_subsidence
1391    END IF
1392 
[138]1393             
[667]1394
[138]1395!
[1]1396!-- Compute Coriolis parameter
1397    f  = 2.0 * omega * SIN( phi / 180.0 * pi )
1398    fs = 2.0 * omega * COS( phi / 180.0 * pi )
1399
1400!
[97]1401!-- Ocean runs always use reference values in the buoyancy term. Therefore
1402!-- set the reference temperature equal to the surface temperature.
1403    IF ( ocean  .AND.  pt_reference == 9999999.9 )  pt_reference = pt_surface
[57]1404
1405!
[97]1406!-- Reference value has to be used in buoyancy terms
1407    IF ( pt_reference /= 9999999.9 )  use_reference = .TRUE.
1408
1409!
1410!-- Sign of buoyancy/stability terms
1411    IF ( ocean )  atmos_ocean_sign = -1.0
1412
1413!
[108]1414!-- Ocean version must use flux boundary conditions at the top
1415    IF ( ocean .AND. .NOT. use_top_fluxes )  THEN
[215]1416       message_string = 'use_top_fluxes must be .TRUE. in ocean version'
[226]1417       CALL message( 'check_parameters', 'PA0042', 1, 2, 0, 6, 0 )
[108]1418    ENDIF
[97]1419
1420!
[1]1421!-- In case of a given slope, compute the relevant quantities
1422    IF ( alpha_surface /= 0.0 )  THEN
1423       IF ( ABS( alpha_surface ) > 90.0 )  THEN
[215]1424          WRITE( message_string, * ) 'ABS( alpha_surface = ', alpha_surface, &
1425                                     ' ) must be < 90.0'
[226]1426          CALL message( 'check_parameters', 'PA0043', 1, 2, 0, 6, 0 )
[1]1427       ENDIF
1428       sloping_surface = .TRUE.
1429       cos_alpha_surface = COS( alpha_surface / 180.0 * pi )
1430       sin_alpha_surface = SIN( alpha_surface / 180.0 * pi )
1431    ENDIF
1432
1433!
1434!-- Check time step and cfl_factor
1435    IF ( dt /= -1.0 )  THEN
1436       IF ( dt <= 0.0  .AND.  dt /= -1.0 )  THEN
[215]1437          WRITE( message_string, * ) 'dt = ', dt , ' <= 0.0'
[226]1438          CALL message( 'check_parameters', 'PA0044', 1, 2, 0, 6, 0 )
[1]1439       ENDIF
1440       dt_3d = dt
1441       dt_fixed = .TRUE.
1442    ENDIF
1443
1444    IF ( cfl_factor <= 0.0  .OR.  cfl_factor > 1.0 )  THEN
1445       IF ( cfl_factor == -1.0 )  THEN
[1001]1446          IF ( timestep_scheme == 'runge-kutta-2' )  THEN
[1]1447             cfl_factor = 0.8
[1001]1448          ELSEIF ( timestep_scheme == 'runge-kutta-3' )  THEN
1449             cfl_factor = 0.9
[1]1450          ELSE
[1001]1451             cfl_factor = 0.9
[1]1452          ENDIF
1453       ELSE
[215]1454          WRITE( message_string, * ) 'cfl_factor = ', cfl_factor, &
1455                 ' out of range & 0.0 < cfl_factor <= 1.0 is required'
[226]1456          CALL message( 'check_parameters', 'PA0045', 1, 2, 0, 6, 0 )
[1]1457       ENDIF
1458    ENDIF
1459
1460!
1461!-- Store simulated time at begin
1462    simulated_time_at_begin = simulated_time
1463
1464!
[291]1465!-- Store reference time for coupled runs and change the coupling flag,
1466!-- if ...
1467    IF ( simulated_time == 0.0 )  THEN
1468       IF ( coupling_start_time == 0.0 )  THEN
1469          time_since_reference_point = 0.0
1470       ELSEIF ( time_since_reference_point < 0.0 )  THEN
1471          run_coupled = .FALSE.
1472       ENDIF
1473    ENDIF
1474
1475!
[1]1476!-- Set wind speed in the Galilei-transformed system
1477    IF ( galilei_transformation )  THEN
[1053]1478       IF ( use_ug_for_galilei_tr .AND.                  &
1479            ug_vertical_gradient_level(1) == 0.0  .AND.  &
1480            ug_vertical_gradient(1) == 0.0  .AND.        & 
1481            vg_vertical_gradient_level(1) == 0.0  .AND.  &
1482            vg_vertical_gradient(1) == 0.0 )  THEN
[866]1483          u_gtrans = ug_surface * 0.6
1484          v_gtrans = vg_surface * 0.6
[1053]1485       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1486                ( ug_vertical_gradient_level(1) /= 0.0  .OR.  &
1487                ug_vertical_gradient(1) /= 0.0 ) )  THEN
[215]1488          message_string = 'baroclinicity (ug) not allowed simultaneously' // &
1489                           ' with galilei transformation'
[226]1490          CALL message( 'check_parameters', 'PA0046', 1, 2, 0, 6, 0 )
[1053]1491       ELSEIF ( use_ug_for_galilei_tr  .AND.                  &
1492                ( vg_vertical_gradient_level(1) /= 0.0  .OR.  &
1493                vg_vertical_gradient(1) /= 0.0 ) )  THEN
[215]1494          message_string = 'baroclinicity (vg) not allowed simultaneously' // &
1495                           ' with galilei transformation'
[226]1496          CALL message( 'check_parameters', 'PA0047', 1, 2, 0, 6, 0 )
[1]1497       ELSE
[215]1498          message_string = 'variable translation speed used for galilei-' // &
1499             'transformation, which may cause & instabilities in stably ' // &
1500             'stratified regions'
[226]1501          CALL message( 'check_parameters', 'PA0048', 0, 1, 0, 6, 0 )
[1]1502       ENDIF
1503    ENDIF
1504
1505!
1506!-- In case of using a prandtl-layer, calculated (or prescribed) surface
1507!-- fluxes have to be used in the diffusion-terms
1508    IF ( prandtl_layer )  use_surface_fluxes = .TRUE.
1509
1510!
1511!-- Check boundary conditions and set internal variables:
1512!-- Lateral boundary conditions
[73]1513    IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
[978]1514         bc_lr /= 'radiation/dirichlet' .AND. bc_lr /= 'dirichlet/neumann' &
1515         .AND. bc_lr /= 'neumann/dirichlet' )  THEN
[215]1516       message_string = 'unknown boundary condition: bc_lr = "' // &
1517                        TRIM( bc_lr ) // '"'
[226]1518       CALL message( 'check_parameters', 'PA0049', 1, 2, 0, 6, 0 )
[1]1519    ENDIF
[73]1520    IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
[978]1521         bc_ns /= 'radiation/dirichlet' .AND. bc_ns /= 'dirichlet/neumann' &
1522         .AND. bc_ns /= 'neumann/dirichlet' )  THEN
[215]1523       message_string = 'unknown boundary condition: bc_ns = "' // &
1524                        TRIM( bc_ns ) // '"'
[226]1525       CALL message( 'check_parameters', 'PA0050', 1, 2, 0, 6, 0 )
[1]1526    ENDIF
1527
1528!
[366]1529!-- Internal variables used for speed optimization in if clauses
[707]1530    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
1531    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
1532    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
[978]1533    IF ( bc_lr == 'dirichlet/neumann' )    bc_lr_dirneu = .TRUE.
1534    IF ( bc_lr == 'neumann/dirichlet' )    bc_lr_neudir = .TRUE.
[707]1535    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
1536    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
1537    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
[978]1538    IF ( bc_ns == 'dirichlet/neumann' )    bc_ns_dirneu = .TRUE.
1539    IF ( bc_ns == 'neumann/dirichlet' )    bc_ns_neudir = .TRUE.
[366]1540
1541!
[1]1542!-- Non-cyclic lateral boundaries require the multigrid method and Piascek-
[667]1543!-- Willimas or Wicker - Skamarock advection scheme. Several schemes
1544!-- and tools do not work with non-cyclic boundary conditions.
[1]1545    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
1546       IF ( psolver /= 'multigrid' )  THEN
[215]1547          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1548                           'psolver = "' // TRIM( psolver ) // '"'
[226]1549          CALL message( 'check_parameters', 'PA0051', 1, 2, 0, 6, 0 )
[1]1550       ENDIF
[667]1551       IF ( momentum_advec /= 'pw-scheme' .AND. &
1552            momentum_advec /= 'ws-scheme')  THEN
[215]1553          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1554                           'momentum_advec = "' // TRIM( momentum_advec ) // '"'
[226]1555          CALL message( 'check_parameters', 'PA0052', 1, 2, 0, 6, 0 )
[1]1556       ENDIF
[667]1557       IF ( scalar_advec /= 'pw-scheme' .AND. &
1558            scalar_advec /= 'ws-scheme' )  THEN
[215]1559          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1560                           'scalar_advec = "' // TRIM( scalar_advec ) // '"'
[226]1561          CALL message( 'check_parameters', 'PA0053', 1, 2, 0, 6, 0 )
[1]1562       ENDIF
1563       IF ( galilei_transformation )  THEN
[215]1564          message_string = 'non-cyclic lateral boundaries do not allow ' // &
1565                           'galilei_transformation = .T.'
[226]1566          CALL message( 'check_parameters', 'PA0054', 1, 2, 0, 6, 0 )
[1]1567       ENDIF
1568    ENDIF
1569
1570!
1571!-- Bottom boundary condition for the turbulent Kinetic energy
1572    IF ( bc_e_b == 'neumann' )  THEN
1573       ibc_e_b = 1
1574    ELSEIF ( bc_e_b == '(u*)**2+neumann' )  THEN
1575       ibc_e_b = 2
[1015]1576       IF ( prandtl_layer )  THEN
1577          message_string = 'adjust mixing length = FALSE and bc_e_b = "' // &
[215]1578                           TRIM( bc_e_b ) // '"'
[226]1579          CALL message( 'check_parameters', 'PA0056', 0, 1, 0, 6, 0 )
[1]1580       ENDIF
1581       IF ( .NOT. prandtl_layer )  THEN
1582          bc_e_b = 'neumann'
1583          ibc_e_b = 1
[215]1584          message_string = 'boundary condition bc_e_b changed to "' // &
1585                           TRIM( bc_e_b ) // '"'
[226]1586          CALL message( 'check_parameters', 'PA0057', 0, 1, 0, 6, 0 )
[1]1587       ENDIF
1588    ELSE
[215]1589       message_string = 'unknown boundary condition: bc_e_b = "' // &
1590                        TRIM( bc_e_b ) // '"'
[226]1591       CALL message( 'check_parameters', 'PA0058', 1, 2, 0, 6, 0 )
[1]1592    ENDIF
1593
1594!
1595!-- Boundary conditions for perturbation pressure
1596    IF ( bc_p_b == 'dirichlet' )  THEN
1597       ibc_p_b = 0
1598    ELSEIF ( bc_p_b == 'neumann' )  THEN
1599       ibc_p_b = 1
1600    ELSEIF ( bc_p_b == 'neumann+inhomo' )  THEN
1601       ibc_p_b = 2
1602    ELSE
[215]1603       message_string = 'unknown boundary condition: bc_p_b = "' // &
1604                        TRIM( bc_p_b ) // '"'
[226]1605       CALL message( 'check_parameters', 'PA0059', 1, 2, 0, 6, 0 )
[1]1606    ENDIF
1607    IF ( ibc_p_b == 2  .AND.  .NOT. prandtl_layer )  THEN
[215]1608       message_string = 'boundary condition: bc_p_b = "' // TRIM( bc_p_b ) // &
1609                        '" not allowed with prandtl_layer = .FALSE.'
[226]1610       CALL message( 'check_parameters', 'PA0060', 1, 2, 0, 6, 0 )
[1]1611    ENDIF
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
3438!-- data from prerun
3439    IF ( turbulent_inflow  .AND.  initializing_actions /= 'cyclic_fill' )  THEN
3440       message_string = 'turbulent_inflow = .T. requires ' // &
3441                        'initializing_actions = ''cyclic_fill'' '
3442       CALL message( 'check_parameters', 'PA0055', 1, 2, 0, 6, 0 )
3443    ENDIF
3444
3445!
[151]3446!-- In case of turbulent inflow calculate the index of the recycling plane
3447    IF ( turbulent_inflow )  THEN
3448       IF ( recycling_width == 9999999.9 )  THEN
3449!
3450!--       Set the default value for the width of the recycling domain
3451          recycling_width = 0.1 * nx * dx
3452       ELSE
3453          IF ( recycling_width < dx  .OR.  recycling_width > nx * dx )  THEN
[215]3454             WRITE( message_string, * )  'illegal value for recycling_width:', &
3455                                         ' ', recycling_width
[226]3456             CALL message( 'check_parameters', 'PA0134', 1, 2, 0, 6, 0 )
[151]3457          ENDIF
3458       ENDIF
3459!
3460!--    Calculate the index
3461       recycling_plane = recycling_width / dx
3462    ENDIF
3463
3464!
[1]3465!-- Check random generator
3466    IF ( random_generator /= 'system-specific'  .AND. &
3467         random_generator /= 'numerical-recipes' )  THEN
[215]3468       message_string = 'unknown random generator: random_generator = "' // &
3469                        TRIM( random_generator ) // '"'
[226]3470       CALL message( 'check_parameters', 'PA0135', 1, 2, 0, 6, 0 )
[1]3471    ENDIF
3472
3473!
3474!-- Determine damping level index for 1D model
3475    IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 )  THEN
3476       IF ( damp_level_1d == -1.0 )  THEN
3477          damp_level_1d     = zu(nzt+1)
3478          damp_level_ind_1d = nzt + 1
3479       ELSEIF ( damp_level_1d < 0.0  .OR.  damp_level_1d > zu(nzt+1) )  THEN
[215]3480          WRITE( message_string, * )  'damp_level_1d = ', damp_level_1d, &
3481                 ' must be > 0.0 and < ', zu(nzt+1), '(zu(nzt+1))'
[226]3482          CALL message( 'check_parameters', 'PA0136', 1, 2, 0, 6, 0 )
[1]3483       ELSE
3484          DO  k = 1, nzt+1
3485             IF ( damp_level_1d <= zu(k) )  THEN
3486                damp_level_ind_1d = k
3487                EXIT
3488             ENDIF
3489          ENDDO
3490       ENDIF
3491    ENDIF
[215]3492
[1]3493!
3494!-- Check some other 1d-model parameters
3495    IF ( TRIM( mixing_length_1d ) /= 'as_in_3d_model'  .AND. &
3496         TRIM( mixing_length_1d ) /= 'blackadar' )  THEN
[215]3497       message_string = 'mixing_length_1d = "' // TRIM( mixing_length_1d ) // &
3498                        '" is unknown'
[226]3499       CALL message( 'check_parameters', 'PA0137', 1, 2, 0, 6, 0 )
[1]3500    ENDIF
3501    IF ( TRIM( dissipation_1d ) /= 'as_in_3d_model'  .AND. &
3502         TRIM( dissipation_1d ) /= 'detering' )  THEN
[215]3503       message_string = 'dissipation_1d = "' // TRIM( dissipation_1d ) // &
3504                        '" is unknown'
[226]3505       CALL message( 'check_parameters', 'PA0138', 1, 2, 0, 6, 0 )
[1]3506    ENDIF
3507
3508!
3509!-- Set time for the next user defined restart (time_restart is the
3510!-- internal parameter for steering restart events)
3511    IF ( restart_time /= 9999999.9 )  THEN
[291]3512       IF ( restart_time > time_since_reference_point )  THEN
3513          time_restart = restart_time
3514       ENDIF
[1]3515    ELSE
3516!
3517!--    In case of a restart run, set internal parameter to default (no restart)
3518!--    if the NAMELIST-parameter restart_time is omitted
3519       time_restart = 9999999.9
3520    ENDIF
3521
3522!
3523!-- Set default value of the time needed to terminate a model run
3524    IF ( termination_time_needed == -1.0 )  THEN
3525       IF ( host(1:3) == 'ibm' )  THEN
3526          termination_time_needed = 300.0
3527       ELSE
3528          termination_time_needed = 35.0
3529       ENDIF
3530    ENDIF
3531
3532!
3533!-- Check the time needed to terminate a model run
3534    IF ( host(1:3) == 't3e' )  THEN
3535!
3536!--    Time needed must be at least 30 seconds on all CRAY machines, because
3537!--    MPP_TREMAIN gives the remaining CPU time only in steps of 30 seconds
3538       IF ( termination_time_needed <= 30.0 )  THEN
[215]3539          WRITE( message_string, * )  'termination_time_needed = ', &
3540                 termination_time_needed, ' must be > 30.0 on host "', &
3541                 TRIM( host ), '"'
[226]3542          CALL message( 'check_parameters', 'PA0139', 1, 2, 0, 6, 0 )
[1]3543       ENDIF
3544    ELSEIF ( host(1:3) == 'ibm' )  THEN
3545!
3546!--    On IBM-regatta machines the time should be at least 300 seconds,
3547!--    because the job time consumed before executing palm (for compiling,
3548!--    copying of files, etc.) has to be regarded
3549       IF ( termination_time_needed < 300.0 )  THEN
[215]3550          WRITE( message_string, * )  'termination_time_needed = ', &
3551                 termination_time_needed, ' should be >= 300.0 on host "', &
3552                 TRIM( host ), '"'
[226]3553          CALL message( 'check_parameters', 'PA0140', 1, 2, 0, 6, 0 )
[1]3554       ENDIF
3555    ENDIF
3556
[217]3557!
[240]3558!-- Check pressure gradient conditions
3559    IF ( dp_external .AND. conserve_volume_flow )  THEN
[388]3560       WRITE( message_string, * )  'Both dp_external and conserve_volume_flo', &
3561            'w are .TRUE. but one of them must be .FALSE.'
[240]3562       CALL message( 'check_parameters', 'PA0150', 1, 2, 0, 6, 0 )
3563    ENDIF
3564    IF ( dp_external )  THEN
3565       IF ( dp_level_b < zu(nzb) .OR. dp_level_b > zu(nzt) )  THEN
3566          WRITE( message_string, * )  'dp_level_b = ', dp_level_b, ' is out ', &
3567               ' of range'
3568          CALL message( 'check_parameters', 'PA0151', 1, 2, 0, 6, 0 )
3569       ENDIF
3570       IF ( .NOT. ANY( dpdxy /= 0.0 ) )  THEN
[388]3571          WRITE( message_string, * )  'dp_external is .TRUE. but dpdxy is ze', &
3572               'ro, i.e. the external pressure gradient & will not be applied'
[240]3573          CALL message( 'check_parameters', 'PA0152', 0, 1, 0, 6, 0 )
3574       ENDIF
3575    ENDIF
3576    IF ( ANY( dpdxy /= 0.0 ) .AND. .NOT. dp_external )  THEN
3577       WRITE( message_string, * )  'dpdxy is nonzero but dp_external is ', &
3578            '.FALSE., i.e. the external pressure gradient & will not be applied'
3579       CALL message( 'check_parameters', 'PA0153', 0, 1, 0, 6, 0 )
3580    ENDIF
[241]3581    IF ( conserve_volume_flow )  THEN
3582       IF ( TRIM( conserve_volume_flow_mode ) == 'default' )  THEN
[667]3583
3584          conserve_volume_flow_mode = 'initial_profiles'
3585
[241]3586       ELSEIF ( TRIM( conserve_volume_flow_mode ) /= 'initial_profiles' .AND.  &
3587            TRIM( conserve_volume_flow_mode ) /= 'inflow_profile' .AND.  &
3588            TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' )  THEN
3589          WRITE( message_string, * )  'unknown conserve_volume_flow_mode: ', &
3590               conserve_volume_flow_mode
3591          CALL message( 'check_parameters', 'PA0154', 1, 2, 0, 6, 0 )
3592       ENDIF
[667]3593       IF ( (bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic')  .AND. &
3594          TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' )  THEN
3595          WRITE( message_string, * )  'non-cyclic boundary conditions ', &
3596               'require  conserve_volume_flow_mode = ''initial_profiles'''
[241]3597          CALL message( 'check_parameters', 'PA0155', 1, 2, 0, 6, 0 )
3598       ENDIF
3599       IF ( bc_lr == 'cyclic'  .AND.  bc_ns == 'cyclic'  .AND.  &
3600            TRIM( conserve_volume_flow_mode ) == 'inflow_profile' )  THEN
3601          WRITE( message_string, * )  'cyclic boundary conditions ', &
[667]3602               'require conserve_volume_flow_mode = ''initial_profiles''', &
[241]3603               ' or ''bulk_velocity'''
3604          CALL message( 'check_parameters', 'PA0156', 1, 2, 0, 6, 0 )
3605       ENDIF
3606    ENDIF
3607    IF ( ( u_bulk /= 0.0 .OR. v_bulk /= 0.0 ) .AND.  &
3608         ( .NOT. conserve_volume_flow .OR.  &
3609         TRIM( conserve_volume_flow_mode ) /= 'bulk_velocity' ) )  THEN
3610       WRITE( message_string, * )  'nonzero bulk velocity requires ', &
[667]3611            'conserve_volume_flow = .T. and ', &
[241]3612            'conserve_volume_flow_mode = ''bulk_velocity'''
3613       CALL message( 'check_parameters', 'PA0157', 1, 2, 0, 6, 0 )
3614    ENDIF
[240]3615
3616!
[264]3617!-- Check particle attributes
3618    IF ( particle_color /= 'none' )  THEN
3619       IF ( particle_color /= 'absuv'  .AND.  particle_color /= 'pt*'  .AND.  &
3620            particle_color /= 'z' )  THEN
3621          message_string = 'illegal value for parameter particle_color: ' // &
3622                           TRIM( particle_color)
3623          CALL message( 'check_parameters', 'PA0313', 1, 2, 0, 6, 0 )
3624       ELSE
3625          IF ( color_interval(2) <= color_interval(1) )  THEN
3626             message_string = 'color_interval(2) <= color_interval(1)'
3627             CALL message( 'check_parameters', 'PA0315', 1, 2, 0, 6, 0 )
3628          ENDIF
3629       ENDIF
3630    ENDIF
3631
3632    IF ( particle_dvrpsize /= 'none' )  THEN
3633       IF ( particle_dvrpsize /= 'absw' )  THEN
3634          message_string = 'illegal value for parameter particle_dvrpsize:' // &
3635                           ' ' // TRIM( particle_color)
3636          CALL message( 'check_parameters', 'PA0314', 1, 2, 0, 6, 0 )
3637       ELSE
3638          IF ( dvrpsize_interval(2) <= dvrpsize_interval(1) )  THEN
3639             message_string = 'dvrpsize_interval(2) <= dvrpsize_interval(1)'
3640             CALL message( 'check_parameters', 'PA0316', 1, 2, 0, 6, 0 )
3641          ENDIF
3642       ENDIF
3643    ENDIF
3644
3645!
[217]3646!-- Check &userpar parameters
3647    CALL user_check_parameters
[1]3648
[217]3649
[667]3650
[1]3651 END SUBROUTINE check_parameters
Note: See TracBrowser for help on using the repository browser.