Index: /palm/trunk/SOURCE/Makefile
===================================================================
--- /palm/trunk/SOURCE/Makefile	(revision 2268)
+++ /palm/trunk/SOURCE/Makefile	(revision 2269)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Add dependency in read_3d_binary
+# 
+# 2263 2017-06-08 14:59:01Z schwenkel
 # Implemented splitting and merging algorithm
 # 
@@ -590,5 +593,5 @@
 read_3d_binary.o: modules.o cpulog_mod.o mod_kinds.o \
    land_surface_model_mod.o radiation_model_mod.o random_function_mod.o random_generator_parallel_mod.o \
-   spectra_mod.o surface_mod.o
+   spectra_mod.o surface_mod.o urban_surface_mod.o
 read_var_list.o: modules.o mod_kinds.o netcdf_interface_mod.o plant_canopy_model_mod.o \
    spectra_mod.o microphysics_mod.o urban_surface_mod.o virtual_flight_mod.o
Index: /palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- /palm/trunk/SOURCE/read_3d_binary.f90	(revision 2268)
+++ /palm/trunk/SOURCE/read_3d_binary.f90	(revision 2269)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Enable restart runs for urban_surface_mod
+! 
+! 2233 2017-05-30 18:08:54Z suehring
 !
 ! 2232 2017-05-30 17:47:52Z suehring
@@ -132,5 +135,5 @@
     USE control_parameters,                                                    &
         ONLY:  iran, land_surface, message_string, outflow_l, outflow_n,       &
-               outflow_r, outflow_s
+               outflow_r, outflow_s, urban_surface
 
     USE cpulog,                                                                &
@@ -165,4 +168,7 @@
     USE surface_mod,                                                           &
         ONLY :  surface_read_restart_data
+        
+    USE urban_surface_mod,                                                     &
+        ONLY:  usm_read_restart_data 
 
     IMPLICIT NONE
@@ -1012,4 +1018,14 @@
                                       nys_on_file, offset_xa, offset_ya,       &
                                       overlap_count(i), tmp_2d )
+
+       ENDIF
+       
+!
+!--    Read land 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
 
Index: /palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_mod.f90	(revision 2268)
+++ /palm/trunk/SOURCE/surface_mod.f90	(revision 2269)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Formatting and description adjustments
+! 
+! 2256 2017-06-07 13:58:08Z suehring
 ! Enable heating at downward-facing surfaces
 ! 
@@ -33,11 +36,11 @@
 ! Description:
 ! ------------
-!> Surface module contains defines derived data structures to treat surface-
+!> Surface module defines derived data structures to treat surface-
 !> bounded grid cells. Three different types of surfaces are defined: 
-!> default surfaces, natural surfaces, and urban surfaces. Moreover, the module
-!> encompasses the initialization of near-surface grid cells, and handles reading 
-!> and writing restart data. 
+!> default surfaces, natural surfaces, and urban surfaces. The module
+!> encompasses the allocation and initialization of surface arrays, and handles 
+!> reading and writing restart data. 
 !> In addition, a further derived data structure is defined, in order to set
-!> boundary conditions at surfaces.   
+!> boundary conditions at surfaces.  
 !------------------------------------------------------------------------------!
  MODULE surface_mod
@@ -1602,14 +1605,14 @@
        IMPLICIT NONE
 
-       CHARACTER(LEN=1)             ::  dum
-
-       INTEGER(iwp)                 ::  i
-       INTEGER(iwp)                 ::  j
-       INTEGER(iwp)                 ::  l
-       INTEGER(iwp)                 ::  m
-       INTEGER(iwp), DIMENSION(0:3) ::  mm
-
-       TYPE(surf_type), DIMENSION(0:2) ::  surf_h
-       TYPE(surf_type), DIMENSION(0:3) ::  surf_v
+       CHARACTER(LEN=1)             ::  dum  !< dummy string to create output-variable name
+
+       INTEGER(iwp)                 ::  i    !< running index x-direction
+       INTEGER(iwp)                 ::  j    !< running index y-direction
+       INTEGER(iwp)                 ::  l    !< index surface type orientation
+       INTEGER(iwp)                 ::  m    !< running index for surface elements on individual surface array
+       INTEGER(iwp), DIMENSION(0:3) ::  mm   !< running index for surface elements on gathered surface array
+
+       TYPE(surf_type), DIMENSION(0:2) ::  surf_h !< gathered horizontal surfaces, contains all surface types
+       TYPE(surf_type), DIMENSION(0:3) ::  surf_v !< gathered vertical surfaces, contains all surface types
 
 !
@@ -2088,5 +2091,5 @@
 !> respective surface types within this routine. This allows e.g. changing the 
 !> surface type after reading the restart data, which might be required in case 
-!> of cyclic-filling a simulation. 
+!> of cyclic_fill mode. 
 !------------------------------------------------------------------------------!
     SUBROUTINE surface_read_restart_data( ii,                                  &
@@ -2135,8 +2138,8 @@
 
        LOGICAL                         ::  horizontal_surface !< flag indicating horizontal surfaces
-       LOGICAL                         ::  vertical_surface   !< flag indicating vertical surfaces
        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
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2268)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2269)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Enable restart runs with different number of PEs
+! Bugfixes nopointer branch
+! 
+! 2258 2017-06-08 07:55:13Z suehring
 ! Bugfix, add pre-preprocessor directives to enable non-parrallel mode
 ! 
@@ -113,4 +117,6 @@
 !>    1.2 Km/s, which seem to be not realistic.
 !>
+!> @todo Revise flux conversion in energy-balance solver
+!> @todo Bugfixing in nopointer branch 
 !> @todo Check optimizations for RMA operations
 !> @todo Alternatives for MPI_WIN_ALLOCATE? (causes problems with openmpi)
@@ -513,5 +519,5 @@
     SAVE
 
-    PRIVATE
+    PRIVATE 
     
 !-- Public parameters, constants and initial values
@@ -959,38 +965,55 @@
 !--     allocate wall and roof temperature arrays, for horizontal walls
 #if defined( __nopointer )
-        ALLOCATE ( t_surf_h(1:surf_usm_h%ns) )
-        ALLOCATE ( t_surf_h_p(1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h_p(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-
-        ALLOCATE ( t_surf_h(1:surf_usm_h%ns) )
-        ALLOCATE ( t_surf_h_p(1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h_p(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
+        IF ( .NOT. ALLOCATED( t_surf_h ) )                                     &
+           ALLOCATE ( t_surf_h(1:surf_usm_h%ns) )
+        IF ( .NOT. ALLOCATED( t_surf_h_p ) )                                   &
+           ALLOCATE ( t_surf_h_p(1:surf_usm_h%ns) )
+        IF ( .NOT. ALLOCATED( t_wall_h ) )                                     &           
+           ALLOCATE ( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
+        IF ( .NOT. ALLOCATED( t_wall_h_p ) )                                   &           
+           ALLOCATE ( t_wall_h_p(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )  
 #else
-        ALLOCATE ( t_surf_h_1(1:surf_usm_h%ns) )
-        ALLOCATE ( t_surf_h_2(1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-        ALLOCATE ( t_wall_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-
+!
+!--     Allocate if required. Note, in case of restarts, some of these arrays 
+!--     might be already allocated.
+        IF ( .NOT. ALLOCATED( t_surf_h_1 ) )                                   &
+           ALLOCATE ( t_surf_h_1(1:surf_usm_h%ns) )
+        IF ( .NOT. ALLOCATED( t_surf_h_2 ) )                                   &
+           ALLOCATE ( t_surf_h_2(1:surf_usm_h%ns) )
+        IF ( .NOT. ALLOCATED( t_wall_h_1 ) )                                   &           
+           ALLOCATE ( t_wall_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
+        IF ( .NOT. ALLOCATED( t_wall_h_2 ) )                                   &           
+           ALLOCATE ( t_wall_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )          
+!           
 !--     initial assignment of the pointers
         t_wall_h    => t_wall_h_1;    t_wall_h_p    => t_wall_h_2
-        t_surf_h => t_surf_h_1; t_surf_h_p => t_surf_h_2
+        t_surf_h => t_surf_h_1; t_surf_h_p => t_surf_h_2           
 #endif
 
-!--     allocate wall and roof temperature arrays, for vertical walls
+!--     allocate wall and roof temperature arrays, for vertical walls if required
 #if defined( __nopointer )
         DO  l = 0, 3
-           ALLOCATE ( t_surf_v(l)%t(1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_surf_v(l)%t_p(1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_wall_v(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_wall_v(l)%t_p(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_surf_v(l)%t ) )                             &
+              ALLOCATE ( t_surf_v(l)%t(1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_surf_v_p(l)%t ) )                           &
+              ALLOCATE ( t_surf_v_p(l)%t(1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_wall_v(l)%t ) )                             &
+              ALLOCATE ( t_wall_v(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_wall_v_p(l)%t ) )                           &                 
+              ALLOCATE ( t_wall_v_p(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
         ENDDO
 #else
+!
+!--     Allocate if required. Note, in case of restarts, some of these arrays 
+!--     might be already allocated.
         DO  l = 0, 3
-           ALLOCATE ( t_surf_v_1(l)%t(1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_surf_v_2(l)%t(1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_wall_v_1(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
-           ALLOCATE ( t_wall_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_surf_v_1(l)%t ) )                           &
+              ALLOCATE ( t_surf_v_1(l)%t(1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_surf_v_2(l)%t ) )                           &
+              ALLOCATE ( t_surf_v_2(l)%t(1:surf_usm_v(l)%ns) )
+           IF ( .NOT. ALLOCATED( t_wall_v_1(l)%t ) )                           &           
+              ALLOCATE ( t_wall_v_1(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) ) 
+           IF ( .NOT. ALLOCATED( t_wall_v_2(l)%t ) )                           &           
+              ALLOCATE ( t_wall_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )  
         ENDDO
 !
@@ -3199,9 +3222,6 @@
 
 !--     Initialization for restart runs
-        IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-
-!--         restore data from restart file
-            CALL usm_read_restart_data()
-        ELSE
+        IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.        &
+             TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
        
 !--         Calculate initial surface temperature from pt of adjacent gridbox
@@ -4153,125 +4173,326 @@
 !        So, I added some directives here.
 !------------------------------------------------------------------------------!
-    SUBROUTINE usm_read_restart_data
-
-
+    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
+           
        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)       ::  ns_h_on_file_usm !< number of horizontal surface elements (urban type) on file
+       INTEGER(iwp)       ::  nxlc             !< index of left boundary on current subdomain
+       INTEGER(iwp)       ::  nxlf             !< index of left boundary on former subdomain 
+       INTEGER(iwp)       ::  nxl_on_file      !< index of left boundary on former local domain 
+       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)       ::  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)       ::  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
        
-       CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
+       INTEGER(iwp)       ::  ns_v_on_file_usm(0:3) !< number of vertical surface elements (urban 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)       ::  i             !< running index
-
-
-       DO  i = 0, io_blocks-1
-          IF ( i == io_group )  THEN
-             READ ( 13 )  variable_chr
-             DO   WHILE ( TRIM( variable_chr ) /= '*** end usm ***' )
-
-                SELECT CASE ( TRIM( variable_chr ) )
+       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
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tmp_wall_h
+       
+       TYPE( t_surf_vertical ), DIMENSION(0:3) ::  tmp_surf_v
+       TYPE( t_wall_vertical ), DIMENSION(0:3) ::  tmp_wall_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) )
+          
+          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) ) )
+          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 ( .NOT.  ALLOCATED( t_surf_h ) )                      &
-                         ALLOCATE( t_surf_h(1:surf_usm_h%ns) )
-                      READ ( 13 )  t_surf_h
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_h, tmp_surf_h,            &
+                                              surf_usm_h%start_index )
+                      ENDIF
 #else                      
-                      IF ( .NOT.  ALLOCATED( t_surf_h_1 ) )                    &
-                         ALLOCATE( t_surf_h_1(1:surf_usm_h%ns) )
-                      READ ( 13 )  t_surf_h_1
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_h_1, tmp_surf_h,          &
+                                              surf_usm_h%start_index )
 #endif
+
                    CASE ( 't_surf_v(0)' )
-#if defined( __nopointer )                   
-                      IF ( .NOT.  ALLOCATED( t_surf_v(0)%t ) )                 &
-                         ALLOCATE( t_surf_v(0)%t(1:surf_usm_v(0)%ns) )
-                      READ ( 13 )  t_surf_v(0)%t
+#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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v(0)%t, tmp_surf_v(0)%t,  &
+                                              surf_usm_v(0)%start_index )
+                      ENDIF
 #else                      
-                      IF ( .NOT.  ALLOCATED( t_surf_v_1(0)%t ) )               &
-                         ALLOCATE( t_surf_v_1(0)%t(1:surf_usm_v(0)%ns) )
-                      READ ( 13 )  t_surf_v_1(0)%t
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v_1(0)%t, tmp_surf_v(0)%t,&
+                                              surf_usm_v(0)%start_index )
 #endif
+                         
                    CASE ( 't_surf_v(1)' )
-#if defined( __nopointer )                   
-                      IF ( .NOT.  ALLOCATED( t_surf_v(1)%t ) )                 &
-                         ALLOCATE( t_surf_v(1)%t(1:surf_usm_v(1)%ns) )
-                      READ ( 13 )  t_surf_v(1)%t
+#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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v(1)%t, tmp_surf_v(1)%t,  &
+                                              surf_usm_v(1)%start_index )                        
 #else                      
-                      IF ( .NOT.  ALLOCATED( t_surf_v_1(1)%t ) )               &
-                         ALLOCATE( t_surf_v_1(1)%t(1:surf_usm_v(1)%ns) )
-                      READ ( 13 )  t_surf_v_1(1)%t
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v_1(1)%t, tmp_surf_v(1)%t,&
+                                              surf_usm_v(1)%start_index )
 #endif
+
                    CASE ( 't_surf_v(2)' )
-#if defined( __nopointer )                   
-                      IF ( .NOT.  ALLOCATED( t_surf_v(2)%t ) )                 &
-                         ALLOCATE( t_surf_v(2)%t(1:surf_usm_v(2)%ns) )
-                      READ ( 13 )  t_surf_v(2)%t
+#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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v(2)%t, tmp_surf_v(2)%t,  &
+                                              surf_usm_v(2)%start_index )
 #else                      
-                      IF ( .NOT.  ALLOCATED( t_surf_v_1(2)%t ) )               &
-                         ALLOCATE( t_surf_v_1(2)%t(1:surf_usm_v(2)%ns) )
-                      READ ( 13 )  t_surf_v_1(2)%t
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v_1(2)%t, tmp_surf_v(2)%t,&
+                                              surf_usm_v(2)%start_index ) 
 #endif
+                         
                    CASE ( 't_surf_v(3)' )
-#if defined( __nopointer )                   
-                      IF ( .NOT.  ALLOCATED( t_surf_v(3)%t ) )                 &
-                         ALLOCATE( t_surf_v(3)%t(1:surf_usm_v(3)%ns) )
-                      READ ( 13 )  t_surf_v(3)%t
+#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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v(3)%t, tmp_surf_v(3)%t,  &
+                                              surf_usm_v(3)%start_index ) 
 #else                      
-                      IF ( .NOT.  ALLOCATED( t_surf_v_1(3)%t ) )               &
-                         ALLOCATE( t_surf_v_1(3)%t(1:surf_usm_v(3)%ns) )
-                      READ ( 13 )  t_surf_v_1(3)%t
+                      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 restore_surface_elements_usm_1d(                    &
+                                              t_surf_v_1(3)%t, tmp_surf_v(3)%t,&
+                                              surf_usm_v(3)%start_index )
 #endif
                    CASE ( 't_wall_h' )
 #if defined( __nopointer )
-                      IF ( .NOT.  ALLOCATED( t_wall_h ) )                      &
-                         ALLOCATE( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                      READ ( 13 )  t_wall_h
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_h, tmp_wall_h,            &
+                                              surf_usm_h%start_index )
 #else
-                      IF ( .NOT.  ALLOCATED( t_wall_h_1 ) )                    &
-                         ALLOCATE( t_wall_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-                      READ ( 13 )  t_wall_h_1
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_h_1, tmp_wall_h,          &
+                                              surf_usm_h%start_index )
 #endif
                    CASE ( 't_wall_v(0)' )
 #if defined( __nopointer )
-                      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 )  t_wall_v(0)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v(0)%t, tmp_wall_v(0)%t,  &
+                                              surf_usm_v(0)%start_index )
 #else
-                      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 )  t_wall_v_1(0)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v_1(0)%t, tmp_wall_v(0)%t,&
+                                              surf_usm_v(0)%start_index )
 #endif
                    CASE ( 't_wall_v(1)' )
 #if defined( __nopointer )
-                      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 )  t_wall_v(1)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v(1)%t, tmp_wall_v(1)%t,  &
+                                              surf_usm_v(1)%start_index )
 #else
-                      IF ( .NOT.  ALLOCATED( t_wall_v_1(0)%t ) )                    &
-                         ALLOCATE( t_wall_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
-                      READ ( 13 )  t_wall_v_1(1)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v_1(1)%t, tmp_wall_v(1)%t,&
+                                              surf_usm_v(1)%start_index )
 #endif
                    CASE ( 't_wall_v(2)' )
 #if defined( __nopointer )
-                      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 )  t_wall_v(2)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v(2)%t, tmp_wall_v(2)%t,  &
+                                              surf_usm_v(2)%start_index )
+                      ENDIF
 #else
-                      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 )  t_wall_v_1(2)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v_1(2)%t, tmp_wall_v(2)%t,&
+                                              surf_usm_v(2)%start_index )
 #endif
                    CASE ( 't_wall_v(3)' )
 #if defined( __nopointer )
-                      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 )  t_wall_v(3)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v(3)%t, tmp_wall_v(3)%t,  &
+                                              surf_usm_v(3)%start_index )
 #else
-                      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 )  t_wall_v_1(3)%t
+                      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 restore_surface_elements_usm_2d(                    &
+                                              t_wall_v_1(3)%t, tmp_wall_v(3)%t,&
+                                              surf_usm_v(3)%start_index )
 #endif
 
                    CASE DEFAULT
                       WRITE ( message_string, * )  'unknown variable named "', &
-                                        TRIM( variable_chr ), '" found in',    &
+                                        TRIM( field_chr ), '" found in',       &
                                         '&data from prior run on PE ', myid
                       CALL message( 'user_read_restart_data', 'UI0012', 1, 2, 0, 6, 0 )
@@ -4279,14 +4500,85 @@
                 END SELECT
 
-                READ ( 13 )  variable_chr
-
              ENDDO
-          ENDIF
-#if defined( __parallel )
-          CALL MPI_BARRIER( comm2d, ierr )
-#endif
-       ENDDO
+
+             READ ( 13 )  field_chr
+
+          ENDDO
+
+       ENDIF
+       
+       CONTAINS
+       
+          SUBROUTINE restore_surface_elements_usm_1d( surf_target, surf_file, start_index_c )
+
+             IMPLICIT NONE
+       
+             INTEGER(iwp) ::  i         !< running index along x-direction, refers to former domain size
+             INTEGER(iwp) ::  ic        !< running index along x-direction, refers to current domain size
+             INTEGER(iwp) ::  j         !< running index along y-direction, refers to former domain size
+             INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size        
+             INTEGER(iwp) ::  m         !< surface-element index on file
+             INTEGER(iwp) ::  mm        !< surface-element index on current subdomain
+
+             INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index_c             
+             
+             REAL(wp), DIMENSION(:) ::  surf_target !< target surface type
+             REAL(wp), DIMENSION(:) ::  surf_file   !< surface type on file
+             
+             ic = nxlc
+             DO  i = nxlf, nxrf
+                jc = nysc
+                DO  j = nysf, nynf
+
+                   mm = start_index_c(jc,ic)
+                   DO  m = start_index_on_file(j,i), end_index_on_file(j,i)
+                      surf_target(mm) = surf_file(m)
+                      mm = mm + 1
+                   ENDDO
+
+                   jc = jc + 1
+                ENDDO
+                ic = ic + 1
+             ENDDO
+
+
+          END SUBROUTINE restore_surface_elements_usm_1d
+          
+          SUBROUTINE restore_surface_elements_usm_2d( surf_target, surf_file, start_index_c )
+
+             IMPLICIT NONE
+        
+             INTEGER(iwp) ::  i         !< running index along x-direction, refers to former domain size
+             INTEGER(iwp) ::  ic        !< running index along x-direction, refers to current domain size
+             INTEGER(iwp) ::  j         !< running index along y-direction, refers to former domain size
+             INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size        
+             INTEGER(iwp) ::  m         !< surface-element index on file
+             INTEGER(iwp) ::  mm        !< surface-element index on current subdomain
+
+             INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index_c
+             
+             REAL(wp), DIMENSION(:,:) ::  surf_target !< target surface type
+             REAL(wp), DIMENSION(:,:) ::  surf_file   !< surface type on file
+             
+             ic = nxlc
+             DO  i = nxlf, nxrf
+                jc = nysc
+                DO  j = nysf, nynf
+
+                   mm = start_index_c(jc,ic)
+                   DO  m = start_index_on_file(j,i), end_index_on_file(j,i)
+                      surf_target(:,mm) = surf_file(:,m)
+                      mm = mm + 1
+                   ENDDO
+
+                   jc = jc + 1
+                ENDDO
+                ic = ic + 1
+             ENDDO
+
+          END SUBROUTINE restore_surface_elements_usm_2d
 
     END SUBROUTINE usm_read_restart_data
+    
 
 
@@ -5105,76 +5397,46 @@
        IMPLICIT NONE
        
-       INTEGER(iwp)  ::  i
-
-       DO  i = 0, io_blocks-1
-          IF ( i == io_group )  THEN
-
-             WRITE ( 14 )  't_surf_h                      '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_surf_h
-#else
-             WRITE ( 14 )  t_surf_h_1
-#endif
-             WRITE ( 14 )  't_surf_v(0)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_surf_v(0)%t
-#else
-             WRITE ( 14 )  t_surf_v_1(0)%t
-#endif
-             WRITE ( 14 )  't_surf_v(1)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_surf_v(1)%t
-#else
-             WRITE ( 14 )  t_surf_v_1(1)%t
-#endif
-             WRITE ( 14 )  't_surf_v(2)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_surf_v(2)%t
-#else
-             WRITE ( 14 )  t_surf_v_1(2)%t
-#endif
-             WRITE ( 14 )  't_surf_v(3)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_surf_v(3)%t
-#else
-             WRITE ( 14 )  t_surf_v_1(3)%t
-#endif
-             WRITE ( 14 )  't_wall_h                      '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_wall_h
-#else
-             WRITE ( 14 )  t_wall_h_1
-#endif
-             WRITE ( 14 )  't_wall_v(0)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_wall_v(0)%t
-#else
-             WRITE ( 14 )  t_wall_v_1(0)%t
-#endif
-             WRITE ( 14 )  't_wall_v(1)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_wall_v(1)%t
-#else
-             WRITE ( 14 )  t_wall_v_1(1)%t
-#endif
-             WRITE ( 14 )  't_wall_v(2)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_wall_v(2)%t
-#else
-             WRITE ( 14 )  t_wall_v_1(2)%t
-#endif
-             WRITE ( 14 )  't_wall_v(3)                   '
-#if defined( __nopointer )             
-             WRITE ( 14 )  t_wall_v(3)%t
-#else
-             WRITE ( 14 )  t_wall_v_1(3)%t
-#endif
-             WRITE ( 14 )  '*** end usm ***               '
-          ENDIF
-#if defined( __parallel )
-          CALL MPI_BARRIER( comm2d, ierr )
-#endif
+       CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name  
+       INTEGER(iwp)     ::  l       !< index surface type orientation
+       
+       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
+       
+       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
+       
+       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          
        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
+       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          
+       ENDDO
+
+       WRITE ( 14 )  '*** end usm ***               '
        
     END SUBROUTINE usm_write_restart_data
