Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 928)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 978)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: nzb_max is set to nzt at non-cyclic lateral boundaries
+! Bugfix: Set wall_flags_0 for inflow boundary
 !
 ! Former revisions:
@@ -608,5 +609,12 @@
 !-- Determine the maximum level of topography. Furthermore it is used for
 !-- steering the degradation of order of the applied advection scheme.
+!-- In case of non-cyclic lateral boundaries, the order of the advection
+!-- scheme is reduced at the lateral boundaries up to nzt.
     nzb_max = MAXVAL( nzb_local )
+    IF ( inflow_l .OR. outflow_l .OR. inflow_r .OR. outflow_r .OR.    &
+         inflow_n .OR. outflow_n .OR. inflow_s .OR. outflow_s )  THEN
+         nzb_max = nzt
+    ENDIF
+
 !
 !-- Consistency checks and index array initialization are only required for
@@ -1079,10 +1087,12 @@
 !--             scalar - x-direction
 !--             WS1 (0), WS3 (1), WS5 (2)
-                IF ( k <= nzb_s_inner(j,i+1) .OR. ( outflow_l .AND. i == nxl ) &
-                     .OR. ( outflow_r .AND. i == nxr ) )  THEN
+                IF ( k <= nzb_s_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )&
+                     .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r )       &
+                     .AND. i == nxr ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 0 )
                 ELSEIF ( k <= nzb_s_inner(j,i+2) .OR. k <= nzb_s_inner(j,i-1)  &
-                         .OR. ( outflow_r .AND. i == nxr-1 )                   &
-                         .OR. ( outflow_l .AND. i == nxlu  ) )  THEN
+                         .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) &
+                         .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu  ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 1 )
                 ELSE
@@ -1092,11 +1102,13 @@
 !--             scalar - y-direction
 !--             WS1 (3), WS3 (4), WS5 (5)
-                IF ( k <= nzb_s_inner(j+1,i) .OR. ( outflow_s .AND. j == nys ) &
-                     .OR. ( outflow_n .AND. j == nyn ) )  THEN
+                IF ( k <= nzb_s_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )&
+                     .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n )       &
+                     .AND. j == nyn ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 3 )
 !--             WS3
                 ELSEIF ( k <= nzb_s_inner(j+2,i) .OR. k <= nzb_s_inner(j-1,i)  &
-                        .OR. ( outflow_s .AND. j == nysv )                     &
-                        .OR. ( outflow_n .AND. j == nyn-1  ) )  THEN
+                         .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv  ) &
+                         .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 4 )
 !--             WS5
@@ -1135,22 +1147,28 @@
 !--             WS1 (9), WS3 (10), WS5 (11)
                 IF ( k <= nzb_u_inner(j,i+1)                                  &
-                     .OR. ( outflow_r .AND. i == nxr ) )  THEN
+                     .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu )     &
+                     .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr  )     &
+                   )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 )
                 ELSEIF ( k <= nzb_u_inner(j,i+2) .OR. k <= nzb_u_inner(j,i-1) &
-                         .OR. ( outflow_r .AND. i == nxr-1 )                  &
-                         .OR. ( outflow_l .AND. i == nxlu  ) )  THEN
+                         .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 )&
+                         .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu+1)&
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 10 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 11 )
                 ENDIF
+
 !
 !--             u component - y-direction
 !--             WS1 (12), WS3 (13), WS5 (14)
-                IF ( k <= nzb_u_inner(j+1,i) .OR. ( outflow_s .AND. j == nys ) &
-                    .OR. ( outflow_n .AND. j == nyn ) )  THEN
+                IF ( k <= nzb_u_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )&
+                     .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n )       &
+                     .AND. j == nyn ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 )
                 ELSEIF ( k <= nzb_u_inner(j+2,i) .OR. k <= nzb_u_inner(j-1,i)  &
-                    .OR. ( outflow_s .AND. j == nysv )                         &
-                    .OR. ( outflow_n .AND. j == nyn-1  ) )  THEN
+                         .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv  ) &
+                         .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 13 )
                 ELSE
@@ -1181,11 +1199,13 @@
 !--             v component - x-direction
 !--             WS1 (18), WS3 (19), WS5 (20)
-                IF ( k <= nzb_v_inner(j,i+1) .OR. ( outflow_l .AND. i == nxl ) &
-                    .OR. ( outflow_r .AND. i == nxr ) )  THEN
+                IF ( k <= nzb_v_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )&
+                     .AND. i == nxl ) .OR. (( inflow_r .OR. outflow_r )        &
+                     .AND. i == nxr ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 )
 !--             WS3
                 ELSEIF ( k <= nzb_v_inner(j,i+2) .OR. k <= nzb_v_inner(j,i-1)  &
-                    .OR. ( outflow_r .AND. i == nxr-1 )                        &
-                    .OR. ( outflow_l .AND. i == nxlu  ) )  THEN
+                         .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) &
+                         .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu  ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 19 )
                 ELSE
@@ -1196,9 +1216,12 @@
 !--             WS1 (21), WS3 (22), WS5 (23)
                 IF ( k <= nzb_v_inner(j+1,i)                                   &
-                     .OR. ( outflow_n .AND. j == nyn ) )  THEN
+                     .OR. ( ( inflow_s .OR. outflow_s ) .AND. i == nysv )      &
+                     .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn  )      &
+                   )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 )
                 ELSEIF ( k <= nzb_v_inner(j+2,i) .OR. k <= nzb_v_inner(j-1,i)  &
-                         .OR. ( outflow_s .AND. j == nysv )                    &
-                         .OR. ( outflow_n .AND. j == nyn-1  ) )  THEN
+                         .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv+1 )&
+                         .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1  )&
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 22 )
                 ELSE
@@ -1228,10 +1251,12 @@
 !--             w component - x-direction
 !--             WS1 (27), WS3 (28), WS5 (29)
-                IF ( k <= nzb_w_inner(j,i+1) .OR. ( outflow_l .AND. i == nxl ) &
-                    .OR. ( outflow_r .AND. i == nxr ) )  THEN
+                IF ( k <= nzb_w_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )&
+                     .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r )       &
+                     .AND. i == nxr ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 )
                 ELSEIF ( k <= nzb_w_inner(j,i+2) .OR. k <= nzb_w_inner(j,i-1)  &
-                         .OR. ( outflow_r .AND. i == nxr-1 )                   &
-                         .OR. ( outflow_l .AND. i == nxlu  ) )  THEN
+                         .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) &
+                         .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu  ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 28 )
                 ELSE
@@ -1241,10 +1266,12 @@
 !--             w component - y-direction
 !--             WS1 (30), WS3 (31), WS5 (32)
-                IF ( k <= nzb_w_inner(j+1,i) .OR. ( outflow_s .AND. j == nys ) &
-                     .OR. ( outflow_n .AND. j == nyn ) )  THEN
+                IF ( k <= nzb_w_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )&
+                     .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n )       &
+                     .AND. j == nyn ) )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 )
                 ELSEIF ( k <= nzb_w_inner(j+2,i) .OR. k <= nzb_w_inner(j-1,i)  &
-                         .OR. ( outflow_s .AND. j == nysv )                    &
-                         .OR. ( outflow_n .AND. j == nyn-1  ) )  THEN
+                         .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv  ) &
+                         .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) &
+                       )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 31 )
                 ELSE
