Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17703)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17704)
@@ -64,13 +64,25 @@
 	IssmDouble*  serial_vertexfloating = NULL;
 	IssmDouble*  phi                   = NULL;
+	int index;
+	int* dof=NULL;
+	IssmDouble* xyz_list=NULL;
 
 	/*Initialize vector with number of vertices*/
-	int numberofvertices=vertices->NumberOfVertices();
-	vertexgrounded=new Vector<IssmDouble>(numberofvertices);
-	vertexfloating=new Vector<IssmDouble>(numberofvertices);
-	phi           =xNew<IssmDouble>(numberofvertices);
+	int numberofvertices            = vertices->NumberOfVertices();
+	vertexgrounded                  = new Vector<IssmDouble>(numberofvertices);
+	vertexfloating                  = new Vector<IssmDouble>(numberofvertices);
+	phi                             = xNew<IssmDouble>(numberofvertices);
+	IssmDouble x[numberofvertices];
+	
+	/*Get x coordinate for each vertex*/
+	for(int i = 0;i<elements->Size();i++){
+		Element* element = dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element->GetVerticesCoordinates(&xyz_list);
+		element->GetDofList(&dof,FSvelocityEnum,GsetEnum);	
+		for (int j=0;j<3;j++)	x[dof[j]]=xyz_list[3*j];
+	}
 
 	/*Fill vector vertices_potentially_floating: */
-	for(int i=0;i<elements->Size();i++){
+	for(int i = 0;i<elements->Size();i++){
 		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->FSContactMigration(vertexgrounded,vertexfloating);
@@ -80,19 +92,25 @@
 	vertexgrounded->Assemble();
 	vertexfloating->Assemble();
-	serial_vertexgrounded=vertexgrounded->ToMPISerial();
-	serial_vertexfloating=vertexfloating->ToMPISerial();
-
-	for(int i=0;i<numberofvertices;i++){
+	serial_vertexgrounded = vertexgrounded->ToMPISerial();
+	serial_vertexfloating = vertexfloating->ToMPISerial();
+
+	/*find vertex on GL */
+	for(int i = 0;i<numberofvertices;i++){
 		if(serial_vertexgrounded[i]==1. && serial_vertexfloating[i]==1.){
-			phi[i]=0.;
-		}
-		else if(serial_vertexgrounded[i]==1.){
-			phi[i]=1.;
-		}
-		else if(serial_vertexfloating[i]==1.){
-			phi[i]=-1.;
-		}
-		else{
-			_error_("not supported (vertexfloating="<<serial_vertexfloating[i]<<" vertexgrounded="<<serial_vertexgrounded[i]<<")");
+			phi[i] = 0.;
+			index  = i;
+		}
+	}
+
+	/*assign value for phi, grounded if >0*/
+	for(int i = 0;i<numberofvertices;i++){
+		if (x[i] < x[index]) {
+			phi[i] = 1.;
+		}
+		else if (x[i] > x[index]) {
+			phi[i] = -1.;
+		}
+		else if (x[i]==x[index]) {
+			phi[i] = 0;
 		}
 	}
