Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2881)
+++ 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
 
 !------------------------------------------------------------------------------!
