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

Last change on this file since 681 was 681, checked in by gryschka, 13 years ago

last commit documented

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