Index: /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90
===================================================================
--- /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4597)
+++ /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4598)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix in treatment of 3D soil arrays
+!
+! 4591 2020-07-06 15:56:08Z raasch
 ! File re-formatted to follow the PALM coding standard
 !
@@ -823,5 +826,5 @@
 #endif
 
-       IF ( include_total_domain_boundaries)  THEN
+       IF ( include_total_domain_boundaries )  THEN
           DO  i = lb%nxl, lb%nxr
              data(lb%nys-nbgp:lb%nyn-nbgp,i-nbgp) = array_2d(i,lb%nys:lb%nyn)
@@ -980,78 +983,4 @@
        CALL posix_read(fh, array_3d, SIZE( array_3d ) )
 #endif
-       IF ( include_total_domain_boundaries)  THEN
-          DO  i = lb%nxl, lb%nxr
-             data(:,lb%nys-nbgp:lb%nyn-nbgp,i-nbgp) = array_3d(:,i,lb%nys:lb%nyn)
-          ENDDO
-       ELSE
-          DO  i = nxl, nxr
-             data(:,nys:nyn,i) = array_3d(:,i,nys:nyn)
-          ENDDO
-       ENDIF
-
-       CALL exchange_horiz( data, nbgp )
-
-    ELSE
-
-       message_string = '3d-REAL array "' // TRIM( name ) // '" not found in restart file'
-       CALL message( 'rrd_mpi_io_real_3d', 'PA0722', 3, 2, 0, 6, 0 )
-
-    ENDIF
-
- END SUBROUTINE rrd_mpi_io_real_3d
-
-
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Read 3d-REAL soil array with MPI-IO
-!> nzb_soil, nzt_soil are located in the module land_surface_model_mod. Since Fortran does not allow
-!> cross referencing of module variables, it is required to pass these variables as arguments.
-!--------------------------------------------------------------------------------------------------!
- SUBROUTINE rrd_mpi_io_real_3d_soil( name, data, nzb_soil, nzt_soil )
-
-    IMPLICIT NONE
-
-    CHARACTER(LEN=*), INTENT(IN)       ::  name      !<
-
-    INTEGER(iwp)                       ::  i         !<
-    INTEGER, INTENT(IN)                ::  nzb_soil  !<
-    INTEGER, INTENT(IN)                ::  nzt_soil  !<
-
-#if defined( __parallel )
-    INTEGER, DIMENSION(rd_status_size) ::  status    !<
-#endif
-
-    LOGICAL                            ::  found     !<
-
-    REAL(wp), INTENT(INOUT), DIMENSION(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) ::  data  !<
-
-
-    found = .FALSE.
-
-    DO  i = 1, tgh%nr_arrays
-       IF ( TRIM(array_names(i)) == TRIM( name ) )  THEN
-          array_position = array_offset(i)
-          found = .TRUE.
-          EXIT
-       ENDIF
-    ENDDO
-
-    IF ( found )  THEN
-#if defined( __parallel )
-       CALL rd_mpi_io_create_filetypes_3dsoil( nzb_soil, nzt_soil )
-       CALL sm_io%sm_node_barrier()  ! Has no effect if I/O on limited number of cores is inactive
-       IF ( sm_io%iam_io_pe )  THEN
-          CALL MPI_FILE_SET_VIEW( fh, array_position, MPI_REAL, ft_3dsoil, 'native',               &
-                                  MPI_INFO_NULL, ierr )
-          CALL MPI_FILE_READ_ALL( fh, array_3d_soil, SIZE( array_3d_soil ), MPI_REAL, status, ierr )
-          CALL MPI_TYPE_FREE( ft_3dsoil, ierr )
-       ENDIF
-       CALL sm_io%sm_node_barrier()
-#else
-       CALL posix_lseek( fh, array_position )
-       CALL posix_read( fh, array_3d_soil, SIZE( array_3d_soil ) )
-#endif
        IF ( include_total_domain_boundaries )  THEN
           DO  i = lb%nxl, lb%nxr
@@ -1064,4 +993,78 @@
        ENDIF
 
+       CALL exchange_horiz( data, nbgp )
+
+    ELSE
+
+       message_string = '3d-REAL array "' // TRIM( name ) // '" not found in restart file'
+       CALL message( 'rrd_mpi_io_real_3d', 'PA0722', 3, 2, 0, 6, 0 )
+
+    ENDIF
+
+ END SUBROUTINE rrd_mpi_io_real_3d
+
+
+
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Read 3d-REAL soil array with MPI-IO
+!> nzb_soil, nzt_soil are located in the module land_surface_model_mod. Since Fortran does not allow
+!> cross referencing of module variables, it is required to pass these variables as arguments.
+!--------------------------------------------------------------------------------------------------!
+ SUBROUTINE rrd_mpi_io_real_3d_soil( name, data, nzb_soil, nzt_soil )
+
+    IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN)       ::  name      !<
+
+    INTEGER(iwp)                       ::  i         !<
+    INTEGER, INTENT(IN)                ::  nzb_soil  !<
+    INTEGER, INTENT(IN)                ::  nzt_soil  !<
+
+#if defined( __parallel )
+    INTEGER, DIMENSION(rd_status_size) ::  status    !<
+#endif
+
+    LOGICAL                            ::  found     !<
+
+    REAL(wp), INTENT(INOUT), DIMENSION(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) ::  data  !<
+
+
+    found = .FALSE.
+
+    DO  i = 1, tgh%nr_arrays
+       IF ( TRIM(array_names(i)) == TRIM( name ) )  THEN
+          array_position = array_offset(i)
+          found = .TRUE.
+          EXIT
+       ENDIF
+    ENDDO
+
+    IF ( found )  THEN
+#if defined( __parallel )
+       CALL rd_mpi_io_create_filetypes_3dsoil( nzb_soil, nzt_soil )
+       CALL sm_io%sm_node_barrier()  ! Has no effect if I/O on limited number of cores is inactive
+       IF ( sm_io%iam_io_pe )  THEN
+          CALL MPI_FILE_SET_VIEW( fh, array_position, MPI_REAL, ft_3dsoil, 'native',               &
+                                  MPI_INFO_NULL, ierr )
+          CALL MPI_FILE_READ_ALL( fh, array_3d_soil, SIZE( array_3d_soil ), MPI_REAL, status, ierr )
+          CALL MPI_TYPE_FREE( ft_3dsoil, ierr )
+       ENDIF
+       CALL sm_io%sm_node_barrier()
+#else
+       CALL posix_lseek( fh, array_position )
+       CALL posix_read( fh, array_3d_soil, SIZE( array_3d_soil ) )
+#endif
+       IF ( include_total_domain_boundaries )  THEN
+          DO  i = lb%nxl, lb%nxr
+             data(:,lb%nys-nbgp:lb%nyn-nbgp,i-nbgp) = array_3d_soil(:,i,lb%nys:lb%nyn)
+          ENDDO
+       ELSE
+          DO  i = nxl, nxr
+             data(:,nys:nyn,i) = array_3d_soil(:,i,nys:nyn)
+          ENDDO
+       ENDIF
+
     ELSE
 
@@ -1432,5 +1435,5 @@
 #endif
 
-    IF ( include_total_domain_boundaries)  THEN
+    IF ( include_total_domain_boundaries )  THEN
 !
 !--    Prepare output of 3d-REAL-array with ghost layers. In the virtual PE grid, the first
Index: /palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_mod.f90	(revision 4597)
+++ /palm/trunk/SOURCE/surface_mod.f90	(revision 4598)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Revise surface-element mapping in mpi-io restart branch
+!
+! 4595 2020-07-09 17:18:21Z suehring
 ! Fix accidently commented subroutine
 !
@@ -488,6 +491,6 @@
        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tswc_h_m           !<
 
-
-!-- Arrays for time averages
+!
+!--    Arrays for time averages
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_net_av          !< average of rad_net_l
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfinsw_av         !< average of sw radiation falling to local surface including
@@ -4243,5 +4246,5 @@
 !--          Horizontal downward facing
              surf_h(1)%ns = ns_h_on_file(1)
-             CALL allocate_surface_attributes_h( surf_h(1), nys_on_file, nyn_on_file, nxl_on_file,  &
+             CALL allocate_surface_attributes_h( surf_h(1), nys_on_file, nyn_on_file, nxl_on_file, &
                                                  nxr_on_file )
 !
@@ -5079,4 +5082,6 @@
 
  CONTAINS
+
+
 !--------------------------------------------------------------------------------------------------!
 ! Description:
@@ -5260,5 +5265,4 @@
  END SUBROUTINE restore_surface_elements
 
-
  END SUBROUTINE surface_rrd_local_ftn
 
@@ -5277,9 +5281,16 @@
     CHARACTER(LEN=1) ::  dum  !< dummy string to create input-variable name
 
-    INTEGER(iwp) ::  l  !< loop index for surface types
+    INTEGER(iwp) ::  i  !< loop index, x-direction
+    INTEGER(iwp) ::  j  !< loop index, y-direction
+    INTEGER(iwp) ::  l  !< loop index for surface orientation
+    INTEGER(iwp) ::  m  !< loop index for surface types - target array
+    INTEGER(iwp) ::  mm !< loop index for surface types - file array
 
     INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  global_start_index  !< index for surface data (MPI-IO)
 
-    LOGICAL ::  ldum  !< dummy variable
+    LOGICAL ::  ldum            !< dummy variable
+    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
 
     TYPE(surf_type), DIMENSION(0:2) ::  surf_h  !< gathered horizontal surfaces, contains all surface types
@@ -5569,114 +5580,214 @@
 
 !
-!-- Redistribute surface elements on its respective type.
+!-- Redistribute surface elements on its respective type. Start with horizontal default surfaces.
     DO  l = 0, 2
-       CALL restore_surface_elements( surf_def_h(l), surf_h(l) )
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             surf_match_def  = surf_def_h(l)%end_index(j,i) >= surf_def_h(l)%start_index(j,i)
+             IF ( surf_match_def )  THEN
+!
+!--             Set the start index for the local surface element
+                mm = surf_def_h(l)%start_index(j,i)
+!
+!--             For index pair (j,i) on file loop from start to end index, and in case the local
+!--             surface element mm is smaller than the local end index, assign the respective
+!--             surface data to this element.
+                DO  m = surf_h(l)%start_index(j,i), surf_h(l)%end_index(j,i)
+                   IF ( surf_def_h(l)%end_index(j,i) >= mm )                                       &
+                      CALL restore_surface_elements( surf_def_h(l), mm, surf_h(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
+          ENDDO
+       ENDDO
     ENDDO
-    CALL restore_surface_elements( surf_lsm_h, surf_h(0) )
-    CALL restore_surface_elements( surf_usm_h, surf_h(0) )
-
+!
+!-- Natural- and urban-like horizontal surfaces.
+    DO  i = nxl, nxr
+       DO  j = nys, nyn
+          surf_match_lsm  = surf_lsm_h%end_index(j,i) >= surf_lsm_h%start_index(j,i)
+          surf_match_usm  = surf_usm_h%end_index(j,i) >= surf_usm_h%start_index(j,i)
+
+          IF ( surf_match_lsm )  THEN
+             mm = surf_lsm_h%start_index(j,i)
+             DO  m = surf_h(0)%start_index(j,i), surf_h(0)%end_index(j,i)
+                IF ( surf_lsm_h%end_index(j,i) >= mm )                                             &
+                   CALL restore_surface_elements( surf_lsm_h, mm, surf_h(0), m )
+                mm = mm + 1
+             ENDDO
+          ENDIF
+
+          IF ( surf_match_usm )  THEN
+             mm = surf_usm_h%start_index(j,i)
+             DO  m = surf_h(0)%start_index(j,i), surf_h(0)%end_index(j,i)
+                IF ( surf_usm_h%end_index(j,i) >= mm )                                             &
+                   CALL restore_surface_elements( surf_usm_h, mm, surf_h(0), m )
+                mm = mm + 1
+             ENDDO
+          ENDIF
+       ENDDO
+    ENDDO
+!
+!-- Same for vertical surfaces.
     DO  l = 0, 3
-       CALL restore_surface_elements( surf_def_v(l), surf_v(l) )
-       CALL restore_surface_elements( surf_lsm_v(l), surf_v(l) )
-       CALL restore_surface_elements( surf_usm_v(l), surf_v(l) )
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             surf_match_def  = surf_def_v(l)%end_index(j,i) >= surf_def_v(l)%start_index(j,i)
+             surf_match_lsm  = surf_lsm_v(l)%end_index(j,i) >= surf_lsm_v(l)%start_index(j,i)
+             surf_match_usm  = surf_usm_v(l)%end_index(j,i) >= surf_usm_v(l)%start_index(j,i)
+
+             IF ( surf_match_def )  THEN
+                mm = surf_def_v(l)%start_index(j,i)
+                DO  m = surf_v(l)%start_index(j,i), surf_v(l)%end_index(j,i)
+                   IF ( surf_def_v(l)%end_index(j,i) >= mm )                                       &
+                      CALL restore_surface_elements( surf_def_v(l), mm, surf_v(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
+             IF ( surf_match_lsm )  THEN
+                mm = surf_lsm_v(l)%start_index(j,i)
+                DO  m = surf_v(l)%start_index(j,i), surf_v(l)%end_index(j,i)
+                   IF ( surf_lsm_v(l)%end_index(j,i) >= mm )                                       &
+                      CALL restore_surface_elements( surf_lsm_v(l), mm, surf_v(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
+             IF ( surf_match_usm )  THEN
+                mm = surf_usm_v(l)%start_index(j,i)
+                DO  m = surf_v(l)%start_index(j,i), surf_v(l)%end_index(j,i)
+                   IF ( surf_usm_v(l)%end_index(j,i) >= mm )                                       &
+                      CALL restore_surface_elements( surf_usm_v(l), mm, surf_v(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
+          ENDDO
+       ENDDO
     ENDDO
 
  CONTAINS
 
- SUBROUTINE restore_surface_elements( surf_target, surf_file )
-
-    IMPLICIT NONE
-
-    INTEGER(iwp) ::  lsp  !< running index chemical species
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Restores surface elements back on its respective type.
+!--------------------------------------------------------------------------------------------------!
+ SUBROUTINE restore_surface_elements( surf_target, m_target, surf_file, m_file )
+
+    INTEGER(iwp) ::  m_file    !< respective surface-element index of current surface array
+    INTEGER(iwp) ::  m_target  !< respecitve surface-element index of surface array on file
+    INTEGER(iwp) ::  lsp       !< running index chemical species
 
     TYPE(surf_type) ::  surf_target  !< target surface type
     TYPE(surf_type) ::  surf_file    !< surface type on file
 
-
-    IF ( ALLOCATED( surf_target%us )  .AND.  ALLOCATED( surf_file%us ) )  THEN
-       surf_target%us = surf_file%us
-    ENDIF
+    IF ( ALLOCATED( surf_target%us )  .AND.  ALLOCATED( surf_file%us ) )                           &
+       surf_target%us(m_target) = surf_file%us(m_file)
 
     IF ( ALLOCATED( surf_target%ol )  .AND.  ALLOCATED( surf_file%ol ) )                           &
-       surf_target%ol = surf_file%ol
+       surf_target%ol(m_target) = surf_file%ol(m_file)
+
+    IF ( ALLOCATED( surf_target%rib )  .AND.  ALLOCATED( surf_file%rib ) )                         &
+       surf_target%rib(m_target) = surf_file%rib(m_file)
+
+    IF ( ALLOCATED( surf_target%ol )  .AND.  ALLOCATED( surf_file%ol ) )                           &
+       surf_target%ol(m_target) = surf_file%ol(m_file)
 
     IF ( ALLOCATED( surf_target%pt_surface )  .AND.  ALLOCATED( surf_file%pt_surface ) )           &
-       surf_target%pt_surface = surf_file%pt_surface
+       surf_target%pt_surface(m_target) = surf_file%pt_surface(m_file)
 
     IF ( ALLOCATED( surf_target%q_surface )  .AND.  ALLOCATED( surf_file%q_surface ) )             &
-       surf_target%q_surface = surf_file%q_surface
+       surf_target%q_surface(m_target) = surf_file%q_surface(m_file)
 
     IF ( ALLOCATED( surf_target%vpt_surface )  .AND.  ALLOCATED( surf_file%vpt_surface ) )         &
-       surf_target%vpt_surface = surf_file%vpt_surface
+       surf_target%vpt_surface(m_target) = surf_file%vpt_surface(m_file)
 
     IF ( ALLOCATED( surf_target%usws )  .AND.  ALLOCATED( surf_file%usws ) )                       &
-       surf_target%usws = surf_file%usws
+       surf_target%usws(m_target) = surf_file%usws(m_file)
 
     IF ( ALLOCATED( surf_target%vsws )  .AND.  ALLOCATED( surf_file%vsws ) )                       &
-       surf_target%vsws = surf_file%vsws
+       surf_target%vsws(m_target) = surf_file%vsws(m_file)
 
     IF ( ALLOCATED( surf_target%ts )  .AND.  ALLOCATED( surf_file%ts ) )                           &
-       surf_target%ts = surf_file%ts
+       surf_target%ts(m_target) = surf_file%ts(m_file)
 
     IF ( ALLOCATED( surf_target%shf )  .AND.  ALLOCATED( surf_file%shf ) )                         &
-       surf_target%shf = surf_file%shf
+       surf_target%shf(m_target) = surf_file%shf(m_file)
 
     IF ( ALLOCATED( surf_target%qs )  .AND.  ALLOCATED( surf_file%qs ) )                           &
-       surf_target%qs = surf_file%qs
+       surf_target%qs(m_target) = surf_file%qs(m_file)
 
     IF ( ALLOCATED( surf_target%qsws )  .AND.  ALLOCATED( surf_file%qsws ) )                       &
-       surf_target%qsws = surf_file%qsws
+       surf_target%qsws(m_target) = surf_file%qsws(m_file)
 
     IF ( ALLOCATED( surf_target%ss )  .AND.  ALLOCATED( surf_file%ss ) )                           &
-       surf_target%ss = surf_file%ss
+       surf_target%ss(m_target) = surf_file%ss(m_file)
 
     IF ( ALLOCATED( surf_target%ssws )  .AND.  ALLOCATED( surf_file%ssws ) )                       &
-       surf_target%ssws = surf_file%ssws
-
-    IF ( ALLOCATED( surf_target%css )  .AND.  ALLOCATED( surf_file%css   ) )  THEN
+       surf_target%ssws(m_target) = surf_file%ssws(m_file)
+
+    IF ( ALLOCATED( surf_target%css )  .AND.  ALLOCATED( surf_file%css ) )  THEN
        DO  lsp = 1, nvar
-          surf_target%css(lsp,:) = surf_file%css(lsp,:)
+          surf_target%css(lsp,m_target) = surf_file%css(lsp,m_file)
        ENDDO
     ENDIF
 
-    IF ( ALLOCATED( surf_target%cssws )  .AND.  ALLOCATED( surf_file%cssws   ) )  THEN
+    IF ( ALLOCATED( surf_target%cssws )  .AND.  ALLOCATED( surf_file%cssws ) )  THEN
        DO  lsp = 1, nvar
-          surf_target%cssws(lsp,:) = surf_file%cssws(lsp,:)
+          surf_target%cssws(lsp,m_target) = surf_file%cssws(lsp,m_file)
        ENDDO
     ENDIF
+
     IF ( ALLOCATED( surf_target%qcs )  .AND.  ALLOCATED( surf_file%qcs ) )                         &
-       surf_target%qcs = surf_file%qcs
+      surf_target%qcs(m_target) = surf_file%qcs(m_file)
+
     IF ( ALLOCATED( surf_target%qcsws )  .AND.  ALLOCATED( surf_file%qcsws ) )                     &
-       surf_target%qcsws = surf_file%qcsws
+       surf_target%qcsws(m_target) = surf_file%qcsws(m_file)
+
     IF ( ALLOCATED( surf_target%ncs )  .AND.  ALLOCATED( surf_file%ncs ) )                         &
-       surf_target%ncs = surf_file%ncs
+       surf_target%ncs(m_target) = surf_file%ncs(m_file)
+
     IF ( ALLOCATED( surf_target%ncsws )  .AND.  ALLOCATED( surf_file%ncsws ) )                     &
-       surf_target%ncsws = surf_file%ncsws
+       surf_target%ncsws(m_target) = surf_file%ncsws(m_file)
+
+    IF ( ALLOCATED( surf_target%qis )  .AND.  ALLOCATED( surf_file%qis ) )                         &
+      surf_target%qis(m_target) = surf_file%qis(m_file)
+
+    IF ( ALLOCATED( surf_target%qisws )  .AND.  ALLOCATED( surf_file%qisws ) )                     &
+       surf_target%qisws(m_target) = surf_file%qisws(m_file)
+
+    IF ( ALLOCATED( surf_target%nis )  .AND.  ALLOCATED( surf_file%nis ) )                         &
+       surf_target%nis(m_target) = surf_file%nis(m_file)
+
+    IF ( ALLOCATED( surf_target%nisws )  .AND.  ALLOCATED( surf_file%nisws ) )                     &
+       surf_target%nisws(m_target) = surf_file%nisws(m_file)
+
     IF ( ALLOCATED( surf_target%qrs )  .AND.  ALLOCATED( surf_file%qrs ) )                         &
-       surf_target%qrs = surf_file%qrs
+       surf_target%qrs(m_target) = surf_file%qrs(m_file)
+
     IF ( ALLOCATED( surf_target%qrsws )  .AND.  ALLOCATED( surf_file%qrsws ) )                     &
-       surf_target%qrsws = surf_file%qrsws
+       surf_target%qrsws(m_target) = surf_file%qrsws(m_file)
+
     IF ( ALLOCATED( surf_target%nrs )  .AND.  ALLOCATED( surf_file%nrs ) )                         &
-       surf_target%nrs = surf_file%nrs
+       surf_target%nrs(m_target) = surf_file%nrs(m_file)
 
     IF ( ALLOCATED( surf_target%nrsws )  .AND.  ALLOCATED( surf_file%nrsws ) )                     &
-       surf_target%nrsws = surf_file%nrsws
-    IF ( ALLOCATED( surf_target%sasws )  .AND. ALLOCATED( surf_file%sasws ) )                      &
-       surf_target%sasws = surf_file%sasws
+       surf_target%nrsws(m_target) = surf_file%nrsws(m_file)
+
+    IF ( ALLOCATED( surf_target%sasws )  .AND.  ALLOCATED( surf_file%sasws ) )                     &
+       surf_target%sasws(m_target) = surf_file%sasws(m_file)
+
     IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.  ALLOCATED( surf_file%mom_flux_uv ) )         &
-       surf_target%mom_flux_uv = surf_file%mom_flux_uv
+       surf_target%mom_flux_uv(m_target) = surf_file%mom_flux_uv(m_file)
+
     IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.  ALLOCATED( surf_file%mom_flux_w ) )           &
-       surf_target%mom_flux_w = surf_file%mom_flux_w
-    IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.  ALLOCATED( surf_file%mom_flux_tke ) )       &
-       surf_target%mom_flux_tke(0:1,:) = surf_file%mom_flux_tke(0:1,:)
-
+       surf_target%mom_flux_w(m_target) = surf_file%mom_flux_w(m_file)
+
+    IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.                                              &
+         ALLOCATED( surf_file%mom_flux_tke   ) )                                                   &
+       surf_target%mom_flux_tke(0:1,m_target) = surf_file%mom_flux_tke(0:1,m_file)
 
  END SUBROUTINE restore_surface_elements
 
  END SUBROUTINE surface_rrd_local_mpi
-
-
-
-
 
 !--------------------------------------------------------------------------------------------------!
