Index: palm/trunk/SOURCE/advec_s_up.f90
===================================================================
--- palm/trunk/SOURCE/advec_s_up.f90	(revision 2101)
+++ palm/trunk/SOURCE/advec_s_up.f90	(revision 2232)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! topography representation via flags
 ! 
 ! Former revisions:
@@ -104,6 +104,6 @@
 
        USE indices,                                                            &
-           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,&
-                  nzt
+           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,        &
+                  wall_flags_0
 
        USE kinds
@@ -128,5 +128,5 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             DO  k = nzb_s_inner(j,i)+1, nzt
+             DO  k = nzb+1, nzt
 !
 !--             x-direction
@@ -134,8 +134,12 @@
                 IF ( ukomp > 0.0_wp )  THEN
                    tend(k,j,i) = tend(k,j,i) - ukomp *                         &
-                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx
+                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ELSE
                    tend(k,j,i) = tend(k,j,i) - ukomp *                         &
-                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx
+                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ENDIF
 !
@@ -144,8 +148,12 @@
                 IF ( vkomp > 0.0_wp )  THEN
                    tend(k,j,i) = tend(k,j,i) - vkomp *                         &
-                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy
+                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ELSE
                    tend(k,j,i) = tend(k,j,i) - vkomp *                         &
-                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy
+                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ENDIF
 !
@@ -154,8 +162,12 @@
                 IF ( wkomp > 0.0_wp )  THEN
                    tend(k,j,i) = tend(k,j,i) - wkomp *                         &
-                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k)
+                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ELSE
                    tend(k,j,i) = tend(k,j,i) - wkomp *                         &
-                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1)
+                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
                 ENDIF
 
@@ -184,5 +196,5 @@
 
        USE indices,                                                            &
-           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzb_s_inner, nzt
+           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0
 
        USE kinds
@@ -206,5 +218,5 @@
 
 
-       DO  k = nzb_s_inner(j,i)+1, nzt
+       DO  k = nzb+1, nzt
 !
 !--       x-direction
@@ -212,8 +224,12 @@
           IF ( ukomp > 0.0_wp )  THEN
              tend(k,j,i) = tend(k,j,i) - ukomp *                               &
-                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx
+                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ELSE
              tend(k,j,i) = tend(k,j,i) - ukomp *                               &
-                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx
+                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ENDIF
 !
@@ -222,8 +238,12 @@
           IF ( vkomp > 0.0_wp )  THEN
              tend(k,j,i) = tend(k,j,i) - vkomp *                               &
-                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy
+                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ELSE
              tend(k,j,i) = tend(k,j,i) - vkomp *                               &
-                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy
+                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy     &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ENDIF
 !
@@ -232,8 +252,12 @@
           IF ( wkomp > 0.0_wp )  THEN
              tend(k,j,i) = tend(k,j,i) - wkomp *                               &
-                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k)
+                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ELSE
              tend(k,j,i) = tend(k,j,i) - wkomp *                               &
-                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1)
+                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) &
+                                      * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
           ENDIF
 
