Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15966)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15967)
@@ -2779,5 +2779,5 @@
 
 	for(i=0;i<NUMVERTICES;i++){
-		if (reCast<bool,IssmDouble>(flags[nodes[i]->Sid()])){
+		if (flags[vertices[i]->Sid()]<0.){
 			shelf=true;
 			break;
@@ -11200,5 +11200,5 @@
 #ifdef _HAVE_GROUNDINGLINE_
 /*FUNCTION Penta::MigrateGroundingLine{{{*/
-void  Penta::MigrateGroundingLine(IssmDouble* sheet_ungrounding){
+void  Penta::MigrateGroundingLine(IssmDouble* phi_ungrounding){
 
 	int        i,migration_style;
@@ -11253,5 +11253,6 @@
 					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
-				else if(migration_style==SoftMigrationEnum && reCast<int,IssmDouble>(sheet_ungrounding[vertices[i]->Sid()])){
+				//else if(migration_style==SoftMigrationEnum && reCast<int,IssmDouble>(sheet_ungrounding[vertices[i]->Sid()])){
+				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Sid()]<0.){
 					s[i]        = (1-density)*h[i];
 					b[i]        = -density*h[i];
@@ -11302,5 +11303,6 @@
 		if(migration_style==SoftMigrationEnum){
 			bed_hydro=-density*h[i];
-			if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
+			//if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
+			if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Sid()]<0.){
 				phi[i]=h[i]+r[i]/density;
 			}
@@ -11356,8 +11358,8 @@
 	for(i=0;i<NUMVERTICES;i++){
 		if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[nodes[i]->Sid()])){
-			vec_nodes_on_iceshelf->SetValue(vertices[i]->Sid(),1,INS_VAL);
+			vec_nodes_on_iceshelf->SetValue(vertices[i]->Sid(),-1.,INS_VAL);
 
 			/*If node was not on ice shelf, we flipped*/
-			if(nodes_on_iceshelf[vertices[i]->Sid()]==0){
+			if(nodes_on_iceshelf[vertices[i]->Sid()]>=0.){
 				nflipped++;
 			}
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15966)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15967)
@@ -1981,5 +1981,5 @@
 
 	for(i=0;i<NUMVERTICES;i++){
-		if (reCast<bool>(flags[nodes[i]->Sid()])){
+		if (flags[vertices[i]->Sid()]<0.){
 			shelf=true;
 			break;
@@ -7312,5 +7312,5 @@
 #ifdef _HAVE_GROUNDINGLINE_
 /*FUNCTION Tria::MigrateGroundingLine{{{*/
-void  Tria::MigrateGroundingLine(IssmDouble* sheet_ungrounding){
+void  Tria::MigrateGroundingLine(IssmDouble* phi_ungrounding){
 
 	int        i,migration_style;
@@ -7363,6 +7363,6 @@
 					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
-				else if(migration_style==SoftMigrationEnum && reCast<bool>(sheet_ungrounding[vertices[i]->Sid()])){
-				//else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Sid()]<0.){
+				//else if(migration_style==SoftMigrationEnum && reCast<bool>(sheet_ungrounding[vertices[i]->Sid()])){
+				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Sid()]<0.){
 					s[i]        = (1-density)*h[i];
 					b[i]        = -density*h[i];
@@ -7414,6 +7414,6 @@
 		if(migration_style==SoftMigrationEnum){
 			bed_hydro=-density*h[i];
-			//if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Sid()]<0.){
-			if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[vertices[i]->Sid()])){
+			if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Sid()]<0.){
+			//if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[vertices[i]->Sid()])){
 				phi[i]=h[i]+r[i]/density;
 			}
@@ -7461,8 +7461,8 @@
 	for(i=0;i<3;i++){
 		if (reCast<bool>(vertices_potentially_ungrounding[vertices[i]->Sid()])){
-			vec_nodes_on_iceshelf->SetValue(vertices[i]->Sid(),1,INS_VAL);
+			vec_nodes_on_iceshelf->SetValue(vertices[i]->Sid(),-1.,INS_VAL);
 
 			/*If node was not on ice shelf, we flipped*/
-			if(nodes_on_iceshelf[vertices[i]->Sid()]==0){
+			if(nodes_on_iceshelf[vertices[i]->Sid()]>=0.){
 				nflipped++;
 			}
Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 15966)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 15967)
@@ -51,31 +51,4 @@
 }
 
-/*FUNCTION CreateNodesOnFloatingIce {{{*/
-Vector<IssmDouble>* CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){ 
-
-	int     i,numnods;
-	Vector<IssmDouble>*   vec_nodes_on_floatingice = NULL;
-	Node *node                     = NULL;
-
-	/*First, initialize nodes_on_floatingice, which will track which nodes have changed status: */
-	numnods=nodes->NumberOfNodes(configuration_type);
-	vec_nodes_on_floatingice=new Vector<IssmDouble>(numnods);
-
-	/*Loop through nodes, and fill vec_nodes_on_floatingice: */
-	for(i=0;i<nodes->Size();i++){
-		node=(Node*)nodes->GetObjectByOffset(i);
-		if(node->InAnalysis(configuration_type)){
-			if(node->IsFloating()){
-				vec_nodes_on_floatingice->SetValue(node->Sid(),1.0,INS_VAL);
-			}
-		}
-	}
-
-	/*Assemble vector: */
-	vec_nodes_on_floatingice->Assemble();
-
-	return vec_nodes_on_floatingice;
-}
-/*%}}}*/
 /*FUNCTION PotentialUngrounding {{{*/
 IssmDouble*    PotentialUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){ 
@@ -111,8 +84,8 @@
 	int      numberofvertices;
 	int      nflipped,local_nflipped;
-	IssmDouble*  nodes_on_floatingice                  = NULL;
+	IssmDouble*  phi                  = NULL;
 	IssmDouble*  elements_neighboring_floatingce      = NULL;
 	Vector<IssmDouble>*      vec_elements_neighboring_floatingice = NULL;
-	Vector<IssmDouble>*      vec_nodes_on_floatingice              = NULL;
+	Vector<IssmDouble>*      vec_phi              = NULL;
 	Node*    node                                  = NULL;
 	Element* element                               = NULL;
@@ -122,7 +95,11 @@
 	numberofvertices=vertices->NumberOfVertices();
 
-	/*recover vec_nodes_on_floatingice*/
-	vec_nodes_on_floatingice=CreateNodesOnFloatingIce(nodes,analysis_type);
-	nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
+	/*recover vec_phi*/
+	vec_phi=new Vector<IssmDouble>(vertices->NumberOfVertices());
+	for(i=0;i<elements->Size();i++){
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element->GetVectorFromInputs(vec_phi,MaskGroundediceLevelsetEnum);
+	}
+	phi=vec_phi->ToMPISerial();
 
 	nflipped=1; //bootstrap
@@ -135,5 +112,5 @@
 		for(i=0;i<elements->Size();i++){
 			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
-			vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INS_VAL);
+			vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(phi)?1.0:0.0,INS_VAL);
 		}
 
@@ -147,8 +124,8 @@
 			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 			if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){
-				local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_nodes_on_floatingice,nodes_on_floatingice);
+				local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_phi,phi);
 			}
 		}
-		vec_nodes_on_floatingice->Assemble();
+		vec_phi->Assemble();
 
 		ISSM_MPI_Allreduce(&local_nflipped,&nflipped,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
@@ -157,16 +134,16 @@
 		/*Avoid leaks: */
 		xDelete<IssmDouble>(elements_neighboring_floatingce);
-		xDelete<IssmDouble>(nodes_on_floatingice);
+		xDelete<IssmDouble>(phi);
 
 		/*Assemble and serialize:*/
 		delete vec_elements_neighboring_floatingice;
-		nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
+		phi=vec_phi->ToMPISerial();
 	}
 
 	/*Free ressources:*/
-	delete vec_nodes_on_floatingice;
+	delete vec_phi;
 	xDelete<IssmDouble>(elements_neighboring_floatingce);
 
-	return nodes_on_floatingice;
+	return phi;
 }
 /*}}}*/
