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

Last change on this file since 809 was 809, checked in by maronga, 12 years ago

Bugfix: cpp directives .NOT., .AND. replaced by !,&&. Minor bugfixes in mrungui

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