Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnGroundingLine.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnGroundingLine.cpp	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnGroundingLine.cpp	(revision 7078)
@@ -0,0 +1,44 @@
+/*!\file CreateElementOnGroundingLine
+ * \brief: create element on grounding line
+ */
+
+#include "./GroundingLineMigrationxLocal.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+bool* CreateElementOnGroundingLine(Elements* elements,double* element_on_iceshelf){
+
+	int      i;
+	int      j;
+	Element *element       = NULL;
+	bool    *element_on_gl = NULL;
+	bool     ongl=false;
+	int     *neighboorsids = NULL;
+	int      sid;
+	int      shelf;
+
+	/*Go through elements, and look for elements that can possibly have a grounding line migration. These 
+	 * are  elements that touch the grounding line: */
+	element_on_gl=(bool*)xmalloc(elements->Size()*sizeof(bool));
+
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		
+		sid=element->Sid();
+		neighboorsids=element->GetHorizontalNeighboorSids();
+
+		shelf=(int)element_on_iceshelf[sid];
+		ongl=false;
+		for(j=0;j<3;j++){
+			if (neighboorsids[j]<0)continue; //this neighboor does not exist
+			if ((shelf==1) & (element_on_iceshelf[neighboorsids[j]]==1))continue;  //both this element and this neighboor are on th ice shelf
+			if ((shelf==0) & (element_on_iceshelf[neighboorsids[j]]==0))continue;  //both this element and this neighboor are on the ice sheet
+			ongl=true; //neighboor j is on a different location than us, ie we are touching the grounding line.
+		}
+		element_on_gl[i]=ongl;
+	}
+
+	return element_on_gl;
+}
Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnIceShelf.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnIceShelf.cpp	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementOnIceShelf.cpp	(revision 7078)
@@ -0,0 +1,38 @@
+/*!\file CreateElementOnIceShelf
+ * \brief: create element on ice shelf, double* vector, from elements, serialized on all cpus.
+ */
+
+#include "./GroundingLineMigrationxLocal.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+double* CreateElementOnIceShelf(Elements* elements){
+
+	int i;
+	Element* element=NULL;
+	Vec vec_element_on_iceshelf=NULL;
+	double* element_on_iceshelf=NULL;
+
+	/*Create  vector holding  all the elements IsOnShelf flags: */
+	vec_element_on_iceshelf=NewVec(elements->NumberOfElements(),true);
+
+	/*Loop through elements, and fill vec_element_on_iceshelf: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		VecSetValue(vec_element_on_iceshelf,element->Sid(),(int)element->IsOnShelf(),INSERT_VALUES);
+	}
+
+	/*Assemble vector: */
+	VecAssemblyBegin(vec_element_on_iceshelf);
+	VecAssemblyEnd(vec_element_on_iceshelf);
+
+	/*Serialize vector: */
+	VecToMPISerial(&element_on_iceshelf,vec_element_on_iceshelf);
+
+	/*free ressouces: */
+	VecFree(&vec_element_on_iceshelf);
+
+	return element_on_iceshelf;
+}
Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementTouchingIceShelf.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementTouchingIceShelf.cpp	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/CreateElementTouchingIceShelf.cpp	(revision 7078)
@@ -0,0 +1,38 @@
+/*!\file CreateElementTouchingIceShelf
+ * \brief: create element on ice shelf, double* vector, from elements, serialized on all cpus.
+ */
+
+#include "./GroundingLineMigrationxLocal.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+double* CreateElementTouchingIceShelf(Elements* elements){
+
+	int i;
+	Element* element=NULL;
+	Vec vec_element_touching_iceshelf=NULL;
+	double* element_touching_iceshelf=NULL;
+
+	/*Create  vector holding  all the elements IsOnShelf flags: */
+	vec_element_touching_iceshelf=NewVec(elements->NumberOfElements(),true);
+
+	/*Loop through elements, and fill vec_element_touching_iceshelf: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		VecSetValue(vec_element_touching_iceshelf,element->Sid(),(int)element->IsNodeOnShelf(),INSERT_VALUES);
+	}
+
+	/*Assemble vector: */
+	VecAssemblyBegin(vec_element_touching_iceshelf);
+	VecAssemblyEnd(vec_element_touching_iceshelf);
+
+	/*Serialize vector: */
+	VecToMPISerial(&element_touching_iceshelf,vec_element_touching_iceshelf);
+
+	/*free ressouces: */
+	VecFree(&vec_element_touching_iceshelf);
+
+	return element_touching_iceshelf;
+}
Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.cpp	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.cpp	(revision 7078)
@@ -0,0 +1,40 @@
+/*!\file GroundingLineMigrationx
+ * \brief: migration grounding line position.
+ */
+
+#include "./GroundingLineMigrationx.h"
+#include "./GroundingLineMigrationxLocal.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void GroundingLineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
+
+	int i,j;
+	Element* element=NULL;
+	double* element_touching_iceshelf=NULL;
+
+	_printf_(VerboseModule(),"   Migrating grounding line\n");
+
+	/*Create  vector holding  all the elements that touch the ice shelf: */
+	element_touching_iceshelf=CreateElementTouchingIceShelf(elements);
+
+	/*Carry out grounding line migration for those elements: */
+	for(i=0;i<elements->Size();i++){
+		if (element_touching_iceshelf[i]){
+			element=(Element*)elements->GetObjectByOffset(i);
+			element->MigrateGroundingLine();
+		}
+	}
+
+	/*Now, update shelf flags in nodes and elements. We could not do this before, 
+	 *because we would end up with discontinuous bed and surface otherwise: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->UpdateShelfStatus();
+	}
+
+	/*free ressouces: */
+	xfree((void**)&element_touching_iceshelf);
+}
Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.h
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.h	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.h	(revision 7078)
@@ -0,0 +1,13 @@
+/*!\file:  GroundingLineMigrationx.h
+ * \brief header file for Grounding Line Migration
+ */ 
+
+#ifndef _GROUNDINGLINEMIGRATIONX_H
+#define _GROUNDINGLINEMIGRATIONX_H
+
+#include "../../Container/Container.h"
+
+/* local prototypes: */
+void GroundingLineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
+
+#endif  /* _GROUNDINGLINEMIGRATIONX_H */
Index: /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationxLocal.h
===================================================================
--- /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationxLocal.h	(revision 7078)
+++ /issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationxLocal.h	(revision 7078)
@@ -0,0 +1,15 @@
+/*!\file:  GroundingLineMigrationxLocal.h
+ * \brief local header file for Grounding Line Migration
+ */ 
+
+#ifndef _GROUNDINGLINEMIGRATIONXLOCAL_H
+#define _GROUNDINGLINEMIGRATIONXLOCAL_H
+
+class Elements;
+
+/* local prototypes: */
+double* CreateElementOnIceShelf(Elements* elements);
+bool*   CreateElementOnGroundingLine(Elements* elements,double* element_on_iceshelf);
+double* CreateElementTouchingIceShelf(Elements* elements);
+
+#endif  /* _GROUNDINGLINEMIGRATIONXLOCAL_H */
