Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 4330)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 4340)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Topography closed channel flow with symmetric boundaries implemented 
+! 
+! 4330 2019-12-10 16:16:33Z knoop
 ! Bugix: removed syntax error introduced by last commit
 ! 
@@ -166,4 +169,5 @@
                salsa,                                                          &
                scalar_advec,                                                   &
+               symmetry_flag,                                                  &
                intermediate_timestep_count,                                    &
                u_gtrans,                                                       &
@@ -502,5 +506,5 @@
                              BTEST(wall_flags_static_0(k+1,j,i),1)       .AND.     &
                              BTEST(wall_flags_static_0(k,j,i),1) )       .OR.      &
-                     k == nzt )                                                    &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                       &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 6 )       
@@ -512,6 +516,6 @@
                                  BTEST(wall_flags_static_0(k+1,j,i),1)     .AND.   &
                                  BTEST(wall_flags_static_0(k_pp,j,i),1)    .AND.   &
-                           .NOT. flag_set                           .OR.           & 
-                         k == nzt - 1 )                                            &
+                           .NOT. flag_set                                  .OR.    & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )               &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 7 )       
@@ -635,5 +639,5 @@
                              BTEST(wall_flags_static_0(k+1,j,i),2)          .AND.     &
                              BTEST(wall_flags_static_0(k,j,i),2) )          .OR.      &
-                     k == nzt )                                                       &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 15 )      
@@ -646,5 +650,5 @@
                                  BTEST(wall_flags_static_0(k_pp,j,i),2)    .AND.      &
                            .NOT. flag_set                                  .OR.       & 
-                         k == nzt - 1 )                                               &
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 16 )      
@@ -1082,9 +1086,11 @@
                                                                                
                 flag_set = .FALSE.                                             
-                IF ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),0)  .AND.               &
-                           BTEST(wall_flags_static_0(k,j,i),0)    .OR.                &
-                     .NOT. BTEST(wall_flags_static_0(k_pp,j,i),0) .AND.               &                              
-                           BTEST(wall_flags_static_0(k,j,i),0)    .OR.                &
-                     k == nzt )                                                &
+                IF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),0)          .AND.     &
+                             BTEST(wall_flags_static_0(k,j,i),0)            .AND.     &
+                             BTEST(wall_flags_static_0(k+1,j,i),0) )        .OR.      &
+                     ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),0)         .AND.     &                              
+                             BTEST(wall_flags_static_0(k+1,j,i),0)          .AND.     &
+                             BTEST(wall_flags_static_0(k,j,i),0) )          .OR.      &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 6 )             
@@ -1096,6 +1102,6 @@
                                  BTEST(wall_flags_static_0(k+1,j,i),0)     .AND.      &
                                  BTEST(wall_flags_static_0(k_pp,j,i),0)    .AND.      &
-                           .NOT. flag_set                           .OR.       & 
-                         k == nzt - 1 )                                        &
+                           .NOT. flag_set                                  .OR.       & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 7 )             
@@ -1595,5 +1601,5 @@
        ENDDO       
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
           ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
           ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
@@ -1638,7 +1644,14 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
+       
        
        IF ( limiter )  THEN
@@ -2323,5 +2336,5 @@
        ENDDO
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2368,5 +2381,12 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+          w_comp(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
@@ -2887,5 +2907,5 @@
        ENDDO
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2932,5 +2952,12 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+          w_comp(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
