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

Last change on this file since 771 was 771, checked in by heinze, 12 years ago

Output of liquid water potential temperature in case of cloud_physics=.T. enabled

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