Index: palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 2955)
+++ palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 2956)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! spectrum_x and spectrum_y have been moved to global data
+! 
+! 2921 2018-03-22 15:05:23Z Giersch
 ! spinup_time, day_of_year_init and time_utc_init are also read now
 ! 
@@ -117,5 +120,5 @@
 
        USE spectra_mod,                                                        &
-           ONLY:  average_count_sp
+           ONLY:  average_count_sp, spectrum_x, spectrum_y
 
        USE statistics,                                                         &
@@ -569,4 +572,14 @@
              CASE ( 'simulated_time' )
                 READ ( 13 )  simulated_time
+             CASE ( 'spectrum_x' )
+                IF ( .NOT. ALLOCATED( spectrum_x ) )  THEN
+                   ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ) )
+                ENDIF
+                READ ( 13 )  spectrum_x
+             CASE ( 'spectrum_y' )
+                IF ( .NOT. ALLOCATED( spectrum_y ) )  THEN
+                   ALLOCATE( spectrum_y( 1:ny/2, 1:100, 1:10 ) )
+                ENDIF
+                READ ( 13 )  spectrum_y
              CASE ( 'spinup_time' )
                 READ ( 13 )  spinup_time
@@ -1052,7 +1065,4 @@
         ONLY:  id_random_array, seq_random_array
 
-    USE spectra_mod,                                                           &
-        ONLY:  spectrum_x, spectrum_y
-
     USE surface_mod,                                                           &
         ONLY :  surface_rrd_local
@@ -1690,34 +1700,4 @@
                    shf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'spectrum_x' )
-                   IF ( k == 1 )  THEN
-                      IF ( nx_on_file /= nx )  THEN
-                         message_string = 'rrd_local: spectrum_x ' //          &
-                                     'on restart file ignored because' //      &
-                                     '&total numbers of grid points (nx) ' //  &
-                                     'do not match'
-                         CALL message( 'rrd_local', 'PA0293',                  &
-                                       0, 1, 0, 6, 0 )
-                         READ ( 13 )  rdummy
-                      ELSE
-                         READ ( 13 )  spectrum_x
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'spectrum_y' )
-                   IF ( k == 1 )  THEN
-                      IF ( ny_on_file /= ny )  THEN
-                         message_string = 'rrd_local: spectrum_y ' //          &
-                                     'on restart file ignored because' //      &
-                                     '&total numbers of grid points (ny) '//   &
-                                     'do not match'
-                         CALL message( 'rrd_local', 'PA0294',                  &
-                                       0, 1, 0, 6, 0 )
-                         READ ( 13 )  rdummy
-                      ELSE
-                         READ ( 13 )  spectrum_y
-                      ENDIF
-                   ENDIF
                    
                 CASE ( 'ssws_av' )
Index: palm/trunk/SOURCE/spectra_mod.f90
===================================================================
--- palm/trunk/SOURCE/spectra_mod.f90	(revision 2955)
+++ palm/trunk/SOURCE/spectra_mod.f90	(revision 2956)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! spectrum_x and spectrum_y will only be allocated if they are not allocated 
+! before (e.g. in case of restart runs) 
+! 
+! 2932 2018-03-26 09:39:22Z maronga
 ! renamed spectra_par to spectra_parameters
 ! 
@@ -291,8 +295,14 @@
 
        IF ( dt_dosp /= 9999999.9_wp )  THEN
-          ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ),                         &
-                    spectrum_y( 1:ny/2, 1:100, 1:10 ) )
-          spectrum_x = 0.0_wp
-          spectrum_y = 0.0_wp
+
+          IF ( .NOT. ALLOCATED( spectrum_x ) )  THEN
+             ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ) )
+             spectrum_x = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED( spectrum_y ) )  THEN
+             ALLOCATE( spectrum_y( 1:ny/2, 1:100, 1:10 ) )
+             spectrum_y = 0.0_wp
+          ENDIF
 
           ALLOCATE( var_d(nzb:nzt+1) )
Index: palm/trunk/SOURCE/write_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/write_restart_data_mod.f90	(revision 2955)
+++ palm/trunk/SOURCE/write_restart_data_mod.f90	(revision 2956)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! spectrum_x and spectrum_y have been moved to global data
+! 
+! 2921 2018-03-22 15:05:23Z Giersch
 ! spinup_time, day_of_year_init and time_utc_init are also written out now
 ! 
@@ -93,5 +96,5 @@
 
        USE indices,                                                            &
-           ONLY:  nz, nx, ny
+           ONLY:  nx, ny, nz
 
        USE microphysics_mod,                                                   &
@@ -116,5 +119,5 @@
 
        USE spectra_mod,                                                        &
-           ONLY:  average_count_sp
+           ONLY:  average_count_sp, spectrum_x, spectrum_y
 
        USE synthetic_turbulence_generator_mod,                                 &
@@ -640,4 +643,11 @@
        CALL wrd_write_string( 'simulated_time' ) 
        WRITE ( 14 )  simulated_time
+
+       IF ( ALLOCATED( spectrum_x ) )  THEN
+          CALL wrd_write_string( 'spectrum_x' ) 
+          WRITE ( 14 )  spectrum_x
+          CALL wrd_write_string( 'spectrum_y' ) 
+          WRITE ( 14 )  spectrum_y
+       ENDIF
 
        CALL wrd_write_string( 'spinup_time ' ) 
@@ -958,7 +968,4 @@
        USE random_generator_parallel,                                          &
            ONLY:  id_random_array, seq_random_array
-        
-       USE spectra_mod,                                                        &
-           ONLY:  spectrum_x, spectrum_y
 
        USE surface_mod,                                                        &
@@ -1220,11 +1227,4 @@
        ENDIF
 
-       IF ( ALLOCATED( spectrum_x ) )  THEN
-          CALL wrd_write_string( 'spectrum_x' ) 
-          WRITE ( 14 )  spectrum_x
-          CALL wrd_write_string( 'spectrum_y' ) 
-          WRITE ( 14 )  spectrum_y
-       ENDIF
-
        IF ( ALLOCATED( ts_av ) )  THEN
           CALL wrd_write_string( 'ts_av' ) 
