Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 4317)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 4318)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Indirect indexing for calculating vertical fluxes close to boundaries is only
+! used for loop indizes where it is really necessary
+! 
+! 4317 2019-12-03 12:43:22Z Giersch
 ! Comments revised/added, formatting improved, fluxes for u,v, and scalars are 
 ! explicitly set to zero at nzt+1, fluxes of w-component are now calculated only
@@ -1476,6 +1480,6 @@
 !
 !--    Now, compute vertical fluxes. Split loop into a part treating the 
-!--    lowest 2 grid points with indirect indexing, a main loop without
-!--    indirect indexing, and a loop for the uppermost 2 grip points with
+!--    lowest grid points with indirect indexing, a main loop without
+!--    indirect indexing, and a loop for the uppermost grip points with
 !--    indirect indexing. This allows better vectorization for the main loop.
 !--    First, compute the flux at model surface, which need has to be 
@@ -1486,5 +1490,5 @@
        diss_t(nzb) = 0.0_wp
        
-       DO  k = nzb+1, nzb+2
+       DO  k = nzb+1, nzb+1
           ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
           ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
@@ -1528,5 +1532,5 @@
        ENDDO 
        
-       DO  k = nzb+3, nzt-2
+       DO  k = nzb+2, nzt-2
           ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
           ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
@@ -2198,6 +2202,6 @@
 !
 !--    Now, compute vertical fluxes. Split loop into a part treating the 
-!--    lowest 2 grid points with indirect indexing, a main loop without
-!--    indirect indexing, and a loop for the uppermost 2 grip points with
+!--    lowest grid points with indirect indexing, a main loop without
+!--    indirect indexing, and a loop for the uppermost grip points with
 !--    indirect indexing. This allows better vectorization for the main loop.
 !--    First, compute the flux at model surface, which need has to be 
@@ -2209,5 +2213,5 @@
        w_comp(nzb) = 0.0_wp
        
-       DO  k = nzb+1, nzb+2
+       DO  k = nzb+1, nzb+1
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2253,5 +2257,5 @@
        ENDDO
        
-       DO  k = nzb+3, nzt-2
+       DO  k = nzb+2, nzt-2
 
           ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
@@ -2762,6 +2766,6 @@
 !
 !--    Now, compute vertical fluxes. Split loop into a part treating the 
-!--    lowest 2 grid points with indirect indexing, a main loop without
-!--    indirect indexing, and a loop for the uppermost 2 grip points with
+!--    lowest grid points with indirect indexing, a main loop without
+!--    indirect indexing, and a loop for the uppermost grip points with
 !--    indirect indexing. This allows better vectorization for the main loop.
 !--    First, compute the flux at model surface, which need has to be 
@@ -2773,5 +2777,5 @@
        w_comp(nzb) = 0.0_wp
        
-       DO  k = nzb+1, nzb+2
+       DO  k = nzb+1, nzb+1
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2817,5 +2821,5 @@
        ENDDO
        
-       DO  k = nzb+3, nzt-2
+       DO  k = nzb+2, nzt-2
 
           ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
@@ -3325,6 +3329,6 @@
 !
 !--    Now, compute vertical fluxes. Split loop into a part treating the 
-!--    lowest 2 grid points with indirect indexing, a main loop without
-!--    indirect indexing, and a loop for the uppermost 2 grip points with
+!--    lowest grid points with indirect indexing, a main loop without
+!--    indirect indexing, and a loop for the uppermost grip points with
 !--    indirect indexing. This allows better vectorization for the main loop.
 !--    First, compute the flux at model surface, which need has to be 
@@ -3337,5 +3341,5 @@
        diss_t(0) = -ABS(w_comp(k)) * ( w(k,j,i) - w(k-1,j,i) ) * adv_mom_1
        
-       DO  k = nzb+1, nzb+2
+       DO  k = nzb+1, nzb+1
 !
 !--       k index has to be modified near bottom and top, else array
@@ -3381,5 +3385,5 @@
        ENDDO
        
-       DO  k = nzb+3, nzt-2
+       DO  k = nzb+2, nzt-2
        
           ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
