Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 2813)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 2894)
@@ -26,4 +26,18 @@
 ! -----------------
 ! $Id$
+! Calculations of the index range of the subdomain on file which overlaps with
+! the current subdomain are already done in read_restart_data_mod,
+! surface_read/write_restart_data was renamed to surface_r/wrd_local, variable 
+! named found has been introduced for checking if restart data was found, 
+! reading of restart strings has been moved completely to 
+! read_restart_data_mod, surface_rrd_local is already inside the overlap loop 
+! programmed in read_restart_data_mod, SAVE attribute added where necessary, 
+! deallocation and allocation of some arrays have been changed to take care of 
+! different restart files that can be opened (index i), the marker *** end 
+! surf *** is not necessary anymore, strings and their respective lengths are 
+! written out and read now in case of restart runs to get rid of prescribed 
+! character lengths (Giersch)
+! 
+! 2813 2018-02-16 16:28:14Z suehring
 ! Some more bugfixes concerning restart runs 
 ! 
@@ -432,11 +446,11 @@
     END INTERFACE init_surface_arrays
 
-    INTERFACE surface_read_restart_data
-       MODULE PROCEDURE surface_read_restart_data
-    END INTERFACE surface_read_restart_data
-
-    INTERFACE surface_write_restart_data
-       MODULE PROCEDURE surface_write_restart_data
-    END INTERFACE surface_write_restart_data
+    INTERFACE surface_rrd_local
+       MODULE PROCEDURE surface_rrd_local
+    END INTERFACE surface_rrd_local
+
+    INTERFACE surface_wrd_local
+       MODULE PROCEDURE surface_wrd_local
+    END INTERFACE surface_wrd_local
 
     INTERFACE surface_last_actions
@@ -457,6 +471,6 @@
     PUBLIC get_topography_top_index, get_topography_top_index_ji, init_bc,     &
            init_surfaces,                                                      &
-           init_surface_arrays, surface_read_restart_data,                     & 
-           surface_restore_elements, surface_write_restart_data,               &
+           init_surface_arrays, surface_rrd_local,                     & 
+           surface_restore_elements, surface_wrd_local,               &
            surface_last_actions
 
@@ -888,4 +902,112 @@
     END SUBROUTINE init_surface_arrays
 
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Deallocating memory for upward and downward-facing horizontal surface types, 
+!> except for top fluxes. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_h( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces  !< respective surface type
+
+
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface element
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+!
+!--    Surface-layer height
+       DEALLOCATE ( surfaces%z_mo )
+!
+!--    Surface orientation
+       DEALLOCATE ( surfaces%facing )
+!
+!--    Surface-parallel wind velocity
+       DEALLOCATE ( surfaces%uvw_abs )
+!
+!--    Roughness
+       DEALLOCATE ( surfaces%z0 )
+       DEALLOCATE ( surfaces%z0h )
+       DEALLOCATE ( surfaces%z0q )
+!
+!--    Friction velocity
+       DEALLOCATE ( surfaces%us )
+!
+!--    Stability parameter
+       DEALLOCATE ( surfaces%ol )
+!
+!--    Bulk Richardson number
+       DEALLOCATE ( surfaces%rib )
+!
+!--    Vertical momentum fluxes of u and v
+       DEALLOCATE ( surfaces%usws )  
+       DEALLOCATE ( surfaces%vsws )  
+!
+!--    Required in production_e
+       IF ( .NOT. constant_diffusion )  THEN    
+          DEALLOCATE ( surfaces%u_0 )  
+          DEALLOCATE ( surfaces%v_0 )
+       ENDIF 
+!
+!--    Characteristic temperature and surface flux of sensible heat
+       DEALLOCATE ( surfaces%ts )    
+       DEALLOCATE ( surfaces%shf )    
+!
+!--    surface temperature
+       DEALLOCATE ( surfaces%pt_surface ) 
+!
+!--    Characteristic humidity and surface flux of latent heat
+       IF ( humidity )  THEN
+          DEALLOCATE ( surfaces%qs ) 
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Characteristic scalar and surface flux of scalar
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ss )   
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF 
+!
+!--    Scaling parameter (cs*) and surface flux of chemical species
+       IF ( air_chemistry )  THEN
+          DEALLOCATE ( surfaces%css )   
+          DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--    Arrays for storing potential temperature and
+!--    specific humidity at first grid level
+       DEALLOCATE ( surfaces%pt1 )
+       DEALLOCATE ( surfaces%qv1 )
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_morrison)  THEN
+          DEALLOCATE ( surfaces%qcs )
+          DEALLOCATE ( surfaces%ncs )
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrs )
+          DEALLOCATE ( surfaces%nrs )
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity surface flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_h
+
+
 !------------------------------------------------------------------------------!
 ! Description:
@@ -916,5 +1038,5 @@
 !--    might exist for given (j,i).
 !--    If no surface of respective type exist at current (j,i), set indicies
-!--    such that loop in diffusion routines will not be entered. 
+!--    such that loop in diffusion routines will not be entered.
        ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
        ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
@@ -1015,4 +1137,69 @@
 ! Description:
 ! ------------
+!> Deallocating memory for model-top fluxes  
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_h_top( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces !< respective surface type
+
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface (model-top) element
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+
+       IF ( .NOT. constant_diffusion )  THEN    
+          DEALLOCATE ( surfaces%u_0 )  
+          DEALLOCATE ( surfaces%v_0 )
+       ENDIF 
+!
+!--    Vertical momentum fluxes of u and v
+       DEALLOCATE ( surfaces%usws )  
+       DEALLOCATE ( surfaces%vsws )  
+!
+!--    Sensible heat flux
+       DEALLOCATE ( surfaces%shf )    
+!
+!--    Latent heat flux
+       IF ( humidity .OR. coupling_mode == 'ocean_to_atmosphere')  THEN
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Scalar flux
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF 
+!
+!--    Chemical species flux
+       IF ( air_chemistry )  THEN
+          DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_morrison)  THEN
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+!
+!--       
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_h_top
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> Allocating memory for model-top fluxes  
 !------------------------------------------------------------------------------!
@@ -1082,4 +1269,120 @@
 
     END SUBROUTINE allocate_surface_attributes_h_top
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Deallocating memory for vertical surface types. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE deallocate_surface_attributes_v( surfaces )
+
+       IMPLICIT NONE
+
+
+       TYPE(surf_type) ::  surfaces !< respective surface type
+
+!
+!--    Allocate arrays for start and end index of vertical surface type 
+!--    for each (j,i)-grid point. This is required in diffion_x, which is
+!--    called for each (j,i). In order to find the location where the 
+!--    respective flux is store within the surface-type, start- and end- 
+!--    index are stored for each (j,i). For example, each (j,i) can have
+!--    several entries where fluxes for vertical surfaces might be stored.  
+!--    In the flat case, where no vertical walls exit, set indicies such 
+!--    that loop in diffusion routines will not be entered. 
+       DEALLOCATE ( surfaces%start_index )
+       DEALLOCATE ( surfaces%end_index )
+!
+!--    Indices to locate surface element.
+       DEALLOCATE ( surfaces%i )
+       DEALLOCATE ( surfaces%j )
+       DEALLOCATE ( surfaces%k )
+!
+!--    Surface-layer height
+       DEALLOCATE ( surfaces%z_mo )
+!
+!--    Surface orientation
+       DEALLOCATE ( surfaces%facing )
+!
+!--    Surface parallel wind velocity
+       DEALLOCATE ( surfaces%uvw_abs )
+!
+!--    Roughness
+       DEALLOCATE ( surfaces%z0 )
+       DEALLOCATE ( surfaces%z0h )
+       DEALLOCATE ( surfaces%z0q )
+
+!
+!--    Friction velocity
+       DEALLOCATE ( surfaces%us )
+!
+!--    Allocate Obukhov length and bulk Richardson number. Actually, at
+!--    vertical surfaces these are only required for natural surfaces.  
+!--    for natural land surfaces
+       DEALLOCATE( surfaces%ol ) 
+       DEALLOCATE( surfaces%rib ) 
+!
+!--    Allocate arrays for surface momentum fluxes for u and v. For u at north- 
+!--    and south-facing surfaces, for v at east- and west-facing surfaces.
+       DEALLOCATE ( surfaces%mom_flux_uv )
+!
+!--    Allocate array for surface momentum flux for w - wsus and wsvs
+       DEALLOCATE ( surfaces%mom_flux_w ) 
+!
+!--    Allocate array for surface momentum flux for subgrid-scale tke wsus and 
+!--    wsvs; first index usvs or vsws, second index for wsus or wsvs, depending
+!--    on surface.
+       DEALLOCATE ( surfaces%mom_flux_tke )  
+!
+!--    Characteristic temperature and surface flux of sensible heat
+       DEALLOCATE ( surfaces%ts )    
+       DEALLOCATE ( surfaces%shf )
+!
+!--    surface temperature
+       DEALLOCATE ( surfaces%pt_surface ) 
+!
+!--    Characteristic humidity and surface flux of latent heat
+       IF ( humidity )  THEN
+          DEALLOCATE ( surfaces%qs ) 
+          DEALLOCATE ( surfaces%qsws )      
+       ENDIF 
+!
+!--    Characteristic scalar and surface flux of scalar
+       IF ( passive_scalar )  THEN
+          DEALLOCATE ( surfaces%ss )   
+          DEALLOCATE ( surfaces%ssws ) 
+       ENDIF
+!
+!--    Scaling parameter (cs*) and surface flux of chemical species
+       IF ( air_chemistry )  THEN
+             DEALLOCATE ( surfaces%css )   
+             DEALLOCATE ( surfaces%cssws ) 
+       ENDIF 
+!
+!--    Arrays for storing potential temperature and
+!--    specific humidity at first grid level
+       DEALLOCATE ( surfaces%pt1 )
+       DEALLOCATE ( surfaces%qv1 )
+
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qcs )
+          DEALLOCATE ( surfaces%ncs )
+          DEALLOCATE ( surfaces%qcsws )
+          DEALLOCATE ( surfaces%ncsws )
+       ENDIF
+
+       IF ( cloud_physics .AND. microphysics_seifert)  THEN
+          DEALLOCATE ( surfaces%qrs )
+          DEALLOCATE ( surfaces%nrs )
+          DEALLOCATE ( surfaces%qrsws )
+          DEALLOCATE ( surfaces%nrsws )
+       ENDIF
+!
+!--    Salinity surface flux
+       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
+
+    END SUBROUTINE deallocate_surface_attributes_v
+
 
 !------------------------------------------------------------------------------!
@@ -1203,4 +1506,5 @@
 
     END SUBROUTINE allocate_surface_attributes_v
+
 
 !------------------------------------------------------------------------------!
@@ -2175,5 +2479,6 @@
 !> type) onto a surface type, and writes binary data into restart files. 
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_write_restart_data
+    SUBROUTINE surface_wrd_local
+
 
        IMPLICIT NONE
@@ -2637,8 +2942,10 @@
 
 
-       WRITE ( 14 )  'ns_h_on_file                  '
-       WRITE ( 14 )   ns_h_on_file
-       WRITE ( 14 )  'ns_v_on_file                  '
-       WRITE ( 14 )   ns_v_on_file
+       CALL wrd_write_string( 'ns_h_on_file' )
+       WRITE ( 14 )  ns_h_on_file
+
+       CALL wrd_write_string( 'ns_v_on_file' )
+       WRITE ( 14 )  ns_v_on_file
+
 !
 !--    Write required restart data.
@@ -2646,102 +2953,126 @@
        DO  l = 0, 2
           WRITE( dum, '(I1)')  l
-          
-          WRITE ( 14 )  'surf_h(' // dum // ')%start_index         '  
-          WRITE ( 14 )   surf_h(l)%start_index
-          WRITE ( 14 )  'surf_h(' // dum // ')%end_index           '  
-          WRITE ( 14 )   surf_h(l)%end_index
+
+          CALL wrd_write_string( 'surf_h(' // dum // ')%start_index' )
+          WRITE ( 14 )  surf_h(l)%start_index
+
+          CALL wrd_write_string( 'surf_h(' // dum // ')%end_index' )
+          WRITE ( 14 )  surf_h(l)%end_index
 
           IF ( ALLOCATED ( surf_h(l)%us ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%us                  ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%us' ) 
              WRITE ( 14 )  surf_h(l)%us
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ts ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ts                  ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ts' ) 
              WRITE ( 14 )  surf_h(l)%ts
           ENDIF
+          
           IF ( ALLOCATED ( surf_h(l)%qs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qs                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qs' )  
              WRITE ( 14 )  surf_h(l)%qs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ss ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ss                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ss' )  
              WRITE ( 14 )  surf_h(l)%ss
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qcs ) )  THEN  
-             WRITE ( 14 )  'surf_h(' // dum // ')%qcs                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qcs' )
              WRITE ( 14 )  surf_h(l)%qcs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ncs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ncs                 ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ncs' ) 
              WRITE ( 14 )  surf_h(l)%ncs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qrs ) )  THEN  
-             WRITE ( 14 )  'surf_h(' // dum // ')%qrs                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qrs' )
              WRITE ( 14 )  surf_h(l)%qrs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%nrs ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%nrs                 '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%nrs' )  
              WRITE ( 14 )  surf_h(l)%nrs
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ol ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ol                  '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ol' )  
              WRITE ( 14 )  surf_h(l)%ol
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%rib ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%rib                 ' 
+            CALL wrd_write_string( 'surf_h(' // dum // ')%rib' ) 
              WRITE ( 14 )  surf_h(l)%rib
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%pt_surface ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%pt_surface          ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%pt_surface' ) 
              WRITE ( 14 )  surf_h(l)%pt_surface
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%usws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%usws                ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%usws' ) 
              WRITE ( 14 )  surf_h(l)%usws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%vsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%vsws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%vsws' )  
              WRITE ( 14 )  surf_h(l)%vsws
           ENDIF
+          
           IF ( ALLOCATED ( surf_h(l)%shf ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%shf                 ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%shf' ) 
              WRITE ( 14 )  surf_h(l)%shf
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qsws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qsws' )  
              WRITE ( 14 )  surf_h(l)%qsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ssws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%ssws                '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ssws' )  
              WRITE ( 14 )  surf_h(l)%ssws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%css ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%css                 '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%css' )
              WRITE ( 14 )  surf_h(l)%css
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%cssws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%cssws               '
+             CALL wrd_write_string( 'surf_h(' // dum // ')%cssws' )
              WRITE ( 14 )  surf_h(l)%cssws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qcsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qcsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qcsws' )  
              WRITE ( 14 )  surf_h(l)%qcsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%ncsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%ncsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%ncsws' )  
              WRITE ( 14 )  surf_h(l)%ncsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%qrsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%qrsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%qrsws' )  
              WRITE ( 14 )  surf_h(l)%qrsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%nrsws ) )  THEN
-             WRITE ( 14 )  'surf_h(' // dum // ')%nrsws               '  
+             CALL wrd_write_string( 'surf_h(' // dum // ')%nrsws' )  
              WRITE ( 14 )  surf_h(l)%nrsws
           ENDIF
+
           IF ( ALLOCATED ( surf_h(l)%sasws ) )  THEN 
-             WRITE ( 14 )  'surf_h(' // dum // ')%sasws               ' 
+             CALL wrd_write_string( 'surf_h(' // dum // ')%sasws' ) 
              WRITE ( 14 )  surf_h(l)%sasws
-          ENDIF
+          ENDIF     
+  
        ENDDO
 !
@@ -2750,111 +3081,134 @@
           WRITE( dum, '(I1)')  l
 
-          WRITE ( 14 )  'surf_v(' // dum // ')%start_index         '  
-          WRITE ( 14 )   surf_v(l)%start_index
-          WRITE ( 14 )  'surf_v(' // dum // ')%end_index           '  
+          CALL wrd_write_string( 'surf_v(' // dum // ')%start_index' )
+          WRITE ( 14 )  surf_v(l)%start_index
+
+          CALL wrd_write_string( 'surf_v(' // dum // ')%end_index' )
           WRITE ( 14 )   surf_v(l)%end_index
 
           IF ( ALLOCATED ( surf_v(l)%us ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%us                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%us' )  
              WRITE ( 14 )  surf_v(l)%us
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ts ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ts                  ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ts' ) 
              WRITE ( 14 )  surf_v(l)%ts
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qs                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qs' )  
              WRITE ( 14 )  surf_v(l)%qs
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ss ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ss                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ss' ) 
              WRITE ( 14 )  surf_v(l)%ss
-          ENDIF
+          ENDIF  
+          
           IF ( ALLOCATED ( surf_v(l)%qcs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qcs                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qcs' ) 
              WRITE ( 14 )  surf_v(l)%qcs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%ncs ) )  THEN 
-             WRITE ( 14 )  'surf_v(' // dum // ')%ncs                 ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ncs' )
              WRITE ( 14 )  surf_v(l)%ncs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qrs ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qrs                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qrs' )  
              WRITE ( 14 )  surf_v(l)%qrs
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%nrs ) )  THEN 
-             WRITE ( 14 )  'surf_v(' // dum // ')%nrs                 ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%nrs' ) 
              WRITE ( 14 )  surf_v(l)%nrs
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ol ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ol                  '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ol' )  
              WRITE ( 14 )  surf_v(l)%ol
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%rib ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%rib                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%rib' )
              WRITE ( 14 )  surf_v(l)%rib
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%pt_surface ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%pt_surface          '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%pt_surface' )
              WRITE ( 14 )  surf_v(l)%pt_surface
-          ENDIF
+          ENDIF 
+
           IF ( ALLOCATED ( surf_v(l)%shf ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%shf                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%shf' )  
              WRITE ( 14 )  surf_v(l)%shf
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qsws                '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qsws' )  
              WRITE ( 14 )  surf_v(l)%qsws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%ssws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ssws                '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ssws' )  
              WRITE ( 14 )  surf_v(l)%ssws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%css ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%css                 '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%css' )  
              WRITE ( 14 )  surf_v(l)%css
-          ENDIF 
+          ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%cssws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%cssws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%cssws' ) 
              WRITE ( 14 )  surf_v(l)%cssws
-          ENDIF 
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%qcsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qcsws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qcsws' ) 
              WRITE ( 14 )  surf_v(l)%qcsws
-          ENDIF 
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%ncsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%ncsws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%ncsws' ) 
              WRITE ( 14 )  surf_v(l)%ncsws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%qrsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%qrsws               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%qrsws' )  
              WRITE ( 14 )  surf_v(l)%qrsws
-          ENDIF
+          ENDIF  
+
           IF ( ALLOCATED ( surf_v(l)%nrsws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%nrsws               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%nrsws' )  
              WRITE ( 14 )  surf_v(l)%nrsws
           ENDIF 
+
           IF ( ALLOCATED ( surf_v(l)%sasws ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%sasws               ' 
+             CALL wrd_write_string( 'surf_v(' // dum // ')%sasws' ) 
              WRITE ( 14 )  surf_v(l)%sasws
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_uv ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_uv              '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_uv' )  
              WRITE ( 14 )  surf_v(l)%mom_flux_uv
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_w ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_w               '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_w' ) 
              WRITE ( 14 )  surf_v(l)%mom_flux_w
           ENDIF
+
           IF ( ALLOCATED ( surf_v(l)%mom_flux_tke ) )  THEN
-             WRITE ( 14 )  'surf_v(' // dum // ')%mom_tke             '  
+             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_tke' )  
              WRITE ( 14 )  surf_v(l)%mom_flux_tke
-          ENDIF
+          ENDIF 
 
        ENDDO
 
-       WRITE ( 14 )  '*** end surf ***              '
-
-    END SUBROUTINE surface_write_restart_data
+
+    END SUBROUTINE surface_wrd_local
 
 
@@ -2870,14 +3224,14 @@
 !> of cyclic_fill mode. 
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_read_restart_data( ii,                                  &
-                                       nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
-                                       nynfa, nyn_on_file, nysfa, nys_on_file, &
-                                       offset_xa, offset_ya, overlap_count )
+    SUBROUTINE surface_rrd_local( ii, kk, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & 
+                                  nxr_on_file, nynf, nync, nyn_on_file, nysf,  &
+                                  nysc, nys_on_file, found )
 
        USE pegrid,                                                             &
-           ONLY: numprocs_previous_run
+           ONLY: myid, numprocs_previous_run
+
+       IMPLICIT NONE
 
        CHARACTER (LEN=1)  ::  dum         !< dummy to create correct string for reading input variable
-       CHARACTER (LEN=30) ::  field_chr   !< input variable
 
        INTEGER(iwp)       ::  i           !< running index along x-direction, refers to former domain size
@@ -2886,8 +3240,6 @@
        INTEGER(iwp)       ::  jc          !< running index along y-direction, refers to former domain size
        INTEGER(iwp)       ::  k           !< running index along z-direction
-       INTEGER(iwp)       ::  l           !< index variable for surface type
        INTEGER(iwp)       ::  m           !< running index for surface elements, refers to gathered array encompassing all surface types
        INTEGER(iwp)       ::  mm          !< running index for surface elements, refers to individual surface types
-
        INTEGER(iwp)       ::  ii               !< running index over input files
        INTEGER(iwp)       ::  kk               !< running index over previous input files covering current local domain
@@ -2904,759 +3256,749 @@
        INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
        INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain  
-       INTEGER(iwp)       ::  overlap_count    !< number of overlaps
-  
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !< 
-       INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
-
-
-       LOGICAL                         ::  horizontal_surface !< flag indicating horizontal surfaces
+
+       INTEGER(iwp), SAVE  ::  l           !< index variable for surface type
+
        LOGICAL                         ::  surf_match_def     !< flag indicating that surface element is of default type
        LOGICAL                         ::  surf_match_lsm     !< flag indicating that surface element is of natural type
        LOGICAL                         ::  surf_match_usm     !< flag indicating that surface element is of urban type
-       LOGICAL                         ::  vertical_surface   !< flag indicating vertical surfaces
-
-       TYPE(surf_type), DIMENSION(0:2) ::  surf_h             !< horizontal surface type on file
-       TYPE(surf_type), DIMENSION(0:3) ::  surf_v             !< vertical surface type on file
-
-!
-!--    Read number of respective surface elements on file
-       READ ( 13 )  field_chr
-       IF ( TRIM( field_chr ) /= 'ns_h_on_file' )  THEN
-!
-!--       Add a proper error message
-       ENDIF
-       READ ( 13 ) ns_h_on_file
-
-       READ ( 13 )  field_chr
-       IF ( TRIM( field_chr ) /= 'ns_v_on_file' )  THEN
-!
-!--       Add a proper error message
-       ENDIF
-       READ ( 13 ) ns_v_on_file
-!
-!--    Allocate memory for number of surface elements on file. Please note, 
-!--    these number is not necessarily the same as the final number of surface
-!--    elements on local domain, which is the case if processor topology changes
-!--    during restart runs. 
-!--    Horizontal upward facing
-       surf_h(0)%ns = ns_h_on_file(0)
-       CALL allocate_surface_attributes_h( surf_h(0),                          &
+
+       LOGICAL, INTENT(OUT) ::  found
+
+       LOGICAL, SAVE ::  horizontal_surface !< flag indicating horizontal surfaces
+       LOGICAL, SAVE ::  vertical_surface   !< flag indicating vertical surfaces
+
+       TYPE(surf_type), DIMENSION(0:2), SAVE ::  surf_h             !< horizontal surface type on file
+       TYPE(surf_type), DIMENSION(0:3), SAVE ::  surf_v             !< vertical surface type on file
+
+
+       found              = .TRUE.
+
+
+       SELECT CASE ( restart_string(1:length) )
+
+          CASE ( 'ns_h_on_file' )
+             IF ( kk == 1 )  THEN
+                READ ( 13 )  ns_h_on_file
+
+                IF ( ALLOCATED( surf_h(0)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h( surf_h(0) )           
+                IF ( ALLOCATED( surf_h(1)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h( surf_h(1) )           
+                IF ( ALLOCATED( surf_h(2)%start_index ) )                      &
+                   CALL deallocate_surface_attributes_h_top( surf_h(2) )       
+
+!--             Allocate memory for number of surface elements on file. 
+!--             Please note, these number is not necessarily the same as 
+!--             the final number of surface elements on local domain,
+!--             which is the case if processor topology changes during
+!--             restart runs.  
+!--             Horizontal upward facing
+                surf_h(0)%ns = ns_h_on_file(0)
+                CALL allocate_surface_attributes_h( surf_h(0),                 &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+
+!--             Horizontal downward facing
+                surf_h(1)%ns = ns_h_on_file(1)
+                CALL allocate_surface_attributes_h( surf_h(1),                 &
+                                        nys_on_file, nyn_on_file,              &
+                                        nxl_on_file, nxr_on_file )
+
+!--             Model top
+                surf_h(2)%ns = ns_h_on_file(2)
+                CALL allocate_surface_attributes_h_top( surf_h(2),             &
+                                            nys_on_file, nyn_on_file,          &
+                                            nxl_on_file, nxr_on_file )
+
+!
+!--             Initial setting of flags for horizontal and vertical surfaces,
+!--             will be set after start- and end-indices are read. 
+                horizontal_surface = .FALSE.
+                vertical_surface   = .FALSE.
+
+             ENDIF   
+
+          CASE ( 'ns_v_on_file' )
+             IF ( kk == 1 ) THEN
+                READ ( 13 )  ns_v_on_file
+
+                DO  l = 0, 3
+                   IF ( ALLOCATED( surf_v(l)%start_index ) )                   &
+                      CALL deallocate_surface_attributes_v( surf_v(l) )
+                ENDDO
+
+!--                Vertical surfaces
+                DO  l = 0, 3
+                   surf_v(l)%ns = ns_v_on_file(l)
+                   CALL allocate_surface_attributes_v( surf_v(l),              &
                                            nys_on_file, nyn_on_file,           &
                                            nxl_on_file, nxr_on_file )
-!
-!--    Horizontal downward facing
-       surf_h(1)%ns = ns_h_on_file(1)
-       CALL allocate_surface_attributes_h( surf_h(1),                          &
-                                           nys_on_file, nyn_on_file,           &
-                                           nxl_on_file, nxr_on_file )
-!
-!--    Model top
-       surf_h(2)%ns = ns_h_on_file(2)
-       CALL allocate_surface_attributes_h_top( surf_h(2),                      &
-                                               nys_on_file, nyn_on_file,       &
-                                               nxl_on_file, nxr_on_file )
-!
-!--    Vertical surfaces
-       DO  l = 0, 3
-          surf_v(l)%ns = ns_v_on_file(l)
-          CALL allocate_surface_attributes_v( surf_v(l),                       &
-                                              nys_on_file, nyn_on_file,        &
-                                              nxl_on_file, nxr_on_file )
-       ENDDO
-
-       IF ( initializing_actions == 'read_restart_data'  .OR.                  &
-            initializing_actions == 'cyclic_fill' )  THEN
-!
-!--       Initial setting of flags for horizontal and vertical surfaces, will
-!--       be set after start- and end-indices are read. 
-          horizontal_surface = .FALSE.
-          vertical_surface   = .FALSE.
-
-          READ ( 13 )  field_chr
-
-          DO  WHILE ( TRIM( field_chr ) /= '*** end surf ***' )
-!
-!--          Map data on file as often as needed (data are read only for k=1)
-             DO  kk = 1, overlap_count
-!
-!--             Get the index range of the subdomain on file which overlap with the
-!--             current subdomain
-                nxlf = nxlfa(ii,kk)
-                nxlc = nxlfa(ii,kk) + offset_xa(ii,kk)
-                nxrf = nxrfa(ii,kk)
-                nxrc = nxrfa(ii,kk) + offset_xa(ii,kk)
-                nysf = nysfa(ii,kk)
-                nysc = nysfa(ii,kk) + offset_ya(ii,kk)
-                nynf = nynfa(ii,kk)
-                nync = nynfa(ii,kk) + offset_ya(ii,kk)
-
-                SELECT CASE ( TRIM( field_chr ) )
-
-                   CASE ( 'surf_h(0)%start_index' )
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(0)%start_index
-                      l = 0
-                   CASE ( 'surf_h(0)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(0)%end_index
-                      horizontal_surface = .TRUE.
-                      vertical_surface   = .FALSE.
-                   CASE ( 'surf_h(0)%us' )         
-                      IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%us
-                   CASE ( 'surf_h(0)%ts' )         
-                      IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ts
-                   CASE ( 'surf_h(0)%qs' )         
-                      IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%qs
-                   CASE ( 'surf_h(0)%ss' )         
-                      IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ss
-                   CASE ( 'surf_h(0)%qcs' )         
-                      IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%qcs
-                   CASE ( 'surf_h(0)%ncs' )         
-                      IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%ncs
-                   CASE ( 'surf_h(0)%qrs' )         
-                      IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%qrs
-                   CASE ( 'surf_h(0)%nrs' )         
-                      IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%nrs
-                   CASE ( 'surf_h(0)%ol' )         
-                      IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(0)%ol
-                   CASE ( 'surf_h(0)%rib' )         
-                      IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%rib
-                   CASE ( 'surf_h(0)%pt_surface' )         
-                      IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_h(0)%pt_surface
-                   CASE ( 'surf_h(0)%usws' )         
-                      IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%usws
-                   CASE ( 'surf_h(0)%vsws' )         
-                      IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%vsws
-                   CASE ( 'surf_h(0)%shf' )         
-                      IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%shf
-                   CASE ( 'surf_h(0)%qsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%qsws
-                   CASE ( 'surf_h(0)%ssws' )         
-                      IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(0)%ssws
-                   CASE ( 'surf_h(0)%css' )
-                      IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(0)%css
-                   CASE ( 'surf_h(0)%cssws' )         
-                      IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%cssws
-                   CASE ( 'surf_h(0)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%qcsws
-                   CASE ( 'surf_h(0)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%ncsws
-                   CASE ( 'surf_h(0)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%qrsws
-                   CASE ( 'surf_h(0)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%nrsws
-                   CASE ( 'surf_h(0)%sasws' )         
-                      IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(0)%sasws
-
-                   CASE ( 'surf_h(1)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(1)%start_index
-                      l = 1
-                   CASE ( 'surf_h(1)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(1)%end_index
-                   CASE ( 'surf_h(1)%us' )         
-                      IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%us
-                   CASE ( 'surf_h(1)%ts' )         
-                      IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ts
-                   CASE ( 'surf_h(1)%qs' )         
-                      IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%qs
-                   CASE ( 'surf_h(1)%ss' )         
-                      IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ss
-                   CASE ( 'surf_h(1)%qcs' )         
-                      IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%qcs
-                   CASE ( 'surf_h(1)%ncs' )         
-                      IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%ncs
-                   CASE ( 'surf_h(1)%qrs' )         
-                      IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%qrs
-                   CASE ( 'surf_h(1)%nrs' )         
-                      IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%nrs
-                   CASE ( 'surf_h(1)%ol' )         
-                      IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(1)%ol
-                   CASE ( 'surf_h(1)%rib' )         
-                      IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%rib
-                   CASE ( 'surf_h(1)%pt_surface' )         
-                      IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_h(1)%pt_surface
-                   CASE ( 'surf_h(1)%usws' )         
-                      IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%usws
-                   CASE ( 'surf_h(1)%vsws' )         
-                      IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%vsws
-                   CASE ( 'surf_h(1)%shf' )         
-                      IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%shf
-                   CASE ( 'surf_h(1)%qsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%qsws
-                   CASE ( 'surf_h(1)%ssws' )         
-                      IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(1)%ssws
-                   CASE ( 'surf_h(1)%css' )
-                      IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(1)%css
-                   CASE ( 'surf_h(1)%cssws' )         
-                      IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%cssws
-                   CASE ( 'surf_h(1)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%qcsws
-                   CASE ( 'surf_h(1)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%ncsws
-                   CASE ( 'surf_h(1)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%qrsws
-                   CASE ( 'surf_h(1)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%nrsws
-                   CASE ( 'surf_h(1)%sasws' )         
-                      IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(1)%sasws
-
-                   CASE ( 'surf_h(2)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(2)%start_index
-                      l = 2
-                   CASE ( 'surf_h(2)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_h(2)%end_index
-                   CASE ( 'surf_h(2)%us' )         
-                      IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%us
-                   CASE ( 'surf_h(2)%ts' )         
-                      IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ts
-                   CASE ( 'surf_h(2)%qs' )        
-                      IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%qs
-                   CASE ( 'surf_h(2)%ss' )         
-                      IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ss
-                   CASE ( 'surf_h(2)%qcs' )         
-                      IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%qcs
-                   CASE ( 'surf_h(2)%ncs' )         
-                      IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%ncs
-                   CASE ( 'surf_h(2)%qrs' )         
-                      IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%qrs
-                   CASE ( 'surf_h(2)%nrs' )         
-                      IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%nrs
-                   CASE ( 'surf_h(2)%ol' )         
-                      IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_h(2)%ol
-                   CASE ( 'surf_h(2)%rib' )         
-                      IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%rib
-                   CASE ( 'surf_h(2)%usws' )         
-                      IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%usws
-                   CASE ( 'surf_h(2)%vsws' )         
-                      IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%vsws
-                   CASE ( 'surf_h(2)%shf' )         
-                      IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%shf
-                   CASE ( 'surf_h(2)%qsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%qsws
-                   CASE ( 'surf_h(2)%ssws' )         
-                      IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_h(2)%ssws
-                   CASE ( 'surf_h(2)%css' )
-                      IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_h(2)%css
-                   CASE ( 'surf_h(2)%cssws' )         
-                      IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%cssws
-                   CASE ( 'surf_h(2)%qcsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%qcsws
-                   CASE ( 'surf_h(2)%ncsws' )         
-                      IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%ncsws
-                   CASE ( 'surf_h(2)%qrsws' )         
-                      IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%qrsws
-                   CASE ( 'surf_h(2)%nrsws' )         
-                      IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%nrsws
-                   CASE ( 'surf_h(2)%sasws' )         
-                      IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_h(2)%sasws
-
-                   CASE ( 'surf_v(0)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(0)%start_index
-                      l = 0
-                      horizontal_surface = .FALSE.
-                      vertical_surface   = .TRUE.
-                   CASE ( 'surf_v(0)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(0)%end_index
-                   CASE ( 'surf_v(0)%us' )         
-                      IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%us
-                   CASE ( 'surf_v(0)%ts' )         
-                      IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ts
-                   CASE ( 'surf_v(0)%qs' )         
-                      IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%qs
-                   CASE ( 'surf_v(0)%ss' )         
-                      IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ss
-                   CASE ( 'surf_v(0)%qcs' )         
-                      IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%qcs
-                   CASE ( 'surf_v(0)%ncs' )         
-                      IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%ncs
-                   CASE ( 'surf_v(0)%qrs' )         
-                      IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%qrs
-                   CASE ( 'surf_v(0)%nrs' )         
-                      IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%nrs
-                   CASE ( 'surf_v(0)%ol' )         
-                      IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(0)%ol
-                   CASE ( 'surf_v(0)%rib' )         
-                      IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%rib
-                   CASE ( 'surf_v(0)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(0)%pt_surface
-                   CASE ( 'surf_v(0)%shf' )         
-                      IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%shf
-                   CASE ( 'surf_v(0)%qsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(0)%qsws
-                   CASE ( 'surf_v(0)%ssws' )         
-                      IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(0)%ssws
-                   CASE ( 'surf_v(0)%css' ) 
-                      IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(0)%css
-                   CASE ( 'surf_v(0)%cssws' )         
-                      IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%cssws
-                   CASE ( 'surf_v(0)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%qcsws
-                   CASE ( 'surf_v(0)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%ncsws
-                   CASE ( 'surf_v(0)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%qrsws
-                   CASE ( 'surf_v(0)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%nrsws
-                   CASE ( 'surf_v(0)%sasws' )         
-                      IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(0)%sasws
-                   CASE ( 'surf_v(0)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(0)%mom_flux_uv
-                   CASE ( 'surf_v(0)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(0)%mom_flux_w
-                   CASE ( 'surf_v(0)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(0)%mom_flux_tke
-
-                   CASE ( 'surf_v(1)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(1)%start_index
-                      l = 1
-                   CASE ( 'surf_v(1)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(1)%end_index
-                   CASE ( 'surf_v(1)%us' )         
-                      IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%us
-                   CASE ( 'surf_v(1)%ts' )         
-                      IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ts
-                   CASE ( 'surf_v(1)%qs' )         
-                      IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%qs
-                   CASE ( 'surf_v(1)%ss' )         
-                      IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ss
-                   CASE ( 'surf_v(1)%qcs' )         
-                      IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%qcs
-                   CASE ( 'surf_v(1)%ncs' )         
-                      IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%ncs
-                   CASE ( 'surf_v(1)%qrs' )         
-                      IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%qrs
-                   CASE ( 'surf_v(1)%nrs' )         
-                      IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%nrs
-                   CASE ( 'surf_v(1)%ol' )         
-                      IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(1)%ol
-                   CASE ( 'surf_v(1)%rib' )         
-                      IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%rib
-                   CASE ( 'surf_v(1)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(1)%pt_surface
-                   CASE ( 'surf_v(1)%shf' )         
-                      IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%shf
-                   CASE ( 'surf_v(1)%qsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(1)%qsws
-                   CASE ( 'surf_v(1)%ssws' )         
-                      IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(1)%ssws
-                   CASE ( 'surf_v(1)%css' ) 
-                      IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(1)%css
-                   CASE ( 'surf_v(1)%cssws' )         
-                      IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%cssws
-                   CASE ( 'surf_v(1)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%qcsws
-                   CASE ( 'surf_v(1)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%ncsws
-                   CASE ( 'surf_v(1)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%qrsws
-                   CASE ( 'surf_v(1)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%nrsws
-                   CASE ( 'surf_v(1)%sasws' )         
-                      IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(1)%sasws
-                   CASE ( 'surf_v(1)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(1)%mom_flux_uv
-                   CASE ( 'surf_v(1)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(1)%mom_flux_w
-                   CASE ( 'surf_v(1)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(1)%mom_flux_tke
-
-                   CASE ( 'surf_v(2)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(2)%start_index
-                      l = 2
-                   CASE ( 'surf_v(2)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(2)%end_index
-                   CASE ( 'surf_v(2)%us' )         
-                      IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%us
-                   CASE ( 'surf_v(2)%ts' )         
-                      IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ts
-                   CASE ( 'surf_v(2)%qs' )         
-                      IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%qs
-                   CASE ( 'surf_v(2)%ss' )         
-                      IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ss
-                   CASE ( 'surf_v(2)%qcs' )         
-                      IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%qcs
-                   CASE ( 'surf_v(2)%ncs' )         
-                      IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%ncs
-                   CASE ( 'surf_v(2)%qrs' )         
-                      IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%qrs
-                   CASE ( 'surf_v(2)%nrs' )         
-                      IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%nrs
-                   CASE ( 'surf_v(2)%ol' )         
-                      IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(2)%ol
-                   CASE ( 'surf_v(2)%rib' )         
-                      IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%rib
-                   CASE ( 'surf_v(2)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(2)%pt_surface
-                   CASE ( 'surf_v(2)%shf' )         
-                      IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%shf
-                   CASE ( 'surf_v(2)%qsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(2)%qsws
-                   CASE ( 'surf_v(2)%ssws' )         
-                      IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(2)%ssws
-                   CASE ( 'surf_v(2)%css' ) 
-                      IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(2)%css
-                   CASE ( 'surf_v(2)%cssws' )         
-                      IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%cssws
-                   CASE ( 'surf_v(2)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%qcsws
-                   CASE ( 'surf_v(2)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%ncsws
-                   CASE ( 'surf_v(2)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%qrsws
-                   CASE ( 'surf_v(2)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%nrsws
-                   CASE ( 'surf_v(2)%sasws' )         
-                      IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(2)%sasws
-                   CASE ( 'surf_v(2)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(2)%mom_flux_uv
-                   CASE ( 'surf_v(2)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(2)%mom_flux_w
-                   CASE ( 'surf_v(2)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(2)%mom_flux_tke
-
-                   CASE ( 'surf_v(3)%start_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(3)%start_index
-                      l = 3
-                   CASE ( 'surf_v(3)%end_index' )   
-                      IF ( kk == 1 )                                           &
-                         READ ( 13 )  surf_v(3)%end_index
-                   CASE ( 'surf_v(3)%us' )         
-                      IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%us
-                   CASE ( 'surf_v(3)%ts' )         
-                      IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ts
-                   CASE ( 'surf_v(3)%qs' )        
-                      IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%qs
-                   CASE ( 'surf_v(3)%ss' )         
-                      IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ss
-                   CASE ( 'surf_v(3)%qcs' )         
-                      IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%qcs
-                   CASE ( 'surf_v(3)%ncs' )         
-                      IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%ncs
-                   CASE ( 'surf_v(3)%qrs' )         
-                      IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%qrs
-                   CASE ( 'surf_v(3)%nrs' )         
-                      IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%nrs
-                   CASE ( 'surf_v(3)%ol' )         
-                      IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )         &
-                         READ ( 13 )  surf_v(3)%ol
-                   CASE ( 'surf_v(3)%rib' )         
-                      IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%rib
-                   CASE ( 'surf_v(3)%pt_surface' )         
-                      IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(3)%pt_surface
-                   CASE ( 'surf_v(3)%shf' )         
-                      IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%shf
-                   CASE ( 'surf_v(3)%qsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(3)%qsws
-                   CASE ( 'surf_v(3)%ssws' )         
-                      IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )       &
-                         READ ( 13 )  surf_v(3)%ssws
-                   CASE ( 'surf_v(3)%css' ) 
-                      IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )        &
-                         READ ( 13 )  surf_v(3)%css
-                   CASE ( 'surf_v(3)%cssws' )         
-                      IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%cssws
-                   CASE ( 'surf_v(3)%qcsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%qcsws
-                   CASE ( 'surf_v(3)%ncsws' )         
-                      IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%ncsws
-                   CASE ( 'surf_v(3)%qrsws' )         
-                      IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%qrsws
-                   CASE ( 'surf_v(3)%nrsws' )         
-                      IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%nrsws
-                   CASE ( 'surf_v(3)%sasws' )         
-                      IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )      &
-                         READ ( 13 )  surf_v(3)%sasws
-                   CASE ( 'surf_v(3)%mom_uv' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(3)%mom_flux_uv
-                   CASE ( 'surf_v(3)%mom_w' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 ) &
-                         READ ( 13 )  surf_v(3)%mom_flux_w
-                   CASE ( 'surf_v(3)%mom_tke' )         
-                      IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )&
-                         READ ( 13 )  surf_v(3)%mom_flux_tke
-
-                END SELECT
-!
-!--             Redistribute surface elements on its respective type. 
-                IF ( horizontal_surface )  THEN
-                   ic = nxlc
-                   DO  i = nxlf, nxrf
-                      jc = nysc
-                      DO  j = nysf, nynf
-
-                         surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=   &
-                                           surf_def_h(l)%start_index(jc,ic)
-                         surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=   &
-                                             surf_lsm_h%start_index(jc,ic) )   &
-                                     .AND.  l == 0 
-                         surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=   &
-                                             surf_usm_h%start_index(jc,ic) )   &
-                                     .AND.  l == 0 
-
-                         IF ( surf_match_def )  THEN
-                            mm = surf_def_h(l)%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_def_h(l),   &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_lsm )  THEN
-                            mm = surf_lsm_h%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_lsm_h,      &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_usm )  THEN
-                            mm = surf_usm_h%start_index(jc,ic)
-                            DO  m = surf_h(l)%start_index(j,i),                &
-                                    surf_h(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_usm_h,      &
-                                                              mm, surf_h(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         jc = jc + 1
-                      ENDDO
-                      ic = ic + 1
-                   ENDDO
-                ELSEIF ( vertical_surface )  THEN
-                   ic = nxlc
-                   DO  i = nxlf, nxrf
-                      jc = nysc
-                      DO  j = nysf, nynf
-
-                         surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=   &
-                                           surf_def_v(l)%start_index(jc,ic)
-                         surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=   &
-                                           surf_lsm_v(l)%start_index(jc,ic)
-                         surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=   &
-                                           surf_usm_v(l)%start_index(jc,ic)
-
-                         IF ( surf_match_def )  THEN
-                            mm = surf_def_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_def_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         IF ( surf_match_lsm )  THEN
-                            mm = surf_lsm_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_lsm_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-   
-                         IF ( surf_match_usm )  THEN
-                            mm = surf_usm_v(l)%start_index(jc,ic)
-                            DO  m = surf_v(l)%start_index(j,i),                &
-                                    surf_v(l)%end_index(j,i)
-                               CALL restore_surface_elements( surf_usm_v(l),   &
-                                                              mm, surf_v(l), m )
-                               mm = mm + 1
-                            ENDDO
-                         ENDIF
-
-                         jc = jc + 1
-                      ENDDO
-                      ic = ic + 1
+               ENDDO
+
+             ENDIF
+
+          CASE ( 'surf_h(0)%start_index' )
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(0)%start_index
+             l = 0
+          CASE ( 'surf_h(0)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(0)%end_index
+             horizontal_surface = .TRUE.
+             vertical_surface   = .FALSE.
+          CASE ( 'surf_h(0)%us' )         
+             IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%us
+          CASE ( 'surf_h(0)%ts' )         
+             IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ts
+          CASE ( 'surf_h(0)%qs' )         
+             IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%qs
+          CASE ( 'surf_h(0)%ss' )         
+             IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ss
+          CASE ( 'surf_h(0)%qcs' )         
+             IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%qcs
+          CASE ( 'surf_h(0)%ncs' )         
+             IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%ncs
+          CASE ( 'surf_h(0)%qrs' )         
+             IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%qrs
+          CASE ( 'surf_h(0)%nrs' )         
+             IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%nrs
+          CASE ( 'surf_h(0)%ol' )         
+             IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(0)%ol
+          CASE ( 'surf_h(0)%rib' )         
+             IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%rib
+          CASE ( 'surf_h(0)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(0)%pt_surface
+          CASE ( 'surf_h(0)%usws' )         
+             IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%usws
+          CASE ( 'surf_h(0)%vsws' )         
+             IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%vsws
+          CASE ( 'surf_h(0)%shf' )         
+             IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%shf
+          CASE ( 'surf_h(0)%qsws' )         
+             IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%qsws
+          CASE ( 'surf_h(0)%ssws' )         
+             IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(0)%ssws
+          CASE ( 'surf_h(0)%css' )
+             IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(0)%css
+          CASE ( 'surf_h(0)%cssws' )         
+             IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%cssws
+          CASE ( 'surf_h(0)%qcsws' )         
+             IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%qcsws
+          CASE ( 'surf_h(0)%ncsws' )         
+             IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%ncsws
+          CASE ( 'surf_h(0)%qrsws' )         
+             IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%qrsws
+          CASE ( 'surf_h(0)%nrsws' )         
+             IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%nrsws
+          CASE ( 'surf_h(0)%sasws' )         
+             IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(0)%sasws
+
+          CASE ( 'surf_h(1)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(1)%start_index
+             l = 1
+          CASE ( 'surf_h(1)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(1)%end_index
+          CASE ( 'surf_h(1)%us' )         
+             IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%us
+          CASE ( 'surf_h(1)%ts' )         
+             IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ts
+          CASE ( 'surf_h(1)%qs' )         
+             IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%qs
+          CASE ( 'surf_h(1)%ss' )         
+             IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ss
+          CASE ( 'surf_h(1)%qcs' )         
+             IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%qcs
+          CASE ( 'surf_h(1)%ncs' )         
+             IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%ncs
+          CASE ( 'surf_h(1)%qrs' )         
+             IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%qrs
+          CASE ( 'surf_h(1)%nrs' )         
+             IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%nrs
+          CASE ( 'surf_h(1)%ol' )         
+             IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(1)%ol
+          CASE ( 'surf_h(1)%rib' )         
+             IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%rib
+          CASE ( 'surf_h(1)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(1)%pt_surface
+          CASE ( 'surf_h(1)%usws' )         
+             IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%usws
+          CASE ( 'surf_h(1)%vsws' )         
+             IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%vsws
+          CASE ( 'surf_h(1)%shf' )         
+             IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%shf
+          CASE ( 'surf_h(1)%qsws' )         
+             IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%qsws
+          CASE ( 'surf_h(1)%ssws' )         
+             IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(1)%ssws
+          CASE ( 'surf_h(1)%css' )
+             IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(1)%css
+          CASE ( 'surf_h(1)%cssws' )         
+             IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%cssws
+          CASE ( 'surf_h(1)%qcsws' )         
+             IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%qcsws
+          CASE ( 'surf_h(1)%ncsws' )         
+             IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%ncsws
+          CASE ( 'surf_h(1)%qrsws' )         
+             IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%qrsws
+          CASE ( 'surf_h(1)%nrsws' )         
+             IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%nrsws
+          CASE ( 'surf_h(1)%sasws' )         
+             IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(1)%sasws
+
+          CASE ( 'surf_h(2)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(2)%start_index
+             l = 2
+          CASE ( 'surf_h(2)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_h(2)%end_index
+          CASE ( 'surf_h(2)%us' )         
+             IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%us
+          CASE ( 'surf_h(2)%ts' )         
+             IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ts
+          CASE ( 'surf_h(2)%qs' )        
+             IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%qs
+          CASE ( 'surf_h(2)%ss' )         
+             IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ss
+          CASE ( 'surf_h(2)%qcs' )         
+             IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%qcs
+          CASE ( 'surf_h(2)%ncs' )         
+             IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%ncs
+          CASE ( 'surf_h(2)%qrs' )         
+             IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%qrs
+          CASE ( 'surf_h(2)%nrs' )         
+             IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%nrs
+          CASE ( 'surf_h(2)%ol' )         
+             IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_h(2)%ol
+          CASE ( 'surf_h(2)%rib' )         
+             IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%rib
+          CASE ( 'surf_h(2)%pt_surface' )         
+             IF ( ALLOCATED( surf_h(2)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_h(2)%pt_surface
+          CASE ( 'surf_h(2)%usws' )         
+             IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%usws
+          CASE ( 'surf_h(2)%vsws' )         
+             IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%vsws
+          CASE ( 'surf_h(2)%shf' )         
+             IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%shf
+          CASE ( 'surf_h(2)%qsws' )         
+             IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%qsws
+          CASE ( 'surf_h(2)%ssws' )         
+             IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_h(2)%ssws
+          CASE ( 'surf_h(2)%css' )
+             IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_h(2)%css
+          CASE ( 'surf_h(2)%cssws' )         
+             IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%cssws
+          CASE ( 'surf_h(2)%qcsws' )         
+             IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%qcsws
+          CASE ( 'surf_h(2)%ncsws' )         
+             IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%ncsws
+          CASE ( 'surf_h(2)%qrsws' )         
+             IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%qrsws
+          CASE ( 'surf_h(2)%nrsws' )         
+             IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%nrsws
+          CASE ( 'surf_h(2)%sasws' )         
+             IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_h(2)%sasws
+
+          CASE ( 'surf_v(0)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(0)%start_index
+             l = 0
+             horizontal_surface = .FALSE.
+             vertical_surface   = .TRUE.
+          CASE ( 'surf_v(0)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(0)%end_index
+          CASE ( 'surf_v(0)%us' )         
+             IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%us
+          CASE ( 'surf_v(0)%ts' )         
+             IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ts
+          CASE ( 'surf_v(0)%qs' )         
+             IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%qs
+          CASE ( 'surf_v(0)%ss' )         
+             IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ss
+          CASE ( 'surf_v(0)%qcs' )         
+             IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%qcs
+          CASE ( 'surf_v(0)%ncs' )         
+             IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%ncs
+          CASE ( 'surf_v(0)%qrs' )         
+             IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%qrs
+          CASE ( 'surf_v(0)%nrs' )         
+             IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%nrs
+          CASE ( 'surf_v(0)%ol' )         
+             IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(0)%ol
+          CASE ( 'surf_v(0)%rib' )         
+             IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%rib
+          CASE ( 'surf_v(0)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(0)%pt_surface
+          CASE ( 'surf_v(0)%shf' )         
+             IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%shf
+          CASE ( 'surf_v(0)%qsws' )         
+             IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(0)%qsws
+          CASE ( 'surf_v(0)%ssws' )         
+             IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(0)%ssws
+          CASE ( 'surf_v(0)%css' ) 
+             IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(0)%css
+          CASE ( 'surf_v(0)%cssws' )         
+             IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%cssws
+          CASE ( 'surf_v(0)%qcsws' )         
+             IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%qcsws
+          CASE ( 'surf_v(0)%ncsws' )         
+             IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%ncsws
+          CASE ( 'surf_v(0)%qrsws' )         
+             IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%qrsws
+          CASE ( 'surf_v(0)%nrsws' )         
+             IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%nrsws
+          CASE ( 'surf_v(0)%sasws' )         
+             IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(0)%sasws
+          CASE ( 'surf_v(0)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(0)%mom_flux_uv
+          CASE ( 'surf_v(0)%mom_w' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(0)%mom_flux_w
+          CASE ( 'surf_v(0)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(0)%mom_flux_tke
+
+          CASE ( 'surf_v(1)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(1)%start_index
+             l = 1
+          CASE ( 'surf_v(1)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(1)%end_index
+          CASE ( 'surf_v(1)%us' )         
+             IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%us
+          CASE ( 'surf_v(1)%ts' )         
+             IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ts
+          CASE ( 'surf_v(1)%qs' )         
+             IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%qs
+          CASE ( 'surf_v(1)%ss' )         
+             IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ss
+          CASE ( 'surf_v(1)%qcs' )         
+             IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%qcs
+          CASE ( 'surf_v(1)%ncs' )         
+             IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%ncs
+          CASE ( 'surf_v(1)%qrs' )         
+             IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%qrs
+          CASE ( 'surf_v(1)%nrs' )         
+             IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%nrs
+          CASE ( 'surf_v(1)%ol' )         
+             IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(1)%ol
+          CASE ( 'surf_v(1)%rib' )         
+             IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%rib
+          CASE ( 'surf_v(1)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(1)%pt_surface
+          CASE ( 'surf_v(1)%shf' )         
+             IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%shf
+          CASE ( 'surf_v(1)%qsws' )         
+             IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(1)%qsws
+          CASE ( 'surf_v(1)%ssws' )         
+             IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(1)%ssws
+          CASE ( 'surf_v(1)%css' ) 
+             IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(1)%css
+          CASE ( 'surf_v(1)%cssws' )         
+             IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%cssws
+          CASE ( 'surf_v(1)%qcsws' )         
+             IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%qcsws
+          CASE ( 'surf_v(1)%ncsws' )         
+             IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%ncsws
+          CASE ( 'surf_v(1)%qrsws' )         
+             IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%qrsws
+          CASE ( 'surf_v(1)%nrsws' )         
+             IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%nrsws
+          CASE ( 'surf_v(1)%sasws' )         
+             IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(1)%sasws
+          CASE ( 'surf_v(1)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(1)%mom_flux_uv
+          CASE ( 'surf_v(1)%mom_w' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(1)%mom_flux_w
+          CASE ( 'surf_v(1)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(1)%mom_flux_tke
+
+          CASE ( 'surf_v(2)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(2)%start_index
+             l = 2
+          CASE ( 'surf_v(2)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(2)%end_index
+          CASE ( 'surf_v(2)%us' )         
+             IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%us
+          CASE ( 'surf_v(2)%ts' )         
+             IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ts
+          CASE ( 'surf_v(2)%qs' )         
+             IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%qs
+          CASE ( 'surf_v(2)%ss' )         
+             IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ss
+          CASE ( 'surf_v(2)%qcs' )         
+             IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%qcs
+          CASE ( 'surf_v(2)%ncs' )         
+             IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%ncs
+          CASE ( 'surf_v(2)%qrs' )         
+             IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%qrs
+          CASE ( 'surf_v(2)%nrs' )         
+             IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%nrs
+          CASE ( 'surf_v(2)%ol' )         
+             IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(2)%ol
+          CASE ( 'surf_v(2)%rib' )         
+             IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%rib
+          CASE ( 'surf_v(2)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(2)%pt_surface
+          CASE ( 'surf_v(2)%shf' )         
+             IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%shf
+          CASE ( 'surf_v(2)%qsws' )         
+             IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(2)%qsws
+          CASE ( 'surf_v(2)%ssws' )         
+             IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(2)%ssws
+          CASE ( 'surf_v(2)%css' ) 
+             IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(2)%css
+          CASE ( 'surf_v(2)%cssws' )         
+             IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%cssws
+          CASE ( 'surf_v(2)%qcsws' )         
+             IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%qcsws
+          CASE ( 'surf_v(2)%ncsws' )         
+             IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%ncsws
+          CASE ( 'surf_v(2)%qrsws' )         
+             IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%qrsws
+          CASE ( 'surf_v(2)%nrsws' )         
+             IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%nrsws
+          CASE ( 'surf_v(2)%sasws' )         
+             IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(2)%sasws
+          CASE ( 'surf_v(2)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(2)%mom_flux_uv
+          CASE ( 'surf_v(2)%mom_w' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(2)%mom_flux_w
+          CASE ( 'surf_v(2)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(2)%mom_flux_tke
+
+          CASE ( 'surf_v(3)%start_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(3)%start_index
+             l = 3
+          CASE ( 'surf_v(3)%end_index' )   
+             IF ( kk == 1 )                                                    &
+                READ ( 13 )  surf_v(3)%end_index
+          CASE ( 'surf_v(3)%us' )         
+             IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%us
+          CASE ( 'surf_v(3)%ts' )         
+             IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ts
+          CASE ( 'surf_v(3)%qs' )        
+             IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%qs
+          CASE ( 'surf_v(3)%ss' )         
+             IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ss
+          CASE ( 'surf_v(3)%qcs' )         
+             IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%qcs
+          CASE ( 'surf_v(3)%ncs' )         
+             IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%ncs
+          CASE ( 'surf_v(3)%qrs' )         
+             IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%qrs
+          CASE ( 'surf_v(3)%nrs' )         
+             IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%nrs
+          CASE ( 'surf_v(3)%ol' )         
+             IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )                  &
+                READ ( 13 )  surf_v(3)%ol
+          CASE ( 'surf_v(3)%rib' )         
+             IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%rib
+          CASE ( 'surf_v(3)%pt_surface' )         
+             IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(3)%pt_surface
+          CASE ( 'surf_v(3)%shf' )         
+             IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%shf
+          CASE ( 'surf_v(3)%qsws' )         
+             IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )                & 
+                READ ( 13 )  surf_v(3)%qsws
+          CASE ( 'surf_v(3)%ssws' )         
+             IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )                &
+                READ ( 13 )  surf_v(3)%ssws
+          CASE ( 'surf_v(3)%css' ) 
+             IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )                 &
+                READ ( 13 )  surf_v(3)%css
+          CASE ( 'surf_v(3)%cssws' )         
+             IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%cssws
+          CASE ( 'surf_v(3)%qcsws' )         
+             IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%qcsws
+          CASE ( 'surf_v(3)%ncsws' )         
+             IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%ncsws
+          CASE ( 'surf_v(3)%qrsws' )         
+             IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%qrsws
+          CASE ( 'surf_v(3)%nrsws' )         
+             IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%nrsws
+          CASE ( 'surf_v(3)%sasws' )         
+             IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )               &
+                READ ( 13 )  surf_v(3)%sasws
+          CASE ( 'surf_v(3)%mom_uv' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )         &
+                READ ( 13 )  surf_v(3)%mom_flux_uv
+          CASE ( 'surf_v(3)%mom_w' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 )          &
+                READ ( 13 )  surf_v(3)%mom_flux_w
+          CASE ( 'surf_v(3)%mom_tke' )         
+             IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )        &
+                READ ( 13 )  surf_v(3)%mom_flux_tke
+
+          CASE DEFAULT
+
+                found = .FALSE.
+
+       END SELECT
+
+!
+!--    Redistribute surface elements on its respective type. 
+       IF ( horizontal_surface )  THEN
+          ic = nxlc
+          DO  i = nxlf, nxrf
+             jc = nysc
+             DO  j = nysf, nynf
+
+                surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=            &
+                                  surf_def_h(l)%start_index(jc,ic)
+                surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=            &
+                                    surf_lsm_h%start_index(jc,ic) )            &
+                            .AND.  l == 0 
+                surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=            &
+                                    surf_usm_h%start_index(jc,ic) )            &
+                            .AND.  l == 0 
+
+                IF ( surf_match_def )  THEN
+                   mm = surf_def_h(l)%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_def_h(l),            &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
                    ENDDO
                 ENDIF
 
+                IF ( surf_match_lsm )  THEN
+                   mm = surf_lsm_h%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_lsm_h,               &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_usm )  THEN
+                   mm = surf_usm_h%start_index(jc,ic)
+                   DO  m = surf_h(l)%start_index(j,i),                         &
+                           surf_h(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_usm_h,               &
+                                                     mm, surf_h(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                jc = jc + 1
              ENDDO
-
-             READ ( 13 )  field_chr
-
+             ic = ic + 1
           ENDDO
-
+       ELSEIF ( vertical_surface )  THEN
+          ic = nxlc
+          DO  i = nxlf, nxrf
+             jc = nysc
+             DO  j = nysf, nynf
+
+                surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=            &
+                                  surf_def_v(l)%start_index(jc,ic)
+                surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=            &
+                                  surf_lsm_v(l)%start_index(jc,ic)
+                surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=            &
+                                  surf_usm_v(l)%start_index(jc,ic)
+
+                IF ( surf_match_def )  THEN
+                   mm = surf_def_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_def_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_lsm )  THEN
+                   mm = surf_lsm_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_lsm_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                IF ( surf_match_usm )  THEN
+                   mm = surf_usm_v(l)%start_index(jc,ic)
+                   DO  m = surf_v(l)%start_index(j,i),                         &
+                           surf_v(l)%end_index(j,i)
+                      CALL restore_surface_elements( surf_usm_v(l),            &
+                                                     mm, surf_v(l), m )
+                      mm = mm + 1
+                   ENDDO
+                ENDIF
+
+                jc = jc + 1
+             ENDDO
+             ic = ic + 1
+          ENDDO
        ENDIF
 
-       CONTAINS
+
+    CONTAINS
 !------------------------------------------------------------------------------!
 ! Description:
@@ -3676,5 +4018,5 @@
              TYPE( surf_type ) ::  surf_file   !< surface type on file
 
-             IF ( INDEX( TRIM( field_chr ), '%us' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%us )  .AND.                        &
                      ALLOCATED( surf_file%us   ) )                             & 
@@ -3682,5 +4024,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ol' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ol' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ol )  .AND.                        &
                      ALLOCATED( surf_file%ol   ) )                             & 
@@ -3688,5 +4030,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%pt_surface' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%pt_surface' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%pt_surface )  .AND.                &
                      ALLOCATED( surf_file%pt_surface   ) )                     & 
@@ -3694,5 +4036,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%usws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%usws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%usws )  .AND.                      &
                      ALLOCATED( surf_file%usws   ) )                           & 
@@ -3700,5 +4042,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%vsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%vsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%vsws )  .AND.                      &
                      ALLOCATED( surf_file%vsws   ) )                           & 
@@ -3706,5 +4048,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ts' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ts' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ts )  .AND.                        &
                      ALLOCATED( surf_file%ts   ) )                             & 
@@ -3712,5 +4054,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%shf' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%shf' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%shf )  .AND.                       &
                      ALLOCATED( surf_file%shf   ) )                            & 
@@ -3718,5 +4060,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qs )  .AND.                        &
                      ALLOCATED( surf_file%qs   ) )                             & 
@@ -3724,5 +4066,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qsws )  .AND.                      &
                      ALLOCATED( surf_file%qsws   ) )                           & 
@@ -3730,5 +4072,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ss' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ss' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ss )  .AND.                        &
                      ALLOCATED( surf_file%ss   ) )                             & 
@@ -3736,5 +4078,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ssws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ssws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ssws )  .AND.                      &
                      ALLOCATED( surf_file%ssws   ) )                           & 
@@ -3742,5 +4084,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%css' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%css' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%css )  .AND.                     &
                      ALLOCATED( surf_file%css   ) )  THEN                  
@@ -3750,5 +4092,5 @@
                 ENDIF
              ENDIF
-             IF ( INDEX( TRIM( field_chr ), '%cssws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%cssws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%cssws )  .AND.                     &
                      ALLOCATED( surf_file%cssws   ) )  THEN                  
@@ -3759,5 +4101,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qcs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qcs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qcs )  .AND.                       &
                      ALLOCATED( surf_file%qcs   ) )                            & 
@@ -3765,5 +4107,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qcsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qcsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qcsws )  .AND.                     &
                      ALLOCATED( surf_file%qcsws   ) )                          & 
@@ -3771,5 +4113,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ncs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ncs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ncs )  .AND.                       &
                      ALLOCATED( surf_file%ncs   ) )                            & 
@@ -3777,5 +4119,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%ncsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%ncsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%ncsws )  .AND.                     &
                      ALLOCATED( surf_file%ncsws   ) )                          & 
@@ -3783,5 +4125,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qrs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qrs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qrs )  .AND.                       &
                      ALLOCATED( surf_file%qrs   ) )                            & 
@@ -3789,5 +4131,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%qrsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%qrsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%qrsws )  .AND.                     &
                      ALLOCATED( surf_file%qrsws   ) )                          & 
@@ -3795,5 +4137,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%nrs' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%nrs' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%nrs )  .AND.                       &
                      ALLOCATED( surf_file%nrs   ) )                            & 
@@ -3801,5 +4143,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%nrsws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%nrsws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%nrsws )  .AND.                     &
                      ALLOCATED( surf_file%nrsws   ) )                          & 
@@ -3807,5 +4149,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%sasws' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%sasws' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%sasws )  .AND.                     &
                      ALLOCATED( surf_file%sasws   ) )                          & 
@@ -3813,5 +4155,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_uv' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_uv' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.               &
                      ALLOCATED( surf_file%mom_flux_uv   ) )                    & 
@@ -3820,5 +4162,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_w' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_w' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.                &
                      ALLOCATED( surf_file%mom_flux_w   ) )                     & 
@@ -3827,5 +4169,5 @@
              ENDIF
 
-             IF ( INDEX( TRIM( field_chr ), '%mom_tke' ) /= 0 )  THEN 
+             IF ( INDEX( restart_string(1:length), '%mom_tke' ) /= 0 )  THEN 
                 IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.              &
                      ALLOCATED( surf_file%mom_flux_tke   ) )                   & 
@@ -3834,7 +4176,9 @@
              ENDIF
 
+
           END SUBROUTINE restore_surface_elements
 
-    END SUBROUTINE surface_read_restart_data
+
+    END SUBROUTINE surface_rrd_local
 
  
@@ -3903,5 +4247,5 @@
        REAL(wp), DIMENSION(:) ::  surf_target !< target surface type
        REAL(wp), DIMENSION(:) ::  surf_file   !< surface type on file
-       
+
        ic = nxlc
        DO  i = nxlf, nxrf
