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

Last change on this file since 1053 was 1053, checked in by hoffmann, 12 years ago

two-moment cloud physics implemented

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