Index: ../trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Element.h	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Element.h	(revision 18855)
@@ -119,6 +119,7 @@
 		bool	     IsInput(int name);
 		bool       IsFloating(); 
 		void       LinearFloatingiceMeltingRate(); 
+		void       MigrateGroundingLine(IssmDouble* sheet_ungrounding);
 		ElementVector*  NewElementVector(int approximation_enum=NoneApproximationEnum);
 		ElementMatrix*  NewElementMatrix(int approximation_enum=NoneApproximationEnum);
 		ElementMatrix*  NewElementMatrixCoupling(int number_nodes,int approximation_enum=NoneApproximationEnum);
@@ -293,7 +294,6 @@
 		virtual void UpdateConstraintsExtrudeFromBase(void)=0;
 		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;
 		virtual int    UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf)=0;
Index: ../trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18855)
@@ -3255,94 +3255,6 @@
 /*}}}*/
 #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){/*{{{*/
 
 	IssmDouble  h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES];
Index: ../trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18855)
@@ -138,7 +138,6 @@
 		void       InputControlUpdate(IssmDouble scalar,bool save_parameter);
 
 		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);
 
 		/*}}}*/
Index: ../trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18855)
@@ -3427,75 +3427,6 @@
 	xDelete<int>(doflist);
 }
 /*}}}*/
-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){/*{{{*/
 
 	IssmDouble  h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES];
Index: ../trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18855)
@@ -134,7 +134,6 @@
 		IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");};
 		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: ../trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18855)
@@ -170,7 +170,6 @@
 		void       InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");};
 
 		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: ../trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18855)
@@ -176,7 +176,6 @@
 		void       InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");};
 
 		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: ../trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- ../trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18854)
+++ ../trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18855)
@@ -1200,6 +1200,106 @@
 	xDelete<IssmDouble>(values);
 
 }/*}}}*/
+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);
 }
