Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 2940)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 2942)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix in assigning surface element data after restart
+! 
+! 2940 2018-04-03 11:22:42Z suehring
 ! Bugfix in reading restart data of vertical surface elements
 ! 
@@ -3928,6 +3931,7 @@
                    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 )
+                      IF ( surf_def_h(l)%end_index(jc,ic) >= mm )              &
+                         CALL restore_surface_elements( surf_def_h(l),         &
+                                                        mm, surf_h(l), m )
                       mm = mm + 1
                    ENDDO
@@ -3938,6 +3942,7 @@
                    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 )
+                      IF ( surf_lsm_h%end_index(jc,ic) >= mm )                 &
+                         CALL restore_surface_elements( surf_lsm_h,            &
+                                                        mm, surf_h(l), m )
                       mm = mm + 1
                    ENDDO
@@ -3948,6 +3953,7 @@
                    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 )
+                      IF ( surf_usm_h%end_index(jc,ic) >= mm )                 &
+                         CALL restore_surface_elements( surf_usm_h,            &
+                                                        mm, surf_h(l), m )
                       mm = mm + 1
                    ENDDO
@@ -3977,6 +3983,7 @@
                    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 )
+                      IF ( surf_def_v(l)%end_index(jc,ic) >= mm )              &
+                         CALL restore_surface_elements( surf_def_v(l),         &
+                                                        mm, surf_v(l), m )
                       mm = mm + 1
                    ENDDO
@@ -3987,6 +3994,7 @@
                    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 )
+                      IF ( surf_lsm_v(l)%end_index(jc,ic) >= mm )              &
+                         CALL restore_surface_elements( surf_lsm_v(l),         &
+                                                        mm, surf_v(l), m )
                       mm = mm + 1
                    ENDDO
@@ -3997,6 +4005,7 @@
                    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 )
+                      IF ( surf_usm_v(l)%end_index(jc,ic) >= mm )              &
+                         CALL restore_surface_elements( surf_usm_v(l),         &
+                                                        mm, surf_v(l), m )
                       mm = mm + 1
                    ENDDO
@@ -4027,4 +4036,5 @@
              TYPE( surf_type ) ::  surf_target !< target surface type
              TYPE( surf_type ) ::  surf_file   !< surface type on file
+
 
              IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN 
