Index: /palm/trunk/SOURCE/calc_spectra.f90
===================================================================
--- /palm/trunk/SOURCE/calc_spectra.f90	(revision 706)
+++ /palm/trunk/SOURCE/calc_spectra.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -88,5 +89,5 @@
 !
 !--       Calculation of spectra works for cyclic boundary conditions only
-          IF ( bc_lr /= 'cyclic' )  THEN
+          IF ( .NOT. bc_lr_cyc )  THEN
 
              message_string = 'non-cyclic lateral boundaries along x do not'// &
@@ -119,5 +120,5 @@
 !
 !--       Calculation of spectra works for cyclic boundary conditions only
-          IF ( bc_ns /= 'cyclic' )  THEN
+          IF ( .NOT. bc_ns_cyc )  THEN
              IF ( myid == 0 )  THEN
                 message_string = 'non-cyclic lateral boundaries along y do' // &
Index: /palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- /palm/trunk/SOURCE/check_parameters.f90	(revision 706)
+++ /palm/trunk/SOURCE/check_parameters.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! setting of bc_lr/ns_dirrad/raddir
 !
 ! Former revisions:
@@ -1253,6 +1254,10 @@
 !
 !-- Internal variables used for speed optimization in if clauses
-    IF ( bc_lr /= 'cyclic' )  bc_lr_cyc = .FALSE.
-    IF ( bc_ns /= 'cyclic' )  bc_ns_cyc = .FALSE.
+    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
+    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
+    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
+    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
+    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
+    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
 
 !
Index: /palm/trunk/SOURCE/exchange_horiz.f90
===================================================================
--- /palm/trunk/SOURCE/exchange_horiz.f90	(revision 706)
+++ /palm/trunk/SOURCE/exchange_horiz.f90	(revision 707)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-!
+! grid_level directly used as index for MPI data type arrays,
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -55,19 +56,9 @@
     INTEGER, DIMENSION(MPI_STATUS_SIZE,4) ::  wait_stat
 #endif
-    INTEGER ::  i, nbgp_local
+    INTEGER ::  nbgp_local
     REAL, DIMENSION(nzb:nzt+1,nys-nbgp_local:nyn+nbgp_local, &
                     nxl-nbgp_local:nxr+nbgp_local) ::  ar
 
     CALL cpu_log( log_point_s(2), 'exchange_horiz', 'start' )
-
-!
-!-- In the Poisson multigrid solver arrays with coarser grids are used.
-!-- Set i appropriately, because the coarser grids have different
-!-- MPI datatypes type_xz, type_yz.
-    IF ( exchange_mg )  THEN
-       i = grid_level
-    ELSE
-       i = 0
-    END IF
 
 #if defined( __parallel )
@@ -79,5 +70,5 @@
 !--    One-dimensional decomposition along y, boundary values can be exchanged
 !--    within the PE memory
-       IF ( bc_lr == 'cyclic' )  THEN
+       IF ( bc_lr_cyc )  THEN
           ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr)
           ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-1)
@@ -90,13 +81,14 @@
 !--       Send left boundary, receive right one (synchronous)
           CALL MPI_SENDRECV(                                                   &
-                       ar(nzb,nys-nbgp_local,nxl),   1, type_yz(i), pleft,  0, &
-                       ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(i), pright, 0, &
-                       comm2d, status, ierr )
+              ar(nzb,nys-nbgp_local,nxl),   1, type_yz(grid_level), pleft,  0, &
+              ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(grid_level), pright, 0, &
+              comm2d, status, ierr )
 !
 !--       Send right boundary, receive left one (synchronous)
-          CALL MPI_SENDRECV(                                                   &
-            ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, type_yz(i), pright, 1, &
-            ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1, type_yz(i), pleft,  1, &
-                       comm2d, status, ierr )
+          CALL MPI_SENDRECV( ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, &
+                             type_yz(grid_level), pright, 1,             &
+                             ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1,   &
+                             type_yz(grid_level), pleft,  1,             &
+                             comm2d, status, ierr )
 
        ELSE
@@ -105,14 +97,14 @@
 !
 !--       Send left boundary, receive right one (asynchronous)
-          CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxl),   1, type_yz(i), pleft,  &
-                          0, comm2d, req(1), ierr )
-          CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(i), pright, &
-                          0, comm2d, req(2), ierr )
+          CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxl),   1, type_yz(grid_level), &
+                          pleft, 0, comm2d, req(1), ierr )
+          CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(grid_level), &
+                          pright, 0, comm2d, req(2), ierr )
 !
 !--       Send right boundary, receive left one (asynchronous)
           CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1,          &
-                          type_yz(i), pright, 1, comm2d, req(3), ierr )
+                          type_yz(grid_level), pright, 1, comm2d, req(3), ierr )
           CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1,          &
-                          type_yz(i), pleft,  1, comm2d, req(4), ierr )
+                          type_yz(grid_level), pleft,  1, comm2d, req(4), ierr )
 
           CALL MPI_WAITALL( 4, req, wait_stat, ierr )
@@ -127,5 +119,5 @@
 !--    One-dimensional decomposition along x, boundary values can be exchanged
 !--    within the PE memory
-       IF ( bc_ns == 'cyclic' )  THEN
+       IF ( bc_ns_cyc )  THEN
           ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:)
           ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:)
@@ -138,13 +130,14 @@
 !--       Send front boundary, receive rear one (synchronous)
           CALL MPI_SENDRECV(                                                   &
-                       ar(nzb,nys,nxl-nbgp_local),   1, type_xz(i), psouth, 0, &
-                       ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(i), pnorth, 0, &
-                       comm2d, status, ierr )
+              ar(nzb,nys,nxl-nbgp_local),   1, type_xz(grid_level), psouth, 0, &
+              ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(grid_level), pnorth, 0, &
+              comm2d, status, ierr )
 !
 !--       Send rear boundary, receive front one (synchronous)
-          CALL MPI_SENDRECV(                                                   &
-            ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, type_xz(i), pnorth, 1, &
-            ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1, type_xz(i), psouth, 1, &
-            comm2d, status, ierr )
+          CALL MPI_SENDRECV( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, &
+                             type_xz(grid_level), pnorth, 1,             &
+                             ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1, &
+                             type_xz(grid_level), psouth, 1,             &
+                             comm2d, status, ierr )
 
        ELSE
@@ -153,14 +146,14 @@
 !
 !--       Send front boundary, receive rear one (asynchronous)
-          CALL MPI_ISEND( ar(nzb,nys,nxl-nbgp_local),   1, type_xz(i), psouth, &
-                          0, comm2d, req(1), ierr )
-          CALL MPI_IRECV( ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(i), pnorth, &
-                          0, comm2d, req(2), ierr )
+          CALL MPI_ISEND( ar(nzb,nys,nxl-nbgp_local),   1, type_xz(grid_level), &
+                          psouth, 0, comm2d, req(1), ierr )
+          CALL MPI_IRECV( ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(grid_level), &
+                          pnorth, 0, comm2d, req(2), ierr )
 !
 !--       Send rear boundary, receive front one (asynchronous)
           CALL MPI_ISEND( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1,          &
-                          type_xz(i), pnorth, 1, comm2d, req(3), ierr )
+                          type_xz(grid_level), pnorth, 1, comm2d, req(3), ierr )
           CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1,          &
-                          type_xz(i), psouth, 1, comm2d, req(4), ierr )
+                          type_xz(grid_level), psouth, 1, comm2d, req(4), ierr )
 
           CALL MPI_WAITALL( 4, req, wait_stat, ierr )
Index: /palm/trunk/SOURCE/exchange_horiz_2d.f90
===================================================================
--- /palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 706)
+++ /palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -104,10 +105,10 @@
 !
 !-- Lateral boundary conditions in the non-parallel case
-    IF ( bc_lr == 'cyclic' )  THEN
-       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
-       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
-    ENDIF
-
-    IF ( bc_ns == 'cyclic' )  THEN
+    IF ( bc_lr_cyc )  THEN
+       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
+       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
+    ENDIF
+
+    IF ( bc_ns_cyc )  THEN
        ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:)
        ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:)
@@ -222,10 +223,10 @@
 !
 !-- Lateral boundary conditions in the non-parallel case
-    IF ( bc_lr == 'cyclic' )  THEN
-       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
-       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
-    ENDIF
-
-    IF ( bc_ns == 'cyclic' )  THEN
+    IF ( bc_lr_cyc )  THEN
+       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
+       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
+    ENDIF
+
+    IF ( bc_ns_cyc )  THEN
        ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:)
        ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:)
Index: /palm/trunk/SOURCE/header.f90
===================================================================
--- /palm/trunk/SOURCE/header.f90	(revision 706)
+++ /palm/trunk/SOURCE/header.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc
 ! 
 ! Former revisions:
@@ -686,5 +687,5 @@
 
     WRITE ( io, 317 )  bc_lr, bc_ns
-    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
+    IF ( .NOT. bc_lr_cyc  .OR.  .NOT. bc_ns_cyc )  THEN
        WRITE ( io, 318 )  outflow_damping_width, km_damp_max
        IF ( turbulent_inflow )  THEN
@@ -1477,5 +1478,5 @@
                           zu(disturbance_level_ind_b), disturbance_level_ind_b,&
                           zu(disturbance_level_ind_t), disturbance_level_ind_t
-       IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
+       IF ( .NOT. bc_lr_cyc  .OR.  .NOT. bc_ns_cyc )  THEN
           WRITE ( io, 472 )  inflow_disturbance_begin, inflow_disturbance_end
        ELSE
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 706)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 707)
@@ -7,5 +7,7 @@
 ! Current revisions:
 ! -----------------
-!
+! p_sub renamed p_loc and allocated depending on the chosen pressure solver,
+! initial assignments of zero to array p for iterative solvers only,
+! bc_lr/ns replaced by bc_lr/ns_dirrad/raddir
 !
 ! Former revisions:
@@ -216,8 +218,14 @@
               w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 !
-!-- Following array is required to buffer the perturbation pressure during 
-!-- Runge-Kutta 3rd order time integration.
-    IF ( psolver == 'multigrid' .OR. psolver == 'sor' )  THEN
-       ALLOCATE( p_sub(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+!-- Following array is required for perturbation pressure within the iterative
+!-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds
+!-- the weighted average of the substeps and cannot be used in the Poisson
+!-- solver.
+    IF ( psolver == 'sor' )  THEN
+       ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+    ELSEIF ( psolver == 'multigrid' )  THEN
+!
+!--    For performance reasons, multigrid is using one ghost layer only
+       ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
     ENDIF
 
@@ -833,10 +841,14 @@
 
 !
-!--    For the moment, perturbation pressure and vertical velocity are zero
-       p = 0.0; w = 0.0
+!--    For the moment, vertical velocity is zero
+       w = 0.0
 
 !
 !--    Initialize array sums (must be defined in first call of pres)
        sums = 0.0
+
+!
+!--    In case of iterative solvers, p must get an initial value
+       IF ( psolver == 'multigrid'  .OR.  psolver == 'sor' )  p = 0.0
 
 !
@@ -881,12 +893,4 @@
 !--    Initialize the random number generator (from numerical recipes)
        CALL random_function_ini
-
-!
-!--    Once again set the perturbation pressure explicitly to zero in order to
-!--    assure that it does not generate any divergences in the first time step.
-!--    At t=0 the velocity field is free of divergence (as constructed above).
-!--    Divergences being created during a time step are not yet known and thus
-!--    cannot be corrected during the time step yet.
-       p = 0.0
 
 !
@@ -1410,5 +1414,5 @@
 !-- non-cyclic lateral boundaries. A linear increase is assumed over the first
 !-- half of the width of the damping layer
-    IF ( bc_lr == 'dirichlet/radiation' )  THEN
+    IF ( bc_lr_dirrad )  THEN
 
        DO  i = nxlg, nxrg
@@ -1423,5 +1427,5 @@
        ENDDO
 
-    ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
+    ELSEIF ( bc_lr_raddir )  THEN
 
        DO  i = nxlg, nxrg
@@ -1438,5 +1442,5 @@
     ENDIF
 
-    IF ( bc_ns == 'dirichlet/radiation' )  THEN
+    IF ( bc_ns_dirrad )  THEN
 
        DO  j = nysg, nyng
@@ -1451,5 +1455,5 @@
        ENDDO
 
-    ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
+    ELSEIF ( bc_ns_raddir )  THEN
 
        DO  j = nysg, nyng
Index: /palm/trunk/SOURCE/init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/init_grid.f90	(revision 706)
+++ /palm/trunk/SOURCE/init_grid.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -561,5 +562,5 @@
        ENDIF
 
-       IF ( bc_lr == 'cyclic' )  THEN
+       IF ( bc_lr_cyc )  THEN
           IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx)   )  .OR. &
                ANY( nzb_local(:,0)  /= nzb_local(:,nx+1) ) )  THEN
@@ -569,5 +570,5 @@
           ENDIF
        ENDIF
-       IF ( bc_ns == 'cyclic' )  THEN
+       IF ( bc_ns_cyc )  THEN
           IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:)   )  .OR. &
                ANY( nzb_local(0,:)  /= nzb_local(ny+1,:) ) )  THEN
Index: /palm/trunk/SOURCE/init_pegrid.f90
===================================================================
--- /palm/trunk/SOURCE/init_pegrid.f90	(revision 706)
+++ /palm/trunk/SOURCE/init_pegrid.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc/dirrad/raddir
 ! 
 ! ATTENTION: nnz_x undefined problem still has to be solved!!!!!!!!
@@ -186,6 +187,6 @@
 !
 !-- If necessary, set horizontal boundary conditions to non-cyclic
-    IF ( bc_lr /= 'cyclic' )  cyclic(1) = .FALSE.
-    IF ( bc_ns /= 'cyclic' )  cyclic(2) = .FALSE.
+    IF ( .NOT. bc_lr_cyc )  cyclic(1) = .FALSE.
+    IF ( .NOT. bc_ns_cyc )  cyclic(2) = .FALSE.
 
 !
@@ -331,4 +332,12 @@
     nzt  = MIN( nz, nzta )
     nnz  = nza
+
+!
+!-- Set switches to define if the PE is situated at the border of the virtual
+!-- processor grid
+    IF ( nxl == 0 )   left_border_pe  = .TRUE.
+    IF ( nxr == nx )  right_border_pe = .TRUE.
+    IF ( nys == 0 )   south_border_pe = .TRUE.
+    IF ( nyn == ny )  north_border_pe = .TRUE.
 
 !
@@ -1066,7 +1075,7 @@
 !-- horizontal boundary conditions.
     IF ( pleft == MPI_PROC_NULL )  THEN
-       IF ( bc_lr == 'dirichlet/radiation' )  THEN
+       IF ( bc_lr_dirrad )  THEN
           inflow_l  = .TRUE.
-       ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
+       ELSEIF ( bc_lr_raddir )  THEN
           outflow_l = .TRUE.
        ENDIF
@@ -1074,7 +1083,7 @@
 
     IF ( pright == MPI_PROC_NULL )  THEN
-       IF ( bc_lr == 'dirichlet/radiation' )  THEN
+       IF ( bc_lr_dirrad )  THEN
           outflow_r = .TRUE.
-       ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
+       ELSEIF ( bc_lr_raddir )  THEN
           inflow_r  = .TRUE.
        ENDIF
@@ -1082,7 +1091,7 @@
 
     IF ( psouth == MPI_PROC_NULL )  THEN
-       IF ( bc_ns == 'dirichlet/radiation' )  THEN
+       IF ( bc_ns_dirrad )  THEN
           outflow_s = .TRUE.
-       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
+       ELSEIF ( bc_ns_raddir )  THEN
           inflow_s  = .TRUE.
        ENDIF
@@ -1090,7 +1099,7 @@
 
     IF ( pnorth == MPI_PROC_NULL )  THEN
-       IF ( bc_ns == 'dirichlet/radiation' )  THEN
+       IF ( bc_ns_dirrad )  THEN
           inflow_n  = .TRUE.
-       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
+       ELSEIF ( bc_ns_raddir )  THEN
           outflow_n = .TRUE.
        ENDIF
@@ -1122,16 +1131,16 @@
 
 #else
-    IF ( bc_lr == 'dirichlet/radiation' )  THEN
+    IF ( bc_lr_dirrad )  THEN
        inflow_l  = .TRUE.
        outflow_r = .TRUE.
-    ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
+    ELSEIF ( bc_lr_raddir )  THEN
        outflow_l = .TRUE.
        inflow_r  = .TRUE.
     ENDIF
 
-    IF ( bc_ns == 'dirichlet/radiation' )  THEN
+    IF ( bc_ns_dirrad )  THEN
        inflow_n  = .TRUE.
        outflow_s = .TRUE.
-    ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
+    ELSEIF ( bc_ns_raddir )  THEN
        outflow_n = .TRUE.
        inflow_s  = .TRUE.
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 706)
+++ /palm/trunk/SOURCE/modules.f90	(revision 707)
@@ -5,5 +5,7 @@
 ! Current revisions:
 ! -----------------
-! 
+! +bc_lr_dirrad, bc_lr_raddir, bc_ns_dirrad, bc_ns_raddir, left_border_pe,
+! north_border_pe, right_border_pe, south_border_pe
+! p_sub renamed p_loc
 !
 ! Former revisions:
@@ -261,5 +263,5 @@
     REAL, DIMENSION(:,:,:), ALLOCATABLE ::                                     &
           canopy_heat_flux, cdc, d, diss, lad_s, lad_u, lad_v, lad_w, lai,     &
-          l_wall, p_sub, sec, sls, tend, u_m_l, u_m_n, u_m_r, u_m_s, v_m_l,    &
+          l_wall, p_loc, sec, sls, tend, u_m_l, u_m_n, u_m_r, u_m_s, v_m_l,    &
           v_m_n, v_m_r, v_m_s, w_m_l, w_m_n, w_m_r, w_m_s
 
@@ -481,5 +483,7 @@
 
     LOGICAL ::  adjust_mixing_length = .FALSE., avs_output = .FALSE., &
-                bc_lr_cyc =.TRUE., bc_ns_cyc = .TRUE., &
+                bc_lr_cyc =.TRUE., bc_lr_dirrad = .FALSE., &
+                bc_lr_raddir = .FALSE., bc_ns_cyc = .TRUE., &
+                bc_ns_dirrad = .FALSE., bc_ns_raddir = .FALSE., &
                 call_psolver_at_all_substeps = .TRUE., &
                 cloud_droplets = .FALSE., cloud_physics = .FALSE., &
@@ -1231,6 +1235,9 @@
     INTEGER, DIMENSION(:), ALLOCATABLE ::  ngp_yz, type_xz, type_yz
 
-    LOGICAL ::  collective_wait = .FALSE., reorder = .TRUE., &
+    LOGICAL ::  collective_wait = .FALSE., left_border_pe  = .FALSE.,  &
+                north_border_pe = .FALSE., reorder = .TRUE.,           &
+                right_border_pe = .FALSE., south_border_pe = .TRUE.,   &
                 synchronous_exchange = .FALSE.
+
     LOGICAL, DIMENSION(2) ::  cyclic = (/ .TRUE. , .TRUE. /), &
                               remain_dims
Index: /palm/trunk/SOURCE/poismg.f90
===================================================================
--- /palm/trunk/SOURCE/poismg.f90	(revision 706)
+++ /palm/trunk/SOURCE/poismg.f90	(revision 707)
@@ -3,9 +3,16 @@
 !------------------------------------------------------------------------------!
 ! Attention: Loop unrolling and cache optimization in SOR-Red/Black method
-!            still does not bring the expected speedup on ibm! Further work
-!            is required.
+!            still does not give the expected speedup! Further work required.
 !
 ! Current revisions:
 ! -----------------
+! p_loc is used instead of p in the main routine (poismg).
+! On coarse grid levels, gathered data are identically processed on all PEs
+! (before, on PE0 only), so that the subsequent scattering of data is not
+! neccessary any more.
+! bc_lr/ns replaced by bc_lr/ns_cyc/dirrad/raddir
+! Bugfix: bottom (nzb) and top (nzt+1) boundary conditions set in routines
+! resid and restrict. They were missed before which may have led to
+! unpredictable results.
 !
 ! Former revisions:
@@ -76,7 +83,8 @@
     ALLOCATE ( p3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
 
-
-!
-!-- Some boundaries have to be added to divergence array
+!
+!-- Ghost boundaries have to be added to divergence array.
+!-- Exchange routine needs to know the grid level!
+    grid_level = maximum_grid_level
     CALL exchange_horiz( d, 1)
     d(nzb,:,:) = d(nzb+1,:,:)
@@ -88,6 +96,6 @@
 !-- If the number of cycles is preset by the user, this number will be
 !-- carried out regardless of the accuracy.
-    grid_level_count =   0
-    mgcycles         =   0
+    grid_level_count =  0
+    mgcycles         =  0
     IF ( mg_cycles == -1 )  THEN
        maximum_mgcycles = 0
@@ -101,5 +109,5 @@
                mgcycles < maximum_mgcycles )
 
-       CALL next_mg_level( d, p, p3, r)
+       CALL next_mg_level( d, p_loc, p3, r)
         
 !
@@ -107,5 +115,5 @@
 !--    cycles to be performed
        IF ( maximum_mgcycles == 0 )  THEN
-          CALL resid( d, p, r )
+          CALL resid( d, p_loc, r )
           maxerror = SUM( r(nzb+1:nzt,nys:nyn,nxl:nxr)**2 )
 #if defined( __parallel )
@@ -132,4 +140,9 @@
 
     DEALLOCATE( p3 )
+
+!
+!-- Unset the grid level. Variable is used to determine the MPI datatypes for
+!-- ghost point exchange
+    grid_level = 0 
 
     CALL cpu_log( log_point_s(29), 'poismg', 'stop' )
@@ -223,10 +236,10 @@
     CALL exchange_horiz( r, 1)
 
-    IF ( bc_lr /= 'cyclic' )  THEN
+    IF ( .NOT. bc_lr_cyc )  THEN
        IF ( inflow_l .OR. outflow_l )  r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
        IF ( inflow_r .OR. outflow_r )  r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
     ENDIF
 
-    IF ( bc_ns /= 'cyclic' )  THEN
+    IF ( .NOT. bc_ns_cyc )  THEN
        IF ( inflow_n .OR. outflow_n )  r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
        IF ( inflow_s .OR. outflow_s )  r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
@@ -234,6 +247,13 @@
 
 !
-!-- Top boundary condition
-!-- A Neumann boundary condition for r is implicitly set in routine restrict
+!-- Boundary conditions at bottom and top of the domain.
+!-- These points are not handled by the above loop. Points may be within
+!-- buildings, but that doesn't matter. 
+    IF ( ibc_p_b == 1 )  THEN
+       r(nzb,:,: ) = r(nzb+1,:,:)
+    ELSE
+       r(nzb,:,: ) = 0.0
+    ENDIF
+
     IF ( ibc_p_t == 1 )  THEN
        r(nzt_mg(l)+1,:,: ) = r(nzt_mg(l),:,:)
@@ -396,10 +416,10 @@
     CALL exchange_horiz( f_mg, 1)
 
-    IF ( bc_lr /= 'cyclic' )  THEN
+    IF ( .NOT. bc_lr_cyc )  THEN
        IF (inflow_l .OR. outflow_l)  f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
        IF (inflow_r .OR. outflow_r)  f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
     ENDIF
 
-    IF ( bc_ns /= 'cyclic' )  THEN
+    IF ( .NOT. bc_ns_cyc )  THEN
        IF (inflow_n .OR. outflow_n)  f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
        IF (inflow_s .OR. outflow_s)  f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
@@ -407,16 +427,18 @@
 
 !
-!-- Bottom and top boundary conditions
-!    IF ( ibc_p_b == 1 )  THEN
-!       f_mg(nzb,:,: ) = f_mg(nzb+1,:,:)
-!    ELSE
-!       f_mg(nzb,:,: ) = 0.0
-!    ENDIF
-!
-!    IF ( ibc_p_t == 1 )  THEN
-!       f_mg(nzt_mg(l)+1,:,: ) = f_mg(nzt_mg(l),:,:)
-!    ELSE
-!       f_mg(nzt_mg(l)+1,:,: ) = 0.0
-!    ENDIF
+!-- Boundary conditions at bottom and top of the domain.
+!-- These points are not handled by the above loop. Points may be within
+!-- buildings, but that doesn't matter. 
+    IF ( ibc_p_b == 1 )  THEN
+       f_mg(nzb,:,: ) = f_mg(nzb+1,:,:)
+    ELSE
+       f_mg(nzb,:,: ) = 0.0
+    ENDIF
+
+    IF ( ibc_p_t == 1 )  THEN
+       f_mg(nzt_mg(l)+1,:,: ) = f_mg(nzt_mg(l),:,:)
+    ELSE
+       f_mg(nzt_mg(l)+1,:,: ) = 0.0
+    ENDIF
 
 
@@ -494,10 +516,10 @@
     CALL exchange_horiz( temp, 1)
 
-    IF ( bc_lr /= 'cyclic' )  THEN
+    IF ( .NOT. bc_lr_cyc )  THEN
        IF (inflow_l .OR. outflow_l)  temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
        IF (inflow_r .OR. outflow_r)  temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
     ENDIF
 
-    IF ( bc_ns /= 'cyclic' )  THEN
+    IF ( .NOT. bc_ns_cyc )  THEN
        IF (inflow_n .OR. outflow_n)  temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
        IF (inflow_s .OR. outflow_s)  temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
@@ -864,5 +886,5 @@
           CALL exchange_horiz( p_mg, 1 )
 
-          IF ( bc_lr /= 'cyclic' )  THEN
+          IF ( .NOT. bc_lr_cyc )  THEN
              IF ( inflow_l .OR. outflow_l )  THEN
                 p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
@@ -873,5 +895,5 @@
           ENDIF
 
-          IF ( bc_ns /= 'cyclic' )  THEN
+          IF ( .NOT. bc_ns_cyc )  THEN
              IF ( inflow_n .OR. outflow_n )  THEN
                 p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
@@ -953,5 +975,5 @@
     IMPLICIT NONE
 
-    INTEGER ::  n, nwords, sender
+    INTEGER ::  i, il, ir, j, jn, js, k, n, nwords, sender
 
     REAL, DIMENSION(nzb:nzt_mg(grid_level)+1,                            &
@@ -963,37 +985,45 @@
                     mg_loc_ind(1,myid)-1:mg_loc_ind(2,myid)+1) ::  f2_sub
 
-!
-!-- Find out the number of array elements of the subdomain array
-    nwords = SIZE( f2_sub )
+    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  f2_l
+
+    ALLOCATE( f2_l(nzb:nzt_mg(grid_level)+1,                            &
+                    nys_mg(grid_level)-1:nyn_mg(grid_level)+1,          &
+                    nxl_mg(grid_level)-1:nxr_mg(grid_level)+1) )
 
 #if defined( __parallel )
     CALL cpu_log( log_point_s(34), 'mg_gather', 'start' )
 
-    IF ( myid == 0 )  THEN
-!
-!--    Store the local subdomain array on the total array
-       f2(:,mg_loc_ind(3,0)-1:mg_loc_ind(4,0)+1, &
-            mg_loc_ind(1,0)-1:mg_loc_ind(2,0)+1) = f2_sub
-
-!
-!--    Receive the subdomain arrays from all other PEs and store them on the
-!--    total array
-       DO  n = 1, numprocs-1
-!
-!--       Receive the arrays in arbitrary order from the PEs.
-          CALL MPI_RECV( f2_sub(nzb,mg_loc_ind(3,0)-1,mg_loc_ind(1,0)-1),     &
-                         nwords, MPI_REAL, MPI_ANY_SOURCE, 1, comm2d, status, &
-                         ierr )
-          sender = status(MPI_SOURCE)
-          f2(:,mg_loc_ind(3,sender)-1:mg_loc_ind(4,sender)+1, &
-               mg_loc_ind(1,sender)-1:mg_loc_ind(2,sender)+1) = f2_sub
+    f2_l = 0.0
+
+!
+!-- Store the local subdomain array on the total array
+    js = mg_loc_ind(3,myid)
+    IF ( south_border_pe )  js = js - 1
+    jn = mg_loc_ind(4,myid)
+    IF ( north_border_pe )  jn = jn + 1
+    il = mg_loc_ind(1,myid)
+    IF ( left_border_pe )   il = il - 1
+    ir = mg_loc_ind(2,myid)
+    IF ( right_border_pe )  ir = ir + 1
+    DO  i = il, ir
+       DO  j = js, jn
+          DO  k = nzb, nzt_mg(grid_level)+1
+             f2_l(k,j,i) = f2_sub(k,j,i)
+          ENDDO
        ENDDO
-
-    ELSE
-!
-!--    Send subdomain array to PE0
-       CALL MPI_SEND( f2_sub(nzb,mg_loc_ind(3,myid)-1,mg_loc_ind(1,myid)-1), &
-                      nwords, MPI_REAL, 0, 1, comm2d, ierr )
-    ENDIF
+    ENDDO
+
+!
+!-- Find out the number of array elements of the total array
+    nwords = SIZE( f2 )
+
+!
+!-- Gather subdomain data from all PEs
+    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
+    CALL MPI_ALLREDUCE( f2_l(nzb,nys_mg(grid_level)-1,nxl_mg(grid_level)-1), &
+                        f2(nzb,nys_mg(grid_level)-1,nxl_mg(grid_level)-1),   &
+                        nwords, MPI_REAL, MPI_SUM, comm2d, ierr )
+
+    DEALLOCATE( f2_l )
 
     CALL cpu_log( log_point_s(34), 'mg_gather', 'stop' )
@@ -1034,30 +1064,6 @@
     CALL cpu_log( log_point_s(35), 'mg_scatter', 'start' )
 
-    IF ( myid == 0 )  THEN
-!
-!--    Scatter the subdomain arrays to the other PEs by blocking
-!--    communication
-       DO  n = 1, numprocs-1
-
-          p2_sub = p2(:,mg_loc_ind(3,n)-1:mg_loc_ind(4,n)+1, &
-                        mg_loc_ind(1,n)-1:mg_loc_ind(2,n)+1)
-
-          CALL MPI_SEND( p2_sub(nzb,mg_loc_ind(3,0)-1,mg_loc_ind(1,0)-1), &
-                         nwords, MPI_REAL, n, 1, comm2d, ierr )
-
-       ENDDO
-
-!
-!--    Store data from the total array to the local subdomain array
-       p2_sub = p2(:,mg_loc_ind(3,0)-1:mg_loc_ind(4,0)+1, &
-                     mg_loc_ind(1,0)-1:mg_loc_ind(2,0)+1)
-
-    ELSE
-!
-!--    Receive subdomain array from PE0
-       CALL MPI_RECV( p2_sub(nzb,mg_loc_ind(3,myid)-1,mg_loc_ind(1,myid)-1), &
-                      nwords, MPI_REAL, 0, 1, comm2d, status, ierr )
-
-    ENDIF
+    p2_sub = p2(:,mg_loc_ind(3,myid)-1:mg_loc_ind(4,myid)+1, &
+                  mg_loc_ind(1,myid)-1:mg_loc_ind(2,myid)+1)
 
     CALL cpu_log( log_point_s(35), 'mg_scatter', 'stop' )
@@ -1092,6 +1098,4 @@
                 nzt_mg_save
 
-    LOGICAL ::  restore_boundary_lr_on_pe0, restore_boundary_ns_on_pe0
-
     REAL, DIMENSION(nzb:nzt_mg(grid_level)+1,                                  &
                  nys_mg(grid_level)-1:nyn_mg(grid_level)+1,                    &
@@ -1143,5 +1147,4 @@
 
        IF ( grid_level == mg_switch_to_pe0_level )  THEN
-!          print*, 'myid=',myid, ' restrict and switch to PE0. level=', grid_level
 !
 !--       From this level on, calculations are done on PE0 only.
@@ -1196,30 +1199,30 @@
 !
 !--       In case of non-cyclic lateral boundary conditions, both in- and
-!--       outflow conditions have to be used on PE0 after the switch, because
-!--       it then contains the total domain. Due to the virtual processor
-!--       grid, before the switch, PE0 can have in-/outflow at the left
-!--       and south wall only (or on opposite walls in case of a 1d
-!--       decomposition).
-          restore_boundary_lr_on_pe0 = .FALSE.
-          restore_boundary_ns_on_pe0 = .FALSE.
-          IF ( myid == 0 )  THEN
-             IF ( inflow_l  .AND.  .NOT. outflow_r )  THEN
-                outflow_r = .TRUE.
-                restore_boundary_lr_on_pe0 = .TRUE.
-             ENDIF
-             IF ( outflow_l  .AND.  .NOT. inflow_r )  THEN
-                inflow_r  = .TRUE.
-                restore_boundary_lr_on_pe0 = .TRUE.
-             ENDIF
-             IF ( inflow_s  .AND.  .NOT. outflow_n )  THEN
-                outflow_n = .TRUE.
-                restore_boundary_ns_on_pe0 = .TRUE.
-             ENDIF
-             IF ( outflow_s  .AND.  .NOT. inflow_n )  THEN
-                inflow_n  = .TRUE.
-                restore_boundary_ns_on_pe0 = .TRUE.
-             ENDIF
+!--       outflow conditions have to be used on all PEs after the switch,
+!--       because then they have the total domain.
+          IF ( bc_lr_dirrad )  THEN
+             inflow_l  = .TRUE.
+             inflow_r  = .FALSE.
+             outflow_l = .FALSE.
+             outflow_r = .TRUE.
+          ELSEIF ( bc_lr_raddir )  THEN
+             inflow_l  = .FALSE.
+             inflow_r  = .TRUE.
+             outflow_l = .TRUE.
+             outflow_r = .FALSE.
           ENDIF
 
+          IF ( bc_ns_dirrad )  THEN
+             inflow_n  = .TRUE.
+             inflow_s  = .FALSE.
+             outflow_n = .FALSE.
+             outflow_s = .TRUE.
+          ELSEIF ( bc_ns_raddir )  THEN
+             inflow_n  = .FALSE.
+             inflow_s  = .TRUE.
+             outflow_n = .TRUE.
+             outflow_s = .FALSE.
+          ENDIF
+
           DEALLOCATE( f2_sub )
 
@@ -1229,11 +1232,10 @@
 
        ENDIF
+
        p2 = 0.0
 
 !
 !--    Repeat the same procedure till the coarsest grid is reached
-       IF ( myid == 0  .OR.  grid_level > mg_switch_to_pe0_level )  THEN
-          CALL next_mg_level( f2, p2, p3, r )
-       ENDIF
+       CALL next_mg_level( f2, p2, p3, r )
 
     ENDIF
@@ -1242,17 +1244,4 @@
 !-- Now follows the prolongation
     IF ( grid_level >= 2 )  THEN
-
-!
-!--    Grid level has to be incremented on the PEs where next_mg_level
-!--    has not been called before (normally it is incremented at the end
-!--    of next_mg_level)
-       IF ( myid /= 0  .AND.  grid_level == mg_switch_to_pe0_level )  THEN
-          grid_level = grid_level + 1
-          nxl = nxl_mg(grid_level)
-          nxr = nxr_mg(grid_level)
-          nys = nys_mg(grid_level)
-          nyn = nyn_mg(grid_level)
-          nzt = nzt_mg(grid_level)
-       ENDIF
 
 !
@@ -1290,14 +1279,40 @@
 
 !
-!--       In case of non-cyclic lateral boundary conditions, restore the
-!--       in-/outflow conditions on PE0
-          IF ( myid == 0 )  THEN
-             IF ( restore_boundary_lr_on_pe0 )  THEN
-                IF ( inflow_l  )  outflow_r = .FALSE.
-                IF ( outflow_l )  inflow_r  = .FALSE.
+!--       For non-cyclic lateral boundary conditions, 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.
+
+          IF ( pleft == MPI_PROC_NULL )  THEN
+             IF ( bc_lr_dirrad )  THEN
+                inflow_l  = .TRUE.
+             ELSEIF ( bc_lr_raddir )  THEN
+                outflow_l = .TRUE.
              ENDIF
-             IF ( restore_boundary_ns_on_pe0 )  THEN
-                IF ( inflow_s  )  outflow_n = .FALSE.
-                IF ( outflow_s )  inflow_n  = .FALSE.
+          ENDIF
+
+          IF ( pright == MPI_PROC_NULL )  THEN
+             IF ( bc_lr_dirrad )  THEN
+                outflow_r = .TRUE.
+             ELSEIF ( bc_lr_raddir )  THEN
+                inflow_r  = .TRUE.
+             ENDIF
+          ENDIF
+
+          IF ( psouth == MPI_PROC_NULL )  THEN
+             IF ( bc_ns_dirrad )  THEN
+                outflow_s = .TRUE.
+             ELSEIF ( bc_ns_raddir )  THEN
+                inflow_s  = .TRUE.
+             ENDIF
+          ENDIF
+
+          IF ( pnorth == MPI_PROC_NULL )  THEN
+             IF ( bc_ns_dirrad )  THEN
+                inflow_n  = .TRUE.
+             ELSEIF ( bc_ns_raddir )  THEN
+                outflow_n = .TRUE.
              ENDIF
           ENDIF
Index: /palm/trunk/SOURCE/pres.f90
===================================================================
--- /palm/trunk/SOURCE/pres.f90	(revision 706)
+++ /palm/trunk/SOURCE/pres.f90	(revision 707)
@@ -4,5 +4,10 @@
 ! Current revisions:
 ! -----------------
-! 
+! Calculation of weighted average of p is now handled in the same way
+! regardless of the number of ghost layers (advection scheme),
+! multigrid and sor method are using p_loc for iterative advancements of
+! pressure, 
+! localsum calculation modified for proper OpenMP reduction,
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -99,20 +104,33 @@
 
 !
-!-- Multigrid method expects 1 additional grid point for the arrays 
-!-- d, tend and p
+!-- Multigrid method expects array d to have one ghost layer.
+!-- 
     IF ( psolver == 'multigrid' )  THEN
      
        DEALLOCATE( d )
        ALLOCATE( d(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) 
+
+!
+!--    Since p is later used to hold the weighted average of the substeps, it
+!--    cannot be used in the iterative solver. Therefore, its initial value is
+!--    stored on p_loc, which is then iteratively advanced in every substep.
+       IF ( intermediate_timestep_count == 1 )  THEN
+          DO  i = nxl-1, nxr+1
+             DO  j = nys-1, nyn+1
+                DO  k = nzb, nzt+1
+                   p_loc(k,j,i) = p(k,j,i)
+                ENDDO
+             ENDDO
+          ENDDO
+       ENDIF
        
-       IF ( ws_scheme_mom  .OR. ws_scheme_sca )  THEN
-       
-          DEALLOCATE( tend )
-          ALLOCATE( tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-          DEALLOCATE( p )
-          ALLOCATE( p(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-          
-       ENDIF
-       
+    ELSEIF ( psolver == 'sor'  .AND.  intermediate_timestep_count == 1 )  THEN
+
+!
+!--    Since p is later used to hold the weighted average of the substeps, it
+!--    cannot be used in the iterative solver. Therefore, its initial value is
+!--    stored on p_loc, which is then iteratively advanced in every substep.
+       p_loc = p
+
     ENDIF
 
@@ -297,6 +315,6 @@
     ENDDO
 
-    localsum = ( localsum + threadsum ) * dt_3d * &
-               weight_pres(intermediate_timestep_count)
+    localsum = localsum + threadsum * dt_3d * &
+                          weight_pres(intermediate_timestep_count)
 
     !$OMP END PARALLEL
@@ -362,6 +380,6 @@
        ENDDO
     ENDDO
-    localsum = ( localsum + threadsum ) * dt_3d                               &
-               * weight_pres(intermediate_timestep_count)
+    localsum = localsum + threadsum * dt_3d * &
+                          weight_pres(intermediate_timestep_count)
     !$OMP END PARALLEL
 #endif
@@ -371,10 +389,4 @@
 !-- of the total domain
     sums_divold_l(0:statistic_regions) = localsum
-
-!
-!-- Determine absolute minimum/maximum (only for test cases, therefore as
-!-- comment line)
-!    CALL global_min_max( nzb+1, nzt, nys, nyn, nxl, nxr, d, 'abs', divmax, &
-!                        divmax_ijk )
 
     CALL cpu_log( log_point_s(1), 'divergence', 'stop' )
@@ -496,6 +508,6 @@
 !--    Solve Poisson equation for perturbation pressure using SOR-Red/Black
 !--    scheme
-       CALL sor( d, ddzu_pres, ddzw, p )
-       tend = p
+       CALL sor( d, ddzu_pres, ddzw, p_loc )
+       tend = p_loc
 
     ELSEIF ( psolver == 'multigrid' )  THEN
@@ -506,64 +518,62 @@
 !--    to discern data exchange in multigrid ( 1 ghostpoint ) and normal grid
 !--    ( nbgp ghost points ).
-       exchange_mg = .TRUE.
        CALL poismg( tend )
-       exchange_mg = .FALSE.
+
 !
 !--    Restore perturbation pressure on tend because this array is used
 !--    further below to correct the velocity fields
-
-       tend = p
-       IF( ws_scheme_mom .OR. ws_scheme_sca )  THEN
-!       
-!--       Allocate p to its normal size and restore pressure.         
-          DEALLOCATE( p )
-          ALLOCATE( p(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          
-       ENDIF
-
-    ENDIF
-
-!
-!-- Store perturbation pressure on array p, used in the momentum equations
-    IF ( psolver(1:7) == 'poisfft' )  THEN
-
-       IF ( intermediate_timestep_count == 1 )  THEN
-          !$OMP PARALLEL PRIVATE (i,j,k)
-          !$OMP DO
-          DO  i = nxlg, nxrg
-             DO  j = nysg, nyng
-                DO  k = nzb, nzt+1
-                   p(k,j,i) = tend(k,j,i)                                     &
-                            * weight_substep(intermediate_timestep_count)
-                ENDDO
-             ENDDO
-          ENDDO
-          !$OMP END PARALLEL
-          
-       ELSE 
-          !$OMP PARALLEL PRIVATE (i,j,k)
-          !$OMP DO
-          DO  i = nxlg, nxrg
-             DO  j = nysg, nyng
-                DO  k = nzb, nzt+1
-                   p(k,j,i) = p(k,j,i) + tend(k,j,i)                          &
-                            * weight_substep(intermediate_timestep_count)
-                ENDDO
-             ENDDO
-          ENDDO
-          !$OMP END PARALLEL
-          
-       ENDIF
+       DO  i = nxl-1, nxr+1
+          DO  j = nys-1, nyn+1
+             DO  k = nzb, nzt+1
+                tend(k,j,i) = p_loc(k,j,i)
+             ENDDO
+          ENDDO
+       ENDDO
+
+    ENDIF
+
+!
+!-- Store perturbation pressure on array p, used for pressure data output.
+!-- Ghost layers are added in the output routines (except sor-method: see below)
+    IF ( intermediate_timestep_count == 1 )  THEN
+       !$OMP PARALLEL PRIVATE (i,j,k)
+       !$OMP DO
+       DO  i = nxl-1, nxr+1
+          DO  j = nys-1, nyn+1
+             DO  k = nzb, nzt+1
+                p(k,j,i) = tend(k,j,i) * &
+                           weight_substep(intermediate_timestep_count)
+             ENDDO
+          ENDDO
+       ENDDO
+       !$OMP END PARALLEL
+
+    ELSE 
+       !$OMP PARALLEL PRIVATE (i,j,k)
+       !$OMP DO
+       DO  i = nxl-1, nxr+1
+          DO  j = nys-1, nyn+1
+             DO  k = nzb, nzt+1
+                p(k,j,i) = p(k,j,i) + tend(k,j,i) * &
+                           weight_substep(intermediate_timestep_count)
+             ENDDO
+          ENDDO
+       ENDDO
+       !$OMP END PARALLEL
+
+    ENDIF
        
-    ENDIF
+!
+!-- SOR-method needs ghost layers for the next timestep
+    IF ( psolver == 'sor' )  CALL exchange_horiz( p, nbgp )
 
 !
 !-- Correction of the provisional velocities with the current perturbation 
 !-- pressure just computed
-    IF ( conserve_volume_flow  .AND. &
-         ( bc_lr == 'cyclic'  .OR.  bc_ns == 'cyclic' ) )  THEN
+    IF ( conserve_volume_flow  .AND.  ( bc_lr_cyc  .OR.  bc_ns_cyc ) )  THEN
        volume_flow_l(1) = 0.0
        volume_flow_l(2) = 0.0
     ENDIF
+
     !$OMP PARALLEL PRIVATE (i,j,k)
     !$OMP DO
@@ -571,22 +581,22 @@
        DO  j = nys, nyn
           DO  k = nzb_w_inner(j,i)+1, nzt
-             w(k,j,i) = w(k,j,i) - dt_3d *                                    &
-                        ( tend(k+1,j,i) - tend(k,j,i) ) * ddzu(k+1)           &
-                        * weight_pres(intermediate_timestep_count)
+             w(k,j,i) = w(k,j,i) - dt_3d *                                 &
+                        ( tend(k+1,j,i) - tend(k,j,i) ) * ddzu(k+1) *      &
+                        weight_pres(intermediate_timestep_count)
           ENDDO
           DO  k = nzb_u_inner(j,i)+1, nzt
              u(k,j,i) = u(k,j,i) - dt_3d *                                 &
-                        ( tend(k,j,i) - tend(k,j,i-1) ) * ddx              &
-                        * weight_pres(intermediate_timestep_count)
+                        ( tend(k,j,i) - tend(k,j,i-1) ) * ddx *            &
+                        weight_pres(intermediate_timestep_count)
           ENDDO
           DO  k = nzb_v_inner(j,i)+1, nzt
              v(k,j,i) = v(k,j,i) - dt_3d *                                 &
-                        ( tend(k,j,i) - tend(k,j-1,i) ) * ddy              &
-                        * weight_pres(intermediate_timestep_count)
+                        ( tend(k,j,i) - tend(k,j-1,i) ) * ddy *            &
+                        weight_pres(intermediate_timestep_count)
           ENDDO                                                         
 !
 !--       Sum up the volume flow through the right and north boundary
-          IF ( conserve_volume_flow  .AND.  bc_lr == 'cyclic'  .AND. &
-               bc_ns == 'cyclic' .AND. i == nx )  THEN
+          IF ( conserve_volume_flow  .AND.  bc_lr_cyc  .AND.  bc_ns_cyc  .AND. &
+               i == nx )  THEN
              !$OMP CRITICAL
              DO  k = nzb_2d(j,i) + 1, nzt
@@ -595,6 +605,6 @@
              !$OMP END CRITICAL
           ENDIF
-          IF ( conserve_volume_flow  .AND.  bc_ns == 'cyclic'  .AND. &
-               bc_lr == 'cyclic' .AND. j == ny )  THEN
+          IF ( conserve_volume_flow  .AND.  bc_ns_cyc  .AND.  bc_lr_cyc  .AND. &
+               j == ny )  THEN
              !$OMP CRITICAL
              DO  k = nzb_2d(j,i) + 1, nzt
@@ -608,59 +618,7 @@
     !$OMP END PARALLEL
     
-    IF ( psolver == 'multigrid' .OR. psolver == 'sor' )  THEN       
-       IF ( intermediate_timestep_count == 1 .OR. simulated_time == 0)  THEN 
-          !$OMP PARALLEL PRIVATE (i,j,k)
-          !$OMP DO
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb, nzt+1
-                   p_sub(k,j,i) = tend(k,j,i)                                 &
-                                * weight_substep(intermediate_timestep_count)
-                ENDDO
-             ENDDO
-          ENDDO
-          !$OMP END PARALLEL
-       ELSE
-          !$OMP PARALLEL PRIVATE (i,j,k)
-          !$OMP DO
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb, nzt+1
-                   p_sub(k,j,i) = p_sub(k,j,i) + tend(k,j,i)                  &
-                                * weight_substep(intermediate_timestep_count)
-                ENDDO
-             ENDDO
-          ENDDO
-          !$OMP END PARALLEL
-       ENDIF
-          
-       IF ( intermediate_timestep_count == intermediate_timestep_count_max )  &
-          THEN
-          !$OMP PARALLEL PRIVATE (i,j,k)
-          !$OMP DO
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb, nzt+1
-                   p(k,j,i) = p_sub(k,j,i) 
-                ENDDO
-             ENDDO
-          ENDDO
-          !$OMP END PARALLEL
-       ENDIF
-    ENDIF
- 
-!
-!-- Resize tend to its normal size in case of multigrid and ws-scheme.
-    IF ( psolver == 'multigrid' .AND. ( ws_scheme_mom        &
-                                   .OR. ws_scheme_sca ) )  THEN
-       DEALLOCATE( tend )
-       ALLOCATE( tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-    ENDIF
-
-
 !
 !-- Conserve the volume flow
-    IF ( conserve_volume_flow  .AND. &
-         ( bc_lr == 'cyclic'  .AND.  bc_ns == 'cyclic' ) )  THEN
+    IF ( conserve_volume_flow  .AND.  ( bc_lr_cyc  .AND.  bc_ns_cyc ) )  THEN
 
 #if defined( __parallel )   
Index: /palm/trunk/SOURCE/sor.f90
===================================================================
--- /palm/trunk/SOURCE/sor.f90	(revision 706)
+++ /palm/trunk/SOURCE/sor.f90	(revision 707)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -110,9 +111,9 @@
 !
 !--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
-       IF ( bc_lr /= 'cyclic' )  THEN
+       IF ( .NOT. bc_lr_cyc )  THEN
           IF ( inflow_l .OR. outflow_l )  p(:,:,nxl-1) = p(:,:,nxl)
           IF ( inflow_r .OR. outflow_r )  p(:,:,nxr+1) = p(:,:,nxr)
        ENDIF
-       IF ( bc_ns /= 'cyclic' )  THEN
+       IF ( .NOT. bc_ns_cyc )  THEN
           IF ( inflow_n .OR. outflow_n )  p(:,nyn+1,:) = p(:,nyn,:)
           IF ( inflow_s .OR. outflow_s )  p(:,nys-1,:) = p(:,nys,:)
@@ -172,9 +173,9 @@
 !
 !--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
-       IF ( bc_lr /= 'cyclic' )  THEN
+       IF ( .NOT. bc_lr_cyc )  THEN
           IF ( inflow_l .OR. outflow_l )  p(:,:,nxl-1) = p(:,:,nxl)
           IF ( inflow_r .OR. outflow_r )  p(:,:,nxr+1) = p(:,:,nxr)
        ENDIF
-       IF ( bc_ns /= 'cyclic' )  THEN
+       IF ( .NOT. bc_ns_cyc )  THEN
           IF ( inflow_n .OR. outflow_n )  p(:,nyn+1,:) = p(:,nyn,:)
           IF ( inflow_s .OR. outflow_s )  p(:,nys-1,:) = p(:,nys,:)
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 706)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 707)
@@ -4,6 +4,7 @@
 ! Current revisions:
 ! -----------------
-! Calls of exchange_horiz are modified.
-! Adaption to slooping surface.
+! bc_lr/ns replaced by bc_lr/ns_cyc,
+! calls of exchange_horiz are modified,
+! adaption to slooping surface,
 !
 ! Former revisions:
@@ -234,6 +235,8 @@
 !--       when a sloping surface is used
           IF ( sloping_surface )  THEN
-             IF ( nxl ==  0 ) pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - pt_slope_offset
-             IF ( nxr == nx )  pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + pt_slope_offset
+             IF ( nxl ==  0 )  pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - &
+                                                    pt_slope_offset
+             IF ( nxr == nx )  pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + &
+                                                    pt_slope_offset
           ENDIF
 
@@ -255,5 +258,5 @@
                    CALL disturb_field( nzb_u_inner, tend, u )
                    CALL disturb_field( nzb_v_inner, tend, v )
-                ELSEIF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  THEN
+                ELSEIF ( .NOT. bc_lr_cyc  .OR.  .NOT. bc_ns_cyc )  THEN
 !
 !--                Runs with a non-cyclic lateral wall need perturbations
Index: /palm/trunk/SOURCE/timestep.f90
===================================================================
--- /palm/trunk/SOURCE/timestep.f90	(revision 706)
+++ /palm/trunk/SOURCE/timestep.f90	(revision 707)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! bc_lr/ns replaced by bc_lr/ns_cyc
 !
 ! Former revisions:
@@ -185,7 +185,7 @@
 !--    may be further restricted by the lateral damping layer (damping only
 !--    along x and y)
-       IF ( bc_lr /= 'cyclic' )  THEN
+       IF ( .NOT. bc_lr_cyc )  THEN
           dt_diff = MIN( dt_diff, 0.125 * dx2 / ( km_damp_max + 1E-20 ) )
-       ELSEIF ( bc_ns /= 'cyclic' )  THEN
+       ELSEIF ( .NOT. bc_ns_cyc )  THEN
           dt_diff = MIN( dt_diff, 0.125 * dy2 / ( km_damp_max + 1E-20 ) )
        ENDIF
