Index: palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3545)
+++ palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3550)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! - calculate diss production same in vector and cache optimization
+! - move boundary condition for e and diss to boundary_conds
+! 
+! 3545 2018-11-21 11:19:41Z gronemeier
 ! - Set rans_mode according to value of turbulence_closure
 ! - removed debug output
@@ -1937,7 +1941,4 @@
     REAL(wp)     ::  sbt     !< wheighting factor for sub-time step
 
-    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: advec  !< advection term of TKE tendency
-    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: produc !< production term of TKE tendency
-
 !
 !-- If required, compute prognostic equation for turbulent kinetic
@@ -1982,11 +1983,5 @@
        ENDIF
 
-       IF ( rans_tke_e )  advec = tend
-
        CALL production_e( .FALSE. )
-
-!
-!--    Save production term for prognostic equation of TKE dissipation rate
-       IF ( rans_tke_e )  produc = tend - advec
 
        IF ( .NOT. humidity )  THEN
@@ -2024,21 +2019,4 @@
           ENDDO
        ENDDO
-
-!
-!--    Use special boundary condition in case of TKE-e closure
-       !> @todo do the same for usm and lsm surfaces
-       !>   2018-06-05, gronemeier
-       IF ( rans_tke_e )  THEN
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                surf_s = surf_def_h(0)%start_index(j,i)
-                surf_e = surf_def_h(0)%end_index(j,i)
-                DO  m = surf_s, surf_e
-                   k = surf_def_h(0)%k(m)
-                   e_p(k,j,i) = surf_def_h(0)%us(m)**2 / c_0**2
-                ENDDO
-             ENDDO
-          ENDDO
-       ENDIF
 
 !
@@ -2110,25 +2088,15 @@
           ENDIF
        ENDIF
-
 !
 !--    Production of TKE dissipation rate
-       DO  i = nxl, nxr
-          DO  j = nys, nyn
-             DO  k = nzb+1, nzt
-!                tend(k,j,i) = tend(k,j,i) + c_1 * diss(k,j,i) / ( e(k,j,i) + 1.0E-20_wp ) * produc(k)
-                tend(k,j,i) = tend(k,j,i) + c_1 * c_0**4 * f / c_4               &  !> @todo needs revision
-                      / surf_def_h(0)%us(surf_def_h(0)%start_index(j,i))       &
-                      * SQRT(e(k,j,i)) * produc(k,j,i)
-             ENDDO
-          ENDDO
-       ENDDO
-
+       CALL production_e( .TRUE. )
+!
+!--    Diffusion term of TKE dissipation rate
        CALL diffusion_diss
-
 !
 !--    Additional sink term for flows through plant canopies
-!        IF ( plant_canopy )  CALL pcm_tendency( ? )                            !> @query what to do with this?
-
-!        CALL user_actions( 'diss-tendency' )                                   !> @todo not yet implemented
+!        IF ( plant_canopy )  CALL pcm_tendency( ? )         !> @todo not yet implemented
+
+!        CALL user_actions( 'diss-tendency' )                !> @todo not yet implemented
 
 !
@@ -2148,17 +2116,4 @@
                 IF ( diss_p(k,j,i) < 0.0_wp )                                  &
                    diss_p(k,j,i) = 0.1_wp * diss(k,j,i)
-             ENDDO
-          ENDDO
-       ENDDO
-
-!
-!--    Use special boundary condition in case of TKE-e closure
-       DO  i = nxl, nxr
-          DO  j = nys, nyn
-             surf_s = surf_def_h(0)%start_index(j,i)
-             surf_e = surf_def_h(0)%end_index(j,i)
-             DO  m = surf_s, surf_e
-                k = surf_def_h(0)%k(m)
-                diss_p(k,j,i) = surf_def_h(0)%us(m)**3 / kappa * ddzu(k)
              ENDDO
           ENDDO
@@ -2315,7 +2270,7 @@
 !
 !--    Additional sink term for flows through plant canopies
-!        IF ( plant_canopy )  CALL pcm_tendency( i, j, ? )                      !> @todo not yet implemented
-
-!        CALL user_actions( i, j, 'diss-tendency' )                             !> @todo not yet implemented
+!        IF ( plant_canopy )  CALL pcm_tendency( i, j, ? )     !> @todo not yet implemented
+
+!        CALL user_actions( i, j, 'diss-tendency' )            !> @todo not yet implemented
 
 !
@@ -2361,5 +2316,4 @@
 !> @warning The case with constant_flux_layer = F and use_surface_fluxes = T is
 !>          not considered well!
-!> @todo Adjust production term in case of rans_tke_e simulation
 !------------------------------------------------------------------------------!
  SUBROUTINE production_e( diss_production )
@@ -2645,10 +2599,10 @@
              IF ( .NOT. diss_production )  THEN
 
-!--             Compute temdency for TKE-production from shear
+!--             Compute tendency for TKE-production from shear
                 tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def * flag
 
              ELSE
 
-!--             RANS mode: Compute temdency for dissipation-rate-production from shear
+!--             RANS mode: Compute tendency for dissipation-rate-production from shear
                 tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def * flag *           &
                               diss(k,j,i)/( e(k,j,i) + 1.0E-20_wp ) * c_1
@@ -2703,5 +2657,5 @@
                    IF ( .NOT. diss_production )  THEN
 
-!--                   Compute temdency for TKE-production from shear
+!--                   Compute tendency for TKE-production from shear
                       DO  k = nzb+1, nzt
                          flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -2713,5 +2667,5 @@
                    ELSE
 
-!--                   RANS mode: Compute temdency for dissipation-rate-production from shear
+!--                   RANS mode: Compute tendency for dissipation-rate-production from shear
                       DO  k = nzb+1, nzt
                          flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -2777,5 +2731,5 @@
                    IF ( .NOT. diss_production )  THEN
 
-!--                   Compute temdency for TKE-production from shear
+!--                   Compute tendency for TKE-production from shear
                       DO  k = nzb+1, nzt
                          flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -2787,5 +2741,5 @@
                    ELSE
 
-!--                   RANS mode: Compute temdency for dissipation-rate-production from shear
+!--                   RANS mode: Compute tendency for dissipation-rate-production from shear
                       DO  k = nzb+1, nzt
                          flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -2992,5 +2946,5 @@
                 IF ( .NOT. diss_production )  THEN
 
-!--                Compute temdency for TKE-production from shear
+!--                Compute tendency for TKE-production from shear
                    DO  k = nzb+1, nzt
                       flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3002,5 +2956,5 @@
                 ELSE
 
-!--                RANS mode: Compute temdency for dissipation-rate-production from shear
+!--                RANS mode: Compute tendency for dissipation-rate-production from shear
                    DO  k = nzb+1, nzt
                       flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3031,5 +2985,4 @@
 !> @warning The case with constant_flux_layer = F and use_surface_fluxes = T is
 !>          not considered well!
-!> @todo non-neutral case is not yet considered for RANS mode
 !------------------------------------------------------------------------------!
  SUBROUTINE production_e_ij( i, j, diss_production )
@@ -3313,5 +3266,5 @@
        ELSE
 
-!--       RANS mode: Compute temdency for dissipation-rate-production from shear
+!--       RANS mode: Compute tendency for dissipation-rate-production from shear
           tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def * flag *           &
                         diss(k,j,i)/( e(k,j,i) + 1.0E-20_wp ) * c_1
@@ -3359,5 +3312,5 @@
              IF ( .NOT. diss_production )  THEN
 
-!--             Compute temdency for TKE-production from shear
+!--             Compute tendency for TKE-production from shear
                 DO  k = nzb+1, nzt
                    flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3369,5 +3322,5 @@
              ELSE
 
-!--             RANS mode: Compute temdency for dissipation-rate-production from shear
+!--             RANS mode: Compute tendency for dissipation-rate-production from shear
                 DO  k = nzb+1, nzt
                    flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3428,5 +3381,5 @@
              IF ( .NOT. diss_production )  THEN
 
-!--             Compute temdency for TKE-production from shear
+!--             Compute tendency for TKE-production from shear
                 DO  k = nzb+1, nzt
                    flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3438,5 +3391,5 @@
              ELSE
 
-!--             RANS mode: Compute temdency for dissipation-rate-production from shear
+!--             RANS mode: Compute tendency for dissipation-rate-production from shear
                 DO  k = nzb+1, nzt
                    flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3637,5 +3590,5 @@
           IF ( .NOT. diss_production )  THEN
 
-!--          Compute temdency for TKE-production from shear
+!--          Compute tendency for TKE-production from shear
              DO  k = nzb+1, nzt
                 flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
@@ -3647,5 +3600,5 @@
           ELSE
 
-!--          RANS mode: Compute temdency for dissipation-rate-production from shear
+!--          RANS mode: Compute tendency for dissipation-rate-production from shear
              DO  k = nzb+1, nzt
                 flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_0(k,j,i),0) )
