Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 2476)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 2478)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix, correct flag for use_top
+! 
+! 2365 2017-08-21 14:59:59Z kanani
 ! Vertical nesting implemented (SadiqHuq)
 ! 
@@ -1554,5 +1557,5 @@
           wall_flags_0(:,j,i) = IBSET( wall_flags_0(:,j,i), 9 )
           IF ( use_top_fluxes )                                                &
-             wall_flags_0(nzt:nzt+1,j,i) = IBCLR( wall_flags_0(nzt:nzt+1,j,i), 9 )
+             wall_flags_0(nzt+1,j,i) = IBCLR( wall_flags_0(nzt+1,j,i), 9 )
 
           DO k = nzb+1, nzt
Index: palm/trunk/SOURCE/production_e.f90
===================================================================
--- palm/trunk/SOURCE/production_e.f90	(revision 2476)
+++ palm/trunk/SOURCE/production_e.f90	(revision 2478)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix, consider case where no constant-flux layer and no surfaces fluxes 
+! are used
+! 
+! 2329 2017-08-03 14:24:56Z knoop
 ! Bugfix: added division by density as kinematic fluxes are needed
 ! 
@@ -432,5 +436,5 @@
              ENDDO
 
-          ELSEIF ( use_surface_fluxes )  THEN
+          ELSE
 
              DO  j = nys, nyn
@@ -1182,5 +1186,5 @@
           ENDDO
 
-       ELSEIF ( use_surface_fluxes )  THEN
+       ELSE
 !
 !--       Calculate TKE production by shear. Here, no additional
@@ -1235,4 +1239,5 @@
 !--                the bottom and top surface layer
                    DO  k = nzb+1, nzt
+ 
                       tend(k,j,i) = tend(k,j,i) +                              &
                                     kh(k,j,i) * g / rho_reference *            &
@@ -1241,5 +1246,5 @@
                                       MERGE( 1.0_wp, 0.0_wp,                   &
                                              BTEST( wall_flags_0(k,j,i), 0 )   &
-                                           )                                   
+                                           )                   
                    ENDDO
 
@@ -1323,5 +1328,5 @@
                                       MERGE( 1.0_wp, 0.0_wp,                   &
                                              BTEST( wall_flags_0(k,j,i), 0 )   &
-                                           )
+                                           )           
                    ENDDO
 
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 2476)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 2478)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfixes in initializing model top
+!
+! 2378 2017-08-31 13:57:27Z suehring
 ! Bugfix in write restart data
 ! 
@@ -1492,21 +1495,21 @@
 !--          Initialize top heat flux
              IF ( constant_top_heatflux )                                      &
-                surf%shf = top_heatflux * heatflux_input_conversion(nzt+1)
+                surf%shf(num_h) = top_heatflux * heatflux_input_conversion(nzt+1)
 !
 !--          Initialization in case of a coupled model run
              IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
-                surf%shf = 0.0_wp
+                surf%shf(num_h) = 0.0_wp
              ENDIF
 !
 !--          Prescribe latent heat flux at the top      
              IF ( humidity )  THEN
-             surf%qsws = 0.0_wp
+             surf%qsws(num_h) = 0.0_wp
                 IF ( cloud_physics  .AND.  microphysics_morrison ) THEN
-                   surf%ncsws = 0.0_wp
-                   surf%qcsws = 0.0_wp
+                   surf%ncsws(num_h) = 0.0_wp
+                   surf%qcsws(num_h) = 0.0_wp
                 ENDIF
                 IF ( cloud_physics  .AND.  microphysics_seifert ) THEN
-                   surf%nrsws = 0.0_wp
-                   surf%qrsws = 0.0_wp
+                   surf%nrsws(num_h) = 0.0_wp
+                   surf%qrsws(num_h) = 0.0_wp
                 ENDIF
              ENDIF
@@ -1514,18 +1517,20 @@
 !--          Prescribe top scalar flux
              IF ( passive_scalar .AND. constant_top_scalarflux )               &
-                surf%ssws = top_scalarflux
+                surf%ssws(num_h) = top_scalarflux
 !
 !--          Prescribe top salinity flux
-             IF ( ocean .AND. constant_top_salinityflux)                          &
-                surf%sasws = top_salinityflux
+             IF ( ocean .AND. constant_top_salinityflux)                       &
+                surf%sasws(num_h) = top_salinityflux
 !
 !--          Initialization in case of a coupled model run
              IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
-                surf%shf = 0.0_wp
+                surf%shf(num_h) = 0.0_wp
              ENDIF
 !
 !--          Top momentum fluxes
-             surf%usws = top_momentumflux_u * momentumflux_input_conversion(nzt+1)
-             surf%vsws = top_momentumflux_v * momentumflux_input_conversion(nzt+1)
+             surf%usws(num_h) = top_momentumflux_u *                           &
+                                            momentumflux_input_conversion(nzt+1)
+             surf%vsws(num_h) = top_momentumflux_v *                           &
+                                            momentumflux_input_conversion(nzt+1)
 !
 !--          Increment surface indices
