Index: palm/trunk/SOURCE/pres.f90
===================================================================
--- palm/trunk/SOURCE/pres.f90	(revision 73)
+++ palm/trunk/SOURCE/pres.f90	(revision 75)
@@ -4,5 +4,6 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Volume flow control for non-cyclic boundary conditions added (currently only
+! for the north boundary!!), 2nd+3rd argument removed from exchange horiz
 !
 ! Former revisions:
@@ -54,4 +55,45 @@
        ALLOCATE( d(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
     ENDIF
+
+!
+!-- Conserve the volume flow at the outflow in case of non-cyclic lateral
+!-- boundary conditions
+    IF ( conserve_volume_flow  .AND.  bc_ns == 'radiation/dirichlet')  THEN
+
+       volume_flow(2)   = 0.0
+       volume_flow_l(2) = 0.0
+
+       IF ( nyn == ny )  THEN
+          j = ny+1
+          DO  i = nxl, nxr
+!
+!--          Sum up the volume flow through the north boundary
+             DO  k = nzb_2d(j,i) + 1, nzt
+                volume_flow_l(2) = volume_flow_l(2) + v(k,j,i) * dzu(k)
+             ENDDO
+          ENDDO
+       ENDIF
+#if defined( __parallel )   
+       CALL MPI_ALLREDUCE( volume_flow_l(2), volume_flow(2), 1, MPI_REAL, &
+                           MPI_SUM, comm1dx, ierr )   
+#else
+       volume_flow = volume_flow_l  
+#endif
+       volume_flow_offset(2) = ( volume_flow_initial(2) - volume_flow(2) )    &
+                               / volume_flow_area(2)                          
+
+       IF ( outflow_n )  THEN
+          j = nyn+1
+          DO  i = nxl, nxr
+             DO  k = nzb_v_inner(j,i) + 1, nzt
+                v(k,j,i) = v(k,j,i) + volume_flow_offset(2)
+             ENDDO
+          ENDDO
+       ENDIF
+
+       CALL exchange_horiz( v )
+
+    ENDIF
+
 
 !
@@ -322,5 +364,5 @@
 !
 !--    Exchange boundaries for p
-       CALL exchange_horiz( tend, 0, 0 )
+       CALL exchange_horiz( tend )
       
     ELSEIF ( psolver == 'sor' )  THEN
@@ -365,6 +407,6 @@
 !-- Correction of the provisional velocities with the current perturbation 
 !-- pressure just computed
-    IF ( bc_lr /= 'cyclic'  .OR.  bc_ns /= 'cyclic' )  uvmean_outflow_l = 0.0
-    IF ( conserve_volume_flow )  THEN
+    IF ( conserve_volume_flow  .AND. &
+         ( bc_lr == 'cyclic'  .OR.  bc_ns == 'cyclic' ) )  THEN
        volume_flow_l(1) = 0.0
        volume_flow_l(2) = 0.0
@@ -393,36 +435,7 @@
 
 !
-!--       Sum up the horizontal velocity along the outflow plane (in case
-!--       of non-cyclic boundary conditions). The respective mean velocity
-!--       is calculated from this in routine boundary_conds.
-!          IF ( outflow_l  .AND.  i == nxl )  THEN
-!             !$OMP CRITICAL
-!             DO  k = nzb, nzt+1
-!                uvmean_outflow_l(k) = uvmean_outflow_l(k) + v(k,j,nxl)
-!             ENDDO
-!             !$OMP END CRITICAL
-!          ELSEIF ( outflow_r  .AND.  i == nxr )  THEN
-!             !$OMP CRITICAL
-!             DO  k = nzb, nzt+1
-!                uvmean_outflow_l(k) = uvmean_outflow_l(k) + v(k,j,nxr)
-!             ENDDO
-!             !$OMP END CRITICAL
-!          ELSEIF ( outflow_s  .AND.  j == nys )  THEN
-!             !$OMP CRITICAL
-!             DO  k = nzb, nzt+1
-!                uvmean_outflow_l(k) = uvmean_outflow_l(k) + u(k,nys,i)
-!             ENDDO
-!             !$OMP END CRITICAL
-!          ELSEIF ( outflow_n  .AND.  j == nyn )  THEN
-!             !$OMP CRITICAL
-!             DO  k = nzb, nzt+1
-!                uvmean_outflow_l(k) = uvmean_outflow_l(k) + u(k,nyn,i)
-!             ENDDO
-!             !$OMP END CRITICAL
-!          ENDIF
-
-!
 !--       Sum up the volume flow through the right and north boundary
-          IF ( conserve_volume_flow  .AND.  i == nx )  THEN
+          IF ( conserve_volume_flow  .AND.  bc_lr == 'cyclic'  .AND. &
+               i == nx )  THEN
              !$OMP CRITICAL
              DO  k = nzb_2d(j,i) + 1, nzt
@@ -431,5 +444,6 @@
              !$OMP END CRITICAL
           ENDIF
-          IF ( conserve_volume_flow  .AND.  j == ny )  THEN
+          IF ( conserve_volume_flow  .AND.  bc_ns == 'cyclic'  .AND. &
+               j == ny )  THEN
              !$OMP CRITICAL
              DO  k = nzb_2d(j,i) + 1, nzt
@@ -445,5 +459,6 @@
 !
 !-- Conserve the volume flow
-    IF ( conserve_volume_flow )  THEN
+    IF ( conserve_volume_flow  .AND. &
+         ( bc_lr == 'cyclic'  .OR.  bc_ns == 'cyclic' ) )  THEN
 
 #if defined( __parallel )   
@@ -461,10 +476,14 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             DO  k = nzb_u_inner(j,i) + 1, nzt
-                u(k,j,i) = u(k,j,i) + volume_flow_offset(1)
-             ENDDO
-             DO  k = nzb_v_inner(j,i) + 1, nzt
-                v(k,j,i) = v(k,j,i) + volume_flow_offset(2)
-             ENDDO
+             IF ( bc_lr == 'cyclic' )  THEN
+                DO  k = nzb_u_inner(j,i) + 1, nzt
+                   u(k,j,i) = u(k,j,i) + volume_flow_offset(1)
+                ENDDO
+             ENDIF
+             IF ( bc_ns == 'cyclic' )  THEN
+                DO  k = nzb_v_inner(j,i) + 1, nzt
+                   v(k,j,i) = v(k,j,i) + volume_flow_offset(2)
+                ENDDO
+             ENDIF
           ENDDO
        ENDDO
@@ -475,7 +494,7 @@
 !
 !-- Exchange of boundaries for the velocities
-    CALL exchange_horiz( u, uxrp,    0 )
-    CALL exchange_horiz( v,    0, vynp )
-    CALL exchange_horiz( w,    0,    0 )
+    CALL exchange_horiz( u )
+    CALL exchange_horiz( v )
+    CALL exchange_horiz( w )
 
 !
