Index: /issm/trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18855)
@@ -1201,4 +1201,104 @@
 
 }/*}}}*/
+void       Element::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/
+
+	int         numvertices = this->GetNumberOfVertices();
+	int        i,migration_style;
+	IssmDouble bed_hydro,yts;
+	IssmDouble rho_water,rho_ice,density;
+	IssmDouble* melting = xNew<IssmDouble>(numvertices);
+	IssmDouble* phi     = xNew<IssmDouble>(numvertices);
+	IssmDouble* h       = xNew<IssmDouble>(numvertices);
+	IssmDouble* s       = xNew<IssmDouble>(numvertices);
+	IssmDouble* b       = xNew<IssmDouble>(numvertices);
+	IssmDouble* r       = xNew<IssmDouble>(numvertices);
+
+	/*Recover info at the vertices: */
+	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
+	parameters->FindParam(&yts,ConstantsYtsEnum);
+	GetInputListOnVertices(&h[0],ThicknessEnum);
+	GetInputListOnVertices(&s[0],SurfaceEnum);
+	GetInputListOnVertices(&b[0],BaseEnum);
+	GetInputListOnVertices(&r[0],BedEnum);
+	GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);
+	rho_water   = matpar->GetRhoWater();
+	rho_ice     = matpar->GetRhoIce();
+	density     = rho_ice/rho_water;
+
+	if(migration_style == ContactEnum){
+		for(i = 0;i < numvertices;i++) phi[i] = phi_ungrounding[vertices[i]->Pid()];
+		this->AddInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum);
+
+		/*go through vertices, and update inputs, considering them to be TriaVertex type: */
+		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.){
+					b[i]  = r[i];
+			}
+		}
+
+		/*Update inputs*/
+		this->AddInput(BaseEnum,&b[0],P1Enum);
+		return;
+	}
+
+	this->AddInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum);
+
+	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
+	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(b[i]<=r[i]){ 
+				b[i]        = r[i];
+				s[i]        = b[i]+h[i];
+			}
+		}
+		/*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */
+		/*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/
+		else{ // phi>0
+			bed_hydro=-density*h[i];
+			if (bed_hydro>r[i]){
+				/*Unground only if the element is connected to the ice shelf*/
+				if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){
+					s[i]        = (1-density)*h[i];
+					b[i]        = -density*h[i];
+				}
+				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
+					s[i]        = (1-density)*h[i];
+					b[i]        = -density*h[i];
+				}
+				else{
+					if(migration_style!=SoftMigrationEnum) _error_("Error: migration should be Aggressive, Soft or Subelement");
+				}
+			}
+		}
+	}
+
+	/*Recalculate phi*/
+	for(i=0;i<numvertices;i++){
+		if(migration_style==SoftMigrationEnum){
+			bed_hydro=-density*h[i];
+			if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){
+				phi[i]=h[i]+r[i]/density;
+			}
+		}
+		else phi[i]=h[i]+r[i]/density;
+	}
+	this->AddInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum);
+
+	/*Update inputs*/
+	this->AddInput(SurfaceEnum,&s[0],P1Enum);
+	this->AddInput(BaseEnum,&b[0],P1Enum);
+
+	/*Delete*/
+	xDelete<IssmDouble>(melting);
+	xDelete<IssmDouble>(phi);
+	xDelete<IssmDouble>(r);
+	xDelete<IssmDouble>(b);
+	xDelete<IssmDouble>(s);
+	xDelete<IssmDouble>(h);
+
+}
+/*}}}*/
 ElementVector* Element::NewElementVector(int approximation_enum){/*{{{*/
 	return new ElementVector(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum);
Index: /issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 18855)
@@ -120,4 +120,5 @@
 		bool       IsFloating(); 
 		void       LinearFloatingiceMeltingRate(); 
+		void       MigrateGroundingLine(IssmDouble* sheet_ungrounding);
 		ElementVector*  NewElementVector(int approximation_enum=NoneApproximationEnum);
 		ElementMatrix*  NewElementMatrix(int approximation_enum=NoneApproximationEnum);
@@ -294,5 +295,4 @@
 		virtual void UpdateConstraintsExtrudeFromTop(void)=0;
 
-		virtual void   MigrateGroundingLine(IssmDouble* sheet_ungrounding)=0;
 		virtual void   FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating)=0;
 		virtual void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding)=0;
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18855)
@@ -3428,73 +3428,4 @@
 }
 /*}}}*/
-void       Penta::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/
-
-	int        i,migration_style;
-	IssmDouble bed_hydro,yts;
-	IssmDouble rho_water,rho_ice,density;
-	IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];
-	IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];
-
-	if(!IsOnBase()) return;
-
-	/*Recover info at the vertices: */
-	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
-	parameters->FindParam(&yts,ConstantsYtsEnum);
-	GetInputListOnVertices(&h[0],ThicknessEnum);
-	GetInputListOnVertices(&s[0],SurfaceEnum);
-	GetInputListOnVertices(&b[0],BaseEnum);
-	GetInputListOnVertices(&r[0],BedEnum);
-	GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);
-	rho_water   = matpar->GetRhoWater();
-	rho_ice     = matpar->GetRhoIce();
-	density     = rho_ice/rho_water;
-
-	/*go through vertices, and update inputs, considering them to be PentaVertex type: */
-	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(b[i]<=r[i]){ 
-				b[i]        = r[i];
-				s[i]        = b[i]+h[i];
-			}
-		}
-		/*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */
-		/*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/
-		else{
-			bed_hydro=-density*h[i];
-			if(bed_hydro>r[i]){
-				/*Unground only if the element is connected to the ice shelf*/
-				if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){
-					s[i]        = (1-density)*h[i];
-					b[i]        = -density*h[i];
-				}
-				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
-					s[i]        = (1-density)*h[i];
-					b[i]        = -density*h[i];
-				}
-				else{
-					if(migration_style!=SoftMigrationEnum) _error_("Error: migration should be Aggressive, Soft or Subelement");
-				}
-			}
-		}
-	}
-
-	/*Recalculate phi*/
-	for(i=0;i<NUMVERTICES;i++){
-		if(migration_style==SoftMigrationEnum){
-			bed_hydro=-density*h[i];
-			if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){
-				phi[i]=h[i]+r[i]/density;
-			}
-		}
-		else phi[i]=h[i]+r[i]/density;
-	}
-	this->inputs->AddInput(new PentaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
-
-	/*Update inputs*/
-	this->inputs->AddInput(new PentaInput(SurfaceEnum,&s[0],P1Enum));
-	this->inputs->AddInput(new PentaInput(BaseEnum,&b[0],P1Enum));
-}
-/*}}}*/
 void       Penta::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18855)
@@ -135,5 +135,4 @@
 		IssmDouble Masscon(IssmDouble* levelset){_error_("not implemented yet");};
 
-		void   MigrateGroundingLine(IssmDouble* sheet_ungrounding);
 		void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding);
 		int    UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18855)
@@ -171,5 +171,4 @@
 
 		void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");};
-		void   MigrateGroundingLine(IssmDouble* sheet_ungrounding){_error_("not implemented yet");};
 		int    UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");};
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18855)
@@ -177,5 +177,4 @@
 
 		void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");};
-		void   MigrateGroundingLine(IssmDouble* sheet_ungrounding){_error_("not implemented yet");};
 		int    UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");};
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18855)
@@ -3256,92 +3256,4 @@
 #endif
 
-void       Tria::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/
-
-	int        i,migration_style;
-	bool       groundedelement = false;
-	IssmDouble bed_hydro,yts;
-	IssmDouble rho_water,rho_ice,density;
-	IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];;
-	IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];
-
-	/*Recover info at the vertices: */
-	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
-	parameters->FindParam(&yts,ConstantsYtsEnum);
-	GetInputListOnVertices(&h[0],ThicknessEnum);
-	GetInputListOnVertices(&s[0],SurfaceEnum);
-	GetInputListOnVertices(&b[0],BaseEnum);
-	GetInputListOnVertices(&r[0],BedEnum);
-	GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);
-	rho_water   = matpar->GetRhoWater();
-	rho_ice     = matpar->GetRhoIce();
-	density     = rho_ice/rho_water;
-
-	if(migration_style == ContactEnum){
-		for(i = 0;i < NUMVERTICES;i++) phi[i] = phi_ungrounding[vertices[i]->Pid()];
-		this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
-
-		/*go through vertices, and update inputs, considering them to be TriaVertex type: */
-		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.){
-					b[i]  = r[i];
-			}
-		}
-
-		/*Update inputs*/
-		this->inputs->AddInput(new TriaInput(BaseEnum,&b[0],P1Enum));
-		return;
-	}
-
-	this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
-
-	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
-	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(b[i]<=r[i]){ 
-				b[i]        = r[i];
-				s[i]        = b[i]+h[i];
-			}
-		}
-		/*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */
-		/*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/
-		else{ // phi>0
-			bed_hydro=-density*h[i];
-			if (bed_hydro>r[i]){
-				/*Unground only if the element is connected to the ice shelf*/
-				if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){
-					s[i]        = (1-density)*h[i];
-					b[i]        = -density*h[i];
-				}
-				else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){
-					s[i]        = (1-density)*h[i];
-					b[i]        = -density*h[i];
-				}
-				else{
-					if(migration_style!=SoftMigrationEnum) _error_("Error: migration should be Aggressive, Soft or Subelement");
-				}
-			}
-		}
-	}
-
-	/*Recalculate phi*/
-	for(i=0;i<NUMVERTICES;i++){
-		if(migration_style==SoftMigrationEnum){
-			bed_hydro=-density*h[i];
-			if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){
-				phi[i]=h[i]+r[i]/density;
-			}
-		}
-		else phi[i]=h[i]+r[i]/density;
-	}
-	this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
-
-	/*Update inputs*/
-	this->inputs->AddInput(new TriaInput(SurfaceEnum,&s[0],P1Enum));
-	this->inputs->AddInput(new TriaInput(BaseEnum,&b[0],P1Enum));
-
-}
-/*}}}*/
 void       Tria::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18854)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18855)
@@ -139,5 +139,4 @@
 
 		void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding);
-		void   MigrateGroundingLine(IssmDouble* sheet_ungrounding);
 		int    UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
 
