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

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

last commit documented

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