Index: /palm/trunk/SOURCE/calc_spectra.f90
===================================================================
--- /palm/trunk/SOURCE/calc_spectra.f90	(revision 1430)
+++ /palm/trunk/SOURCE/calc_spectra.f90	(revision 1431)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Wavenumber-integrated spectra coincide with respective variance. 
 ! 
 ! Former revisions:
@@ -198,5 +198,5 @@
 
     USE indices,                                                               &
-        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
+        ONLY:  ngp_2dh, nxl, nxr, nyn, nys, nzb, nzt
 
     USE kinds
@@ -208,5 +208,5 @@
 
     USE statistics,                                                            &
-        ONLY:  sums
+        ONLY:  hom, var_d
 
 
@@ -218,4 +218,6 @@
     INTEGER(iwp) :: m  !:
     INTEGER(iwp) :: pr !:
+
+    REAL(wp), DIMENSION(nzb:nzt+1) :: var_d_l
 
     SELECT CASE ( TRIM( data_output_sp(m) ) )
@@ -254,11 +256,24 @@
 !-- Subtract horizontal mean from the array, for which spectra have to be
 !-- calculated
+    var_d_l(:) = 0.0_wp
     DO  i = nxl, nxr
        DO  j = nys, nyn
           DO  k = nzb+1, nzt
-             d(k,j,i) = d(k,j,i) - sums(k,pr)
+             d(k,j,i)   = d(k,j,i) - hom(k,1,pr,0)
+             var_d_l(k) = var_d_l(k) + d(k,j,i) * d(k,j,i)
           ENDDO
        ENDDO
     ENDDO
+!
+!-- Compute total variance from local variances
+    var_d(:) = 0.0_wp
+#if defined( __parallel ) 
+    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
+    CALL MPI_ALLREDUCE( var_d_l(0), var_d(0), nzt+1-nzb, MPI_REAL,   &
+                        MPI_SUM, comm2d, ierr )
+#else
+    var_d(:) = var_d_l(:)
+#endif
+    var_d(:) = var_d(:) / ngp_2dh(0)
 
  END SUBROUTINE preprocess_spectra
@@ -290,5 +305,5 @@
 
     USE statistics,                                                            &
-        ONLY:  spectrum_x
+        ONLY:  spectrum_x, var_d
 
     USE transpose_indices,                                                     &
@@ -306,6 +321,7 @@
     INTEGER(iwp) ::  pr        !:
 
-    REAL(wp) ::  fac      !:
-    REAL(wp) ::  exponent !:
+    REAL(wp) ::  fac          !:
+    REAL(wp) ::  exponent     !:
+    REAL(wp) ::  sum_spec_dum !: wavenumber-integrated spectrum
     
     REAL(wp), DIMENSION(0:nx) ::  work !:
@@ -373,5 +389,10 @@
        sums_spectra(:,n) = sums_spectra_l
 #endif
-
+!
+!--    Normalize spectra by variance
+       sum_spec_dum = SUM( sums_spectra(:,n) )
+       IF ( sum_spec_dum /= 0.0_wp )  THEN
+          sums_spectra(:,n) = sums_spectra(:,n) * var_d(k) / sum_spec_dum
+       ENDIF
        n = n + 1
 
@@ -390,10 +411,9 @@
        DO  i = 1, nx/2
           DO k = 1, n
-             spectrum_x(i,k,m) = spectrum_x(i,k,m) + sums_spectra(i,k) * fac
+             spectrum_x(i,k,m) = spectrum_x(i,k,m) + sums_spectra(i,k) * fac 
           ENDDO
        ENDDO
 
     ENDIF
-
 !
 !-- n_sp_x is needed by data_output_spectra_x
@@ -428,5 +448,5 @@
 
     USE statistics,                                                            &
-        ONLY:  spectrum_y
+        ONLY:  spectrum_y, var_d
 
     USE transpose_indices,                                                     &
@@ -446,4 +466,5 @@
     REAL(wp) ::  fac      !:
     REAL(wp) ::  exponent !:
+    REAL(wp) ::  sum_spec_dum !: wavenumber-integrated spectrum
     
     REAL(wp), DIMENSION(0:ny) ::  work !:
@@ -512,5 +533,10 @@
        sums_spectra(:,n) = sums_spectra_l
 #endif
-
+!
+!--    Normalize spectra by variance
+       sum_spec_dum = SUM( sums_spectra(:,n) )
+       IF ( SUM(sums_spectra(:,n)) /= 0.0_wp )  THEN
+          sums_spectra(:,n) = sums_spectra(:,n) * var_d(k) / SUM(sums_spectra(:,n))
+       ENDIF
        n = n + 1
 
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 1430)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 1431)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! var_d added, in order to normalize spectra.
 ! 
 ! Former revisions:
@@ -224,5 +224,5 @@
                statistic_regions, sums, sums_divnew_l, sums_divold_l, sums_l,  &
                sums_l_l, sums_up_fraction_l, sums_wsts_bc_l, ts_value,         &
-               weight_pres, weight_substep 
+               var_d, weight_pres, weight_substep 
     
     USE transpose_indices 
@@ -492,4 +492,7 @@
        spectrum_x = 0.0_wp
        spectrum_y = 0.0_wp
+
+       ALLOCATE( var_d(nzb:nzt+1) )
+       var_d = 0.0_wp
     ENDIF
 
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 1430)
+++ /palm/trunk/SOURCE/modules.f90	(revision 1431)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! +var_d
 ! 
 ! Former revisions:
@@ -1411,5 +1411,6 @@
     REAL(wp) ::     u_max, v_max, w_max
     REAL(wp), DIMENSION(:), ALLOCATABLE       ::  sums_divnew_l, sums_divold_l,   &
-                                                  weight_substep, weight_pres
+                                                  var_d, weight_substep,          &
+                                                  weight_pres
     REAL(wp), DIMENSION(:,:), ALLOCATABLE     ::  sums, sums_wsts_bc_l, ts_value, &
                                                   sums_wsus_ws_l, sums_wsvs_ws_l, &
