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

Last change on this file since 867 was 867, checked in by raasch, 12 years ago

last commit documented

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