Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15958)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 15959)
@@ -11299,5 +11299,13 @@
 
 	/*Recalculate phi*/
-	for(i=0;i<NUMVERTICES;i++) phi[i]=h[i]+r[i]/density;
+	for(i=0;i<NUMVERTICES;i++){
+		if(migration_style==SoftMigrationEnum){
+			bed_hydro=-density*h[i];
+			if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
+				phi[i]=h[i]+r[i]/density;
+			}
+		}
+		else phi[i]=h[i]+r[i]/density;
+	}
 	this->inputs->AddInput(new PentaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
 	this->InputExtrude(MaskGroundediceLevelsetEnum,ElementEnum);
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15958)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15959)
@@ -7339,5 +7339,5 @@
 	for(i=0;i<NUMVERTICES;i++){
 		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
-		if(phi[i]<=0){
+		if(phi[i]<=0.){
 			if(b[i]<=r[i]){ 
 				b[i]        = r[i];
@@ -7351,5 +7351,5 @@
 		/*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */
 		/*Change only if AgressiveMigration or if the ice sheet is in contact with the ocean*/
-		else{
+		else{ // phi>0
 			bed_hydro=-density*h[i];
 			if (bed_hydro>r[i]){
@@ -7410,5 +7410,13 @@
 
 	/*Recalculate phi*/
-	for(i=0;i<NUMVERTICES;i++) phi[i]=h[i]+r[i]/density;
+	for(i=0;i<NUMVERTICES;i++){
+		if(migration_style==SoftMigrationEnum){
+			bed_hydro=-density*h[i];
+			if(phi[i]<0. || bed_hydro<=r[i] || reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
+				phi[i]=h[i]+r[i]/density;
+			}
+		}
+		else phi[i]=h[i]+r[i]/density;
+	}
 	this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
 }
