Index: palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 216)
+++ palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 217)
@@ -11,8 +11,10 @@
 User can add additional routines in files user_additional_routines.f90
 
+User can check user parameters and deduce further quantities in user_check_parameters
+
 check_for_restart, check_parameters, data_output_dvrp, init_dvrp, init_pegrid, local_stop, modules, package_parin, palm, surface_coupler, timestep, user_additional_routines
 Makefile, mrun, mbuild, subjob
 
-New: init_coupling
+New: init_coupling, user_check_parameters
 
 
@@ -41,4 +43,7 @@
 Origin of the xy-coordinate system shifted from the center of the first
 grid cell (indices i=0, j=0) to the south-left corner of this cell. (netcdf)
+
+Topography definition according to new user parameter topography_grid_convention
+(init_grid, modules, user_header, user_init_grid, user_parin)
 
 Makefile, mbuild, mrun, advec_s_bc, check_parameters, local_stop, modules, netcdf, read_var_list, read_3d_binary, user_read_restart_data
Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 216)
+++ palm/trunk/SOURCE/Makefile	(revision 217)
@@ -76,6 +76,6 @@
 	timestep_scheme_steering.f90 transpose.f90 user_3d_data_averaging.f90 \
 	user_actions.f90 user_additional_routines.f90 user_advec_particles.f90 \
-	user_check_data_output.f90 \
-	user_check_data_output_pr.f90 user_data_output_2d.f90 \
+	user_check_data_output.f90 user_check_data_output_pr.f90 \
+	user_check_parameters.f90 user_data_output_2d.f90 \
 	user_data_output_3d.f90 user_data_output_dvrp.f90 \
 	user_define_netcdf_grid.f90 user_dvrp_coltab.f90 user_header.f90 \
@@ -116,6 +116,6 @@
         timestep.o timestep_scheme_steering.o transpose.o \
 	user_3d_data_averaging.o user_actions.o user_additional_routines.o \
-	user_advec_particles.o \
-	user_check_data_output.o user_check_data_output_pr.o \
+	user_advec_particles.o user_check_data_output.o \
+	user_check_data_output_pr.o user_check_parameters.o \
 	user_data_output_2d.o user_data_output_3d.o user_data_output_dvrp.o \
 	user_define_netcdf_grid.o user_dvrp_coltab.o user_header.o \
@@ -271,4 +271,5 @@
 user_check_data_output.o: modules.o user_module.o
 user_check_data_output_pr.o: modules.o user_module.o
+user_check_parameters.o: modules.o user_module.o
 user_data_output_2d.o: modules.o user_module.o
 user_data_output_3d.o: modules.o user_module.o
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 216)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 217)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! +user_check_parameters
 ! Output of messages replaced by message handling routine.
 ! Implementation of an MPI-1 coupling: replaced myid with target_id, 
@@ -2900,4 +2901,8 @@
     ENDIF
 
+!
+!-- Check &userpar parameters
+    CALL user_check_parameters
+
 
  END SUBROUTINE check_parameters
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 216)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 217)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! +topography_grid_convention
 !
 ! Former revisions:
@@ -372,7 +372,5 @@
 
 !
-!--       Set the actual total size of the building. Due to the staggered grid,
-!--       the building will be displaced by -0.5dx in x-direction and by -0.5dy
-!--       in y-direction compared to the scalar grid.
+!--       Define the building.
           nzb_local = 0
           nzb_local(bys:byn,bxl:bxr) = bh
@@ -419,5 +417,5 @@
 !
 !--       The DEFAULT case is reached either if the parameter topography
-!--       contains a wrong character string or if the user has coded a special
+!--       contains a wrong character string or if the user has defined a special
 !--       case in the user interface. There, the subroutine user_init_grid 
 !--       checks which of these two conditions applies.
@@ -435,5 +433,5 @@
 !
 !-- Consistency checks and index array initialization are only required for
-!-- non-flat topography, also the initialization of topography heigth arrays
+!-- non-flat topography, also the initialization of topography height arrays
 !-- zu_s_inner and zw_w_inner
     IF ( TRIM( topography ) /= 'flat' )  THEN
@@ -472,26 +470,31 @@
        ENDIF
 
+       IF ( topography_grid_convention == 'cell_edge' )  THEN
 ! 
-!--    The array nzb_local as defined above describes the actual total size of
-!--    topography which is defined by u=0 on the topography walls in x-direction
-!--    and by v=0 on the topography walls in y-direction. However, PALM uses
-!--    individual arrays nzb_u|v|w|s_inner|outer that are based on nzb_s_inner.
-!--    Therefore, the extent of topography in nzb_local is now reduced by 1dx 
-!--    at the E topography walls and by 1dy at the N topography walls to form 
-!--    the basis for nzb_s_inner.
-       DO  j = -gls, ny + gls
-          DO  i = -gls, nx
-             nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j,i+1) )
-          ENDDO
-       ENDDO
-!--    apply cyclic boundary conditions in x-direction
-       nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1)
-       DO  i = -gls, nx + gls
-          DO  j = -gls, ny
-             nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j+1,i) )
-          ENDDO
-       ENDDO
-!--    apply cyclic boundary conditions in y-direction
-       nzb_local(ny+1:ny+gls,:) = nzb_local(0:gls-1,:)
+!--       The array nzb_local as defined using the 'cell_edge' convention 
+!--       describes the actual total size of topography which is defined at the 
+!--       cell edges where u=0 on the topography walls in x-direction and v=0 
+!--       on the topography walls in y-direction. However, PALM uses individual
+!--       arrays nzb_u|v|w|s_inner|outer that are based on nzb_s_inner.
+!--       Therefore, the extent of topography in nzb_local is now reduced by 
+!--       1dx at the E topography walls and by 1dy at the N topography walls 
+!--       to form the basis for nzb_s_inner.
+          DO  j = -gls, ny + gls
+             DO  i = -gls, nx
+                nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j,i+1) )
+             ENDDO
+          ENDDO
+!--       apply cyclic boundary conditions in x-direction 
+!(ist das erforderlich? Ursache von Seung Bus Fehler?)
+          nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1)
+          DO  i = -gls, nx + gls
+             DO  j = -gls, ny
+                nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j+1,i) )
+             ENDDO
+          ENDDO
+!--       apply cyclic boundary conditions in y-direction
+!(ist das erforderlich? Ursache von Seung Bus Fehler?)
+          nzb_local(ny+1:ny+gls,:) = nzb_local(0:gls-1,:)
+       ENDIF
 
 !
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 216)
+++ palm/trunk/SOURCE/modules.f90	(revision 217)
@@ -5,4 +5,5 @@
 ! Actual revisions:
 ! -----------------
+! +topography_grid_convention
 ! some dvrp-variables changed to single precision, variables for dvrp-mode
 ! pathlines added, +target_id, abort_mode, message_string
@@ -263,4 +264,5 @@
     CHARACTER (LEN=8)    ::  run_date, run_time
     CHARACTER (LEN=9)    ::  simulated_time_chr
+    CHARACTER (LEN=11)   ::  topography_grid_convention = ' '
     CHARACTER (LEN=12)   ::  version = ' ', revision = ' '
     CHARACTER (LEN=16)   ::  loop_optimization = 'default', &
Index: palm/trunk/SOURCE/user_check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/user_check_parameters.f90	(revision 217)
+++ palm/trunk/SOURCE/user_check_parameters.f90	(revision 217)
@@ -0,0 +1,63 @@
+ SUBROUTINE user_check_parameters
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Initial version
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Check &userpar control parameters and deduce further quantities.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE user
+
+    IMPLICIT NONE
+
+!
+!-- In case of non-flat topography, check whether the convention how to 
+!-- define the topography grid has been set correctly, or whether the default
+!-- is applicable. If this is not possible, abort.
+    IF ( TRIM( topography ) /= 'flat' )  THEN
+       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
+          IF ( TRIM( topography ) /= 'single_building' .AND.  &
+               TRIM( topography ) /= 'read_from_file' )  THEN
+!--          The default value is not applicable here, because it is only valid
+!--          for the two standard cases 'single_building' and 'read_from_file'
+!--          defined in init_grid.
+             message_string = 'The value for "topography_grid_convention" '//  &
+                  'is not set. Its default value is & only valid for '//  &
+                  '"topography" = ''single_building'' or ''read_from_file''.'//&
+                  ' & Choose ''cell_edge'' or ''cell_center''.'
+             CALL handle_palm_message( 'user_check_parameters', 'UI0001', 1,  &
+                  2, 0, 6, 0 )
+          ELSE
+!--          The default value is applicable here.
+!--          Set convention according to topography.
+             IF ( TRIM( topography ) == 'single_building' )  THEN
+                topography_grid_convention = 'cell_edge'
+             ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
+                topography_grid_convention = 'cell_center'
+             ENDIF
+          ENDIF
+       ELSEIF ( TRIM( topography_grid_convention ) /= 'cell_edge' .AND.  &
+                TRIM( topography_grid_convention ) /= 'cell_center' )  THEN
+          message_string = 'The value for "topography_grid_convention" is '// &
+               'not recognized. & Choose ''cell_edge'' or ''cell_center''.'
+          CALL handle_palm_message( 'user_check_parameters', 'UI0002', 1,  &
+               2, 0, 6, 0 )
+       ENDIF
+    ENDIF
+
+!
+!-- Here the user may add code to check the validity of further &userpar 
+!-- control parameters or deduce further quantities.
+
+
+ END SUBROUTINE user_check_parameters
+
Index: palm/trunk/SOURCE/user_header.f90
===================================================================
--- palm/trunk/SOURCE/user_header.f90	(revision 216)
+++ palm/trunk/SOURCE/user_header.f90	(revision 217)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! +topography_grid_convention
 ! Former file user_interface.f90 split into one file per subroutine
 !
@@ -15,4 +16,5 @@
 !------------------------------------------------------------------------------!
 
+    USE control_parameters
     USE statistics
     USE user
@@ -41,5 +43,18 @@
     ENDIF
 
-
+    IF ( TRIM( topography ) /= 'flat' )  THEN
+       WRITE ( io, 300 )
+       IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
+          IF ( TRIM( topography ) == 'single_building' )  THEN
+             WRITE ( io, 301 )
+          ELSEIF ( TRIM( topography ) == 'read_from_file' )  THEN
+             WRITE ( io, 302 )
+          ENDIF
+       ELSEIF ( TRIM( topography_grid_convention ) == 'cell_edge' )  THEN
+          WRITE ( io, 301 )
+       ELSEIF ( TRIM( topography_grid_convention ) == 'cell_center' )  THEN
+          WRITE ( io, 302 )
+       ENDIF
+    ENDIF
 
 !
@@ -51,4 +66,8 @@
 200 FORMAT (' Output of profiles and time series for following regions:' /)
 201 FORMAT (4X,'Region ',I1,':   ',A)
+300 FORMAT (' Topography grid definition convention:'/)
+301 FORMAT (' cell edge (staggered grid points'/  &
+            ' (u in x-direction, v in y-direction))' /)
+302 FORMAT (' cell center (scalar grid points)' /)
 
 
Index: palm/trunk/SOURCE/user_init_grid.f90
===================================================================
--- palm/trunk/SOURCE/user_init_grid.f90	(revision 216)
+++ palm/trunk/SOURCE/user_init_grid.f90	(revision 217)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! +topography_grid_convention
 ! Former file user_interface.f90 split into one file per subroutine
 !
@@ -41,6 +42,14 @@
        CASE ( 'user_defined_topography_1' )
 !
-!--       Here the user can define his own topography. After definition, please
-!--       remove the following three lines!
+!--       Here the user can define his own topography. 
+
+!
+!--       For each user-defined topography, the topography grid convention has 
+!--       to be explicitly set to either 'cell_edge' or 'cell_center'.
+!--       topography_grid_convention = 'cell_edge'     ! OR:
+!--       topography_grid_convention = 'cell_center'
+
+!
+!--       After definition, please remove the following three lines!
           PRINT*, '+++ user_init_grid: topography "', &
                topography, '" not available yet'
Index: palm/trunk/SOURCE/user_parin.f90
===================================================================
--- palm/trunk/SOURCE/user_parin.f90	(revision 216)
+++ palm/trunk/SOURCE/user_parin.f90	(revision 217)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! +topography_grid_convention
 ! Former file user_interface.f90 split into one file per subroutine
 !
@@ -27,5 +28,6 @@
 
 
-    NAMELIST /userpar/  data_output_pr_user, data_output_user, region
+    NAMELIST /userpar/  data_output_pr_user, data_output_user, region,  &
+                        topography_grid_convention
 
 !
