Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17704)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17705)
@@ -64,25 +64,13 @@
 	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);
-	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];
-	}
+	int numberofvertices = vertices->NumberOfVertices();
+	vertexgrounded = new Vector<IssmDouble>(numberofvertices);
+	vertexfloating = new Vector<IssmDouble>(numberofvertices);
+	phi            = xNew<IssmDouble>(numberofvertices);
 
 	/*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);
@@ -92,25 +80,20 @@
 	vertexgrounded->Assemble();
 	vertexfloating->Assemble();
-	serial_vertexgrounded = vertexgrounded->ToMPISerial();
-	serial_vertexfloating = vertexfloating->ToMPISerial();
-
-	/*find vertex on GL */
-	for(int i = 0;i<numberofvertices;i++){
+	serial_vertexgrounded=vertexgrounded->ToMPISerial();
+	serial_vertexfloating=vertexfloating->ToMPISerial();
+
+	/*find vertices on GL */
+	for(int i=0;i<numberofvertices;i++){
 		if(serial_vertexgrounded[i]==1. && serial_vertexfloating[i]==1.){
-			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;
+			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]<<")");
 		}
 	}
