Index: /palm/trunk/SOURCE/init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/init_grid.f90	(revision 2020)
+++ /palm/trunk/SOURCE/init_grid.f90	(revision 2021)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: setting Neumann boundary conditions for topography required for 
+! topography flags in multigrid_noopt solver
 ! 
 ! Former revisions:
@@ -211,9 +212,10 @@
                io_blocks, io_group, inflow_l, inflow_n, inflow_r, inflow_s,    &
                masking_method, maximum_grid_level, message_string,             &
-               momentum_advec, nest_domain, ocean, outflow_l, outflow_n,       &
+               momentum_advec, nest_domain, nest_bound_l, nest_bound_n,        &
+               nest_bound_r, nest_bound_s, ocean, outflow_l, outflow_n,        &
                outflow_r, outflow_s, psolver, scalar_advec, topography,        &
                topography_grid_convention, use_surface_fluxes, use_top_fluxes, &
-               wall_adjustment_factor 
-        
+               wall_adjustment_factor
+         
     USE grid_variables,                                                        &
         ONLY:  ddx, ddx2, ddx2_mg, ddy, ddy2, ddy2_mg, dx, dx2, dy, dy2, fwxm, &
@@ -1343,21 +1345,21 @@
 !--          Set non-cyclic boundary conditions on respective multigrid level
              IF ( .NOT. bc_ns_cyc )  THEN
-                IF ( nys == 0  )  THEN
+                IF ( inflow_s .OR. outflow_s .OR. nest_bound_s  )  THEN
                    nzb_tmp(-2,:) = nzb_tmp(0,:)
                    nzb_tmp(-1,:) = nzb_tmp(0,:)
                 ENDIF
-                IF ( nyn == ny )  THEN
-                   nzb_tmp(ny+2,:) = nzb_tmp(ny,:)
-                   nzb_tmp(ny+1,:) = nzb_tmp(ny,:)
+                IF ( inflow_n .OR. outflow_n .OR. nest_bound_n )  THEN
+                   nzb_tmp(nyn_l+2,:) = nzb_tmp(nyn_l,:)
+                   nzb_tmp(nyn_l+1,:) = nzb_tmp(nyn_l,:)
                 ENDIF
              ENDIF
              IF ( .NOT. bc_lr_cyc )  THEN
-                IF ( nxl == 0  )  THEN
+                IF ( inflow_l .OR. outflow_l .OR. nest_bound_l  )  THEN
                    nzb_tmp(:,-2) = nzb_tmp(:,0)
                    nzb_tmp(:,-1) = nzb_tmp(:,0)
                 ENDIF
-                IF ( nxr == nx )  THEN
-                   nzb_tmp(:,nx+1) = nzb_tmp(:,nx)    
-                   nzb_tmp(:,nx+2) = nzb_tmp(:,nx)      
+                IF ( inflow_r .OR. outflow_r .OR. nest_bound_r )  THEN
+                   nzb_tmp(:,nxr_l+1) = nzb_tmp(:,nxr_l)    
+                   nzb_tmp(:,nxr_l+2) = nzb_tmp(:,nxr_l)      
                 ENDIF        
              ENDIF
@@ -1420,5 +1422,5 @@
 !
 !-- Allocate flags needed for masking walls. Even though these flags are only
-!-- required in the ws-scheme, the arrays need to be allocated as they are 
+!-- required in the ws-scheme, the arrays need to be allocated here as they are 
 !-- used in OpenACC directives. 
     ALLOCATE( wall_flags_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                     &
@@ -1427,5 +1429,6 @@
     wall_flags_00 = 0
 !
-!-- Init flags for ws-scheme to degrade order near walls
+!-- Init flags for ws-scheme to degrade order of the numerics near walls, i.e. 
+!-- to decrease the numerical stencil appropriately.
     IF ( momentum_advec == 'ws-scheme'  .OR.  scalar_advec == 'ws-scheme'  .OR.&
          scalar_advec   == 'ws-scheme-mono' )  THEN
Index: /palm/trunk/SOURCE/poismg_mod.f90
===================================================================
--- /palm/trunk/SOURCE/poismg_mod.f90	(revision 2020)
+++ /palm/trunk/SOURCE/poismg_mod.f90	(revision 2021)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: restore nest_bound_(l/r/s/n) in case of mg_switch_to_pe0
 ! 
 ! Former revisions:
@@ -1607,10 +1607,18 @@
 
 !
-!--          For non-cyclic lateral boundary conditions, restore the
-!--          in-/outflow conditions
+!--          For non-cyclic lateral boundary conditions and in case of nesting, 
+!--          restore the in-/outflow conditions. 
              inflow_l  = .FALSE.;  inflow_r  = .FALSE.
              inflow_n  = .FALSE.;  inflow_s  = .FALSE.
              outflow_l = .FALSE.;  outflow_r = .FALSE.
              outflow_n = .FALSE.;  outflow_s = .FALSE.
+!
+!--          In case of nesting, restore lateral boundary conditions
+             IF ( nest_domain )  THEN
+                nest_bound_l = .FALSE.
+                nest_bound_r = .FALSE.
+                nest_bound_s = .FALSE.
+                nest_bound_n = .FALSE.      
+             ENDIF
 
              IF ( pleft == MPI_PROC_NULL )  THEN
Index: /palm/trunk/SOURCE/poismg_noopt.f90
===================================================================
--- /palm/trunk/SOURCE/poismg_noopt.f90	(revision 2020)
+++ /palm/trunk/SOURCE/poismg_noopt.f90	(revision 2021)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: restore nest_bound_(l/r/s/n) in case of mg_switch_to_pe0
 ! 
 ! Former revisions:
@@ -1561,10 +1561,18 @@
 
 !
-!--       For non-cyclic lateral boundary conditions, restore the
-!--       in-/outflow conditions
+!--       For non-cyclic lateral boundary conditions and in case of nesting, 
+!--       restore the in-/outflow conditions. 
           inflow_l  = .FALSE.;  inflow_r  = .FALSE.
           inflow_n  = .FALSE.;  inflow_s  = .FALSE.
           outflow_l = .FALSE.;  outflow_r = .FALSE.
           outflow_n = .FALSE.;  outflow_s = .FALSE.
+!
+!--       In case of nesting, restore lateral boundary conditions
+          IF ( nest_domain )  THEN
+             nest_bound_l = .FALSE.
+             nest_bound_r = .FALSE.
+             nest_bound_s = .FALSE.
+             nest_bound_n = .FALSE.      
+          ENDIF
 
           IF ( pleft == MPI_PROC_NULL )  THEN
