Index: /palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- /palm/trunk/SOURCE/check_parameters.f90	(revision 19)
+++ /palm/trunk/SOURCE/check_parameters.f90	(revision 20)
@@ -806,10 +806,6 @@
     ENDIF
 
-    IF ( surface_heatflux == 9999999.9 )  constant_heatflux = .FALSE.
-    IF ( top_heatflux     == 9999999.9 )  THEN
-       constant_top_heatflux = .FALSE.
-    ELSE
-       use_top_fluxes = .TRUE.    ! because this is currently the only choice
-    ENDIF
+    IF ( surface_heatflux == 9999999.9 )  constant_heatflux     = .FALSE.
+    IF ( top_heatflux     == 9999999.9 )  constant_top_heatflux = .FALSE.
 
 !
Index: /palm/trunk/SOURCE/diffusion_e.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_e.f90	(revision 19)
+++ /palm/trunk/SOURCE/diffusion_e.f90	(revision 20)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! Bugfix: ddzw dimensioned 1:nzt"+1"
 ! Calculation extended for gridpoint nzt
 !
@@ -51,5 +52,5 @@
        INTEGER ::  i, j, k
        REAL            ::  dpt_dz, l_stable, phi_m
-       REAL            ::  ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt), &
+       REAL            ::  ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt+1), &
                            l_grid(1:nzt), zu(0:nzt+1)
        REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) :: diss, tend
@@ -166,5 +167,5 @@
        INTEGER         ::  i, j, k
        REAL            ::  dpt_dz, l_stable, phi_m
-       REAL            ::  ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt), &
+       REAL            ::  ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt+1), &
                            l_grid(1:nzt), zu(0:nzt+1)
        REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ::  diss, tend
Index: /palm/trunk/SOURCE/diffusion_s.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_s.f90	(revision 19)
+++ /palm/trunk/SOURCE/diffusion_s.f90	(revision 20)
@@ -4,6 +4,7 @@
 ! Actual revisions:
 ! -----------------
+! Bugfix: ddzw dimensioned 1:nzt"+1"
 ! Calculation extended for gridpoint nzt, fluxes can be given at top,
-! +s_flux_t in parameter list, s_flux renamed s_flux_b
+! +s_flux_t in parameter list, s_flux renamed s_flux_b,
 !
 ! Former revisions:
@@ -50,5 +51,5 @@
        INTEGER ::  i, j, k
        REAL    ::  vertical_gridspace
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
        REAL, DIMENSION(:,:),   POINTER ::  s_flux_b, s_flux_t
@@ -134,7 +135,7 @@
                 tend(k,j,i) = tend(k,j,i)                                     &
                                        + ( - s_flux_t(j,i)                    &
-                                         - 0.5 * ( kh(k-1,j,i)+kh(k,j,i) )    &
-                                               * ( s(k,j,i)-s(k-1,j,i) )      &
-                                               * ddzu(k)                      &
+                                           - 0.5 * ( kh(k-1,j,i)+kh(k,j,i) )  &
+                                                 * ( s(k,j,i)-s(k-1,j,i) )    &
+                                                 * ddzu(k)                    &
                                          ) * ddzw(k)
 
@@ -161,5 +162,5 @@
        INTEGER ::  i, j, k
        REAL    ::  vertical_gridspace
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
        REAL, DIMENSION(:,:),   POINTER ::  s_flux_b, s_flux_t
Index: /palm/trunk/SOURCE/diffusion_u.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_u.f90	(revision 19)
+++ /palm/trunk/SOURCE/diffusion_u.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Bugfix: ddzw dimensioned 1:nzt"+1"
 ! 
 ! Former revisions:
@@ -52,5 +52,5 @@
        INTEGER ::  i, j, k
        REAL    ::  kmym_x, kmym_y, kmyp_x, kmyp_y, kmzm, kmzp, usvs
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_y(nys-1:nyn+1)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_y(nys-1:nyn+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
@@ -201,5 +201,5 @@
        INTEGER ::  i, j, k
        REAL    ::  kmym_x, kmym_y, kmyp_x, kmyp_y, kmzm, kmzp, usvs
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_y(nys-1:nyn+1)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_y(nys-1:nyn+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
Index: /palm/trunk/SOURCE/diffusion_v.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_v.f90	(revision 19)
+++ /palm/trunk/SOURCE/diffusion_v.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Bugfix: ddzw dimensioned 1:nzt"+1"
 !
 ! Former revisions:
@@ -52,5 +52,5 @@
        INTEGER ::  i, j, k
        REAL    ::  kmxm_x, kmxm_y, kmxp_x, kmxp_y, kmzm, kmzp, vsus
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_x(nxl-1:nxr+1)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
@@ -201,5 +201,5 @@
        INTEGER ::  i, j, k
        REAL    ::  kmxm_x, kmxm_y, kmxp_x, kmxp_y, kmzm, kmzp, vsus
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_x(nxl-1:nxr+1)
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
Index: /palm/trunk/SOURCE/diffusion_w.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_w.f90	(revision 19)
+++ /palm/trunk/SOURCE/diffusion_w.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Bugfix: ddzw dimensioned 1:nzt"+1"
 !
 ! Former revisions:
@@ -51,5 +51,5 @@
        REAL    ::  kmxm_x, kmxm_z, kmxp_x, kmxp_z, kmym_y, kmym_z, kmyp_y, &
                    kmyp_z, wsus, wsvs
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_x(nxl-1:nxr+1), &
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1), &
                    km_damp_y(nys-1:nyn+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
@@ -199,5 +199,5 @@
        REAL    ::  kmxm_x, kmxm_z, kmxp_x, kmxp_z, kmym_y, kmym_z, kmyp_y, &
                    kmyp_z, wsus, wsvs
-       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt), km_damp_x(nxl-1:nxr+1), &
+       REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1), &
                    km_damp_y(nys-1:nyn+1)
        REAL    ::  z0(nys-1:nyn+1,nxl-1:nxr+1)
Index: /palm/trunk/SOURCE/parin.f90
===================================================================
--- /palm/trunk/SOURCE/parin.f90	(revision 19)
+++ /palm/trunk/SOURCE/parin.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! +top_heatflux in inipar
+! +top_heatflux, use_top_fluxes in inipar
 !
 ! Former revisions:
@@ -74,6 +74,7 @@
                        ug_vertical_gradient, ug_vertical_gradient_level, &
                        ups_limit_e, ups_limit_pt, ups_limit_u, ups_limit_v, &
-                       ups_limit_w, use_surface_fluxes, use_ug_for_galilei_tr, &
-                       use_upstream_for_tke, vg_surface, vg_vertical_gradient, &
+                       ups_limit_w, use_surface_fluxes, use_top_fluxes, &
+                       use_ug_for_galilei_tr, use_upstream_for_tke, &
+                       vg_surface, vg_vertical_gradient, &
                        vg_vertical_gradient_level, wall_adjustment, &
                        wall_heatflux
Index: /palm/trunk/SOURCE/read_var_list.f90
===================================================================
--- /palm/trunk/SOURCE/read_var_list.f90	(revision 19)
+++ /palm/trunk/SOURCE/read_var_list.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! +top_heatflux
+! +top_heatflux, use_top_fluxes
 !
 ! Former revisions:
@@ -372,4 +372,6 @@
           CASE ( 'use_surface_fluxes' )
              READ ( 13 )  use_surface_fluxes
+          CASE ( 'use_top_fluxes' )
+             READ ( 13 )  use_top_fluxes
           CASE ( 'use_ug_for_galilei_tr' )
              READ ( 13 )  use_ug_for_galilei_tr
Index: /palm/trunk/SOURCE/write_var_list.f90
===================================================================
--- /palm/trunk/SOURCE/write_var_list.f90	(revision 19)
+++ /palm/trunk/SOURCE/write_var_list.f90	(revision 20)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! +top_heatflux
+! +top_heatflux, use_top_fluxes
 !
 ! Former revisions:
@@ -338,4 +338,6 @@
     WRITE ( 14 )  'use_surface_fluxes            '
     WRITE ( 14 )  use_surface_fluxes
+    WRITE ( 14 )  'use_top_fluxes                '
+    WRITE ( 14 )  use_top_fluxes
     WRITE ( 14 )  'use_ug_for_galilei_tr         '
     WRITE ( 14 )  use_ug_for_galilei_tr
