Index: /issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 15971)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 15972)
@@ -48,5 +48,4 @@
 		virtual int    Sid()=0;
 		virtual bool   IsFloating()=0; 
-		virtual bool   IsNodeOnShelf()=0; 
 		virtual bool   IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 
 		virtual bool   IsOnBed()=0;
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15971)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15972)
@@ -2368,4 +2368,5 @@
 	IssmDouble oldsurface[NUMVERTICES];
 	IssmDouble oldthickness[NUMVERTICES];
+	IssmDouble phi[NUMVERTICES];
 	Penta  *penta   = NULL;
 
@@ -2390,4 +2391,5 @@
 	GetInputListOnVertices(&oldsurface[0],SurfaceEnum);
 	GetInputListOnVertices(&oldthickness[0],ThicknessEnum);
+	GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);
 
 	/*Fing MasstransportHydrostaticAdjustment to figure out how to update the geometry:*/
@@ -2400,5 +2402,5 @@
 	for(i=0;i<numdof;i++) {
 		/*If shelf: hydrostatic equilibrium*/
-		if (this->nodes[i]->IsGrounded()){
+		if (phi[i]>0.){
 			newsurface[i]=oldbed[i]+newthickness[i]; //surface = oldbed + newthickness
 			newbed[i]=oldbed[i];               //same bed: do nothing
@@ -2755,19 +2757,4 @@
 	inputs->GetInputValue(&onshelf,MaskElementonfloatingiceEnum);
 	return onshelf;
-}
-/*}}}*/
-/*FUNCTION Penta::IsNodeOnShelf {{{*/
-bool   Penta::IsNodeOnShelf(){
-
-	int  i;
-	bool shelf=false;
-
-	for(i=0;i<6;i++){
-		if (nodes[i]->IsFloating()){
-			shelf=true;
-			break;
-		}
-	}
-	return shelf;
 }
 /*}}}*/
@@ -11235,6 +11222,4 @@
 				floating[i] = false;
 				grounded[i] = true;
-				nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,false));
-				nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,true));
 			}
 		}
@@ -11250,6 +11235,4 @@
 					floating[i] = true;
 					grounded[i] = false;
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true));
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
 				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
@@ -11258,6 +11241,4 @@
 					floating[i] = true;
 					grounded[i] = false;
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true));
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
 				else{
@@ -11267,34 +11248,4 @@
 		}
 	}
-
-	/*SubelementMigrationEnum: if one grounded, all grounded*/
-	if(migration_style==SubelementMigrationEnum){
-		for(i=0;i<NUMVERTICES;i++){
-			if(nodes[i]->IsGrounded()){
-				groundedelement=true;
-				break;
-			}
-		}
-		floatingelement=!groundedelement;
-	}
-	else{
-		for(i=0;i<NUMVERTICES;i++){
-			if(nodes[i]->IsFloating()){
-				floatingelement=true;
-				break;
-			}
-		}
-	}
-
-   /*Add basal melting rate if element just ungrounded*/
-	if(!this->IsFloating() && floatingelement==true){
-		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
-		this->inputs->AddInput(new PentaInput(BasalforcingsMeltingRateEnum,&melting[0],P1Enum));
-	} 
-
-	/*Update inputs*/
-	this->inputs->AddInput(new PentaInput(SurfaceEnum,&s[0],P1Enum));
-	this->inputs->AddInput(new PentaInput(BedEnum,&b[0],P1Enum));
-   this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,floatingelement));
 
 	/*Recalculate phi*/
@@ -11311,10 +11262,38 @@
 	this->InputExtrude(MaskGroundediceLevelsetEnum,ElementEnum);
 
+	/*SubelementMigrationEnum: if one grounded, all grounded*/
+	if(migration_style==SubelementMigrationEnum){
+		for(i=0;i<NUMVERTICES;i++){
+			if(phi[i]>0.){
+				groundedelement=true;
+				break;
+			}
+		}
+		floatingelement=!groundedelement;
+	}
+	else{
+		for(i=0;i<NUMVERTICES;i++){
+			if(phi[i]<=0.){
+				floatingelement=true;
+				break;
+			}
+		}
+	}
+
+   /*Add basal melting rate if element just ungrounded*/
+	if(!this->IsFloating() && floatingelement==true){
+		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
+		this->inputs->AddInput(new PentaInput(BasalforcingsMeltingRateEnum,&melting[0],P1Enum));
+	} 
+
+	/*Update inputs*/
+	this->inputs->AddInput(new PentaInput(SurfaceEnum,&s[0],P1Enum));
+	this->inputs->AddInput(new PentaInput(BedEnum,&b[0],P1Enum));
+   this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,floatingelement));
+
 	/*Extrude inputs*/
 	this->InputExtrude(SurfaceEnum,ElementEnum);
 	this->InputExtrude(BedEnum,ElementEnum);
 	this->InputExtrude(MaskElementonfloatingiceEnum,ElementEnum);
-	this->InputExtrude(MaskVertexonfloatingiceEnum,NodeEnum);
-	this->InputExtrude(MaskVertexongroundediceEnum,NodeEnum);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 15971)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 15972)
@@ -223,5 +223,4 @@
 		bool	         IsOnBed(void);
 		bool           IsFloating(void); 
-		bool           IsNodeOnShelf(); 
 		bool           IsNodeOnShelfFromFlags(IssmDouble* flags);
 		bool           NoIceInElement(void); 
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15971)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15972)
@@ -1667,4 +1667,5 @@
 	IssmDouble* oldbed       = xNew<IssmDouble>(numnodes);
 	IssmDouble* oldsurface   = xNew<IssmDouble>(numnodes);
+	IssmDouble* phi          = xNew<IssmDouble>(numnodes);
 
 	/*Use the dof list to index into the solution vector: */
@@ -1681,6 +1682,7 @@
 	GetInputListOnNodes(&oldsurface[0],SurfaceEnum);
 	GetInputListOnNodes(&oldthickness[0],ThicknessEnum);
-
-	/*Fing MasstransportHydrostaticAdjustment to figure out how to update the geometry:*/
+	GetInputListOnNodes(&phi[0],MaskGroundediceLevelsetEnum);
+
+	/*Find MasstransportHydrostaticAdjustment to figure out how to update the geometry:*/
 	this->parameters->FindParam(&hydroadjustment,MasstransportHydrostaticAdjustmentEnum);
 	rho_ice=matpar->GetRhoIce();
@@ -1689,5 +1691,5 @@
 	for(i=0;i<numnodes;i++) {
 		/*If shelf: hydrostatic equilibrium*/
-		if (this->nodes[i]->IsGrounded()){
+		if (phi[i]>0.){
 			newsurface[i] = oldbed[i]+newthickness[i]; //surface = oldbed + newthickness
 			newbed[i]     = oldbed[i];                 //same bed: do nothing
@@ -1718,4 +1720,5 @@
 	xDelete<IssmDouble>(oldbed);
 	xDelete<IssmDouble>(oldsurface);
+	xDelete<IssmDouble>(phi);
 	xDelete<int>(doflist);
 }
@@ -1956,19 +1959,4 @@
 	bool shelf;
 	inputs->GetInputValue(&shelf,MaskElementonfloatingiceEnum);
-	return shelf;
-}
-/*}}}*/
-/*FUNCTION Tria::IsNodeOnShelf {{{*/
-bool   Tria::IsNodeOnShelf(){
-
-	int  i;
-	bool shelf=false;
-
-	for(i=0;i<3;i++){
-		if (nodes[i]->IsFloating()){
-			shelf=true;
-			break;
-		}
-	}
 	return shelf;
 }
@@ -7345,6 +7333,4 @@
 				floating[i] = false;
 				grounded[i] = true;
-				nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,false));
-				nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,true));
 			}
 		}
@@ -7360,6 +7346,4 @@
 					floating[i] = true;
 					grounded[i] = false;
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true));
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
 				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
@@ -7368,6 +7352,4 @@
 					floating[i] = true;
 					grounded[i] = false;
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true));
-					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
 				else{
@@ -7377,35 +7359,4 @@
 		}
 	}
-
-	/*SubelementMigrationEnum: if one grounded, all grounded*/
-	if(migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){
-		for(i=0;i<NUMVERTICES;i++){
-			if(nodes[i]->IsGrounded()){
-				groundedelement=true;
-				break;
-			}
-		}
-		floatingelement=!groundedelement;
-	}
-	else{
-		/*Otherwise: if one floating, all floating*/
-		for(i=0;i<NUMVERTICES;i++){
-			if(nodes[i]->IsFloating()){
-				floatingelement=true;
-				break;
-			}
-		}
-	}
-
-   /*Add basal melting rate if element just ungrounded*/
-	if(!this->IsFloating() && floatingelement==true){
-		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
-		this->inputs->AddInput(new TriaInput(BasalforcingsMeltingRateEnum,&melting[0],P1Enum));
-	} 
-
-	/*Update inputs*/
-   this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,floatingelement));
-	this->inputs->AddInput(new TriaInput(SurfaceEnum,&s[0],P1Enum));
-	this->inputs->AddInput(new TriaInput(BedEnum,&b[0],P1Enum));
 
 	/*Recalculate phi*/
@@ -7420,4 +7371,36 @@
 	}
 	this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
+
+	/*SubelementMigrationEnum: if one grounded, all grounded*/
+	if(migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){
+		for(i=0;i<NUMVERTICES;i++){
+			if(phi[i]>0.){
+				groundedelement=true;
+				break;
+			}
+		}
+		floatingelement=!groundedelement;
+	}
+	else{
+		/*Otherwise: if one floating, all floating*/
+		for(i=0;i<NUMVERTICES;i++){
+			if(phi[i]<=0.){
+				floatingelement=true;
+				break;
+			}
+		}
+	}
+
+   /*Add basal melting rate if element just ungrounded*/
+	if(!this->IsFloating() && floatingelement==true){
+		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
+		this->inputs->AddInput(new TriaInput(BasalforcingsMeltingRateEnum,&melting[0],P1Enum));
+	} 
+
+	/*Update inputs*/
+   this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,floatingelement));
+	this->inputs->AddInput(new TriaInput(SurfaceEnum,&s[0],P1Enum));
+	this->inputs->AddInput(new TriaInput(BedEnum,&b[0],P1Enum));
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 15971)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 15972)
@@ -88,5 +88,4 @@
 		bool        IsOnBed();
 		bool        IsFloating();
-		bool        IsNodeOnShelf(); 
 		bool        IsNodeOnShelfFromFlags(IssmDouble* flags);
 		bool        NoIceInElement();
