Index: palm/trunk/SOURCE/production_e.f90
===================================================================
--- palm/trunk/SOURCE/production_e.f90	(revision 207)
+++ palm/trunk/SOURCE/production_e.f90	(revision 208)
@@ -4,5 +4,6 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Bugfix concerning the calculation of velocity gradients at vertical walls 
+! in case of diabatic conditions
 !
 ! Former revisions:
@@ -92,5 +93,5 @@
 
        REAL    ::  def, dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz, &
-                   k1, k2, theta, temp
+                   k1, k2, km_neutral, theta, temp
 
 !       REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) ::  usvs, vsus, wsus, wsvs
@@ -166,12 +167,21 @@
 
                    IF ( wall_e_y(j,i) /= 0.0 )  THEN
+!                     
+!--                   Inconsistency removed: as the thermal stratification is 
+!--                   not taken into account for the evaluation of the wall 
+!--                   fluxes at vertical walls, the eddy viscosity km must not 
+!--                   be used for the evaluation of the velocity gradients dudy 
+!--                   and dwdy
+!--                   Note: The validity of the new method has not yet been 
+!--                         shown, as so far no suitable data for a validation 
+!--                         has been available
                       CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                           usvs, 1.0, 0.0, 0.0, 0.0 )
-                      dudy = - wall_e_y(j,i) * usvs(k) / km(k,j,i)
-!                      dudy = - wall_e_y(j,i) * usvs(k,j,i) / km(k,j,i)
                       CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                           wsvs, 0.0, 0.0, 1.0, 0.0 )
-                      dwdy = - wall_e_y(j,i) * wsvs(k) / km(k,j,i)
-!                      dwdy = - wall_e_y(j,i) * wsvs(k,j,i) / km(k,j,i)
+                      km_neutral = kappa * ( usvs(k)**2 + wsvs(k)**2 )**0.25 * &
+                                   0.5 * dy 
+                      dudy = - wall_e_y(j,i) * usvs(k) / km_neutral
+                      dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral
                    ELSE
                       dudy = 0.25 * ( u(k,j+1,i) + u(k,j+1,i+1) - &
@@ -182,12 +192,21 @@
 
                    IF ( wall_e_x(j,i) /= 0.0 )  THEN
+!                     
+!--                   Inconsistency removed: as the thermal stratification is 
+!--                   not taken into account for the evaluation of the wall 
+!--                   fluxes at vertical walls, the eddy viscosity km must not 
+!--                   be used for the evaluation of the velocity gradients dvdx 
+!--                   and dwdx
+!--                   Note: The validity of the new method has not yet been 
+!--                         shown, as so far no suitable data for a validation 
+!--                         has been available
                       CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                           vsus, 0.0, 1.0, 0.0, 0.0 )
-                      dvdx = - wall_e_x(j,i) * vsus(k) / km(k,j,i)
-!                      dvdx = - wall_e_x(j,i) * vsus(k,j,i) / km(k,j,i)
                       CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                           wsus, 0.0, 0.0, 0.0, 1.0 )
-                      dwdx = - wall_e_x(j,i) * wsus(k) / km(k,j,i)
-!                      dwdx = - wall_e_x(j,i) * wsus(k,j,i) / km(k,j,i)
+                      km_neutral = kappa * ( vsus(k)**2 + wsus(k)**2 )**0.25 * &
+                                   0.5 * dx
+                      dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral
+                      dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral
                    ELSE
                       dvdx = 0.25 * ( v(k,j,i+1) + v(k,j+1,i+1) - &
@@ -224,8 +243,17 @@
 
                       IF ( wall_e_y(j,i) /= 0.0 )  THEN
-                         dudy = - wall_e_y(j,i) * usvs(k) / km(k,j,i)
-!                         dudy = - wall_e_y(j,i) * usvs(k,j,i) / km(k,j,i)
-                         dwdy = - wall_e_y(j,i) * wsvs(k) / km(k,j,i)
-!                         dwdy = - wall_e_y(j,i) * wsvs(k,j,i) / km(k,j,i)
+!                     
+!--                      Inconsistency removed: as the thermal stratification 
+!--                      is not taken into account for the evaluation of the 
+!--                      wall fluxes at vertical walls, the eddy viscosity km 
+!--                      must not be used for the evaluation of the velocity 
+!--                      gradients dudy and dwdy
+!--                      Note: The validity of the new method has not yet 
+!--                            been shown, as so far no suitable data for a 
+!--                            validation has been available
+                         km_neutral = kappa * ( usvs(k)**2 + & 
+                                                wsvs(k)**2 )**0.25 * 0.5 * dy
+                         dudy = - wall_e_y(j,i) * usvs(k) / km_neutral
+                         dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral
                       ELSE
                          dudy = 0.25 * ( u(k,j+1,i) + u(k,j+1,i+1) - &
@@ -236,8 +264,17 @@
 
                       IF ( wall_e_x(j,i) /= 0.0 )  THEN
-                         dvdx = - wall_e_x(j,i) * vsus(k) / km(k,j,i)
-!                         dvdx = - wall_e_x(j,i) * vsus(k,j,i) / km(k,j,i)
-                         dwdx = - wall_e_x(j,i) * wsus(k) / km(k,j,i)
-!                         dwdx = - wall_e_x(j,i) * wsus(k,j,i) / km(k,j,i)
+!                     
+!--                      Inconsistency removed: as the thermal stratification 
+!--                      is not taken into account for the evaluation of the 
+!--                      wall fluxes at vertical walls, the eddy viscosity km 
+!--                      must not be used for the evaluation of the velocity 
+!--                      gradients dvdx and dwdx
+!--                      Note: The validity of the new method has not yet 
+!--                            been shown, as so far no suitable data for a 
+!--                            validation has been available
+                         km_neutral = kappa * ( vsus(k)**2 + & 
+                                                wsus(k)**2 )**0.25 * 0.5 * dx
+                         dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral
+                         dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral
                       ELSE
                          dvdx = 0.25 * ( v(k,j,i+1) + v(k,j+1,i+1) - &
@@ -576,5 +613,5 @@
 
        REAL    ::  def, dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz, &
-                   k1, k2, theta, temp
+                   k1, k2, km_neutral, theta, temp
 
        REAL, DIMENSION(nzb:nzt+1) ::  usvs, vsus, wsus, wsvs
@@ -631,10 +668,21 @@
 
              IF ( wall_e_y(j,i) /= 0.0 )  THEN
+!                     
+!--             Inconsistency removed: as the thermal stratification 
+!--             is not taken into account for the evaluation of the 
+!--             wall fluxes at vertical walls, the eddy viscosity km 
+!--             must not be used for the evaluation of the velocity 
+!--             gradients dudy and dwdy
+!--             Note: The validity of the new method has not yet 
+!--                   been shown, as so far no suitable data for a 
+!--                   validation has been available
                 CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                     usvs, 1.0, 0.0, 0.0, 0.0 )
-                dudy = - wall_e_y(j,i) * usvs(k) / km(k,j,i)
                 CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                     wsvs, 0.0, 0.0, 1.0, 0.0 )
-                dwdy = - wall_e_y(j,i) * wsvs(k) / km(k,j,i)
+                km_neutral = kappa * ( usvs(k)**2 + wsvs(k)**2 )**0.25 * &
+                             0.5 * dy
+                dudy = - wall_e_y(j,i) * usvs(k) / km_neutral
+                dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral
              ELSE
                 dudy = 0.25 * ( u(k,j+1,i) + u(k,j+1,i+1) - &
@@ -645,10 +693,21 @@
 
              IF ( wall_e_x(j,i) /= 0.0 )  THEN
+!                     
+!--             Inconsistency removed: as the thermal stratification 
+!--             is not taken into account for the evaluation of the 
+!--             wall fluxes at vertical walls, the eddy viscosity km 
+!--             must not be used for the evaluation of the velocity 
+!--             gradients dvdx and dwdx
+!--             Note: The validity of the new method has not yet 
+!--                   been shown, as so far no suitable data for a 
+!--                   validation has been available
                 CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                     vsus, 0.0, 1.0, 0.0, 0.0 )
-                dvdx = - wall_e_x(j,i) * vsus(k) / km(k,j,i)
                 CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, &
                                     wsus, 0.0, 0.0, 0.0, 1.0 )
-                dwdx = - wall_e_x(j,i) * wsus(k) / km(k,j,i)
+                km_neutral = kappa * ( vsus(k)**2 + wsus(k)**2 )**0.25 * & 
+                             0.5 * dx
+                dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral
+                dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral
              ELSE
                 dvdx = 0.25 * ( v(k,j,i+1) + v(k,j+1,i+1) - &
@@ -683,6 +742,17 @@
 
                 IF ( wall_e_y(j,i) /= 0.0 )  THEN
-                   dudy = - wall_e_y(j,i) * usvs(k) / km(k,j,i)
-                   dwdy = - wall_e_y(j,i) * wsvs(k) / km(k,j,i)
+!                     
+!--                Inconsistency removed: as the thermal stratification 
+!--                is not taken into account for the evaluation of the 
+!--                wall fluxes at vertical walls, the eddy viscosity km 
+!--                must not be used for the evaluation of the velocity 
+!--                gradients dudy and dwdy
+!--                Note: The validity of the new method has not yet 
+!--                      been shown, as so far no suitable data for a 
+!--                      validation has been available
+                   km_neutral = kappa * ( usvs(k)**2 + & 
+                                          wsvs(k)**2 )**0.25 * 0.5 * dy
+                   dudy = - wall_e_y(j,i) * usvs(k) / km_neutral
+                   dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral
                 ELSE
                    dudy = 0.25 * ( u(k,j+1,i) + u(k,j+1,i+1) - &
@@ -693,6 +763,17 @@
 
                 IF ( wall_e_x(j,i) /= 0.0 )  THEN
-                   dvdx = - wall_e_x(j,i) * vsus(k) / km(k,j,i)
-                   dwdx = - wall_e_x(j,i) * wsus(k) / km(k,j,i)
+!                     
+!--                Inconsistency removed: as the thermal stratification 
+!--                is not taken into account for the evaluation of the 
+!--                wall fluxes at vertical walls, the eddy viscosity km 
+!--                must not be used for the evaluation of the velocity 
+!--                gradients dvdx and dwdx
+!--                Note: The validity of the new method has not yet 
+!--                      been shown, as so far no suitable data for a 
+!--                      validation has been available
+                   km_neutral = kappa * ( vsus(k)**2 + & 
+                                          wsus(k)**2 )**0.25 * 0.5 * dx
+                   dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral
+                   dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral
                 ELSE
                    dvdx = 0.25 * ( v(k,j,i+1) + v(k,j+1,i+1) - &
