Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 2893)
+++ palm/trunk/SOURCE/Makefile	(revision 2894)
@@ -25,4 +25,10 @@
 # -----------------
 # $Id$
+# read/write_3d_binary and read/write_var_list has been removed, 
+# read/write_restart_data_mod, wrd_write_string and
+# user_read/write_restart_data_mod has been added, dependencies with respect to 
+# the aforementioned routines have been added/removed
+#
+# 2847 2018-03-02 21:45:58Z suehring
 # Changed format and enforced sorting
 # 
@@ -66,9 +72,9 @@
 # virtual_flight_mod, synthetic_turbulence_generator_mod and
 # wind_turbine_model_mod were added to read_var_list
-# 
+#
 # 2563 2017-10-19 15:36:10Z Giersch
 # wind_turbine_model_mod and synthetic_turbulence_generator_mod were added to
-# write_var_list and virtual_flight_mod was deleted from read_var_list  
-# 
+# write_var_list and virtual_flight_mod was deleted from read_var_list 
+#
 # 2544 2017-10-13 18:09:32Z maronga
 # Added date_and_time_mod 
@@ -533,6 +539,5 @@
 	random_gauss.f90 \
 	random_generator_parallel_mod.f90 \
-	read_3d_binary.f90 \
-	read_var_list.f90 \
+        read_restart_data_mod.f90 \
 	run_control.f90 \
 	set_slicer_attributes_dvrp.f90 \
@@ -585,13 +590,14 @@
 	user_module.f90 \
 	user_parin.f90 \
-	user_read_restart_data.f90 \
+	user_read_restart_data_mod.f90 \
 	user_spectra.f90 \
 	user_statistics.f90 \
+	user_write_restart_data_mod.f90 \
 	uv_exposure_model_mod.f90 \
 	vertical_nesting_mod.f90 \
 	virtual_flight_mod.f90 \
 	wind_turbine_model_mod.f90 \
-	write_3d_binary.f90 \
-	write_var_list.f90
+	wrd_write_string.f90 \
+        write_restart_data_mod.f90
 
 
@@ -625,5 +631,4 @@
 .f90.o:
 	$(F90) $(F90FLAGS) $(COPT) -c $<
-
 
 
@@ -934,4 +939,5 @@
 	random_function_mod.o \
 	random_generator_parallel_mod.o \
+	read_restart_data_mod.o \
 	surface_layer_fluxes_mod.o \
 	surface_mod.o \
@@ -1181,5 +1187,6 @@
 	pmc_interface_mod.o \
 	pmc_particle_interface.o \
-	surface_layer_fluxes_mod.o
+	surface_layer_fluxes_mod.o \
+	write_restart_data_mod.o
 parin.o: \
 	chemistry_model_mod.o \
@@ -1198,4 +1205,5 @@
 	progress_bar_mod.o \
 	radiation_model_mod.o \
+	read_restart_data_mod.o \
 	spectra_mod.o \
 	synthetic_turbulence_generator_mod.o \
@@ -1334,27 +1342,21 @@
 	mod_kinds.o \
 	modules.o
-read_3d_binary.o: \
+read_restart_data_mod.o: \
 	chemistry_model_mod.o \
-	cpulog_mod.o \
-	gust_mod.o \
-	land_surface_model_mod.o \
-	mod_kinds.o \
-	modules.o \
+	cpulog_mod.o\
+	land_surface_model_mod.o \
+	microphysics_mod.o \
+	modules.o \
+	mod_kinds.o \
+	model_1d_mod.o \
+	netcdf_interface_mod.o \
 	radiation_model_mod.o \
-	random_function_mod.o \
+	random_function_mod.o\
 	random_generator_parallel_mod.o \
 	spectra_mod.o \
 	surface_mod.o \
-	urban_surface_mod.o
-read_var_list.o: \
-	microphysics_mod.o \
-	model_1d_mod.o \
-	mod_kinds.o \
-	modules.o \
-	netcdf_interface_mod.o \
-	plant_canopy_model_mod.o \
-	spectra_mod.o \
 	synthetic_turbulence_generator_mod.o \
 	urban_surface_mod.o \
+	user_read_restart_data_mod.o \
 	vertical_nesting_mod.o \
 	virtual_flight_mod.o \
@@ -1631,6 +1633,5 @@
 	modules.o \
 	user_module.o
-user_read_restart_data.o: \
-	mod_kinds.o \
+user_read_restart_data_mod.o: \
 	modules.o \
 	user_module.o
@@ -1644,4 +1645,6 @@
 	modules.o \
 	netcdf_interface_mod.o \
+	user_module.o
+user_write_restart_data_mod.o: \
 	user_module.o
 uv_exposure_model_mod.o: \
@@ -1666,26 +1669,23 @@
 	mod_kinds.o \
 	modules.o
-write_3d_binary.o: \
-	cpulog_mod.o \
-	gust_mod.o \
-	mod_kinds.o \
-	modules.o \
+wrd_write_string.o: \
+	mod_kinds.o
+write_restart_data_mod.o: \
+	chemistry_model_mod.o \
+	land_surface_model_mod.o \
+	microphysics_mod.o \
+	mod_kinds.o \
+	mod_particle_attributes.o \
+	model_1d_mod.o \
+	modules.o \
+	netcdf_interface_mod.o \
 	radiation_model_mod.o \
 	random_function_mod.o \
 	random_generator_parallel_mod.o \
-	spectra_mod.o \
-	surface_mod.o
-write_var_list.o: \
-	chemistry_model_mod.o \
-	microphysics_mod.o \
-	model_1d_mod.o \
-	mod_kinds.o \
-	modules.o \
-	netcdf_interface_mod.o \
-	plant_canopy_model_mod.o\
-	spectra_mod.o \
+	spectra_mod.o surface_mod.o \
 	synthetic_turbulence_generator_mod.o \
 	urban_surface_mod.o \
+	user_write_restart_data_mod.o \
 	vertical_nesting_mod.o \
-	virtual_flight_mod.o\
+	virtual_flight_mod.o \
 	wind_turbine_model_mod.o
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 2894)
@@ -27,4 +27,19 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod,
+! chem_last_actions was renamed to chem_wrd_local, chem_read_restart_data was
+! renamed to chem_rrd_local, chem_write_var_list was renamed to 
+! chem_wrd_global, chem_read_var_list was renamed to chem_rrd_global, 
+! chem_skip_var_list has been removed, variable named found has been
+! introduced for checking if restart data was found, reading of restart strings
+! has been moved completely to read_restart_data_mod, chem_rrd_local is already
+! inside the overlap loop programmed in read_restart_data_mod, todo list has 
+! bees extended, redundant characters in chem_wrd_local have been removed, 
+! the marker *** end chemistry *** is not necessary anymore, strings and their 
+! respective lengths are written out and read now in case of restart runs to 
+! get rid of prescribed character lengths
+!
+! 2815 2018-02-19 11:29:57Z suehring
 ! Bugfix in restart mechanism,
 ! rename chem_tendency to chem_prognostic_equations,
@@ -65,4 +80,7 @@
 ! ------------
 !> Chemistry model for PALM-4U
+!> @todo Adjust chem_rrd_local to CASE structure of others modules. It is not 
+!>       allowed to use the chemistry model in a precursor run and additionally 
+!>       not using it in a main run
 !> @todo Update/clean-up todo list! (FK)
 !> @todo Set proper fill values (/= 0) for chem output arrays! (FK)
@@ -208,11 +226,11 @@
    END INTERFACE chem_3d_data_averaging
 
-   INTERFACE chem_last_actions
-      MODULE PROCEDURE chem_last_actions 
-   END INTERFACE chem_last_actions
-
-   INTERFACE chem_read_restart_data
-      MODULE PROCEDURE chem_read_restart_data
-   END INTERFACE chem_read_restart_data
+   INTERFACE chem_wrd_local
+      MODULE PROCEDURE chem_wrd_local 
+   END INTERFACE chem_wrd_local
+
+   INTERFACE chem_rrd_local
+      MODULE PROCEDURE chem_rrd_local
+   END INTERFACE chem_rrd_local
 
    INTERFACE chem_prognostic_equations
@@ -229,15 +247,11 @@
    END INTERFACE chem_emissions
 
-!    INTERFACE chem_write_var_list
-!       MODULE PROCEDURE chem_write_var_list
-!    END INTERFACE chem_write_var_list
-! 
-!    INTERFACE chem_read_var_list
-!       MODULE PROCEDURE chem_read_var_list
-!    END INTERFACE chem_read_var_list
-! 
-!    INTERFACE chem_skip_var_list
-!       MODULE PROCEDURE chem_skip_var_list
-!    END INTERFACE chem_skip_var_list
+!    INTERFACE chem_wrd_global
+!       MODULE PROCEDURE chem_wrd_global
+!    END INTERFACE chem_wrd_global
+! 
+!    INTERFACE chem_rrd_global
+!       MODULE PROCEDURE chem_rrd_global
+!    END INTERFACE chem_rrd_global
 
 
@@ -245,9 +259,8 @@
           chem_check_data_output_pr, chem_data_output_3d,                      &
           chem_define_netcdf_grid, chem_emissions, chem_header, chem_init,     &
-          chem_init_profiles, chem_integrate, chem_last_actions,               &
+          chem_init_profiles, chem_integrate, chem_wrd_local,                  &
           chem_parin, chem_prognostic_equations,                               &
-          chem_read_restart_data, chem_swap_timelevel
+          chem_rrd_local, chem_swap_timelevel
           
-
 
  CONTAINS
@@ -849,9 +862,4 @@
       air_chemistry = .TRUE.                    
 
-!
-!--   FK: Not in use/needed (yet), since chemistry_par namelist is always read in
-!       IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
-!          CALL chem_read_var_list
-!       ENDIF
       
  10   CONTINUE
@@ -1309,35 +1317,26 @@
 !> Subroutine to write restart data for chemistry model
 !------------------------------------------------------------------------------!
- SUBROUTINE chem_last_actions
- 
-
-    USE control_parameters
-    
-    USE kinds
+ SUBROUTINE chem_wrd_local
+
 
     IMPLICIT NONE 
 
     INTEGER(iwp) ::  lsp !< 
-    CHARACTER(LEN=20) ::  cspcs_name
-    CHARACTER(LEN=20) ::  cspcs_name_av
+
 !      REAL(kind=wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg)   :: chems_conc
 
 
-    IF ( write_binary )  THEN
-       DO  lsp = 1, nspec
-          cspcs_name    = '                    '
-          cspcs_name_av = '                    '
-          cspcs_name    = TRIM(chem_species(lsp)%name)
-          cspcs_name_av = TRIM(chem_species(lsp)%name)//'_av'
-
-          WRITE(14) cspcs_name   ; WRITE(14) chem_species(lsp)%conc
-          WRITE(14) cspcs_name_av; WRITE(14) chem_species(lsp)%conc_av
-       ENDDO
-   
-       WRITE ( 14 )       '*** end chem ***    '
-
-    ENDIF
-
- END SUBROUTINE chem_last_actions
+    DO  lsp = 1, nspec
+
+       CALL wrd_write_string( TRIM( chem_species(lsp)%name ))
+       WRITE ( 14 )  chem_species(lsp)%conc
+
+       CALL wrd_write_string( TRIM( chem_species(lsp)%name )//'_av' )
+       WRITE ( 14 )  chem_species(lsp)%conc_av
+
+    ENDDO
+
+
+ END SUBROUTINE chem_wrd_local
 
 !------------------------------------------------------------------------------!
@@ -1348,8 +1347,7 @@
 !------------------------------------------------------------------------------!
 
- SUBROUTINE chem_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
-                                    nynfa, nyn_on_file, nysfa, nys_on_file,    &
-                                    offset_xa, offset_ya, overlap_count,       &
-                                    tmp_2d, tmp_3d )    
+ SUBROUTINE chem_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,         &
+                            nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,  &
+                            nys_on_file, tmp_3d, found )    
                                      
     USE control_parameters
@@ -1357,11 +1355,8 @@
     USE indices
     
-    USE kinds
-    
     USE pegrid
 
     IMPLICIT NONE 
 
-    CHARACTER (LEN=20) :: field_char !<   
     CHARACTER (LEN=20) :: spc_name_av !<   
        
@@ -1380,77 +1375,43 @@
     INTEGER(iwp) ::  nysf            !< 
     INTEGER(iwp) ::  nys_on_file     !<   
-    INTEGER(iwp) ::  overlap_count   !<   
-
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<   
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !<  
     
-    LOGICAL ::  chem_found 
-!!
-    REAL(wp),                                                                  &
-       DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_2d   !< 2D array to temp store data
-
-    REAL(wp),                                                                  &
-       DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_3d   !< 3D array to temp store data
-
-
-    IF ( initializing_actions == 'read_restart_data' )  THEN
-       READ ( 13 )  field_char
-       DO  WHILE ( TRIM( field_char ) /= '*** end chem ***    ' )
-
-          DO  k = 1, overlap_count
-
-             nxlf = nxlfa(i,k)
-             nxlc = nxlfa(i,k) + offset_xa(i,k)
-             nxrf = nxrfa(i,k)
-             nxrc = nxrfa(i,k) + offset_xa(i,k)
-             nysf = nysfa(i,k)
-             nysc = nysfa(i,k) + offset_ya(i,k)
-             nynf = nynfa(i,k)
-             nync = nynfa(i,k) + offset_ya(i,k)
-             
-
-             chem_found = .FALSE.
-  
-             DO  lsp = 1, nspec
-
-                spc_name_av  =  TRIM(chem_species(lsp)%name)//'_av'   !< for time-averaged chemical conc.
-                IF (TRIM( field_char ) == TRIM(chem_species(lsp)%name) )  THEN
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   chem_species(lsp)%conc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                   chem_found = .TRUE.
-                ELSEIF (TRIM( field_char ) == spc_name_av )  THEN
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   chem_species(lsp)%conc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
-                                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                   chem_found = .TRUE.
-                ENDIF
-
-             ENDDO
-             IF (  .NOT.  chem_found )  THEN
-                WRITE( message_string, * ) 'unknown variable named "',         &
-                                        TRIM( field_char ), '" found in',      &
-                                        '&data from prior run on PE ', myid
-                CALL message( 'chem_read_restart_data', 'CM0008', 1, 2, 0, 6, 0 )
+    LOGICAL, INTENT(OUT)  :: found 
+
+    REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !< 3D array to temp store data
+
+
+    found = .FALSE.  
+
+
+       IF ( ALLOCATED(chem_species) )  THEN
+
+          DO  lsp = 1, nspec
+
+              !< for time-averaged chemical conc.
+             spc_name_av  =  TRIM(chem_species(lsp)%name)//'_av'
+
+             IF (restart_string(1:length) == TRIM(chem_species(lsp)%name) )    &
+             THEN
+                !< read data into tmp_3d
+                IF ( k == 1 )  READ ( 13 )  tmp_3d  
+                !< fill ..%conc in the restart run    
+                chem_species(lsp)%conc(:,nysc-nbgp:nync+nbgp,                  &
+                                       nxlc-nbgp:nxrc+nbgp) =                  & 
+                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                found = .TRUE.
+             ELSEIF (restart_string(1:length) == spc_name_av )  THEN
+                IF ( k == 1 )  READ ( 13 )  tmp_3d
+                chem_species(lsp)%conc_av(:,nysc-nbgp:nync+nbgp,               &
+                                          nxlc-nbgp:nxrc+nbgp) =               &
+                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                found = .TRUE.
              ENDIF
+
           ENDDO
 
-          READ ( 13 )  field_char
-
-       ENDDO
-
-!        IF (TRIM( field_char ) == TRIM('surface_csflux') )      THEN
-!           READ ( 13 ) surface_csflux
-!        ENDIF
-
-    ENDIF
-
- END SUBROUTINE chem_read_restart_data
+       ENDIF
+
+
+ END SUBROUTINE chem_rrd_local
 
 
@@ -1756,57 +1717,37 @@
 !       also in case of a restart run)
 !------------------------------------------------------------------------------
-!  SUBROUTINE chem_read_var_list
-! 
-! !   USE kinds
-! !   USE chem_modules
+!  SUBROUTINE chem_rrd_global
+!
+!    USE chem_modules
+!
+!    USE control_parameters,                                                   &
+!        ONLY: length, message_string, restart_string
 ! 
 !     
 !     IMPLICIT NONE
 !     
-!     CHARACTER (LEN=30) ::  variable_chr !< dummy variable to read string
 !     
 !     
-!     READ ( 13 )  variable_chr
-!     DO  WHILE ( TRIM( variable_chr ) /= '*** end chemistry ***' )
-! 
-!        SELECT CASE ( TRIM( variable_chr ) )
+!     DO
+! 
+!        SELECT CASE ( restart_string(1:length) )
 !        
 !           CASE ( 'bc_cs_b' )
 !              READ ( 13 )  bc_cs_b
-!    
-!        
+!
+!           CASE DEFAULT
+!
+!              EXIT
+!            
 !        END SELECT
 !        
-!        READ ( 13 )  variable_chr
+!!
+!!--     Read next string and its length
+!        READ ( 13 )  length
+!        READ ( 13 )  restart_string(1:length)
 !        
 !     ENDDO
 !     
-!  END SUBROUTINE chem_read_var_list
-
-!------------------------------------------------------------------------------
-! Description:
-! ------------
-!> Skipping the chemistry-module parameters from restart-file (binary format).
-!  (FK: To make restarts work, I had to comment this routine. We actually
-!       don't need it, since the namelist parameters are always read in,
-!       also in case of a restart run)
-!------------------------------------------------------------------------------
-!  SUBROUTINE chem_skip_var_list 
-!       
-!     IMPLICIT NONE
-!           
-!     CHARACTER (LEN=1)  ::  cdum
-!     CHARACTER (LEN=30) ::  variable_chr
-!           
-!     READ ( 13 )  variable_chr
-! 
-!     DO  WHILE ( TRIM( variable_chr ) /= '*** end chemistry ***' )
-! 
-!        READ ( 13 )  cdum
-!        READ ( 13 )  variable_chr
-! 
-!     ENDDO   
-!           
-!  END SUBROUTINE chem_skip_var_list
+!  END SUBROUTINE chem_rrd_global
 
 
@@ -1820,5 +1761,5 @@
 !       also in case of a restart run)
 !------------------------------------------------------------------------------!
-!  SUBROUTINE chem_write_var_list
+!  SUBROUTINE chem_wrd_global
 ! 
 !     USE chem_modules
@@ -1835,11 +1776,10 @@
 ! !-- (namelist parameters are anyway read in again in case of restart)
 !     DO lsp = 1, nvar
-!        WRITE ( 14 )  'conc_pr_init_'//chem_species(lsp)%name 
+!        CALL wrd_write_string( 'conc_pr_init_'//chem_species(lsp)%name )
 !        WRITE ( 14 )  chem_species(lsp)%conc_pr_init
 !     ENDDO
 ! 
-!     WRITE ( 14 )     '*** end chemistry ***         '
-! 
-!  END SUBROUTINE chem_write_var_list
+! 
+!  END SUBROUTINE chem_wrd_global
 
 
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 2893)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 2894)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Renamed routines with respect to reading restart data, file 13 is closed in
+! rrd_read_parts_of_global now
+! 
+! 2867 2018-03-09 09:40:23Z suehring
 ! Further bugfix concerning call of user_init. 
 ! 
@@ -492,4 +496,7 @@
     USE random_generator_parallel,                                             &
         ONLY:  init_parallel_random_generator
+
+    USE read_restart_data_mod,                                                 &
+        ONLY:  rrd_read_parts_of_global, rrd_local                                      
     
     USE statistics,                                                            &
@@ -1611,6 +1618,5 @@
           DO  i = 0, io_blocks-1
              IF ( i == io_group )  THEN
-                CALL read_parts_of_var_list
-                CALL close_file( 13 )
+                CALL rrd_read_parts_of_global
              ENDIF
 #if defined( __parallel )
@@ -1622,8 +1628,8 @@
 
 !
-!--    Read binary data from restart file
+!--    Read processor specific binary data from restart file
        DO  i = 0, io_blocks-1
           IF ( i == io_group )  THEN
-             CALL read_3d_binary
+             CALL rrd_local
           ENDIF
 #if defined( __parallel )
Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2894)
@@ -25,4 +25,18 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod,
+! lsm_read/write_restart_data was renamed to lsm_r/wrd_local, USE kinds has 
+! been removed in several routines, variable named found has been
+! introduced for checking if restart data was found, reading of restart strings
+! has been moved completely to read_restart_data_mod, lsm_rrd_local is already
+! inside the overlap loop programmed in read_restart_data_mod, the marker ***
+! end lsm *** is not necessary anymore, strings and their respective lengths 
+! are written out and read now in case of restart runs to get rid of prescribed
+! character lengths, SAVE attribute added where necessary, deallocation and 
+! allocation of some arrays have been changed to take care of different restart
+! files that can be opened (index i)
+! 
+! 2881 2018-03-13 16:24:40Z suehring
 ! Bugfix: wrong loop structure for soil moisture calculation
 ! 
@@ -85,5 +99,5 @@
 ! radiation quantities belong to surface type now
 ! surface fractions initialized
-! Rename lsm_last_actions into lsm_write_restart_data (MS)
+! Rename lsm_last_actions into lsm_wrd_subdomain (MS)
 ! 
 ! 2608 2017-11-13 14:04:26Z schwenkel
@@ -872,5 +886,5 @@
            lsm_data_output_2d, lsm_data_output_3d, lsm_energy_balance,         &
            lsm_header, lsm_init, lsm_init_arrays, lsm_parin, lsm_soil_model,   &
-           lsm_swap_timelevel, lsm_read_restart_data, lsm_write_restart_data
+           lsm_swap_timelevel, lsm_rrd_local, lsm_wrd_local
 ! !vegetat
 !-- Public parameters, constants and initial values
@@ -945,11 +959,11 @@
     END INTERFACE lsm_swap_timelevel
 
-    INTERFACE lsm_read_restart_data
-       MODULE PROCEDURE lsm_read_restart_data
-    END INTERFACE lsm_read_restart_data
-
-    INTERFACE lsm_write_restart_data
-       MODULE PROCEDURE lsm_write_restart_data
-    END INTERFACE lsm_write_restart_data
+    INTERFACE lsm_rrd_local
+       MODULE PROCEDURE lsm_rrd_local
+    END INTERFACE lsm_rrd_local
+
+    INTERFACE lsm_wrd_local
+       MODULE PROCEDURE lsm_wrd_local
+    END INTERFACE lsm_wrd_local
 
  CONTAINS
@@ -1591,5 +1605,5 @@
           message_string = 'invalid soil layer configuration found ' //        &
                            '(dz_soil_center(k) = 0.0)'
-          CALL message( 'lsm_read_restart_data', 'PA0140', 1, 2, 0, 6, 0 )
+          CALL message( 'lsm_rrd_local', 'PA0140', 1, 2, 0, 6, 0 )
        ENDIF  
     ENDDO
@@ -4301,5 +4315,5 @@
           message_string = 'For non-pavement surfaces the combination ' //     &
                            ' lai = 0.0 and c_veg = 1.0 is not allowed.'
-          CALL message( 'lsm_read_restart_data', 'PA0999', 2, 2, 0, 6, 0 )
+          CALL message( 'lsm_rrd_local', 'PA0999', 2, 2, 0, 6, 0 )
        ENDIF
 
@@ -4310,5 +4324,5 @@
              message_string = 'For non-pavement surfaces the combination ' //  &
                               ' lai = 0.0 and c_veg = 1.0 is not allowed.'
-             CALL message( 'lsm_read_restart_data', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'lsm_rrd_local', 'PA0999', 2, 2, 0, 6, 0 )
           ENDIF
        ENDDO
@@ -5015,6 +5029,4 @@
     USE indices
 
-    USE kinds
-
     IMPLICIT NONE
 
@@ -5349,6 +5361,4 @@
     USE indices
 
-    USE kinds
-
 
     IMPLICIT NONE
@@ -5608,6 +5618,4 @@
 
     USE indices
-
-    USE kinds
 
 
@@ -5688,12 +5696,9 @@
 ! Description:
 ! ------------
-!> Write restart data for land surface model
+!> Write restart data for land surface model. It is necessary to write 
+!> start_index and end_index several times.
 !------------------------------------------------------------------------------!
- SUBROUTINE lsm_write_restart_data
- 
-
-    USE control_parameters
+ SUBROUTINE lsm_wrd_local
         
-    USE kinds
 
     IMPLICIT NONE
@@ -5702,123 +5707,172 @@
     INTEGER(iwp)      ::  l      !< index variable for surface orientation
 
-    IF ( write_binary )  THEN
-
-
-       WRITE ( 14 ) 'ns_h_on_file_lsm    '
-       WRITE ( 14 ) surf_lsm_h%ns
-       WRITE ( 14 ) 'ns_v_on_file_lsm    '
-       WRITE ( 14 ) surf_lsm_v(0:3)%ns
-
-       IF ( ALLOCATED( c_liq_av ) )  THEN
-          WRITE ( 14 )  'c_liq_av            ';  WRITE ( 14 ) c_liq_av
-       ENDIF
-       IF ( ALLOCATED( c_soil_av ) )  THEN
-          WRITE ( 14 )  'c_soil_av           ';  WRITE ( 14 ) c_soil_av
-       ENDIF
-       IF ( ALLOCATED( c_veg_av ) )  THEN
-          WRITE ( 14 )  'c_veg_av            ';  WRITE ( 14 ) c_veg_av
-       ENDIF
-       IF ( ALLOCATED( lai_av ) )  THEN
-          WRITE ( 14 )  'lai_av              ';  WRITE ( 14 )  lai_av
-       ENDIF
-       IF ( ALLOCATED( m_liq_av ) )  THEN
-          WRITE ( 14 )  'm_liq_av            ';  WRITE ( 14 )  m_liq_av
-       ENDIF
-       IF ( ALLOCATED( m_soil_av ) )  THEN
-          WRITE ( 14 )  'm_soil_av           ';  WRITE ( 14 )  m_soil_av
-       ENDIF
-       IF ( ALLOCATED( qsws_liq_av ) )  THEN
-          WRITE ( 14 )  'qsws_liq_av         ';  WRITE ( 14 )  qsws_liq_av
-       ENDIF  
-       IF ( ALLOCATED( qsws_soil_av ) )  THEN
-          WRITE ( 14 )  'qsws_soil_av        ';  WRITE ( 14 )  qsws_soil_av
-       ENDIF 
-       IF ( ALLOCATED( qsws_veg_av ) )  THEN
-          WRITE ( 14 )  'qsws_veg_av         ';  WRITE ( 14 )  qsws_veg_av
-       ENDIF 
-       IF ( ALLOCATED( t_soil_av ) )  THEN
-          WRITE ( 14 )  't_soil_av           ';  WRITE ( 14 )  t_soil_av
-       ENDIF
+    CALL wrd_write_string( 'ns_h_on_file_lsm' )
+    WRITE ( 14 )  surf_lsm_h%ns
+
+    CALL wrd_write_string( 'ns_v_on_file_lsm' )
+    WRITE ( 14 )  surf_lsm_v(0:3)%ns
+
+
+    IF ( ALLOCATED( c_liq_av ) )  THEN
+       CALL wrd_write_string( 'c_liq_av' )
+       WRITE ( 14 )  c_liq_av
+    ENDIF
+
+    IF ( ALLOCATED( c_soil_av ) )  THEN
+       CALL wrd_write_string( 'c_soil_av' )
+       WRITE ( 14 )  c_soil_av
+    ENDIF
+
+    IF ( ALLOCATED( c_veg_av ) )  THEN
+       CALL wrd_write_string( 'c_veg_av' )
+       WRITE ( 14 )  c_veg_av
+    ENDIF
+
+    IF ( ALLOCATED( lai_av ) )  THEN
+       CALL wrd_write_string( 'lai_av' )
+       WRITE ( 14 )  lai_av
+    ENDIF
+
+    IF ( ALLOCATED( m_liq_av ) )  THEN
+       CALL wrd_write_string( 'm_liq_av' )
+       WRITE ( 14 )  m_liq_av
+    ENDIF
+
+    IF ( ALLOCATED( m_soil_av ) )  THEN
+       CALL wrd_write_string( 'm_soil_av' )
+       WRITE ( 14 )  m_soil_av
+    ENDIF
+
+    IF ( ALLOCATED( qsws_liq_av ) )  THEN
+       CALL wrd_write_string( 'qsws_liq_av' )
+       WRITE ( 14 )  qsws_liq_av
+    ENDIF
+
+    IF ( ALLOCATED( qsws_soil_av ) )  THEN
+       CALL wrd_write_string( 'qsws_soil_av' )
+       WRITE ( 14 )  qsws_soil_av
+    ENDIF
+
+    IF ( ALLOCATED( qsws_veg_av ) )  THEN
+       CALL wrd_write_string( 'qsws_veg_av' )
+       WRITE ( 14 )  qsws_veg_av
+    ENDIF
+
+    IF ( ALLOCATED( t_soil_av ) )  THEN
+       CALL wrd_write_string( 't_soil_av' )
+       WRITE ( 14 )  t_soil_av
+    ENDIF
+
+    CALL wrd_write_string( 'lsm_start_index_h' )
+    WRITE ( 14 )  surf_lsm_h%start_index
+
+    CALL wrd_write_string( 'lsm_end_index_h' )
+    WRITE ( 14 )  surf_lsm_h%end_index
+
+    CALL wrd_write_string( 't_soil_h' )
+    WRITE ( 14 )  t_soil_h%var_2d
        
-       WRITE ( 14 ) 'lsm_start_index_h   '
-       WRITE ( 14 ) surf_lsm_h%start_index
-       WRITE ( 14 ) 'lsm_end_index_h     '
-       WRITE ( 14 ) surf_lsm_h%end_index
-       WRITE ( 14 ) 't_soil_h            '
-       WRITE ( 14 ) t_soil_h%var_2d
+
        
-       DO  l = 0, 3
-          WRITE ( 14 ) 'lsm_start_index_v   '
-          WRITE ( 14 ) surf_lsm_v(l)%start_index
-          WRITE ( 14 ) 'lsm_end_index_v     '
-          WRITE ( 14 ) surf_lsm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 ) 't_soil_v(' // dum // ')         ' 
-          WRITE ( 14 ) t_soil_v(l)%var_2d          
-       ENDDO
-
-       WRITE ( 14 ) 'lsm_start_index_h   '
-       WRITE ( 14 ) surf_lsm_h%start_index
-       WRITE ( 14 ) 'lsm_end_index_h     '
-       WRITE ( 14 ) surf_lsm_h%end_index
-       WRITE ( 14 ) 'm_soil_h            '
-       WRITE ( 14 ) m_soil_h%var_2d
+    DO  l = 0, 3
+
+       CALL wrd_write_string( 'lsm_start_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%start_index
+
+       CALL wrd_write_string( 'lsm_end_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%end_index
+
+       WRITE( dum, '(I1)')  l   
+
+       CALL wrd_write_string( 't_soil_v(' // dum // ')' )
+       WRITE ( 14 )  t_soil_v(l)%var_2d
+             
+    ENDDO
+
+    CALL wrd_write_string( 'lsm_start_index_h' )
+    WRITE ( 14 )  surf_lsm_h%start_index
+
+    CALL wrd_write_string( 'lsm_end_index_h' )
+    WRITE ( 14 )  surf_lsm_h%end_index
+
+    CALL wrd_write_string( 'm_soil_h' )
+    WRITE ( 14 )  m_soil_h%var_2d
+
+    DO  l = 0, 3
+
+       CALL wrd_write_string( 'lsm_start_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%start_index
+
+       CALL wrd_write_string( 'lsm_end_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%end_index
+
+       WRITE( dum, '(I1)')  l   
+
+       CALL wrd_write_string( 'm_soil_v(' // dum // ')' )
+       WRITE ( 14 )  m_soil_v(l)%var_2d 
+      
+    ENDDO
+
+    CALL wrd_write_string( 'lsm_start_index_h' )
+    WRITE ( 14 )  surf_lsm_h%start_index
+
+    CALL wrd_write_string( 'lsm_end_index_h' )
+    WRITE ( 14 )  surf_lsm_h%end_index
+
+    CALL wrd_write_string( 'm_liq_h' )
+    WRITE ( 14 )  m_liq_h%var_1d
        
-       DO  l = 0, 3
-          WRITE ( 14 ) 'lsm_start_index_v   '
-          WRITE ( 14 ) surf_lsm_v(l)%start_index
-          WRITE ( 14 ) 'lsm_end_index_v     '
-          WRITE ( 14 ) surf_lsm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 ) 'm_soil_v(' // dum // ')         ' 
-          WRITE ( 14 ) m_soil_v(l)%var_2d          
-       ENDDO
-
-       WRITE ( 14 ) 'lsm_start_index_h   '
-       WRITE ( 14 ) surf_lsm_h%start_index
-       WRITE ( 14 ) 'lsm_end_index_h     '
-       WRITE ( 14 ) surf_lsm_h%end_index
-       WRITE ( 14 ) 'm_liq_h             '
-       WRITE ( 14 ) m_liq_h%var_1d
+    DO  l = 0, 3
+
+       CALL wrd_write_string( 'lsm_start_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%start_index
+
+       CALL wrd_write_string( 'lsm_end_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%end_index
+
+       WRITE( dum, '(I1)')  l   
+
+       CALL wrd_write_string( 'm_liq_v(' // dum // ')' )
+       WRITE ( 14 )  m_liq_v(l)%var_1d     
+                
+    ENDDO
+
+    CALL wrd_write_string( 'lsm_start_index_h' )
+    WRITE ( 14 )  surf_lsm_h%start_index
+
+    CALL wrd_write_string( 'lsm_end_index_h' )
+    WRITE ( 14 )  surf_lsm_h%end_index
+
+    CALL wrd_write_string( 't_surface_h' )
+    WRITE ( 14 )  t_surface_h%var_1d
+
+    DO  l = 0, 3
+
+       CALL wrd_write_string( 'lsm_start_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%start_index
+
+       CALL wrd_write_string( 'lsm_end_index_v' )
+       WRITE ( 14 )  surf_lsm_v(l)%end_index
+
+       WRITE( dum, '(I1)')  l   
+
+       CALL wrd_write_string( 't_surface_v(' // dum // ')' )
+       WRITE ( 14 )  t_surface_v(l)%var_1d     
        
-       DO  l = 0, 3
-          WRITE ( 14 ) 'lsm_start_index_v   '
-          WRITE ( 14 ) surf_lsm_v(l)%start_index
-          WRITE ( 14 ) 'lsm_end_index_v     '
-          WRITE ( 14 ) surf_lsm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 ) 'm_liq_v(' // dum // ')          ' 
-          WRITE ( 14 ) m_liq_v(l)%var_1d          
-       ENDDO
-
-       WRITE ( 14 ) 'lsm_start_index_h   '
-       WRITE ( 14 ) surf_lsm_h%start_index
-       WRITE ( 14 ) 'lsm_end_index_h     '
-       WRITE ( 14 ) surf_lsm_h%end_index
-       WRITE ( 14 ) 't_surface_h         '
-       WRITE ( 14 ) t_surface_h%var_1d
-       
-       DO  l = 0, 3
-          WRITE ( 14 ) 'lsm_start_index_v   '
-          WRITE ( 14 ) surf_lsm_v(l)%start_index
-          WRITE ( 14 ) 'lsm_end_index_v     '
-          WRITE ( 14 ) surf_lsm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 ) 't_surface_v(' // dum // ')      ' 
-          WRITE ( 14 ) t_surface_v(l)%var_1d         
-       ENDDO
-
-
-       WRITE ( 14 )  '*** end lsm ***     '
-
-    ENDIF
-
- END SUBROUTINE lsm_write_restart_data
-
-
-SUBROUTINE lsm_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file,   &
-                                     nynfa, nyn_on_file, nysfa, nys_on_file,   &
-                                     offset_xa, offset_ya, overlap_count,      &
-                                     tmp_2d )
+    ENDDO
+
+
+ END SUBROUTINE lsm_wrd_local
+
+
+!------------------------------------------------------------------------------!
+!
+! Description:
+! ------------
+!> Soubroutine reads lsm data from restart file(s)
+!------------------------------------------------------------------------------!
+SUBROUTINE lsm_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,           &
+                          nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,    &
+                          nys_on_file, tmp_2d, found )
  
 
@@ -5827,11 +5881,8 @@
     USE indices
     
-    USE kinds
-    
     USE pegrid
 
+
     IMPLICIT NONE
-
-    CHARACTER (LEN=20) :: field_char   !< 
 
     INTEGER(iwp) ::  i                 !< 
@@ -5841,569 +5892,584 @@
     INTEGER(iwp) ::  nxlc              !< 
     INTEGER(iwp) ::  nxlf              !< 
-    INTEGER(iwp) ::  nxl_on_file       !< 
+    INTEGER(iwp) ::  nxl_on_file       !< index of left boundary on former local domain
     INTEGER(iwp) ::  nxrc              !< 
     INTEGER(iwp) ::  nxrf              !< 
-    INTEGER(iwp) ::  nxr_on_file       !< 
+    INTEGER(iwp) ::  nxr_on_file       !< index of right boundary on former local domain
     INTEGER(iwp) ::  nync              !< 
     INTEGER(iwp) ::  nynf              !< 
-    INTEGER(iwp) ::  nyn_on_file       !< 
+    INTEGER(iwp) ::  nyn_on_file       !< index of north boundary on former local domain
     INTEGER(iwp) ::  nysc              !< 
     INTEGER(iwp) ::  nysf              !< 
-    INTEGER(iwp) ::  nys_on_file       !< 
-    INTEGER(iwp) ::  overlap_count     !< 
+    INTEGER(iwp) ::  nys_on_file       !< index of south boundary on former local domain
 
     INTEGER(iwp) ::  ns_v_on_file_lsm(0:3) !< number of vertical surface elements (natural type) on file
 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
-
-    INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  start_index_on_file
-    INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  end_index_on_file
-
-    REAL(wp),                                                                  &
-       DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
-          tmp_2d   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nzb_soil:nzt_soil+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
-          tmp_3d   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nzb_soil:nzt_soil,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
-          tmp_3d2   !< 
-
-    TYPE(surf_type_lsm) :: tmp_walltype_h_1d   !< temporary 1D array containing the respective surface variable stored on file, horizontal surfaces
-    TYPE(surf_type_lsm) :: tmp_walltype_h_2d   !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
-    TYPE(surf_type_lsm) :: tmp_walltype_h_2d2  !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces 
-
-    TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_1d   !< temporary 1D array containing the respective surface variable stored on file, vertical surfaces 
-    TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_2d   !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces 
-    TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_2d2  !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
-
-   IF ( initializing_actions == 'read_restart_data' )  THEN
-      READ ( 13 )  field_char
-
-!
-!--   At first, determine the number of surface elements (with certain orientation) on file
-      IF ( TRIM( field_char ) /= 'ns_h_on_file_lsm' )  THEN
-!
-!--      Add a proper error message
-      ENDIF
-      READ ( 13 ) ns_h_on_file_lsm
-
-      READ ( 13 )  field_char
-      IF ( TRIM( field_char ) /= 'ns_v_on_file_lsm' )  THEN
-!
-!--      Add a proper error message
-      ENDIF
-      READ ( 13 ) ns_v_on_file_lsm
-!
-!--   Allocate temporary arrays to store surface data
-      ALLOCATE( tmp_walltype_h_1d%var_1d(1:ns_h_on_file_lsm)                     )
-      ALLOCATE( tmp_walltype_h_2d%var_2d(nzb_soil:nzt_soil+1,1:ns_h_on_file_lsm) )
-      ALLOCATE( tmp_walltype_h_2d2%var_2d(nzb_soil:nzt_soil,1:ns_h_on_file_lsm)  )
-
-      DO  l = 0, 3
-         ALLOCATE( tmp_walltype_v_1d(l)%var_1d(1:ns_v_on_file_lsm(l))                     )
-         ALLOCATE( tmp_walltype_v_2d(l)%var_2d(nzb_soil:nzt_soil+1,1:ns_v_on_file_lsm(l)) )
-         ALLOCATE( tmp_walltype_v_2d2(l)%var_2d(nzb_soil:nzt_soil,1:ns_v_on_file_lsm(l))  )
-      ENDDO
-     
-      READ ( 13 )  field_char
-
-      DO  WHILE ( TRIM( field_char ) /= '*** end lsm ***' )
-
-         DO  k = 1, overlap_count
-
-            nxlf = nxlfa(i,k)
-            nxlc = nxlfa(i,k) + offset_xa(i,k)
-            nxrf = nxrfa(i,k)
-            nxrc = nxrfa(i,k) + offset_xa(i,k)
-            nysf = nysfa(i,k)
-            nysc = nysfa(i,k) + offset_ya(i,k)
-            nynf = nynfa(i,k)
-            nync = nynfa(i,k) + offset_ya(i,k)
-
-
-            SELECT CASE ( TRIM( field_char ) )
-
-
-                CASE ( 'c_liq_av' )
-                   IF ( .NOT. ALLOCATED( c_liq_av ) )  THEN
-                      ALLOCATE( c_liq_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   c_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'c_soil_av' )
-                   IF ( .NOT. ALLOCATED( c_soil_av ) )  THEN
-                      ALLOCATE( c_soil_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   c_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'c_veg_av' )
-                   IF ( .NOT. ALLOCATED( c_veg_av ) )  THEN
-                      ALLOCATE( c_veg_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   c_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lai_av' )
-                   IF ( .NOT. ALLOCATED( lai_av ) )  THEN
-                      ALLOCATE( lai_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   lai_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'm_liq_av' )
-                   IF ( .NOT. ALLOCATED( m_liq_av ) )  THEN
-                      ALLOCATE( m_liq_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   m_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'm_soil_av' )
-                   IF ( .NOT. ALLOCATED( m_soil_av ) )  THEN
-                      ALLOCATE( m_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
-                   m_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
-                                    tmp_3d2(nzb_soil:nzt_soil,nysf             &
-                                    -nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsws_liq_av' )
-                   IF ( .NOT. ALLOCATED( qsws_liq_av ) )  THEN
-                      ALLOCATE( qsws_liq_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =     &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                CASE ( 'qsws_soil_av' )
-                   IF ( .NOT. ALLOCATED( qsws_soil_av ) )  THEN
-                      ALLOCATE( qsws_soil_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =    &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsws_veg_av' )
-                   IF ( .NOT. ALLOCATED( qsws_veg_av ) )  THEN
-                      ALLOCATE( qsws_veg_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =     &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 't_soil_av' )
-                   IF ( .NOT. ALLOCATED( t_soil_av ) )  THEN
-                      ALLOCATE( t_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
-                   t_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
-                                    tmp_3d2(:,nysf-nbgp:nynf+nbgp,             &
-                                    nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lsm_start_index_h', 'lsm_start_index_v'  )   
-                   IF ( k == 1 )                                               &
-                      READ ( 13 )  start_index_on_file
-                      
-                CASE ( 'lsm_end_index_h', 'lsm_end_index_v' )   
-                   IF ( k == 1 )                                               &
-                      READ ( 13 )  end_index_on_file
-                
-                CASE ( 't_soil_h' )
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file 
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  end_index_on_file
+
+    LOGICAL, INTENT(OUT)  :: found
+
+    REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d   !< 
+
+    REAL(wp), DIMENSION(nzb_soil:nzt_soil+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !< 
+
+    REAL(wp), DIMENSION(nzb_soil:nzt_soil,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d2   !< 
+
+    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_1d   !< temporary 1D array containing the respective surface variable stored on file, horizontal surfaces
+    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_2d   !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
+    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_2d2  !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces 
+
+    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_1d   !< temporary 1D array containing the respective surface variable stored on file, vertical surfaces 
+    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_2d   !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces 
+    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_2d2  !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
+
+
+    found = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
+
+           CASE ( 'ns_h_on_file_lsm' )
+              IF ( k == 1 )  THEN  
+                 READ ( 13 ) ns_h_on_file_lsm
+
+                 IF ( ALLOCATED( tmp_walltype_h_1d%var_1d ) )                  &
+                    DEALLOCATE( tmp_walltype_h_1d%var_1d )
+                 IF ( ALLOCATED( tmp_walltype_h_2d%var_2d ) )                  &   
+                    DEALLOCATE( tmp_walltype_h_2d%var_2d )
+                 IF ( ALLOCATED( tmp_walltype_h_2d2%var_2d ) )                 &
+                    DEALLOCATE( tmp_walltype_h_2d2%var_2d ) 
+
+!
+!--              Allocate temporary arrays to store surface data
+                 ALLOCATE( tmp_walltype_h_1d%var_1d(1:ns_h_on_file_lsm) )
+                 ALLOCATE( tmp_walltype_h_2d%var_2d(nzb_soil:nzt_soil+1,       &
+                                                    1:ns_h_on_file_lsm) )
+                 ALLOCATE( tmp_walltype_h_2d2%var_2d(nzb_soil:nzt_soil,        &
+                           1:ns_h_on_file_lsm)  )
+
+              ENDIF
+
+           CASE ( 'ns_v_on_file_lsm' )
+              IF ( k == 1 )  THEN
+                 READ ( 13 ) ns_v_on_file_lsm
+
+                 DO  l = 0, 3
+                    IF ( ALLOCATED( tmp_walltype_v_1d(l)%var_1d ) )            &
+                       DEALLOCATE( tmp_walltype_v_1d(l)%var_1d )
+                    IF ( ALLOCATED( tmp_walltype_v_2d(l)%var_2d ) )            &
+                       DEALLOCATE( tmp_walltype_v_2d(l)%var_2d )
+                    IF ( ALLOCATED( tmp_walltype_v_2d2(l)%var_2d ) )           &
+                       DEALLOCATE( tmp_walltype_v_2d2(l)%var_2d )
+                 ENDDO
+
+!
+!--              Allocate temporary arrays to store surface data
+                 DO  l = 0, 3
+                    ALLOCATE( tmp_walltype_v_1d(l)                             &
+                                 %var_1d(1:ns_v_on_file_lsm(l)) )
+                    ALLOCATE( tmp_walltype_v_2d(l)                             &
+                                 %var_2d(nzb_soil:nzt_soil+1,                  &
+                                         1:ns_v_on_file_lsm(l)) )
+                    ALLOCATE( tmp_walltype_v_2d2(l)                            &
+                                 %var_2d(nzb_soil:nzt_soil,                    &
+                                         1:ns_v_on_file_lsm(l))  )
+                 ENDDO
+
+              ENDIF
+
+
+           CASE ( 'c_liq_av' )
+              IF ( .NOT. ALLOCATED( c_liq_av ) )  THEN
+                 ALLOCATE( c_liq_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              c_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'c_soil_av' )
+              IF ( .NOT. ALLOCATED( c_soil_av ) )  THEN
+                 ALLOCATE( c_soil_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              c_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'c_veg_av' )
+              IF ( .NOT. ALLOCATED( c_veg_av ) )  THEN
+                 ALLOCATE( c_veg_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              c_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'lai_av' )
+              IF ( .NOT. ALLOCATED( lai_av ) )  THEN
+                 ALLOCATE( lai_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              lai_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'm_liq_av' )
+              IF ( .NOT. ALLOCATED( m_liq_av ) )  THEN
+                 ALLOCATE( m_liq_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              m_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'm_soil_av' )
+              IF ( .NOT. ALLOCATED( m_soil_av ) )  THEN
+                 ALLOCATE( m_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
+              m_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                 tmp_3d2(nzb_soil:nzt_soil,nysf                                &
+                         -nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'qsws_liq_av' )
+              IF ( .NOT. ALLOCATED( qsws_liq_av ) )  THEN
+                 ALLOCATE( qsws_liq_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF  
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              qsws_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+           CASE ( 'qsws_soil_av' )
+              IF ( .NOT. ALLOCATED( qsws_soil_av ) )  THEN
+                 ALLOCATE( qsws_soil_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF  
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              qsws_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =         &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'qsws_veg_av' )
+              IF ( .NOT. ALLOCATED( qsws_veg_av ) )  THEN
+                 ALLOCATE( qsws_veg_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF  
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              qsws_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
+                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 't_soil_av' )
+              IF ( .NOT. ALLOCATED( t_soil_av ) )  THEN
+                 ALLOCATE( t_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
+              t_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                 tmp_3d2(:,nysf-nbgp:nynf+nbgp,                                &
+                         nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'lsm_start_index_h', 'lsm_start_index_v'  )   
+                IF ( k == 1 )  THEN
+
+                   IF ( ALLOCATED( start_index_on_file ) )                     &
+                      DEALLOCATE( start_index_on_file )
+
+                   ALLOCATE ( start_index_on_file(nys_on_file:nyn_on_file,     &
+                   nxl_on_file:nxr_on_file) )
+
+                   READ ( 13 )  start_index_on_file
+
+                ENDIF
                  
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_soil_h%var_2d ) )               &
-                         ALLOCATE( t_soil_h%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_h%ns) )
-                      READ ( 13 )  tmp_walltype_h_2d%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                              t_soil_h%var_2d,                 &
-                                              tmp_walltype_h_2d%var_2d,        &
-                                              surf_lsm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-
-                CASE ( 't_soil_v(0)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_soil_v(0)%var_2d ) )            &
-                         ALLOCATE( t_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(0)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d(0)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_soil_v(0)%var_2d,                 &
-                                           tmp_walltype_v_2d(0)%var_2d,        &
-                                           surf_lsm_v(0)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_soil_v(1)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_soil_v(1)%var_2d ) )            &
-                         ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(1)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d(1)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_soil_v(1)%var_2d,                 &
-                                           tmp_walltype_v_2d(1)%var_2d,        &
-                                           surf_lsm_v(1)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_soil_v(2)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_soil_v(2)%var_2d ) )            &
-                         ALLOCATE( t_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(2)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d(2)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_soil_v(2)%var_2d,                 &
-                                           tmp_walltype_v_2d(2)%var_2d,        &
-                                           surf_lsm_v(2)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_soil_v(3)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_soil_v(3)%var_2d ) )            &
-                         ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(3)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d(3)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_soil_v(3)%var_2d,                 &
-                                           tmp_walltype_v_2d(3)%var_2d,        &
-                                           surf_lsm_v(3)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 'm_soil_h' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_soil_h%var_2d ) )               &
-                         ALLOCATE( m_soil_h%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_h%ns) )
-                      READ ( 13 )  tmp_walltype_h_2d2%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                             m_soil_h%var_2d,                  &
-                                             tmp_walltype_h_2d2%var_2d,        &
-                                             surf_lsm_h%start_index,           & 
-                                             start_index_on_file,              &
-                                             end_index_on_file,                &
-                                             nxlc, nysc,                       &
-                                             nxlf, nxrf, nysf, nynf,           &
-                                             nys_on_file, nyn_on_file,         &
-                                             nxl_on_file,nxr_on_file )
-
-                CASE ( 'm_soil_v(0)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_soil_v(0)%var_2d ) )            &
-                         ALLOCATE( m_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(0)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d2(0)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                          m_soil_v(0)%var_2d,                  & 
-                                          tmp_walltype_v_2d2(0)%var_2d,        &
-                                          surf_lsm_v(0)%start_index,           & 
-                                          start_index_on_file,                 &
-                                          end_index_on_file,                   &
-                                          nxlc, nysc,                          &
-                                          nxlf, nxrf, nysf, nynf,              &
-                                          nys_on_file, nyn_on_file,            &
-                                          nxl_on_file,nxr_on_file )
-
-                CASE ( 'm_soil_v(1)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_soil_v(1)%var_2d ) )            &
-                         ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(1)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d2(1)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                          m_soil_v(1)%var_2d,                  & 
-                                          tmp_walltype_v_2d2(1)%var_2d,        &
-                                          surf_lsm_v(1)%start_index,           & 
-                                          start_index_on_file,                 &
-                                          end_index_on_file,                   &
-                                          nxlc, nysc,                          &
-                                          nxlf, nxrf, nysf, nynf,              &
-                                          nys_on_file, nyn_on_file,            &
-                                          nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_soil_v(2)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_soil_v(2)%var_2d ) )            &
-                         ALLOCATE( m_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(2)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d2(2)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                          m_soil_v(2)%var_2d,                  & 
-                                          tmp_walltype_v_2d2(2)%var_2d,        &
-                                          surf_lsm_v(2)%start_index,           & 
-                                          start_index_on_file,                 &
-                                          end_index_on_file,                   &
-                                          nxlc, nysc,                          &
-                                          nxlf, nxrf, nysf, nynf,              &
-                                          nys_on_file, nyn_on_file,            &
-                                          nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_soil_v(3)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_soil_v(3)%var_2d ) )            &
-                         ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(3)%ns) )
-                      READ ( 13 )  tmp_walltype_v_2d2(3)%var_2d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                          m_soil_v(3)%var_2d,                  & 
-                                          tmp_walltype_v_2d2(3)%var_2d,        &
-                                          surf_lsm_v(3)%start_index,           & 
-                                          start_index_on_file,                 &
-                                          end_index_on_file,                   &
-                                          nxlc, nysc,                          &
-                                          nxlf, nxrf, nysf, nynf,              &
-                                          nys_on_file, nyn_on_file,            &
-                                          nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_liq_h' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_liq_h%var_1d ) )                &
-                         ALLOCATE( m_liq_h%var_1d(1:surf_lsm_h%ns) )
-                      READ ( 13 )  tmp_walltype_h_1d%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                              m_liq_h%var_1d,                  &
-                                              tmp_walltype_h_1d%var_1d,        &
-                                              surf_lsm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_liq_v(0)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_liq_v(0)%var_1d ) )             &
-                         ALLOCATE( m_liq_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           m_liq_v(0)%var_1d,                  &
-                                           tmp_walltype_v_1d(0)%var_1d,        &
-                                           surf_lsm_v(0)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_liq_v(1)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_liq_v(1)%var_1d ) )             &
-                         ALLOCATE( m_liq_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           m_liq_v(1)%var_1d,                  &
-                                           tmp_walltype_v_1d(1)%var_1d,        &
-                                           surf_lsm_v(1)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-
-                CASE ( 'm_liq_v(2)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_liq_v(2)%var_1d ) )             &
-                         ALLOCATE( m_liq_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           m_liq_v(2)%var_1d,                  &
-                                           tmp_walltype_v_1d(2)%var_1d,        &
-                                           surf_lsm_v(2)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 'm_liq_v(3)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( m_liq_v(3)%var_1d ) )             &
-                         ALLOCATE( m_liq_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           m_liq_v(3)%var_1d,                  &
-                                           tmp_walltype_v_1d(3)%var_1d,        &
-                                           surf_lsm_v(3)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-
-                CASE ( 't_surface_h' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_surface_h%var_1d ) )            &
-                         ALLOCATE( t_surface_h%var_1d(1:surf_lsm_h%ns) )
-                      READ ( 13 )  tmp_walltype_h_1d%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                              t_surface_h%var_1d,              &
-                                              tmp_walltype_h_1d%var_1d,        &
-                                              surf_lsm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-
-                CASE ( 't_surface_v(0)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_surface_v(0)%var_1d ) )         &
-                         ALLOCATE( t_surface_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_surface_v(0)%var_1d,              &
-                                           tmp_walltype_v_1d(0)%var_1d,        &
-                                           surf_lsm_v(0)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_surface_v(1)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_surface_v(1)%var_1d ) )         &
-                         ALLOCATE( t_surface_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_surface_v(1)%var_1d,              &
-                                           tmp_walltype_v_1d(1)%var_1d,        &
-                                           surf_lsm_v(1)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_surface_v(2)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_surface_v(2)%var_1d ) )         &
-                         ALLOCATE( t_surface_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_surface_v(2)%var_1d,              &
-                                           tmp_walltype_v_1d(2)%var_1d,        &
-                                           surf_lsm_v(2)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-                CASE ( 't_surface_v(3)' )
-                 
-                   IF ( k == 1 )  THEN
-                      IF ( .NOT.  ALLOCATED( t_surface_v(3)%var_1d ) )         &
-                         ALLOCATE( t_surface_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
-                      READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
-                   ENDIF
-                   CALL surface_restore_elements(                              &
-                                           t_surface_v(3)%var_1d,              &
-                                           tmp_walltype_v_1d(3)%var_1d,        &
-                                           surf_lsm_v(3)%start_index,          & 
-                                           start_index_on_file,                &
-                                           end_index_on_file,                  &
-                                           nxlc, nysc,                         &
-                                           nxlf, nxrf, nysf, nynf,             &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file,nxr_on_file )
-
-               CASE DEFAULT
-                  WRITE( message_string, * ) 'unknown variable named "',       &
-                                        TRIM( field_char ), '" found in',      &
-                                        '&data from prior run on PE ', myid
-                  CALL message( 'lsm_read_restart_data', 'PA0302', 1, 2, 0, 6, &
-                                 0 )
-
-            END SELECT
-
-         ENDDO
-
-         READ ( 13 )  field_char
-
-      ENDDO
-   ENDIF
-
- END SUBROUTINE lsm_read_restart_data
+           CASE ( 'lsm_end_index_h', 'lsm_end_index_v' )   
+                IF ( k == 1 )  THEN
+
+                   IF ( ALLOCATED( end_index_on_file ) )                       &
+                      DEALLOCATE( end_index_on_file )
+
+                   ALLOCATE ( end_index_on_file(nys_on_file:nyn_on_file,       &
+                      nxl_on_file:nxr_on_file) )
+
+                   READ ( 13 )  end_index_on_file
+
+                ENDIF
+           
+           CASE ( 't_soil_h' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_soil_h%var_2d ) )                    &
+                    ALLOCATE( t_soil_h%var_2d(nzb_soil:nzt_soil+1,             &
+                                              1:surf_lsm_h%ns) )
+                 READ ( 13 )  tmp_walltype_h_2d%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                         t_soil_h%var_2d,                      &
+                                         tmp_walltype_h_2d%var_2d,             &
+                                         surf_lsm_h%start_index,               & 
+                                         start_index_on_file,                  &
+                                         end_index_on_file,                    &
+                                         nxlc, nysc,                           &
+                                         nxlf, nxrf, nysf, nynf,               &
+                                         nys_on_file, nyn_on_file,             &
+                                         nxl_on_file,nxr_on_file )
+
+           CASE ( 't_soil_v(0)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_soil_v(0)%var_2d ) )                 &
+                    ALLOCATE( t_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(0)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d(0)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_soil_v(0)%var_2d,                      &
+                                      tmp_walltype_v_2d(0)%var_2d,             &
+                                      surf_lsm_v(0)%start_index,               &  
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_soil_v(1)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_soil_v(1)%var_2d ) )                 &
+                    ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(1)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d(1)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_soil_v(1)%var_2d,                      &
+                                      tmp_walltype_v_2d(1)%var_2d,             &
+                                      surf_lsm_v(1)%start_index,               &   
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_soil_v(2)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_soil_v(2)%var_2d ) )                 &
+                    ALLOCATE( t_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(2)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d(2)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_soil_v(2)%var_2d,                      &
+                                      tmp_walltype_v_2d(2)%var_2d,             &
+                                      surf_lsm_v(2)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_soil_v(3)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_soil_v(3)%var_2d ) )                 &
+                    ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(3)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d(3)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_soil_v(3)%var_2d,                      &
+                                      tmp_walltype_v_2d(3)%var_2d,             &
+                                      surf_lsm_v(3)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 'm_soil_h' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_soil_h%var_2d ) )                    &
+                    ALLOCATE( m_soil_h%var_2d(nzb_soil:nzt_soil+1,             &
+                                              1:surf_lsm_h%ns) )
+                 READ ( 13 )  tmp_walltype_h_2d2%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                        m_soil_h%var_2d,                       &
+                                        tmp_walltype_h_2d2%var_2d,             &
+                                        surf_lsm_h%start_index,                &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+
+           CASE ( 'm_soil_v(0)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_soil_v(0)%var_2d ) )                 &
+                    ALLOCATE( m_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(0)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d2(0)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                     m_soil_v(0)%var_2d,                       & 
+                                     tmp_walltype_v_2d2(0)%var_2d,             &
+                                     surf_lsm_v(0)%start_index,                & 
+                                     start_index_on_file,                      &
+                                     end_index_on_file,                        &
+                                     nxlc, nysc,                               &
+                                     nxlf, nxrf, nysf, nynf,                   &
+                                     nys_on_file, nyn_on_file,                 &
+                                     nxl_on_file,nxr_on_file )
+
+           CASE ( 'm_soil_v(1)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_soil_v(1)%var_2d ) )                 &
+                    ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(1)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d2(1)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                     m_soil_v(1)%var_2d,                       &    
+                                     tmp_walltype_v_2d2(1)%var_2d,             &
+                                     surf_lsm_v(1)%start_index,                &  
+                                     start_index_on_file,                      &
+                                     end_index_on_file,                        &
+                                     nxlc, nysc,                               &
+                                     nxlf, nxrf, nysf, nynf,                   &
+                                     nys_on_file, nyn_on_file,                 &
+                                     nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_soil_v(2)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_soil_v(2)%var_2d ) )                 &
+                    ALLOCATE( m_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(2)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d2(2)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                     m_soil_v(2)%var_2d,                       & 
+                                     tmp_walltype_v_2d2(2)%var_2d,             &
+                                     surf_lsm_v(2)%start_index,                &   
+                                     start_index_on_file,                      &
+                                     end_index_on_file,                        &
+                                     nxlc, nysc,                               &
+                                     nxlf, nxrf, nysf, nynf,                   &
+                                     nys_on_file, nyn_on_file,                 &
+                                     nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_soil_v(3)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_soil_v(3)%var_2d ) )                 &
+                    ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
+                                                 1:surf_lsm_v(3)%ns) )
+                 READ ( 13 )  tmp_walltype_v_2d2(3)%var_2d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                     m_soil_v(3)%var_2d,                       & 
+                                     tmp_walltype_v_2d2(3)%var_2d,             &
+                                     surf_lsm_v(3)%start_index,                &  
+                                     start_index_on_file,                      &
+                                     end_index_on_file,                        &
+                                     nxlc, nysc,                               &
+                                     nxlf, nxrf, nysf, nynf,                   &
+                                     nys_on_file, nyn_on_file,                 &
+                                     nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_liq_h' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_liq_h%var_1d ) )                     &
+                    ALLOCATE( m_liq_h%var_1d(1:surf_lsm_h%ns) )
+                 READ ( 13 )  tmp_walltype_h_1d%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                         m_liq_h%var_1d,                       &
+                                         tmp_walltype_h_1d%var_1d,             &
+                                         surf_lsm_h%start_index,               &  
+                                         start_index_on_file,                  &
+                                         end_index_on_file,                    &
+                                         nxlc, nysc,                           &
+                                         nxlf, nxrf, nysf, nynf,               &
+                                         nys_on_file, nyn_on_file,             &
+                                         nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_liq_v(0)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_liq_v(0)%var_1d ) )                  &
+                    ALLOCATE( m_liq_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      m_liq_v(0)%var_1d,                       &
+                                      tmp_walltype_v_1d(0)%var_1d,             &
+                                      surf_lsm_v(0)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_liq_v(1)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_liq_v(1)%var_1d ) )                  &
+                    ALLOCATE( m_liq_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      m_liq_v(1)%var_1d,                       &
+                                      tmp_walltype_v_1d(1)%var_1d,             &
+                                      surf_lsm_v(1)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+
+           CASE ( 'm_liq_v(2)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_liq_v(2)%var_1d ) )                  &
+                    ALLOCATE( m_liq_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      m_liq_v(2)%var_1d,                       &
+                                      tmp_walltype_v_1d(2)%var_1d,             &
+                                      surf_lsm_v(2)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 'm_liq_v(3)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( m_liq_v(3)%var_1d ) )                  &
+                    ALLOCATE( m_liq_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      m_liq_v(3)%var_1d,                       &
+                                      tmp_walltype_v_1d(3)%var_1d,             &
+                                      surf_lsm_v(3)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+
+           CASE ( 't_surface_h' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_surface_h%var_1d ) )                 &
+                    ALLOCATE( t_surface_h%var_1d(1:surf_lsm_h%ns) )
+                 READ ( 13 )  tmp_walltype_h_1d%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                         t_surface_h%var_1d,                   &
+                                         tmp_walltype_h_1d%var_1d,             &
+                                         surf_lsm_h%start_index,               & 
+                                         start_index_on_file,                  &
+                                         end_index_on_file,                    &
+                                         nxlc, nysc,                           &
+                                         nxlf, nxrf, nysf, nynf,               &
+                                         nys_on_file, nyn_on_file,             &
+                                         nxl_on_file,nxr_on_file )
+
+           CASE ( 't_surface_v(0)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_surface_v(0)%var_1d ) )              &
+                    ALLOCATE( t_surface_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_surface_v(0)%var_1d,                   &
+                                      tmp_walltype_v_1d(0)%var_1d,             &
+                                      surf_lsm_v(0)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_surface_v(1)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_surface_v(1)%var_1d ) )              &
+                    ALLOCATE( t_surface_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_surface_v(1)%var_1d,                   &
+                                      tmp_walltype_v_1d(1)%var_1d,             &
+                                      surf_lsm_v(1)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                & 
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_surface_v(2)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_surface_v(2)%var_1d ) )              &
+                    ALLOCATE( t_surface_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_surface_v(2)%var_1d,                   &
+                                      tmp_walltype_v_1d(2)%var_1d,             &
+                                      surf_lsm_v(2)%start_index,               & 
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+           CASE ( 't_surface_v(3)' )
+            
+              IF ( k == 1 )  THEN
+                 IF ( .NOT.  ALLOCATED( t_surface_v(3)%var_1d ) )              &
+                    ALLOCATE( t_surface_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
+                 READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
+              ENDIF
+              CALL surface_restore_elements(                                   &
+                                      t_surface_v(3)%var_1d,                   &
+                                      tmp_walltype_v_1d(3)%var_1d,             &
+                                      surf_lsm_v(3)%start_index,               &   
+                                      start_index_on_file,                     &
+                                      end_index_on_file,                       &
+                                      nxlc, nysc,                              &
+                                      nxlf, nxrf, nysf, nynf,                  &
+                                      nys_on_file, nyn_on_file,                &
+                                      nxl_on_file,nxr_on_file )
+
+          CASE DEFAULT
+
+                found = .FALSE.
+
+       END SELECT
+
+
+ END SUBROUTINE lsm_rrd_local
 
 !------------------------------------------------------------------------------!
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 2893)
+++ palm/trunk/SOURCE/modules.f90	(revision 2894)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! _prerun flags were removed, Control paramters restart_string and length have
+! been added
+! 
+! 2881 2018-03-13 16:24:40Z suehring
 ! Added flag for switching on/off calculation of soil moisture
 ! 
@@ -1077,4 +1081,5 @@
     CHARACTER (LEN=80)   ::  run_identifier                               !< run identifier as given by mrun option -d, ENVPAR namelist parameter provided by mrun
     CHARACTER (LEN=100)  ::  initializing_actions = ' '                   !< namelist parameter
+    CHARACTER (LEN=100)  ::  restart_string = ' '                         !< for storing strings in case of writing/reading restart data
     CHARACTER (LEN=210)  ::  run_description_header                       !< string containing diverse run informations as run identifier, coupling mode, host, ensemble number, run date and time
     CHARACTER (LEN=1000) ::  message_string = ' '                         !< dynamic string for error message output
@@ -1140,4 +1145,5 @@
     INTEGER(iwp) ::  io_blocks = 1                     !< number of blocks for which I/O is done in sequence (total number of PEs / maximum_parallel_io_streams)
     INTEGER(iwp) ::  iran = -1234567                   !< integer random number used for flow disturbances
+    INTEGER(iwp) ::  length = 0                        !< integer that specifies the length of a string in case of writing/reading restart data
     INTEGER(iwp) ::  masks = 0                         !< counter for number of masked output quantities
     INTEGER(iwp) ::  maximum_grid_level                !< number of grid levels that the multigrid solver is using
@@ -1301,5 +1307,4 @@
     LOGICAL ::  synchronous_exchange = .FALSE.                   !< namelist parameter
     LOGICAL ::  syn_turb_gen = .FALSE.                           !< flag for synthetic turbulence generator module
-    LOGICAL ::  syn_turb_gen_prerun = .FALSE.                    !< Was restart data of the sythentic turbulence generator written out? 
     LOGICAL ::  terminate_run = .FALSE.                          !< terminate run (cpu-time limit, restarts)?
     LOGICAL ::  topo_no_distinct = .FALSE.                       !< flag controlling classification of topography surfaces
@@ -1320,8 +1325,6 @@
     LOGICAL ::  uv_exposure = .FALSE.                            !< switch for uv exposure model
     LOGICAL ::  virtual_flight = .FALSE.                         !< use virtual flight model?
-    LOGICAL ::  virtual_flight_prerun = .FALSE.                  !< Was restart data of the virtual flight model written out?
     LOGICAL ::  wall_adjustment = .TRUE.                         !< namelist parameter
     LOGICAL ::  wind_turbine = .FALSE.                           !< flag for use of wind turbine model
-    LOGICAL ::  wind_turbine_prerun = .FALSE.                    !< Was restart data of the wtm model written out? 
     LOGICAL ::  write_binary = .FALSE.                           !< ENVPAR namelist parameter to steer restart I/O (ENVPAR is created by mrun)
     LOGICAL ::  ws_scheme_sca = .FALSE.                          !< use Wicker-Skamarock scheme (scalar advection)?
Index: palm/trunk/SOURCE/palm.f90
===================================================================
--- palm/trunk/SOURCE/palm.f90	(revision 2893)
+++ palm/trunk/SOURCE/palm.f90	(revision 2894)
@@ -25,4 +25,11 @@
 ! -----------------
 ! $Id$
+! Modified todo list, _write_restart_data/_last_actions has been renamed to 
+! _wrd_local, unit 14 will be opened now for each io_group
+! write_3d_binary is called wrd_local now, wrd_global moved from wrd_local to 
+! palm.f90, unit 14 is closed directly after the wrd_local call, Module related
+! routines for writing restart data have been moved to wrd_local
+! 
+! 2801 2018-02-14 16:01:55Z suehring
 ! Changed lpm from subroutine to module.
 ! Introduce particle transfer in nested models.
@@ -204,5 +211,4 @@
 !>
 !> @todo create routine last_actions instead of calling lsm_last_actions etc.
-!> @todo eventually move CALL usm_write_restart_data to suitable location
 !> @todo move chem_init call to init_3d_model or to check_parameters
 !------------------------------------------------------------------------------!
@@ -213,5 +219,5 @@
 
     USE chemistry_model_mod,                                                   &
-        ONLY:  chem_init, chem_last_actions
+        ONLY:  chem_init
 
     USE chem_photolysis_mod,                                                   &
@@ -222,8 +228,8 @@
                cloud_physics, constant_diffusion, coupling_char, coupling_mode,&
                do2d_at_begin, do3d_at_begin, humidity, initializing_actions,   &
-               io_blocks, io_group, land_surface, large_scale_forcing,         &
+               io_blocks, io_group, large_scale_forcing,                       &
                message_string, microphysics_morrison, microphysics_seifert,    &
                nest_domain, neutral, nudging, passive_scalar, runnr,           &
-               simulated_time, simulated_time_chr, spinup, urban_surface,      &
+               simulated_time, simulated_time_chr, spinup,                     &
                user_interface_current_revision,                                &
                user_interface_required_revision, version, wall_heatflux,       &
@@ -242,11 +248,11 @@
     USE kinds
 
-    USE land_surface_model_mod,                                                &
-        ONLY:  lsm_write_restart_data
-
     USE particle_attributes,                                                   &
         ONLY:  particle_advection
 
     USE pegrid
+
+    USE pmc_particle_interface,                                                &
+        ONLY: pmcp_g_alloc_win
 
     USE pmc_interface,                                                         &
@@ -255,12 +261,7 @@
                pmci_ensure_nest_mass_conservation
 
-    USE pmc_particle_interface,                                                 &
-        ONLY: pmcp_g_alloc_win
-
-    USE radiation_model_mod,                                                   &
-        ONLY:  radiation, radiation_last_actions
-       
-    USE urban_surface_mod,                                                     &
-        ONLY:  usm_write_restart_data        
+    USE write_restart_data_mod,                                                &
+        ONLY:  wrd_global, wrd_local
+
 
     IMPLICIT NONE
@@ -478,15 +479,24 @@
     IF ( write_binary )  THEN
 
-       CALL cpu_log( log_point(22), 'write_3d_binary', 'start' )
+       CALL cpu_log( log_point(22), 'wrd_local', 'start' )
 
        CALL location_message( 'writing restart data', .FALSE. )
-
-       CALL check_open( 14 )
 
        DO  i = 0, io_blocks-1
           IF ( i == io_group )  THEN
-!
-!--          Write flow field data
-             CALL write_3d_binary
+
+!
+!--          Open binary file 
+             CALL check_open( 14 )
+!
+!--          Write control parameters and other global variables for restart.
+             IF ( myid == 0 )  CALL wrd_global
+!
+!--          Write processor specific flow field data for restart runs
+             CALL wrd_local
+!
+!--          Close binary file 
+             CALL close_file( 14 )
+
           ENDIF
 #if defined( __parallel )
@@ -497,8 +507,8 @@
        CALL location_message( 'finished', .TRUE. )
 
-       CALL cpu_log( log_point(22), 'write_3d_binary', 'stop' )
-
-!
-!--    If required, write particle data
+       CALL cpu_log( log_point(22), 'wrd_local', 'stop' )
+
+!
+!--    If required, write particle data in own restart files
        IF ( particle_advection )  CALL lpm_write_restart_file
        
@@ -509,34 +519,14 @@
     IF ( myid == 0 )  CALL header
 !
-!-- If required, final land surface and user-defined actions, and
+!-- If required, final  user-defined actions, and
 !-- last actions on the open files and close files. Unit 14 was opened
-!-- in write_3d_binary but it is closed here, to allow writing on this
+!-- in wrd_local but it is closed here, to allow writing on this
 !-- unit in routine user_last_actions.
     CALL cpu_log( log_point(4), 'last actions', 'start' )
-    DO  i = 0, io_blocks-1
-       IF ( i == io_group )  THEN
-
-          IF ( urban_surface )  THEN
-             CALL usm_write_restart_data
-          ENDIF
-          IF ( land_surface )  THEN
-             CALL lsm_write_restart_data
-          ENDIF
-          IF ( radiation )  THEN
-             CALL radiation_last_actions
-          ENDIF
-          IF ( air_chemistry )  THEN
-             CALL chem_last_actions
-          ENDIF
           
-          CALL user_last_actions
-          IF ( write_binary )  CALL close_file( 14 )
-       ENDIF
-#if defined( __parallel )
-       CALL MPI_BARRIER( comm2d, ierr )
-#endif
-    ENDDO
+    CALL user_last_actions
     CALL close_file( 0 )
     CALL close_dvrp
+
     CALL cpu_log( log_point(4), 'last actions', 'stop' )
 
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 2893)
+++ palm/trunk/SOURCE/parin.f90	(revision 2894)
@@ -25,4 +25,9 @@
 ! -----------------
 ! $Id$
+! read_var_list has been renamed to rrd_global, all module related _parin 
+! routines are called before reading the global restart data to overwrite them
+! in case of restart runs
+! 
+! 2881 2018-03-13 16:24:40Z suehring
 ! Added flag for switching on/off calculation of soil moisture
 ! 
@@ -408,5 +413,8 @@
 
     USE radiation_model_mod,                                                   &
-        ONLY: radiation_parin  
+        ONLY: radiation_parin
+
+    USE read_restart_data_mod,                                                 &
+        ONLY:  rrd_global     
 
     USE spectra_mod,                                                           &
@@ -614,10 +622,79 @@
 
 !
+!--       Try to read runtime parameters given by the user for this run
+!--       (namelist "d3par"). The namelist "d3par" can be omitted. In that case
+!--       default values are used for the parameters.
+ 12       line = ' '
+
+          REWIND ( 11 )
+          line = ' '
+          DO   WHILE ( INDEX( line, '&d3par' ) == 0 )
+             READ ( 11, '(A)', END=20 )  line
+          ENDDO
+          BACKSPACE ( 11 )
+
+!
+!--       Read namelist
+          READ ( 11, d3par )
+
+ 20       CONTINUE
+
+!
+!--       Check if land surface model is used and read &lsm_par if required
+          CALL lsm_parin
+
+!
+!--       Check if urban surface model is used and read &urban_surface_par if required
+          CALL usm_parin
+
+!
+!--       Check if spectra shall be calculated and read spectra_par if required
+          CALL spectra_parin
+
+!
+!--       Check if radiation model is used and read &radiation_par if required
+          CALL radiation_parin
+
+!
+!--       Check if gust module is used and read &gust_par if required
+          CALL gust_parin
+ 
+ 
+!--       Check if plant canopy model is used and read &canopy_par if required
+          CALL pcm_parin
+ 
+!
+!--       Read control parameters for optionally used model software packages
+          CALL package_parin
+
+!
+!--       Check if wind turbine model is used and read &wind_turbine_par if
+!--       required
+          CALL wtm_parin
+!
+!--       Check if virtual flights should be carried out and read &flight_par
+!--       if required
+          CALL flight_parin
+!
+!--       Check if synthetic turbulence generator is used and read stg_par if
+!--       required
+          CALL stg_parin
+!
+!--       Read chemistry variables
+          CALL chem_parin
+!
+!--       Check if uv exposure model is used and read &uvexposure_par
+          CALL uvem_parin
+!
+!--       Read user-defined variables
+          CALL user_parin
+
+!
 !--       If required, read control parameters from restart file (produced by
 !--       a prior run). All PEs are reading from file created by PE0 (see
 !--       check_open)
- 12       IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-             CALL read_var_list
-
+          IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
+
+             CALL rrd_global
 !
 !--          Increment the run count
@@ -724,83 +801,8 @@
 
 !
-!--       Try to read runtime parameters given by the user for this run
-!--       (namelist "d3par"). The namelist "d3par" can be omitted. In that case
-!--       default values are used for the parameters.
-          line = ' '
-
-          REWIND ( 11 )
-          line = ' '
-          DO   WHILE ( INDEX( line, '&d3par' ) == 0 )
-             READ ( 11, '(A)', END=20 )  line
-          ENDDO
-          BACKSPACE ( 11 )
-
-!
-!--       Read namelist
-          READ ( 11, d3par )
-
- 20       CONTINUE
-
-!
-!--       Check if land surface model is used and read &lsm_par if required
-          CALL lsm_parin
-
-!
-!--       Check if urban surface model is used and read &urban_surface_par if required
-          CALL usm_parin
-
-!
-!--       Check if spectra shall be calculated and read spectra_par if required
-          CALL spectra_parin
-
-!
-!--       Check if radiation model is used and read &radiation_par if required
-          CALL radiation_parin
-
-!
-!--       Check if gust module is used and read &gust_par if required
-          CALL gust_parin
- 
- 
-!--       Check if plant canopy model is used and read &canopy_par if required
-          CALL pcm_parin
- 
-!
-!--       Read control parameters for optionally used model software packages
-          CALL package_parin
-
-!
-!--       Check if wind turbine model is used and read &wind_turbine_par if
-!--       required
-          CALL wtm_parin
-!
-!--       Check if virtual flights should be carried out and read &flight_par
-!--       if required
-          CALL flight_parin
-!
-!--       Check if synthetic turbulence generator is used and read stg_par if
-!--       required
-          CALL stg_parin
-!
-!--       Read chemistry variables
-          CALL chem_parin
-!
-!--       Check if uv exposure model is used and read &uvexposure_par
-          CALL uvem_parin
-!
-!--       Read user-defined variables
-          CALL user_parin
-
-!
-!--       The restart file will be reopened when reading the subdomain data
-          IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-             CALL close_file( 13 )
-          ENDIF
-
-!
 !--       Check in case of initial run, if the grid point numbers are well
 !--       defined and allocate some arrays which are already needed in
 !--       init_pegrid or check_parameters. During restart jobs, these arrays
-!--       will be allocated in read_var_list. All other arrays are allocated
+!--       will be allocated in rrd_global. All other arrays are allocated
 !--       in init_3d_model.
           IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
@@ -823,5 +825,5 @@
 !
 !--          ATTENTION: in case of changes to the following statement please
-!--                  also check the allocate statement in routine read_var_list
+!--                  also check the allocate statement in routine rrd_global
              ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
                        ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2894)
@@ -25,4 +25,16 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod
+! radiation_read_restart_data was renamed to radiation_rrd_local and 
+! radiation_last_actions was renamed to radiation_wrd_local, variable named 
+! found has been introduced for checking if restart data was found, reading 
+! of restart strings has been moved completely to read_restart_data_mod, 
+! radiation_rrd_local is already inside the overlap loop programmed in 
+! read_restart_data_mod, the marker *** end rad *** is not necessary anymore,
+! strings and their respective lengths are written out and read now in case of 
+! restart runs to get rid of prescribed character lengths (Giersch)
+!
+! 2809 2018-02-15 09:55:58Z suehring
 ! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE
 ! 
@@ -809,11 +821,11 @@
     END INTERFACE radiation_tendency
 
-    INTERFACE radiation_read_restart_data
-       MODULE PROCEDURE radiation_read_restart_data
-    END INTERFACE radiation_read_restart_data
-
-    INTERFACE radiation_last_actions
-       MODULE PROCEDURE radiation_last_actions
-    END INTERFACE radiation_last_actions
+    INTERFACE radiation_rrd_local
+       MODULE PROCEDURE radiation_rrd_local
+    END INTERFACE radiation_rrd_local
+
+    INTERFACE radiation_wrd_local
+       MODULE PROCEDURE radiation_wrd_local
+    END INTERFACE radiation_wrd_local
 
     INTERFACE radiation_interaction
@@ -853,6 +865,6 @@
            radiation_3d_data_averaging, radiation_tendency,                    &
            radiation_data_output_2d, radiation_data_output_3d,                 &
-           radiation_define_netcdf_grid, radiation_last_actions,               &
-           radiation_read_restart_data, radiation_data_output_mask,            &
+           radiation_define_netcdf_grid, radiation_wrd_local,                  &
+           radiation_rrd_local, radiation_data_output_mask,                    &
            radiation_radflux_gridbox, radiation_calc_svf, radiation_write_svf, &
            radiation_interaction, radiation_interaction_init,                  &
@@ -8030,79 +8042,104 @@
 ! Description:
 ! ------------
-!> Subroutine defines masked output variables
+!> Subroutine writes the respective restart data
 !------------------------------------------------------------------------------!
- SUBROUTINE radiation_last_actions
- 
-
-    USE control_parameters
-        
-    USE kinds
+ SUBROUTINE radiation_wrd_local
+
 
     IMPLICIT NONE
 
-    IF ( write_binary )  THEN
-       IF ( ALLOCATED( rad_net_av ) )  THEN
-          WRITE ( 14 )  'rad_net_av          ';  WRITE ( 14 )  rad_net_av  
-       ENDIF  
-       IF ( ALLOCATED( rad_lw_in ) )  THEN
-          WRITE ( 14 )  'rad_lw_in           ';  WRITE ( 14 )  rad_lw_in  
-       ENDIF
-       IF ( ALLOCATED( rad_lw_in_av ) )  THEN
-          WRITE ( 14 )  'rad_lw_in_av        ';  WRITE ( 14 )  rad_lw_in_av  
-       ENDIF 
-       IF ( ALLOCATED( rad_lw_out ) )  THEN
-          WRITE ( 14 )  'rad_lw_out          ';  WRITE ( 14 )  rad_lw_out 
-       ENDIF 
-       IF ( ALLOCATED( rad_lw_out_av ) )  THEN
-          WRITE ( 14 )  'rad_lw_out_av       ';  WRITE ( 14 )  rad_lw_out_av  
-       ENDIF 
-       IF ( ALLOCATED( rad_lw_cs_hr ) )  THEN
-          WRITE ( 14 )  'rad_lw_cs_hr        ';  WRITE ( 14 )  rad_lw_cs_hr
-       ENDIF
-       IF ( ALLOCATED( rad_lw_cs_hr_av ) )  THEN
-          WRITE ( 14 )  'rad_lw_cs_hr_av     ';  WRITE ( 14 )  rad_lw_cs_hr_av
-       ENDIF
-       IF ( ALLOCATED( rad_lw_hr ) )  THEN
-          WRITE ( 14 )  'rad_lw_hr           ';  WRITE ( 14 )  rad_lw_hr
-       ENDIF
-       IF ( ALLOCATED( rad_lw_hr_av ) )  THEN
-          WRITE ( 14 )  'rad_lw_hr_av        ';  WRITE ( 14 )  rad_lw_hr_av
-       ENDIF
-       IF ( ALLOCATED( rad_sw_in ) )  THEN
-          WRITE ( 14 )  'rad_sw_in           ';  WRITE ( 14 )  rad_sw_in  
-       ENDIF 
-       IF ( ALLOCATED( rad_sw_in_av ) )  THEN
-          WRITE ( 14 )  'rad_sw_in_av        ';  WRITE ( 14 )  rad_sw_in_av  
-       ENDIF 
-       IF ( ALLOCATED( rad_sw_out ) )  THEN
-          WRITE ( 14 )  'rad_sw_out          ';  WRITE ( 14 )  rad_sw_out  
-       ENDIF 
-       IF ( ALLOCATED( rad_sw_out_av ) )  THEN
-          WRITE ( 14 )  'rad_sw_out_av       ';  WRITE ( 14 )  rad_sw_out_av  
-       ENDIF 
-       IF ( ALLOCATED( rad_sw_cs_hr ) )  THEN
-          WRITE ( 14 )  'rad_sw_cs_hr        ';  WRITE ( 14 )  rad_sw_cs_hr
-       ENDIF
-       IF ( ALLOCATED( rad_sw_cs_hr_av ) )  THEN
-          WRITE ( 14 )  'rad_sw_cs_hr_av     ';  WRITE ( 14 )  rad_sw_cs_hr_av
-       ENDIF
-       IF ( ALLOCATED( rad_sw_hr ) )  THEN
-          WRITE ( 14 )  'rad_sw_hr           ';  WRITE ( 14 )  rad_sw_hr
-       ENDIF
-       IF ( ALLOCATED( rad_sw_hr_av ) )  THEN
-          WRITE ( 14 )  'rad_sw_hr_av        ';  WRITE ( 14 )  rad_sw_hr_av
-       ENDIF
-
-       WRITE ( 14 )  '*** end rad ***     '
-
+
+    IF ( ALLOCATED( rad_net_av ) )  THEN
+       CALL wrd_write_string( 'rad_net_av' )
+       WRITE ( 14 )  rad_net_av
     ENDIF
 
- END SUBROUTINE radiation_last_actions
-
-
-SUBROUTINE radiation_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,          &
-                                        nxr_on_file, nynfa, nyn_on_file, nysfa,&
-                                        nys_on_file, offset_xa, offset_ya,     &
-                                        overlap_count, tmp_2d, tmp_3d )
+    IF ( ALLOCATED( rad_lw_in ) )  THEN
+       CALL wrd_write_string( 'rad_lw_in' )
+       WRITE ( 14 )  rad_lw_in
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_in_av ) )  THEN
+       CALL wrd_write_string( 'rad_lw_in_av' )
+       WRITE ( 14 )  rad_lw_in_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_out ) )  THEN
+       CALL wrd_write_string( 'rad_lw_out' )
+       WRITE ( 14 )  rad_lw_out
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_out_av) )  THEN
+       CALL wrd_write_string( 'rad_lw_out_av' )
+       WRITE ( 14 )  rad_lw_out_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_cs_hr) )  THEN
+       CALL wrd_write_string( 'rad_lw_cs_hr' )
+       WRITE ( 14 )  rad_lw_cs_hr
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_cs_hr_av) )  THEN
+       CALL wrd_write_string( 'rad_lw_cs_hr_av' )
+       WRITE ( 14 )  rad_lw_cs_hr_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_hr) )  THEN
+       CALL wrd_write_string( 'rad_lw_hr' )
+       WRITE ( 14 )  rad_lw_hr
+    ENDIF
+
+    IF ( ALLOCATED( rad_lw_hr_av) )  THEN
+       CALL wrd_write_string( 'rad_lw_hr_av' )
+       WRITE ( 14 )  rad_lw_hr_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_in) )  THEN
+       CALL wrd_write_string( 'rad_sw_in' )
+       WRITE ( 14 )  rad_sw_in
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_in_av) )  THEN
+       CALL wrd_write_string( 'rad_sw_in_av' )
+       WRITE ( 14 )  rad_sw_in_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_out) )  THEN
+       CALL wrd_write_string( 'rad_sw_out' )
+       WRITE ( 14 )  rad_sw_out
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_out_av) )  THEN
+       CALL wrd_write_string( 'rad_sw_out_av' )
+       WRITE ( 14 )  rad_sw_out_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_cs_hr) )  THEN
+       CALL wrd_write_string( 'rad_sw_cs_hr' )
+       WRITE ( 14 )  rad_sw_cs_hr
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_cs_hr_av) )  THEN
+       CALL wrd_write_string( 'rad_sw_cs_hr_av' )
+       WRITE ( 14 )  rad_sw_cs_hr_av
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_hr) )  THEN
+       CALL wrd_write_string( 'rad_sw_hr' )
+       WRITE ( 14 )  rad_sw_hr
+    ENDIF
+
+    IF ( ALLOCATED( rad_sw_hr_av) )  THEN
+       CALL wrd_write_string( 'rad_sw_hr_av' )
+       WRITE ( 14 )  rad_sw_hr_av
+    ENDIF
+
+
+ END SUBROUTINE radiation_wrd_local
+
+
+SUBROUTINE radiation_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,     &
+                                nxr_on_file, nynf, nync, nyn_on_file, nysf,    &
+                                nysc, nys_on_file, tmp_2d, tmp_3d, found )
  
 
@@ -8115,7 +8152,6 @@
     USE pegrid
 
+
     IMPLICIT NONE
-
-    CHARACTER (LEN=20) :: field_char   !< 
 
     INTEGER(iwp) ::  i               !< 
@@ -8133,310 +8169,274 @@
     INTEGER(iwp) ::  nysf            !< 
     INTEGER(iwp) ::  nys_on_file     !< 
-    INTEGER(iwp) ::  overlap_count   !< 
-
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_2d   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_3d   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(0:0,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_3d2   !< 
-
-
-
-   IF ( initializing_actions == 'read_restart_data' )  THEN
-      READ ( 13 )  field_char
-
-      DO  WHILE ( TRIM( field_char ) /= '*** end rad ***' )
-
-         DO  k = 1, overlap_count
-
-            nxlf = nxlfa(i,k)
-            nxlc = nxlfa(i,k) + offset_xa(i,k)
-            nxrf = nxrfa(i,k)
-            nxrc = nxrfa(i,k) + offset_xa(i,k)
-            nysf = nysfa(i,k)
-            nysc = nysfa(i,k) + offset_ya(i,k)
-            nynf = nynfa(i,k)
-            nync = nynfa(i,k) + offset_ya(i,k)
-
-
-            SELECT CASE ( TRIM( field_char ) )
-
-                CASE ( 'rad_net_av' )
-                   IF ( .NOT. ALLOCATED( rad_net_av ) )  THEN
-                      ALLOCATE( rad_net_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   rad_net_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =      &
-                                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                CASE ( 'rad_lw_in' )
-                   IF ( .NOT. ALLOCATED( rad_lw_in ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_lw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                            tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_lw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_lw_in_av' )
-                   IF ( .NOT. ALLOCATED( rad_lw_in_av ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_lw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_lw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_lw_out' )
-                   IF ( .NOT. ALLOCATED( rad_lw_out ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_lw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_lw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_lw_out_av' )
-                   IF ( .NOT. ALLOCATED( rad_lw_out_av ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_lw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_lw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_lw_cs_hr' )
-                   IF ( .NOT. ALLOCATED( rad_lw_cs_hr ) )  THEN
-                      ALLOCATE( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_lw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_lw_cs_hr_av' )
-                   IF ( .NOT. ALLOCATED( rad_lw_cs_hr_av ) )  THEN
-                      ALLOCATE( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_lw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_lw_hr' )
-                   IF ( .NOT. ALLOCATED( rad_lw_hr ) )  THEN
-                      ALLOCATE( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_lw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_lw_hr_av' )
-                   IF ( .NOT. ALLOCATED( rad_lw_hr_av ) )  THEN
-                      ALLOCATE( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_sw_in' )
-                   IF ( .NOT. ALLOCATED( rad_sw_in ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_sw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_sw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_sw_in_av' )
-                   IF ( .NOT. ALLOCATED( rad_sw_in_av ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_sw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_sw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_sw_out' )
-                   IF ( .NOT. ALLOCATED( rad_sw_out ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_sw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_sw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_sw_out_av' )
-                   IF ( .NOT. ALLOCATED( rad_sw_out_av ) )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         ALLOCATE( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
-                      ELSE
-                         ALLOCATE( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                      ENDIF
-                   ENDIF  
-                   IF ( k == 1 )  THEN
-                      IF ( radiation_scheme == 'clear-sky'  .OR.               &
-                           radiation_scheme == 'constant')  THEN
-                         READ ( 13 )  tmp_3d2
-                         rad_sw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ELSE
-                         READ ( 13 )  tmp_3d
-                         rad_sw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                      ENDIF
-                   ENDIF
-
-                CASE ( 'rad_sw_cs_hr' )
-                   IF ( .NOT. ALLOCATED( rad_sw_cs_hr ) )  THEN
-                      ALLOCATE( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_sw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_sw_cs_hr_av' )
-                   IF ( .NOT. ALLOCATED( rad_sw_cs_hr_av ) )  THEN
-                      ALLOCATE( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_sw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_sw_hr' )
-                   IF ( .NOT. ALLOCATED( rad_sw_hr ) )  THEN
-                      ALLOCATE( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_sw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rad_sw_hr_av' )
-                   IF ( .NOT. ALLOCATED( rad_sw_hr_av ) )  THEN
-                      ALLOCATE( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-               CASE DEFAULT
-                  WRITE( message_string, * ) 'unknown variable named "',       &
-                                        TRIM( field_char ), '" found in',      &
-                                        '&data from prior run on PE ', myid
-                  CALL message( 'radiation_read_restart_data', 'PA0302', 1, 2, &
-                                0, 6, 0 )
-
-            END SELECT
-
-         ENDDO
-
-         READ ( 13 )  field_char
-
-      ENDDO
-   ENDIF
-
- END SUBROUTINE radiation_read_restart_data
+
+    LOGICAL, INTENT(OUT)  :: found
+
+    REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d   !< 
+
+    REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !< 
+
+    REAL(wp), DIMENSION(0:0,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d2   !< 
+
+
+    found = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
+
+           CASE ( 'rad_net_av' )
+              IF ( .NOT. ALLOCATED( rad_net_av ) )  THEN
+                 ALLOCATE( rad_net_av(nysg:nyng,nxlg:nxrg) )
+              ENDIF  
+              IF ( k == 1 )  READ ( 13 )  tmp_2d
+              rad_net_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =           &
+                            tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+           CASE ( 'rad_lw_in' )
+              IF ( .NOT. ALLOCATED( rad_lw_in ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_lw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
+                       tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_lw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_lw_in_av' )
+              IF ( .NOT. ALLOCATED( rad_lw_in_av ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_lw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
+                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_lw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_lw_out' )
+              IF ( .NOT. ALLOCATED( rad_lw_out ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_lw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
+                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_lw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =    &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_lw_out_av' )
+              IF ( .NOT. ALLOCATED( rad_lw_out_av ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_lw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) &
+                       = tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_lw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_lw_cs_hr' )
+              IF ( .NOT. ALLOCATED( rad_lw_cs_hr ) )  THEN
+                 ALLOCATE( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_lw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_lw_cs_hr_av' )
+              IF ( .NOT. ALLOCATED( rad_lw_cs_hr_av ) )  THEN
+                 ALLOCATE( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_lw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_lw_hr' )
+              IF ( .NOT. ALLOCATED( rad_lw_hr ) )  THEN
+                 ALLOCATE( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_lw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_lw_hr_av' )
+              IF ( .NOT. ALLOCATED( rad_lw_hr_av ) )  THEN
+                 ALLOCATE( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_sw_in' )
+              IF ( .NOT. ALLOCATED( rad_sw_in ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_sw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
+                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_sw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_sw_in_av' )
+              IF ( .NOT. ALLOCATED( rad_sw_in_av ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_sw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
+                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_sw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_sw_out' )
+              IF ( .NOT. ALLOCATED( rad_sw_out ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_sw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
+                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_sw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =    &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_sw_out_av' )
+              IF ( .NOT. ALLOCATED( rad_sw_out_av ) )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    ALLOCATE( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
+                 ELSE
+                    ALLOCATE( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                 ENDIF
+              ENDIF  
+              IF ( k == 1 )  THEN
+                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
+                      radiation_scheme == 'constant')  THEN
+                    READ ( 13 )  tmp_3d2
+                    rad_sw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) &
+                       = tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ELSE
+                    READ ( 13 )  tmp_3d
+                    rad_sw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
+                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 ENDIF
+              ENDIF
+
+           CASE ( 'rad_sw_cs_hr' )
+              IF ( .NOT. ALLOCATED( rad_sw_cs_hr ) )  THEN
+                 ALLOCATE( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_sw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_sw_cs_hr_av' )
+              IF ( .NOT. ALLOCATED( rad_sw_cs_hr_av ) )  THEN
+                 ALLOCATE( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_sw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_sw_hr' )
+              IF ( .NOT. ALLOCATED( rad_sw_hr ) )  THEN
+                 ALLOCATE( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_sw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE ( 'rad_sw_hr_av' )
+              IF ( .NOT. ALLOCATED( rad_sw_hr_av ) )  THEN
+                 ALLOCATE( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+              ENDIF
+              IF ( k == 1 )  READ ( 13 )  tmp_3d
+              rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+           CASE DEFAULT
+
+              found = .FALSE.
+
+       END SELECT
+
+
+ END SUBROUTINE radiation_rrd_local
 
 
Index: palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/read_3d_binary.f90	(revision 2893)
+++ 	(revision )
@@ -1,1189 +1,0 @@
-!> @file read_3d_binary.f90
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2018 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Preliminary gust module interface implemented
-! 
-! 2797 2018-02-08 13:24:35Z suehring
-! Enable restarts for land- and urban-surface variables ghf_av, r_a_av and 
-! tsurf_av.
-! 
-! 2766 2018-01-22 17:17:47Z kanani
-! Removed preprocessor directive __chem
-! 
-! 2718 2018-01-02 08:49:38Z maronga
-! Corrected "Former revisions" section
-! 
-! 2706 2017-12-18 18:33:49Z suehring
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! - Change in file header (GPL part)
-! - kh_av, km_av (TG)
-! - Implementation of chemistry module (FK)
-! - Changes from trunk concerning random generator added (MS)
-! 
-! 2644 2017-11-27 09:27:09Z raasch
-! further bugfix for r2636 (wrong datatype used for allocation)
-!
-! 2636 2017-11-22 15:22:20Z raasch
-! bugfix for reading required for parrallel random number generator
-! 
-! 2292 2017-06-20 09:51:42Z schwenkel
-! Implementation of new microphysic scheme: cloud_scheme = 'morrison' 
-! includes two more prognostic equations for cloud drop concentration (nc)  
-! and cloud water content (qc). 
-! 
-! 2269 2017-06-09 11:57:32Z suehring
-! Enable restart runs for urban_surface_mod
-! 
-! 2233 2017-05-30 18:08:54Z suehring
-!
-! 2232 2017-05-30 17:47:52Z suehring
-! Adjustments to new surface concept - move output of surface varariables
-! to surface_mod
-! 
-! 2031 2016-10-21 15:11:58Z knoop
-! renamed variable rho_av to rho_ocean_av
-! 
-! 2000 2016-08-20 18:09:15Z knoop
-! Forced header and separation lines into 80 columns
-! 
-! 1976 2016-07-27 13:28:04Z maronga
-! Bugfix: read of land surface data only when module is switched on.
-! Radiation parts are now done in the respective module.
-! Binary version increased to 4.5.
-! 
-! 1972 2016-07-26 07:52:02Z maronga
-! Land surface parts are now done in the respective module
-! 
-! 1849 2016-04-08 11:33:18Z hoffmann 
-! prr, precipitation_amount moved to arrays_3d
-!
-! 1833 2016-04-07 14:23:03Z raasch
-! statistics module replaced by spectra module
-!
-! 1808 2016-04-05 19:44:00Z raasch
-! test output removed
-!
-! 1788 2016-03-10 11:01:04Z maronga
-! Added z0q and z0q_av
-! 
-! 1757 2016-02-22 15:49:32Z maronga
-! Bugfix in allocation of radiative heating rates
-! 
-! 1709 2015-11-04 14:47:01Z maronga
-! Added rad_lw_out_change_0, increased binary_version
-! 
-! 1691 2015-10-26 16:17:44Z maronga
-! Added output of radiative heating rates and Obukhov length. Removed output of
-! rif.
-! 
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable 
-! 
-! 1585 2015-04-30 07:05:52Z maronga
-! Adapted for RRTMG
-! 
-! 1551 2015-03-03 14:18:16Z maronga
-! Added support for binary input of land surface and radiation model data. In the
-! course of this work, new temporary arrays tmp_3d_soil1, tmp_3d_soil2 were
-! required.
-! 
-! 1468 2014-09-24 14:06:57Z maronga
-! Adapted for use on up to 6-digit processor cores
-! 
-! 1400 2014-05-09 14:03:54Z knoop
-! reading of arrays for random_generator_parallel added
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! ONLY-attribute added to USE-statements,
-! kind-parameters added to all INTEGER and REAL declaration statements,
-! kinds are defined in new module kinds,
-! old module precision_kind is removed,
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements
-!
-! 1318 2014-03-17 13:35:16Z raasch
-! module interfaces removed
-!
-! 1115 2013-03-26 18:16:16Z hoffmann
-! unused variables removed
-!
-! 1053 2012-11-13 17:11:03Z hoffmann
-! necessary expansions according to the two new prognostic equations (nr, qr) 
-! of the two-moment cloud physics scheme:
-! +prr, prr_av, *, *_av, *s, *sws, *swst
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 1001 2012-09-13 14:08:46Z raasch
-! all actions concerning leapfrog scheme removed
-!
-! 978 2012-08-09 08:28:32Z fricke
-! +z0h, z0h_av
-!
-! Revision 1.1  2004/04/30 12:47:27  raasch
-! Initial revision
-!
-!
-! Description:
-! ------------
-!> Binary input of variables and arrays from restart file
-!------------------------------------------------------------------------------!
- SUBROUTINE read_3d_binary
- 
-
-    USE arrays_3d,                                                             &
-        ONLY:  e, kh, km, p, pt, q, ql, qc, nc, nr, prr, precipitation_amount, &
-               qr, s, sa, u, u_m_l, u_m_n, u_m_r, u_m_s, v, v_m_l, v_m_n,      &
-               v_m_r, v_m_s, vpt, w, w_m_l, w_m_n, w_m_r, w_m_s
-
-    USE averaging
-
-    USE chemistry_model_mod,                                                   &
-        ONLY:  chem_read_restart_data, chem_species, nspec                                
-
-    USE control_parameters,                                                    &
-        ONLY:  air_chemistry, iran, land_surface, message_string, outflow_l,   &
-               outflow_n, outflow_r, outflow_s, urban_surface
-
-    USE cpulog,                                                                &
-        ONLY:  cpu_log, log_point_s
-
-    USE gust_mod,                                                              &
-        ONLY :  gust_module_enabled, gust_read_restart_data
-
-    USE indices,                                                               &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nx_on_file, ny, nys, nysg, nyn, &
-               nyng, ny_on_file, nzb, nzt
-
-    USE kinds
-
-    USE land_surface_model_mod,                                                &
-        ONLY:  lsm_read_restart_data
-
-    USE particle_attributes,                                                   &
-        ONLY:  iran_part
-
-    USE pegrid
-
-    USE radiation_model_mod,                                                   &
-        ONLY: radiation, radiation_read_restart_data
-
-    USE random_function_mod,                                                   &
-        ONLY:  random_iv, random_iy
-
-    USE random_generator_parallel,                                             &
-        ONLY:  id_random_array, seq_random_array
-
-    USE spectra_mod,                                                           &
-        ONLY:  spectrum_x, spectrum_y
-
-    USE surface_mod,                                                           &
-        ONLY :  surface_read_restart_data
-        
-    USE urban_surface_mod,                                                     &
-        ONLY:  usm_read_restart_data 
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=7)  ::  myid_char_save
-    CHARACTER (LEN=10) ::  binary_version
-    CHARACTER (LEN=10) ::  version_on_file
-    CHARACTER (LEN=20) ::  field_chr
-
-    INTEGER(iwp) ::  files_to_be_opened  !<
-    INTEGER(iwp) ::  i                   !<
-    INTEGER(iwp) ::  j                   !<
-    INTEGER(iwp) ::  k                   !<
-    INTEGER(iwp) ::  myid_on_file        !<
-    INTEGER(iwp) ::  numprocs_on_file    !<
-    INTEGER(iwp) ::  nxlc                !<
-    INTEGER(iwp) ::  nxlf                !<
-    INTEGER(iwp) ::  nxlpr               !<
-    INTEGER(iwp) ::  nxl_on_file         !<
-    INTEGER(iwp) ::  nxrc                !<
-    INTEGER(iwp) ::  nxrf                !<
-    INTEGER(iwp) ::  nxrpr               !<
-    INTEGER(iwp) ::  nxr_on_file         !<
-    INTEGER(iwp) ::  nync                !<
-    INTEGER(iwp) ::  nynf                !<
-    INTEGER(iwp) ::  nynpr               !<
-    INTEGER(iwp) ::  nyn_on_file         !<
-    INTEGER(iwp) ::  nysc                !<
-    INTEGER(iwp) ::  nysf                !<
-    INTEGER(iwp) ::  nyspr               !<
-    INTEGER(iwp) ::  nys_on_file         !<
-    INTEGER(iwp) ::  nzb_on_file         !<
-    INTEGER(iwp) ::  nzt_on_file         !<
-    INTEGER(iwp) ::  offset_x            !<
-    INTEGER(iwp) ::  offset_y            !<
-    INTEGER(iwp) ::  shift_x             !<
-    INTEGER(iwp) ::  shift_y             !<
-
-    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  file_list       !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  overlap_count   !<
-
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa      !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa      !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa      !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa      !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa  !<
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya  !<
-
-    INTEGER(isp), DIMENSION(:,:),   ALLOCATABLE ::  tmp_2d_id_random   !< temporary array for storing random generator data
-    INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE ::  tmp_2d_seq_random  !< temporary array for storing random generator data
-
-    REAL(wp) ::  rdummy
-
-    REAL(wp), DIMENSION(:,:),   ALLOCATABLE   ::  tmp_2d      !< temporary array for storing 2D data
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d      !< temporary array for storing 3D data
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwul   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwun   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwur   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwus   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvl   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvn   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvr   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvs   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwl   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwn   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwr   !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwws   !<
-
-    REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  tmp_4d     !<
-
-
-!
-!-- Read data from previous model run.
-    CALL cpu_log( log_point_s(14), 'read_3d_binary', 'start' )
-
-!
-!-- Check which of the restart files contain data needed for the subdomain
-!-- of this PE
-    files_to_be_opened = 0
-
-    DO  i = 1, numprocs_previous_run
-!
-!--    Store array bounds of the previous run ("pr") in temporary scalars
-       nxlpr = hor_index_bounds_previous_run(1,i-1)
-       nxrpr = hor_index_bounds_previous_run(2,i-1)
-       nyspr = hor_index_bounds_previous_run(3,i-1)
-       nynpr = hor_index_bounds_previous_run(4,i-1)
-
-!
-!--    Determine the offsets. They may be non-zero in case that the total domain
-!--    on file is smaller than the current total domain.
-       offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
-       offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
-
-!
-!--    Start with this offset and then check, if the subdomain on file
-!--    matches another time(s) in the current subdomain by shifting it
-!--    for nx_on_file+1, ny_on_file+1 respectively
-    
-       shift_y = 0
-       j       = 0
-       DO WHILE (  nyspr+shift_y <= nyn-offset_y )
-          
-          IF ( nynpr+shift_y >= nys-offset_y ) THEN 
-
-             shift_x = 0
-             DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
-                
-                IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
-                   j = j +1
-                   IF ( j > 1000 )  THEN
-!
-!--                   Array bound exceeded
-                      message_string = 'data from subdomain of previous' // &
-                                       ' run mapped more than 1000 times'
-                      CALL message( 'read_3d_binary', 'PA0284', 2, 2, -1,   &
-                                       6, 1 )
-                   ENDIF
-
-                   IF ( j == 1 )  THEN
-                      files_to_be_opened = files_to_be_opened + 1
-                      file_list(files_to_be_opened) = i-1
-                   ENDIF
-                      
-                   offset_xa(files_to_be_opened,j) = offset_x + shift_x
-                   offset_ya(files_to_be_opened,j) = offset_y + shift_y
-!
-!--                Index bounds of overlapping data
-                   nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr )
-                   nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr )
-                   nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y, nyspr )
-                   nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y, nynpr )
-
-                ENDIF
-
-                shift_x = shift_x + ( nx_on_file + 1 )
-             ENDDO
-       
-          ENDIF
-             
-          shift_y = shift_y + ( ny_on_file + 1 )             
-       ENDDO
-          
-       IF ( j > 0 )  overlap_count(files_to_be_opened) = j
-          
-    ENDDO
-   
-!
-!-- Save the id-string of the current process, since myid_char may now be used
-!-- to open files created by PEs with other id.
-    myid_char_save = myid_char
-
-    IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run ) &
-    THEN
-       WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed ', &
-                        'in restart run&  PE', myid, ' will read from files ', &
-                         file_list(1:files_to_be_opened)
-       CALL message( 'read_3d_binary', 'PA0285', 0, 0, 0, 6, 0 )
-    ENDIF
-
-!
-!-- Read data from all restart files determined above
-    DO  i = 1, files_to_be_opened
-
-       j = file_list(i)
-!
-!--    Set the filename (underscore followed by four digit processor id)
-       WRITE (myid_char,'(''_'',I6.6)')  j
-
-!
-!--    Open the restart file. If this file has been created by PE0 (_000000),
-!--    the global variables at the beginning of the file have to be skipped
-!--    first.
-       CALL check_open( 13 )
-       IF ( j == 0 )  CALL skip_var_list
-
-!
-!--    First compare the version numbers
-       READ ( 13 )  version_on_file
-       binary_version = '4.6'
-       IF ( TRIM( version_on_file ) /= TRIM( binary_version ) )  THEN
-          WRITE( message_string, * ) 'version mismatch concerning data ',      &
-                      'from prior run',                                        &
-                      '&version on file    = "', TRIM( version_on_file ), '"', &
-                      '&version in program = "', TRIM( binary_version ), '"'
-          CALL message( 'read_3d_binary', 'PA0286', 1, 2, 0, 6, 0 )
-       ENDIF
-
-!
-!--    Read number of processors, processor-id, and array ranges.
-!--    Compare the array ranges with those stored in the index bound array.
-       READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, &
-                    nys_on_file, nyn_on_file, nzb_on_file, nzt_on_file
-
-       IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
-          WRITE( message_string, * ) 'problem with index bound nxl on ',  &
-                            'restart file "', myid_char, '"',             &
-                            '&nxl = ', nxl_on_file, ' but it should be',  &
-                            '&= ', hor_index_bounds_previous_run(1,j),    &
-                            '&from the index bound information array'
-          CALL message( 'read_3d_binary', 'PA0287', 2, 2, -1, 6, 1 )
-       ENDIF
-
-       IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
-           WRITE( message_string, * ) 'problem with index bound nxr on ',   &
-                               'restart file "', myid_char, '"'  ,          &
-                               '&nxr = ', nxr_on_file, ' but it should be', &
-                               '&= ', hor_index_bounds_previous_run(2,j),   &
-                               '&from the index bound information array' 
-          CALL message( 'read_3d_binary', 'PA0288', 2, 2, -1, 6, 1 )
-
-       ENDIF
-
-       IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
-          WRITE( message_string, * ) 'problem with index bound nys on ',      &
-                                 'restart file "', myid_char, '"',            &
-                                 '&nys = ', nys_on_file, ' but it should be', &
-                                 '&= ', hor_index_bounds_previous_run(3,j),   &
-                                     '&from the index bound information array'
-          CALL message( 'read_3d_binary', 'PA0289', 2, 2, -1, 6, 1 ) 
-       ENDIF
-
-       IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
-          WRITE( message_string, * ) 'problem with index bound nyn on ',    &
-                               'restart file "', myid_char, '"',            &
-                               '&nyn = ', nyn_on_file, ' but it should be', &
-                               '&= ', hor_index_bounds_previous_run(4,j),   &
-                               '&from the index bound information array'
-          CALL message( 'read_3d_binary', 'PA0290', 2, 2, -1, 6, 1 ) 
-       ENDIF
-
-       IF ( nzb_on_file /= nzb )  THEN
-          WRITE( message_string, * ) 'mismatch between actual data and data ', &
-                                     '&from prior run on PE ', myid,           &
-                                     '&nzb on file = ', nzb_on_file,           &
-                                     '&nzb         = ', nzb
-          CALL message( 'read_3d_binary', 'PA0291', 1, 2, 0, 6, 0 )  
-       ENDIF
-
-       IF ( nzt_on_file /= nzt )  THEN
-          WRITE( message_string, * ) 'mismatch between actual data and data ', &
-                                     '&from prior run on PE ', myid,           &
-                                     '&nzt on file = ', nzt_on_file,           &
-                                     '&nzt         = ', nzt
-          CALL message( 'read_3d_binary', 'PA0292', 1, 2, 0, 6, 0 )  
-       ENDIF
-
-!
-!--    Allocate temporary arrays sized as the arrays on the restart file
-       ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,                     &
-                        nxl_on_file-nbgp:nxr_on_file+nbgp),                    &
-                 tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,           &
-                        nxl_on_file-nbgp:nxr_on_file+nbgp) )
-
-!
-!--    Read arrays
-!--    ATTENTION: If the following read commands have been altered, the 
-!--    ---------- version number of the variable binary_version must be altered,
-!--               too. Furthermore, the output list of arrays in write_3d_binary
-!--               must also be altered accordingly.
-       READ ( 13 )  field_chr
-       DO  WHILE ( TRIM( field_chr ) /= '*** end ***' )
-
-!
-!--       Map data on file as often as needed (data are read only for k=1)
-          DO  k = 1, overlap_count(i)
-
-!
-!--          Get the index range of the subdomain on file which overlap with the
-!--          current subdomain
-             nxlf = nxlfa(i,k)
-             nxlc = nxlfa(i,k) + offset_xa(i,k)
-             nxrf = nxrfa(i,k)
-             nxrc = nxrfa(i,k) + offset_xa(i,k)
-             nysf = nysfa(i,k)
-             nysc = nysfa(i,k) + offset_ya(i,k)
-             nynf = nynfa(i,k)
-             nync = nynfa(i,k) + offset_ya(i,k)
-
-
-
-             SELECT CASE ( TRIM( field_chr ) )
-
-                CASE ( 'ghf_av' )
-                   IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
-                      ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'e' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                           tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'e_av' )
-                   IF ( .NOT. ALLOCATED( e_av ) )  THEN
-                      ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'iran' ) ! matching random numbers is still unresolved
-                                ! issue
-                   IF ( k == 1 )  READ ( 13 )  iran, iran_part
-
-                CASE ( 'kh' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'kh_av' )
-                   IF ( .NOT. ALLOCATED( kh_av ) )  THEN
-                      ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'km' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'km_av' )
-                   IF ( .NOT. ALLOCATED( km_av ) )  THEN
-                      ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lpt_av' )
-                   IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
-                      ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lwp_av' )
-                   IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
-                      ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nc' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   nc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nc_av' )
-                   IF ( .NOT. ALLOCATED( nc_av ) )  THEN
-                      ALLOCATE( nc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   nc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-
-                CASE ( 'nr' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   nr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nr_av' )
-                   IF ( .NOT. ALLOCATED( nr_av ) )  THEN
-                      ALLOCATE( nr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   nr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'p' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                 tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'p_av' )
-                   IF ( .NOT. ALLOCATED( p_av ) )  THEN
-                      ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                  tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pc_av' )
-                   IF ( .NOT. ALLOCATED( pc_av ) )  THEN
-                      ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                  tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pr_av' )
-                   IF ( .NOT. ALLOCATED( pr_av ) )  THEN
-                      ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'prr' )
-                   IF ( .NOT. ALLOCATED( prr ) )  THEN
-                      ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   prr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'prr_av' )
-                   IF ( .NOT. ALLOCATED( prr_av ) )  THEN
-                      ALLOCATE( prr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   prr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'precipitation_amount' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   precipitation_amount(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'precipitation_rate_a' )
-                   IF ( .NOT. ALLOCATED( precipitation_rate_av ) )  THEN
-                      ALLOCATE( precipitation_rate_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   precipitation_rate_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pt' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pt_av' )
-                   IF ( .NOT. ALLOCATED( pt_av ) )  THEN
-                      ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'q' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'q_av' )
-                   IF ( .NOT. ALLOCATED( q_av ) )  THEN
-                      ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                     tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qc' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                       tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qc_av' )
-                   IF ( .NOT. ALLOCATED( qc_av ) )  THEN
-                      ALLOCATE( qc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                       tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                       tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql_av' )
-                   IF ( .NOT. ALLOCATED( ql_av ) )  THEN
-                      ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                       tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qr' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qr_av' )
-                   IF ( .NOT. ALLOCATED( qr_av ) )  THEN
-                      ALLOCATE( qr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql_c_av' )
-                   IF ( .NOT. ALLOCATED( ql_c_av ) )  THEN
-                      ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql_c_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql_v_av' )
-                   IF ( .NOT. ALLOCATED( ql_v_av ) )  THEN
-                      ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql_v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql_vp_av' )
-                   IF ( .NOT. ALLOCATED( ql_vp_av ) )  THEN
-                      ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql_vp_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsws_av' )
-                   IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
-                      ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qv_av' )
-                   IF ( .NOT. ALLOCATED( qv_av ) )  THEN
-                      ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'r_a_av' )
-                   IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
-                      ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'random_iv' )  ! still unresolved issue
-                   IF ( k == 1 )  READ ( 13 )  random_iv
-                   IF ( k == 1 )  READ ( 13 )  random_iy
-
-                CASE ( 'seq_random_array' )
-                   ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,         &
-                                              nxl_on_file:nxr_on_file) )
-                   ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,      &
-                                                 nxl_on_file:nxr_on_file) )
-                   IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
-                      ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
-                      ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
-                   id_random_array(nysc:nync,nxlc:nxrc) =                      &
-                                          tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
-                   seq_random_array(:,nysc:nync,nxlc:nxrc) =                   &
-                                       tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
-                   DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
-
-                CASE ( 'rho_ocean_av' )
-                   IF ( .NOT. ALLOCATED( rho_ocean_av ) )  THEN
-                      ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                           
-                CASE ( 's' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 's_av' )
-                   IF ( .NOT. ALLOCATED( s_av ) )  THEN
-                      ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                 tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'sa' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   sa(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                  tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'sa_av' )
-                   IF ( .NOT. ALLOCATED( sa_av ) )  THEN
-                      ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'shf_av' )
-                   IF ( .NOT. ALLOCATED( shf_av ) )  THEN
-                      ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   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 = 'read_3d_binary: spectrum_x ' // &
-                                     'on restart file ignored because' // &
-                                     '&total numbers of grid points (nx) ' // &
-                                     'do not match'
-                         CALL message( 'read_3d_binary', '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 = 'read_3d_binary: spectrum_y ' //   &
-                                     'on restart file ignored because' //    &
-                                     '&total numbers of grid points (ny) '// &
-                                     'do not match'
-                         CALL message( 'read_3d_binary', 'PA0294', &
-                                                                 0, 1, 0, 6, 0 )
-                      READ ( 13 )  rdummy
-                      ELSE
-                         READ ( 13 )  spectrum_y
-                      ENDIF
-                   ENDIF
-                   
-                CASE ( 'ssws_av' )
-                   IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
-                      ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF  
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                 
-                CASE ( 'ts_av' )
-                   IF ( .NOT. ALLOCATED( ts_av ) )  THEN
-                      ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'tsurf_av' )
-                   IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
-                      ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
-                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u_av' )
-                   IF ( .NOT. ALLOCATED( u_av ) )  THEN
-                      ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwul(nzb:nzt+1, &
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,1:2) )
-                      READ ( 13 )  tmp_3dwul
-                   ENDIF
-                   IF ( outflow_l )  THEN
-                      u_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwul(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'u_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwun(nzb:nzt+1,ny-1:ny, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwun
-                   ENDIF
-                   IF ( outflow_n )  THEN
-                      u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwun(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'u_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwur(nzb:nzt+1,&
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
-                      READ ( 13 )  tmp_3dwur
-                   ENDIF
-                   IF ( outflow_r )  THEN
-                      u_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwur(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'u_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwus(nzb:nzt+1,0:1, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwus
-                   ENDIF
-                   IF ( outflow_s )  THEN
-                      u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwus(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'us_av' )
-                   IF ( .NOT. ALLOCATED( us_av ) )  THEN
-                      ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v_av' )
-                   IF ( .NOT. ALLOCATED( v_av ) )  THEN
-                      ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwvl(nzb:nzt+1,&
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,0:1) )
-                      READ ( 13 )  tmp_3dwvl
-                   ENDIF
-                   IF ( outflow_l )  THEN
-                      v_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwvl(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'v_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwvn(nzb:nzt+1,ny-1:ny, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwvn
-                   ENDIF
-                   IF ( outflow_n )  THEN
-                      v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwvn(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'v_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwvr(nzb:nzt+1,&
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
-                      READ ( 13 )  tmp_3dwvr
-                   ENDIF
-                   IF ( outflow_r )  THEN
-                      v_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwvr(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'v_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwvs(nzb:nzt+1,1:2, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwvs
-                   ENDIF
-                   IF ( outflow_s )  THEN
-                      v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwvs(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'vpt' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'vpt_av' )
-                   IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
-                      ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'w' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                             tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'w_av' )
-                   IF ( .NOT. ALLOCATED( w_av ) )  THEN
-                      ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
-                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'w_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwwl(nzb:nzt+1,&
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,0:1) )
-                      READ ( 13 )  tmp_3dwwl
-                   ENDIF
-                   IF ( outflow_l )  THEN
-                      w_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwwl(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'w_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwwn(nzb:nzt+1,ny-1:ny, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwwn
-                   ENDIF
-                   IF ( outflow_n )  THEN
-                      w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwwn(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'w_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwwr(nzb:nzt+1,&
-                                          nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
-                      READ ( 13 )  tmp_3dwwr
-                   ENDIF
-                   IF ( outflow_r )  THEN
-                      w_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3dwwr(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'w_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3dwws(nzb:nzt+1,0:1, &
-                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3dwws
-                   ENDIF
-                   IF ( outflow_s )  THEN
-                      w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3dwws(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-                   DEALLOCATE( tmp_3dwws )
-
-                CASE ( 'z0_av' )
-                   IF ( .NOT. ALLOCATED( z0_av ) )  THEN
-                      ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'z0h_av' )
-                   IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
-                      ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'z0q_av' )
-                   IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
-                      ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE DEFAULT
-                   WRITE( message_string, * ) 'unknown field named "', &
-                                              TRIM( field_chr ), '" found in', &
-                                              '&data from prior run on PE ',myid
-                    CALL message( 'read_3d_binary', 'PA0295', 1, 2, 0, 6, 0 )  
-                   
-             END SELECT
-
-          ENDDO  ! overlap loop
-
-!
-!--       Deallocate arrays needed for specific variables only
-          IF ( ALLOCATED( tmp_3dwul ) )  DEALLOCATE( tmp_3dwul )
-          IF ( ALLOCATED( tmp_3dwun ) )  DEALLOCATE( tmp_3dwun )
-          IF ( ALLOCATED( tmp_3dwur ) )  DEALLOCATE( tmp_3dwur )
-          IF ( ALLOCATED( tmp_3dwus ) )  DEALLOCATE( tmp_3dwus )
-          IF ( ALLOCATED( tmp_3dwvl ) )  DEALLOCATE( tmp_3dwvl )
-          IF ( ALLOCATED( tmp_3dwvn ) )  DEALLOCATE( tmp_3dwvn )
-          IF ( ALLOCATED( tmp_3dwvr ) )  DEALLOCATE( tmp_3dwvr )
-          IF ( ALLOCATED( tmp_3dwvs ) )  DEALLOCATE( tmp_3dwvs )
-          IF ( ALLOCATED( tmp_3dwwl ) )  DEALLOCATE( tmp_3dwwl )
-          IF ( ALLOCATED( tmp_3dwwn ) )  DEALLOCATE( tmp_3dwwn )
-          IF ( ALLOCATED( tmp_3dwwr ) )  DEALLOCATE( tmp_3dwwr )
-          IF ( ALLOCATED( tmp_3dwws ) )  DEALLOCATE( tmp_3dwws )
-          IF ( ALLOCATED( tmp_4d ) )  DEALLOCATE( tmp_4d )
-
-!
-!--       Read next character string
-          READ ( 13 )  field_chr
-
-       ENDDO  ! loop over variables
-
-!
-!--    Read gust model restart data
-       IF ( gust_module_enabled )  THEN
-          CALL gust_read_restart_data
-       ENDIF
-!
-!--    Read surface related variables
-       CALL surface_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,           &
-                                       nxr_on_file, nynfa, nyn_on_file, nysfa, &
-                                       nys_on_file, offset_xa, offset_ya,      &
-                                       overlap_count(i) )
-
-!
-!--    Read urban surface restart data
-       IF ( urban_surface )  THEN
-          CALL usm_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,            &
-                                      nxr_on_file, nynfa, nyn_on_file, nysfa,  &
-                                      nys_on_file, offset_xa, offset_ya,       &
-                                      overlap_count(i) )
-       ENDIF
-
-!
-!--    Read land surface restart data
-       IF ( land_surface )  THEN
-          CALL lsm_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,            &
-                                      nxr_on_file, nynfa, nyn_on_file, nysfa,  &
-                                      nys_on_file, offset_xa, offset_ya,       &
-                                      overlap_count(i), tmp_2d )
-
-       ENDIF
-
-!
-!--    Read radiation restart data
-       IF ( radiation )  THEN
-          CALL radiation_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,      &
-                                            nxr_on_file, nynfa, nyn_on_file,   &
-                                            nysfa, nys_on_file, offset_xa,     &
-                                            offset_ya, overlap_count(i),       &
-                                            tmp_2d, tmp_3d )
-       ENDIF
-
-!
-!--    Read chemistry restart data
-       IF ( air_chemistry )  THEN
-          CALL chem_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,           &
-                                       nxr_on_file, nynfa, nyn_on_file,        &
-                                       nysfa, nys_on_file, offset_xa,          &
-                                       offset_ya, overlap_count(i),            &
-                                       tmp_2d, tmp_3d )
-       ENDIF
-
-!
-!--    Read user-defined restart data
-       CALL user_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
-                                    nynfa, nyn_on_file, nysfa, nys_on_file,    &
-                                    offset_xa, offset_ya, overlap_count(i),    &
-                                    tmp_2d, tmp_3d )
-
-!
-!--    Close the restart file
-       CALL close_file( 13 )
-
-       DEALLOCATE( tmp_2d, tmp_3d )
-
-    ENDDO  ! loop over restart files
-
-
-!
-!-- Restore the original filename for the restart file to be written
-    myid_char = myid_char_save
-
-!
-!-- End of time measuring for reading binary data
-    CALL cpu_log( log_point_s(14), 'read_3d_binary', 'stop' )
-
- END SUBROUTINE read_3d_binary
Index: palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 2894)
+++ palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 2894)
@@ -0,0 +1,2080 @@
+!> @file read_restart_data_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision
+! 
+!
+! Description:
+! ------------
+!> Reads restart data from restart-file(s) (binary format).
+!------------------------------------------------------------------------------!
+ MODULE read_restart_data_mod
+
+
+    USE control_parameters
+     
+
+    IMPLICIT NONE
+
+
+    INTERFACE rrd_global
+       MODULE PROCEDURE rrd_global
+    END INTERFACE rrd_global
+
+    INTERFACE rrd_read_parts_of_global
+       MODULE PROCEDURE rrd_read_parts_of_global
+    END INTERFACE rrd_read_parts_of_global
+
+    INTERFACE rrd_local
+       MODULE PROCEDURE rrd_local
+    END INTERFACE rrd_local
+
+    INTERFACE rrd_skip_global
+       MODULE PROCEDURE rrd_skip_global
+    END INTERFACE rrd_skip_global
+
+
+    PUBLIC rrd_global, rrd_read_parts_of_global, rrd_local,      & 
+           rrd_skip_global
+
+
+ CONTAINS
+
+! Description:
+! ------------
+!> Reads values of global control variables from restart-file (binary format) 
+!> created by PE0 of the previous run
+!------------------------------------------------------------------------------!
+    SUBROUTINE rrd_global
+
+
+       USE arrays_3d,                                                          &
+           ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,        &
+                  q_init, ref_state, s_init, sa_init, u_init, ug, v_init, vg
+
+       USE flight_mod,                                                         &
+           ONLY: flight_rrd_global
+
+       USE grid_variables,                                                     &
+           ONLY:  dx, dy
+
+       USE indices,                                                            &
+           ONLY:  nz, nx, nx_on_file, ny, ny_on_file
+
+       USE microphysics_mod,                                                   &
+           ONLY:  c_sedimentation, collision_turbulence,                       &
+                  cloud_water_sedimentation, limiter_sedimentation,            &
+                  nc_const, ventilation_effect
+
+       USE model_1d_mod,                                                       &
+           ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
+
+       USE netcdf_interface,                                                   &
+           ONLY:  netcdf_precision, output_for_t0
+
+       USE particle_attributes,                                                &
+           ONLY:  curvature_solution_effects
+
+       USE pegrid
+
+       USE radiation_model_mod,                                                &
+           ONLY:  time_radiation
+
+       USE spectra_mod,                                                        &
+           ONLY:  average_count_sp
+
+       USE statistics,                                                         &
+           ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,  &
+                  v_max, v_max_ijk, w_max, w_max_ijk
+
+       USE synthetic_turbulence_generator_mod,                                 &
+           ONLY: stg_rrd_global
+
+       USE user_read_restart_data_mod,                                         &
+           ONLY:  user_rrd_global 
+
+       USE vertical_nesting_mod,                                               &
+           ONLY:  vnest_init
+
+       USE wind_turbine_model_mod,                                             &
+           ONLY: wtm_rrd_global
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=10) ::  binary_version_global, version_on_file
+
+       LOGICAL ::  found  
+
+
+       CALL check_open( 13 )
+
+!
+!-- Make version number check first
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+       READ ( 13 )  version_on_file
+
+       binary_version_global = '4.7'
+       IF ( TRIM( version_on_file ) /= TRIM( binary_version_global ) )  THEN
+          WRITE( message_string, * ) 'version mismatch concerning control ',   &
+                                     'variables',                              &
+                                     '&version on file    = "',                &
+                                     TRIM( version_on_file ), '"',             &
+                                     '&version on program = "',                &
+                                     TRIM( binary_version_global ), '"'
+          CALL message( 'rrd_global', 'PA0296', 1, 2, 0, 6, 0 )
+       ENDIF
+
+!
+!-- Read number of PEs and horizontal index bounds of all PEs used in previous
+!-- run
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( TRIM( restart_string(1:length) ) /= 'numprocs' )  THEN
+          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
+                                     'run on PE ', myid
+          CALL message( 'rrd_global', 'PA0297', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  numprocs_previous_run
+
+       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
+          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
+       ENDIF
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
+          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
+                                     'from prior run on PE ', myid
+          CALL message( 'rrd_global', 'PA0298', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  hor_index_bounds_previous_run
+
+!
+!-- Read vertical number of gridpoints and number of different areas used
+!-- for computing statistics. Allocate arrays depending on these values,
+!-- which are needed for the following read instructions.
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'nz' )  THEN
+          WRITE( message_string, * ) 'nz not found in data from prior run ',   &
+                                     'on PE ', myid
+          CALL message( 'rrd_global', 'PA0299', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  nz
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
+          WRITE( message_string, * ) 'max_pr_user not found in data from ',    &
+                                     'prior run on PE ', myid
+          CALL message( 'rrd_global', 'PA0300', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  max_pr_user    ! This value is checked against the number of
+                                   ! user profiles given for the current run
+                                   ! in routine user_parin (it has to match)
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
+          WRITE( message_string, * ) 'statistic_regions not found in data ',   &
+                                     'from prior run on PE ', myid
+          CALL message( 'rrd_global', 'PA0301', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  statistic_regions
+       IF ( .NOT. ALLOCATED( ug ) )  THEN
+          ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1),                    &
+                    v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),           &
+                    ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),        &
+                    hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),     &
+                    hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
+       ENDIF
+
+!
+!-- Now read all control parameters:
+!-- Caution: When the following read instructions have been changed, the
+!-- -------  version number stored in the variable binary_version_global has to
+!--          be increased. The same changes must also be done in 
+!--          wrd_write_global.
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       DO WHILE ( restart_string(1:length) /= 'binary_version_local' )
+
+          found = .FALSE.
+
+          SELECT CASE ( restart_string(1:length) )
+
+             CASE ( 'advected_distance_x' )
+                READ ( 13 )  advected_distance_x
+             CASE ( 'advected_distance_y' )
+                READ ( 13 )  advected_distance_y
+             CASE ( 'alpha_surface' )
+                READ ( 13 )  alpha_surface
+             CASE ( 'average_count_pr' )
+                READ ( 13 )  average_count_pr
+             CASE ( 'average_count_sp' )
+                READ ( 13 )  average_count_sp
+             CASE ( 'average_count_3d' )
+                READ ( 13 )  average_count_3d
+             CASE ( 'bc_e_b' )
+                READ ( 13 )  bc_e_b
+             CASE ( 'bc_lr' )
+                READ ( 13 )  bc_lr
+             CASE ( 'bc_ns' )
+                READ ( 13 )  bc_ns
+             CASE ( 'bc_p_b' )
+                READ ( 13 )  bc_p_b
+             CASE ( 'bc_p_t' )
+                READ ( 13 )  bc_p_t
+             CASE ( 'bc_pt_b' )
+                READ ( 13 )  bc_pt_b
+             CASE ( 'bc_pt_t' )
+                READ ( 13 )  bc_pt_t
+             CASE ( 'bc_pt_t_val' )
+                READ ( 13 )  bc_pt_t_val
+             CASE ( 'bc_q_b' )
+                READ ( 13 )  bc_q_b
+             CASE ( 'bc_q_t' )
+                READ ( 13 )  bc_q_t
+             CASE ( 'bc_q_t_val' )
+                READ ( 13 )  bc_q_t_val
+             CASE ( 'bc_s_b' )
+                READ ( 13 )  bc_s_b
+             CASE ( 'bc_s_t' )
+                READ ( 13 )  bc_s_t
+             CASE ( 'bc_sa_t' )
+                READ ( 13 )  bc_sa_t
+             CASE ( 'bc_uv_b' )
+                READ ( 13 )  bc_uv_b
+             CASE ( 'bc_uv_t' )
+                READ ( 13 )  bc_uv_t
+             CASE ( 'bottom_salinityflux' )
+                READ ( 13 )  bottom_salinityflux
+             CASE ( 'building_height' )
+                READ ( 13 )  building_height
+             CASE ( 'building_length_x' )
+                READ ( 13 )  building_length_x
+             CASE ( 'building_length_y' )
+                READ ( 13 )  building_length_y
+             CASE ( 'building_wall_left' )
+                READ ( 13 )  building_wall_left
+             CASE ( 'building_wall_south' )
+                READ ( 13 )  building_wall_south
+             CASE ( 'c_sedimentation' )
+                READ ( 13 )  c_sedimentation
+             CASE ( 'call_psolver_at_all_substeps' )
+                READ ( 13 )  call_psolver_at_all_substeps
+             CASE ( 'canyon_height' )
+                READ ( 13 )  canyon_height
+             CASE ( 'canyon_wall_left' )
+                READ ( 13 )  canyon_wall_left
+             CASE ( 'canyon_wall_south' )
+                READ ( 13 )  canyon_wall_south
+             CASE ( 'canyon_width_x' )
+                READ ( 13 )  canyon_width_x
+             CASE ( 'canyon_width_y' )
+                READ ( 13 )  canyon_width_y
+             CASE ( 'cfl_factor' )
+                READ ( 13 )  cfl_factor
+             CASE ( 'cloud_droplets' )
+                READ ( 13 )  cloud_droplets
+             CASE ( 'cloud_physics' )
+                READ ( 13 )  cloud_physics
+             CASE ( 'cloud_scheme' )
+                READ ( 13 )  cloud_scheme
+             CASE ( 'cloud_top_radiation' )
+                READ ( 13 )  cloud_top_radiation
+             CASE ( 'cloud_water_sedimentation' )
+                READ ( 13 )  cloud_water_sedimentation
+             CASE ( 'collective_wait' )
+                READ ( 13 )  collective_wait
+             CASE ( 'collision_turbulence' )
+                READ ( 13 )  collision_turbulence
+             CASE ( 'conserve_volume_flow' )
+                READ ( 13 )  conserve_volume_flow
+             CASE ( 'conserve_volume_flow_mode' )
+                READ ( 13 )  conserve_volume_flow_mode
+             CASE ( 'constant_flux_layer' )
+                READ ( 13 )  constant_flux_layer
+             CASE ( 'coupling_start_time' )
+                READ ( 13 )  coupling_start_time
+             CASE ( 'current_timestep_number' )
+                READ ( 13 )  current_timestep_number
+             CASE ( 'curvature_solution_effects' )
+                READ ( 13 )  curvature_solution_effects
+             CASE ( 'cycle_mg' )
+                READ ( 13 )  cycle_mg
+             CASE ( 'damp_level_1d' )
+                READ ( 13 )  damp_level_1d
+             CASE ( 'dissipation_1d' )
+                READ ( 13 )  dissipation_1d
+             CASE ( 'do2d_xy_time_count' )
+                READ ( 13 )  do2d_xy_time_count
+             CASE ( 'do2d_xz_time_count' )
+                READ ( 13 )  do2d_xz_time_count
+             CASE ( 'do2d_yz_time_count' )
+                READ ( 13 )  do2d_yz_time_count
+             CASE ( 'do3d_time_count' )
+                READ ( 13 )  do3d_time_count
+             CASE ( 'dp_external' )
+                READ ( 13 )  dp_external
+             CASE ( 'dp_level_b' )
+                READ ( 13 )  dp_level_b
+             CASE ( 'dp_smooth' )
+                READ ( 13 )  dp_smooth
+             CASE ( 'dpdxy' )
+                READ ( 13 )  dpdxy
+             CASE ( 'dt_3d' )
+                READ ( 13 )  dt_3d
+             CASE ( 'dt_pr_1d' )
+                READ ( 13 )  dt_pr_1d
+             CASE ( 'dt_run_control_1d' )
+                READ ( 13 )  dt_run_control_1d
+             CASE ( 'dvrp_filecount' )
+                READ ( 13 )  dvrp_filecount
+             CASE ( 'dx' )
+                READ ( 13 )  dx
+             CASE ( 'dy' )
+                READ ( 13 )  dy
+             CASE ( 'dz' )
+                READ ( 13 )  dz
+             CASE ( 'dz_max' )
+                READ ( 13 )  dz_max
+             CASE ( 'dz_stretch_factor' )
+                READ ( 13 )  dz_stretch_factor
+             CASE ( 'dz_stretch_level' )
+                READ ( 13 )  dz_stretch_level
+             CASE ( 'e_min' )
+                READ ( 13 )  e_min
+             CASE ( 'end_time_1d' )
+                READ ( 13 )  end_time_1d
+             CASE ( 'fft_method' )
+                READ ( 13 )  fft_method
+             CASE ( 'first_call_lpm' )
+                READ ( 13 )  first_call_lpm
+             CASE ( 'galilei_transformation' )
+                READ ( 13 )  galilei_transformation
+             CASE ( 'hom' )
+                READ ( 13 )  hom
+             CASE ( 'hom_sum' )
+                READ ( 13 )  hom_sum
+             CASE ( 'humidity' )
+                READ ( 13 )  humidity
+             CASE ( 'inflow_damping_factor' )
+                IF ( .NOT. ALLOCATED( inflow_damping_factor ) )  THEN
+                   ALLOCATE( inflow_damping_factor(0:nz+1) )
+                ENDIF
+                READ ( 13 )  inflow_damping_factor
+             CASE ( 'inflow_damping_height' )
+                READ ( 13 )  inflow_damping_height
+             CASE ( 'inflow_damping_width' )
+                READ ( 13 )  inflow_damping_width
+             CASE ( 'inflow_disturbance_begin' )
+                READ ( 13 )  inflow_disturbance_begin
+             CASE ( 'inflow_disturbance_end' )
+                READ ( 13 )  inflow_disturbance_end
+             CASE ( 'km_constant' )
+                READ ( 13 )  km_constant
+             CASE ( 'large_scale_forcing' )
+                READ ( 13 )  large_scale_forcing
+             CASE ( 'large_scale_subsidence' )
+                READ ( 13 )  large_scale_subsidence
+             CASE ( 'latitude' )
+                READ ( 13 )  latitude
+             CASE ( 'limiter_sedimentation' )
+                READ ( 13 )  limiter_sedimentation
+             CASE ( 'longitude' )
+                READ ( 13 )  longitude
+             CASE ( 'loop_optimization' )
+                READ ( 13 )  loop_optimization
+             CASE ( 'masking_method' )
+                READ ( 13 )  masking_method
+             CASE ( 'mean_inflow_profiles' )
+                IF ( .NOT. ALLOCATED( mean_inflow_profiles ) )  THEN
+                   ALLOCATE( mean_inflow_profiles(0:nz+1,7) )
+                ENDIF
+                READ ( 13 )  mean_inflow_profiles
+             CASE ( 'mg_cycles' )
+                READ ( 13 )  mg_cycles
+             CASE ( 'mg_switch_to_pe0_level' )
+                READ ( 13 )  mg_switch_to_pe0_level
+             CASE ( 'mixing_length_1d' )
+                READ ( 13 )  mixing_length_1d
+             CASE ( 'momentum_advec' )
+                READ ( 13 )  momentum_advec
+             CASE ( 'most_method' )
+                READ ( 13 )  most_method
+             CASE ( 'nc_const' )
+                READ ( 13 )  nc_const
+             CASE ( 'netcdf_precision' )
+                READ ( 13 )  netcdf_precision
+             CASE ( 'neutral' )
+                READ ( 13 )  neutral
+             CASE ( 'ngsrb' )
+                READ ( 13 )  ngsrb
+             CASE ( 'nsor' )
+                READ ( 13 )  nsor
+             CASE ( 'nsor_ini' )
+                READ ( 13 )  nsor_ini
+             CASE ( 'nudging' )
+                READ ( 13 )  nudging
+             CASE ( 'num_leg' )
+                READ ( 13 )  num_leg
+             CASE ( 'nx' )
+                READ ( 13 )  nx
+                nx_on_file = nx
+             CASE ( 'ny' )
+                READ ( 13 )  ny
+                ny_on_file = ny
+             CASE ( 'ocean' )
+                READ ( 13 )  ocean
+             CASE ( 'old_dt' )
+                READ ( 13 )  old_dt
+             CASE ( 'omega' )
+                READ ( 13 )  omega
+             CASE ( 'omega_sor' )
+                READ ( 13 )  omega_sor
+             CASE ( 'output_for_t0' )
+                READ (13)    output_for_t0
+             CASE ( 'passive_scalar' )
+                READ ( 13 )  passive_scalar
+             CASE ( 'prandtl_number' )
+                READ ( 13 )  prandtl_number
+             CASE ( 'precipitation' )
+                READ ( 13 ) precipitation
+             CASE ( 'psolver' )
+                READ ( 13 )  psolver
+             CASE ( 'pt_damping_factor' )
+                READ ( 13 )  pt_damping_factor
+             CASE ( 'pt_damping_width' )
+                READ ( 13 )  pt_damping_width
+             CASE ( 'pt_init' )
+                READ ( 13 )  pt_init
+             CASE ( 'pt_reference' )
+                READ ( 13 )  pt_reference
+             CASE ( 'pt_surface' )
+                READ ( 13 )  pt_surface
+             CASE ( 'pt_surface_initial_change' )
+                READ ( 13 )  pt_surface_initial_change
+             CASE ( 'pt_vertical_gradient' )
+                READ ( 13 )  pt_vertical_gradient
+             CASE ( 'pt_vertical_gradient_level' )
+                READ ( 13 )  pt_vertical_gradient_level
+             CASE ( 'pt_vertical_gradient_level_ind' )
+                READ ( 13 )  pt_vertical_gradient_level_ind
+             CASE ( 'q_init' )
+                READ ( 13 )  q_init
+             CASE ( 'q_surface' )
+                READ ( 13 )  q_surface
+             CASE ( 'q_surface_initial_change' )
+                READ ( 13 )  q_surface_initial_change
+             CASE ( 'q_vertical_gradient' )
+                READ ( 13 )  q_vertical_gradient
+             CASE ( 'q_vertical_gradient_level' )
+                READ ( 13 )  q_vertical_gradient_level
+             CASE ( 'q_vertical_gradient_level_ind' )
+                READ ( 13 )  q_vertical_gradient_level_ind
+             CASE ( 'random_generator' )
+                READ ( 13 )  random_generator
+             CASE ( 'random_heatflux' )
+                READ ( 13 )  random_heatflux
+             CASE ( 'rans_mode' )
+                READ ( 13 )  rans_mode
+             CASE ( 'rayleigh_damping_factor' )
+                READ ( 13 )  rayleigh_damping_factor
+             CASE ( 'rayleigh_damping_height' )
+                READ ( 13 )  rayleigh_damping_height
+             CASE ( 'recycling_width' )
+                READ ( 13 )  recycling_width
+             CASE ( 'recycling_yshift' )
+                READ ( 13 ) recycling_yshift
+             CASE ( 'ref_state' )
+                READ ( 13 )  ref_state
+             CASE ( 'reference_state' )
+                READ ( 13 )  reference_state
+             CASE ( 'residual_limit' )
+                READ ( 13 )  residual_limit
+             CASE ( 'roughness_length' )
+                READ ( 13 )  roughness_length
+             CASE ( 'run_coupled' )
+                READ ( 13 )  run_coupled
+             CASE ( 'runnr' )
+                READ ( 13 )  runnr
+             CASE ( 's_init' )
+                READ ( 13 )  s_init
+             CASE ( 's_surface' )
+                READ ( 13 )  s_surface
+             CASE ( 's_surface_initial_change' )
+                READ ( 13 )  s_surface_initial_change
+             CASE ( 's_vertical_gradient' )
+                READ ( 13 )  s_vertical_gradient
+             CASE ( 's_vertical_gradient_level' )
+                READ ( 13 )  s_vertical_gradient_level
+             CASE ( 's_vertical_gradient_level_ind' )
+                READ ( 13 )  s_vertical_gradient_level_ind
+             CASE ( 'sa_init' )
+                READ ( 13 )  sa_init
+             CASE ( 'sa_surface' )
+                READ ( 13 )  sa_surface
+             CASE ( 'sa_vertical_gradient' )
+                READ ( 13 )  sa_vertical_gradient
+             CASE ( 'sa_vertical_gradient_level' )
+                READ ( 13 )  sa_vertical_gradient_level
+             CASE ( 'scalar_advec' )
+                READ ( 13 )  scalar_advec
+             CASE ( 'simulated_time' )
+                READ ( 13 )  simulated_time
+             CASE ( 'surface_heatflux' )
+                READ ( 13 )  surface_heatflux
+             CASE ( 'surface_pressure' )
+                READ ( 13 )  surface_pressure
+             CASE ( 'surface_scalarflux' )
+                READ ( 13 )  surface_scalarflux
+             CASE ( 'surface_waterflux' )
+                READ ( 13 )  surface_waterflux
+             CASE ( 'time_coupling' )
+                READ ( 13 )  time_coupling
+             CASE ( 'time_disturb' )
+                READ ( 13 )  time_disturb
+             CASE ( 'time_do2d_xy' )
+                READ ( 13 )  time_do2d_xy
+             CASE ( 'time_do2d_xz' )
+                READ ( 13 )  time_do2d_xz
+             CASE ( 'time_do2d_yz' )
+                READ ( 13 )  time_do2d_yz
+             CASE ( 'time_do3d' )
+                READ ( 13 )  time_do3d
+             CASE ( 'time_do_av' )
+                READ ( 13 )  time_do_av
+             CASE ( 'time_do_sla' )
+                READ ( 13 )  time_do_sla
+             CASE ( 'time_domask' )
+                READ ( 13 )  time_domask
+             CASE ( 'time_dopr' )
+                READ ( 13 )  time_dopr
+             CASE ( 'time_dopr_av' )
+                READ ( 13 )  time_dopr_av
+             CASE ( 'time_dopr_listing' )
+                READ ( 13 )  time_dopr_listing
+             CASE ( 'time_dopts' )
+                READ ( 13 )  time_dopts
+             CASE ( 'time_dosp' )
+                READ ( 13 )  time_dosp
+             CASE ( 'time_dots' )
+                READ ( 13 )  time_dots
+             CASE ( 'time_dvrp' )
+                READ ( 13 )  time_dvrp
+             CASE ( 'time_radiation' )
+                READ ( 13 )  time_radiation
+             CASE ( 'time_restart' )
+                READ ( 13 )  time_restart
+             CASE ( 'time_run_control' )
+                READ ( 13 )  time_run_control
+             CASE ( 'time_since_reference_point' )
+                READ ( 13 )  time_since_reference_point
+             CASE ( 'timestep_scheme' )
+                READ ( 13 )  timestep_scheme
+             CASE ( 'top_heatflux' )
+                READ ( 13 )  top_heatflux
+             CASE ( 'top_momentumflux_u' )
+                READ ( 13 )  top_momentumflux_u
+             CASE ( 'top_momentumflux_v' )
+                READ ( 13 )  top_momentumflux_v
+             CASE ( 'top_salinityflux' )
+                READ ( 13 )  top_salinityflux
+             CASE ( 'top_scalarflux' )
+                READ ( 13 )  top_scalarflux
+             CASE ( 'topography' )
+                READ ( 13 )  topography
+             CASE ( 'topography_grid_convention' )
+                READ ( 13 )  topography_grid_convention
+             CASE ( 'tsc' )
+                READ ( 13 )  tsc
+             CASE ( 'tunnel_height' )
+                READ ( 13 )  tunnel_height
+             CASE ( 'tunnel_length' )
+                READ ( 13 )  tunnel_length
+             CASE ( 'tunnel_wall_depth' )
+                READ ( 13 )  tunnel_wall_depth
+             CASE ( 'tunnel_width_x' )
+                READ ( 13 )  tunnel_width_x
+             CASE ( 'tunnel_width_y' )
+                READ ( 13 )  tunnel_width_y
+             CASE ( 'turbulence_closure' )
+                READ ( 13 )  turbulence_closure
+             CASE ( 'turbulent_inflow' )
+                READ ( 13 )  turbulent_inflow
+             CASE ( 'u_bulk' )
+                READ ( 13 )  u_bulk
+             CASE ( 'u_init' )
+                READ ( 13 )  u_init
+             CASE ( 'u_max' )
+                READ ( 13 )  u_max
+             CASE ( 'u_max_ijk' )
+                READ ( 13 )  u_max_ijk
+             CASE ( 'ug' )
+                READ ( 13 )  ug
+             CASE ( 'ug_surface' )
+                READ ( 13 )  ug_surface
+             CASE ( 'ug_vertical_gradient' )
+                READ ( 13 )  ug_vertical_gradient
+             CASE ( 'ug_vertical_gradient_level' )
+                READ ( 13 )  ug_vertical_gradient_level
+             CASE ( 'ug_vertical_gradient_level_ind' )
+                READ ( 13 )  ug_vertical_gradient_level_ind
+             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
+             CASE ( 'use_upstream_for_tke' )
+                READ ( 13 )  use_upstream_for_tke
+             CASE ( 'v_bulk' )
+                READ ( 13 )  v_bulk
+             CASE ( 'v_init' )
+                READ ( 13 )  v_init
+             CASE ( 'v_max' )
+                READ ( 13 )  v_max
+             CASE ( 'v_max_ijk' )
+                READ ( 13 )  v_max_ijk
+             CASE ( 'ventilation_effect' )
+                READ ( 13 )  ventilation_effect
+             CASE ( 'vg' )
+                READ ( 13 )  vg
+             CASE ( 'vg_surface' )
+                READ ( 13 )  vg_surface
+             CASE ( 'vg_vertical_gradient' )
+                READ ( 13 )  vg_vertical_gradient
+             CASE ( 'vg_vertical_gradient_level' )
+                READ ( 13 )  vg_vertical_gradient_level
+             CASE ( 'vg_vertical_gradient_level_ind' )
+                READ ( 13 )  vg_vertical_gradient_level_ind
+             CASE ( 'virtual_flight' )
+                READ ( 13 )  virtual_flight
+             CASE ( 'vnest_init' )
+                READ ( 13 )  vnest_init
+             CASE ( 'volume_flow_area' )
+                READ ( 13 )  volume_flow_area
+             CASE ( 'volume_flow_initial' )
+                READ ( 13 )  volume_flow_initial
+             CASE ( 'subs_vertical_gradient' )
+                READ ( 13 )  subs_vertical_gradient
+             CASE ( 'subs_vertical_gradient_level' )
+                READ ( 13 )  subs_vertical_gradient_level
+             CASE ( 'subs_vertical_gradient_level_i' )
+                READ ( 13 )  subs_vertical_gradient_level_i
+             CASE ( 'w_max' )
+                READ ( 13 )  w_max
+             CASE ( 'w_max_ijk' )
+                READ ( 13 )  w_max_ijk
+             CASE ( 'wall_adjustment' )
+                READ ( 13 )  wall_adjustment
+             CASE ( 'wall_heatflux' )
+                READ ( 13 )  wall_heatflux
+             CASE ( 'wall_humidityflux' )
+                READ ( 13 )  wall_humidityflux
+             CASE ( 'wall_salinityflux' )
+                READ ( 13 )  wall_salinityflux
+             CASE ( 'wall_scalarflux' )
+                READ ( 13 )  wall_scalarflux
+             CASE ( 'y_shift' )
+                READ ( 13 )  y_shift
+             CASE ( 'z0h_factor' )
+                READ ( 13 )  z0h_factor
+             CASE ( 'zeta_max' )
+                READ ( 13 )  zeta_max
+             CASE ( 'zeta_min' )
+                READ ( 13 )  zeta_min
+
+             CASE DEFAULT
+
+                IF ( .NOT. found ) CALL wtm_rrd_global( found )
+
+                IF ( .NOT. found ) CALL flight_rrd_global( found )
+
+                IF ( .NOT. found ) CALL stg_rrd_global ( found )
+
+                IF ( .NOT. found ) CALL user_rrd_global( found )
+
+                IF ( .NOT. found )  THEN
+                   WRITE( message_string, * ) 'unknown variable named "',      &
+                                           restart_string(1:length),           &
+                                          '" found in global data from ',      & 
+                                          'prior run on PE ', myid
+                CALL message( 'rrd_global', 'PA0302', 1, 2, 0, 6, 0 )
+ 
+                ENDIF
+
+          END SELECT
+!
+!--       Read next string
+          READ ( 13 )  length
+          READ ( 13 )  restart_string(1:length)    
+
+       ENDDO
+ 
+
+    CALL close_file( 13 )
+
+    
+    END SUBROUTINE rrd_global
+
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Skipping the global control variables from restart-file (binary format)
+!> except some information needed when reading restart data from a previous
+!> run which used a smaller total domain or/and a different domain decomposition
+!> (initializing_actions  == 'cyclic_fill').
+!------------------------------------------------------------------------------!
+
+    SUBROUTINE rrd_read_parts_of_global
+
+
+       USE arrays_3d,                                                             &
+           ONLY:  inflow_damping_factor, mean_inflow_profiles, ref_state, ug, vg
+
+       USE indices,                                                               &
+           ONLY:  nz, nx, nx_on_file, ny, ny_on_file
+
+       USE kinds
+
+       USE pegrid
+
+       USE statistics,                                                            &
+           ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,     &
+                  v_max, v_max_ijk, w_max, w_max_ijk
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=10) ::  version_on_file
+       CHARACTER (LEN=20) ::  momentum_advec_check
+       CHARACTER (LEN=20) ::  scalar_advec_check
+       CHARACTER (LEN=1)  ::  cdum
+
+       INTEGER(iwp) ::  max_pr_user_on_file
+       INTEGER(iwp) ::  nz_on_file
+       INTEGER(iwp) ::  statistic_regions_on_file
+       INTEGER(iwp) ::  tmp_mpru
+       INTEGER(iwp) ::  tmp_sr
+
+       REAL(wp), DIMENSION(:,:,:),   ALLOCATABLE ::  hom_sum_on_file
+       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  hom_on_file
+
+
+       CALL check_open( 13 )
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+       READ ( 13 )  version_on_file
+
+!
+!-- Read number of PEs and horizontal index bounds of all PEs used in previous
+!-- run
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'numprocs' )  THEN
+          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
+                                     'run on PE ', myid
+          CALL message( 'rrd_read_parts_of_global', 'PA0297', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  numprocs_previous_run
+
+       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
+          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
+       ENDIF
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
+          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
+                                     'from prior run on PE ', myid
+          CALL message( 'rrd_read_parts_of_global', 'PA0298', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  hor_index_bounds_previous_run
+
+!
+!-- Read vertical number of gridpoints and number of different areas used
+!-- for computing statistics. Allocate arrays depending on these values,
+!-- which are needed for the following read instructions.
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'nz' )  THEN
+          message_string = 'nz not found in restart data file'
+          CALL message( 'rrd_read_parts_of_global', 'PA0303', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  nz_on_file
+       IF ( nz_on_file /= nz )  THEN
+          WRITE( message_string, * ) 'mismatch concerning number of ',         &
+                                     'gridpoints along z',                     &
+                                     '&nz on file    = "', nz_on_file, '"',    &
+                                     '&nz from run   = "', nz, '"'
+          CALL message( 'rrd_read_parts_of_global', 'PA0304', 1, 2, 0, 6, 0 )
+       ENDIF
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
+          message_string = 'max_pr_user not found in restart data file'
+          CALL message( 'rrd_read_parts_of_global', 'PA0305', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  max_pr_user_on_file
+       IF ( max_pr_user_on_file /= max_pr_user )  THEN
+          WRITE( message_string, * ) 'number of user profiles on res',         &
+                                     'tart data file differs from the ',       &
+                                     'current run&max_pr_user on file    = "', &
+                                     max_pr_user_on_file, '"',                 &
+                                     '&max_pr_user from run   = "',            &
+                                     max_pr_user, '"'
+          CALL message( 'rrd_read_parts_of_global', 'PA0306', 0, 0, 0, 6, 0 )
+          tmp_mpru = MIN( max_pr_user_on_file, max_pr_user )
+       ELSE
+          tmp_mpru = max_pr_user
+       ENDIF
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
+          message_string = 'statistic_regions not found in restart data file'
+          CALL message( 'rrd_read_parts_of_global', 'PA0307', 1, 2, 0, 6, 0 )
+       ENDIF
+       READ ( 13 )  statistic_regions_on_file
+       IF ( statistic_regions_on_file /= statistic_regions )  THEN
+          WRITE( message_string, * ) 'statistic regions on restart data file ',&
+                                     'differ from the current run',            &
+                                     '&statistic regions on file    = "',      &
+                                     statistic_regions_on_file, '"',           &
+                                     '&statistic regions from run   = "',      &
+                                      statistic_regions, '"',                  &
+                                     '&statistic data may be lost!'
+          CALL message( 'rrd_read_parts_of_global', 'PA0308', 0, 1, 0, 6, 0 )
+          tmp_sr = MIN( statistic_regions_on_file, statistic_regions )
+       ELSE
+          tmp_sr = statistic_regions
+       ENDIF
+
+!
+!-- Now read and check some control parameters and skip the rest
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
+
+          SELECT CASE ( restart_string(1:length) )
+
+             CASE ( 'average_count_pr' )
+                READ ( 13 )  average_count_pr
+                IF ( average_count_pr /= 0 )  THEN
+                   WRITE( message_string, * ) 'inflow profiles not ',          &
+                                  'temporally averaged. &Averaging will be ',  &
+                                  'done now using', average_count_pr,          & 
+                                  ' samples.'
+                   CALL message( 'rrd_read_parts_of_global', 'PA0309',         &
+                                 0, 1, 0, 6, 0 )
+                ENDIF
+
+             CASE ( 'hom' )
+                ALLOCATE( hom_on_file(0:nz+1,2,pr_palm+max_pr_user_on_file,    &
+                          0:statistic_regions_on_file) )
+                READ ( 13 )  hom_on_file
+                hom(:,:,1:pr_palm+tmp_mpru,0:tmp_sr) =                         &
+                             hom_on_file(:,:,1:pr_palm+tmp_mpru,0:tmp_sr)
+                DEALLOCATE( hom_on_file )
+
+             CASE ( 'hom_sum' )
+                ALLOCATE( hom_sum_on_file(0:nz+1,pr_palm+max_pr_user_on_file,  &
+                          0:statistic_regions_on_file) )
+                READ ( 13 )  hom_sum_on_file
+                hom_sum(:,1:pr_palm+tmp_mpru,0:tmp_sr) =                       &
+                             hom_sum_on_file(:,1:pr_palm+tmp_mpru,0:tmp_sr)
+                DEALLOCATE( hom_sum_on_file )
+
+             CASE ( 'momentum_advec' )
+                momentum_advec_check = momentum_advec
+                READ ( 13 )  momentum_advec
+                IF ( TRIM( momentum_advec_check ) /= TRIM( momentum_advec ) )  &
+                THEN
+                   WRITE( message_string, * ) 'momentum_advec of the restart ',&
+                                  'run differs from momentum_advec of the ',   &
+                                  'initial run.'
+                   CALL message( 'rrd_read_parts_of_global', 'PA0100',         &
+                                 1, 2, 0, 6, 0 )
+                ENDIF
+
+             CASE ( 'nx' )
+                READ ( 13 )  nx_on_file
+
+             CASE ( 'ny' )
+                READ ( 13 )  ny_on_file
+
+             CASE ( 'ref_state' )
+                READ ( 13 )  ref_state
+
+             CASE ( 'scalar_advec' )
+                scalar_advec_check = scalar_advec
+                READ ( 13 )  scalar_advec
+                IF ( TRIM( scalar_advec_check ) /= TRIM( scalar_advec ) )      &
+                THEN
+                   WRITE( message_string, * ) 'scalar_advec of the restart ',  &
+                                  'run differs from scalar_advec of the ',     &
+                                  'initial run.'
+                   CALL message( 'rrd_read_parts_of_global', 'PA0101',         &
+                                 1, 2, 0, 6, 0 )
+                ENDIF
+
+             CASE DEFAULT
+
+                READ ( 13 )  cdum
+
+          END SELECT
+
+          READ ( 13 )  length
+          READ ( 13 )  restart_string(1:length)
+
+       ENDDO
+
+!
+!-- Calculate the temporal average of vertical profiles, if neccessary
+    IF ( average_count_pr /= 0 )  THEN
+       hom_sum = hom_sum / REAL( average_count_pr, KIND=wp )
+    ENDIF
+
+
+    CALL close_file( 13 )
+
+
+    END SUBROUTINE rrd_read_parts_of_global
+
+
+! Description:
+! ------------
+!> Reads processor specific data of variables and arrays from restart file 
+!> (binary format).
+!------------------------------------------------------------------------------!
+ SUBROUTINE rrd_local 
+ 
+
+    USE arrays_3d,                                                             &
+        ONLY:  e, kh, km, p, pt, q, ql, qc, nc, nr, prr, precipitation_amount, &
+               qr, s, sa, u, u_m_l, u_m_n, u_m_r, u_m_s, v, v_m_l, v_m_n,      &
+               v_m_r, v_m_s, vpt, w, w_m_l, w_m_n, w_m_r, w_m_s
+
+    USE averaging
+
+    USE chemistry_model_mod,                                                   &
+        ONLY:  chem_rrd_local, chem_species, nspec                                
+
+    USE cpulog,                                                                &
+        ONLY:  cpu_log, log_point_s
+
+    USE indices,                                                               &
+        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nx_on_file, ny, nys, nysg, nyn, &
+               nyng, ny_on_file, nzb, nzt
+
+    USE kinds
+
+    USE land_surface_model_mod,                                                &
+        ONLY:  lsm_rrd_local
+
+    USE particle_attributes,                                                   &
+        ONLY:  iran_part
+
+    USE pegrid
+
+    USE radiation_model_mod,                                                   &
+        ONLY: radiation, radiation_rrd_local
+
+    USE random_function_mod,                                                   &
+        ONLY:  random_iv, random_iy
+
+    USE random_generator_parallel,                                             &
+        ONLY:  id_random_array, seq_random_array
+
+    USE spectra_mod,                                                           &
+        ONLY:  spectrum_x, spectrum_y
+
+    USE surface_mod,                                                           &
+        ONLY :  surface_rrd_local
+        
+    USE urban_surface_mod,                                                     &
+        ONLY:  usm_rrd_local
+
+    USE user_read_restart_data_mod,                                            &
+        ONLY:  user_rrd_local 
+ 
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=7)  ::  myid_char_save
+    CHARACTER (LEN=10) ::  binary_version_local
+    CHARACTER (LEN=10) ::  version_on_file
+
+    INTEGER(iwp) ::  files_to_be_opened  !<
+    INTEGER(iwp) ::  i                   !<
+    INTEGER(iwp) ::  j                   !<
+    INTEGER(iwp) ::  k                   !<
+    INTEGER(iwp) ::  myid_on_file        !<
+    INTEGER(iwp) ::  numprocs_on_file    !<
+    INTEGER(iwp) ::  nxlc                !<
+    INTEGER(iwp) ::  nxlf                !<
+    INTEGER(iwp) ::  nxlpr               !<
+    INTEGER(iwp) ::  nxl_on_file         !<
+    INTEGER(iwp) ::  nxrc                !<
+    INTEGER(iwp) ::  nxrf                !<
+    INTEGER(iwp) ::  nxrpr               !<
+    INTEGER(iwp) ::  nxr_on_file         !<
+    INTEGER(iwp) ::  nync                !<
+    INTEGER(iwp) ::  nynf                !<
+    INTEGER(iwp) ::  nynpr               !<
+    INTEGER(iwp) ::  nyn_on_file         !<
+    INTEGER(iwp) ::  nysc                !<
+    INTEGER(iwp) ::  nysf                !<
+    INTEGER(iwp) ::  nyspr               !<
+    INTEGER(iwp) ::  nys_on_file         !<
+    INTEGER(iwp) ::  nzb_on_file         !<
+    INTEGER(iwp) ::  nzt_on_file         !<
+    INTEGER(iwp) ::  offset_x            !<
+    INTEGER(iwp) ::  offset_y            !<
+    INTEGER(iwp) ::  shift_x             !<
+    INTEGER(iwp) ::  shift_y             !<
+
+    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  file_list       !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  overlap_count   !<
+
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa      !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa      !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa      !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa      !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa  !<
+    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya  !<
+
+    INTEGER(isp), DIMENSION(:,:),   ALLOCATABLE ::  tmp_2d_id_random   !< temporary array for storing random generator data
+    INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE ::  tmp_2d_seq_random  !< temporary array for storing random generator data
+
+    LOGICAL ::  found
+
+    REAL(wp) ::  rdummy
+
+    REAL(wp), DIMENSION(:,:),   ALLOCATABLE   ::  tmp_2d      !< temporary array for storing 2D data
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d      !< temporary array for storing 3D data
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwul   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwun   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwur   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwus   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvl   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvn   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvr   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwvs   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwl   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwn   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwwr   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3dwws   !<
+
+
+!
+!-- Read data from previous model run.
+    CALL cpu_log( log_point_s(14), 'rrd_local', 'start' )
+
+!
+!-- Check which of the restart files contain data needed for the subdomain
+!-- of this PE
+    files_to_be_opened = 0
+
+    DO  i = 1, numprocs_previous_run
+!
+!--    Store array bounds of the previous run ("pr") in temporary scalars
+       nxlpr = hor_index_bounds_previous_run(1,i-1)
+       nxrpr = hor_index_bounds_previous_run(2,i-1)
+       nyspr = hor_index_bounds_previous_run(3,i-1)
+       nynpr = hor_index_bounds_previous_run(4,i-1)
+
+!
+!--    Determine the offsets. They may be non-zero in case that the total domain
+!--    on file is smaller than the current total domain.
+       offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
+       offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
+
+!
+!--    Start with this offset and then check, if the subdomain on file
+!--    matches another time(s) in the current subdomain by shifting it
+!--    for nx_on_file+1, ny_on_file+1 respectively
+    
+       shift_y = 0
+       j       = 0
+       DO WHILE (  nyspr+shift_y <= nyn-offset_y )
+          
+          IF ( nynpr+shift_y >= nys-offset_y ) THEN 
+
+             shift_x = 0
+             DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
+                
+                IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
+                   j = j +1
+                   IF ( j > 1000 )  THEN
+!
+!--                   Array bound exceeded
+                      message_string = 'data from subdomain of previous' //    &
+                                       ' run mapped more than 1000 times'
+                      CALL message( 'rrd_local', 'PA0284', 2, 2, -1,           &
+                                       6, 1 )
+                   ENDIF
+
+                   IF ( j == 1 )  THEN
+                      files_to_be_opened = files_to_be_opened + 1
+                      file_list(files_to_be_opened) = i-1
+                   ENDIF
+                      
+                   offset_xa(files_to_be_opened,j) = offset_x + shift_x
+                   offset_ya(files_to_be_opened,j) = offset_y + shift_y
+!
+!--                Index bounds of overlapping data
+                   nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x,    &
+                                                      nxlpr )
+                   nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x,    &
+                                                      nxrpr )
+                   nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y,    & 
+                                                      nyspr )
+                   nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y,    & 
+                                                      nynpr )
+
+                ENDIF
+
+                shift_x = shift_x + ( nx_on_file + 1 )
+             ENDDO
+       
+          ENDIF
+             
+          shift_y = shift_y + ( ny_on_file + 1 )             
+       ENDDO
+          
+       IF ( j > 0 )  overlap_count(files_to_be_opened) = j
+          
+    ENDDO
+   
+!
+!-- Save the id-string of the current process, since myid_char may now be used
+!-- to open files created by PEs with other id.
+    myid_char_save = myid_char
+
+    IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run )    &
+    THEN
+       WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed ', &
+                        'in restart run&  PE', myid, ' will read from files ', &
+                         file_list(1:files_to_be_opened)
+       CALL message( 'rrd_local', 'PA0285', 0, 0, 0, 6, 0 )
+    ENDIF
+
+!
+!-- Read data from all restart files determined above
+    DO  i = 1, files_to_be_opened
+ 
+       j = file_list(i)
+!
+!--    Set the filename (underscore followed by four digit processor id)
+       WRITE (myid_char,'(''_'',I6.6)')  j
+
+!
+!--    Open the restart file. If this file has been created by PE0 (_000000),
+!--    the global variables at the beginning of the file have to be skipped
+!--    first.
+       CALL check_open( 13 )
+       IF ( j == 0 )  CALL rrd_skip_global
+
+!
+!--    First compare the version numbers
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+       READ ( 13 )  version_on_file
+
+       binary_version_local = '4.7'
+       IF ( TRIM( version_on_file ) /= TRIM( binary_version_local ) )  THEN
+          WRITE( message_string, * ) 'version mismatch concerning data ',      &
+                      'from prior run',                                        &
+                      '&version on file    = "', TRIM( version_on_file ), '"', &
+                      '&version in program = "', TRIM( binary_version_local ), '"'
+          CALL message( 'rrd_local', 'PA0286', 1, 2, 0, 6, 0 )
+       ENDIF
+
+!
+!--    Read number of processors, processor-id, and array ranges.
+!--    Compare the array ranges with those stored in the index bound array.
+       READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file,  &
+                    nys_on_file, nyn_on_file, nzb_on_file, nzt_on_file
+
+       IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
+          WRITE( message_string, * ) 'problem with index bound nxl on ',       &
+                            'restart file "', myid_char, '"',                  &
+                            '&nxl = ', nxl_on_file, ' but it should be',       &
+                            '&= ', hor_index_bounds_previous_run(1,j),         &
+                            '&from the index bound information array'
+          CALL message( 'rrd_local', 'PA0287', 2, 2, -1, 6, 1 )
+       ENDIF
+
+       IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
+           WRITE( message_string, * ) 'problem with index bound nxr on ',      &
+                               'restart file "', myid_char, '"'  ,             &
+                               '&nxr = ', nxr_on_file, ' but it should be',    &
+                               '&= ', hor_index_bounds_previous_run(2,j),      &
+                               '&from the index bound information array' 
+          CALL message( 'rrd_local', 'PA0288', 2, 2, -1, 6, 1 )
+
+       ENDIF
+
+       IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
+          WRITE( message_string, * ) 'problem with index bound nys on ',       &
+                                 'restart file "', myid_char, '"',             &
+                                 '&nys = ', nys_on_file, ' but it should be',  &
+                                 '&= ', hor_index_bounds_previous_run(3,j),    &
+                                     '&from the index bound information array'
+          CALL message( 'rrd_local', 'PA0289', 2, 2, -1, 6, 1 ) 
+       ENDIF
+
+       IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
+          WRITE( message_string, * ) 'problem with index bound nyn on ',       &
+                               'restart file "', myid_char, '"',               &
+                               '&nyn = ', nyn_on_file, ' but it should be',    &
+                               '&= ', hor_index_bounds_previous_run(4,j),      &
+                               '&from the index bound information array'
+          CALL message( 'rrd_local', 'PA0290', 2, 2, -1, 6, 1 ) 
+       ENDIF
+
+       IF ( nzb_on_file /= nzb )  THEN
+          WRITE( message_string, * ) 'mismatch between actual data and data ', &
+                                     '&from prior run on PE ', myid,           &
+                                     '&nzb on file = ', nzb_on_file,           &
+                                     '&nzb         = ', nzb
+          CALL message( 'rrd_local', 'PA0291', 1, 2, 0, 6, 0 )  
+       ENDIF
+
+       IF ( nzt_on_file /= nzt )  THEN
+          WRITE( message_string, * ) 'mismatch between actual data and data ', &
+                                     '&from prior run on PE ', myid,           &
+                                     '&nzt on file = ', nzt_on_file,           &
+                                     '&nzt         = ', nzt
+          CALL message( 'rrd_local', 'PA0292', 1, 2, 0, 6, 0 )  
+       ENDIF
+
+!
+!--    Allocate temporary arrays sized as the arrays on the restart file
+       ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,                     &
+                        nxl_on_file-nbgp:nxr_on_file+nbgp),                    &
+                 tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,           &
+                        nxl_on_file-nbgp:nxr_on_file+nbgp) )
+
+!
+!--    Read arrays
+!--    ATTENTION: If the following read commands have been altered, the 
+!--    ---------- version number of the variable binary_version_local must 
+!--               be altered, too. Furthermore, the output list of arrays in 
+!--               wrd_write_local must also be altered 
+!--               accordingly.
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+       
+
+!
+!--    Loop over processor specific field data
+       DO  WHILE ( restart_string(1:length) /= '*** end ***' )
+
+          found = .FALSE.
+!
+!--       Map data on file as often as needed (data are read only for k=1)
+          DO  k = 1, overlap_count(i)
+
+!
+!--          Get the index range of the subdomain on file which overlap with
+!--          the current subdomain
+             nxlf = nxlfa(i,k)
+             nxlc = nxlfa(i,k) + offset_xa(i,k)
+             nxrf = nxrfa(i,k)
+             nxrc = nxrfa(i,k) + offset_xa(i,k)
+             nysf = nysfa(i,k)
+             nysc = nysfa(i,k) + offset_ya(i,k)
+             nynf = nynfa(i,k)
+             nync = nynfa(i,k) + offset_ya(i,k)
+
+
+             SELECT CASE ( restart_string(1:length) )
+
+                CASE ( 'ghf_av' )
+                   IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
+                      ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'e' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'e_av' )
+                   IF ( .NOT. ALLOCATED( e_av ) )  THEN
+                      ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,              &
+                                     nxl-nbgp:nxr+nbgp) )    
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'iran' ) ! matching random numbers is still unresolved
+                                ! issue
+                   IF ( k == 1 )  READ ( 13 )  iran, iran_part
+
+                CASE ( 'kh' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'kh_av' )
+                   IF ( .NOT. ALLOCATED( kh_av ) )  THEN
+                      ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'km' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'km_av' )
+                   IF ( .NOT. ALLOCATED( km_av ) )  THEN
+                      ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'lpt_av' )
+                   IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
+                      ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'lwp_av' )
+                   IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
+                      ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'nc' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   nc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'nc_av' )
+                   IF ( .NOT. ALLOCATED( nc_av ) )  THEN
+                      ALLOCATE( nc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   nc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+
+                CASE ( 'nr' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   nr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'nr_av' )
+                   IF ( .NOT. ALLOCATED( nr_av ) )  THEN
+                      ALLOCATE( nr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   nr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'p' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'p_av' )
+                   IF ( .NOT. ALLOCATED( p_av ) )  THEN
+                      ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'pc_av' )
+                   IF ( .NOT. ALLOCATED( pc_av ) )  THEN
+                      ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   pc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'pr_av' )
+                   IF ( .NOT. ALLOCATED( pr_av ) )  THEN
+                      ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   pr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'prr' )
+                   IF ( .NOT. ALLOCATED( prr ) )  THEN
+                      ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   prr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =            &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'prr_av' )
+                   IF ( .NOT. ALLOCATED( prr_av ) )  THEN
+                      ALLOCATE( prr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   prr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'precipitation_amount' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   precipitation_amount(nysc-nbgp:nync+nbgp,                   &
+                                        nxlc-nbgp:nxrc+nbgp)  =                &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'precipitation_rate_av' )
+                   IF ( .NOT. ALLOCATED( precipitation_rate_av ) )  THEN
+                      ALLOCATE( precipitation_rate_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   precipitation_rate_av(nysc-nbgp:nync+nbgp,                  &
+                                         nxlc-nbgp:nxrc+nbgp)  =               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'pt' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'pt_av' )
+                   IF ( .NOT. ALLOCATED( pt_av ) )  THEN
+                      ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'q' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'q_av' )
+                   IF ( .NOT. ALLOCATED( q_av ) )  THEN
+                      ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qc' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   qc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qc_av' )
+                   IF ( .NOT. ALLOCATED( qc_av ) )  THEN
+                      ALLOCATE( qc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   qc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'ql' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'ql_av' )
+                   IF ( .NOT. ALLOCATED( ql_av ) )  THEN
+                      ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qr' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   qr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qr_av' )
+                   IF ( .NOT. ALLOCATED( qr_av ) )  THEN
+                      ALLOCATE( qr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   qr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'ql_c_av' )
+                   IF ( .NOT. ALLOCATED( ql_c_av ) )  THEN
+                      ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   ql_c_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'ql_v_av' )
+                   IF ( .NOT. ALLOCATED( ql_v_av ) )  THEN
+                      ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   ql_v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'ql_vp_av' )
+                   IF ( .NOT. ALLOCATED( ql_vp_av ) )  THEN
+                      ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   ql_vp_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =       &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qsws_av' )
+                   IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
+                      ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF  
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =         &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'qv_av' )
+                   IF ( .NOT. ALLOCATED( qv_av ) )  THEN
+                      ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'r_a_av' )
+                   IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
+                      ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'random_iv' )  ! still unresolved issue
+                   IF ( k == 1 )  READ ( 13 )  random_iv
+                   IF ( k == 1 )  READ ( 13 )  random_iy
+
+                CASE ( 'seq_random_array' )
+                   ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,         &
+                                              nxl_on_file:nxr_on_file) )
+                   ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,      &
+                                                 nxl_on_file:nxr_on_file) )
+                   IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
+                      ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
+                   ENDIF
+                   IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
+                      ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
+                   id_random_array(nysc:nync,nxlc:nxrc) =                      &
+                      tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
+                   seq_random_array(:,nysc:nync,nxlc:nxrc) =                   &
+                      tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
+                   DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
+
+                CASE ( 'rho_ocean_av' )
+                   IF ( .NOT. ALLOCATED( rho_ocean_av ) )  THEN
+                      ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                           
+                CASE ( 's' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 's_av' )
+                   IF ( .NOT. ALLOCATED( s_av ) )  THEN
+                      ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'sa' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   sa(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'sa_av' )
+                   IF ( .NOT. ALLOCATED( sa_av ) )  THEN
+                      ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'shf_av' )
+                   IF ( .NOT. ALLOCATED( shf_av ) )  THEN
+                      ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   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' )
+                   IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
+                      ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF  
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =         &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+                 
+                CASE ( 'ts_av' )
+                   IF ( .NOT. ALLOCATED( ts_av ) )  THEN
+                      ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =           &
+                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'tsurf_av' )
+                   IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
+                      ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'u' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'u_av' )
+                   IF ( .NOT. ALLOCATED( u_av ) )  THEN
+                      ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'u_m_l' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwul(nzb:nzt+1,                           &
+                                nys_on_file-nbgp:nyn_on_file+nbgp,1:2) )
+                      READ ( 13 )  tmp_3dwul
+                   ENDIF
+                   IF ( outflow_l )  THEN
+                      u_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
+                         tmp_3dwul(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'u_m_n' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwun(nzb:nzt+1,ny-1:ny,                   &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwun
+                   ENDIF
+                   IF ( outflow_n )  THEN
+                      u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         & 
+                         tmp_3dwun(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'u_m_r' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwur(nzb:nzt+1,                           &
+                                nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
+                      READ ( 13 )  tmp_3dwur
+                   ENDIF
+                   IF ( outflow_r )  THEN
+                      u_m_r(:,nysc-nbgp:nync+nbgp,:) =                         & 
+                         tmp_3dwur(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'u_m_s' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwus(nzb:nzt+1,0:1,                       &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwus
+                   ENDIF
+                   IF ( outflow_s )  THEN
+                      u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
+                         tmp_3dwus(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'us_av' )
+                   IF ( .NOT. ALLOCATED( us_av ) )  THEN
+                      ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =           &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'v' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'v_av' )
+                   IF ( .NOT. ALLOCATED( v_av ) )  THEN
+                      ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'v_m_l' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwvl(nzb:nzt+1,                           &
+                                nys_on_file-nbgp:nyn_on_file+nbgp,0:1) )
+                      READ ( 13 )  tmp_3dwvl
+                   ENDIF
+                   IF ( outflow_l )  THEN
+                      v_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
+                         tmp_3dwvl(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'v_m_n' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwvn(nzb:nzt+1,ny-1:ny,                   &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwvn
+                   ENDIF
+                   IF ( outflow_n )  THEN
+                      v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
+                         tmp_3dwvn(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'v_m_r' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwvr(nzb:nzt+1,                           &
+                                nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
+                      READ ( 13 )  tmp_3dwvr
+                   ENDIF
+                   IF ( outflow_r )  THEN
+                      v_m_r(:,nysc-nbgp:nync+nbgp,:) =                         &
+                         tmp_3dwvr(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'v_m_s' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwvs(nzb:nzt+1,1:2,                       &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwvs
+                   ENDIF
+                   IF ( outflow_s )  THEN
+                      v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
+                         tmp_3dwvs(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'vpt' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =            &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'vpt_av' )
+                   IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
+                      ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'w' )
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'w_av' )
+                   IF ( .NOT. ALLOCATED( w_av ) )  THEN
+                      ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_3d
+                   w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
+                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'w_m_l' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwwl(nzb:nzt+1,&
+                                nys_on_file-nbgp:nyn_on_file+nbgp,0:1) )
+                      READ ( 13 )  tmp_3dwwl
+                   ENDIF
+                   IF ( outflow_l )  THEN
+                      w_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
+                         tmp_3dwwl(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'w_m_n' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwwn(nzb:nzt+1,ny-1:ny, &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwwn
+                   ENDIF
+                   IF ( outflow_n )  THEN
+                      w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
+                         tmp_3dwwn(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'w_m_r' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwwr(nzb:nzt+1,&
+                                nys_on_file-nbgp:nyn_on_file+nbgp,nx-1:nx) )
+                      READ ( 13 )  tmp_3dwwr
+                   ENDIF
+                   IF ( outflow_r )  THEN
+                      w_m_r(:,nysc-nbgp:nync+nbgp,:) =                         & 
+                         tmp_3dwwr(:,nysf-nbgp:nynf+nbgp,:)
+                   ENDIF
+
+                CASE ( 'w_m_s' )
+                   IF ( k == 1 )  THEN
+                      ALLOCATE( tmp_3dwws(nzb:nzt+1,0:1, &
+                                          nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                      READ ( 13 )  tmp_3dwws
+                   ENDIF
+                   IF ( outflow_s )  THEN
+                      w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         & 
+                         tmp_3dwws(:,:,nxlf-nbgp:nxrf+nbgp)
+                   ENDIF
+
+                CASE ( 'z0_av' )
+                   IF ( .NOT. ALLOCATED( z0_av ) )  THEN
+                      ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =           &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'z0h_av' )
+                   IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
+                      ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
+                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE ( 'z0q_av' )
+                   IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
+                      ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
+                   ENDIF
+                   IF ( k == 1 )  READ ( 13 )  tmp_2d
+                   z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
+                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                CASE DEFAULT
+
+!
+!--                Read surface related variables
+                   IF ( .NOT. found ) CALL surface_rrd_local( i, k, nxlf,      &
+                                           nxlc, nxl_on_file, nxrf, nxrc,      & 
+                                           nxr_on_file, nynf, nync,            & 
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, found )
+
+!
+!--                Read urban surface restart data
+                   IF ( .NOT. found ) CALL usm_rrd_local( i, k, nxlf,          & 
+                                           nxlc, nxl_on_file, nxrf, nxrc,      &
+                                           nxr_on_file, nynf, nync,            &
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, found )
+
+!
+!--                Read land surface restart data
+                   IF ( .NOT. found ) CALL lsm_rrd_local( i, k, nxlf,          & 
+                                           nxlc, nxl_on_file, nxrf, nxrc,      &
+                                           nxr_on_file, nynf, nync,            &
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, tmp_2d, found )
+
+!
+!--                Read radiation restart data
+                   IF ( .NOT. found ) CALL radiation_rrd_local( i, k, nxlf,    &
+                                           nxlc, nxl_on_file, nxrf, nxrc,      &
+                                           nxr_on_file, nynf, nync,            &
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, tmp_2d, tmp_3d, found )
+
+!
+!--                Read chemistry restart data
+                   IF ( .NOT. found ) CALL chem_rrd_local( i, k, nxlf,         &
+                                           nxlc, nxl_on_file, nxrf, nxrc,      &
+                                           nxr_on_file, nynf, nync,            & 
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, tmp_3d, found )
+
+!
+!--                Read user-defined restart data
+                   IF ( .NOT. found ) CALL user_rrd_local( i, k, nxlf,         &
+                                           nxlc, nxl_on_file, nxrf, nxrc,      &
+                                           nxr_on_file, nynf, nync,            &
+                                           nyn_on_file, nysf, nysc,            &
+                                           nys_on_file, tmp_3d, found )
+
+
+                   IF ( .NOT. found )  THEN
+                      WRITE( message_string, * ) 'unknown variable named "',   &
+                                                 restart_string(1:length),     &
+                                                '" found in subdomain data ',  & 
+                                                'from prior run on PE ', myid
+                      CALL message( 'rrd_local', 'PA0302', 1, 2, 0, 6, 0 )
+ 
+                   ENDIF
+
+             END SELECT
+
+          ENDDO ! overlaploop 
+
+!
+!--       Deallocate arrays needed for specific variables only
+          IF ( ALLOCATED( tmp_3dwul ) )  DEALLOCATE( tmp_3dwul )
+          IF ( ALLOCATED( tmp_3dwun ) )  DEALLOCATE( tmp_3dwun )
+          IF ( ALLOCATED( tmp_3dwur ) )  DEALLOCATE( tmp_3dwur )
+          IF ( ALLOCATED( tmp_3dwus ) )  DEALLOCATE( tmp_3dwus )
+          IF ( ALLOCATED( tmp_3dwvl ) )  DEALLOCATE( tmp_3dwvl )
+          IF ( ALLOCATED( tmp_3dwvn ) )  DEALLOCATE( tmp_3dwvn )
+          IF ( ALLOCATED( tmp_3dwvr ) )  DEALLOCATE( tmp_3dwvr )
+          IF ( ALLOCATED( tmp_3dwvs ) )  DEALLOCATE( tmp_3dwvs )
+          IF ( ALLOCATED( tmp_3dwwl ) )  DEALLOCATE( tmp_3dwwl )
+          IF ( ALLOCATED( tmp_3dwwn ) )  DEALLOCATE( tmp_3dwwn )
+          IF ( ALLOCATED( tmp_3dwwr ) )  DEALLOCATE( tmp_3dwwr )
+          IF ( ALLOCATED( tmp_3dwws ) )  DEALLOCATE( tmp_3dwws )
+
+!
+!--       Read next character string
+          READ ( 13 )  length
+          READ ( 13 )  restart_string(1:length)
+
+       ENDDO ! dataloop
+
+!
+!--    Close the restart file
+       CALL close_file( 13 )
+
+       DEALLOCATE( tmp_2d, tmp_3d )
+
+    ENDDO  ! loop over restart files
+
+
+!
+!-- Restore the original filename for the restart file to be written
+    myid_char = myid_char_save
+
+!
+!-- End of time measuring for reading binary data
+    CALL cpu_log( log_point_s(14), 'rrd_local', 'stop' )
+
+ END SUBROUTINE rrd_local
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Skipping the global control variables from restart-file (binary format)
+!------------------------------------------------------------------------------!
+
+    SUBROUTINE rrd_skip_global
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=10) ::  version_on_file
+
+       CHARACTER (LEN=1) ::  cdum
+
+
+       READ ( 13 )  length
+       READ ( 13 )  restart_string(1:length)
+
+       DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
+
+          READ ( 13 )  cdum
+          READ ( 13 )  length 
+          READ ( 13 )  restart_string(1:length)
+
+       ENDDO
+
+       BACKSPACE ( 13 )
+       BACKSPACE ( 13 )
+
+
+    END SUBROUTINE rrd_skip_global
+
+
+ END MODULE read_restart_data_mod
Index: palm/trunk/SOURCE/read_var_list.f90
===================================================================
--- palm/trunk/SOURCE/read_var_list.f90	(revision 2893)
+++ 	(revision )
@@ -1,1153 +1,0 @@
-!> @file read_var_list.f90
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2018 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! ------------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Added spinup_time to allow for restarts with spinup in precursor run.
-! 
-! 2776 2018-01-31 10:44:42Z Giersch
-! Change skip_var_list: Skipping of module related parameter is only necessary 
-! if restart data was outputted at the end of the precursor run
-! 
-! 2718 2018-01-02 08:49:38Z maronga
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-! + rans_mode, turbulence_closure (TG)
-! 
-! 2576 2017-10-24 13:49:46Z Giersch
-! *** end *** marks the end of the standard parameter list of restart files
-! like it was before revision 2563. To skip also the variables of the modules  
-! wind_turbine_model_mod, flight_mod and synthetic_turbulence_generator_mod 
-! three new functions has to be defined which are called in skip_var_list.
-! Adapted binary version number 
-! 
-! 2575 2017-10-24 09:57:58Z maronga
-! Renamed phi -> latitude, added longitude
-! 
-! 2563 2017-10-19 15:36:10Z Giersch
-! CALL stg_read_restart_data moved to synthetic_turbulence_generator_mod and
-! CALL flight_read_restart_data moved to virtual_flights_mod. Furthermore 
-! *** end default *** marks the end of the standard parameter list of restart
-! files and *** end *** marks the end of all parameter including module
-! parameter. Therefore the call of flight_skip_var_list becomes unnecessary.
-! 
-! 2372 2017-08-25 12:37:32Z sward
-! y_shift added to vars, version no. increased
-! 
-! 2365 2017-08-21 14:59:59Z kanani
-! Vertical grid nesting implemented (SadiqHuq)
-! 
-! 2339 2017-08-07 13:55:26Z gronemeier
-! corrected timestamp in header
-! 
-! 2338 2017-08-07 12:15:38Z gronemeier
-! Modularize 1D model
-! 
-! 2320 2017-07-21 12:47:43Z suehring
-! Formatting adjustment
-! 
-! 2265 2017-06-08 16:58:28Z schwenkel
-! Unused variables removed.
-! 
-! 2259 2017-06-08 09:09:11Z gronemeier
-! Implemented synthetic turbulence generator
-!
-! 2233 2017-05-30 18:08:54Z suehring
-!
-! 2232 2017-05-30 17:47:52Z suehring
-! Replace wall_qflux, wall_sflux by wall_humidityflux and wall_scalarflux; add
-! wall_salinityflux
-! +tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,
-!  tunnel_wall_depth
-!
-! 2042 2016-11-02 13:47:31Z suehring
-! Bugfix, read restart data for wall_heatflux, wall_qflux and wall_sflux
-!
-! 2000 2016-08-20 18:09:15Z knoop
-! Forced header and separation lines into 80 columns
-!
-! 1992 2016-08-12 15:14:59Z suehring
-! top_scalarflux added
-!
-! 1960 2016-07-12 16:34:24Z suehring
-! Separate humidity and passive scalar
-! Remove unused variables from ONLY list
-!
-! 1957 2016-07-07 10:43:48Z suehring
-! flight module added
-!
-! 1849 2016-04-08 11:33:18Z hoffmann
-! Adapted for modularization of microphysics
-!
-! 1833 2016-04-07 14:23:03Z raasch
-! spectra_mod added
-!
-! 1831 2016-04-07 13:15:51Z hoffmann
-! turbulence renamed collision_turbulence, drizzle renamed
-! cloud_water_sedimentation
-!
-! 1808 2016-04-05 19:44:00Z raasch
-! test output removed
-!
-! 1783 2016-03-06 18:36:17Z raasch
-! netcdf module name changed + related changes
-!
-! 1699 2015-10-29 08:02:35Z maronga
-! Bugfix: update of binary version from 3.9b to 4.0 was missing
-!
-! 1691 2015-10-26 16:17:44Z maronga
-! Added output of most_method, constant_flux_layer, zeta_min, zeta_max. Removed
-! output of prandtl_layer and rif_min, rif_max.
-!
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable
-!
-! 1615 2015-07-08 18:49:19Z suehring
-! Enable turbulent inflow for passive_scalar and humidity
-!
-! 1585 2015-04-30 07:05:52Z maronga
-! Adapted for RRTMG
-!
-! 1560 2015-03-06 10:48:54Z keck
-! +recycling_yshift
-!
-! 1522 2015-01-14 10:53:12Z keck
-! added query for checking if the advection scheme in the restart run is the
-! same as the advection scheme in the corresponding initial run
-!
-! 1502 2014-12-03 18:22:31Z kanani
-! Canopy module and parameters removed (parameters are always read from
-! canopy_par NAMELIST for initial and restart runs)
-!
-! 1496 2014-12-02 17:25:50Z maronga
-! Renamed "radiation" -> "cloud_top_radiation"
-!
-! 1484 2014-10-21 10:53:05Z kanani
-! Changes in the course of the canopy-model modularization:
-!   parameters alpha_lad, beta_lad, lai_beta added,
-!   module plant_canopy_model_mod added,
-!   drag_coefficient, leaf_surface_concentration and scalar_exchange_coefficient
-!   renamed to canopy_drag_coeff, leaf_surface_conc and leaf_scalar_exch_coeff
-!
-! 1322 2014-03-20 16:38:49Z raasch
-! REAL functions provided with KIND-attribute
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! ONLY-attribute added to USE-statements,
-! kind-parameters added to all INTEGER and REAL declaration statements,
-! kinds are defined in new module kinds,
-! old module precision_kind is removed,
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements
-!
-! 1308 2014-03-13 14:58:42Z fricke
-! +do2d_xy_time_count, do2d_xz_time_count, do2d_yz_time_count,
-! +do3d_time_count
-!
-! 1253 2013-11-07 10:48:12Z fricke
-! Bugfix: add ref_state to read_parts_of_var_list, otherwise ref_state
-! is zero for initializing_actions = 'cyclic_fill'
-!
-! 1241 2013-10-30 11:36:58Z heinze
-! +nudging
-! +large_scale_forcing
-!
-! 1195 2013-07-01 12:27:57Z heinze
-! Bugfix: allocate ref_state
-!
-! 1179 2013-06-14 05:57:58Z raasch
-! +ref_state
-!
-! 1115 2013-03-26 18:16:16Z hoffmann
-! unused variables removed
-!
-! 1092 2013-02-02 11:24:22Z raasch
-! unused variables removed
-!
-! 1065 2012-11-22 17:42:36Z hoffmann
-! +nc, c_sedimentation, limiter_sedimentation, turbulence
-! -mu_constant, mu_constant_value
-!
-! 1053 2012-11-13 17:11:03Z hoffmann
-! necessary expansions according to the two new prognostic equations (nr, qr)
-! of the two-moment cloud physics scheme:
-! +bc_*_b, +bc_*_t, +bc_*_t_val, *_init, *_surface, *_surface_initial_change,
-! +*_vertical_gradient, +*_vertical_gradient_level, *_vertical_gradient_level_ind,
-! +surface_waterflux_*
-!
-! in addition, steering parameters parameters of the two-moment cloud physics
-! scheme:
-! +cloud_scheme, +drizzle, +mu_constant, +mu_constant_value, +ventilation_effect
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 1015 2012-09-27 09:23:24Z raasch
-! -adjust_mixing_length
-!
-! 1003 2012-09-14 14:35:53Z raasch
-! -grid_matching
-!
-! 1001 2012-09-13 14:08:46Z raasch
-! -cut_spline_overshoot, dt_fixed, last_dt_change, long_filter_factor,
-! overshoot_limit_*, ups_limit_*
-!
-! 978 2012-08-09 08:28:32Z fricke
-! -km_damp_max, outflow_damping_width
-! +pt_damping_factor, pt_damping_width
-! +z0h_factor
-!
-! 940 2012-07-09 14:31:00Z raasch
-! +neutral
-!
-! 927 2012-06-06 19:15:04Z raasch
-! +masking_method
-!
-! 849 2012-03-15 10:35:09Z raasch
-! first_call_advec_particles renamed first_call_lpm
-!
-! 824 2012-02-17 09:09:57Z raasch
-! +curvature_solution_effects
-!
-! Revision 1.1  1998/03/18 20:18:48  raasch
-! Initial revision
-!
-!
-! Description:
-! ------------
-!> Reading values of global control variables from restart-file (binary format)
-!------------------------------------------------------------------------------!
- SUBROUTINE read_var_list
-
-
-    USE arrays_3d,                                                             &
-        ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,           &
-               q_init, ref_state, s_init, sa_init, u_init, ug, v_init, vg
-
-    USE control_parameters
-
-    USE grid_variables,                                                        &
-        ONLY:  dx, dy
-
-    USE indices,                                                               &
-        ONLY:  nz, nx, nx_on_file, ny, ny_on_file
-
-    USE microphysics_mod,                                                      &
-        ONLY:  c_sedimentation, collision_turbulence,                          &
-               cloud_water_sedimentation, limiter_sedimentation,               &
-               nc_const, ventilation_effect
-
-    USE model_1d_mod,                                                          &
-        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
-
-    USE netcdf_interface,                                                      &
-        ONLY:  netcdf_precision, output_for_t0
-
-    USE particle_attributes,                                                   &
-        ONLY:  curvature_solution_effects
-
-    USE pegrid
-
-    USE radiation_model_mod,                                                   &
-        ONLY:  time_radiation
-
-    USE spectra_mod,                                                           &
-        ONLY:  average_count_sp
-
-    USE statistics,                                                            &
-        ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,     &
-               v_max, v_max_ijk, w_max, w_max_ijk
-
-    USE vertical_nesting_mod,                                                  &
-        ONLY:  vnest_init
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=10) ::  binary_version, version_on_file
-    CHARACTER (LEN=30) ::  variable_chr
-
-
-    CALL check_open( 13 )
-
-!
-!-- Make version number check first
-    READ ( 13 )  version_on_file
-    binary_version = '4.6'
-    IF ( TRIM( version_on_file ) /= TRIM( binary_version ) )  THEN
-       WRITE( message_string, * ) 'version mismatch concerning control ', &
-                                  'variables',                            &
-                                  '&version on file    = "',              &
-                                  TRIM( version_on_file ), '"',           &
-                                  '&version on program = "',              &
-                                  TRIM( binary_version ), '"'
-       CALL message( 'read_var_list', 'PA0296', 1, 2, 0, 6, 0 )
-    ENDIF
-
-!
-!-- Read number of PEs and horizontal index bounds of all PEs used in previous
-!-- run
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'numprocs' )  THEN
-       WRITE( message_string, * ) 'numprocs not found in data from prior ', &
-                                  'run on PE ', myid
-       CALL message( 'read_var_list', 'PA0297', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  numprocs_previous_run
-
-    IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
-       ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
-    ENDIF
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'hor_index_bounds' )  THEN
-       WRITE( message_string, * ) 'hor_index_bounds not found in data from ', &
-                                  'prior run on PE ', myid
-       CALL message( 'read_var_list', 'PA0298', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  hor_index_bounds_previous_run
-
-!
-!-- Read vertical number of gridpoints and number of different areas used
-!-- for computing statistics. Allocate arrays depending on these values,
-!-- which are needed for the following read instructions.
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'nz' )  THEN
-       WRITE( message_string, * ) 'nz not found in data from prior run on PE ',&
-                                  myid
-       CALL message( 'read_var_list', 'PA0299', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  nz
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'max_pr_user' )  THEN
-       WRITE( message_string, * ) 'max_pr_user not found in data from ', &
-                    'prior run on PE ', myid
-       CALL message( 'read_var_list', 'PA0300', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  max_pr_user    ! This value is checked against the number of
-                                ! user profiles given for the current run
-                                ! in routine user_parin (it has to match)
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'statistic_regions' )  THEN
-       WRITE( message_string, * ) 'statistic_regions not found in data from ', &
-                    'prior run on PE ', myid
-       CALL message( 'read_var_list', 'PA0301', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  statistic_regions
-    IF ( .NOT. ALLOCATED( ug ) )  THEN
-       ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1),                       &
-                 v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),              &
-                 ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),           &
-                 hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),        &
-                 hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
-    ENDIF
-
-!
-!-- Now read all control parameters:
-!-- Caution: When the following read instructions have been changed, the
-!-- -------  version number stored in the variable binary_version has to be
-!--          increased. The same changes must also be done in write_var_list.
-    READ ( 13 )  variable_chr
-    DO  WHILE ( TRIM( variable_chr ) /= '*** end ***' )
-
-       SELECT CASE ( TRIM( variable_chr ) )
-
-          CASE ( 'advected_distance_x' )
-             READ ( 13 )  advected_distance_x
-          CASE ( 'advected_distance_y' )
-             READ ( 13 )  advected_distance_y
-          CASE ( 'alpha_surface' )
-             READ ( 13 )  alpha_surface
-          CASE ( 'average_count_pr' )
-             READ ( 13 )  average_count_pr
-          CASE ( 'average_count_sp' )
-             READ ( 13 )  average_count_sp
-          CASE ( 'average_count_3d' )
-             READ ( 13 )  average_count_3d
-          CASE ( 'bc_e_b' )
-             READ ( 13 )  bc_e_b
-          CASE ( 'bc_lr' )
-             READ ( 13 )  bc_lr
-          CASE ( 'bc_ns' )
-             READ ( 13 )  bc_ns
-          CASE ( 'bc_p_b' )
-             READ ( 13 )  bc_p_b
-          CASE ( 'bc_p_t' )
-             READ ( 13 )  bc_p_t
-          CASE ( 'bc_pt_b' )
-             READ ( 13 )  bc_pt_b
-          CASE ( 'bc_pt_t' )
-             READ ( 13 )  bc_pt_t
-          CASE ( 'bc_pt_t_val' )
-             READ ( 13 )  bc_pt_t_val
-          CASE ( 'bc_q_b' )
-             READ ( 13 )  bc_q_b
-          CASE ( 'bc_q_t' )
-             READ ( 13 )  bc_q_t
-          CASE ( 'bc_q_t_val' )
-             READ ( 13 )  bc_q_t_val
-          CASE ( 'bc_s_b' )
-             READ ( 13 )  bc_s_b
-          CASE ( 'bc_s_t' )
-             READ ( 13 )  bc_s_t
-          CASE ( 'bc_sa_t' )
-             READ ( 13 )  bc_sa_t
-          CASE ( 'bc_uv_b' )
-             READ ( 13 )  bc_uv_b
-          CASE ( 'bc_uv_t' )
-             READ ( 13 )  bc_uv_t
-          CASE ( 'bottom_salinityflux' )
-             READ ( 13 )  bottom_salinityflux
-          CASE ( 'building_height' )
-             READ ( 13 )  building_height
-          CASE ( 'building_length_x' )
-             READ ( 13 )  building_length_x
-          CASE ( 'building_length_y' )
-             READ ( 13 )  building_length_y
-          CASE ( 'building_wall_left' )
-             READ ( 13 )  building_wall_left
-          CASE ( 'building_wall_south' )
-             READ ( 13 )  building_wall_south
-          CASE ( 'call_psolver_at_all_substeps' )
-             READ ( 13 )  call_psolver_at_all_substeps
-          CASE ( 'canyon_height' )
-             READ ( 13 )  canyon_height
-          CASE ( 'canyon_width_x' )
-             READ ( 13 )  canyon_width_x
-          CASE ( 'canyon_width_y' )
-             READ ( 13 )  canyon_width_y
-          CASE ( 'canyon_wall_left' )
-             READ ( 13 )  canyon_wall_left
-          CASE ( 'canyon_wall_south' )
-             READ ( 13 )  canyon_wall_south
-          CASE ( 'c_sedimentation' )
-             READ ( 13 )  c_sedimentation
-          CASE ( 'cfl_factor' )
-             READ ( 13 )  cfl_factor
-          CASE ( 'cloud_droplets' )
-             READ ( 13 )  cloud_droplets
-          CASE ( 'cloud_physics' )
-             READ ( 13 )  cloud_physics
-          CASE ( 'cloud_scheme' )
-             READ ( 13 )  cloud_scheme
-          CASE ( 'collective_wait' )
-             READ ( 13 )  collective_wait
-          CASE ( 'conserve_volume_flow' )
-             READ ( 13 )  conserve_volume_flow
-          CASE ( 'conserve_volume_flow_mode' )
-             READ ( 13 )  conserve_volume_flow_mode
-          CASE ( 'constant_flux_layer' )
-             READ ( 13 )  constant_flux_layer
-          CASE ( 'coupling_start_time' )
-             READ ( 13 )  coupling_start_time
-          CASE ( 'current_timestep_number' )
-             READ ( 13 )  current_timestep_number
-          CASE ( 'curvature_solution_effects' )
-             READ ( 13 )  curvature_solution_effects
-          CASE ( 'cycle_mg' )
-             READ ( 13 )  cycle_mg
-          CASE ( 'damp_level_1d' )
-             READ ( 13 )  damp_level_1d
-          CASE ( 'dissipation_1d' )
-             READ ( 13 )  dissipation_1d
-          CASE ( 'do2d_xy_time_count' )
-             READ ( 13 )  do2d_xy_time_count
-          CASE ( 'do2d_xz_time_count' )
-             READ ( 13 )  do2d_xz_time_count
-          CASE ( 'do2d_yz_time_count' )
-             READ ( 13 )  do2d_yz_time_count
-          CASE ( 'do3d_time_count' )
-             READ ( 13 )  do3d_time_count
-          CASE ( 'dp_external' )
-             READ ( 13 )  dp_external
-          CASE ( 'dp_level_b' )
-             READ ( 13 )  dp_level_b
-          CASE ( 'dp_smooth' )
-             READ ( 13 )  dp_smooth
-          CASE ( 'dpdxy' )
-             READ ( 13 )  dpdxy
-          CASE ( 'cloud_water_sedimentation' )
-             READ ( 13 )  cloud_water_sedimentation
-          CASE ( 'dt_pr_1d' )
-             READ ( 13 )  dt_pr_1d
-          CASE ( 'dt_run_control_1d' )
-             READ ( 13 )  dt_run_control_1d
-          CASE ( 'dt_3d' )
-             READ ( 13 )  dt_3d
-          CASE ( 'dvrp_filecount' )
-             READ ( 13 )  dvrp_filecount
-          CASE ( 'dx' )
-             READ ( 13 )  dx
-          CASE ( 'dy' )
-             READ ( 13 )  dy
-          CASE ( 'dz' )
-             READ ( 13 )  dz
-          CASE ( 'dz_max' )
-             READ ( 13 )  dz_max
-          CASE ( 'dz_stretch_factor' )
-             READ ( 13 )  dz_stretch_factor
-          CASE ( 'dz_stretch_level' )
-             READ ( 13 )  dz_stretch_level
-          CASE ( 'e_min' )
-             READ ( 13 )  e_min
-          CASE ( 'end_time_1d' )
-             READ ( 13 )  end_time_1d
-          CASE ( 'fft_method' )
-             READ ( 13 )  fft_method
-          CASE ( 'first_call_lpm' )
-             READ ( 13 )  first_call_lpm
-          CASE ( 'galilei_transformation' )
-             READ ( 13 )  galilei_transformation
-          CASE ( 'hom' )
-             READ ( 13 )  hom
-          CASE ( 'hom_sum' )
-             READ ( 13 )  hom_sum
-          CASE ( 'humidity' )
-             READ ( 13 )  humidity
-          CASE ( 'inflow_damping_factor' )
-             IF ( .NOT. ALLOCATED( inflow_damping_factor ) )  THEN
-                ALLOCATE( inflow_damping_factor(0:nz+1) )
-             ENDIF
-             READ ( 13 )  inflow_damping_factor
-          CASE ( 'inflow_damping_height' )
-             READ ( 13 )  inflow_damping_height
-          CASE ( 'inflow_damping_width' )
-             READ ( 13 )  inflow_damping_width
-          CASE ( 'inflow_disturbance_begin' )
-             READ ( 13 )  inflow_disturbance_begin
-          CASE ( 'inflow_disturbance_end' )
-             READ ( 13 )  inflow_disturbance_end
-          CASE ( 'km_constant' )
-             READ ( 13 )  km_constant
-          CASE ( 'large_scale_forcing' )
-             READ ( 13 )  large_scale_forcing
-          CASE ( 'large_scale_subsidence' )
-             READ ( 13 )  large_scale_subsidence
-          CASE ( 'limiter_sedimentation' )
-             READ ( 13 )  limiter_sedimentation
-          CASE ( 'loop_optimization' )
-             READ ( 13 )  loop_optimization
-          CASE ( 'masking_method' )
-             READ ( 13 )  masking_method
-          CASE ( 'mean_inflow_profiles' )
-             IF ( .NOT. ALLOCATED( mean_inflow_profiles ) )  THEN
-                ALLOCATE( mean_inflow_profiles(0:nz+1,7) )
-             ENDIF
-             READ ( 13 )  mean_inflow_profiles
-          CASE ( 'mg_cycles' )
-             READ ( 13 )  mg_cycles
-          CASE ( 'mg_switch_to_pe0_level' )
-             READ ( 13 )  mg_switch_to_pe0_level
-          CASE ( 'mixing_length_1d' )
-             READ ( 13 )  mixing_length_1d
-          CASE ( 'momentum_advec' )
-             READ ( 13 )  momentum_advec
-          CASE ( 'most_method' )
-             READ ( 13 )  most_method
-          CASE ( 'nc_const' )
-             READ ( 13 )  nc_const
-          CASE ( 'netcdf_precision' )
-             READ ( 13 )  netcdf_precision
-          CASE ( 'neutral' )
-             READ ( 13 )  neutral
-          CASE ( 'ngsrb' )
-             READ ( 13 )  ngsrb
-          CASE ( 'nsor' )
-             READ ( 13 )  nsor
-          CASE ( 'nsor_ini' )
-             READ ( 13 )  nsor_ini
-          CASE ( 'nudging' )
-             READ ( 13 )  nudging
-          CASE ( 'num_leg' )
-             READ ( 13 )  num_leg
-          CASE ( 'nx' )
-             READ ( 13 )  nx
-             nx_on_file = nx
-          CASE ( 'ny' )
-             READ ( 13 )  ny
-             ny_on_file = ny
-          CASE ( 'ocean' )
-             READ ( 13 )  ocean
-          CASE ( 'old_dt' )
-             READ ( 13 )  old_dt
-          CASE ( 'omega' )
-             READ ( 13 )  omega
-          CASE ( 'omega_sor' )
-             READ ( 13 )  omega_sor
-          CASE ( 'output_for_t0' )
-             READ (13)    output_for_t0
-          CASE ( 'passive_scalar' )
-             READ ( 13 )  passive_scalar
-          CASE ( 'latitude' )
-             READ ( 13 )  latitude
-          CASE ( 'longitude' )
-             READ ( 13 )  longitude
-          CASE ( 'prandtl_number' )
-             READ ( 13 )  prandtl_number
-          CASE ( 'precipitation' )
-             READ ( 13 ) precipitation
-          CASE ( 'psolver' )
-             READ ( 13 )  psolver
-          CASE ( 'pt_damping_factor' )
-             READ ( 13 )  pt_damping_factor
-          CASE ( 'pt_damping_width' )
-             READ ( 13 )  pt_damping_width
-          CASE ( 'pt_init' )
-             READ ( 13 )  pt_init
-          CASE ( 'pt_reference' )
-             READ ( 13 )  pt_reference
-          CASE ( 'pt_surface' )
-             READ ( 13 )  pt_surface
-          CASE ( 'pt_surface_initial_change' )
-             READ ( 13 )  pt_surface_initial_change
-          CASE ( 'pt_vertical_gradient' )
-             READ ( 13 )  pt_vertical_gradient
-          CASE ( 'pt_vertical_gradient_level' )
-             READ ( 13 )  pt_vertical_gradient_level
-          CASE ( 'pt_vertical_gradient_level_ind' )
-             READ ( 13 )  pt_vertical_gradient_level_ind
-          CASE ( 'q_init' )
-             READ ( 13 )  q_init
-          CASE ( 'q_surface' )
-             READ ( 13 )  q_surface
-          CASE ( 'q_surface_initial_change' )
-             READ ( 13 )  q_surface_initial_change
-          CASE ( 'q_vertical_gradient' )
-             READ ( 13 )  q_vertical_gradient
-          CASE ( 'q_vertical_gradient_level' )
-             READ ( 13 )  q_vertical_gradient_level
-          CASE ( 'q_vertical_gradient_level_ind' )
-             READ ( 13 )  q_vertical_gradient_level_ind
-          CASE ( 'cloud_top_radiation' )
-             READ ( 13 )  cloud_top_radiation
-          CASE ( 'random_generator' )
-             READ ( 13 )  random_generator
-          CASE ( 'random_heatflux' )
-             READ ( 13 )  random_heatflux
-          CASE ( 'rans_mode' )
-             READ ( 13 )  rans_mode
-          CASE ( 'rayleigh_damping_factor' )
-             READ ( 13 )  rayleigh_damping_factor
-          CASE ( 'rayleigh_damping_height' )
-             READ ( 13 )  rayleigh_damping_height
-          CASE ( 'recycling_width' )
-             READ ( 13 )  recycling_width
-          CASE ( 'recycling_yshift' )
-             READ ( 13 ) recycling_yshift
-          CASE ( 'reference_state' )
-             READ ( 13 )  reference_state
-          CASE ( 'ref_state' )
-             READ ( 13 )  ref_state
-          CASE ( 'residual_limit' )
-             READ ( 13 )  residual_limit
-          CASE ( 'roughness_length' )
-             READ ( 13 )  roughness_length
-          CASE ( 'runnr' )
-             READ ( 13 )  runnr
-          CASE ( 'run_coupled' )
-             READ ( 13 )  run_coupled
-          CASE ( 's_init' )
-             READ ( 13 )  s_init
-          CASE ( 's_surface' )
-             READ ( 13 )  s_surface
-          CASE ( 's_surface_initial_change' )
-             READ ( 13 )  s_surface_initial_change
-          CASE ( 's_vertical_gradient' )
-             READ ( 13 )  s_vertical_gradient
-          CASE ( 's_vertical_gradient_level' )
-             READ ( 13 )  s_vertical_gradient_level
-          CASE ( 's_vertical_gradient_level_ind' )
-             READ ( 13 )  s_vertical_gradient_level_ind
-          CASE ( 'sa_init' )
-             READ ( 13 )  sa_init
-          CASE ( 'sa_surface' )
-             READ ( 13 )  sa_surface
-          CASE ( 'sa_vertical_gradient' )
-             READ ( 13 )  sa_vertical_gradient
-          CASE ( 'sa_vertical_gradient_level' )
-             READ ( 13 )  sa_vertical_gradient_level
-          CASE ( 'scalar_advec' )
-             READ ( 13 )  scalar_advec
-          CASE ( 'simulated_time' )
-             READ ( 13 )  simulated_time
-          CASE ( 'spinup_time' ) 
-             READ ( 13 )  spinup_time
-          CASE ( 'surface_heatflux' )
-             READ ( 13 )  surface_heatflux
-          CASE ( 'surface_pressure' )
-             READ ( 13 )  surface_pressure
-          CASE ( 'surface_scalarflux' )
-             READ ( 13 )  surface_scalarflux
-          CASE ( 'surface_waterflux' )
-             READ ( 13 )  surface_waterflux
-          CASE ( 'time_coupling' )
-             READ ( 13 )  time_coupling
-          CASE ( 'time_disturb' )
-             READ ( 13 )  time_disturb
-          CASE ( 'time_dopr' )
-             READ ( 13 )  time_dopr
-          CASE ( 'time_domask' )
-             READ ( 13 )  time_domask
-          CASE ( 'time_dopr_av' )
-             READ ( 13 )  time_dopr_av
-          CASE ( 'time_dopr_listing' )
-             READ ( 13 )  time_dopr_listing
-          CASE ( 'time_dopts' )
-             READ ( 13 )  time_dopts
-          CASE ( 'time_dosp' )
-             READ ( 13 )  time_dosp
-          CASE ( 'time_dots' )
-             READ ( 13 )  time_dots
-          CASE ( 'time_do2d_xy' )
-             READ ( 13 )  time_do2d_xy
-          CASE ( 'time_do2d_xz' )
-             READ ( 13 )  time_do2d_xz
-          CASE ( 'time_do2d_yz' )
-             READ ( 13 )  time_do2d_yz
-          CASE ( 'time_do3d' )
-             READ ( 13 )  time_do3d
-          CASE ( 'time_do_av' )
-             READ ( 13 )  time_do_av
-          CASE ( 'time_do_sla' )
-             READ ( 13 )  time_do_sla
-          CASE ( 'time_dvrp' )
-             READ ( 13 )  time_dvrp
-          CASE ( 'time_radiation' )
-             READ ( 13 )  time_radiation
-          CASE ( 'time_restart' )
-             READ ( 13 )  time_restart
-          CASE ( 'time_run_control' )
-             READ ( 13 )  time_run_control
-          CASE ( 'time_since_reference_point' )
-             READ ( 13 )  time_since_reference_point
-          CASE ( 'timestep_scheme' )
-             READ ( 13 )  timestep_scheme
-          CASE ( 'topography' )
-             READ ( 13 )  topography
-          CASE ( 'topography_grid_convention' )
-             READ ( 13 )  topography_grid_convention
-          CASE ( 'top_heatflux' )
-             READ ( 13 )  top_heatflux
-          CASE ( 'top_momentumflux_u' )
-             READ ( 13 )  top_momentumflux_u
-          CASE ( 'top_momentumflux_v' )
-             READ ( 13 )  top_momentumflux_v
-          CASE ( 'top_salinityflux' )
-             READ ( 13 )  top_salinityflux
-          CASE ( 'top_scalarflux' )
-             READ ( 13 )  top_scalarflux
-          CASE ( 'tsc' )
-             READ ( 13 )  tsc
-          CASE ( 'collision_turbulence' )
-             READ ( 13 )  collision_turbulence
-          CASE ( 'tunnel_height' )
-             READ ( 13 )  tunnel_height
-          CASE ( 'tunnel_length' )
-             READ ( 13 )  tunnel_length
-          CASE ( 'tunnel_width_x' )
-             READ ( 13 )  tunnel_width_x
-          CASE ( 'tunnel_width_y' )
-             READ ( 13 )  tunnel_width_y
-          CASE ( 'tunnel_wall_depth' )
-             READ ( 13 )  tunnel_wall_depth
-          CASE ( 'turbulence_closure' )
-             READ ( 13 )  turbulence_closure
-          CASE ( 'turbulent_inflow' )
-             READ ( 13 )  turbulent_inflow
-          CASE ( 'u_bulk' )
-             READ ( 13 )  u_bulk
-          CASE ( 'u_init' )
-             READ ( 13 )  u_init
-          CASE ( 'u_max' )
-             READ ( 13 )  u_max
-          CASE ( 'u_max_ijk' )
-             READ ( 13 )  u_max_ijk
-          CASE ( 'ug' )
-             READ ( 13 )  ug
-          CASE ( 'ug_surface' )
-             READ ( 13 )  ug_surface
-          CASE ( 'ug_vertical_gradient' )
-             READ ( 13 )  ug_vertical_gradient
-          CASE ( 'ug_vertical_gradient_level' )
-             READ ( 13 )  ug_vertical_gradient_level
-          CASE ( 'ug_vertical_gradient_level_ind' )
-             READ ( 13 )  ug_vertical_gradient_level_ind
-          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
-          CASE ( 'use_upstream_for_tke' )
-             READ ( 13 )  use_upstream_for_tke
-          CASE ( 'v_bulk' )
-             READ ( 13 )  v_bulk
-          CASE ( 'v_init' )
-             READ ( 13 )  v_init
-          CASE ( 'v_max' )
-             READ ( 13 )  v_max
-          CASE ( 'v_max_ijk' )
-             READ ( 13 )  v_max_ijk
-          CASE ( 'ventilation_effect' )
-             READ ( 13 )  ventilation_effect
-          CASE ( 'vg' )
-             READ ( 13 )  vg
-          CASE ( 'vg_surface' )
-             READ ( 13 )  vg_surface
-          CASE ( 'vg_vertical_gradient' )
-             READ ( 13 )  vg_vertical_gradient
-          CASE ( 'vg_vertical_gradient_level' )
-             READ ( 13 )  vg_vertical_gradient_level
-          CASE ( 'vg_vertical_gradient_level_ind' )
-             READ ( 13 )  vg_vertical_gradient_level_ind
-          CASE ( 'virtual_flight' )
-             READ ( 13 )  virtual_flight
-          CASE ( 'vnest_init' )
-             READ ( 13 )  vnest_init
-          CASE ( 'volume_flow_area' )
-             READ ( 13 )  volume_flow_area
-          CASE ( 'volume_flow_initial' )
-             READ ( 13 )  volume_flow_initial
-          CASE ( 'wall_adjustment' )
-             READ ( 13 )  wall_adjustment
-          CASE ( 'subs_vertical_gradient' )
-             READ ( 13 )  subs_vertical_gradient
-          CASE ( 'subs_vertical_gradient_level' )
-             READ ( 13 )  subs_vertical_gradient_level
-          CASE ( 'subs_vertical_gradient_level_i' )
-             READ ( 13 )  subs_vertical_gradient_level_i
-          CASE ( 'wall_heatflux' )
-             READ ( 13 )  wall_heatflux
-          CASE ( 'wall_humidityflux' )
-             READ ( 13 )  wall_humidityflux
-          CASE ( 'wall_scalarflux' )
-             READ ( 13 )  wall_scalarflux
-          CASE ( 'wall_salinityflux' )
-             READ ( 13 )  wall_salinityflux
-          CASE ( 'w_max' )
-             READ ( 13 )  w_max
-          CASE ( 'w_max_ijk' )
-             READ ( 13 )  w_max_ijk
-          CASE ( 'y_shift' )
-             READ ( 13 )  y_shift
-          CASE ( 'zeta_max' )
-             READ ( 13 )  zeta_max
-          CASE ( 'zeta_min' )
-             READ ( 13 )  zeta_min
-          CASE ( 'z0h_factor' )
-             READ ( 13 )  z0h_factor
-
-          CASE DEFAULT
-             WRITE( message_string, * ) 'unknown variable named "',         &
-                                        TRIM( variable_chr ), '" found in', &
-                                        ' data from prior run on PE ', myid
-             CALL message( 'read_var_list', 'PA0302', 1, 2, 0, 6, 0 )
-        END SELECT
-!
-!--    Read next string
-       READ ( 13 )  variable_chr
-
-    ENDDO
-
-
- END SUBROUTINE read_var_list
-
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Skipping the global control variables from restart-file (binary format)
-!> except some information needed when reading restart data from a previous
-!> run which used a smaller total domain or/and a different domain decomposition.
-!------------------------------------------------------------------------------!
-
- SUBROUTINE read_parts_of_var_list
-
-
-    USE arrays_3d,                                                             &
-        ONLY:  inflow_damping_factor, mean_inflow_profiles, ref_state, ug, vg
-
-    USE control_parameters
-
-    USE indices,                                                               &
-        ONLY:  nz, nx, nx_on_file, ny, ny_on_file
-
-    USE kinds
-
-    USE pegrid
-
-    USE statistics,                                                            &
-        ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,     &
-               v_max, v_max_ijk, w_max, w_max_ijk
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=10) ::  version_on_file
-    CHARACTER (LEN=20) ::  momentum_advec_check
-    CHARACTER (LEN=20) ::  scalar_advec_check
-    CHARACTER (LEN=30) ::  variable_chr
-    CHARACTER (LEN=1)  ::  cdum
-
-    INTEGER(iwp) ::  max_pr_user_on_file
-    INTEGER(iwp) ::  nz_on_file
-    INTEGER(iwp) ::  statistic_regions_on_file
-    INTEGER(iwp) ::  tmp_mpru
-    INTEGER(iwp) ::  tmp_sr
-
-    REAL(wp), DIMENSION(:,:,:),   ALLOCATABLE ::  hom_sum_on_file
-    REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  hom_on_file
-
-
-    CALL check_open( 13 )
-
-    READ ( 13 )  version_on_file
-
-
-!
-!-- Read number of PEs and horizontal index bounds of all PEs used in previous
-!-- run
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'numprocs' )  THEN
-       WRITE( message_string, * ) 'numprocs not found in data from prior ', &
-                                  'run on PE ', myid
-       CALL message( 'read_parts_of_var_list', 'PA0297', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  numprocs_previous_run
-
-    IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
-       ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
-    ENDIF
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'hor_index_bounds' )  THEN
-       WRITE( message_string, * ) 'hor_index_bounds not found in data from ', &
-                                  'prior run on PE ', myid
-       CALL message( 'read_parts_of_var_list', 'PA0298', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  hor_index_bounds_previous_run
-
-!
-!-- Read vertical number of gridpoints and number of different areas used
-!-- for computing statistics. Allocate arrays depending on these values,
-!-- which are needed for the following read instructions.
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'nz' )  THEN
-       message_string = 'nz not found in restart data file'
-       CALL message( 'read_parts_of_var_list', 'PA0303', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  nz_on_file
-    IF ( nz_on_file /= nz )  THEN
-       WRITE( message_string, * ) 'mismatch concerning number of ',      &
-                                  'gridpoints along z',                  &
-                                  '&nz on file    = "', nz_on_file, '"', &
-                                  '&nz from run   = "', nz, '"'
-       CALL message( 'read_parts_of_var_list', 'PA0304', 1, 2, 0, 6, 0 )
-    ENDIF
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'max_pr_user' )  THEN
-       message_string = 'max_pr_user not found in restart data file'
-       CALL message( 'read_parts_of_var_list', 'PA0305', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  max_pr_user_on_file
-    IF ( max_pr_user_on_file /= max_pr_user )  THEN
-       WRITE( message_string, * ) 'number of user profiles on res',           &
-                                  'tart data file differs from the current ', &
-                                  'run&max_pr_user on file    = "',           &
-                                  max_pr_user_on_file, '"',                   &
-                                  '&max_pr_user from run   = "',              &
-                                  max_pr_user, '"'
-       CALL message( 'read_parts_of_var_list', 'PA0306', 0, 0, 0, 6, 0 )
-       tmp_mpru = MIN( max_pr_user_on_file, max_pr_user )
-    ELSE
-       tmp_mpru = max_pr_user
-    ENDIF
-
-    READ ( 13 )  variable_chr
-    IF ( TRIM( variable_chr ) /= 'statistic_regions' )  THEN
-       message_string = 'statistic_regions not found in restart data file'
-       CALL message( 'read_parts_of_var_list', 'PA0307', 1, 2, 0, 6, 0 )
-    ENDIF
-    READ ( 13 )  statistic_regions_on_file
-    IF ( statistic_regions_on_file /= statistic_regions )  THEN
-       WRITE( message_string, * ) 'statistic regions on restart data file ',&
-                                  'differ from the current run',            &
-                                  '&statistic regions on file    = "',      &
-                                  statistic_regions_on_file, '"',           &
-                                  '&statistic regions from run   = "',      &
-                                   statistic_regions, '"',                  &
-                                  '&statistic data may be lost!'
-       CALL message( 'read_parts_of_var_list', 'PA0308', 0, 1, 0, 6, 0 )
-       tmp_sr = MIN( statistic_regions_on_file, statistic_regions )
-    ELSE
-       tmp_sr = statistic_regions
-    ENDIF
-
-!
-!-- Now read and check some control parameters and skip the rest
-    READ ( 13 )  variable_chr
-
-    DO  WHILE ( TRIM( variable_chr ) /= '*** end ***' )
-
-       SELECT CASE ( TRIM( variable_chr ) )
-
-          CASE ( 'average_count_pr' )
-             READ ( 13 )  average_count_pr
-             IF ( average_count_pr /= 0 )  THEN
-                WRITE( message_string, * ) 'inflow profiles not temporally ',  &
-                               'averaged. &Averaging will be done now using ', &
-                               average_count_pr, ' samples.'
-                CALL message( 'read_parts_of_var_list', 'PA0309', &
-                                                                 0, 1, 0, 6, 0 )
-             ENDIF
-
-          CASE ( 'hom' )
-             ALLOCATE( hom_on_file(0:nz+1,2,pr_palm+max_pr_user_on_file, &
-                       0:statistic_regions_on_file) )
-             READ ( 13 )  hom_on_file
-             hom(:,:,1:pr_palm+tmp_mpru,0:tmp_sr) = &
-                          hom_on_file(:,:,1:pr_palm+tmp_mpru,0:tmp_sr)
-             DEALLOCATE( hom_on_file )
-
-          CASE ( 'hom_sum' )
-             ALLOCATE( hom_sum_on_file(0:nz+1,pr_palm+max_pr_user_on_file, &
-                       0:statistic_regions_on_file) )
-             READ ( 13 )  hom_sum_on_file
-             hom_sum(:,1:pr_palm+tmp_mpru,0:tmp_sr) = &
-                          hom_sum_on_file(:,1:pr_palm+tmp_mpru,0:tmp_sr)
-             DEALLOCATE( hom_sum_on_file )
-
-          CASE ( 'momentum_advec' )
-             momentum_advec_check = momentum_advec
-             READ ( 13 )  momentum_advec
-             IF ( TRIM( momentum_advec_check ) /= TRIM( momentum_advec ) )  THEN
-                WRITE( message_string, * ) 'momentum_advec of the restart run ',&
-                               'differs from momentum_advec of the initial run.'
-                CALL message( 'read_parts_of_var_list', 'PA0100', &
-                                                                 1, 2, 0, 6, 0 )
-             END IF
-
-          CASE ( 'nx' )
-             READ ( 13 )  nx_on_file
-
-          CASE ( 'ny' )
-             READ ( 13 )  ny_on_file
-
-          CASE ( 'ref_state' )
-             READ ( 13 )  ref_state
-
-          CASE ( 'scalar_advec' )
-             scalar_advec_check = scalar_advec
-             READ ( 13 )  scalar_advec
-             IF ( TRIM( scalar_advec_check ) /= TRIM( scalar_advec ) )  THEN
-                WRITE( message_string, * ) 'scalar_advec of the restart run ', &
-                               'differs from scalar_advec of the initial run.'
-                CALL message( 'read_parts_of_var_list', 'PA0101', &
-                                                                 1, 2, 0, 6, 0 )
-             END IF
-
-          CASE DEFAULT
-
-             READ ( 13 )  cdum
-
-       END SELECT
-
-       READ ( 13 )  variable_chr
-
-    ENDDO
-
-!
-!-- Calculate the temporal average of vertical profiles, if neccessary
-    IF ( average_count_pr /= 0 )  THEN
-       hom_sum = hom_sum / REAL( average_count_pr, KIND=wp )
-    ENDIF
-
-
- END SUBROUTINE read_parts_of_var_list
-
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Skipping the global control variables from restart-file (binary format)
-!------------------------------------------------------------------------------!
-
- SUBROUTINE skip_var_list
-
-    USE control_parameters,                                                    &
-        ONLY: wind_turbine, wind_turbine_prerun, virtual_flight,               & 
-              virtual_flight_prerun, syn_turb_gen, syn_turb_gen_prerun
-
-    USE wind_turbine_model_mod,                                                &
-        ONLY: wtm_skip_var_list
-
-    USE flight_mod,                                                            &
-        ONLY: flight_skip_var_list
-
-    USE synthetic_turbulence_generator_mod,                                    &
-        ONLY: stg_skip_var_list
-
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=10) ::  version_on_file
-    CHARACTER (LEN=30) ::  variable_chr
-
-    CHARACTER (LEN=1) ::  cdum
-
-
-    READ ( 13 )  version_on_file
-
-    READ ( 13 )  variable_chr
-
-    DO  WHILE ( TRIM( variable_chr ) /= '*** end ***' )
-
-       READ ( 13 )  cdum
-       READ ( 13 )  variable_chr
-
-    ENDDO
-
-!
-!-- In case of virtual flights, skip also variables related to
-!-- this module.
-    IF ( wind_turbine_prerun )  CALL wtm_skip_var_list
-
-!
-!-- In case of virtual flights, skip also variables related to
-!-- this module.
-    IF ( virtual_flight_prerun)  CALL flight_skip_var_list
-
-!
-!-- In case of virtual flights, skip also variables related to
-!-- this module.
-    IF ( syn_turb_gen_prerun )  CALL stg_skip_var_list
-
-
- END SUBROUTINE skip_var_list
Index: palm/trunk/SOURCE/sum_up_3d_data.f90
===================================================================
--- palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2893)
+++ palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2894)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Changed comment
+! 
+! 2817 2018-02-19 16:32:21Z suehring
 ! Preliminary gust module interface implemented
 ! 
@@ -254,5 +257,5 @@
 !-- time or the first time after average_3d_data has been called 
 !-- (some or all of the arrays may have been already allocated
-!-- in read_3d_binary)
+!-- in rrd_local)
     IF ( average_count_3d == 0 )  THEN
 
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 2894)
@@ -26,4 +26,18 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod,
+! surface_read/write_restart_data was renamed to surface_r/wrd_local, variable 
+! named found has been introduced for checking if restart data was found, 
+! reading of restart strings has been moved completely to 
+! read_restart_data_mod, surface_rrd_local is already inside the overlap loop 
+! programmed in read_restart_data_mod, SAVE attribute added where necessary, 
+! deallocation and allocation of some arrays have been changed to take care of 
+! different restart files that can be opened (index i), the marker *** end 
+! surf *** is not necessary anymore, strings and their respective lengths are 
+! written out and read now in case of restart runs to get rid of prescribed 
+! character lengths (Giersch)
+! 
+! 2813 2018-02-16 16:28:14Z suehring
 ! Some more bugfixes concerning restart runs 
 ! 
@@ -432,11 +446,11 @@
     END INTERFACE init_surface_arrays
 
-    INTERFACE surface_read_restart_data
-       MODULE PROCEDURE surface_read_restart_data
-    END INTERFACE surface_read_restart_data
-
-    INTERFACE surface_write_restart_data
-       MODULE PROCEDURE surface_write_restart_data
-    END INTERFACE surface_write_restart_data
+    INTERFACE surface_rrd_local
+       MODULE PROCEDURE surface_rrd_local
+    END INTERFACE surface_rrd_local
+
+    INTERFACE surface_wrd_local
+       MODULE PROCEDURE surface_wrd_local
+    END INTERFACE surface_wrd_local
 
     INTERFACE surface_last_actions
@@ -457,6 +471,6 @@
     PUBLIC get_topography_top_index, get_topography_top_index_ji, init_bc,     &
            init_surfaces,                                                      &
-           init_surface_arrays, surface_read_restart_data,                     & 
-           surface_restore_elements, surface_write_restart_data,               &
+           init_surface_arrays, surface_rrd_local,                     & 
+           surface_restore_elements, surface_wrd_local,               &
            surface_last_actions
 
@@ -888,4 +902,112 @@
     END SUBROUTINE init_surface_arrays
 
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Deallocating memory for upward and downward-facing horizontal surface types, 
+!> except for top fluxes. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_h( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces  !< respective surface type
+
+
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface element
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+!
+!--    Surface-layer height
+       DEALLOCATE ( surfaces%z_mo )
+!
+!--    Surface orientation
+       DEALLOCATE ( surfaces%facing )
+!
+!--    Surface-parallel wind velocity
+       DEALLOCATE ( surfaces%uvw_abs )
+!
+!--    Roughness
+       DEALLOCATE ( surfaces%z0 )
+       DEALLOCATE ( surfaces%z0h )
+       DEALLOCATE ( surfaces%z0q )
+!
+!--    Friction velocity
+       DEALLOCATE ( surfaces%us )
+!
+!--    Stability parameter
+       DEALLOCATE ( surfaces%ol )
+!
+!--    Bulk Richardson number
+       DEALLOCATE ( surfaces%rib )
+!
+!--    Vertical momentum fluxes of u and v
+       DEALLOCATE ( surfaces%usws )  
+       DEALLOCATE ( surfaces%vsws )  
+!
+!--    Required in production_e
+       IF ( .NOT. constant_diffusion )  THEN    
+          DEALLOCATE ( surfaces%u_0 )  
+          DEALLOCATE ( surfaces%v_0 )
+       ENDIF 
+!
+!--    Characteristic temperature and surface flux of sensible heat
+       DEALLOCATE ( surfaces%ts )    
+       DEALLOCATE ( surfaces%shf )    
+!
+!--    surface temperature
+       DEALLOCATE ( surfaces%pt_surface ) 
+!
+!--    Characteristic humidity and surface flux of latent heat
+       IF ( humidity )  THEN
+          DEALLOCATE ( surfaces%qs ) 
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Characteristic scalar and surface flux of scalar
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ss )   
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF 
+!
+!--    Scaling parameter (cs*) and surface flux of chemical species
+       IF ( air_chemistry )  THEN
+          DEALLOCATE ( surfaces%css )   
+          DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--    Arrays for storing potential temperature and
+!--    specific humidity at first grid level
+       DEALLOCATE ( surfaces%pt1 )
+       DEALLOCATE ( surfaces%qv1 )
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_morrison)  THEN
+          DEALLOCATE ( surfaces%qcs )
+          DEALLOCATE ( surfaces%ncs )
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrs )
+          DEALLOCATE ( surfaces%nrs )
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity surface flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_h
+
+
 !------------------------------------------------------------------------------!
 ! Description:
@@ -916,5 +1038,5 @@
 !--    might exist for given (j,i).
 !--    If no surface of respective type exist at current (j,i), set indicies
-!--    such that loop in diffusion routines will not be entered. 
+!--    such that loop in diffusion routines will not be entered.
        ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
        ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
@@ -1015,4 +1137,69 @@
 ! Description:
 ! ------------
+!> Deallocating memory for model-top fluxes  
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_h_top( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces !< respective surface type
+
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface (model-top) element
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+
+       IF ( .NOT. constant_diffusion )  THEN    
+          DEALLOCATE ( surfaces%u_0 )  
+          DEALLOCATE ( surfaces%v_0 )
+       ENDIF 
+!
+!--    Vertical momentum fluxes of u and v
+       DEALLOCATE ( surfaces%usws )  
+       DEALLOCATE ( surfaces%vsws )  
+!
+!--    Sensible heat flux
+       DEALLOCATE ( surfaces%shf )    
+!
+!--    Latent heat flux
+       IF ( humidity .OR. coupling_mode == 'ocean_to_atmosphere')  THEN
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Scalar flux
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF 
+!
+!--    Chemical species flux
+       IF ( air_chemistry )  THEN
+          DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_morrison)  THEN
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_h_top
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> Allocating memory for model-top fluxes  
 !------------------------------------------------------------------------------!
@@ -1082,4 +1269,120 @@
 
     END SUBROUTINE allocate_surface_attributes_h_top
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Deallocating memory for vertical surface types. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_v( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces !< respective surface type
+
+!
+!--    Allocate arrays for start and end index of vertical surface type 
+!--    for each (j,i)-grid point. This is required in diffion_x, which is
+!--    called for each (j,i). In order to find the location where the 
+!--    respective flux is store within the surface-type, start- and end- 
+!--    index are stored for each (j,i). For example, each (j,i) can have
+!--    several entries where fluxes for vertical surfaces might be stored.  
+!--    In the flat case, where no vertical walls exit, set indicies such 
+!--    that loop in diffusion routines will not be entered. 
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface element.
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+!
+!--    Surface-layer height
+       DEALLOCATE ( surfaces%z_mo )
+!
+!--    Surface orientation
+       DEALLOCATE ( surfaces%facing )
+!
+!--    Surface parallel wind velocity
+       DEALLOCATE ( surfaces%uvw_abs )
+!
+!--    Roughness
+       DEALLOCATE ( surfaces%z0 )
+       DEALLOCATE ( surfaces%z0h )
+       DEALLOCATE ( surfaces%z0q )
+
+!
+!--    Friction velocity
+       DEALLOCATE ( surfaces%us )
+!
+!--    Allocate Obukhov length and bulk Richardson number. Actually, at
+!--    vertical surfaces these are only required for natural surfaces.  
+!--    for natural land surfaces
+       DEALLOCATE( surfaces%ol ) 
+       DEALLOCATE( surfaces%rib ) 
+!
+!--    Allocate arrays for surface momentum fluxes for u and v. For u at north- 
+!--    and south-facing surfaces, for v at east- and west-facing surfaces.
+       DEALLOCATE ( surfaces%mom_flux_uv )
+!
+!--    Allocate array for surface momentum flux for w - wsus and wsvs
+       DEALLOCATE ( surfaces%mom_flux_w ) 
+!
+!--    Allocate array for surface momentum flux for subgrid-scale tke wsus and 
+!--    wsvs; first index usvs or vsws, second index for wsus or wsvs, depending
+!--    on surface.
+       DEALLOCATE ( surfaces%mom_flux_tke )  
+!
+!--    Characteristic temperature and surface flux of sensible heat
+       DEALLOCATE ( surfaces%ts )    
+       DEALLOCATE ( surfaces%shf )
+!
+!--    surface temperature
+       DEALLOCATE ( surfaces%pt_surface ) 
+!
+!--    Characteristic humidity and surface flux of latent heat
+       IF ( humidity )  THEN
+          DEALLOCATE ( surfaces%qs ) 
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Characteristic scalar and surface flux of scalar
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ss )   
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF
+!
+!--    Scaling parameter (cs*) and surface flux of chemical species
+       IF ( air_chemistry )  THEN
+             DEALLOCATE ( surfaces%css )   
+             DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--    Arrays for storing potential temperature and
+!--    specific humidity at first grid level
+       DEALLOCATE ( surfaces%pt1 )
+       DEALLOCATE ( surfaces%qv1 )
+
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qcs )
+          DEALLOCATE ( surfaces%ncs )
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrs )
+          DEALLOCATE ( surfaces%nrs )
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity surface flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_v
+
 
 !------------------------------------------------------------------------------!
@@ -1203,4 +1506,5 @@
 
     END SUBROUTINE allocate_surface_attributes_v
+
 
 !------------------------------------------------------------------------------!
@@ -2175,5 +2479,6 @@
 !> type) onto a surface type, and writes binary data into restart files. 
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_write_restart_data
+    SUBROUTINE surface_wrd_local
+
 
        IMPLICIT NONE
@@ -2637,8 +2942,10 @@
 
 
-       WRITE ( 14 )  'ns_h_on_file                  '
-       WRITE ( 14 )   ns_h_on_file
-       WRITE ( 14 )  'ns_v_on_file                  '
-       WRITE ( 14 )   ns_v_on_file
+       CALL wrd_write_string( 'ns_h_on_file' )
+       WRITE ( 14 )  ns_h_on_file
+
+       CALL wrd_write_string( 'ns_v_on_file' )
+       WRITE ( 14 )  ns_v_on_file
+
 !
 !--    Write required restart data.
@@ -2646,102 +2953,126 @@
        DO  l = 0, 2
           WRITE( dum, '(I1)')  l
-          
-          WRITE ( 14 )  'surf_h(' // dum // ')%start_index         '  
-          WRITE ( 14 )   surf_h(l)%start_index
-          WRITE ( 14 )  'surf_h(' // dum // ')%end_index           '  
-          WRITE ( 14 )   surf_h(l)%end_index
+
+          CALL wrd_write_string( 'surf_h(' // dum // ')%start_index' )
+          WRITE ( 14 )  surf_h(l)%start_index
+
+          CALL wrd_write_string( 'surf_h(' // dum // ')%end_index' )
+          WRITE ( 14 )  surf_h(l)%end_index
 
           IF ( ALLOCATED ( surf_h(l)%us ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%us                  ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%us' ) 
              WRITE ( 14 )  surf_h(l)%us
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ts ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ts                  ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ts' ) 
              WRITE ( 14 )  surf_h(l)%ts
           ENDIF
+          
           IF ( ALLOCATED ( surf_h(l)%qs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qs                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qs' )  
              WRITE ( 14 )  surf_h(l)%qs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ss ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ss                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ss' )  
              WRITE ( 14 )  surf_h(l)%ss
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qcs ) )  THEN  
-             WRITE ( 14 )  'surf_h(' // dum // ')%qcs                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qcs' )
              WRITE ( 14 )  surf_h(l)%qcs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ncs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ncs                 ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ncs' ) 
              WRITE ( 14 )  surf_h(l)%ncs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qrs ) )  THEN  
-             WRITE ( 14 )  'surf_h(' // dum // ')%qrs                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qrs' )
              WRITE ( 14 )  surf_h(l)%qrs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%nrs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%nrs                 '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%nrs' )  
              WRITE ( 14 )  surf_h(l)%nrs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ol ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ol                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ol' )  
              WRITE ( 14 )  surf_h(l)%ol
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%rib ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%rib                 ' 
+            CALL wrd_write_string( 'surf_h(' // dum // ')%rib' ) 
              WRITE ( 14 )  surf_h(l)%rib
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%pt_surface ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%pt_surface          ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%pt_surface' ) 
              WRITE ( 14 )  surf_h(l)%pt_surface
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%usws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%usws                ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%usws' ) 
              WRITE ( 14 )  surf_h(l)%usws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%vsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%vsws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%vsws' )  
              WRITE ( 14 )  surf_h(l)%vsws
           ENDIF
+          
           IF ( ALLOCATED ( surf_h(l)%shf ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%shf                 ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%shf' ) 
              WRITE ( 14 )  surf_h(l)%shf
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qsws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qsws' )  
              WRITE ( 14 )  surf_h(l)%qsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ssws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%ssws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ssws' )  
              WRITE ( 14 )  surf_h(l)%ssws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%css ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%css                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%css' )
              WRITE ( 14 )  surf_h(l)%css
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%cssws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%cssws               '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%cssws' )
              WRITE ( 14 )  surf_h(l)%cssws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qcsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qcsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qcsws' )  
              WRITE ( 14 )  surf_h(l)%qcsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ncsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ncsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ncsws' )  
              WRITE ( 14 )  surf_h(l)%ncsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qrsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qrsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qrsws' )  
              WRITE ( 14 )  surf_h(l)%qrsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%nrsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%nrsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%nrsws' )  
              WRITE ( 14 )  surf_h(l)%nrsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%sasws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%sasws               ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%sasws' ) 
              WRITE ( 14 )  surf_h(l)%sasws
-          ENDIF
+          ENDIF     
+  
        ENDDO
 !
@@ -2750,111 +3081,134 @@
           WRITE( dum, '(I1)')  l
 
-          WRITE ( 14 )  'surf_v(' // dum // ')%start_index         '  
-          WRITE ( 14 )   surf_v(l)%start_index
-          WRITE ( 14 )  'surf_v(' // dum // ')%end_index           '  
+          CALL wrd_write_string( 'surf_v(' // dum // ')%start_index' )
+          WRITE ( 14 )  surf_v(l)%start_index
+
+          CALL wrd_write_string( 'surf_v(' // dum // ')%end_index' )
           WRITE ( 14 )   surf_v(l)%end_index
 
           IF ( ALLOCATED ( surf_v(l)%us ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%us                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%us' )  
              WRITE ( 14 )  surf_v(l)%us
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ts ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ts                  ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ts' ) 
              WRITE ( 14 )  surf_v(l)%ts
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qs                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qs' )  
              WRITE ( 14 )  surf_v(l)%qs
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ss ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ss                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ss' ) 
              WRITE ( 14 )  surf_v(l)%ss
-          ENDIF
+          ENDIF  
+          
           IF ( ALLOCATED ( surf_v(l)%qcs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qcs                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qcs' ) 
              WRITE ( 14 )  surf_v(l)%qcs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%ncs ) )  THEN 
-             WRITE ( 14 )  'surf_v(' // dum // ')%ncs                 ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ncs' )
              WRITE ( 14 )  surf_v(l)%ncs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qrs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qrs                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qrs' )  
              WRITE ( 14 )  surf_v(l)%qrs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%nrs ) )  THEN 
-             WRITE ( 14 )  'surf_v(' // dum // ')%nrs                 ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%nrs' ) 
              WRITE ( 14 )  surf_v(l)%nrs
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ol ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ol                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ol' )  
              WRITE ( 14 )  surf_v(l)%ol
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%rib ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%rib                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%rib' )
              WRITE ( 14 )  surf_v(l)%rib
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%pt_surface ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%pt_surface          '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%pt_surface' )
              WRITE ( 14 )  surf_v(l)%pt_surface
-          ENDIF
+          ENDIF 
+
           IF ( ALLOCATED ( surf_v(l)%shf ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%shf                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%shf' )  
              WRITE ( 14 )  surf_v(l)%shf
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qsws                '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qsws' )  
              WRITE ( 14 )  surf_v(l)%qsws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%ssws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ssws                '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ssws' )  
              WRITE ( 14 )  surf_v(l)%ssws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%css ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%css                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%css' )  
              WRITE ( 14 )  surf_v(l)%css
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%cssws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%cssws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%cssws' ) 
              WRITE ( 14 )  surf_v(l)%cssws
-          ENDIF 
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%qcsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qcsws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qcsws' ) 
              WRITE ( 14 )  surf_v(l)%qcsws
-          ENDIF 
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ncsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ncsws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ncsws' ) 
              WRITE ( 14 )  surf_v(l)%ncsws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qrsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qrsws               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qrsws' )  
              WRITE ( 14 )  surf_v(l)%qrsws
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%nrsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%nrsws               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%nrsws' )  
              WRITE ( 14 )  surf_v(l)%nrsws
           ENDIF 
+
           IF ( ALLOCATED ( surf_v(l)%sasws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%sasws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%sasws' ) 
              WRITE ( 14 )  surf_v(l)%sasws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_uv ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_uv              '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_uv' )  
              WRITE ( 14 )  surf_v(l)%mom_flux_uv
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_w ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_w               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_w' ) 
              WRITE ( 14 )  surf_v(l)%mom_flux_w
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_tke ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_tke             '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_tke' )  
              WRITE ( 14 )  surf_v(l)%mom_flux_tke
-          ENDIF
+          ENDIF 
 
        ENDDO
 
-       WRITE ( 14 )  '*** end surf ***              '
-
-    END SUBROUTINE surface_write_restart_data
+
+    END SUBROUTINE surface_wrd_local
 
 
@@ -2870,14 +3224,14 @@
 !> of cyclic_fill mode. 
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_read_restart_data( ii,                                  &
-                                       nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
-                                       nynfa, nyn_on_file, nysfa, nys_on_file, &
-                                       offset_xa, offset_ya, overlap_count )
+    SUBROUTINE surface_rrd_local( ii, kk, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & 
+                                  nxr_on_file, nynf, nync, nyn_on_file, nysf,  &
+                                  nysc, nys_on_file, found )
 
        USE pegrid,                                                             &
-           ONLY: numprocs_previous_run
+           ONLY: myid, numprocs_previous_run
+
+       IMPLICIT NONE
 
        CHARACTER (LEN=1)  ::  dum         !< dummy to create correct string for reading input variable
-       CHARACTER (LEN=30) ::  field_chr   !< input variable
 
        INTEGER(iwp)       ::  i           !< running index along x-direction, refers to former domain size
@@ -2886,8 +3240,6 @@
        INTEGER(iwp)       ::  jc          !< running index along y-direction, refers to former domain size
        INTEGER(iwp)       ::  k           !< running index along z-direction
-       INTEGER(iwp)       ::  l           !< index variable for surface type
        INTEGER(iwp)       ::  m           !< running index for surface elements, refers to gathered array encompassing all surface types
        INTEGER(iwp)       ::  mm          !< running index for surface elements, refers to individual surface types
-
        INTEGER(iwp)       ::  ii               !< running index over input files
        INTEGER(iwp)       ::  kk               !< running index over previous input files covering current local domain
@@ -2904,759 +3256,749 @@
        INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
        INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain  
-       INTEGER(iwp)       ::  overlap_count    !< number of overlaps
-  
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
-
-
-       LOGICAL                         ::  horizontal_surface !< flag indicating horizontal surfaces
+
+       INTEGER(iwp), SAVE  ::  l           !< index variable for surface type
+
        LOGICAL                         ::  surf_match_def     !< flag indicating that surface element is of default type
        LOGICAL                         ::  surf_match_lsm     !< flag indicating that surface element is of natural type
        LOGICAL                         ::  surf_match_usm     !< flag indicating that surface element is of urban type
-       LOGICAL                         ::  vertical_surface   !< flag indicating vertical surfaces
-
-       TYPE(surf_type), DIMENSION(0:2) ::  surf_h             !< horizontal surface type on file
-       TYPE(surf_type), DIMENSION(0:3) ::  surf_v             !< vertical surface type on file
-
-!
-!--    Read number of respective surface elements on file
-       READ ( 13 )  field_chr
-       IF ( TRIM( field_chr ) /= 'ns_h_on_file' )  THEN
-!
-!--       Add a proper error message
-       ENDIF
-       READ ( 13 ) ns_h_on_file
-
-       READ ( 13 )  field_chr
-       IF ( TRIM( field_chr ) /= 'ns_v_on_file' )  THEN
-!
-!--       Add a proper error message
-       ENDIF
-       READ ( 13 ) ns_v_on_file
-!
-!--    Allocate memory for number of surface elements on file. Please note, 
-!--    these number is not necessarily the same as the final number of surface
-!--    elements on local domain, which is the case if processor topology changes
-!--    during restart runs. 
-!--    Horizontal upward facing
-       surf_h(0)%ns = ns_h_on_file(0)
-       CALL allocate_surface_attributes_h( surf_h(0),                          &
+
+       LOGICAL, INTENT(OUT) ::  found
+
+       LOGICAL, SAVE ::  horizontal_surface !< flag indicating horizontal surfaces
+       LOGICAL, SAVE ::  vertical_surface   !< flag indicating vertical surfaces
+
+       TYPE(surf_type), DIMENSION(0:2), SAVE ::  surf_h             !< horizontal surface type on file
+       TYPE(surf_type), DIMENSION(0:3), SAVE ::  surf_v             !< vertical surface type on file
+
+
+       found              = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
+
+          CASE ( 'ns_h_on_file' )
+             IF ( kk == 1 )  THEN
+                READ ( 13 )  ns_h_on_file
+
+                IF ( ALLOCATED( surf_h(0)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h( surf_h(0) )           
+                IF ( ALLOCATED( surf_h(1)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h( surf_h(1) )           
+                IF ( ALLOCATED( surf_h(2)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h_top( surf_h(2) )       
+
+!--             Allocate memory for number of surface elements on file. 
+!--             Please note, these number is not necessarily the same as 
+!--             the final number of surface elements on local domain,
+!--             which is the case if processor topology changes during
+!--             restart runs.  
+!--             Horizontal upward facing
+                surf_h(0)%ns = ns_h_on_file(0)
+                CALL allocate_surface_attributes_h( surf_h(0),                 &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+
+!--             Horizontal downward facing
+                surf_h(1)%ns = ns_h_on_file(1)
+                CALL allocate_surface_attributes_h( surf_h(1),                 &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+
+!--             Model top
+                surf_h(2)%ns = ns_h_on_file(2)
+                CALL allocate_surface_attributes_h_top( surf_h(2),             &
+                                            nys_on_file, nyn_on_file,          &
+                                            nxl_on_file, nxr_on_file )
+
+!
+!--             Initial setting of flags for horizontal and vertical surfaces,
+!--             will be set after start- and end-indices are read. 
+                horizontal_surface = .FALSE.
+                vertical_surface   = .FALSE.
+
+             ENDIF   
+
+          CASE ( 'ns_v_on_file' )
+             IF ( kk == 1 ) THEN
+                READ ( 13 )  ns_v_on_file
+
+                DO  l = 0, 3
+                   IF ( ALLOCATED( surf_v(l)%start_index ) )                   &
+                      CALL deallocate_surface_attributes_v( surf_v(l) )
+                ENDDO
+
+!--                Vertical surfaces
+                DO  l = 0, 3
+                   surf_v(l)%ns = ns_v_on_file(l)
+                   CALL allocate_surface_attributes_v( surf_v(l),              &
                                            nys_on_file, nyn_on_file,           &
                                            nxl_on_file, nxr_on_file )
-!
-!--    Horizontal downward facing
-       surf_h(1)%ns = ns_h_on_file(1)
-       CALL allocate_surface_attributes_h( surf_h(1),                          &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file, nxr_on_file )
-!
-!--    Model top
-       surf_h(2)%ns = ns_h_on_file(2)
-       CALL allocate_surface_attributes_h_top( surf_h(2),                      &
-                                               nys_on_file, nyn_on_file,       &
-                                               nxl_on_file, nxr_on_file )
-!
-!--    Vertical surfaces
-       DO  l = 0, 3
-          surf_v(l)%ns = ns_v_on_file(l)
-          CALL allocate_surface_attributes_v( surf_v(l),                       &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-       ENDDO
-
-       IF ( initializing_actions == 'read_restart_data'  .OR.                  &
-            initializing_actions == 'cyclic_fill' )  THEN
-!
-!--       Initial setting of flags for horizontal and vertical surfaces, will
-!--       be set after start- and end-indices are read. 
-          horizontal_surface = .FALSE.
-          vertical_surface   = .FALSE.
-
-          READ ( 13 )  field_chr
-
-          DO  WHILE ( TRIM( field_chr ) /= '*** end surf ***' )
-!
-!--          Map data on file as often as needed (data are read only for k=1)
-             DO  kk = 1, overlap_count
-!
-!--             Get the index range of the subdomain on file which overlap with the
-!--             current subdomain
-                nxlf = nxlfa(ii,kk)
-                nxlc = nxlfa(ii,kk) + offset_xa(ii,kk)
-                nxrf = nxrfa(ii,kk)
-                nxrc = nxrfa(ii,kk) + offset_xa(ii,kk)
-                nysf = nysfa(ii,kk)
-                nysc = nysfa(ii,kk) + offset_ya(ii,kk)
-                nynf = nynfa(ii,kk)
-                nync = nynfa(ii,kk) + offset_ya(ii,kk)
-
-                SELECT CASE ( TRIM( field_chr ) )
-
-                   CASE ( 'surf_h(0)%start_index' )
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(0)%start_index
-                      l = 0
-                   CASE ( 'surf_h(0)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(0)%end_index
-                      horizontal_surface = .TRUE.
-                      vertical_surface   = .FALSE.
-                   CASE ( 'surf_h(0)%us' )         
-                      IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%us
-                   CASE ( 'surf_h(0)%ts' )         
-                      IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ts
-                   CASE ( 'surf_h(0)%qs' )         
-                      IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%qs
-                   CASE ( 'surf_h(0)%ss' )         
-                      IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ss
-                   CASE ( 'surf_h(0)%qcs' )         
-                      IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%qcs
-                   CASE ( 'surf_h(0)%ncs' )         
-                      IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%ncs
-                   CASE ( 'surf_h(0)%qrs' )         
-                      IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%qrs
-                   CASE ( 'surf_h(0)%nrs' )         
-                      IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%nrs
-                   CASE ( 'surf_h(0)%ol' )         
-                      IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ol
-                   CASE ( 'surf_h(0)%rib' )         
-                      IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%rib
-                   CASE ( 'surf_h(0)%pt_surface' )         
-                      IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_h(0)%pt_surface
-                   CASE ( 'surf_h(0)%usws' )         
-                      IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%usws
-                   CASE ( 'surf_h(0)%vsws' )         
-                      IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%vsws
-                   CASE ( 'surf_h(0)%shf' )         
-                      IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%shf
-                   CASE ( 'surf_h(0)%qsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%qsws
-                   CASE ( 'surf_h(0)%ssws' )         
-                      IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%ssws
-                   CASE ( 'surf_h(0)%css' )
-                      IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%css
-                   CASE ( 'surf_h(0)%cssws' )         
-                      IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%cssws
-                   CASE ( 'surf_h(0)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%qcsws
-                   CASE ( 'surf_h(0)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%ncsws
-                   CASE ( 'surf_h(0)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%qrsws
-                   CASE ( 'surf_h(0)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%nrsws
-                   CASE ( 'surf_h(0)%sasws' )         
-                      IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%sasws
-
-                   CASE ( 'surf_h(1)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(1)%start_index
-                      l = 1
-                   CASE ( 'surf_h(1)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(1)%end_index
-                   CASE ( 'surf_h(1)%us' )         
-                      IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%us
-                   CASE ( 'surf_h(1)%ts' )         
-                      IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ts
-                   CASE ( 'surf_h(1)%qs' )         
-                      IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%qs
-                   CASE ( 'surf_h(1)%ss' )         
-                      IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ss
-                   CASE ( 'surf_h(1)%qcs' )         
-                      IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%qcs
-                   CASE ( 'surf_h(1)%ncs' )         
-                      IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%ncs
-                   CASE ( 'surf_h(1)%qrs' )         
-                      IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%qrs
-                   CASE ( 'surf_h(1)%nrs' )         
-                      IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%nrs
-                   CASE ( 'surf_h(1)%ol' )         
-                      IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ol
-                   CASE ( 'surf_h(1)%rib' )         
-                      IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%rib
-                   CASE ( 'surf_h(1)%pt_surface' )         
-                      IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_h(1)%pt_surface
-                   CASE ( 'surf_h(1)%usws' )         
-                      IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%usws
-                   CASE ( 'surf_h(1)%vsws' )         
-                      IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%vsws
-                   CASE ( 'surf_h(1)%shf' )         
-                      IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%shf
-                   CASE ( 'surf_h(1)%qsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%qsws
-                   CASE ( 'surf_h(1)%ssws' )         
-                      IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%ssws
-                   CASE ( 'surf_h(1)%css' )
-                      IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%css
-                   CASE ( 'surf_h(1)%cssws' )         
-                      IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%cssws
-                   CASE ( 'surf_h(1)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%qcsws
-                   CASE ( 'surf_h(1)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%ncsws
-                   CASE ( 'surf_h(1)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%qrsws
-                   CASE ( 'surf_h(1)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%nrsws
-                   CASE ( 'surf_h(1)%sasws' )         
-                      IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%sasws
-
-                   CASE ( 'surf_h(2)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(2)%start_index
-                      l = 2
-                   CASE ( 'surf_h(2)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(2)%end_index
-                   CASE ( 'surf_h(2)%us' )         
-                      IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%us
-                   CASE ( 'surf_h(2)%ts' )         
-                      IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ts
-                   CASE ( 'surf_h(2)%qs' )        
-                      IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%qs
-                   CASE ( 'surf_h(2)%ss' )         
-                      IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ss
-                   CASE ( 'surf_h(2)%qcs' )         
-                      IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%qcs
-                   CASE ( 'surf_h(2)%ncs' )         
-                      IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%ncs
-                   CASE ( 'surf_h(2)%qrs' )         
-                      IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%qrs
-                   CASE ( 'surf_h(2)%nrs' )         
-                      IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%nrs
-                   CASE ( 'surf_h(2)%ol' )         
-                      IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ol
-                   CASE ( 'surf_h(2)%rib' )         
-                      IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%rib
-                   CASE ( 'surf_h(2)%usws' )         
-                      IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%usws
-                   CASE ( 'surf_h(2)%vsws' )         
-                      IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%vsws
-                   CASE ( 'surf_h(2)%shf' )         
-                      IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%shf
-                   CASE ( 'surf_h(2)%qsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%qsws
-                   CASE ( 'surf_h(2)%ssws' )         
-                      IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%ssws
-                   CASE ( 'surf_h(2)%css' )
-                      IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%css
-                   CASE ( 'surf_h(2)%cssws' )         
-                      IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%cssws
-                   CASE ( 'surf_h(2)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%qcsws
-                   CASE ( 'surf_h(2)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%ncsws
-                   CASE ( 'surf_h(2)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%qrsws
-                   CASE ( 'surf_h(2)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%nrsws
-                   CASE ( 'surf_h(2)%sasws' )         
-                      IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%sasws
-
-                   CASE ( 'surf_v(0)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(0)%start_index
-                      l = 0
-                      horizontal_surface = .FALSE.
-                      vertical_surface   = .TRUE.
-                   CASE ( 'surf_v(0)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(0)%end_index
-                   CASE ( 'surf_v(0)%us' )         
-                      IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%us
-                   CASE ( 'surf_v(0)%ts' )         
-                      IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ts
-                   CASE ( 'surf_v(0)%qs' )         
-                      IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%qs
-                   CASE ( 'surf_v(0)%ss' )         
-                      IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ss
-                   CASE ( 'surf_v(0)%qcs' )         
-                      IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%qcs
-                   CASE ( 'surf_v(0)%ncs' )         
-                      IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%ncs
-                   CASE ( 'surf_v(0)%qrs' )         
-                      IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%qrs
-                   CASE ( 'surf_v(0)%nrs' )         
-                      IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%nrs
-                   CASE ( 'surf_v(0)%ol' )         
-                      IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ol
-                   CASE ( 'surf_v(0)%rib' )         
-                      IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%rib
-                   CASE ( 'surf_v(0)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(0)%pt_surface
-                   CASE ( 'surf_v(0)%shf' )         
-                      IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%shf
-                   CASE ( 'surf_v(0)%qsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(0)%qsws
-                   CASE ( 'surf_v(0)%ssws' )         
-                      IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(0)%ssws
-                   CASE ( 'surf_v(0)%css' ) 
-                      IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%css
-                   CASE ( 'surf_v(0)%cssws' )         
-                      IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%cssws
-                   CASE ( 'surf_v(0)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%qcsws
-                   CASE ( 'surf_v(0)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%ncsws
-                   CASE ( 'surf_v(0)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%qrsws
-                   CASE ( 'surf_v(0)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%nrsws
-                   CASE ( 'surf_v(0)%sasws' )         
-                      IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%sasws
-                   CASE ( 'surf_v(0)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(0)%mom_flux_uv
-                   CASE ( 'surf_v(0)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(0)%mom_flux_w
-                   CASE ( 'surf_v(0)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(0)%mom_flux_tke
-
-                   CASE ( 'surf_v(1)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(1)%start_index
-                      l = 1
-                   CASE ( 'surf_v(1)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(1)%end_index
-                   CASE ( 'surf_v(1)%us' )         
-                      IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%us
-                   CASE ( 'surf_v(1)%ts' )         
-                      IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ts
-                   CASE ( 'surf_v(1)%qs' )         
-                      IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%qs
-                   CASE ( 'surf_v(1)%ss' )         
-                      IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ss
-                   CASE ( 'surf_v(1)%qcs' )         
-                      IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%qcs
-                   CASE ( 'surf_v(1)%ncs' )         
-                      IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%ncs
-                   CASE ( 'surf_v(1)%qrs' )         
-                      IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%qrs
-                   CASE ( 'surf_v(1)%nrs' )         
-                      IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%nrs
-                   CASE ( 'surf_v(1)%ol' )         
-                      IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ol
-                   CASE ( 'surf_v(1)%rib' )         
-                      IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%rib
-                   CASE ( 'surf_v(1)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(1)%pt_surface
-                   CASE ( 'surf_v(1)%shf' )         
-                      IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%shf
-                   CASE ( 'surf_v(1)%qsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(1)%qsws
-                   CASE ( 'surf_v(1)%ssws' )         
-                      IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(1)%ssws
-                   CASE ( 'surf_v(1)%css' ) 
-                      IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%css
-                   CASE ( 'surf_v(1)%cssws' )         
-                      IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%cssws
-                   CASE ( 'surf_v(1)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%qcsws
-                   CASE ( 'surf_v(1)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%ncsws
-                   CASE ( 'surf_v(1)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%qrsws
-                   CASE ( 'surf_v(1)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%nrsws
-                   CASE ( 'surf_v(1)%sasws' )         
-                      IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%sasws
-                   CASE ( 'surf_v(1)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(1)%mom_flux_uv
-                   CASE ( 'surf_v(1)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(1)%mom_flux_w
-                   CASE ( 'surf_v(1)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(1)%mom_flux_tke
-
-                   CASE ( 'surf_v(2)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(2)%start_index
-                      l = 2
-                   CASE ( 'surf_v(2)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(2)%end_index
-                   CASE ( 'surf_v(2)%us' )         
-                      IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%us
-                   CASE ( 'surf_v(2)%ts' )         
-                      IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ts
-                   CASE ( 'surf_v(2)%qs' )         
-                      IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%qs
-                   CASE ( 'surf_v(2)%ss' )         
-                      IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ss
-                   CASE ( 'surf_v(2)%qcs' )         
-                      IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%qcs
-                   CASE ( 'surf_v(2)%ncs' )         
-                      IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%ncs
-                   CASE ( 'surf_v(2)%qrs' )         
-                      IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%qrs
-                   CASE ( 'surf_v(2)%nrs' )         
-                      IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%nrs
-                   CASE ( 'surf_v(2)%ol' )         
-                      IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ol
-                   CASE ( 'surf_v(2)%rib' )         
-                      IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%rib
-                   CASE ( 'surf_v(2)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(2)%pt_surface
-                   CASE ( 'surf_v(2)%shf' )         
-                      IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%shf
-                   CASE ( 'surf_v(2)%qsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(2)%qsws
-                   CASE ( 'surf_v(2)%ssws' )         
-                      IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(2)%ssws
-                   CASE ( 'surf_v(2)%css' ) 
-                      IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%css
-                   CASE ( 'surf_v(2)%cssws' )         
-                      IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%cssws
-                   CASE ( 'surf_v(2)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%qcsws
-                   CASE ( 'surf_v(2)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%ncsws
-                   CASE ( 'surf_v(2)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%qrsws
-                   CASE ( 'surf_v(2)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%nrsws
-                   CASE ( 'surf_v(2)%sasws' )         
-                      IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%sasws
-                   CASE ( 'surf_v(2)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(2)%mom_flux_uv
-                   CASE ( 'surf_v(2)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(2)%mom_flux_w
-                   CASE ( 'surf_v(2)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(2)%mom_flux_tke
-
-                   CASE ( 'surf_v(3)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(3)%start_index
-                      l = 3
-                   CASE ( 'surf_v(3)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(3)%end_index
-                   CASE ( 'surf_v(3)%us' )         
-                      IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%us
-                   CASE ( 'surf_v(3)%ts' )         
-                      IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ts
-                   CASE ( 'surf_v(3)%qs' )        
-                      IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%qs
-                   CASE ( 'surf_v(3)%ss' )         
-                      IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ss
-                   CASE ( 'surf_v(3)%qcs' )         
-                      IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%qcs
-                   CASE ( 'surf_v(3)%ncs' )         
-                      IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%ncs
-                   CASE ( 'surf_v(3)%qrs' )         
-                      IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%qrs
-                   CASE ( 'surf_v(3)%nrs' )         
-                      IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%nrs
-                   CASE ( 'surf_v(3)%ol' )         
-                      IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ol
-                   CASE ( 'surf_v(3)%rib' )         
-                      IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%rib
-                   CASE ( 'surf_v(3)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(3)%pt_surface
-                   CASE ( 'surf_v(3)%shf' )         
-                      IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%shf
-                   CASE ( 'surf_v(3)%qsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(3)%qsws
-                   CASE ( 'surf_v(3)%ssws' )         
-                      IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(3)%ssws
-                   CASE ( 'surf_v(3)%css' ) 
-                      IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%css
-                   CASE ( 'surf_v(3)%cssws' )         
-                      IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%cssws
-                   CASE ( 'surf_v(3)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%qcsws
-                   CASE ( 'surf_v(3)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%ncsws
-                   CASE ( 'surf_v(3)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%qrsws
-                   CASE ( 'surf_v(3)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%nrsws
-                   CASE ( 'surf_v(3)%sasws' )         
-                      IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%sasws
-                   CASE ( 'surf_v(3)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(3)%mom_flux_uv
-                   CASE ( 'surf_v(3)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(3)%mom_flux_w
-                   CASE ( 'surf_v(3)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(3)%mom_flux_tke
-
-                END SELECT
-!
-!--             Redistribute surface elements on its respective type. 
-                IF ( horizontal_surface )  THEN
-                   ic = nxlc
-                   DO  i = nxlf, nxrf
-                      jc = nysc
-                      DO  j = nysf, nynf
-
-                         surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=   &
-                                           surf_def_h(l)%start_index(jc,ic)
-                         surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=   &
-                                             surf_lsm_h%start_index(jc,ic) )   &
-                                     .AND.  l == 0 
-                         surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=   &
-                                             surf_usm_h%start_index(jc,ic) )   &
-                                     .AND.  l == 0 
-
-                         IF ( surf_match_def )  THEN
-                            mm = surf_def_h(l)%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_def_h(l),   &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_lsm )  THEN
-                            mm = surf_lsm_h%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_lsm_h,      &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_usm )  THEN
-                            mm = surf_usm_h%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_usm_h,      &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         jc = jc + 1
-                      ENDDO
-                      ic = ic + 1
-                   ENDDO
-                ELSEIF ( vertical_surface )  THEN
-                   ic = nxlc
-                   DO  i = nxlf, nxrf
-                      jc = nysc
-                      DO  j = nysf, nynf
-
-                         surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=   &
-                                           surf_def_v(l)%start_index(jc,ic)
-                         surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=   &
-                                           surf_lsm_v(l)%start_index(jc,ic)
-                         surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=   &
-                                           surf_usm_v(l)%start_index(jc,ic)
-
-                         IF ( surf_match_def )  THEN
-                            mm = surf_def_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_def_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_lsm )  THEN
-                            mm = surf_lsm_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_lsm_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-   
-                         IF ( surf_match_usm )  THEN
-                            mm = surf_usm_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_usm_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         jc = jc + 1
-                      ENDDO
-                      ic = ic + 1
+               ENDDO
+
+             ENDIF
+
+          CASE ( 'surf_h(0)%start_index' )
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(0)%start_index
+             l = 0
+          CASE ( 'surf_h(0)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(0)%end_index
+             horizontal_surface = .TRUE.
+             vertical_surface   = .FALSE.
+          CASE ( 'surf_h(0)%us' )         
+             IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%us
+          CASE ( 'surf_h(0)%ts' )         
+             IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ts
+          CASE ( 'surf_h(0)%qs' )         
+             IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%qs
+          CASE ( 'surf_h(0)%ss' )         
+             IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ss
+          CASE ( 'surf_h(0)%qcs' )         
+             IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%qcs
+          CASE ( 'surf_h(0)%ncs' )         
+             IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%ncs
+          CASE ( 'surf_h(0)%qrs' )         
+             IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%qrs
+          CASE ( 'surf_h(0)%nrs' )         
+             IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%nrs
+          CASE ( 'surf_h(0)%ol' )         
+             IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ol
+          CASE ( 'surf_h(0)%rib' )         
+             IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%rib
+          CASE ( 'surf_h(0)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(0)%pt_surface
+          CASE ( 'surf_h(0)%usws' )         
+             IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%usws
+          CASE ( 'surf_h(0)%vsws' )         
+             IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%vsws
+          CASE ( 'surf_h(0)%shf' )         
+             IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%shf
+          CASE ( 'surf_h(0)%qsws' )         
+             IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%qsws
+          CASE ( 'surf_h(0)%ssws' )         
+             IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%ssws
+          CASE ( 'surf_h(0)%css' )
+             IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%css
+          CASE ( 'surf_h(0)%cssws' )         
+             IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%cssws
+          CASE ( 'surf_h(0)%qcsws' )         
+             IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%qcsws
+          CASE ( 'surf_h(0)%ncsws' )         
+             IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%ncsws
+          CASE ( 'surf_h(0)%qrsws' )         
+             IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%qrsws
+          CASE ( 'surf_h(0)%nrsws' )         
+             IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%nrsws
+          CASE ( 'surf_h(0)%sasws' )         
+             IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%sasws
+
+          CASE ( 'surf_h(1)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(1)%start_index
+             l = 1
+          CASE ( 'surf_h(1)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(1)%end_index
+          CASE ( 'surf_h(1)%us' )         
+             IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%us
+          CASE ( 'surf_h(1)%ts' )         
+             IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ts
+          CASE ( 'surf_h(1)%qs' )         
+             IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%qs
+          CASE ( 'surf_h(1)%ss' )         
+             IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ss
+          CASE ( 'surf_h(1)%qcs' )         
+             IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%qcs
+          CASE ( 'surf_h(1)%ncs' )         
+             IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%ncs
+          CASE ( 'surf_h(1)%qrs' )         
+             IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%qrs
+          CASE ( 'surf_h(1)%nrs' )         
+             IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%nrs
+          CASE ( 'surf_h(1)%ol' )         
+             IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ol
+          CASE ( 'surf_h(1)%rib' )         
+             IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%rib
+          CASE ( 'surf_h(1)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(1)%pt_surface
+          CASE ( 'surf_h(1)%usws' )         
+             IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%usws
+          CASE ( 'surf_h(1)%vsws' )         
+             IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%vsws
+          CASE ( 'surf_h(1)%shf' )         
+             IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%shf
+          CASE ( 'surf_h(1)%qsws' )         
+             IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%qsws
+          CASE ( 'surf_h(1)%ssws' )         
+             IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%ssws
+          CASE ( 'surf_h(1)%css' )
+             IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%css
+          CASE ( 'surf_h(1)%cssws' )         
+             IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%cssws
+          CASE ( 'surf_h(1)%qcsws' )         
+             IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%qcsws
+          CASE ( 'surf_h(1)%ncsws' )         
+             IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%ncsws
+          CASE ( 'surf_h(1)%qrsws' )         
+             IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%qrsws
+          CASE ( 'surf_h(1)%nrsws' )         
+             IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%nrsws
+          CASE ( 'surf_h(1)%sasws' )         
+             IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%sasws
+
+          CASE ( 'surf_h(2)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(2)%start_index
+             l = 2
+          CASE ( 'surf_h(2)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(2)%end_index
+          CASE ( 'surf_h(2)%us' )         
+             IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%us
+          CASE ( 'surf_h(2)%ts' )         
+             IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ts
+          CASE ( 'surf_h(2)%qs' )        
+             IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%qs
+          CASE ( 'surf_h(2)%ss' )         
+             IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ss
+          CASE ( 'surf_h(2)%qcs' )         
+             IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%qcs
+          CASE ( 'surf_h(2)%ncs' )         
+             IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%ncs
+          CASE ( 'surf_h(2)%qrs' )         
+             IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%qrs
+          CASE ( 'surf_h(2)%nrs' )         
+             IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%nrs
+          CASE ( 'surf_h(2)%ol' )         
+             IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ol
+          CASE ( 'surf_h(2)%rib' )         
+             IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%rib
+          CASE ( 'surf_h(2)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(2)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(2)%pt_surface
+          CASE ( 'surf_h(2)%usws' )         
+             IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%usws
+          CASE ( 'surf_h(2)%vsws' )         
+             IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%vsws
+          CASE ( 'surf_h(2)%shf' )         
+             IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%shf
+          CASE ( 'surf_h(2)%qsws' )         
+             IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%qsws
+          CASE ( 'surf_h(2)%ssws' )         
+             IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%ssws
+          CASE ( 'surf_h(2)%css' )
+             IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%css
+          CASE ( 'surf_h(2)%cssws' )         
+             IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%cssws
+          CASE ( 'surf_h(2)%qcsws' )         
+             IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%qcsws
+          CASE ( 'surf_h(2)%ncsws' )         
+             IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%ncsws
+          CASE ( 'surf_h(2)%qrsws' )         
+             IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%qrsws
+          CASE ( 'surf_h(2)%nrsws' )         
+             IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%nrsws
+          CASE ( 'surf_h(2)%sasws' )         
+             IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%sasws
+
+          CASE ( 'surf_v(0)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(0)%start_index
+             l = 0
+             horizontal_surface = .FALSE.
+             vertical_surface   = .TRUE.
+          CASE ( 'surf_v(0)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(0)%end_index
+          CASE ( 'surf_v(0)%us' )         
+             IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%us
+          CASE ( 'surf_v(0)%ts' )         
+             IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ts
+          CASE ( 'surf_v(0)%qs' )         
+             IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%qs
+          CASE ( 'surf_v(0)%ss' )         
+             IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ss
+          CASE ( 'surf_v(0)%qcs' )         
+             IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%qcs
+          CASE ( 'surf_v(0)%ncs' )         
+             IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%ncs
+          CASE ( 'surf_v(0)%qrs' )         
+             IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%qrs
+          CASE ( 'surf_v(0)%nrs' )         
+             IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%nrs
+          CASE ( 'surf_v(0)%ol' )         
+             IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ol
+          CASE ( 'surf_v(0)%rib' )         
+             IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%rib
+          CASE ( 'surf_v(0)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(0)%pt_surface
+          CASE ( 'surf_v(0)%shf' )         
+             IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%shf
+          CASE ( 'surf_v(0)%qsws' )         
+             IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(0)%qsws
+          CASE ( 'surf_v(0)%ssws' )         
+             IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(0)%ssws
+          CASE ( 'surf_v(0)%css' ) 
+             IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%css
+          CASE ( 'surf_v(0)%cssws' )         
+             IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%cssws
+          CASE ( 'surf_v(0)%qcsws' )         
+             IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%qcsws
+          CASE ( 'surf_v(0)%ncsws' )         
+             IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%ncsws
+          CASE ( 'surf_v(0)%qrsws' )         
+             IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%qrsws
+          CASE ( 'surf_v(0)%nrsws' )         
+             IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%nrsws
+          CASE ( 'surf_v(0)%sasws' )         
+             IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%sasws
+          CASE ( 'surf_v(0)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(0)%mom_flux_uv
+          CASE ( 'surf_v(0)%mom_w' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(0)%mom_flux_w
+          CASE ( 'surf_v(0)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(0)%mom_flux_tke
+
+          CASE ( 'surf_v(1)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(1)%start_index
+             l = 1
+          CASE ( 'surf_v(1)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(1)%end_index
+          CASE ( 'surf_v(1)%us' )         
+             IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%us
+          CASE ( 'surf_v(1)%ts' )         
+             IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ts
+          CASE ( 'surf_v(1)%qs' )         
+             IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%qs
+          CASE ( 'surf_v(1)%ss' )         
+             IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ss
+          CASE ( 'surf_v(1)%qcs' )         
+             IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%qcs
+          CASE ( 'surf_v(1)%ncs' )         
+             IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%ncs
+          CASE ( 'surf_v(1)%qrs' )         
+             IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%qrs
+          CASE ( 'surf_v(1)%nrs' )         
+             IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%nrs
+          CASE ( 'surf_v(1)%ol' )         
+             IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ol
+          CASE ( 'surf_v(1)%rib' )         
+             IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%rib
+          CASE ( 'surf_v(1)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(1)%pt_surface
+          CASE ( 'surf_v(1)%shf' )         
+             IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%shf
+          CASE ( 'surf_v(1)%qsws' )         
+             IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(1)%qsws
+          CASE ( 'surf_v(1)%ssws' )         
+             IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(1)%ssws
+          CASE ( 'surf_v(1)%css' ) 
+             IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%css
+          CASE ( 'surf_v(1)%cssws' )         
+             IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%cssws
+          CASE ( 'surf_v(1)%qcsws' )         
+             IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%qcsws
+          CASE ( 'surf_v(1)%ncsws' )         
+             IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%ncsws
+          CASE ( 'surf_v(1)%qrsws' )         
+             IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%qrsws
+          CASE ( 'surf_v(1)%nrsws' )         
+             IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%nrsws
+          CASE ( 'surf_v(1)%sasws' )         
+             IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%sasws
+          CASE ( 'surf_v(1)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(1)%mom_flux_uv
+          CASE ( 'surf_v(1)%mom_w' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(1)%mom_flux_w
+          CASE ( 'surf_v(1)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(1)%mom_flux_tke
+
+          CASE ( 'surf_v(2)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(2)%start_index
+             l = 2
+          CASE ( 'surf_v(2)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(2)%end_index
+          CASE ( 'surf_v(2)%us' )         
+             IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%us
+          CASE ( 'surf_v(2)%ts' )         
+             IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ts
+          CASE ( 'surf_v(2)%qs' )         
+             IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%qs
+          CASE ( 'surf_v(2)%ss' )         
+             IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ss
+          CASE ( 'surf_v(2)%qcs' )         
+             IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%qcs
+          CASE ( 'surf_v(2)%ncs' )         
+             IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%ncs
+          CASE ( 'surf_v(2)%qrs' )         
+             IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%qrs
+          CASE ( 'surf_v(2)%nrs' )         
+             IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%nrs
+          CASE ( 'surf_v(2)%ol' )         
+             IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ol
+          CASE ( 'surf_v(2)%rib' )         
+             IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%rib
+          CASE ( 'surf_v(2)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(2)%pt_surface
+          CASE ( 'surf_v(2)%shf' )         
+             IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%shf
+          CASE ( 'surf_v(2)%qsws' )         
+             IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(2)%qsws
+          CASE ( 'surf_v(2)%ssws' )         
+             IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(2)%ssws
+          CASE ( 'surf_v(2)%css' ) 
+             IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%css
+          CASE ( 'surf_v(2)%cssws' )         
+             IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%cssws
+          CASE ( 'surf_v(2)%qcsws' )         
+             IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%qcsws
+          CASE ( 'surf_v(2)%ncsws' )         
+             IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%ncsws
+          CASE ( 'surf_v(2)%qrsws' )         
+             IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%qrsws
+          CASE ( 'surf_v(2)%nrsws' )         
+             IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%nrsws
+          CASE ( 'surf_v(2)%sasws' )         
+             IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%sasws
+          CASE ( 'surf_v(2)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(2)%mom_flux_uv
+          CASE ( 'surf_v(2)%mom_w' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(2)%mom_flux_w
+          CASE ( 'surf_v(2)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(2)%mom_flux_tke
+
+          CASE ( 'surf_v(3)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(3)%start_index
+             l = 3
+          CASE ( 'surf_v(3)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(3)%end_index
+          CASE ( 'surf_v(3)%us' )         
+             IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%us
+          CASE ( 'surf_v(3)%ts' )         
+             IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ts
+          CASE ( 'surf_v(3)%qs' )        
+             IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%qs
+          CASE ( 'surf_v(3)%ss' )         
+             IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ss
+          CASE ( 'surf_v(3)%qcs' )         
+             IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%qcs
+          CASE ( 'surf_v(3)%ncs' )         
+             IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%ncs
+          CASE ( 'surf_v(3)%qrs' )         
+             IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%qrs
+          CASE ( 'surf_v(3)%nrs' )         
+             IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%nrs
+          CASE ( 'surf_v(3)%ol' )         
+             IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ol
+          CASE ( 'surf_v(3)%rib' )         
+             IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%rib
+          CASE ( 'surf_v(3)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(3)%pt_surface
+          CASE ( 'surf_v(3)%shf' )         
+             IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%shf
+          CASE ( 'surf_v(3)%qsws' )         
+             IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )                & 
+                READ ( 13 )  surf_v(3)%qsws
+          CASE ( 'surf_v(3)%ssws' )         
+             IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(3)%ssws
+          CASE ( 'surf_v(3)%css' ) 
+             IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%css
+          CASE ( 'surf_v(3)%cssws' )         
+             IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%cssws
+          CASE ( 'surf_v(3)%qcsws' )         
+             IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%qcsws
+          CASE ( 'surf_v(3)%ncsws' )         
+             IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%ncsws
+          CASE ( 'surf_v(3)%qrsws' )         
+             IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%qrsws
+          CASE ( 'surf_v(3)%nrsws' )         
+             IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%nrsws
+          CASE ( 'surf_v(3)%sasws' )         
+             IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%sasws
+          CASE ( 'surf_v(3)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(3)%mom_flux_uv
+          CASE ( 'surf_v(3)%mom_w' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(3)%mom_flux_w
+          CASE ( 'surf_v(3)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(3)%mom_flux_tke
+
+          CASE DEFAULT
+
+                found = .FALSE.
+
+       END SELECT
+
+!
+!--    Redistribute surface elements on its respective type. 
+       IF ( horizontal_surface )  THEN
+          ic = nxlc
+          DO  i = nxlf, nxrf
+             jc = nysc
+             DO  j = nysf, nynf
+
+                surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=            &
+                                  surf_def_h(l)%start_index(jc,ic)
+                surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=            &
+                                    surf_lsm_h%start_index(jc,ic) )            &
+                            .AND.  l == 0 
+                surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=            &
+                                    surf_usm_h%start_index(jc,ic) )            &
+                            .AND.  l == 0 
+
+                IF ( surf_match_def )  THEN
+                   mm = surf_def_h(l)%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_def_h(l),            &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
                    ENDDO
                 ENDIF
 
+                IF ( surf_match_lsm )  THEN
+                   mm = surf_lsm_h%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_lsm_h,               &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_usm )  THEN
+                   mm = surf_usm_h%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_usm_h,               &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                jc = jc + 1
              ENDDO
-
-             READ ( 13 )  field_chr
-
+             ic = ic + 1
           ENDDO
-
+       ELSEIF ( vertical_surface )  THEN
+          ic = nxlc
+          DO  i = nxlf, nxrf
+             jc = nysc
+             DO  j = nysf, nynf
+
+                surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=            &
+                                  surf_def_v(l)%start_index(jc,ic)
+                surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=            &
+                                  surf_lsm_v(l)%start_index(jc,ic)
+                surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=            &
+                                  surf_usm_v(l)%start_index(jc,ic)
+
+                IF ( surf_match_def )  THEN
+                   mm = surf_def_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_def_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_lsm )  THEN
+                   mm = surf_lsm_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_lsm_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_usm )  THEN
+                   mm = surf_usm_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_usm_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                jc = jc + 1
+             ENDDO
+             ic = ic + 1
+          ENDDO
        ENDIF
 
-       CONTAINS
+
+    CONTAINS
 !------------------------------------------------------------------------------!
 ! Description:
@@ -3676,5 +4018,5 @@
              TYPE( surf_type ) ::  surf_file   !< surface type on file
 
-             IF ( INDEX( TRIM( field_chr ), '%us' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%us )  .AND.                        &
                      ALLOCATED( surf_file%us   ) )                             & 
@@ -3682,5 +4024,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ol' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ol' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ol )  .AND.                        &
                      ALLOCATED( surf_file%ol   ) )                             & 
@@ -3688,5 +4030,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%pt_surface' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%pt_surface' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%pt_surface )  .AND.                &
                      ALLOCATED( surf_file%pt_surface   ) )                     & 
@@ -3694,5 +4036,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%usws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%usws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%usws )  .AND.                      &
                      ALLOCATED( surf_file%usws   ) )                           & 
@@ -3700,5 +4042,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%vsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%vsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%vsws )  .AND.                      &
                      ALLOCATED( surf_file%vsws   ) )                           & 
@@ -3706,5 +4048,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ts' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ts' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ts )  .AND.                        &
                      ALLOCATED( surf_file%ts   ) )                             & 
@@ -3712,5 +4054,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%shf' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%shf' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%shf )  .AND.                       &
                      ALLOCATED( surf_file%shf   ) )                            & 
@@ -3718,5 +4060,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qs )  .AND.                        &
                      ALLOCATED( surf_file%qs   ) )                             & 
@@ -3724,5 +4066,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qsws )  .AND.                      &
                      ALLOCATED( surf_file%qsws   ) )                           & 
@@ -3730,5 +4072,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ss' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ss' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ss )  .AND.                        &
                      ALLOCATED( surf_file%ss   ) )                             & 
@@ -3736,5 +4078,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ssws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ssws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ssws )  .AND.                      &
                      ALLOCATED( surf_file%ssws   ) )                           & 
@@ -3742,5 +4084,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%css' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%css' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%css )  .AND.                     &
                      ALLOCATED( surf_file%css   ) )  THEN                  
@@ -3750,5 +4092,5 @@
                 ENDIF
              ENDIF
-             IF ( INDEX( TRIM( field_chr ), '%cssws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%cssws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%cssws )  .AND.                     &
                      ALLOCATED( surf_file%cssws   ) )  THEN                  
@@ -3759,5 +4101,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qcs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qcs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qcs )  .AND.                       &
                      ALLOCATED( surf_file%qcs   ) )                            & 
@@ -3765,5 +4107,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qcsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qcsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qcsws )  .AND.                     &
                      ALLOCATED( surf_file%qcsws   ) )                          & 
@@ -3771,5 +4113,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ncs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ncs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ncs )  .AND.                       &
                      ALLOCATED( surf_file%ncs   ) )                            & 
@@ -3777,5 +4119,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ncsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ncsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ncsws )  .AND.                     &
                      ALLOCATED( surf_file%ncsws   ) )                          & 
@@ -3783,5 +4125,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qrs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qrs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qrs )  .AND.                       &
                      ALLOCATED( surf_file%qrs   ) )                            & 
@@ -3789,5 +4131,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qrsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qrsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qrsws )  .AND.                     &
                      ALLOCATED( surf_file%qrsws   ) )                          & 
@@ -3795,5 +4137,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%nrs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%nrs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%nrs )  .AND.                       &
                      ALLOCATED( surf_file%nrs   ) )                            & 
@@ -3801,5 +4143,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%nrsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%nrsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%nrsws )  .AND.                     &
                      ALLOCATED( surf_file%nrsws   ) )                          & 
@@ -3807,5 +4149,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%sasws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%sasws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%sasws )  .AND.                     &
                      ALLOCATED( surf_file%sasws   ) )                          & 
@@ -3813,5 +4155,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_uv' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_uv' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.               &
                      ALLOCATED( surf_file%mom_flux_uv   ) )                    & 
@@ -3820,5 +4162,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_w' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_w' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.                &
                      ALLOCATED( surf_file%mom_flux_w   ) )                     & 
@@ -3827,5 +4169,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_tke' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_tke' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.              &
                      ALLOCATED( surf_file%mom_flux_tke   ) )                   & 
@@ -3834,7 +4176,9 @@
              ENDIF
 
+
           END SUBROUTINE restore_surface_elements
 
-    END SUBROUTINE surface_read_restart_data
+
+    END SUBROUTINE surface_rrd_local
 
  
@@ -3903,5 +4247,5 @@
        REAL(wp), DIMENSION(:) ::  surf_target !< target surface type
        REAL(wp), DIMENSION(:) ::  surf_file   !< surface type on file
-       
+
        ic = nxlc
        DO  i = nxlf, nxrf
Index: palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 2894)
@@ -25,4 +25,14 @@
 ! -----------------
 ! $Id$
+! variable named found has been introduced for checking if restart data was found, 
+! reading of restart strings has been moved completely to read_restart_data_mod, 
+! redundant skipping function has been removed, stg_read/write_restart_data 
+! have been renamed to stg_r/wrd_global, stg_rrd_global is called in 
+! read_restart_data_mod now, flag syn_turb_gen_prerun and marker *** end stg
+! *** have been removed (Giersch), strings and their respective lengths are 
+! written out and read now in case of restart runs to get rid of prescribed 
+! character lengths (Giersch), CASE DEFAULT was added if restart data is read 
+! 
+! 2841 2018-02-27 15:02:57Z suehring
 ! Bugfix: wrong placement of include 'mpif.h' corrected
 ! 
@@ -44,5 +54,5 @@
 ! 
 ! 2576 2017-10-24 13:49:46Z Giersch
-! Definition of a new function called stg_skip_var_list to skip module 
+! Definition of a new function called stg_skip_global to skip module 
 ! parameters during reading restart data
 ! 
@@ -92,5 +102,5 @@
     USE control_parameters,                                                    &
         ONLY:  initializing_actions, message_string,                           &
-               syn_turb_gen, syn_turb_gen_prerun
+               syn_turb_gen
 
     USE cpulog,                                                                &
@@ -208,20 +218,14 @@
 
 !
-!-- Skipping of parameters for restart runs
-    INTERFACE stg_skip_var_list 
-       MODULE PROCEDURE stg_skip_var_list
-    END INTERFACE stg_skip_var_list
-
-!
 !-- Reading of parameters for restart runs
-    INTERFACE stg_read_restart_data
-       MODULE PROCEDURE stg_read_restart_data
-    END INTERFACE stg_read_restart_data
+    INTERFACE stg_rrd_global
+       MODULE PROCEDURE stg_rrd_global
+    END INTERFACE stg_rrd_global
 
 !
 !-- Writing of binary output for restart runs
-    INTERFACE stg_write_restart_data
-       MODULE PROCEDURE stg_write_restart_data
-    END INTERFACE stg_write_restart_data
+    INTERFACE stg_wrd_global
+       MODULE PROCEDURE stg_wrd_global
+    END INTERFACE stg_wrd_global
 
     SAVE
@@ -232,5 +236,5 @@
 !-- Public interfaces
     PUBLIC  stg_check_parameters, stg_header, stg_init, stg_main, stg_parin,   &
-            stg_write_restart_data, stg_skip_var_list
+            stg_wrd_global, stg_rrd_global
 
 !
@@ -702,35 +706,8 @@
     syn_turb_gen = .TRUE.
 
-    IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
-       CALL stg_read_restart_data
-    ENDIF
 
  10 CONTINUE
 
  END SUBROUTINE stg_parin
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Skipping the stg variables from restart-file (binary format).
-!------------------------------------------------------------------------------!
-   SUBROUTINE stg_skip_var_list 
-        
-      IMPLICIT NONE
-            
-      CHARACTER (LEN=1)  ::  cdum
-      CHARACTER (LEN=30) ::  variable_chr
-            
-      READ ( 13 )  variable_chr
-
-      DO  WHILE ( TRIM( variable_chr ) /= '*** end stg module ***' )
-
-         READ ( 13 )  cdum
-         READ ( 13 )  variable_chr
-
-      ENDDO   
-            
-   END SUBROUTINE stg_skip_var_list 
 
 
@@ -740,31 +717,34 @@
 !> This routine reads the respective restart data.
 !------------------------------------------------------------------------------!
- SUBROUTINE stg_read_restart_data
+ SUBROUTINE stg_rrd_global( found )
+
+
+    USE control_parameters,                                                    &
+        ONLY: length, restart_string
 
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
-
-
-    READ ( 13 )  variable_chr
-    DO  WHILE ( TRIM( variable_chr ) /= '*** end stg module ***' )
-
-       SELECT CASE ( TRIM( variable_chr ) )
-
-          CASE ( 'use_syn_turb_gen' )
-             READ ( 13 )  use_syn_turb_gen
-          CASE ( 'mc_factor' )
-             READ ( 13 )  mc_factor
-          CASE ( 'syn_turb_gen_prerun' )
-             READ ( 13 )  syn_turb_gen_prerun
-
-       END SELECT
-
-       READ ( 13 )  variable_chr
-
-    ENDDO
-
- END SUBROUTINE stg_read_restart_data
+    LOGICAL, INTENT(OUT)  ::  found 
+
+
+    found = .TRUE.
+ 
+
+    SELECT CASE ( restart_string(1:length) )
+
+       CASE ( 'mc_factor' )
+          READ ( 13 )  mc_factor
+       CASE ( 'use_syn_turb_gen' )
+          READ ( 13 )  use_syn_turb_gen
+
+       CASE DEFAULT
+
+          found = .FALSE.   
+
+    END SELECT
+
+
+ END SUBROUTINE stg_rrd_global
 
 
@@ -774,21 +754,18 @@
 !> This routine writes the respective restart data.
 !------------------------------------------------------------------------------!
- SUBROUTINE stg_write_restart_data
+ SUBROUTINE stg_wrd_global
 
 
     IMPLICIT NONE
 
-    syn_turb_gen_prerun = .TRUE.
-
-    WRITE ( 14 )  'use_syn_turb_gen              '
+
+    CALL wrd_write_string( 'mc_factor' )
+    WRITE ( 14 )  mc_factor
+
+    CALL wrd_write_string( 'use_syn_turb_gen' )
     WRITE ( 14 )  use_syn_turb_gen
-    WRITE ( 14 )  'mc_factor                     '
-    WRITE ( 14 )  mc_factor
-    WRITE ( 14 )  'syn_turb_gen_prerun           '
-    WRITE ( 14 )  syn_turb_gen_prerun
-
-    WRITE ( 14 )  '*** end stg module ***        '
-
-END SUBROUTINE stg_write_restart_data
+
+
+ END SUBROUTINE stg_wrd_global
 
 
Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2894)
@@ -26,4 +26,18 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod,
+! usm_read/write_restart_data have been renamed to usm_r/wrd_local, variable 
+! named found has been introduced for checking if restart data was found, 
+! reading of restart strings has been moved completely to 
+! read_restart_data_mod, usm_rrd_local is already inside the overlap loop 
+! programmed in read_restart_data_mod, SAVE attribute added where necessary, 
+! deallocation and allocation of some arrays have been changed to take care of 
+! different restart files that can be opened (index i), the marker *** end usm 
+! *** is not necessary anymore, strings and their respective lengths are 
+! written out and read now in case of restart runs to get rid of prescribed 
+! character lengths
+! 
+! 2805 2018-02-14 17:00:09Z suehring
 ! Initialization of resistances.
 ! 
@@ -711,7 +725,7 @@
     END INTERFACE usm_temperature_near_surface
 
-    INTERFACE usm_read_restart_data 
-       MODULE PROCEDURE usm_read_restart_data
-    END INTERFACE usm_read_restart_data
+    INTERFACE usm_rrd_local 
+       MODULE PROCEDURE usm_rrd_local
+    END INTERFACE usm_rrd_local
 
     INTERFACE usm_surface_energy_balance
@@ -723,7 +737,7 @@
     END INTERFACE usm_swap_timelevel
         
-    INTERFACE usm_write_restart_data
-       MODULE PROCEDURE usm_write_restart_data
-    END INTERFACE usm_write_restart_data
+    INTERFACE usm_wrd_local
+       MODULE PROCEDURE usm_wrd_local
+    END INTERFACE usm_wrd_local
 
     INTERFACE usm_allocate_surface
@@ -742,9 +756,9 @@
 !-- Public functions
     PUBLIC usm_boundary_condition, usm_check_parameters, usm_init_urban_surface,&
-           usm_read_restart_data,                                               & 
+           usm_rrd_local,                                                       & 
            usm_surface_energy_balance, usm_material_heat_model,                 &
            usm_swap_timelevel, usm_check_data_output, usm_average_3d_data,      &
            usm_data_output_3d, usm_define_netcdf_grid, usm_parin,               &
-           usm_write_restart_data, usm_allocate_surface
+           usm_wrd_local, usm_allocate_surface
 
 !-- Public parameters, constants and initial values
@@ -5196,28 +5210,26 @@
 ! Description:
 ! ------------
-!> Soubroutine reads t_surf and t_wall data from restart files
+!> Soubroutine reads t_surf and t_wall data from restart file(s)
 !kanani: Renamed this routine according to corresponging routines in PALM
-!kanani: Modified the routine to match read_var_list, from where usm_read_restart_data
+!kanani: Modified the routine to match rrd_global, from where usm_rrd_local
 !        shall be called in the future. This part has not been tested yet. (see virtual_flight_mod)
 !        Also, I had some trouble with the allocation of t_surf, since this is a pointer.
 !        So, I added some directives here.
 !------------------------------------------------------------------------------!
-    SUBROUTINE usm_read_restart_data( ii,                                      &
-                                      nxlfa, nxl_on_file, nxrfa, nxr_on_file,  &
-                                      nynfa, nyn_on_file, nysfa, nys_on_file,  &
-                                      offset_xa, offset_ya, overlap_count )
-
-
-       USE pegrid,                                                             &
-           ONLY: numprocs_previous_run
+    SUBROUTINE usm_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,       &
+                              nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,&
+                              nys_on_file, found )
+
+
+       USE control_parameters,                                                 &
+           ONLY: length, restart_string
            
        IMPLICIT NONE
 
        CHARACTER (LEN=1)  ::  dum              !< dummy to create correct string for reading input variable
-       CHARACTER (LEN=30) ::  field_chr        !< input variable
 
        INTEGER(iwp)       ::  l                !< index variable for surface type
-       INTEGER(iwp)       ::  ii               !< running index over input files
-       INTEGER(iwp)       ::  kk               !< running index over previous input files covering current local domain
+       INTEGER(iwp)       ::  i                !< running index over input files
+       INTEGER(iwp)       ::  k                !< running index over previous input files covering current local domain
        INTEGER(iwp)       ::  ns_h_on_file_usm !< number of horizontal surface elements (urban type) on file
        INTEGER(iwp)       ::  nxlc             !< index of left boundary on current subdomain
@@ -5226,1086 +5238,1153 @@
        INTEGER(iwp)       ::  nxrc             !< index of right boundary on current subdomain
        INTEGER(iwp)       ::  nxrf             !< index of right boundary on former subdomain
-       INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain  
+       INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain 
        INTEGER(iwp)       ::  nync             !< index of north boundary on current subdomain
        INTEGER(iwp)       ::  nynf             !< index of north boundary on former subdomain
-       INTEGER(iwp)       ::  nyn_on_file      !< index of norht boundary on former local domain  
+       INTEGER(iwp)       ::  nyn_on_file      !< index of north boundary on former local domain 
        INTEGER(iwp)       ::  nysc             !< index of south boundary on current subdomain 
        INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
-       INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain  
-       INTEGER(iwp)       ::  overlap_count    !< number of overlaps
+       INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain
        
        INTEGER(iwp)       ::  ns_v_on_file_usm(0:3) !< number of vertical surface elements (urban type) on file
+       
+       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file 
+       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  end_index_on_file
+
+       LOGICAL, INTENT(OUT)  ::  found 
+       
+       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_h, tmp_surf_window_h, tmp_surf_green_h
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_wall_h, tmp_window_h, tmp_green_h
+       
+       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_v, tmp_surf_window_v, tmp_surf_green_v
+       TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_wall_v, tmp_window_v, tmp_green_v
+
+
+       found = .TRUE.
+
+
+          SELECT CASE ( restart_string(1:length) ) 
+
+             CASE ( 'ns_h_on_file_usm') 
+                IF ( k == 1 )  THEN
+                   READ ( 13 ) ns_h_on_file_usm
+                
+                   IF ( ALLOCATED( tmp_surf_h ) ) DEALLOCATE( tmp_surf_h )
+                   IF ( ALLOCATED( tmp_wall_h ) ) DEALLOCATE( tmp_wall_h ) 
+                   IF ( ALLOCATED( tmp_surf_window_h ) )                       &
+                      DEALLOCATE( tmp_surf_window_h ) 
+                   IF ( ALLOCATED( tmp_window_h) ) DEALLOCATE( tmp_window_h ) 
+                   IF ( ALLOCATED( tmp_surf_green_h) )                         &
+                      DEALLOCATE( tmp_surf_green_h ) 
+                   IF ( ALLOCATED( tmp_green_h) ) DEALLOCATE( tmp_green_h )
   
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
+!
+!--                Allocate temporary arrays for reading data on file. Note,
+!--                the size of allocated surface elements do not necessarily
+!--                need  to match the size of present surface elements on 
+!--                current processor, as the number of processors between 
+!--                restarts can change. 
+                   ALLOCATE( tmp_surf_h(1:ns_h_on_file_usm) )
+                   ALLOCATE( tmp_wall_h(nzb_wall:nzt_wall+1,                   &
+                                        1:ns_h_on_file_usm) )
+                   ALLOCATE( tmp_surf_window_h(1:ns_h_on_file_usm) )
+                   ALLOCATE( tmp_window_h(nzb_wall:nzt_wall+1,                 &
+                                          1:ns_h_on_file_usm) )
+                   ALLOCATE( tmp_surf_green_h(1:ns_h_on_file_usm) )
+                   ALLOCATE( tmp_green_h(nzb_wall:nzt_wall+1,                  &
+                                         1:ns_h_on_file_usm) )
+
+                ENDIF
+
+             CASE ( 'ns_v_on_file_usm')
+                IF ( k == 1 )  THEN
+                   READ ( 13 ) ns_v_on_file_usm 
+
+                   DO  l = 0, 3
+                      IF ( ALLOCATED( tmp_surf_v(l)%t ) )                      &
+                         DEALLOCATE( tmp_surf_v(l)%t )
+                      IF ( ALLOCATED( tmp_wall_v(l)%t ) )                      &
+                         DEALLOCATE( tmp_wall_v(l)%t )
+                      IF ( ALLOCATED( tmp_surf_window_v(l)%t ) )               & 
+                         DEALLOCATE( tmp_surf_window_v(l)%t )
+                      IF ( ALLOCATED( tmp_window_v(l)%t ) )                    &
+                         DEALLOCATE( tmp_window_v(l)%t )
+                      IF ( ALLOCATED( tmp_surf_green_v(l)%t ) )                &
+                         DEALLOCATE( tmp_surf_green_v(l)%t )
+                      IF ( ALLOCATED( tmp_green_v(l)%t ) )                     &
+                         DEALLOCATE( tmp_green_v(l)%t )
+                   ENDDO 
+
+!
+!--                Allocate temporary arrays for reading data on file. Note,
+!--                the size of allocated surface elements do not necessarily
+!--                need to match the size of present surface elements on 
+!--                current processor, as the number of processors between 
+!--                restarts can change. 
+                   DO  l = 0, 3
+                      ALLOCATE( tmp_surf_v(l)%t(1:ns_v_on_file_usm(l)) )
+                      ALLOCATE( tmp_wall_v(l)%t(nzb_wall:nzt_wall+1,           &
+                                                1:ns_v_on_file_usm(l) ) )
+                      ALLOCATE( tmp_surf_window_v(l)%t(1:ns_v_on_file_usm(l)) )
+                      ALLOCATE( tmp_window_v(l)%t(nzb_wall:nzt_wall+1,         & 
+                                                  1:ns_v_on_file_usm(l) ) )
+                      ALLOCATE( tmp_surf_green_v(l)%t(1:ns_v_on_file_usm(l)) )
+                      ALLOCATE( tmp_green_v(l)%t(nzb_wall:nzt_wall+1,          &
+                                                 1:ns_v_on_file_usm(l) ) )
+                   ENDDO
+
+                ENDIF    
+          
+             CASE ( 'usm_start_index_h', 'usm_start_index_v'  )   
+                IF ( k == 1 )  THEN
+
+                   IF ( ALLOCATED( start_index_on_file ) )                     &
+                      DEALLOCATE( start_index_on_file )
+
+                   ALLOCATE ( start_index_on_file(nys_on_file:nyn_on_file,     &
+                                                  nxl_on_file:nxr_on_file) )
+
+                   READ ( 13 )  start_index_on_file
+
+                ENDIF
+                
+             CASE ( 'usm_end_index_h', 'usm_end_index_v' )   
+                IF ( k == 1 )  THEN
+
+                   IF ( ALLOCATED( end_index_on_file ) )                       &
+                      DEALLOCATE( end_index_on_file )
+
+                   ALLOCATE ( end_index_on_file(nys_on_file:nyn_on_file,       &
+                                                nxl_on_file:nxr_on_file) )
+
+                   READ ( 13 )  end_index_on_file
+
+                ENDIF
+          
+             CASE ( 't_surf_h' )
+#if defined( __nopointer )                   
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_h ) )                         &
+                      ALLOCATE( t_surf_h(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_h, tmp_surf_h,                  &
+                                        surf_usm_h%start_index,                &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                  
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_h_1 ) )                       &
+                      ALLOCATE( t_surf_h_1(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_h
+                ENDIF              
+                CALL surface_restore_elements(                                 &
+                                        t_surf_h_1, tmp_surf_h,                &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_v(0)' )
+#if defined( __nopointer )            
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v(0)%t ) )                    &
+                      ALLOCATE( t_surf_v(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v(0)%t, tmp_surf_v(0)%t,        &
+                                        surf_usm_v(0)%start_index,             &
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v_1(0)%t ) )                  &
+                      ALLOCATE( t_surf_v_1(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v_1(0)%t, tmp_surf_v(0)%t,      &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                      
+             CASE ( 't_surf_v(1)' )
+#if defined( __nopointer )        
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v(1)%t ) )                    &
+                      ALLOCATE( t_surf_v(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v(1)%t, tmp_surf_v(1)%t,        &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )                 
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v_1(1)%t ) )                  &
+                      ALLOCATE( t_surf_v_1(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v_1(1)%t, tmp_surf_v(1)%t,      &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_v(2)' )
+#if defined( __nopointer )          
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v(2)%t ) )                    &
+                      ALLOCATE( t_surf_v(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v(2)%t, tmp_surf_v(2)%t,        &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v_1(2)%t ) )                  &
+                      ALLOCATE( t_surf_v_1(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v_1(2)%t, tmp_surf_v(2)%t,      &
+                                        surf_usm_v(2)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                      
+             CASE ( 't_surf_v(3)' )
+#if defined( __nopointer )    
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v(3)%t ) )                    &
+                      ALLOCATE( t_surf_v(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v(3)%t, tmp_surf_v(3)%t,        &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_v_1(3)%t ) )                  &
+                      ALLOCATE( t_surf_v_1(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_v_1(3)%t, tmp_surf_v(3)%t,      &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_surf_green_h' )
+#if defined( __nopointer )                   
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_h ) )                   &
+                      ALLOCATE( t_surf_green_h(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_green_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_h, tmp_surf_green_h,      &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_h_1 ) )                 &
+                      ALLOCATE( t_surf_green_h_1(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_green_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_h_1, tmp_surf_green_h,    &
+                                        surf_usm_h%start_index,                &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_green_v(0)' )
+#if defined( __nopointer )            
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v(0)%t ) )              &
+                      ALLOCATE( t_surf_green_v(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v(0)%t,                   &
+                                        tmp_surf_green_v(0)%t,                 &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(0)%t ) )            &
+                      ALLOCATE( t_surf_green_v_1(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v_1(0)%t,                 &
+                                        tmp_surf_green_v(0)%t,                 &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                   
+             CASE ( 't_surf_green_v(1)' )
+#if defined( __nopointer )        
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v(1)%t ) )              &
+                      ALLOCATE( t_surf_green_v(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v(1)%t,                   &
+                                        tmp_surf_green_v(1)%t,                 &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )                 
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(1)%t ) )            &
+                      ALLOCATE( t_surf_green_v_1(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v_1(1)%t,                 &
+                                        tmp_surf_green_v(1)%t,                 &
+                                        surf_usm_v(1)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_green_v(2)' )
+#if defined( __nopointer )          
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v(2)%t ) )              &
+                      ALLOCATE( t_surf_green_v(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v(2)%t,                   & 
+                                        tmp_surf_green_v(2)%t,                 &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(2)%t ) )            &
+                      ALLOCATE( t_surf_green_v_1(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v_1(2)%t,                 &
+                                        tmp_surf_green_v(2)%t,                 &
+                                        surf_usm_v(2)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                   
+             CASE ( 't_surf_green_v(3)' )
+#if defined( __nopointer )    
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v(3)%t ) )              &
+                      ALLOCATE( t_surf_green_v(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v(3)%t,                   &
+                                        tmp_surf_green_v(3)%t,                 &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(3)%t ) )            &
+                      ALLOCATE( t_surf_green_v_1(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_green_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_green_v_1(3)%t,                 & 
+                                        tmp_surf_green_v(3)%t,                 &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_surf_window_h' )
+#if defined( __nopointer )                   
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_h ) )                  &
+                      ALLOCATE( t_surf_window_h(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_window_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_h, tmp_surf_window_h,    &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_h_1 ) )                &
+                      ALLOCATE( t_surf_window_h_1(1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_surf_window_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_h_1,                     &
+                                        tmp_surf_window_h,                     &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_window_v(0)' )
+#if defined( __nopointer )            
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v(0)%t ) )             &
+                      ALLOCATE( t_surf_window_v(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v(0)%t,                  &
+                                        tmp_surf_window_v(0)%t,                &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(0)%t ) )           &
+                      ALLOCATE( t_surf_window_v_1(0)%t(1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v_1(0)%t,                &
+                                        tmp_surf_window_v(0)%t,                &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                   
+             CASE ( 't_surf_window_v(1)' )
+#if defined( __nopointer )        
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v(1)%t ) )             &
+                      ALLOCATE( t_surf_window_v(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v(1)%t,                  & 
+                                        tmp_surf_window_v(1)%t,                &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )                 
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(1)%t ) )           &
+                      ALLOCATE( t_surf_window_v_1(1)%t(1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v_1(1)%t,                &
+                                        tmp_surf_window_v(1)%t,                &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+
+             CASE ( 't_surf_window_v(2)' )
+#if defined( __nopointer )          
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v(2)%t ) )             &
+                      ALLOCATE( t_surf_window_v(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v(2)%t,                  &
+                                        tmp_surf_window_v(2)%t,                &
+                                        surf_usm_v(2)%start_index,             &   
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(2)%t ) )           &
+                      ALLOCATE( t_surf_window_v_1(2)%t(1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v_1(2)%t,                & 
+                                        tmp_surf_window_v(2)%t,                &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+                   
+             CASE ( 't_surf_window_v(3)' )
+#if defined( __nopointer )    
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v(3)%t ) )             &
+                      ALLOCATE( t_surf_window_v(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v(3)%t,                  &
+                                        tmp_surf_window_v(3)%t,                &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else                      
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(3)%t ) )           &
+                      ALLOCATE( t_surf_window_v_1(3)%t(1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_surf_window_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_surf_window_v_1(3)%t,                &  
+                                        tmp_surf_window_v(3)%t,                &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_wall_h' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_h ) )                         &
+                      ALLOCATE( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_wall_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_h, tmp_wall_h,                  &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_h_1 ) )                       &
+                      ALLOCATE( t_wall_h_1(nzb_wall:nzt_wall+1,                &
+                                           1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_wall_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_h_1, tmp_wall_h,                &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_wall_v(0)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v(0)%t ) )                    &
+                      ALLOCATE( t_wall_v(0)%t(nzb_wall:nzt_wall+1,             &
+                                              1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_wall_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v(0)%t, tmp_wall_v(0)%t,        &
+                                        surf_usm_v(0)%start_index,             &    
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v_1(0)%t ) )                  &
+                      ALLOCATE( t_wall_v_1(0)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_wall_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v_1(0)%t, tmp_wall_v(0)%t,      &
+                                        surf_usm_v(0)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_wall_v(1)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v(1)%t ) )                    &
+                      ALLOCATE( t_wall_v(1)%t(nzb_wall:nzt_wall+1,             &
+                                              1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_wall_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v(1)%t, tmp_wall_v(1)%t,        &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v_1(1)%t ) )                  &
+                      ALLOCATE( t_wall_v_1(1)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_wall_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v_1(1)%t, tmp_wall_v(1)%t,      &
+                                        surf_usm_v(1)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_wall_v(2)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v(2)%t ) )                    &
+                      ALLOCATE( t_wall_v(2)%t(nzb_wall:nzt_wall+1,             &
+                                              1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_wall_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v(2)%t, tmp_wall_v(2)%t,        &
+                                        surf_usm_v(2)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v_1(2)%t ) )                  &
+                      ALLOCATE( t_wall_v_1(2)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_wall_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v_1(2)%t, tmp_wall_v(2)%t,      &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_wall_v(3)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v(3)%t ) )                    &
+                      ALLOCATE( t_wall_v(3)%t(nzb_wall:nzt_wall+1,             &
+                                              1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_wall_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v(3)%t, tmp_wall_v(3)%t,        &
+                                        surf_usm_v(3)%start_index,             &   
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_wall_v_1(3)%t ) )                  &
+                      ALLOCATE( t_wall_v_1(3)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_wall_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_wall_v_1(3)%t, tmp_wall_v(3)%t,      &
+                                        surf_usm_v(3)%start_index,             &   
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_green_h' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_h ) )                        &
+                      ALLOCATE( t_green_h(nzb_wall:nzt_wall+1,                 &
+                                          1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_green_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_h, tmp_green_h,                &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_h_1 ) )                      &
+                      ALLOCATE( t_green_h_1(nzb_wall:nzt_wall+1,               &
+                                            1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_green_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_h_1, tmp_green_h,              &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_green_v(0)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v(0)%t ) )                   &
+                      ALLOCATE( t_green_v(0)%t(nzb_wall:nzt_wall+1,            &
+                                               1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_green_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v(0)%t, tmp_green_v(0)%t,      &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v_1(0)%t ) )                 &
+                      ALLOCATE( t_green_v_1(0)%t(nzb_wall:nzt_wall+1,          &
+                                                 1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_green_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v_1(0)%t, tmp_green_v(0)%t,    &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_green_v(1)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v(1)%t ) )                   &
+                      ALLOCATE( t_green_v(1)%t(nzb_wall:nzt_wall+1,            &
+                                               1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_green_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v(1)%t, tmp_green_v(1)%t,      &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v_1(1)%t ) )                 &
+                      ALLOCATE( t_green_v_1(1)%t(nzb_wall:nzt_wall+1,          &
+                                                 1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_green_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v_1(1)%t, tmp_green_v(1)%t,    &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_green_v(2)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v(2)%t ) )                   &
+                      ALLOCATE( t_green_v(2)%t(nzb_wall:nzt_wall+1,            &
+                                               1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_green_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v(2)%t, tmp_green_v(2)%t,      &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v_1(2)%t ) )                 &
+                      ALLOCATE( t_green_v_1(2)%t(nzb_wall:nzt_wall+1,          &
+                                                 1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_green_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v_1(2)%t, tmp_green_v(2)%t,    &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_green_v(3)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v(3)%t ) )                   &
+                      ALLOCATE( t_green_v(3)%t(nzb_wall:nzt_wall+1,            &
+                                               1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_green_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v(3)%t, tmp_green_v(3)%t,      &
+                                        surf_usm_v(3)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_green_v_1(3)%t ) )                 &
+                      ALLOCATE( t_green_v_1(3)%t(nzb_wall:nzt_wall+1,          &
+                                                 1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_green_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_green_v_1(3)%t, tmp_green_v(3)%t,    &
+                                        surf_usm_v(3)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_window_h' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_h ) )                       &
+                      ALLOCATE( t_window_h(nzb_wall:nzt_wall+1,                &
+                                           1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_window_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_h, tmp_window_h,              &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_h_1 ) )                     &
+                      ALLOCATE( t_window_h_1(nzb_wall:nzt_wall+1,              &
+                                             1:surf_usm_h%ns) )
+                   READ ( 13 )  tmp_window_h
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_h_1, tmp_window_h,            &
+                                        surf_usm_h%start_index,                & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+#endif
+             CASE ( 't_window_v(0)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v(0)%t ) )                  &
+                      ALLOCATE( t_window_v(0)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_window_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v(0)%t, tmp_window_v(0)%t,    &
+                                        surf_usm_v(0)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v_1(0)%t ) )                &
+                      ALLOCATE( t_window_v_1(0)%t(nzb_wall:nzt_wall+1,         &
+                                                  1:surf_usm_v(0)%ns) )
+                   READ ( 13 )  tmp_window_v(0)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v_1(0)%t,                     & 
+                                        tmp_window_v(0)%t,                     &
+                                        surf_usm_v(0)%start_index,             &
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_window_v(1)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v(1)%t ) )                  &
+                      ALLOCATE( t_window_v(1)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_window_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v(1)%t, tmp_window_v(1)%t,    &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v_1(1)%t ) )                &
+                      ALLOCATE( t_window_v_1(1)%t(nzb_wall:nzt_wall+1,         &
+                                                  1:surf_usm_v(1)%ns) )
+                   READ ( 13 )  tmp_window_v(1)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v_1(1)%t,                     & 
+                                        tmp_window_v(1)%t,                     &
+                                        surf_usm_v(1)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_window_v(2)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v(2)%t ) )                  &
+                      ALLOCATE( t_window_v(2)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_window_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v(2)%t, tmp_window_v(2)%t,    &
+                                        surf_usm_v(2)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v_1(2)%t ) )                &
+                      ALLOCATE( t_window_v_1(2)%t(nzb_wall:nzt_wall+1,         &
+                                                  1:surf_usm_v(2)%ns) )
+                   READ ( 13 )  tmp_window_v(2)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v_1(2)%t,                     & 
+                                        tmp_window_v(2)%t,                     &
+                                        surf_usm_v(2)%start_index,             &  
+                                        start_index_on_file,                   &
+                                        end_index_on_file ,                    &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE ( 't_window_v(3)' )
+#if defined( __nopointer )
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v(3)%t ) )                  &
+                      ALLOCATE( t_window_v(3)%t(nzb_wall:nzt_wall+1,           &
+                                                1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_window_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v(3)%t, tmp_window_v(3)%t,    &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#else
+                IF ( k == 1 )  THEN
+                   IF ( .NOT.  ALLOCATED( t_window_v_1(3)%t ) )                &
+                      ALLOCATE( t_window_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
+                   READ ( 13 )  tmp_window_v(3)%t
+                ENDIF
+                CALL surface_restore_elements(                                 &
+                                        t_window_v_1(3)%t,                     & 
+                                        tmp_window_v(3)%t,                     &
+                                        surf_usm_v(3)%start_index,             & 
+                                        start_index_on_file,                   &
+                                        end_index_on_file,                     &
+                                        nxlc, nysc,                            &
+                                        nxlf, nxrf, nysf, nynf,                &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file,nxr_on_file )
+#endif
+             CASE DEFAULT
+
+                   found = .FALSE.
+
+          END SELECT
+
        
-       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  start_index_on_file
-       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  end_index_on_file
-       
-       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  tmp_surf_h, tmp_surf_window_h, tmp_surf_green_h
-       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tmp_wall_h, tmp_window_h, tmp_green_h
-       
-       TYPE( t_surf_vertical ), DIMENSION(0:3) ::  tmp_surf_v, tmp_surf_window_v, tmp_surf_green_v
-       TYPE( t_wall_vertical ), DIMENSION(0:3) ::  tmp_wall_v, tmp_window_v, tmp_green_v
-
-       
-       IF ( initializing_actions == 'read_restart_data'  .OR.                  &
-            initializing_actions == 'cyclic_fill' )  THEN
-          
-!
-!--       Read number of respective surface elements on file
-          READ ( 13 ) field_chr
-          IF ( TRIM( field_chr ) /= 'ns_h_on_file_usm' )  THEN
-!
-!--          Add a proper error message
-          ENDIF
-          READ ( 13 ) ns_h_on_file_usm
-
-          READ ( 13 )  field_chr
-          IF ( TRIM( field_chr ) /= 'ns_v_on_file_usm' )  THEN
-!
-!--          Add a proper error message
-          ENDIF
-          READ ( 13 ) ns_v_on_file_usm
-!
-!--       Allocate temporary arrays for reading data on file. Note, the
-!--       size of allocated surface elements do not necessarily need to match
-!--       the size of present surface elements on current processor, as the 
-!--       number of processors between restarts can change. 
-          ALLOCATE( tmp_surf_h(1:ns_h_on_file_usm) )
-          ALLOCATE( tmp_wall_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
-          ALLOCATE( tmp_surf_window_h(1:ns_h_on_file_usm) )
-          ALLOCATE( tmp_window_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
-          ALLOCATE( tmp_surf_green_h(1:ns_h_on_file_usm) )
-          ALLOCATE( tmp_green_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
-          
-          DO  l = 0, 3
-             ALLOCATE( tmp_surf_v(l)%t(1:ns_v_on_file_usm(l)) )
-             ALLOCATE( tmp_wall_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
-             ALLOCATE( tmp_surf_window_v(l)%t(1:ns_v_on_file_usm(l)) )
-             ALLOCATE( tmp_window_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
-             ALLOCATE( tmp_surf_green_v(l)%t(1:ns_v_on_file_usm(l)) )
-             ALLOCATE( tmp_green_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
-          ENDDO
-          
-       
-          READ ( 13 )  field_chr
-
-          DO  WHILE ( TRIM( field_chr ) /= '*** end usm ***' )
-!
-!--          Map data on file as often as needed (data are read only for k=1)
-             DO  kk = 1, overlap_count
-!
-!--             Get the index range of the subdomain on file which overlap with the
-!--             current subdomain
-                nxlf = nxlfa(ii,kk)
-                nxlc = nxlfa(ii,kk) + offset_xa(ii,kk)
-                nxrf = nxrfa(ii,kk)
-                nxrc = nxrfa(ii,kk) + offset_xa(ii,kk)
-                nysf = nysfa(ii,kk)
-                nysc = nysfa(ii,kk) + offset_ya(ii,kk)
-                nynf = nynfa(ii,kk)
-                nync = nynfa(ii,kk) + offset_ya(ii,kk)
-
-                SELECT CASE ( TRIM( field_chr ) )     
-                
-                   CASE ( 'usm_start_index_h', 'usm_start_index_v'  )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  start_index_on_file
-                      
-                   CASE ( 'usm_end_index_h', 'usm_end_index_v' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  end_index_on_file
-                
-                   CASE ( 't_surf_h' )
-#if defined( __nopointer )                   
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_h ) )                   &
-                            ALLOCATE( t_surf_h(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_h, tmp_surf_h,            &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_h_1 ) )                 &
-                            ALLOCATE( t_surf_h_1(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_h_1, tmp_surf_h,          &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_v(0)' )
-#if defined( __nopointer )            
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v(0)%t ) )              &
-                            ALLOCATE( t_surf_v(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v(0)%t, tmp_surf_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v_1(0)%t ) )            &
-                            ALLOCATE( t_surf_v_1(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v_1(0)%t, tmp_surf_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_v(1)' )
-#if defined( __nopointer )        
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v(1)%t ) )              &
-                            ALLOCATE( t_surf_v(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v(1)%t, tmp_surf_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )                 
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v_1(1)%t ) )            &
-                            ALLOCATE( t_surf_v_1(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v_1(1)%t, tmp_surf_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_v(2)' )
-#if defined( __nopointer )          
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v(2)%t ) )              &
-                            ALLOCATE( t_surf_v(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v(2)%t, tmp_surf_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v_1(2)%t ) )            &
-                            ALLOCATE( t_surf_v_1(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v_1(2)%t, tmp_surf_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_v(3)' )
-#if defined( __nopointer )    
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v(3)%t ) )              &
-                            ALLOCATE( t_surf_v(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v(3)%t, tmp_surf_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_v_1(3)%t ) )            &
-                            ALLOCATE( t_surf_v_1(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_v_1(3)%t, tmp_surf_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_surf_green_h' )
-#if defined( __nopointer )                   
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_h ) )                   &
-                            ALLOCATE( t_surf_green_h(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_green_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_h, tmp_surf_green_h, &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_h_1 ) )                 &
-                            ALLOCATE( t_surf_green_h_1(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_green_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_h_1, tmp_surf_green_h, &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_green_v(0)' )
-#if defined( __nopointer )            
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v(0)%t ) )              &
-                            ALLOCATE( t_surf_green_v(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v(0)%t, tmp_surf_green_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v_1(0)%t ) )            &
-                            ALLOCATE( t_surf_green_v_1(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v_1(0)%t, tmp_surf_green_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_green_v(1)' )
-#if defined( __nopointer )        
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v(1)%t ) )              &
-                            ALLOCATE( t_surf_green_v(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v(1)%t, tmp_surf_green_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )                 
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v_1(1)%t ) )            &
-                            ALLOCATE( t_surf_green_v_1(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v_1(1)%t, tmp_surf_green_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_green_v(2)' )
-#if defined( __nopointer )          
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v(2)%t ) )              &
-                            ALLOCATE( t_surf_green_v(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v(2)%t, tmp_surf_green_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v_1(2)%t ) )            &
-                            ALLOCATE( t_surf_green_v_1(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v_1(2)%t, tmp_surf_green_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_green_v(3)' )
-#if defined( __nopointer )    
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v(3)%t ) )              &
-                            ALLOCATE( t_surf_green_v(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v(3)%t, tmp_surf_green_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_green_v_1(3)%t ) )            &
-                            ALLOCATE( t_surf_green_v_1(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_green_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_green_v_1(3)%t, tmp_surf_green_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_surf_window_h' )
-#if defined( __nopointer )                   
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_h ) )                   &
-                            ALLOCATE( t_surf_window_h(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_window_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_h, tmp_surf_window_h,            &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_h_1 ) )                 &
-                            ALLOCATE( t_surf_window_h_1(1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_surf_window_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_h_1, tmp_surf_window_h,          &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_window_v(0)' )
-#if defined( __nopointer )            
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v(0)%t ) )              &
-                            ALLOCATE( t_surf_window_v(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v(0)%t, tmp_surf_window_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v_1(0)%t ) )            &
-                            ALLOCATE( t_surf_window_v_1(0)%t(1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v_1(0)%t, tmp_surf_window_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_window_v(1)' )
-#if defined( __nopointer )        
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v(1)%t ) )              &
-                            ALLOCATE( t_surf_window_v(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v(1)%t, tmp_surf_window_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )                 
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v_1(1)%t ) )            &
-                            ALLOCATE( t_surf_window_v_1(1)%t(1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v_1(1)%t, tmp_surf_window_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-
-                   CASE ( 't_surf_window_v(2)' )
-#if defined( __nopointer )          
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v(2)%t ) )              &
-                            ALLOCATE( t_surf_window_v(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v(2)%t, tmp_surf_window_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v_1(2)%t ) )            &
-                            ALLOCATE( t_surf_window_v_1(2)%t(1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v_1(2)%t, tmp_surf_window_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                         
-                   CASE ( 't_surf_window_v(3)' )
-#if defined( __nopointer )    
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v(3)%t ) )              &
-                            ALLOCATE( t_surf_window_v(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v(3)%t, tmp_surf_window_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else                      
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_surf_window_v_1(3)%t ) )            &
-                            ALLOCATE( t_surf_window_v_1(3)%t(1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_surf_window_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_surf_window_v_1(3)%t, tmp_surf_window_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_wall_h' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_h ) )                   &
-                            ALLOCATE( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_wall_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_h, tmp_wall_h,            &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_h_1 ) )                 &
-                            ALLOCATE( t_wall_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_wall_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_h_1, tmp_wall_h,          &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_wall_v(0)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v(0)%t ) )              &
-                            ALLOCATE( t_wall_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_wall_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v(0)%t, tmp_wall_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v_1(0)%t ) )            &
-                            ALLOCATE( t_wall_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_wall_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v_1(0)%t, tmp_wall_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_wall_v(1)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v(1)%t ) )              &
-                            ALLOCATE( t_wall_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_wall_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v(1)%t, tmp_wall_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,              &
-                                              nxlc, nysc,                      &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v_1(1)%t ) )            &
-                            ALLOCATE( t_wall_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_wall_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v_1(1)%t, tmp_wall_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_wall_v(2)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v(2)%t ) )              &
-                            ALLOCATE( t_wall_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_wall_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v(2)%t, tmp_wall_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v_1(2)%t ) )            &
-                            ALLOCATE( t_wall_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_wall_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v_1(2)%t, tmp_wall_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_wall_v(3)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v(3)%t ) )              &
-                            ALLOCATE( t_wall_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_wall_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v(3)%t, tmp_wall_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_wall_v_1(3)%t ) )            &
-                            ALLOCATE( t_wall_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_wall_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_wall_v_1(3)%t, tmp_wall_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_green_h' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_h ) )                   &
-                            ALLOCATE( t_green_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_green_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_h, tmp_green_h,            &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_h_1 ) )                 &
-                            ALLOCATE( t_green_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_green_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_h_1, tmp_green_h,          &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_green_v(0)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v(0)%t ) )              &
-                            ALLOCATE( t_green_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_green_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v(0)%t, tmp_green_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v_1(0)%t ) )            &
-                            ALLOCATE( t_green_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_green_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v_1(0)%t, tmp_green_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_green_v(1)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v(1)%t ) )              &
-                            ALLOCATE( t_green_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_green_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v(1)%t, tmp_green_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,              &
-                                              nxlc, nysc,                      &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v_1(1)%t ) )            &
-                            ALLOCATE( t_green_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_green_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v_1(1)%t, tmp_green_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_green_v(2)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v(2)%t ) )              &
-                            ALLOCATE( t_green_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_green_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v(2)%t, tmp_green_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v_1(2)%t ) )            &
-                            ALLOCATE( t_green_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_green_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v_1(2)%t, tmp_green_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_green_v(3)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v(3)%t ) )              &
-                            ALLOCATE( t_green_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_green_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v(3)%t, tmp_green_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_green_v_1(3)%t ) )            &
-                            ALLOCATE( t_green_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_green_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_green_v_1(3)%t, tmp_green_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_window_h' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_h ) )                   &
-                            ALLOCATE( t_window_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_window_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_h, tmp_window_h,            &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_h_1 ) )                 &
-                            ALLOCATE( t_window_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                         READ ( 13 )  tmp_window_h
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_h_1, tmp_window_h,          &
-                                              surf_usm_h%start_index,          & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-#endif
-                   CASE ( 't_window_v(0)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v(0)%t ) )              &
-                            ALLOCATE( t_window_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_window_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v(0)%t, tmp_window_v(0)%t,  &
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v_1(0)%t ) )            &
-                            ALLOCATE( t_window_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
-                         READ ( 13 )  tmp_window_v(0)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v_1(0)%t, tmp_window_v(0)%t,&
-                                              surf_usm_v(0)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_window_v(1)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v(1)%t ) )              &
-                            ALLOCATE( t_window_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_window_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v(1)%t, tmp_window_v(1)%t,  &
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,              &
-                                              nxlc, nysc,                      &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v_1(1)%t ) )            &
-                            ALLOCATE( t_window_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                         READ ( 13 )  tmp_window_v(1)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v_1(1)%t, tmp_window_v(1)%t,&
-                                              surf_usm_v(1)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_window_v(2)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v(2)%t ) )              &
-                            ALLOCATE( t_window_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_window_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v(2)%t, tmp_window_v(2)%t,  &
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v_1(2)%t ) )            &
-                            ALLOCATE( t_window_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
-                         READ ( 13 )  tmp_window_v(2)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v_1(2)%t, tmp_window_v(2)%t,&
-                                              surf_usm_v(2)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file ,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE ( 't_window_v(3)' )
-#if defined( __nopointer )
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v(3)%t ) )              &
-                            ALLOCATE( t_window_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_window_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v(3)%t, tmp_window_v(3)%t,  &
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#else
-                      IF ( kk == 1 )  THEN
-                         IF ( .NOT.  ALLOCATED( t_window_v_1(3)%t ) )            &
-                            ALLOCATE( t_window_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
-                         READ ( 13 )  tmp_window_v(3)%t
-                      ENDIF
-                      CALL surface_restore_elements(                           &
-                                              t_window_v_1(3)%t, tmp_window_v(3)%t,&
-                                              surf_usm_v(3)%start_index,       & 
-                                              start_index_on_file,             &
-                                              end_index_on_file,               &
-                                              nxlc, nysc,                      &
-                                              nxlf, nxrf, nysf, nynf,          &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file,nxr_on_file )
-#endif
-                   CASE DEFAULT
-                      WRITE ( message_string, * )  'unknown variable named "', &
-                                        TRIM( field_chr ), '" found in',       &
-                                        '&data from prior run on PE ', myid
-                      CALL message( 'user_read_restart_data', 'UI0012', 1, 2, 0, 6, 0 )
-
-                END SELECT
-
-             ENDDO
-
-             READ ( 13 )  field_chr
-
-          ENDDO
-
-       ENDIF
-       
-    END SUBROUTINE usm_read_restart_data
+    END SUBROUTINE usm_rrd_local
     
 
@@ -7356,12 +7435,14 @@
 ! Description:
 ! ------------
-!> Subroutine writes t_surf and t_wall data into restart files
+!> Subroutine writes t_surf and t_wall data into restart files. It is necessary
+!> to write start_index and end_index several times
 !kanani: Renamed this routine according to corresponging routines in PALM
-!kanani: Modified the routine to match write_var_list, from where usm_write_restart_data
+!kanani: Modified the routine to match wrd_global, from where usm_wrd_local
 !        shall be called in the future. This part has not been tested yet. (see virtual_flight_mod)
 !        Also, I had some trouble with the allocation of t_surf, since this is a pointer.
 !        So, I added some directives here.
 !------------------------------------------------------------------------------!
-    SUBROUTINE usm_write_restart_data
+    SUBROUTINE usm_wrd_local
+
     
        IMPLICIT NONE
@@ -7369,62 +7450,85 @@
        CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name  
        INTEGER(iwp)     ::  l       !< index surface type orientation
+
+       CALL wrd_write_string( 'ns_h_on_file_usm' )
+       WRITE ( 14 )  surf_usm_h%ns
+
+       CALL wrd_write_string( 'ns_v_on_file_usm' )
+       WRITE ( 14 )  surf_usm_v(0:3)%ns
+
+       CALL wrd_write_string( 'usm_start_index_h' )
+       WRITE ( 14 )  surf_usm_h%start_index
+
+       CALL wrd_write_string( 'usm_end_index_h' )
+       WRITE ( 14 )  surf_usm_h%end_index
+
+       CALL wrd_write_string( 't_surf_h' )
+       WRITE ( 14 )  t_surf_h
+
+       CALL wrd_write_string( 't_surf_window_h' )
+       WRITE ( 14 )  t_surf_window_h
+
+       CALL wrd_write_string( 't_surf_green_h' )
+       WRITE ( 14 )  t_surf_green_h
+
+       DO  l = 0, 3
+
+          CALL wrd_write_string( 'usm_start_index_v' )
+          WRITE ( 14 )  surf_usm_v(l)%start_index
+
+          CALL wrd_write_string( 'usm_end_index_v' )
+          WRITE ( 14 )  surf_usm_v(l)%end_index
+
+          WRITE( dum, '(I1)')  l          
+
+          CALL wrd_write_string( 't_surf_v(' // dum // ')' )
+          WRITE ( 14 )  t_surf_v(l)%t
+
+          CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
+          WRITE ( 14 ) t_surf_window_v(l)%t     
+
+          CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
+          WRITE ( 14 ) t_surf_green_v(l)%t    
+          
+       ENDDO
+
+       CALL wrd_write_string( 'usm_start_index_h' )
+       WRITE ( 14 )  surf_usm_h%start_index
+
+       CALL wrd_write_string( 'usm_end_index_h' )
+       WRITE ( 14 )  surf_usm_h%end_index
+
+       CALL wrd_write_string( 't_wall_h' )
+       WRITE ( 14 )  t_wall_h
+
+       CALL wrd_write_string( 't_window_h' )
+       WRITE ( 14 )  t_window_h
+
+       CALL wrd_write_string( 't_green_h' )
+       WRITE ( 14 )  t_green_h
+
+       DO  l = 0, 3
+
+          CALL wrd_write_string( 'usm_start_index_v' )
+          WRITE ( 14 )  surf_usm_v(l)%start_index
+
+          CALL wrd_write_string( 'usm_end_index_v' )
+          WRITE ( 14 )  surf_usm_v(l)%end_index
+
+          WRITE( dum, '(I1)')  l     
+
+          CALL wrd_write_string( 't_wall_v(' // dum // ')' )
+          WRITE ( 14 )  t_wall_v(l)%t
+
+          CALL wrd_write_string( 't_window_v(' // dum // ')' )
+          WRITE ( 14 )  t_window_v(l)%t
+
+          CALL wrd_write_string( 't_green_v(' // dum // ')' )
+          WRITE ( 14 )  t_green_v(l)%t
        
-       WRITE ( 14 ) 'ns_h_on_file_usm              '
-       WRITE ( 14 ) surf_usm_h%ns
-       WRITE ( 14 ) 'ns_v_on_file_usm              '
-       WRITE ( 14 ) surf_usm_v(0:3)%ns
+       ENDDO
+
        
-       WRITE ( 14 ) 'usm_start_index_h             '
-       WRITE ( 14 ) surf_usm_h%start_index
-       WRITE ( 14 ) 'usm_end_index_h               '
-       WRITE ( 14 ) surf_usm_h%end_index
-       WRITE ( 14 ) 't_surf_h                      '
-       WRITE ( 14 ) t_surf_h
-       WRITE ( 14 ) 't_surf_window_h               '
-       WRITE ( 14 ) t_surf_window_h
-       WRITE ( 14 ) 't_surf_green_h                '
-       WRITE ( 14 ) t_surf_green_h
-       
-       DO  l = 0, 3
-          WRITE ( 14 ) 'usm_start_index_v             '
-          WRITE ( 14 ) surf_usm_v(l)%start_index
-          WRITE ( 14 ) 'usm_end_index_v               '
-          WRITE ( 14 ) surf_usm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 ) 't_surf_v(' // dum // ')                   ' 
-          WRITE ( 14 ) t_surf_v(l)%t          
-          WRITE ( 14 ) 't_surf_window_v(' // dum // ')            ' 
-          WRITE ( 14 ) t_surf_window_v(l)%t          
-          WRITE ( 14 ) 't_surf_green_v(' // dum // ')             ' 
-          WRITE ( 14 ) t_surf_green_v(l)%t          
-       ENDDO
-
-       WRITE ( 14 ) 'usm_start_index_h             '
-       WRITE ( 14 ) surf_usm_h%start_index
-       WRITE ( 14 ) 'usm_end_index_h               '
-       WRITE ( 14 ) surf_usm_h%end_index
-       WRITE ( 14 ) 't_wall_h                      '
-       WRITE ( 14 ) t_wall_h
-       WRITE ( 14 ) 't_window_h                    '
-       WRITE ( 14 ) t_window_h
-       WRITE ( 14 ) 't_green_h                     '
-       WRITE ( 14 ) t_green_h
-       DO  l = 0, 3
-          WRITE ( 14 ) 'usm_start_index_v             '
-          WRITE ( 14 ) surf_usm_v(l)%start_index
-          WRITE ( 14 ) 'usm_end_index_v               '
-          WRITE ( 14 ) surf_usm_v(l)%end_index
-          WRITE( dum, '(I1)')  l          
-          WRITE ( 14 )  't_wall_v(' // dum // ')                   ' 
-          WRITE ( 14 )  t_wall_v(l)%t          
-          WRITE ( 14 )  't_window_v(' // dum // ')                 ' 
-          WRITE ( 14 )  t_window_v(l)%t          
-          WRITE ( 14 )  't_green_v(' // dum // ')                  ' 
-          WRITE ( 14 )  t_green_v(l)%t          
-       ENDDO
-
-       WRITE ( 14 )  '*** end usm ***               '
-       
-    END SUBROUTINE usm_write_restart_data
+    END SUBROUTINE usm_wrd_local
 
 !
Index: palm/trunk/SOURCE/user_last_actions.f90
===================================================================
--- palm/trunk/SOURCE/user_last_actions.f90	(revision 2893)
+++ palm/trunk/SOURCE/user_last_actions.f90	(revision 2894)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Writing of user-defined restart data will be done in an own module called
+! user_write_restart_data_mod 
+! 
+! 2718 2018-01-02 08:49:38Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -66,14 +70,6 @@
 
 !
-!-- Here the user-defined actions at the end of a job follow.
-!-- Sample for user-defined output:
-    IF ( write_binary )  THEN
-!       IF ( ALLOCATED( u2_av ) )  THEN
-!          WRITE ( 14 )  'u2_av               ';  WRITE ( 14 )  u2_av
-!       ENDIF
+!-- Here the user-defined actions at the end of a job might follow.
 
-       WRITE ( 14 )  '*** end user ***    '
-
-    ENDIF
 
  END SUBROUTINE user_last_actions
Index: palm/trunk/SOURCE/user_module.f90
===================================================================
--- palm/trunk/SOURCE/user_module.f90	(revision 2893)
+++ palm/trunk/SOURCE/user_module.f90	(revision 2894)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! An example for a user defined global variable has been added (Giersch)
+! 
+! 2718 2018-01-02 08:49:38Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -82,4 +85,6 @@
 !
 !-- Sample for user-defined output
+!    REAL(wp) :: global_parameter !< user defined global parameter 
+!
 !    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u2       !< user defined array
 !    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u2_av    !< user defined array
Index: palm/trunk/SOURCE/user_read_restart_data.f90
===================================================================
--- palm/trunk/SOURCE/user_read_restart_data.f90	(revision 2893)
+++ 	(revision )
@@ -1,161 +1,0 @@
-!> @file user_read_restart_data.f90
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2018 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 2101 2017-01-05 16:42:31Z suehring
-!
-! 2000 2016-08-20 18:09:15Z knoop
-! Forced header and separation lines into 80 columns
-! 
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! kind-parameters added to all INTEGER and REAL declaration statements, 
-! kinds are defined in new module kinds, 
-! old module precision_kind is removed,
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements 
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 220 2008-12-18 07:00:36Z raasch
-! reading mechanism revised (subdomain/total domain size can vary arbitrarily
-! between current and previous run),
-! former file user_interface.f90 split into one file per subroutine
-!
-! Description:
-! ------------
-!> Reading restart data from file(s)
-!> Subdomain index limits on file are given by nxl_on_file, etc.
-!> Indices nxlc, etc. indicate the range of gridpoints to be mapped from the
-!> subdomain on file (f) to the subdomain of the current PE (c). They have been
-!> calculated in routine read_3d_binary.
-!------------------------------------------------------------------------------!
- SUBROUTINE user_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
-                                    nynfa, nyn_on_file, nysfa, nys_on_file,    &
-                                    offset_xa, offset_ya, overlap_count,       &
-                                    tmp_2d, tmp_3d )
- 
-
-    USE control_parameters
-        
-    USE indices
-    
-    USE kinds
-    
-    USE pegrid
-    
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=20) :: field_char   !< 
-
-    INTEGER(iwp) ::  i               !< 
-    INTEGER(iwp) ::  k               !< 
-    INTEGER(iwp) ::  nxlc            !< 
-    INTEGER(iwp) ::  nxlf            !< 
-    INTEGER(iwp) ::  nxl_on_file     !< 
-    INTEGER(iwp) ::  nxrc            !< 
-    INTEGER(iwp) ::  nxrf            !< 
-    INTEGER(iwp) ::  nxr_on_file     !< 
-    INTEGER(iwp) ::  nync            !< 
-    INTEGER(iwp) ::  nynf            !< 
-    INTEGER(iwp) ::  nyn_on_file     !< 
-    INTEGER(iwp) ::  nysc            !< 
-    INTEGER(iwp) ::  nysf            !< 
-    INTEGER(iwp) ::  nys_on_file     !< 
-    INTEGER(iwp) ::  overlap_count   !< 
-
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_2d   !< 
-
-    REAL(wp),                                                                  &
-       DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
-          tmp_3d   !< 
-
-!
-!-- Here the reading of user-defined restart data follows:
-!-- Sample for user-defined output
-!
-!    IF ( initializing_actions == 'read_restart_data' )  THEN
-!       READ ( 13 )  field_char
-!       DO  WHILE ( TRIM( field_char ) /= '*** end user ***' )
-!
-!          DO  k = 1, overlap_count
-!
-!             nxlf = nxlfa(i,k)
-!             nxlc = nxlfa(i,k) + offset_xa(i,k)
-!             nxrf = nxrfa(i,k)
-!             nxrc = nxrfa(i,k) + offset_xa(i,k)
-!             nysf = nysfa(i,k)
-!             nysc = nysfa(i,k) + offset_ya(i,k)
-!             nynf = nynfa(i,k)
-!             nync = nynfa(i,k) + offset_ya(i,k)
-!
-!
-!             SELECT CASE ( TRIM( field_char ) )
-!
-!                CASE ( 'u2_av' )
-!                   IF ( .NOT. ALLOCATED( u2_av ) ) THEN
-!                      ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-!                   ENDIF
-!                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-!                   u2_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
-!                                          tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-!
-!                CASE DEFAULT
-!                   WRITE( message_string, * ) 'unknown variable named "',       &
-!                                         TRIM( field_char ), '" found in',      &
-!                                         '&data from prior run on PE ', myid
-!                   CALL message( 'user_read_restart_data', 'UI0012', 1, 2, 0, 6, 0 )
-!
-!             END SELECT
-!
-!          ENDDO
-!
-!          READ ( 13 )  field_char
-!
-!       ENDDO
-!    ENDIF
-
- END SUBROUTINE user_read_restart_data
-
Index: palm/trunk/SOURCE/user_read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/user_read_restart_data_mod.f90	(revision 2894)
+++ palm/trunk/SOURCE/user_read_restart_data_mod.f90	(revision 2894)
@@ -0,0 +1,165 @@
+!> @file user_read_restart_data_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision
+!
+!
+! Description:
+! ------------
+!> Reads user specific restart data into binary file(s) for restart runs.
+!------------------------------------------------------------------------------!
+ MODULE user_read_restart_data_mod
+
+
+    USE user
+     
+
+    IMPLICIT NONE
+
+
+    INTERFACE user_rrd_global
+       MODULE PROCEDURE user_rrd_global
+    END INTERFACE user_rrd_global
+
+    INTERFACE user_rrd_local
+       MODULE PROCEDURE user_rrd_local
+    END INTERFACE user_rrd_local
+
+
+    PUBLIC user_rrd_global, user_rrd_local
+
+
+ CONTAINS
+
+
+!-------------
+! Description:
+! ------------
+!> Reading global restart data that has been defined by the user.
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_rrd_global( found )
+
+
+       USE control_parameters,                                                 &
+           ONLY: length, restart_string
+
+
+       IMPLICIT NONE
+
+       LOGICAL, INTENT(OUT)  ::  found 
+
+
+       found = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
+
+          CASE ( 'global_paramter' )
+!             READ ( 13 )  global_parameter
+
+          CASE DEFAULT
+ 
+             found = .FALSE.
+
+       END SELECT  
+
+
+    END SUBROUTINE user_rrd_global
+
+
+! Description:
+! ------------
+!> Reading processor specific restart data from file(s) that has been defined 
+!> by the user.
+!> Subdomain index limits on file are given by nxl_on_file, etc.
+!> Indices nxlc, etc. indicate the range of gridpoints to be mapped from the
+!> subdomain on file (f) to the subdomain of the current PE (c). They have been
+!> calculated in routine rrd_local.
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,      &
+                               nxr_on_file, nynf, nync, nyn_on_file, nysf,     & 
+                               nysc, nys_on_file, tmp_3d, found )
+    
+
+       USE control_parameters
+           
+       USE indices
+       
+       USE kinds
+       
+       USE pegrid
+ 
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  i               !< 
+       INTEGER(iwp) ::  k               !< 
+       INTEGER(iwp) ::  nxlc            !< 
+       INTEGER(iwp) ::  nxlf            !< 
+       INTEGER(iwp) ::  nxl_on_file     !< 
+       INTEGER(iwp) ::  nxrc            !< 
+       INTEGER(iwp) ::  nxrf            !< 
+       INTEGER(iwp) ::  nxr_on_file     !< 
+       INTEGER(iwp) ::  nync            !< 
+       INTEGER(iwp) ::  nynf            !< 
+       INTEGER(iwp) ::  nyn_on_file     !< 
+       INTEGER(iwp) ::  nysc            !< 
+       INTEGER(iwp) ::  nysf            !< 
+       INTEGER(iwp) ::  nys_on_file     !< 
+
+       LOGICAL, INTENT(OUT)  ::  found 
+
+       REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !< 
+
+!
+!-- Here the reading of user-defined restart data follows:
+!-- Sample for user-defined output
+
+
+       found = .TRUE.
+
+
+          SELECT CASE ( restart_string(1:length) )
+
+             CASE ( 'u2_av' )
+!                IF ( .NOT. ALLOCATED( u2_av ) ) THEN
+!                     ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+!                ENDIF
+!                IF ( k == 1 )  READ ( 13 )  tmp_3d
+!                   u2_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
+!                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+!
+             CASE DEFAULT
+
+                found = .FALSE.
+
+             END SELECT
+
+
+    END SUBROUTINE user_rrd_local
+
+
+ END MODULE user_read_restart_data_mod
Index: palm/trunk/SOURCE/user_write_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/user_write_restart_data_mod.f90	(revision 2894)
+++ palm/trunk/SOURCE/user_write_restart_data_mod.f90	(revision 2894)
@@ -0,0 +1,101 @@
+!> @file user_write_restart_data_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision
+! 
+!
+! Description:
+! ------------
+!> Writes user specific restart data into binary file(s) for restart runs.
+!------------------------------------------------------------------------------!
+ MODULE user_write_restart_data_mod
+
+
+    USE user
+     
+
+    IMPLICIT NONE
+
+
+    INTERFACE user_wrd_global
+       MODULE PROCEDURE user_wrd_global
+    END INTERFACE user_wrd_global
+
+    INTERFACE user_wrd_local
+       MODULE PROCEDURE user_wrd_local
+    END INTERFACE user_wrd_local
+
+
+    PUBLIC user_wrd_global, user_wrd_local
+
+
+ CONTAINS
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Writes global and user-defined restart data into binary file(s) for restart
+!> runs.
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_wrd_global  
+
+
+       IMPLICIT NONE
+
+       
+!       CALL wrd_write_string( 'global_parameter' )
+!       WRITE ( 14 )  global_parameter
+
+       
+    END SUBROUTINE user_wrd_global    
+
+
+! Description:
+! ------------
+!> Writes processor specific and user-defined restart data into binary file(s) 
+!> for restart runs.
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_wrd_local
+
+
+       IMPLICIT NONE
+
+
+!
+!-- Here the user-defined actions at the end of a job follow.
+!-- Sample for user-defined output:
+!          IF ( ALLOCATED( u2_av ) )  THEN
+!             CALL wrd_write_string( 'u2_av' )  
+!             WRITE ( 14 )  u2_av
+!          ENDIF
+
+
+
+    END SUBROUTINE user_wrd_local
+
+
+ END MODULE user_write_restart_data_mod
Index: palm/trunk/SOURCE/uv_exposure_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/uv_exposure_model_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/uv_exposure_model_mod.f90	(revision 2894)
@@ -25,4 +25,14 @@
 ! -----------------
 ! $Id$
+! Routine for skipping global restart data has been removed, uvem_last_actions
+! has been renamed to uvem_wrd_global and uvem_read_restart_data has been 
+! renamed to uvem_rrd_global, variable named found has been introduced for 
+! checking if restart data was found, reading of restart strings has been moved
+! completely to read_restart_data_mod, marker *** end new module *** has been
+! removed, strings and their respective lengths are written out and read now 
+! in case of restart runs to get rid of prescribed character lengths, CASE 
+! DEFAULT was added if restart data is read 
+! 
+! 2848 2018-03-05 10:11:18Z Giersch
 ! Initial revision
 !
@@ -199,7 +209,7 @@
 ! !
 ! !-- Writing of binary output for restart runs  !!! renaming?!
-!     INTERFACE uvem_last_actions
-!        MODULE PROCEDURE uvem_last_actions
-!     END INTERFACE uvem_last_actions
+!     INTERFACE uvem_wrd_global
+!        MODULE PROCEDURE uvem_wrd_global
+!     END INTERFACE uvem_wrd_global
 !     
 !
@@ -211,13 +221,7 @@
 ! !
 ! !-- Reading of parameters for restart runs
-!     INTERFACE uvem_read_restart_data
-!        MODULE PROCEDURE uvem_read_restart_data
-!     END INTERFACE uvem_read_restart_data
-! 
-! !
-! !-- Writing of parameters for restart runs !!! renaming?!
-!     INTERFACE uvem_skip_var_list
-!        MODULE PROCEDURE uvem_skip_var_list
-!     END INTERFACE uvem_skip_var_list
+!     INTERFACE uvem_rrd_global
+!        MODULE PROCEDURE uvem_rrd_global
+!     END INTERFACE uvem_rrd_global
 ! 
 ! !
@@ -860,30 +864,33 @@
 ! ! Description:
 ! ! ------------
-! !> This routine reads the respective restart data.
+! !> This routine reads the global restart data.
 ! !------------------------------------------------------------------------------!
-!  SUBROUTINE uvem_read_restart_data  
-! 
-!     
+!  SUBROUTINE uvem_rrd_global
+!
+!
+!     USE control_parameters,                                                    &
+!         ONLY: length, restart_string
+!
+!
 !     IMPLICIT NONE
-!        
-!     CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
+!
+!     LOGICAL, INTENT(OUT)  ::  found 
+!
+!
+!     found = .TRUE. 
 !        
 !        
-!     READ ( 13 )  variable_chr
-!     DO  WHILE ( TRIM( variable_chr ) /= '*** end new module ***' )
-! 
-!        SELECT CASE ( TRIM( variable_chr ) )
-!           
-! !           CASE ( 'param1' )
-! !              IF ( .NOT. ALLOCATED( param1 ) )  ALLOCATE( param1(...) )
-! !              READ ( 13 )  param1   
-!           
-!        END SELECT
-!           
-!        READ ( 13 )  variable_chr
-!           
-!     ENDDO
-! 
-!  END SUBROUTINE uvem_read_restart_data  
+!     SELECT CASE ( restart_string(1:length) )
+!
+!       CASE ( 'param1' )
+!          READ ( 13 )  param1
+!
+!        CASE DEFAULT
+!
+!          found = .FALSE.   
+!
+!     END SELECT
+! 
+!  END SUBROUTINE uvem_rrd_global  
     
 
@@ -891,37 +898,18 @@
 ! ! Description:
 ! ! ------------
-! !> This routine writes the respective restart data.
+! !> This routine writes the global restart data.
 ! !------------------------------------------------------------------------------!
-!  SUBROUTINE uvem_last_actions
-! 
+!  SUBROUTINE uvem_wrd_global
+! 
+!
 !     IMPLICIT NONE
+!
+!
+!     CALL wrd_write_string( 'param1' )
+!     WRITE ( 14 )  param1         
+! 
 !        
-! !      WRITE ( 14 )  'param1                            '
-! !      WRITE ( 14 )  param1       
-! 
 !        
-!     WRITE ( 14 )  '*** end new module ***            '
-!        
-!  END SUBROUTINE uvem_last_actions   
-
-
-! !------------------------------------------------------------------------------!
-! ! Description:
-! ! ------------
-! !> Skipping of parameters from restart file (binary format).
-! !------------------------------------------------------------------------------!
-!  SUBROUTINE uvem_skip_var_list  
-!            
-!     IMPLICIT NONE
-!        
-!     CHARACTER (LEN=1)  ::  param2         !<
-!     CHARACTER (LEN=30) ::  variable_chr   !<
-!        
-!     READ ( 13 )  variable_chr
-!     DO  WHILE ( TRIM( variable_chr ) /= '*** end new module ***' )
-!        READ ( 13 )  param2
-!     ENDDO    
-!        
-!  END SUBROUTINE uvem_skip_var_list 
+!  END SUBROUTINE uvem_wrd_global   
 
 
Index: palm/trunk/SOURCE/virtual_flight_mod.f90
===================================================================
--- palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 2894)
@@ -25,4 +25,15 @@
 ! -----------------
 ! $Id$
+! variable named found has been introduced for checking if restart data was 
+! found, reading of restart strings has been moved completely to 
+! read_restart_data_mod, virtual_flight_prerun flag has been removed, redundant
+! skipping function has been removed, flight_read/write_restart_data 
+! have been renamed to flight_r/wrd_global, flight_rrd_global is called in 
+! read_restart_data_mod now, marker *** end flight *** was removed, strings and
+! their respective lengths are written out and read now in case of restart runs
+! to get rid of prescribed character lengths, CASE DEFAULT was added if restart
+! data is read
+! 
+! 2872 2018-03-12 10:05:47Z Giersch
 ! virutal_flight_prerun flag is used to define if module 
 ! related parameters were outputted as restart data
@@ -66,6 +77,5 @@
  
     USE control_parameters,                                                    &
-        ONLY:  fl_max, num_leg, num_var_fl, num_var_fl_user, virtual_flight,   &
-               virtual_flight_prerun
+        ONLY:  fl_max, num_leg, num_var_fl, num_var_fl_user, virtual_flight
  
     USE kinds
@@ -134,16 +144,12 @@
        MODULE PROCEDURE flight_measurement
     END INTERFACE flight_measurement
-
-    INTERFACE flight_skip_var_list 
-       MODULE PROCEDURE flight_skip_var_list
-    END INTERFACE flight_skip_var_list
-    
-    INTERFACE flight_read_restart_data 
-       MODULE PROCEDURE flight_read_restart_data
-    END INTERFACE flight_read_restart_data
-    
-    INTERFACE flight_write_restart_data 
-       MODULE PROCEDURE flight_write_restart_data 
-    END INTERFACE flight_write_restart_data 
+    
+    INTERFACE flight_rrd_global 
+       MODULE PROCEDURE flight_rrd_global
+    END INTERFACE flight_rrd_global
+    
+    INTERFACE flight_wrd_global 
+       MODULE PROCEDURE flight_wrd_global 
+    END INTERFACE flight_wrd_global 
 
 !
@@ -153,5 +159,5 @@
 !-- Public interfaces
     PUBLIC flight_init, flight_header, flight_parin, flight_measurement,       &
-           flight_write_restart_data, flight_skip_var_list                    
+           flight_wrd_global, flight_rrd_global                   
 !
 !-- Public variables
@@ -238,7 +244,4 @@
        virtual_flight = .TRUE.
 
-       IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
-          CALL flight_read_restart_data
-       ENDIF
 
  10    CONTINUE
@@ -879,29 +882,6 @@
 
     END SUBROUTINE flight_check_parameters
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Skipping the flight-module variables from restart-file (binary format).
-!------------------------------------------------------------------------------!
-   SUBROUTINE flight_skip_var_list 
         
-      IMPLICIT NONE
-            
-      CHARACTER (LEN=1)  ::  cdum
-      CHARACTER (LEN=30) ::  variable_chr
-            
-      READ ( 13 )  variable_chr
-
-      DO  WHILE ( TRIM( variable_chr ) /= '*** end flight ***' )
-
-         READ ( 13 )  cdum
-         READ ( 13 )  variable_chr
-
-      ENDDO   
-            
-   END SUBROUTINE flight_skip_var_list 
-        
-   
+
 !------------------------------------------------------------------------------!
 ! Description:
@@ -909,45 +889,48 @@
 !> This routine reads the respective restart data.
 !------------------------------------------------------------------------------!
-    SUBROUTINE flight_read_restart_data  
+    SUBROUTINE flight_rrd_global( found )  
+
+
+       USE control_parameters,                                                 &
+           ONLY: length, restart_string
 
     
        IMPLICIT NONE
        
-       CHARACTER (LEN=30) ::  variable_chr !< dummy variable to read string
-       
-       
-       READ ( 13 )  variable_chr
-       DO  WHILE ( TRIM( variable_chr ) /= '*** end flight ***' )
-
-          SELECT CASE ( TRIM( variable_chr ) )
+       LOGICAL, INTENT(OUT)  ::  found 
+
+
+       found = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
           
-             CASE ( 'u_agl' )
-                IF ( .NOT. ALLOCATED( u_agl ) )  ALLOCATE( u_agl(1:num_leg) )
-                READ ( 13 )  u_agl   
-             CASE ( 'v_agl' )
-                IF ( .NOT. ALLOCATED( v_agl ) )  ALLOCATE( v_agl(1:num_leg) )
-                READ ( 13 )  v_agl
-             CASE ( 'w_agl' )
-                IF ( .NOT. ALLOCATED( w_agl ) )  ALLOCATE( w_agl(1:num_leg) )
-                READ ( 13 )  w_agl
-             CASE ( 'x_pos' )
-                IF ( .NOT. ALLOCATED( x_pos ) )  ALLOCATE( x_pos(1:num_leg) )
-                READ ( 13 )  x_pos
-             CASE ( 'y_pos' )
-                IF ( .NOT. ALLOCATED( y_pos ) )  ALLOCATE( y_pos(1:num_leg) )
-                READ ( 13 )  y_pos
-             CASE ( 'z_pos' )
-                IF ( .NOT. ALLOCATED( z_pos ) )  ALLOCATE( z_pos(1:num_leg) )
-                READ ( 13 )  z_pos
-             CASE ( 'virtual_flight_prerun' )
-                READ ( 13 )  virtual_flight_prerun
+          CASE ( 'u_agl' )
+             IF ( .NOT. ALLOCATED( u_agl ) )  ALLOCATE( u_agl(1:num_leg) )
+             READ ( 13 )  u_agl   
+          CASE ( 'v_agl' )
+             IF ( .NOT. ALLOCATED( v_agl ) )  ALLOCATE( v_agl(1:num_leg) )
+             READ ( 13 )  v_agl
+          CASE ( 'w_agl' )
+             IF ( .NOT. ALLOCATED( w_agl ) )  ALLOCATE( w_agl(1:num_leg) )
+             READ ( 13 )  w_agl
+          CASE ( 'x_pos' )
+             IF ( .NOT. ALLOCATED( x_pos ) )  ALLOCATE( x_pos(1:num_leg) )
+             READ ( 13 )  x_pos
+          CASE ( 'y_pos' )
+             IF ( .NOT. ALLOCATED( y_pos ) )  ALLOCATE( y_pos(1:num_leg) )
+             READ ( 13 )  y_pos
+          CASE ( 'z_pos' )
+             IF ( .NOT. ALLOCATED( z_pos ) )  ALLOCATE( z_pos(1:num_leg) )
+             READ ( 13 )  z_pos
+
+          CASE DEFAULT
+
+             found = .FALSE.
           
-          END SELECT
-          
-          READ ( 13 )  variable_chr
-          
-       ENDDO
-
-    END SUBROUTINE flight_read_restart_data  
+       END SELECT
+
+
+    END SUBROUTINE flight_rrd_global  
     
 !------------------------------------------------------------------------------!
@@ -956,28 +939,30 @@
 !> This routine writes the respective restart data.
 !------------------------------------------------------------------------------!
-    SUBROUTINE flight_write_restart_data  
+    SUBROUTINE flight_wrd_global  
+
 
        IMPLICIT NONE
 
-       virtual_flight_prerun = .TRUE.
-       
-       WRITE ( 14 )  'u_agl                         '
-       WRITE ( 14 )  u_agl       
-       WRITE ( 14 )  'v_agl                         '
+ 
+       CALL wrd_write_string( 'u_agl' )
+       WRITE ( 14 )  u_agl
+
+       CALL wrd_write_string( 'v_agl' )
        WRITE ( 14 )  v_agl
-       WRITE ( 14 )  'w_agl                         '
+
+       CALL wrd_write_string( 'w_agl' )
        WRITE ( 14 )  w_agl
-       WRITE ( 14 )  'x_pos                         '
+
+       CALL wrd_write_string( 'x_pos' )
        WRITE ( 14 )  x_pos
-       WRITE ( 14 )  'y_pos                         '
+
+       CALL wrd_write_string( 'y_pos' )
        WRITE ( 14 )  y_pos
-       WRITE ( 14 )  'z_pos                         '
+
+       CALL wrd_write_string( 'z_pos' )
        WRITE ( 14 )  z_pos
-       WRITE ( 14 )  'virtual_flight_prerun         '
-       WRITE ( 14 )  virtual_flight_prerun
-       
-       WRITE ( 14 )  '*** end flight ***            '
-       
-    END SUBROUTINE flight_write_restart_data    
+
+       
+    END SUBROUTINE flight_wrd_global    
     
 
Index: palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 2893)
+++ palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 2894)
@@ -26,4 +26,15 @@
 ! -----------------
 ! $Id$
+! variable named found has been introduced for checking if restart data was 
+! found, reading of restart strings has been moved completely to 
+! read_restart_data_mod, wind_turbine_prerun flag has been removed, redundant 
+! skipping function has been removed, wtm_read/write_restart_data have been
+! renamed to wtm_r/wrd_global, wtm_rrd_global is called in 
+! read_restart_data_mod now, marker *** end wtm *** was removed, strings and 
+! their respective lengths are written out and read now in case of restart 
+! runs to get rid of prescribed character lengths, CASE DEFAULT was added if 
+! restart data is read 
+! 
+! 2885 2018-03-14 11:02:46Z Giersch
 ! Bugfix in interpolation of lift and drag coefficients on fine grid of radius 
 ! segments and angles of attack, speed-up of the initialization of the wind 
@@ -49,5 +60,5 @@
 !
 ! 2576 2017-10-24 13:49:46Z Giersch
-! Definition of a new function called wtm_skip_var_list to skip module 
+! Definition of a new function called wtm_skip_global to skip module 
 ! parameters during reading restart data
 ! 
@@ -137,5 +148,5 @@
     USE control_parameters,                                                    &
         ONLY:  coupling_char, dt_3d, dz, message_string, simulated_time,       &
-               wind_turbine, wind_turbine_prerun, initializing_actions
+               wind_turbine, initializing_actions
 
     USE cpulog,                                                                &
@@ -404,15 +415,11 @@
     END INTERFACE wtm_parin
 
-    INTERFACE wtm_skip_var_list 
-       MODULE PROCEDURE wtm_skip_var_list 
-    END INTERFACE wtm_skip_var_list
-
-    INTERFACE wtm_write_restart_data 
-       MODULE PROCEDURE wtm_write_restart_data 
-    END INTERFACE wtm_write_restart_data
-
-    INTERFACE wtm_read_restart_data 
-       MODULE PROCEDURE wtm_read_restart_data
-    END INTERFACE wtm_read_restart_data 
+    INTERFACE wtm_wrd_global 
+       MODULE PROCEDURE wtm_wrd_global 
+    END INTERFACE wtm_wrd_global
+
+    INTERFACE wtm_rrd_global 
+       MODULE PROCEDURE wtm_rrd_global
+    END INTERFACE wtm_rrd_global 
     
     INTERFACE wtm_check_parameters
@@ -456,5 +463,5 @@
     
     PUBLIC wtm_check_parameters, wtm_forces, wtm_init, wtm_init_arrays,        &
-           wtm_parin, wtm_write_restart_data, wtm_tendencies, wtm_skip_var_list
+           wtm_parin, wtm_wrd_global, wtm_rrd_global, wtm_tendencies
 
 
@@ -514,7 +521,4 @@
        wind_turbine = .TRUE.
 
-       IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
-          CALL wtm_read_restart_data
-       ENDIF
 
  10    CONTINUE   ! TBD Change from continue, mit ierrn machen
@@ -522,28 +526,4 @@
 
     END SUBROUTINE wtm_parin
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Skipping the wind turbine module variables from restart-file (binary format).
-!------------------------------------------------------------------------------!
-   SUBROUTINE wtm_skip_var_list 
-        
-      IMPLICIT NONE
-            
-      CHARACTER (LEN=1)  ::  cdum
-      CHARACTER (LEN=30) ::  variable_chr
-            
-      READ ( 13 )  variable_chr
-
-      DO  WHILE ( TRIM( variable_chr ) /= '*** end wtm ***' )
-
-         READ ( 13 )  cdum
-         READ ( 13 )  variable_chr
-
-      ENDDO   
-            
-   END SUBROUTINE wtm_skip_var_list 
 
 
@@ -553,36 +533,42 @@
 !> This routine writes the respective restart data.
 !------------------------------------------------------------------------------!
-    SUBROUTINE wtm_write_restart_data  
+    SUBROUTINE wtm_wrd_global  
+
 
        IMPLICIT NONE
 
-       wind_turbine_prerun = .TRUE.
-       
-       WRITE ( 14 )  'omega_gen                     '
+       
+       CALL wrd_write_string( 'omega_gen' )
        WRITE ( 14 )  omega_gen
-       WRITE ( 14 )  'omega_gen_f                   '
+
+       CALL wrd_write_string( 'omega_gen_f' )
        WRITE ( 14 )  omega_gen_f
-       WRITE ( 14 )  'omega_gen_f_old               '
+
+       CALL wrd_write_string( 'omega_gen_f_old' )
        WRITE ( 14 )  omega_gen_f_old
-       WRITE ( 14 )  'omega_gen_old                 '
+
+       CALL wrd_write_string( 'omega_gen_old' )
        WRITE ( 14 )  omega_gen_old
-       WRITE ( 14 )  'omega_rot                     '
+
+       CALL wrd_write_string( 'omega_rot' )
        WRITE ( 14 )  omega_rot
-       WRITE ( 14 )  'phi_yaw                       '
-       WRITE ( 14 )  phi_yaw(:)
-       WRITE ( 14 )  'pitch_add                     '
+
+       CALL wrd_write_string( 'phi_yaw' )
+       WRITE ( 14 )  phi_yaw
+
+       CALL wrd_write_string( 'pitch_add' )
        WRITE ( 14 )  pitch_add
-       WRITE ( 14 )  'pitch_add_old                 '
+
+       CALL wrd_write_string( 'pitch_add_old' )
        WRITE ( 14 )  pitch_add_old
-       WRITE ( 14 )  'torque_gen                    '
+
+       CALL wrd_write_string( 'torque_gen' )
        WRITE ( 14 )  torque_gen
-       WRITE ( 14 )  'torque_gen_old                '
+
+       CALL wrd_write_string( 'torque_gen_old' )
        WRITE ( 14 )  torque_gen_old
-       WRITE ( 14 )  'wind_turbine_prerun           '
-       WRITE ( 14 )  wind_turbine_prerun
-     
-       WRITE ( 14 )  '*** end wtm ***               '
-       
-    END SUBROUTINE wtm_write_restart_data    
+
+       
+    END SUBROUTINE wtm_wrd_global    
 
 
@@ -592,47 +578,50 @@
 !> This routine reads the respective restart data.
 !------------------------------------------------------------------------------!
- SUBROUTINE wtm_read_restart_data
+ SUBROUTINE wtm_rrd_global( found )
+
+
+    USE control_parameters,                                                    &
+        ONLY: length, restart_string
 
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
-
-
-    READ ( 13 )  variable_chr
-    DO  WHILE ( TRIM( variable_chr ) /= '*** end wtm ***' )
-
-       SELECT CASE ( TRIM( variable_chr ) )
-
-          CASE ( 'omega_gen' )
-             READ ( 13 )  omega_gen
-          CASE ( 'omega_gen_f' )
-             READ ( 13 )  omega_gen_f
-          CASE ( 'omega_gen_f_old' )
-             READ ( 13 )  omega_gen_f_old
-          CASE ( 'omega_gen_old' )
-             READ ( 13 )  omega_gen_old
-          CASE ( 'omega_rot' )
-             READ ( 13 )  omega_rot
-          CASE ( 'phi_yaw' )
-             READ ( 13 )  phi_yaw
-          CASE ( 'pitch_add' )
-             READ ( 13 )  pitch_add
-          CASE ( 'pitch_add_old' )
-             READ ( 13 )  pitch_add_old
-          CASE ( 'torque_gen' )
-             READ ( 13 )  torque_gen
-          CASE ( 'torque_gen_old' )
-             READ ( 13 )  torque_gen_old
-          CASE ( 'wind_turbine_prerun' )
-             READ ( 13 )  wind_turbine_prerun
-
-       END SELECT
-       
-       READ ( 13 )  variable_chr
-
-    ENDDO
-
- END SUBROUTINE wtm_read_restart_data
+    LOGICAL, INTENT(OUT)  ::  found 
+
+
+    found = .TRUE.
+
+
+    SELECT CASE ( restart_string(1:length) )
+
+       CASE ( 'omega_gen' )
+          READ ( 13 )  omega_gen
+       CASE ( 'omega_gen_f' )
+          READ ( 13 )  omega_gen_f
+       CASE ( 'omega_gen_f_old' )
+          READ ( 13 )  omega_gen_f_old
+       CASE ( 'omega_gen_old' )
+          READ ( 13 )  omega_gen_old
+       CASE ( 'omega_rot' )
+          READ ( 13 )  omega_rot
+       CASE ( 'phi_yaw' )
+          READ ( 13 )  phi_yaw
+       CASE ( 'pitch_add' )
+          READ ( 13 )  pitch_add
+       CASE ( 'pitch_add_old' )
+          READ ( 13 )  pitch_add_old
+       CASE ( 'torque_gen' )
+          READ ( 13 )  torque_gen
+       CASE ( 'torque_gen_old' )
+          READ ( 13 )  torque_gen_old
+
+       CASE DEFAULT
+
+          found = .FALSE.
+
+    END SELECT
+   
+
+ END SUBROUTINE wtm_rrd_global
 
 
@@ -2066,5 +2055,5 @@
                      turb_cl(rseg)  = tl_factor * turb_cl(rseg)                                  
                                  
-                   END IF               
+                   ENDIF               
 !
 !--                !-----------------------------------------------------!
@@ -2371,5 +2360,5 @@
              ENDDO ! End of loop over turbines
                            
-          END IF  ! end of yaw control 
+          ENDIF  ! end of yaw control 
           
           IF ( speed_control )  THEN
Index: palm/trunk/SOURCE/wrd_write_string.f90
===================================================================
--- palm/trunk/SOURCE/wrd_write_string.f90	(revision 2894)
+++ palm/trunk/SOURCE/wrd_write_string.f90	(revision 2894)
@@ -0,0 +1,56 @@
+!> @file user_last_actions.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision
+!
+!
+! Description:
+! ------------
+!> Calculates length of string and write the respective value together with the
+!> string into binary file(s) for restart runs
+!------------------------------------------------------------------------------!
+ 
+ SUBROUTINE wrd_write_string( string )
+
+
+    USE kinds
+
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*), INTENT (IN) ::  string  !< for storing strings in case of writing/reading restart data
+
+    INTEGER(iwp) ::  length  !< integer that specifies the length of a string in case of writing/reading restart
+                             !< data
+
+
+    length = LEN_TRIM( string )
+
+    WRITE ( 14 )  length
+    WRITE ( 14 )  string(1:length)
+
+
+ END SUBROUTINE wrd_write_string
Index: palm/trunk/SOURCE/write_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/write_3d_binary.f90	(revision 2893)
+++ 	(revision )
@@ -1,417 +1,0 @@
-!> @file write_3d_binary.f90
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2018 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Preliminary gust module interface implemented
-! 
-! 2798 2018-02-09 17:16:39Z suehring
-! Consider also default-type surfaces for surface temperature output. 
-! 
-! 2797 2018-02-08 13:24:35Z suehring
-! Enable restarts for land- and urban-surface variables ghf_av, r_a_av and 
-! tsurf_av.
-! 
-! 2718 2018-01-02 08:49:38Z maronga
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-! + kh_av, km_av (TG)
-! 
-! 2292 2017-06-20 09:51:42Z schwenkel
-! Implementation of new microphysic scheme: cloud_scheme = 'morrison' 
-! includes two more prognostic equations for cloud drop concentration (nc)  
-! and cloud water content (qc). 
-! 
-! 2233 2017-05-30 18:08:54Z suehring
-!
-! 2232 2017-05-30 17:47:52Z suehring
-! Adjustments to new surface concept - move output of surface varariables
-! to surface_mod
-! 
-! 2031 2016-10-21 15:11:58Z knoop
-! renamed variable rho_av to rho_ocean_av
-! 
-! 2000 2016-08-20 18:09:15Z knoop
-! Forced header and separation lines into 80 columns
-! 
-! 1976 2016-07-27 13:28:04Z maronga
-! Radiation actions are now done directly in the respective module.
-! Binary version increased to 4.5.
-! 
-! 1972 2016-07-26 07:52:02Z maronga
-! Land surface actions are now done directly in the respective module
-! 
-! 1849 2016-04-08 11:33:18Z hoffmann
-! prr, precipitation_amount moved to arrays_3d
-!
-! 1833 2016-04-07 14:23:03Z raasch
-! statistics module replaced by spectra module
-! 
-! 1822 2016-04-07 07:49:42Z hoffmann
-! icloud_scheme replaced by microphysics_*
-!
-! 1788 2016-03-10 11:01:04Z maronga
-! Added z0q and z0q_av
-! 
-! 1709 2015-11-04 14:47:01Z maronga
-! Added rad_lw_out_change_0, increased binary_version
-! 
-! 1691 2015-10-26 16:17:44Z maronga
-! Added output of radiative heating rates for RRTMG. Added output of ol. Removed
-! output of rif.
-! 
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable 
-! 
-! 1585 2015-04-30 07:05:52Z maronga
-! Adapted for RRTMG
-! 
-! 1551 2015-03-03 14:18:16Z maronga
-! Added support for binary ouput of land surface and radiation model data. 
-! 
-! 1400 2014-05-09 14:03:54Z knoop
-! writing of arrays for random_generator_parallel added
-! 
-! 1359 2014-04-11 17:15:14Z hoffmann
-! Bugfix using cloud_droplets solved. qc, qr*, nr* are no longer written in case
-! of cloud_droplets = .TRUE.
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! ONLY-attribute added to USE-statements,
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements 
-!
-! 1318 2014-03-17 13:35:16Z raasch
-! module interfaces removed
-!
-! 1115 2013-03-26 18:16:16Z hoffmann
-! qr and nr are restricted to precipitation
-!
-! 1053 2012-11-13 17:11:03Z hoffmann
-! necessary expansions according to the two new prognostic equations (nr, qr) 
-! of the two-moment cloud physics scheme:
-! +prr, prr_av, *, *_av, *s, *sws, *swst
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 1001 2012-09-13 14:08:46Z raasch
-! all actions concerning leapfrog- and ups-scheme removed
-!
-! 978 2012-08-09 08:28:32Z fricke
-! +z0h, z0h_av
-!
-! Revision 1.1  1998/03/18 20:20:21  raasch
-! Initial revision
-!
-!
-! Description:
-! ------------
-!> Binary output of variables and arrays for restarts.
-!------------------------------------------------------------------------------!
- SUBROUTINE write_3d_binary
- 
-
-    USE arrays_3d,                                                             &
-        ONLY:  e, kh, km, p, pt, q, ql, qc, nc, nr, prr, precipitation_amount, &
-               qr, s, sa, u, u_m_l, u_m_n, u_m_r, u_m_s, v, v_m_l, v_m_n,      &
-               v_m_r, v_m_s, vpt, w, w_m_l, w_m_n, w_m_r, w_m_s
-        
-    USE averaging
-
-    USE control_parameters,                                                    &
-        ONLY:  cloud_physics, cloud_droplets, humidity, iran,                  &
-               land_surface, microphysics_morrison, microphysics_seifert,      &
-               ocean, passive_scalar, topography, urban_surface
-
-    USE gust_mod,                                                              &
-        ONLY :  gust_module_enabled, gust_write_restart_data
-
-    USE indices,                                                               &
-        ONLY:  nxl, nxr, nys, nyn, nzb, nzt
-        
-    USE particle_attributes,                                                   &
-        ONLY:  iran_part
-        
-    USE pegrid
-    
-    USE random_function_mod,                                                   &
-        ONLY:  random_iv, random_iy
-
-    USE random_generator_parallel,                                             &
-        ONLY:  id_random_array, seq_random_array
-        
-    USE spectra_mod,                                                           &
-        ONLY:  spectrum_x, spectrum_y
-
-    USE surface_mod,                                                           &
-        ONLY :  surface_write_restart_data
-
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=10) ::  binary_version   !< 
-
-!
-!-- Write control parameters and other variables for restart.
-    IF ( myid == 0 )  CALL write_var_list
-
-!
-!-- Write arrays.
-    binary_version = '4.6'
-
-    WRITE ( 14 )  binary_version
-
-    WRITE ( 14 )  numprocs, myid, nxl, nxr, nys, nyn, nzb, nzt
-
-!
-!-- Attention: After changes to the following output commands the version number
-!-- ---------  of the variable binary_version must be changed!
-!--            Also, the list of arrays to be read in read_3d_binary must be
-!--            adjusted accordingly.
-    WRITE ( 14 )  'e                   ';  WRITE ( 14 )  e
-    IF ( ALLOCATED( e_av ) )  THEN
-       WRITE ( 14 )  'e_av                ';  WRITE ( 14 )  e_av
-    ENDIF
-    WRITE ( 14 )  'iran                ';  WRITE ( 14 )  iran, iran_part
-    WRITE ( 14 )  'kh                  ';  WRITE ( 14 )  kh
-    IF ( ALLOCATED( kh_av ) )  THEN
-       WRITE ( 14 )  'kh_av               ';  WRITE ( 14 )  kh_av
-    ENDIF
-    WRITE ( 14 )  'km                  ';  WRITE ( 14 )  km
-    IF ( ALLOCATED( km_av ) )  THEN
-       WRITE ( 14 )  'km_av               ';  WRITE ( 14 )  km_av
-    ENDIF
-    IF ( ALLOCATED( lpt_av ) )  THEN
-       WRITE ( 14 )  'lpt_av              ';  WRITE ( 14 )  lpt_av
-    ENDIF
-    IF ( ALLOCATED( lwp_av ) )  THEN
-       WRITE ( 14 )  'lwp_av              ';  WRITE ( 14 )  lwp_av
-    ENDIF
-    WRITE ( 14 )  'p                   ';  WRITE ( 14 )  p
-    IF ( ALLOCATED( p_av ) )  THEN
-       WRITE ( 14 )  'p_av                ';  WRITE ( 14 )  p_av
-    ENDIF
-    IF ( ALLOCATED( pc_av ) )  THEN
-       WRITE ( 14 )  'pc_av               ';  WRITE ( 14 )  pc_av
-    ENDIF
-    IF ( ALLOCATED( pr_av ) )  THEN
-       WRITE ( 14 )  'pr_av               ';  WRITE ( 14 )  pr_av
-    ENDIF
-    IF ( ALLOCATED( prr ) )  THEN
-       WRITE ( 14 )  'prr                 ';  WRITE ( 14 )  prr
-    ENDIF
-    IF ( ALLOCATED( prr_av ) )  THEN
-       WRITE ( 14 )  'prr_av              ';  WRITE ( 14 )  prr_av
-    ENDIF
-    IF ( ALLOCATED( precipitation_amount ) )  THEN
-       WRITE ( 14 )  'precipitation_amount';  WRITE ( 14 )  precipitation_amount
-    ENDIF
-    IF ( ALLOCATED( precipitation_rate_av ) )  THEN
-       WRITE ( 14 )  'precipitation_rate_a';  WRITE ( 14 )                     &
-                                                           precipitation_rate_av
-    ENDIF
-    WRITE ( 14 )  'pt                  ';  WRITE ( 14 )  pt
-    IF ( ALLOCATED( pt_av ) )  THEN
-       WRITE ( 14 )  'pt_av               ';  WRITE ( 14 )  pt_av
-    ENDIF
-    IF ( humidity )  THEN
-       WRITE ( 14 )  'q                   ';  WRITE ( 14 )  q 
-       IF ( ALLOCATED( q_av ) )  THEN
-          WRITE ( 14 )  'q_av                ';  WRITE ( 14 )  q_av
-       ENDIF
-       IF ( cloud_physics  .OR.  cloud_droplets )  THEN
-          WRITE ( 14 )  'ql                  ';  WRITE ( 14 )  ql
-          IF ( ALLOCATED( ql_av ) )  THEN
-             WRITE ( 14 )  'ql_av               ';  WRITE ( 14 )  ql_av
-          ENDIF
-          IF ( .NOT. cloud_droplets )  THEN
-             WRITE ( 14 )  'qc                  ';  WRITE ( 14 )  qc
-             IF ( ALLOCATED( qc_av ) )  THEN
-                WRITE ( 14 )  'qc_av               ';  WRITE ( 14 )  qc_av
-             ENDIF
-             IF ( microphysics_morrison )  THEN
-                WRITE ( 14 )  'nc                  ';  WRITE ( 14 )  nc
-                IF ( ALLOCATED( nc_av ) )  THEN
-                   WRITE ( 14 )  'nc_av               ';  WRITE ( 14 )  nc_av
-                ENDIF
-             ENDIF
-             IF ( microphysics_seifert )  THEN
-                WRITE ( 14 )  'nr                  ';  WRITE ( 14 )  nr
-                IF ( ALLOCATED( nr_av ) )  THEN
-                   WRITE ( 14 )  'nr_av               ';  WRITE ( 14 )  nr_av
-                ENDIF
-                WRITE ( 14 )  'qr                  ';  WRITE ( 14 )  qr
-                IF ( ALLOCATED( qr_av ) )  THEN
-                   WRITE ( 14 )  'qr_av               ';  WRITE ( 14 )  qr_av
-                ENDIF
-             ENDIF
-          ENDIF
-       ENDIF
-       IF ( ALLOCATED( qsws_av ) )  THEN
-          WRITE ( 14 )  'qsws_av             ';  WRITE ( 14 )  qsws_av
-       ENDIF
-    ENDIF
-    IF ( passive_scalar )  THEN
-       WRITE ( 14 )  's                   ';  WRITE ( 14 )  s 
-       IF ( ALLOCATED( s_av ) )  THEN
-          WRITE ( 14 )  's_av                ';  WRITE ( 14 )  s_av
-       ENDIF
-       IF ( ALLOCATED( ssws_av ) )  THEN
-          WRITE ( 14 )  'ssws_av             ';  WRITE ( 14 )  ssws_av
-       ENDIF
-    ENDIF    
-    IF ( ocean )  THEN
-       IF ( ALLOCATED( rho_ocean_av ) )  THEN
-          WRITE ( 14 )  'rho_ocean_av              ';  WRITE ( 14 )  rho_ocean_av
-       ENDIF
-       WRITE ( 14 )  'sa                  ';  WRITE ( 14 )  sa
-       IF ( ALLOCATED( sa_av ) )  THEN
-          WRITE ( 14 )  'sa_av               ';  WRITE ( 14 )  sa_av
-       ENDIF
-    ENDIF
-    IF ( ALLOCATED( ql_c_av ) )  THEN
-       WRITE ( 14 )  'ql_c_av             ';  WRITE ( 14 )  ql_c_av
-    ENDIF
-    IF ( ALLOCATED( ql_v_av ) )  THEN
-       WRITE ( 14 )  'ql_v_av             ';  WRITE ( 14 )  ql_v_av
-    ENDIF
-    IF ( ALLOCATED( ql_vp_av ) )  THEN
-       WRITE ( 14 )  'ql_vp_av            ';  WRITE ( 14 )  ql_vp_av
-    ENDIF
-    IF ( ALLOCATED( qv_av ) )  THEN
-       WRITE ( 14 )  'qv_av               ';  WRITE ( 14 )  qv_av
-    ENDIF
-    WRITE ( 14 )  'random_iv           ';  WRITE ( 14 )  random_iv
-                                           WRITE ( 14 )  random_iy
-    IF ( ALLOCATED( seq_random_array ) )  THEN
-    WRITE ( 14 )  'seq_random_array    ';  WRITE ( 14 )  id_random_array
-                                           WRITE ( 14 )  seq_random_array
-    ENDIF
-    IF ( ALLOCATED( s_av ) )  THEN
-       WRITE ( 14 )  's_av                ';  WRITE ( 14 )  s_av
-    ENDIF
-    IF ( ALLOCATED( shf_av ) )  THEN
-       WRITE ( 14 )  'shf_av              ';  WRITE ( 14 )  shf_av
-    ENDIF
-    IF ( ALLOCATED( spectrum_x ) )  THEN
-       WRITE ( 14 )  'spectrum_x          ';  WRITE ( 14 )  spectrum_x
-       WRITE ( 14 )  'spectrum_y          ';  WRITE ( 14 )  spectrum_y
-    ENDIF
-    IF ( ALLOCATED( ts_av ) )  THEN
-       WRITE ( 14 )  'ts_av               ';  WRITE ( 14 )  ts_av
-    ENDIF
-    WRITE ( 14 )  'u                   ';  WRITE ( 14 )  u
-    IF ( ALLOCATED( u_av ) )  THEN
-       WRITE ( 14 )  'u_av                ';  WRITE ( 14 )  u_av
-    ENDIF
-    IF ( ALLOCATED( u_m_l ) )  THEN
-       WRITE ( 14 )  'u_m_l               ';  WRITE ( 14 )  u_m_l
-    ENDIF
-    IF ( ALLOCATED( u_m_n ) )  THEN
-       WRITE ( 14 )  'u_m_n               ';  WRITE ( 14 )  u_m_n
-    ENDIF
-    IF ( ALLOCATED( u_m_r ) )  THEN
-       WRITE ( 14 )  'u_m_r               ';  WRITE ( 14 )  u_m_r
-    ENDIF
-    IF ( ALLOCATED( u_m_s ) )  THEN
-       WRITE ( 14 )  'u_m_s               ';  WRITE ( 14 )  u_m_s
-    ENDIF
-    IF ( ALLOCATED( us_av ) )  THEN
-       WRITE ( 14 )  'us_av               ';  WRITE ( 14 )  us_av
-    ENDIF
-    WRITE ( 14 )  'v                   ';  WRITE ( 14 )  v
-    IF ( ALLOCATED( v_av ) )  THEN
-       WRITE ( 14 )  'v_av                ';  WRITE ( 14 )  v_av
-    ENDIF
-    IF ( ALLOCATED( v_m_l ) )  THEN
-       WRITE ( 14 )  'v_m_l               ';  WRITE ( 14 )  v_m_l
-    ENDIF
-    IF ( ALLOCATED( v_m_n ) )  THEN
-       WRITE ( 14 )  'v_m_n               ';  WRITE ( 14 )  v_m_n
-    ENDIF
-    IF ( ALLOCATED( v_m_r ) )  THEN
-       WRITE ( 14 )  'v_m_r               ';  WRITE ( 14 )  v_m_r
-    ENDIF
-    IF ( ALLOCATED( v_m_s ) )  THEN
-       WRITE ( 14 )  'v_m_s               ';  WRITE ( 14 )  v_m_s
-    ENDIF
-    IF ( humidity )  THEN
-       WRITE ( 14 )  'vpt                 ';  WRITE ( 14 )  vpt
-       IF ( ALLOCATED( vpt_av ) )  THEN
-          WRITE ( 14 )  'vpt_av              ';  WRITE ( 14 )  vpt_av
-       ENDIF
-    ENDIF
-    WRITE ( 14 )  'w                   ';  WRITE ( 14 )  w
-    IF ( ALLOCATED( w_av ) )  THEN
-       WRITE ( 14 )  'w_av                ';  WRITE ( 14 )  w_av
-    ENDIF
-    IF ( ALLOCATED( w_m_l ) )  THEN
-       WRITE ( 14 )  'w_m_l               ';  WRITE ( 14 )  w_m_l
-    ENDIF
-    IF ( ALLOCATED( w_m_n ) )  THEN
-       WRITE ( 14 )  'w_m_n               ';  WRITE ( 14 )  w_m_n
-    ENDIF
-    IF ( ALLOCATED( w_m_r ) )  THEN
-       WRITE ( 14 )  'w_m_r               ';  WRITE ( 14 )  w_m_r
-    ENDIF
-    IF ( ALLOCATED( w_m_s ) )  THEN
-       WRITE ( 14 )  'w_m_s               ';  WRITE ( 14 )  w_m_s
-    ENDIF
-    IF ( ALLOCATED( z0_av ) )  THEN
-       WRITE ( 14 )  'z0_av               ';  WRITE ( 14 )  z0_av
-    ENDIF
-    IF ( ALLOCATED( z0h_av ) )  THEN
-       WRITE ( 14 )  'z0h_av              ';  WRITE ( 14 )  z0h_av
-    ENDIF
-    IF ( ALLOCATED( z0q_av ) )  THEN
-       WRITE ( 14 )  'z0q_av              ';  WRITE ( 14 )  z0q_av
-    ENDIF
-    IF ( land_surface  .OR.  urban_surface )  THEN
-       IF ( ALLOCATED( ghf_av ) )  THEN
-          WRITE ( 14 )  'ghf_av              ';  WRITE ( 14 )  ghf_av
-       ENDIF
-       IF ( ALLOCATED( r_a_av ) )  THEN
-          WRITE ( 14 )  'r_a_av              ';  WRITE ( 14 )  r_a_av
-       ENDIF
-    ENDIF
-    IF ( ALLOCATED( tsurf_av ) )  THEN
-       WRITE ( 14 )  'tsurf_av            ';  WRITE ( 14 )  tsurf_av
-    ENDIF
-
-!
-!-- Write end label. Unit 14 is closed in the main program.
-    WRITE ( 14 )  '*** end ***         '
-
-    IF ( gust_module_enabled )  THEN
-       CALL gust_write_restart_data
-    ENDIF
-
-    CALL surface_write_restart_data
-
- END SUBROUTINE write_3d_binary
- 
Index: palm/trunk/SOURCE/write_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/write_restart_data_mod.f90	(revision 2894)
+++ palm/trunk/SOURCE/write_restart_data_mod.f90	(revision 2894)
@@ -0,0 +1,1380 @@
+!> @file write_restart_data_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision 
+!
+!
+! Description:
+! ------------
+!> Writes restart data into binary file(s) for restart runs.
+!------------------------------------------------------------------------------!
+ MODULE write_restart_data_mod
+
+
+    USE control_parameters
+ 
+    USE kinds     
+
+    USE pegrid,                                                                &
+        ONLY:  myid, numprocs
+     
+
+    IMPLICIT NONE
+
+
+    INTERFACE wrd_global
+       MODULE PROCEDURE wrd_global
+    END INTERFACE wrd_global
+
+    INTERFACE wrd_local
+       MODULE PROCEDURE wrd_local
+    END INTERFACE wrd_local
+
+
+    PUBLIC wrd_local, wrd_global
+
+
+ CONTAINS
+
+
+! Description:
+! ------------
+!> Global data of control variables and arrays is written out for 
+!> restarts (binary format).
+!> This information is only written to the file opened by PE0.
+!------------------------------------------------------------------------------!
+    SUBROUTINE wrd_global
+
+
+       USE arrays_3d,                                                          &
+           ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,        &
+                  q_init, ref_state, s_init, sa_init, u_init, ug, v_init, vg
+
+       USE flight_mod,                                                         &
+           ONLY:  flight_wrd_global
+
+       USE grid_variables,                                                     &
+           ONLY:  dx, dy
+
+       USE indices,                                                            &
+           ONLY:  nz, nx, ny
+
+       USE microphysics_mod,                                                   &
+           ONLY:  c_sedimentation, cloud_water_sedimentation,                  &
+                  collision_turbulence, limiter_sedimentation, nc_const,       &
+                  ventilation_effect
+
+       USE model_1d_mod,                                                       &
+           ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
+
+       USE netcdf_interface,                                                   &
+           ONLY:  netcdf_precision, output_for_t0
+
+       USE particle_attributes,                                                &
+           ONLY:  curvature_solution_effects
+
+       USE pegrid,                                                             &
+           ONLY:  hor_index_bounds, collective_wait                                
+
+       USE radiation_model_mod,                                                &
+           ONLY:  time_radiation
+
+       USE spectra_mod,                                                        &
+           ONLY:  average_count_sp
+
+       USE synthetic_turbulence_generator_mod,                                 &
+           ONLY:  stg_wrd_global
+
+       USE statistics,                                                         &
+           ONLY:  statistic_regions, hom, hom_sum, u_max, u_max_ijk, v_max,    &
+                  v_max_ijk, w_max, w_max_ijk
+
+       USE user_write_restart_data_mod,                                        &
+           ONLY:  user_wrd_global 
+
+       USE vertical_nesting_mod,                                               &
+           ONLY:  vnest_init
+
+       USE wind_turbine_model_mod,                                             &
+           ONLY:  wtm_wrd_global
+     
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=10)  ::  binary_version_global   !<
+
+
+       binary_version_global = '4.7'
+
+       CALL wrd_write_string( 'binary_version_global' )
+       WRITE ( 14 )  binary_version_global
+
+       CALL wrd_write_string( 'numprocs' )
+       WRITE ( 14 )  numprocs
+
+       CALL wrd_write_string( 'hor_index_bounds' ) 
+       WRITE ( 14 )  hor_index_bounds
+
+       CALL wrd_write_string( 'nz' ) 
+       WRITE ( 14 )  nz
+
+       CALL wrd_write_string( 'max_pr_user' ) 
+       WRITE ( 14 )  max_pr_user
+
+       CALL wrd_write_string( 'statistic_regions' ) 
+       WRITE ( 14 )  statistic_regions
+
+!
+!-- Caution: After changes in the following parameter-list, the
+!-- -------  version number stored in the variable binary_version_global has to
+!--          be increased. The same changes must also be done in the parameter-
+!--          list in rrd_global.
+
+       CALL wrd_write_string( 'advected_distance_x' ) 
+       WRITE ( 14 )  advected_distance_x
+
+       CALL wrd_write_string( 'advected_distance_y' ) 
+       WRITE ( 14 )  advected_distance_y
+
+       CALL wrd_write_string( 'alpha_surface' ) 
+       WRITE ( 14 )  alpha_surface 
+
+       CALL wrd_write_string( 'average_count_pr' ) 
+       WRITE ( 14 )  average_count_pr
+
+       CALL wrd_write_string( 'average_count_sp' ) 
+       WRITE ( 14 )  average_count_sp
+
+       CALL wrd_write_string( 'average_count_3d' ) 
+       WRITE ( 14 )  average_count_3d
+
+       CALL wrd_write_string( 'bc_e_b' ) 
+       WRITE ( 14 )  bc_e_b
+
+       CALL wrd_write_string( 'bc_lr' ) 
+       WRITE ( 14 )  bc_lr
+
+       CALL wrd_write_string( 'bc_ns' ) 
+       WRITE ( 14 )  bc_ns
+
+       CALL wrd_write_string( 'bc_p_b' ) 
+       WRITE ( 14 )  bc_p_b
+
+       CALL wrd_write_string( 'bc_p_t' ) 
+       WRITE ( 14 )  bc_p_t
+
+       CALL wrd_write_string( 'bc_pt_b' ) 
+       WRITE ( 14 )  bc_pt_b
+
+       CALL wrd_write_string( 'bc_pt_t' ) 
+       WRITE ( 14 )  bc_pt_t
+
+       CALL wrd_write_string( 'bc_pt_t_val' ) 
+       WRITE ( 14 )  bc_pt_t_val
+
+       CALL wrd_write_string( 'bc_q_b' ) 
+       WRITE ( 14 )  bc_q_b
+
+       CALL wrd_write_string( 'bc_q_t' ) 
+       WRITE ( 14 )  bc_q_t
+
+       CALL wrd_write_string( 'bc_q_t_val' ) 
+       WRITE ( 14 )  bc_q_t_val
+
+       CALL wrd_write_string( 'bc_s_b' ) 
+       WRITE ( 14 )  bc_s_b
+
+       CALL wrd_write_string( 'bc_s_t' ) 
+       WRITE ( 14 )  bc_s_t
+
+       CALL wrd_write_string( 'bc_sa_t' ) 
+       WRITE ( 14 )  bc_sa_t
+
+       CALL wrd_write_string( 'bc_uv_b' ) 
+       WRITE ( 14 )  bc_uv_b
+
+       CALL wrd_write_string( 'bc_uv_t' ) 
+       WRITE ( 14 )  bc_uv_t
+
+       CALL wrd_write_string( 'bottom_salinityflux' ) 
+       WRITE ( 14 )  bottom_salinityflux
+
+       CALL wrd_write_string( 'building_height' ) 
+       WRITE ( 14 )  building_height
+
+       CALL wrd_write_string( 'building_length_x' ) 
+       WRITE ( 14 )  building_length_x
+
+       CALL wrd_write_string( 'building_length_y' ) 
+       WRITE ( 14 )  building_length_y
+
+       CALL wrd_write_string( 'building_wall_left' ) 
+       WRITE ( 14 )  building_wall_left
+
+       CALL wrd_write_string( 'building_wall_south' ) 
+       WRITE ( 14 )  building_wall_south
+
+       CALL wrd_write_string( 'c_sedimentation' ) 
+       WRITE ( 14 )  c_sedimentation
+
+       CALL wrd_write_string( 'call_psolver_at_all_substeps' ) 
+       WRITE ( 14 )  call_psolver_at_all_substeps
+
+       CALL wrd_write_string( 'canyon_height' ) 
+       WRITE ( 14 )  canyon_height 
+
+       CALL wrd_write_string( 'canyon_wall_left' ) 
+       WRITE ( 14 )  canyon_wall_left
+
+       CALL wrd_write_string( 'canyon_wall_south' ) 
+       WRITE ( 14 )  canyon_wall_south
+
+       CALL wrd_write_string( 'canyon_width_x' ) 
+       WRITE ( 14 )  canyon_width_x
+
+       CALL wrd_write_string( 'canyon_width_y' ) 
+       WRITE ( 14 )  canyon_width_y
+
+       CALL wrd_write_string( 'cfl_factor' ) 
+       WRITE ( 14 )  cfl_factor
+
+       CALL wrd_write_string( 'cloud_droplets' ) 
+       WRITE ( 14 )  cloud_droplets
+
+       CALL wrd_write_string( 'cloud_physics' ) 
+       WRITE ( 14 )  cloud_physics
+
+       CALL wrd_write_string( 'cloud_scheme' ) 
+       WRITE ( 14 )  cloud_scheme
+
+       CALL wrd_write_string( 'cloud_top_radiation' ) 
+       WRITE ( 14 )  cloud_top_radiation
+
+       CALL wrd_write_string( 'cloud_water_sedimentation' ) 
+       WRITE ( 14 )  cloud_water_sedimentation
+
+       CALL wrd_write_string( 'collective_wait' ) 
+       WRITE ( 14 )  collective_wait
+
+       CALL wrd_write_string( 'collision_turbulence' ) 
+       WRITE ( 14 )  collision_turbulence
+
+       CALL wrd_write_string( 'conserve_volume_flow' ) 
+       WRITE ( 14 )  conserve_volume_flow
+
+       CALL wrd_write_string( 'conserve_volume_flow_mode' ) 
+       WRITE ( 14 )  conserve_volume_flow_mode
+
+       CALL wrd_write_string( 'constant_flux_layer' ) 
+       WRITE ( 14 )  constant_flux_layer
+
+       CALL wrd_write_string( 'coupling_start_time' ) 
+       WRITE ( 14 )  coupling_start_time
+
+       CALL wrd_write_string( 'current_timestep_number' ) 
+       WRITE ( 14 )  current_timestep_number
+
+       CALL wrd_write_string( 'curvature_solution_effects' ) 
+       WRITE ( 14 )  curvature_solution_effects
+
+       CALL wrd_write_string( 'cycle_mg' ) 
+       WRITE ( 14 )  cycle_mg
+
+       CALL wrd_write_string( 'damp_level_1d' ) 
+       WRITE ( 14 )  damp_level_1d
+
+       CALL wrd_write_string( 'dissipation_1d' ) 
+       WRITE ( 14 )  dissipation_1d
+
+       CALL wrd_write_string( 'do2d_xy_time_count' ) 
+       WRITE ( 14 )  do2d_xy_time_count
+
+       CALL wrd_write_string( 'do2d_xz_time_count' ) 
+       WRITE ( 14 )  do2d_xz_time_count
+
+       CALL wrd_write_string( 'do2d_yz_time_count' ) 
+       WRITE ( 14 )  do2d_yz_time_count
+
+       CALL wrd_write_string( 'do3d_time_count' ) 
+       WRITE ( 14 )  do3d_time_count
+
+       CALL wrd_write_string( 'dp_external' ) 
+       WRITE ( 14 )  dp_external
+
+       CALL wrd_write_string( 'dp_level_b' ) 
+       WRITE ( 14 )  dp_level_b
+
+       CALL wrd_write_string( 'dp_smooth' ) 
+       WRITE ( 14 )  dp_smooth
+
+       CALL wrd_write_string( 'dpdxy' ) 
+       WRITE ( 14 )  dpdxy
+
+       CALL wrd_write_string( 'dt_3d' ) 
+       WRITE ( 14 )  dt_3d
+
+       CALL wrd_write_string( 'dt_pr_1d' ) 
+       WRITE ( 14 )  dt_pr_1d
+
+       CALL wrd_write_string( 'dt_run_control_1d' ) 
+       WRITE ( 14 )  dt_run_control_1d
+
+       CALL wrd_write_string( 'dvrp_filecount' ) 
+       WRITE ( 14 )  dvrp_filecount
+
+       CALL wrd_write_string( 'dx' ) 
+       WRITE ( 14 )  dx
+
+       CALL wrd_write_string( 'dy' ) 
+       WRITE ( 14 )  dy
+
+       CALL wrd_write_string( 'dz' ) 
+       WRITE ( 14 )  dz
+
+       CALL wrd_write_string( 'dz_max' ) 
+       WRITE ( 14 )  dz_max
+
+       CALL wrd_write_string( 'dz_stretch_factor' ) 
+       WRITE ( 14 )  dz_stretch_factor
+
+       CALL wrd_write_string( 'dz_stretch_level' ) 
+       WRITE ( 14 )  dz_stretch_level
+
+       CALL wrd_write_string( 'e_min' ) 
+       WRITE ( 14 )  e_min
+
+       CALL wrd_write_string( 'end_time_1d' ) 
+       WRITE ( 14 )  end_time_1d
+
+       CALL wrd_write_string( 'fft_method' ) 
+       WRITE ( 14 )  fft_method
+
+       CALL wrd_write_string( 'first_call_lpm' ) 
+       WRITE ( 14 )  first_call_lpm
+
+       CALL wrd_write_string( 'galilei_transformation' ) 
+       WRITE ( 14 )  galilei_transformation
+
+       CALL wrd_write_string( 'hom' ) 
+       WRITE ( 14 )  hom
+
+       CALL wrd_write_string( 'hom_sum' ) 
+       WRITE ( 14 )  hom_sum
+
+       CALL wrd_write_string( 'humidity' ) 
+       WRITE ( 14 )  humidity
+
+       IF ( ALLOCATED( inflow_damping_factor ) )  THEN
+          CALL wrd_write_string( 'inflow_damping_factor' ) 
+          WRITE ( 14 )  inflow_damping_factor
+       ENDIF
+
+       CALL wrd_write_string( 'inflow_damping_height' ) 
+       WRITE ( 14 )  inflow_damping_height
+
+       CALL wrd_write_string( 'inflow_damping_width' ) 
+       WRITE ( 14 )  inflow_damping_width
+
+       CALL wrd_write_string( 'inflow_disturbance_begin' ) 
+       WRITE ( 14 )  inflow_disturbance_begin
+
+       CALL wrd_write_string( 'inflow_disturbance_end' ) 
+       WRITE ( 14 )  inflow_disturbance_end
+
+       CALL wrd_write_string( 'km_constant' ) 
+       WRITE ( 14 )  km_constant
+
+       CALL wrd_write_string( 'large_scale_forcing' ) 
+       WRITE ( 14 )  large_scale_forcing
+
+       CALL wrd_write_string( 'large_scale_subsidence' ) 
+       WRITE ( 14 )  large_scale_subsidence
+
+       CALL wrd_write_string( 'latitude' ) 
+       WRITE ( 14 )  latitude
+
+       CALL wrd_write_string( 'limiter_sedimentation' ) 
+       WRITE ( 14 )  limiter_sedimentation
+
+       CALL wrd_write_string( 'longitude' )
+       WRITE ( 14 )  longitude 
+
+       CALL wrd_write_string( 'loop_optimization' ) 
+       WRITE ( 14 )  loop_optimization
+
+       CALL wrd_write_string( 'masking_method' ) 
+       WRITE ( 14 )  masking_method
+
+       IF ( ALLOCATED( mean_inflow_profiles ) )  THEN
+          CALL wrd_write_string( 'mean_inflow_profiles' ) 
+          WRITE ( 14 )  mean_inflow_profiles
+       ENDIF
+
+       CALL wrd_write_string( 'mg_cycles' ) 
+       WRITE ( 14 )  mg_cycles
+
+       CALL wrd_write_string( 'mg_switch_to_pe0_level' ) 
+       WRITE ( 14 )  mg_switch_to_pe0_level
+
+       CALL wrd_write_string( 'mixing_length_1d' ) 
+       WRITE ( 14 )  mixing_length_1d
+
+       CALL wrd_write_string( 'momentum_advec' ) 
+       WRITE ( 14 )  momentum_advec
+
+       CALL wrd_write_string( 'most_method' ) 
+       WRITE ( 14 )  most_method
+
+       CALL wrd_write_string( 'nc_const' ) 
+       WRITE ( 14 )  nc_const
+
+       CALL wrd_write_string( 'netcdf_precision' ) 
+       WRITE ( 14 )  netcdf_precision
+
+       CALL wrd_write_string( 'neutral' ) 
+       WRITE ( 14 )  neutral
+
+       CALL wrd_write_string( 'ngsrb' ) 
+       WRITE ( 14 )  ngsrb
+
+       CALL wrd_write_string( 'nsor' ) 
+       WRITE ( 14 )  nsor
+
+       CALL wrd_write_string( 'nsor_ini' ) 
+       WRITE ( 14 )  nsor_ini
+
+       CALL wrd_write_string( 'nudging' ) 
+       WRITE ( 14 )  nudging
+
+       CALL wrd_write_string( 'num_leg' ) 
+       WRITE ( 14 )  num_leg
+
+       CALL wrd_write_string( 'nx' ) 
+       WRITE ( 14 )  nx
+
+       CALL wrd_write_string( 'ny' ) 
+       WRITE ( 14 )  ny
+
+       CALL wrd_write_string( 'ocean' ) 
+       WRITE ( 14 )  ocean
+
+       CALL wrd_write_string( 'old_dt' ) 
+       WRITE ( 14 )  old_dt
+
+       CALL wrd_write_string( 'omega' ) 
+       WRITE ( 14 )  omega
+
+       CALL wrd_write_string( 'omega_sor' ) 
+       WRITE ( 14 )  omega_sor
+
+       CALL wrd_write_string( 'output_for_t0' ) 
+       WRITE ( 14 )  output_for_t0
+
+       CALL wrd_write_string( 'passive_scalar' ) 
+       WRITE ( 14 )  passive_scalar
+
+       CALL wrd_write_string( 'prandtl_number' ) 
+       WRITE ( 14 )  prandtl_number
+
+       CALL wrd_write_string( 'precipitation' ) 
+       WRITE ( 14 )  precipitation
+
+       CALL wrd_write_string( 'psolver' )
+       WRITE ( 14 )  psolver 
+
+       CALL wrd_write_string( 'pt_damping_factor' ) 
+       WRITE ( 14 )  pt_damping_factor
+
+       CALL wrd_write_string( 'pt_damping_width' ) 
+       WRITE ( 14 )  pt_damping_width
+
+       CALL wrd_write_string( 'pt_init' ) 
+       WRITE ( 14 )  pt_init
+
+       CALL wrd_write_string( 'pt_reference' ) 
+       WRITE ( 14 )  pt_reference
+
+       CALL wrd_write_string( 'pt_surface' ) 
+       WRITE ( 14 )  pt_surface
+
+       CALL wrd_write_string( 'pt_surface_initial_change' ) 
+       WRITE ( 14 )  pt_surface_initial_change
+
+       CALL wrd_write_string( 'pt_vertical_gradient' ) 
+       WRITE ( 14 )  pt_vertical_gradient
+
+       CALL wrd_write_string( 'pt_vertical_gradient_level' ) 
+       WRITE ( 14 )  pt_vertical_gradient_level
+
+       CALL wrd_write_string( 'pt_vertical_gradient_level_ind' ) 
+       WRITE ( 14 )  pt_vertical_gradient_level_ind
+
+       CALL wrd_write_string( 'q_init' ) 
+       WRITE ( 14 )  q_init
+
+       CALL wrd_write_string( 'q_surface' ) 
+       WRITE ( 14 )  q_surface
+
+       CALL wrd_write_string( 'q_surface_initial_change' ) 
+       WRITE ( 14 )  q_surface_initial_change
+
+       CALL wrd_write_string( 'q_vertical_gradient' ) 
+       WRITE ( 14 )  q_vertical_gradient
+
+       CALL wrd_write_string( 'q_vertical_gradient_level' ) 
+       WRITE ( 14 )  q_vertical_gradient_level
+
+       CALL wrd_write_string( 'q_vertical_gradient_level_ind' ) 
+       WRITE ( 14 )  q_vertical_gradient_level_ind
+
+       CALL wrd_write_string( 'random_generator' ) 
+       WRITE ( 14 )  random_generator
+
+       CALL wrd_write_string( 'random_heatflux' ) 
+       WRITE ( 14 )  random_heatflux
+
+       CALL wrd_write_string( 'rans_mode' ) 
+       WRITE ( 14 )  rans_mode
+
+       CALL wrd_write_string( 'rayleigh_damping_factor' ) 
+       WRITE ( 14 )  rayleigh_damping_factor
+
+       CALL wrd_write_string( 'rayleigh_damping_height' ) 
+       WRITE ( 14 )  rayleigh_damping_height
+
+       CALL wrd_write_string( 'recycling_width' ) 
+       WRITE ( 14 )  recycling_width
+
+       CALL wrd_write_string( 'recycling_yshift' ) 
+       WRITE ( 14 )  recycling_yshift
+
+       CALL wrd_write_string( 'ref_state' ) 
+       WRITE ( 14 )  ref_state
+
+       CALL wrd_write_string( 'reference_state' ) 
+       WRITE ( 14 )  reference_state
+
+       CALL wrd_write_string( 'residual_limit' ) 
+       WRITE ( 14 )  residual_limit
+
+       CALL wrd_write_string( 'roughness_length' ) 
+       WRITE ( 14 )  roughness_length
+
+       CALL wrd_write_string( 'run_coupled' ) 
+       WRITE ( 14 )  run_coupled
+
+       CALL wrd_write_string( 'runnr' ) 
+       WRITE ( 14 )  runnr
+
+       CALL wrd_write_string( 's_init' ) 
+       WRITE ( 14 )  s_init
+
+       CALL wrd_write_string( 's_surface' ) 
+       WRITE ( 14 )  s_surface
+
+       CALL wrd_write_string( 's_surface_initial_change' ) 
+       WRITE ( 14 )  s_surface_initial_change
+
+       CALL wrd_write_string( 's_vertical_gradient' ) 
+       WRITE ( 14 )  s_vertical_gradient
+
+       CALL wrd_write_string( 's_vertical_gradient_level' ) 
+       WRITE ( 14 )  s_vertical_gradient_level
+
+       CALL wrd_write_string( 's_vertical_gradient_level_ind' ) 
+       WRITE ( 14 )  s_vertical_gradient_level_ind
+
+       CALL wrd_write_string( 'sa_init' ) 
+       WRITE ( 14 )  sa_init
+
+       CALL wrd_write_string( 'sa_surface' ) 
+       WRITE ( 14 )  sa_surface
+
+       CALL wrd_write_string( 'sa_vertical_gradient' ) 
+       WRITE ( 14 )  sa_vertical_gradient
+
+       CALL wrd_write_string( 'sa_vertical_gradient_level' ) 
+       WRITE ( 14 )  sa_vertical_gradient_level
+
+       CALL wrd_write_string( 'scalar_advec' ) 
+       WRITE ( 14 )  scalar_advec
+
+       CALL wrd_write_string( 'simulated_time' ) 
+       WRITE ( 14 )  simulated_time
+
+       CALL wrd_write_string( 'surface_heatflux' ) 
+       WRITE ( 14 )  surface_heatflux
+
+       CALL wrd_write_string( 'surface_pressure' ) 
+       WRITE ( 14 )  surface_pressure
+
+       CALL wrd_write_string( 'surface_scalarflux' ) 
+       WRITE ( 14 )  surface_scalarflux
+
+       CALL wrd_write_string( 'surface_waterflux' ) 
+       WRITE ( 14 )  surface_waterflux
+
+       CALL wrd_write_string( 'time_coupling' ) 
+       WRITE ( 14 )  time_coupling
+
+       CALL wrd_write_string( 'time_disturb' ) 
+       WRITE ( 14 )  time_disturb
+
+       CALL wrd_write_string( 'time_do2d_xy' ) 
+       WRITE ( 14 )  time_do2d_xy
+
+       CALL wrd_write_string( 'time_do2d_xz' ) 
+       WRITE ( 14 )  time_do2d_xz
+
+       CALL wrd_write_string( 'time_do2d_yz' ) 
+       WRITE ( 14 )  time_do2d_yz
+
+       CALL wrd_write_string( 'time_do3d' ) 
+       WRITE ( 14 )  time_do3d
+
+       CALL wrd_write_string( 'time_do_av' ) 
+       WRITE ( 14 )  time_do_av
+
+       CALL wrd_write_string( 'time_do_sla' ) 
+       WRITE ( 14 )  time_do_sla
+
+       CALL wrd_write_string( 'time_domask' ) 
+       WRITE ( 14 )  time_domask
+
+       CALL wrd_write_string( 'time_dopr' ) 
+       WRITE ( 14 )  time_dopr
+
+       CALL wrd_write_string( 'time_dopr_av' ) 
+       WRITE ( 14 )  time_dopr_av
+
+       CALL wrd_write_string( 'time_dopr_listing' ) 
+       WRITE ( 14 )  time_dopr_listing
+
+       CALL wrd_write_string( 'time_dopts' ) 
+       WRITE ( 14 )  time_dopts
+
+       CALL wrd_write_string( 'time_dosp' ) 
+       WRITE ( 14 )  time_dosp
+
+       CALL wrd_write_string( 'time_dots' ) 
+       WRITE ( 14 )  time_dots
+
+       CALL wrd_write_string( 'time_dvrp' ) 
+       WRITE ( 14 )  time_dvrp
+
+       CALL wrd_write_string( 'time_radiation' ) 
+       WRITE ( 14 )  time_radiation
+
+       CALL wrd_write_string( 'time_restart' ) 
+       WRITE ( 14 )  time_restart
+
+       CALL wrd_write_string( 'time_run_control' ) 
+       WRITE ( 14 )  time_run_control
+
+       CALL wrd_write_string( 'time_since_reference_point' ) 
+       WRITE ( 14 )  time_since_reference_point
+
+       CALL wrd_write_string( 'timestep_scheme' ) 
+       WRITE ( 14 )  timestep_scheme
+
+       CALL wrd_write_string( 'top_heatflux' ) 
+       WRITE ( 14 )  top_heatflux
+
+       CALL wrd_write_string( 'top_momentumflux_u' ) 
+       WRITE ( 14 )  top_momentumflux_u
+
+       CALL wrd_write_string( 'top_momentumflux_v' ) 
+       WRITE ( 14 )  top_momentumflux_v
+
+       CALL wrd_write_string( 'top_salinityflux' ) 
+       WRITE ( 14 )  top_salinityflux
+
+       CALL wrd_write_string( 'top_scalarflux' ) 
+       WRITE ( 14 )  top_scalarflux
+
+       CALL wrd_write_string( 'topography' ) 
+       WRITE ( 14 )  topography
+
+       CALL wrd_write_string( 'topography_grid_convention' ) 
+       WRITE ( 14 )  topography_grid_convention
+
+       CALL wrd_write_string( 'tsc' ) 
+       WRITE ( 14 )  tsc
+
+       CALL wrd_write_string( 'tunnel_height' ) 
+       WRITE ( 14 )  tunnel_height
+
+       CALL wrd_write_string( 'tunnel_length' ) 
+       WRITE ( 14 )  tunnel_length
+
+       CALL wrd_write_string( 'tunnel_wall_depth' ) 
+       WRITE ( 14 )  tunnel_wall_depth
+
+       CALL wrd_write_string( 'tunnel_width_x' ) 
+       WRITE ( 14 )  tunnel_width_x
+
+       CALL wrd_write_string( 'tunnel_width_y' ) 
+       WRITE ( 14 )  tunnel_width_y
+
+       CALL wrd_write_string( 'turbulence_closure' ) 
+       WRITE ( 14 )  turbulence_closure
+
+       CALL wrd_write_string( 'turbulent_inflow' ) 
+       WRITE ( 14 )  turbulent_inflow
+
+       CALL wrd_write_string( 'u_bulk' ) 
+       WRITE ( 14 )  u_bulk
+
+       CALL wrd_write_string( 'u_init' ) 
+       WRITE ( 14 )  u_init
+
+       CALL wrd_write_string( 'u_max' ) 
+       WRITE ( 14 )  u_max
+
+       CALL wrd_write_string( 'u_max_ijk' ) 
+       WRITE ( 14 )  u_max_ijk
+
+       CALL wrd_write_string( 'ug' ) 
+       WRITE ( 14 )  ug
+
+       CALL wrd_write_string( 'ug_surface' ) 
+       WRITE ( 14 )  ug_surface
+
+       CALL wrd_write_string( 'ug_vertical_gradient' ) 
+       WRITE ( 14 )  ug_vertical_gradient
+
+       CALL wrd_write_string( 'ug_vertical_gradient_level' ) 
+       WRITE ( 14 )  ug_vertical_gradient_level
+
+       CALL wrd_write_string( 'ug_vertical_gradient_level_ind' ) 
+       WRITE ( 14 )  ug_vertical_gradient_level_ind
+
+       CALL wrd_write_string( 'use_surface_fluxes' ) 
+       WRITE ( 14 )  use_surface_fluxes
+
+       CALL wrd_write_string( 'use_top_fluxes' ) 
+       WRITE ( 14 )  use_top_fluxes
+
+       CALL wrd_write_string( 'use_ug_for_galilei_tr' ) 
+       WRITE ( 14 )  use_ug_for_galilei_tr
+
+       CALL wrd_write_string( 'use_upstream_for_tke' ) 
+       WRITE ( 14 )  use_upstream_for_tke
+
+       CALL wrd_write_string( 'v_bulk' ) 
+       WRITE ( 14 )  v_bulk
+
+       CALL wrd_write_string( 'v_init' ) 
+       WRITE ( 14 )  v_init
+
+       CALL wrd_write_string( 'v_max' ) 
+       WRITE ( 14 )  v_max
+
+       CALL wrd_write_string( 'v_max_ijk' ) 
+       WRITE ( 14 )  v_max_ijk
+
+       CALL wrd_write_string( 'ventilation_effect' ) 
+       WRITE ( 14 )  ventilation_effect
+
+       CALL wrd_write_string( 'vg' ) 
+       WRITE ( 14 )  vg
+
+       CALL wrd_write_string( 'vg_surface' ) 
+       WRITE ( 14 )  vg_surface
+
+       CALL wrd_write_string( 'vg_vertical_gradient' ) 
+       WRITE ( 14 ) vg_vertical_gradient
+
+       CALL wrd_write_string( 'vg_vertical_gradient_level' ) 
+       WRITE ( 14 )  vg_vertical_gradient_level
+
+       CALL wrd_write_string( 'vg_vertical_gradient_level_ind' ) 
+       WRITE ( 14 )  vg_vertical_gradient_level_ind
+
+       CALL wrd_write_string( 'virtual_flight' ) 
+       WRITE ( 14 )  virtual_flight
+
+       CALL wrd_write_string( 'vnest_init' ) 
+       WRITE ( 14 )  vnest_init
+
+       CALL wrd_write_string( 'volume_flow_area' ) 
+       WRITE ( 14 )  volume_flow_area
+
+       CALL wrd_write_string( 'volume_flow_initial' ) 
+       WRITE ( 14 )  volume_flow_initial
+
+       CALL wrd_write_string( 'subs_vertical_gradient' ) 
+       WRITE ( 14 )  subs_vertical_gradient
+
+       CALL wrd_write_string( 'subs_vertical_gradient_level' ) 
+       WRITE ( 14 )  subs_vertical_gradient_level
+
+       CALL wrd_write_string( 'subs_vertical_gradient_level_i' ) 
+       WRITE ( 14 )  subs_vertical_gradient_level_i
+
+       CALL wrd_write_string( 'w_max' ) 
+       WRITE ( 14 )  w_max
+
+       CALL wrd_write_string( 'w_max_ijk' ) 
+       WRITE ( 14 )  w_max_ijk
+
+       CALL wrd_write_string( 'wall_adjustment' ) 
+       WRITE ( 14 )  wall_adjustment
+
+       CALL wrd_write_string( 'wall_heatflux' ) 
+       WRITE ( 14 )  wall_heatflux
+
+       CALL wrd_write_string( 'wall_humidityflux' ) 
+       WRITE ( 14 )  wall_humidityflux
+
+       CALL wrd_write_string( 'wall_salinityflux' ) 
+       WRITE ( 14 )  wall_salinityflux
+
+       CALL wrd_write_string( 'wall_scalarflux' ) 
+       WRITE ( 14 )  wall_scalarflux
+
+       CALL wrd_write_string( 'y_shift' ) 
+       WRITE ( 14 )  y_shift
+
+       CALL wrd_write_string( 'z0h_factor' ) 
+       WRITE ( 14 )  z0h_factor
+
+       CALL wrd_write_string( 'zeta_max' ) 
+       WRITE ( 14 )  zeta_max
+
+       CALL wrd_write_string( 'zeta_min' ) 
+       WRITE ( 14 )  zeta_min
+
+
+!    
+!-- The order of the calls can be different as in read_restart_data_mod where
+!-- the restart data will be read 
+!
+!-- If required, write restart data for wind turbine model.
+       IF ( wind_turbine )  CALL wtm_wrd_global
+
+!
+!-- If required, write restart data for virtual measurements.
+       IF ( virtual_flight )  CALL flight_wrd_global
+
+!
+!-- If required, write restart data for turbulence generator.
+       IF ( syn_turb_gen )  CALL stg_wrd_global
+
+!
+!-- Write restart data for user data.
+       CALL user_wrd_global
+
+
+    END SUBROUTINE wrd_global
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Processor specific data of variables and arrays is written out for 
+!> restarts (binary format).
+!> This information is written to the file opened by each PE.
+!------------------------------------------------------------------------------!
+    SUBROUTINE wrd_local
+ 
+
+       USE arrays_3d,                                                          &
+           ONLY:  e, kh, km, p, pt, q, ql, qc, nc, nr, prr,                    &
+                  precipitation_amount, qr, s, sa, u, u_m_l, u_m_n, u_m_r,     &
+                  u_m_s, v, v_m_l, v_m_n, v_m_r, v_m_s, vpt, w, w_m_l, w_m_n,  &
+                  w_m_r, w_m_s
+        
+       USE averaging
+
+       USE chemistry_model_mod,                                                &
+           ONLY:  chem_wrd_local
+                
+       USE indices,                                                            &
+           ONLY:  nxl, nxr, nys, nyn, nzb, nzt
+
+       USE land_surface_model_mod,                                             &
+           ONLY:  lsm_wrd_local
+        
+       USE particle_attributes,                                                &
+           ONLY:  iran_part
+
+       USE radiation_model_mod,                                                &
+           ONLY:  radiation, radiation_wrd_local
+    
+       USE random_function_mod,                                                &
+           ONLY:  random_iv, random_iy
+
+       USE random_generator_parallel,                                          &
+           ONLY:  id_random_array, seq_random_array
+        
+       USE spectra_mod,                                                        &
+           ONLY:  spectrum_x, spectrum_y
+
+       USE surface_mod,                                                        &
+           ONLY :  surface_wrd_local
+
+       USE urban_surface_mod,                                                  &
+           ONLY:  usm_wrd_local    
+
+       USE user_write_restart_data_mod,                                        &
+           ONLY:  user_wrd_local 
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=10) ::  binary_version_local   !< 
+
+
+!
+!-- Write arrays.
+       binary_version_local = '4.7'
+
+       CALL wrd_write_string( 'binary_version_local' )
+       WRITE ( 14 )  binary_version_local
+
+       WRITE ( 14 )  numprocs, myid, nxl, nxr, nys, nyn, nzb, nzt
+
+!
+!-- Attention: After changes to the following output commands the version number
+!-- ---------  of the variable binary_version_local must be changed!
+!--            Also, the list of arrays to be read in rrd_local must be
+!--            adjusted accordingly.
+       CALL wrd_write_string( 'e' ) 
+       WRITE ( 14 )  e
+
+       IF ( ALLOCATED( e_av ) )  THEN
+          CALL wrd_write_string( 'e_av' ) 
+          WRITE ( 14 )  e_av
+       ENDIF
+
+       CALL wrd_write_string( 'iran' ) 
+       WRITE ( 14 )  iran, iran_part 
+
+       CALL wrd_write_string( 'kh' ) 
+       WRITE ( 14 )  kh
+  
+
+       IF ( ALLOCATED( kh_av ) )  THEN
+          CALL wrd_write_string( 'kh_av' ) 
+          WRITE ( 14 )  kh_av
+       ENDIF
+
+       CALL wrd_write_string( 'km' ) 
+       WRITE ( 14 )  km
+
+       IF ( ALLOCATED( km_av ) )  THEN
+          CALL wrd_write_string( 'km_av' ) 
+          WRITE ( 14 )  km_av
+       ENDIF
+
+       IF ( ALLOCATED( lpt_av ) )  THEN
+          CALL wrd_write_string( 'lpt_av' ) 
+          WRITE ( 14 )  lpt_av
+       ENDIF
+
+       IF ( ALLOCATED( lwp_av ) )  THEN
+          CALL wrd_write_string( 'lwp_av' ) 
+          WRITE ( 14 )  lwp_av
+       ENDIF
+
+       CALL wrd_write_string( 'p' ) 
+       WRITE ( 14 )  p
+
+       IF ( ALLOCATED( p_av ) )  THEN
+          CALL wrd_write_string( 'p_av' ) 
+          WRITE ( 14 )  p_av
+       ENDIF
+
+       IF ( ALLOCATED( pc_av ) )  THEN
+          CALL wrd_write_string( 'pc_av' ) 
+          WRITE ( 14 )  pc_av
+       ENDIF
+
+       IF ( ALLOCATED( pr_av ) )  THEN
+          CALL wrd_write_string( 'pr_av' ) 
+          WRITE ( 14 )  pr_av
+       ENDIF
+
+       IF ( ALLOCATED( prr ) )  THEN
+          CALL wrd_write_string( 'prr' ) 
+          WRITE ( 14 )  prr
+       ENDIF
+
+       IF ( ALLOCATED( prr_av ) )  THEN
+          CALL wrd_write_string( 'prr_av' ) 
+          WRITE ( 14 )  prr_av
+       ENDIF
+
+       IF ( ALLOCATED( precipitation_amount ) )  THEN
+          CALL wrd_write_string( 'precipitation_amount' ) 
+          WRITE ( 14 )  precipitation_amount
+       ENDIF
+
+       IF ( ALLOCATED( precipitation_rate_av ) )  THEN
+          CALL wrd_write_string( 'precipitation_rate_av' ) 
+          WRITE ( 14 )  precipitation_rate_av
+       ENDIF
+
+       CALL wrd_write_string( 'pt' ) 
+       WRITE ( 14 )  pt
+
+       IF ( ALLOCATED( pt_av ) )  THEN
+          CALL wrd_write_string( 'pt_av' ) 
+          WRITE ( 14 )  pt_av
+       ENDIF
+
+       IF ( humidity )  THEN
+
+          CALL wrd_write_string( 'q' ) 
+          WRITE ( 14 )  q
+
+          IF ( ALLOCATED( q_av ) )  THEN
+             CALL wrd_write_string( 'q_av' ) 
+             WRITE ( 14 )  q_av
+          ENDIF
+
+          IF ( cloud_physics  .OR.  cloud_droplets )  THEN
+
+             CALL wrd_write_string( 'ql' ) 
+             WRITE ( 14 )  ql
+
+             IF ( ALLOCATED( ql_av ) )  THEN
+                CALL wrd_write_string( 'ql_av' ) 
+                WRITE ( 14 )  ql_av
+             ENDIF
+
+             IF ( .NOT. cloud_droplets )  THEN
+
+                CALL wrd_write_string( 'qc' ) 
+                WRITE ( 14 )  qc
+
+                IF ( ALLOCATED( qc_av ) )  THEN
+                   CALL wrd_write_string( 'qc_av' ) 
+                   WRITE ( 14 )  qc_av
+                ENDIF
+
+                IF ( microphysics_morrison )  THEN
+
+                   CALL wrd_write_string( 'nc' ) 
+                   WRITE ( 14 )  nc
+
+                   IF ( ALLOCATED( nc_av ) )  THEN
+                      CALL wrd_write_string( 'nc_av' ) 
+                      WRITE ( 14 )  nc_av
+                   ENDIF
+
+                ENDIF
+
+                IF ( microphysics_seifert )  THEN
+
+                   CALL wrd_write_string( 'nr' ) 
+                   WRITE ( 14 )  nr
+
+                   IF ( ALLOCATED( nr_av ) )  THEN
+                      CALL wrd_write_string( 'nr_av' ) 
+                      WRITE ( 14 )  nr_av
+                   ENDIF
+
+                   CALL wrd_write_string( 'qr' ) 
+                   WRITE ( 14 )  qr
+
+                   IF ( ALLOCATED( qr_av ) )  THEN
+                      CALL wrd_write_string( 'qr_av' ) 
+                      WRITE ( 14 )  qr_av
+                   ENDIF
+
+                ENDIF
+             ENDIF
+          ENDIF
+
+          IF ( ALLOCATED( qsws_av ) )  THEN
+             CALL wrd_write_string( 'qsws_av' ) 
+             WRITE ( 14 )  qsws_av
+          ENDIF
+
+       ENDIF
+
+       IF ( passive_scalar )  THEN
+
+          CALL wrd_write_string( 's' ) 
+          WRITE ( 14 )  s
+
+          IF ( ALLOCATED( s_av ) )  THEN
+             CALL wrd_write_string( 's_av' ) 
+             WRITE ( 14 )  s_av
+          ENDIF
+
+          IF ( ALLOCATED( ssws_av ) )  THEN
+             CALL wrd_write_string( 'ssws_av' ) 
+             WRITE ( 14 )  ssws_av
+          ENDIF
+
+       ENDIF
+       
+       IF ( ocean )  THEN
+
+          IF ( ALLOCATED( rho_ocean_av ) )  THEN
+             CALL wrd_write_string( 'rho_ocean_av' ) 
+             WRITE ( 14 )  rho_ocean_av
+          ENDIF
+
+          CALL wrd_write_string( 'sa' ) 
+          WRITE ( 14 )  sa
+
+          IF ( ALLOCATED( sa_av ) )  THEN
+             CALL wrd_write_string( 'sa_av' ) 
+             WRITE ( 14 )  sa_av
+          ENDIF
+
+       ENDIF
+
+       IF ( ALLOCATED( ql_c_av ) )  THEN
+          CALL wrd_write_string( 'ql_c_av' ) 
+          WRITE ( 14 )  ql_c_av
+       ENDIF
+
+       IF ( ALLOCATED( ql_v_av ) )  THEN
+          CALL wrd_write_string( 'ql_v_av' ) 
+          WRITE ( 14 )  ql_v_av
+       ENDIF
+
+       IF ( ALLOCATED( ql_vp_av ) )  THEN
+          CALL wrd_write_string( 'ql_vp_av' ) 
+          WRITE ( 14 )  ql_vp_av
+       ENDIF
+
+       IF ( ALLOCATED( qv_av ) )  THEN
+          CALL wrd_write_string( 'qv_av' ) 
+          WRITE ( 14 )  qv_av
+       ENDIF
+
+       CALL wrd_write_string( 'random_iv' ) 
+       WRITE ( 14 )  random_iv
+       WRITE ( 14 )  random_iy
+
+       IF ( ALLOCATED( seq_random_array ) )  THEN
+          CALL wrd_write_string( 'seq_random_array' ) 
+          WRITE ( 14 )  id_random_array
+          WRITE ( 14 )  seq_random_array 
+       ENDIF
+
+       IF ( ALLOCATED( s_av ) )  THEN
+          CALL wrd_write_string( 's_av' ) 
+          WRITE ( 14 )  s_av
+       ENDIF
+
+       IF ( ALLOCATED( shf_av ) )  THEN
+          CALL wrd_write_string( 'shf_av' ) 
+          WRITE ( 14 )  shf_av
+       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' ) 
+          WRITE ( 14 ) ts_av
+       ENDIF
+
+       CALL wrd_write_string( 'u' ) 
+       WRITE ( 14 )  u
+
+       IF ( ALLOCATED( u_av ) )  THEN
+          CALL wrd_write_string( 'u_av' ) 
+          WRITE ( 14 )  u_av
+       ENDIF
+
+       IF ( ALLOCATED( u_m_l ) )  THEN
+          CALL wrd_write_string( 'u_m_l' ) 
+          WRITE ( 14 )  u_m_l
+       ENDIF
+
+       IF ( ALLOCATED( u_m_n ) )  THEN
+          CALL wrd_write_string( 'u_m_n' ) 
+          WRITE ( 14 )  u_m_n
+       ENDIF
+
+       IF ( ALLOCATED( u_m_r ) )  THEN
+          CALL wrd_write_string( 'u_m_r' ) 
+          WRITE ( 14 )  u_m_r
+       ENDIF
+
+       IF ( ALLOCATED( u_m_s ) )  THEN
+          CALL wrd_write_string( 'u_m_s' ) 
+          WRITE ( 14 )  u_m_s
+       ENDIF
+
+       IF ( ALLOCATED( us_av ) )  THEN
+          CALL wrd_write_string( 'us_av' ) 
+          WRITE ( 14 )  us_av
+       ENDIF
+
+       CALL wrd_write_string( 'v' ) 
+       WRITE ( 14 )  v
+
+       IF ( ALLOCATED( v_av ) )  THEN
+          CALL wrd_write_string( 'v_av' ) 
+          WRITE ( 14 )  v_av
+       ENDIF
+
+       IF ( ALLOCATED( v_m_l  ) )  THEN
+          CALL wrd_write_string( 'v_m_l' ) 
+          WRITE ( 14 )  v_m_l
+       ENDIF
+
+       IF ( ALLOCATED( v_m_n ) )  THEN
+          CALL wrd_write_string( 'v_m_n' ) 
+          WRITE ( 14 )  v_m_n
+       ENDIF
+
+       IF ( ALLOCATED( v_m_r ) )  THEN
+          CALL wrd_write_string( 'v_m_r' ) 
+          WRITE ( 14 )  v_m_r
+       ENDIF
+
+       IF ( ALLOCATED( v_m_s ) )  THEN
+          CALL wrd_write_string( 'v_m_s' ) 
+          WRITE ( 14 )  v_m_s
+       ENDIF
+
+       IF ( humidity )  THEN
+
+          CALL wrd_write_string( 'vpt' ) 
+          WRITE ( 14 )  vpt
+
+          IF ( ALLOCATED( vpt_av ) )  THEN
+             CALL wrd_write_string( 'vpt_av' ) 
+             WRITE ( 14 ) vpt_av
+          ENDIF
+
+       ENDIF
+
+       CALL wrd_write_string( 'w' ) 
+       WRITE ( 14 )  w
+
+       IF ( ALLOCATED( w_av ) )  THEN
+          CALL wrd_write_string( 'w_av' ) 
+          WRITE ( 14 )  w_av
+       ENDIF
+
+       IF ( ALLOCATED( w_m_l ) )  THEN
+          CALL wrd_write_string( 'w_m_l' ) 
+          WRITE ( 14 )  w_m_l
+       ENDIF
+
+       IF ( ALLOCATED( w_m_n ) )  THEN
+          CALL wrd_write_string( 'w_m_n' ) 
+          WRITE ( 14 )  w_m_n
+       ENDIF
+
+       IF ( ALLOCATED( w_m_r ) )  THEN
+          CALL wrd_write_string( 'w_m_r' ) 
+          WRITE ( 14 )  w_m_r
+       ENDIF
+
+       IF ( ALLOCATED( w_m_s ) )  THEN
+          CALL wrd_write_string( 'w_m_s' ) 
+          WRITE ( 14 )  w_m_s
+       ENDIF
+
+       IF ( ALLOCATED( z0_av ) )  THEN
+          CALL wrd_write_string( 'z0_av' ) 
+          WRITE ( 14 )  z0_av
+       ENDIF
+
+       IF ( ALLOCATED( z0h_av ) )  THEN
+          CALL wrd_write_string( 'z0h_av' ) 
+          WRITE ( 14 )  z0h_av
+       ENDIF
+
+       IF ( ALLOCATED( z0q_av ) )  THEN
+          CALL wrd_write_string( 'z0q_av' ) 
+          WRITE ( 14 )  z0q_av
+       ENDIF
+
+       IF ( land_surface  .OR.  urban_surface )  THEN
+
+          IF ( ALLOCATED( ghf_av ) )  THEN
+             CALL wrd_write_string( 'ghf_av' ) 
+             WRITE ( 14 )  ghf_av
+          ENDIF
+
+          IF ( ALLOCATED( r_a_av ) )  THEN
+             CALL wrd_write_string( 'r_a_av' ) 
+             WRITE ( 14 )  r_a_av
+          ENDIF
+
+       ENDIF
+
+       IF ( ALLOCATED( tsurf_av ) )  THEN
+          CALL wrd_write_string( 'tsurf_av' ) 
+          WRITE ( 14 )  tsurf_av
+       ENDIF
+
+!
+!-- Write surface-related restart data.
+       CALL surface_wrd_local
+
+!
+!-- If required, write restart data for urban surface model.
+       IF ( urban_surface )  THEN
+          CALL usm_wrd_local
+       ENDIF
+
+!
+!-- If required, write restart data for land surface model.
+       IF ( land_surface )  THEN
+          CALL lsm_wrd_local
+       ENDIF
+
+!
+!-- If required, write restart data for radiation model.
+       IF ( radiation )  THEN
+          CALL radiation_wrd_local
+       ENDIF
+
+!
+!-- If required, write restart data for chemistry model.
+       IF ( air_chemistry )  THEN
+          CALL chem_wrd_local
+       ENDIF
+
+!
+!-- Write user-related restart data.
+       CALL user_wrd_local
+
+!--    Write end label.
+       CALL wrd_write_string( '*** end ***' )
+
+    END SUBROUTINE wrd_local
+
+
+ END MODULE write_restart_data_mod
Index: palm/trunk/SOURCE/write_var_list.f90
===================================================================
--- palm/trunk/SOURCE/write_var_list.f90	(revision 2893)
+++ 	(revision )
@@ -1,803 +1,0 @@
-!> @file write_var_list.f90
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2018 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Added spinup_time to allow for restarts with spinup in precursor run.
-! 
-! 2776 2018-01-31 10:44:42Z Giersch
-! Variable synthetic_turbulence_generator has been abbreviated
-! 
-! 2718 2018-01-02 08:49:38Z maronga
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-! + rans_mode, turbulence_closure (TG)
-! Implementation of chemistry module (FK)
-! Removal of chemistry module part. It is not needed and causes bugs (FK)
-! 
-! 2576 2017-10-24 13:49:46Z Giersch
-! The end of the standard parameter list is again marked with *** end *** like 
-! it was before revision 2563
-! 
-! 2575 2017-10-24 09:57:58Z maronga
-! Renamed phi -> latitude, added longitude
-! 
-! 2574 2017-10-23 09:02:53Z Giersch
-! Bugfix: Increased length of the character string *** end ***
-! 
-! 2563 2017-10-19 15:36:10Z Giersch
-! Function call wtm_write_restart_data was added and the end of the standard 
-! parameter list is now marked with *** end default ***. The end of the whole
-! parameter list including module parameter is marked with *** end ***
-! 
-! 2372 2017-08-25 12:37:32Z sward
-! y_shift added to vars, version no. increased
-! 
-! 2365 2017-08-21 14:59:59Z kanani
-! Vertical nesting implemented (SadiqHuq)
-! 
-! 2339 2017-08-07 13:55:26Z gronemeier
-! corrected timestamp in header
-! 
-! 2338 2017-08-07 12:15:38Z gronemeier
-! Modularize 1D model
-! 
-! 2265 2017-06-08 16:58:28Z schwenkel
-! Unused variables removed.
-! 
-! 2259 2017-06-08 09:09:11Z gronemeier
-! Implemented synthetic turbulence generator
-!
-! 2233 2017-05-30 18:08:54Z suehring
-!
-! 2232 2017-05-30 17:47:52Z suehring
-! Replace wall_qflux, wall_sflux by wall_humidityflux and wall_scalarflux; add
-! wall_salinityflux
-! +tunnel_height, tunnel_lenth, tunnel_width_x, tunnel_width_y,
-! tunnel_wall_depth
-!
-! 2042 2016-11-02 13:47:31Z suehring
-! Bugfix, write restart data for wall_heatflux, wall_qflux and wall_sflux
-!
-! 2000 2016-08-20 18:09:15Z knoop
-! Forced header and separation lines into 80 columns
-!
-! 1992 2016-08-12 15:14:59Z suehring
-! top scalarflux added
-!
-! 1957 2016-07-07 10:43:48Z suehring
-! flight module added
-!
-! 1849 2016-04-08 11:33:18Z hoffmann
-! Adapted for modularization of microphysics
-!
-! 1833 2016-04-07 14:23:03Z raasch
-! spectra_mod added
-!
-! 1831 2016-04-07 13:15:51Z hoffmann
-! turbulence renamed collision_turbulence, drizzle renamed
-! cloud_water_sedimentation
-!
-! 1783 2016-03-06 18:36:17Z raasch
-! netcdf module name changed + related changes
-!
-! 1705 2015-11-02 14:28:56Z maronga
-! Bugfix: two lines required swapping
-!
-! 1691 2015-10-26 16:17:44Z maronga
-! Added output of most_method, constant_flux_layer, zeta_min, zeta_max. Removed
-! output of prandtl_layer and rif_min, rif_max.
-!
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable
-!
-! 1585 2015-04-30 07:05:52Z maronga
-! Adapted for RRTMG
-!
-! 1551 2015-03-03 14:18:16Z maronga
-! Typo removed
-!
-! 1502 2014-12-03 18:22:31Z kanani
-! Canopy module and parameters removed (parameters are always read from
-! canopy_par NAMELIST for initial and restart runs),
-! Bugfix: added blanks in "cloud_top_radiation"-string to a total of 30
-! characters
-!
-! 1496 2014-12-02 17:25:50Z maronga
-! Renamed "radiation" -> "cloud_top_radiation"
-!
-! 1484 2014-10-21 10:53:05Z kanani
-! Changes in the course of the canopy-model modularization:
-!   parameters alpha_lad, beta_lad, lai_beta added,
-!   module plant_canopy_model_mod added,
-!   drag_coefficient, leaf_surface_concentration and scalar_exchange_coefficient
-!   renamed to canopy_drag_coeff, leaf_surface_conc and leaf_scalar_exch_coeff
-!
-! 1324 2014-03-21 09:13:16Z suehring
-! Bugfix: ONLY statement for module netcdf_control removed
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements
-!
-! 1308 2014-03-13 14:58:42Z fricke
-! +do2d_xy_time_count, do2d_xz_time_count, do2d_yz_time_count,
-! +do3d_time_count
-!
-! 1241 2013-10-30 11:36:58Z heinze
-! +nudging
-! +large_scale_forcing
-!
-! 1179 2013-06-14 05:57:58Z raasch
-! +reference_state, ref_state
-!
-! 1115 2013-03-26 18:16:16Z hoffmann
-! unused variables removed
-!
-! 1065 2012-11-22 17:42:36Z hoffmann
-! +nc, c_sedimentation, turbulence, limiter_sedimentation
-! -mu_constant, mu_constant_value
-!
-! 1053 2012-11-13 17:11:03Z hoffmann
-! necessary expansions according to the two new prognostic equations (nr, qr)
-! of the two-moment cloud physics scheme:
-! +bc_*_b, bc_*_t, bc_*_t_val, *_init, *_surface, *_surface_initial_change,
-! +*_vertical_gradient, *_vertical_gradient_level, *_vertical_gradient_level_ind,
-! +surface_waterflux_*
-!
-! in addition, steering parameters parameters of the two-moment cloud physics
-! scheme:
-! +cloud_scheme, +drizzle, +mu_constant, +mu_constant_value, +ventilation_effect
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 1015 2012-09-27 09:23:24Z raasch
-! -adjust_mixing_length
-!
-! 1003 2012-09-14 14:35:53Z raasch
-! -grid_matching
-!
-! 1001 2012-09-13 14:08:46Z raasch
-! -cut_spline_overshoot, last_dt_change, long_filter_factor, overshoot_limit_*,
-! ups_limit_*
-!
-! 978 2012-08-09 08:28:32Z fricke
-! -km_damp_max, outflow_damping_width
-! +pt_damping_factor, pt_damping_width
-! +z0h_factor
-!
-! 940 2012-07-09 14:31:00Z raasch
-! +neutral
-!
-! 927 2012-06-06 19:15:04Z raasch
-! +masking_method
-!
-! 849 2012-03-15 10:35:09Z raasch
-! first_call_advec_particles renamed first_call_lpm
-!
-! 824 2012-02-17 09:09:57Z raasch
-! +curvature_solution_effects
-!
-! Revision 1.1  1998/03/18 20:20:38  raasch
-! Initial revision
-!
-!
-! Description:
-! ------------
-!> Writing values of control variables to restart-file (binary format).
-!> This information are only written to the file opened by PE0.
-!------------------------------------------------------------------------------!
- SUBROUTINE write_var_list
-
-
-    USE arrays_3d,                                                             &
-        ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,           &
-               q_init, ref_state, s_init, sa_init, u_init, ug, v_init, vg
-
-    USE control_parameters
-
-    USE flight_mod,                                                            &
-        ONLY:  flight_write_restart_data
-
-    USE grid_variables,                                                        &
-        ONLY:  dx, dy
-
-    USE indices,                                                               &
-        ONLY:  nz, nx, ny
-
-    USE microphysics_mod,                                                      &
-        ONLY:  c_sedimentation, cloud_water_sedimentation,                     &
-               collision_turbulence, limiter_sedimentation, nc_const,          &
-               ventilation_effect
-
-    USE model_1d_mod,                                                          &
-        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
-
-    USE netcdf_interface,                                                      &
-        ONLY:  netcdf_precision, output_for_t0
-
-    USE particle_attributes,                                                   &
-        ONLY:  curvature_solution_effects
-
-    USE pegrid
-
-    USE radiation_model_mod,                                                   &
-        ONLY:  time_radiation
-
-    USE spectra_mod,                                                           &
-        ONLY:  average_count_sp
-
-    USE synthetic_turbulence_generator_mod,                                    &
-        ONLY:  stg_write_restart_data
-
-    USE statistics,                                                            &
-        ONLY:  statistic_regions, hom, hom_sum, u_max, u_max_ijk, v_max,       &
-               v_max_ijk, w_max, w_max_ijk
-
-    USE vertical_nesting_mod,                                                  &
-        ONLY:  vnest_init
-
-    USE wind_turbine_model_mod,                                                &
-        ONLY:  wtm_write_restart_data  
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=10) ::  binary_version   !<
-
-
-    binary_version = '4.6'
-
-    WRITE ( 14 )  binary_version
-
-    WRITE ( 14 )  'numprocs                      '
-    WRITE ( 14 )  numprocs
-    WRITE ( 14 )  'hor_index_bounds              '
-    WRITE ( 14 )  hor_index_bounds
-    WRITE ( 14 )  'nz                            '
-    WRITE ( 14 )  nz
-    WRITE ( 14 )  'max_pr_user                   '
-    WRITE ( 14 )  max_pr_user
-    WRITE ( 14 )  'statistic_regions             '
-    WRITE ( 14 )  statistic_regions
-
-!
-!-- Caution: After changes in the following parameter-list, the
-!-- -------  version number stored in the variable binary_version has to be
-!--          increased. The same changes must also be done in the parameter-
-!--          list in read_var_list.
-
-    WRITE ( 14 )  'advected_distance_x           '
-    WRITE ( 14 )  advected_distance_x
-    WRITE ( 14 )  'advected_distance_y           '
-    WRITE ( 14 )  advected_distance_y
-    WRITE ( 14 )  'alpha_surface                 '
-    WRITE ( 14 )  alpha_surface
-    WRITE ( 14 )  'average_count_pr              '
-    WRITE ( 14 )  average_count_pr
-    WRITE ( 14 )  'average_count_sp              '
-    WRITE ( 14 )  average_count_sp
-    WRITE ( 14 )  'average_count_3d              '
-    WRITE ( 14 )  average_count_3d
-    WRITE ( 14 )  'bc_e_b                        '
-    WRITE ( 14 )  bc_e_b
-    WRITE ( 14 )  'bc_lr                         '
-    WRITE ( 14 )  bc_lr
-    WRITE ( 14 )  'bc_ns                         '
-    WRITE ( 14 )  bc_ns
-    WRITE ( 14 )  'bc_p_b                        '
-    WRITE ( 14 )  bc_p_b
-    WRITE ( 14 )  'bc_p_t                        '
-    WRITE ( 14 )  bc_p_t
-    WRITE ( 14 )  'bc_pt_b                       '
-    WRITE ( 14 )  bc_pt_b
-    WRITE ( 14 )  'bc_pt_t                       '
-    WRITE ( 14 )  bc_pt_t
-    WRITE ( 14 )  'bc_pt_t_val                   '
-    WRITE ( 14 )  bc_pt_t_val
-    WRITE ( 14 )  'bc_q_b                        '
-    WRITE ( 14 )  bc_q_b
-    WRITE ( 14 )  'bc_q_t                        '
-    WRITE ( 14 )  bc_q_t
-    WRITE ( 14 )  'bc_q_t_val                    '
-    WRITE ( 14 )  bc_q_t_val
-    WRITE ( 14 )  'bc_s_b                        '
-    WRITE ( 14 )  bc_s_b
-    WRITE ( 14 )  'bc_s_t                        '
-    WRITE ( 14 )  bc_s_t
-    WRITE ( 14 )  'bc_sa_t                       '
-    WRITE ( 14 )  bc_sa_t
-    WRITE ( 14 )  'bc_uv_b                       '
-    WRITE ( 14 )  bc_uv_b
-    WRITE ( 14 )  'bc_uv_t                       '
-    WRITE ( 14 )  bc_uv_t
-    WRITE ( 14 )  'bottom_salinityflux           '
-    WRITE ( 14 )  bottom_salinityflux
-    WRITE ( 14 )  'building_height               '
-    WRITE ( 14 )  building_height
-    WRITE ( 14 )  'building_length_x             '
-    WRITE ( 14 )  building_length_x
-    WRITE ( 14 )  'building_length_y             '
-    WRITE ( 14 )  building_length_y
-    WRITE ( 14 )  'building_wall_left            '
-    WRITE ( 14 )  building_wall_left
-    WRITE ( 14 )  'building_wall_south           '
-    WRITE ( 14 )  building_wall_south
-    WRITE ( 14 )  'call_psolver_at_all_substeps  '
-    WRITE ( 14 )  call_psolver_at_all_substeps
-    WRITE ( 14 )  'canyon_height                 '
-    WRITE ( 14 )  canyon_height
-    WRITE ( 14 )  'canyon_width_x                '
-    WRITE ( 14 )  canyon_width_x
-    WRITE ( 14 )  'canyon_width_y                '
-    WRITE ( 14 )  canyon_width_y
-    WRITE ( 14 )  'canyon_wall_left              '
-    WRITE ( 14 )  canyon_wall_left
-    WRITE ( 14 )  'canyon_wall_south             '
-    WRITE ( 14 )  canyon_wall_south
-    WRITE ( 14 )  'c_sedimentation               '
-    WRITE ( 14 )  c_sedimentation
-    WRITE ( 14 )  'cfl_factor                    '
-    WRITE ( 14 )  cfl_factor
-    WRITE ( 14 )  'cloud_droplets                '
-    WRITE ( 14 )  cloud_droplets
-    WRITE ( 14 )  'cloud_physics                 '
-    WRITE ( 14 )  cloud_physics
-    WRITE ( 14 )  'cloud_scheme                  '
-    WRITE ( 14 )  cloud_scheme
-    WRITE ( 14 )  'collective_wait               '
-    WRITE ( 14 )  collective_wait
-    WRITE ( 14 )  'conserve_volume_flow          '
-    WRITE ( 14 )  conserve_volume_flow
-    WRITE ( 14 )  'conserve_volume_flow_mode     '
-    WRITE ( 14 )  conserve_volume_flow_mode
-    WRITE ( 14 )  'coupling_start_time           '
-    WRITE ( 14 )  coupling_start_time
-    WRITE ( 14 )  'constant_flux_layer           '
-    WRITE ( 14 )  constant_flux_layer
-    WRITE ( 14 )  'current_timestep_number       '
-    WRITE ( 14 )  current_timestep_number
-    WRITE ( 14 )  'curvature_solution_effects    '
-    WRITE ( 14 )  curvature_solution_effects
-    WRITE ( 14 )  'cycle_mg                      '
-    WRITE ( 14 )  cycle_mg
-    WRITE ( 14 )  'damp_level_1d                 '
-    WRITE ( 14 )  damp_level_1d
-    WRITE ( 14 )  'dissipation_1d                '
-    WRITE ( 14 )  dissipation_1d
-    WRITE ( 14 )  'do2d_xy_time_count            '
-    WRITE ( 14 )  do2d_xy_time_count
-    WRITE ( 14 )  'do2d_xz_time_count            '
-    WRITE ( 14 )  do2d_xz_time_count
-    WRITE ( 14 )  'do2d_yz_time_count            '
-    WRITE ( 14 )  do2d_yz_time_count
-    WRITE ( 14 )  'do3d_time_count               '
-    WRITE ( 14 )  do3d_time_count
-    WRITE ( 14 )  'dp_external                   '
-    WRITE ( 14 )  dp_external
-    WRITE ( 14 )  'dp_level_b                    '
-    WRITE ( 14 )  dp_level_b
-    WRITE ( 14 )  'dp_smooth                     '
-    WRITE ( 14 )  dp_smooth
-    WRITE ( 14 )  'dpdxy                         '
-    WRITE ( 14 )  dpdxy
-    WRITE ( 14 )  'cloud_water_sedimentation     '
-    WRITE ( 14 )  cloud_water_sedimentation
-    WRITE ( 14 )  'dt_pr_1d                      '
-    WRITE ( 14 )  dt_pr_1d
-    WRITE ( 14 )  'dt_run_control_1d             '
-    WRITE ( 14 )  dt_run_control_1d
-    WRITE ( 14 )  'dt_3d                         '
-    WRITE ( 14 )  dt_3d
-    WRITE ( 14 )  'dvrp_filecount                '
-    WRITE ( 14 )  dvrp_filecount
-    WRITE ( 14 )  'dx                            '
-    WRITE ( 14 )  dx
-    WRITE ( 14 )  'dy                            '
-    WRITE ( 14 )  dy
-    WRITE ( 14 )  'dz                            '
-    WRITE ( 14 )  dz
-    WRITE ( 14 )  'dz_max                        '
-    WRITE ( 14 )  dz_max
-    WRITE ( 14 )  'dz_stretch_factor             '
-    WRITE ( 14 )  dz_stretch_factor
-    WRITE ( 14 )  'dz_stretch_level              '
-    WRITE ( 14 )  dz_stretch_level
-    WRITE ( 14 )  'e_min                         '
-    WRITE ( 14 )  e_min
-    WRITE ( 14 )  'end_time_1d                   '
-    WRITE ( 14 )  end_time_1d
-    WRITE ( 14 )  'fft_method                    '
-    WRITE ( 14 )  fft_method
-    WRITE ( 14 )  'first_call_lpm                '
-    WRITE ( 14 )  first_call_lpm
-    WRITE ( 14 )  'galilei_transformation        '
-    WRITE ( 14 )  galilei_transformation
-    WRITE ( 14 )  'hom                           '
-    WRITE ( 14 )  hom
-    WRITE ( 14 )  'hom_sum                       '
-    WRITE ( 14 )  hom_sum
-    WRITE ( 14 )  'humidity                      '
-    WRITE ( 14 )  humidity
-    IF ( ALLOCATED( inflow_damping_factor ) )  THEN
-       WRITE ( 14 )  'inflow_damping_factor         '
-       WRITE ( 14 )  inflow_damping_factor
-    ENDIF
-    WRITE ( 14 )  'inflow_damping_height         '
-    WRITE ( 14 )  inflow_damping_height
-    WRITE ( 14 )  'inflow_damping_width          '
-    WRITE ( 14 )  inflow_damping_width
-    WRITE ( 14 )  'inflow_disturbance_begin      '
-    WRITE ( 14 )  inflow_disturbance_begin
-    WRITE ( 14 )  'inflow_disturbance_end        '
-    WRITE ( 14 )  inflow_disturbance_end
-    WRITE ( 14 )  'km_constant                   '
-    WRITE ( 14 )  km_constant
-    WRITE ( 14 )  'large_scale_forcing           '
-    WRITE ( 14 )  large_scale_forcing
-    WRITE ( 14 )  'large_scale_subsidence        '
-    WRITE ( 14 )  large_scale_subsidence
-    WRITE ( 14 )  'limiter_sedimentation         '
-    WRITE ( 14 )  limiter_sedimentation
-    WRITE ( 14 )  'loop_optimization             '
-    WRITE ( 14 )  loop_optimization
-    WRITE ( 14 )  'masking_method                '
-    WRITE ( 14 )  masking_method
-    IF ( ALLOCATED( mean_inflow_profiles ) )  THEN
-       WRITE ( 14 )  'mean_inflow_profiles          '
-       WRITE ( 14 )  mean_inflow_profiles
-    ENDIF
-    WRITE ( 14 )  'mg_cycles                     '
-    WRITE ( 14 )  mg_cycles
-    WRITE ( 14 )  'mg_switch_to_pe0_level        '
-    WRITE ( 14 )  mg_switch_to_pe0_level
-    WRITE ( 14 )  'mixing_length_1d              '
-    WRITE ( 14 )  mixing_length_1d
-    WRITE ( 14 )  'momentum_advec                '
-    WRITE ( 14 )  momentum_advec
-    WRITE ( 14 )  'most_method                   '
-    WRITE ( 14 )  most_method
-    WRITE ( 14 )  'nc_const                      '
-    WRITE ( 14 )  nc_const
-    WRITE ( 14 )  'netcdf_precision              '
-    WRITE ( 14 )  netcdf_precision
-    WRITE ( 14 )  'neutral                       '
-    WRITE ( 14 )  neutral
-    WRITE ( 14 )  'ngsrb                         '
-    WRITE ( 14 )  ngsrb
-    WRITE ( 14 )  'nsor                          '
-    WRITE ( 14 )  nsor
-    WRITE ( 14 )  'nsor_ini                      '
-    WRITE ( 14 )  nsor_ini
-    WRITE ( 14 )  'nudging                       '
-    WRITE ( 14 )  nudging
-    WRITE ( 14 )  'num_leg                       '
-    WRITE ( 14 )  num_leg
-    WRITE ( 14 )  'nx                            '
-    WRITE ( 14 )  nx
-    WRITE ( 14 )  'ny                            '
-    WRITE ( 14 )  ny
-    WRITE ( 14 )  'ocean                         '
-    WRITE ( 14 )  ocean
-    WRITE ( 14 )  'old_dt                        '
-    WRITE ( 14 )  old_dt
-    WRITE ( 14 )  'omega                         '
-    WRITE ( 14 )  omega
-    WRITE ( 14 )  'omega_sor                     '
-    WRITE ( 14 )  omega_sor
-    WRITE ( 14 )  'output_for_t0                 '
-    WRITE ( 14 )  output_for_t0
-    WRITE ( 14 )  'passive_scalar                '
-    WRITE ( 14 )  passive_scalar
-    WRITE ( 14 )  'latitude                      '
-    WRITE ( 14 )  latitude
-    WRITE ( 14 )  'longitude                     '
-    WRITE ( 14 )  longitude
-    WRITE ( 14 )  'prandtl_number                '
-    WRITE ( 14 )  prandtl_number
-    WRITE ( 14 )  'precipitation                 '
-    WRITE ( 14 )  precipitation
-    WRITE ( 14 )  'psolver                       '
-    WRITE ( 14 )  psolver
-    WRITE ( 14 )  'pt_damping_factor             '
-    WRITE ( 14 )  pt_damping_factor
-    WRITE ( 14 )  'pt_damping_width              '
-    WRITE ( 14 )  pt_damping_width
-    WRITE ( 14 )  'pt_init                       '
-    WRITE ( 14 )  pt_init
-    WRITE ( 14 )  'pt_reference                  '
-    WRITE ( 14 )  pt_reference
-    WRITE ( 14 )  'pt_surface                    '
-    WRITE ( 14 )  pt_surface
-    WRITE ( 14 )  'pt_surface_initial_change     '
-    WRITE ( 14 )  pt_surface_initial_change
-    WRITE ( 14 )  'pt_vertical_gradient          '
-    WRITE ( 14 )  pt_vertical_gradient
-    WRITE ( 14 )  'pt_vertical_gradient_level    '
-    WRITE ( 14 )  pt_vertical_gradient_level
-    WRITE ( 14 )  'pt_vertical_gradient_level_ind'
-    WRITE ( 14 )  pt_vertical_gradient_level_ind
-    WRITE ( 14 )  'q_init                        '
-    WRITE ( 14 )  q_init
-    WRITE ( 14 )  'q_surface                     '
-    WRITE ( 14 )  q_surface
-    WRITE ( 14 )  'q_surface_initial_change      '
-    WRITE ( 14 )  q_surface_initial_change
-    WRITE ( 14 )  'q_vertical_gradient           '
-    WRITE ( 14 )  q_vertical_gradient
-    WRITE ( 14 )  'q_vertical_gradient_level     '
-    WRITE ( 14 )  q_vertical_gradient_level
-    WRITE ( 14 )  'q_vertical_gradient_level_ind '
-    WRITE ( 14 )  q_vertical_gradient_level_ind
-    WRITE ( 14 )  'cloud_top_radiation           '
-    WRITE ( 14 )  cloud_top_radiation
-    WRITE ( 14 )  'random_generator              '
-    WRITE ( 14 )  random_generator
-    WRITE ( 14 )  'random_heatflux               '
-    WRITE ( 14 )  random_heatflux
-    WRITE ( 14 )  'rans_mode                     '
-    WRITE ( 14 )  rans_mode
-    WRITE ( 14 )  'rayleigh_damping_factor       '
-    WRITE ( 14 )  rayleigh_damping_factor
-    WRITE ( 14 )  'rayleigh_damping_height       '
-    WRITE ( 14 )  rayleigh_damping_height
-    WRITE ( 14 )  'recycling_width               '
-    WRITE ( 14 )  recycling_width
-    WRITE ( 14 )  'reference_state               '
-    WRITE ( 14 )  reference_state
-    WRITE ( 14 )  'ref_state                     '
-    WRITE ( 14 )  ref_state
-    WRITE ( 14 )  'residual_limit                '
-    WRITE ( 14 )  residual_limit
-    WRITE ( 14 )  'roughness_length              '
-    WRITE ( 14 )  roughness_length
-    WRITE ( 14 )  'runnr                         '
-    WRITE ( 14 )  runnr
-    WRITE ( 14 )  'run_coupled                   '
-    WRITE ( 14 )  run_coupled
-    WRITE ( 14 )  's_init                        '
-    WRITE ( 14 )  s_init
-    WRITE ( 14 )  's_surface                     '
-    WRITE ( 14 )  s_surface
-    WRITE ( 14 )  's_surface_initial_change      '
-    WRITE ( 14 )  s_surface_initial_change
-    WRITE ( 14 )  's_vertical_gradient           '
-    WRITE ( 14 )  s_vertical_gradient
-    WRITE ( 14 )  's_vertical_gradient_level     '
-    WRITE ( 14 )  s_vertical_gradient_level
-    WRITE ( 14 )  's_vertical_gradient_level_ind '
-    WRITE ( 14 )  s_vertical_gradient_level_ind
-    WRITE ( 14 )  'sa_init                       '
-    WRITE ( 14 )  sa_init
-    WRITE ( 14 )  'sa_surface                    '
-    WRITE ( 14 )  sa_surface
-    WRITE ( 14 )  'sa_vertical_gradient          '
-    WRITE ( 14 )  sa_vertical_gradient
-    WRITE ( 14 )  'sa_vertical_gradient_level    '
-    WRITE ( 14 )  sa_vertical_gradient_level
-    WRITE ( 14 )  'scalar_advec                  '
-    WRITE ( 14 )  scalar_advec
-    WRITE ( 14 )  'simulated_time                '
-    WRITE ( 14 )  simulated_time
-    WRITE ( 14 )  'spinup_time                   '
-    WRITE ( 14 )  spinup_time
-    WRITE ( 14 )  'surface_heatflux              '
-    WRITE ( 14 )  surface_heatflux
-    WRITE ( 14 )  'surface_pressure              '
-    WRITE ( 14 )  surface_pressure
-    WRITE ( 14 )  'surface_scalarflux            '
-    WRITE ( 14 )  surface_scalarflux
-    WRITE ( 14 )  'surface_waterflux             '
-    WRITE ( 14 )  surface_waterflux
-    WRITE ( 14 )  's_surface                     '
-    WRITE ( 14 )  s_surface
-    WRITE ( 14 )  's_surface_initial_change      '
-    WRITE ( 14 )  s_surface_initial_change
-    WRITE ( 14 )  's_vertical_gradient           '
-    WRITE ( 14 )  s_vertical_gradient
-    WRITE ( 14 )  's_vertical_gradient_level     '
-    WRITE ( 14 )  s_vertical_gradient_level
-    WRITE ( 14 )  'time_coupling                 '
-    WRITE ( 14 )  time_coupling
-    WRITE ( 14 )  'time_disturb                  '
-    WRITE ( 14 )  time_disturb
-    WRITE ( 14 )  'time_domask                   '
-    WRITE ( 14 )  time_domask
-    WRITE ( 14 )  'time_dopr                     '
-    WRITE ( 14 )  time_dopr
-    WRITE ( 14 )  'time_dopr_av                  '
-    WRITE ( 14 )  time_dopr_av
-    WRITE ( 14 )  'time_dopr_listing             '
-    WRITE ( 14 )  time_dopr_listing
-    WRITE ( 14 )  'time_dopts                    '
-    WRITE ( 14 )  time_dopts
-    WRITE ( 14 )  'time_dosp                     '
-    WRITE ( 14 )  time_dosp
-    WRITE ( 14 )  'time_dots                     '
-    WRITE ( 14 )  time_dots
-    WRITE ( 14 )  'time_do2d_xy                  '
-    WRITE ( 14 )  time_do2d_xy
-    WRITE ( 14 )  'time_do2d_xz                  '
-    WRITE ( 14 )  time_do2d_xz
-    WRITE ( 14 )  'time_do2d_yz                  '
-    WRITE ( 14 )  time_do2d_yz
-    WRITE ( 14 )  'time_do3d                     '
-    WRITE ( 14 )  time_do3d
-    WRITE ( 14 )  'time_do_av                    '
-    WRITE ( 14 )  time_do_av
-    WRITE ( 14 )  'time_do_sla                   '
-    WRITE ( 14 )  time_do_sla
-    WRITE ( 14 )  'time_dvrp                     '
-    WRITE ( 14 )  time_dvrp
-    WRITE ( 14 )  'time_radiation                '
-    WRITE ( 14 )  time_radiation
-    WRITE ( 14 )  'time_restart                  '
-    WRITE ( 14 )  time_restart
-    WRITE ( 14 )  'time_run_control              '
-    WRITE ( 14 )  time_run_control
-    WRITE ( 14 )  'time_since_reference_point    '
-    WRITE ( 14 )  time_since_reference_point
-    WRITE ( 14 )  'timestep_scheme               '
-    WRITE ( 14 )  timestep_scheme
-    WRITE ( 14 )  'topography                    '
-    WRITE ( 14 )  topography
-    WRITE ( 14 )  'topography_grid_convention    '
-    WRITE ( 14 )  topography_grid_convention
-    WRITE ( 14 )  'top_heatflux                  '
-    WRITE ( 14 )  top_heatflux
-    WRITE ( 14 )  'top_momentumflux_u            '
-    WRITE ( 14 )  top_momentumflux_u
-    WRITE ( 14 )  'top_momentumflux_v            '
-    WRITE ( 14 )  top_momentumflux_v
-    WRITE ( 14 )  'top_salinityflux              '
-    WRITE ( 14 )  top_salinityflux
-    WRITE ( 14 )  'top_scalarflux                '
-    WRITE ( 14 )  top_scalarflux
-    WRITE ( 14 )  'tsc                           '
-    WRITE ( 14 )  tsc
-    WRITE ( 14 )  'tunnel_height                 '
-    WRITE ( 14 )  tunnel_height
-    WRITE ( 14 )  'tunnel_length                 '
-    WRITE ( 14 )  tunnel_length
-    WRITE ( 14 )  'tunnel_width_x                '
-    WRITE ( 14 )  tunnel_width_x
-    WRITE ( 14 )  'tunnel_width_y                '
-    WRITE ( 14 )  tunnel_width_y
-    WRITE ( 14 )  'tunnel_wall_depth             '
-    WRITE ( 14 )  tunnel_wall_depth
-    WRITE ( 14 )  'turbulence_closure            '
-    WRITE ( 14 )  turbulence_closure
-    WRITE ( 14 )  'collision_turbulence          '
-    WRITE ( 14 )  collision_turbulence
-    WRITE ( 14 )  'turbulent_inflow              '
-    WRITE ( 14 )  turbulent_inflow
-    WRITE ( 14 )  'u_bulk                        '
-    WRITE ( 14 )  u_bulk
-    WRITE ( 14 )  'u_init                        '
-    WRITE ( 14 )  u_init
-    WRITE ( 14 )  'u_max                         '
-    WRITE ( 14 )  u_max
-    WRITE ( 14 )  'u_max_ijk                     '
-    WRITE ( 14 )  u_max_ijk
-    WRITE ( 14 )  'ug                            '
-    WRITE ( 14 )  ug
-    WRITE ( 14 )  'ug_surface                    '
-    WRITE ( 14 )  ug_surface
-    WRITE ( 14 )  'ug_vertical_gradient          '
-    WRITE ( 14 )  ug_vertical_gradient
-    WRITE ( 14 )  'ug_vertical_gradient_level    '
-    WRITE ( 14 )  ug_vertical_gradient_level
-    WRITE ( 14 )  'ug_vertical_gradient_level_ind'
-    WRITE ( 14 )  ug_vertical_gradient_level_ind
-    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
-    WRITE ( 14 )  'use_upstream_for_tke          '
-    WRITE ( 14 )  use_upstream_for_tke
-    WRITE ( 14 )  'v_bulk                        '
-    WRITE ( 14 )  v_bulk
-    WRITE ( 14 )  'v_init                        '
-    WRITE ( 14 )  v_init
-    WRITE ( 14 )  'v_max                         '
-    WRITE ( 14 )  v_max
-    WRITE ( 14 )  'v_max_ijk                     '
-    WRITE ( 14 )  v_max_ijk
-    WRITE ( 14 )  'ventilation_effect            '
-    WRITE ( 14 )  ventilation_effect
-    WRITE ( 14 )  'vg                            '
-    WRITE ( 14 )  vg
-    WRITE ( 14 )  'vg_surface                    '
-    WRITE ( 14 )  vg_surface
-    WRITE ( 14 )  'vg_vertical_gradient          '
-    WRITE ( 14 )  vg_vertical_gradient
-    WRITE ( 14 )  'vg_vertical_gradient_level    '
-    WRITE ( 14 )  vg_vertical_gradient_level
-    WRITE ( 14 )  'vg_vertical_gradient_level_ind'
-    WRITE ( 14 )  vg_vertical_gradient_level_ind
-    WRITE ( 14 )  'virtual_flight                '
-    WRITE ( 14 )  virtual_flight
-    WRITE ( 14 )  'vnest_init                    '
-    WRITE ( 14 )  vnest_init
-    WRITE ( 14 )  'volume_flow_area              '
-    WRITE ( 14 )  volume_flow_area
-    WRITE ( 14 )  'volume_flow_initial           '
-    WRITE ( 14 )  volume_flow_initial
-    WRITE ( 14 )  'wall_adjustment               '
-    WRITE ( 14 )  wall_adjustment
-    WRITE ( 14 )  'subs_vertical_gradient        '
-    WRITE ( 14 )  subs_vertical_gradient
-    WRITE ( 14 )  'subs_vertical_gradient_level  '
-    WRITE ( 14 )  subs_vertical_gradient_level
-    WRITE ( 14 )  'subs_vertical_gradient_level_i'
-    WRITE ( 14 )  subs_vertical_gradient_level_i
-    WRITE ( 14 )  'wall_heatflux                 '
-    WRITE ( 14 )  wall_heatflux
-    WRITE ( 14 )  'wall_humidityflux             '
-    WRITE ( 14 )  wall_humidityflux
-    WRITE ( 14 )  'wall_scalarflux               '
-    WRITE ( 14 )  wall_scalarflux
-    WRITE ( 14 )  'wall_salinityflux             '
-    WRITE ( 14 )  wall_salinityflux
-    WRITE ( 14 )  'w_max                         '
-    WRITE ( 14 )  w_max
-    WRITE ( 14 )  'w_max_ijk                     '
-    WRITE ( 14 )  w_max_ijk
-    WRITE ( 14 )  'y_shift                       '
-    WRITE ( 14 )  y_shift
-    WRITE ( 14 )  'zeta_max                      '
-    WRITE ( 14 )  zeta_max
-    WRITE ( 14 )  'zeta_min                      '
-    WRITE ( 14 )  zeta_min
-    WRITE ( 14 )  'z0h_factor                    '
-    WRITE ( 14 )  z0h_factor
-
-!
-!-- Set the end-of-file mark for default parameter
-    WRITE ( 14 )  '*** end ***                   '
-
-!    
-!-- ADD NEW "CALL <module>_skip_var_list" BELOW THE LAST CALL
-!-- (The order of the calls MUST be the same as in parin, and
-!--  read/skip_var_list)!
-!
-!-- If required, write restart data for wind turbine model.
-    IF ( wind_turbine )  CALL wtm_write_restart_data
-
-!
-!-- If required, write restart data for virtual measurements.
-    IF ( virtual_flight )  CALL flight_write_restart_data
-
-!
-!-- If required, write restart data for turbulence generator.
-    IF ( syn_turb_gen )  CALL stg_write_restart_data
-
-
-
- END SUBROUTINE write_var_list
