Index: /issm/trunk/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk/src/c/Container/Vertices.cpp	(revision 10354)
+++ /issm/trunk/src/c/Container/Vertices.cpp	(revision 10355)
@@ -155,12 +155,9 @@
 int Vertices::NumberOfVertices(void){
 
-	int i;
-
+	int i,sid;
 	int max_sid=0;
-	int sid;
 	int vertex_max_sid;
 
 	for(i=0;i<this->Size();i++){
-		
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
 		sid=vertex->Sid();
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 10354)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 10355)
@@ -14,6 +14,8 @@
 void GroundinglineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
 
-	int i, migration_style;
-	Element* element=NULL;
+	int      i, migration_style;
+	double*  vertices_potentially_ungrounding = NULL;
+	double*  sheet_ungrounding                = NULL;
+	Element* element                          = NULL;
 	
 	_printf_(VerboseModule(),"   Migrating grounding line\n");
@@ -21,45 +23,29 @@
 	/*retrieve parameters: */
 	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
+	if(migration_style==NoneEnum) return;
+	if(migration_style!=AgressiveMigrationEnum && migration_style!=SoftMigrationEnum) _error_("%s not supported yet!",EnumToStringx(migration_style));
 
-	/*call different migration modules, according to user wishes: */
-	if(migration_style==AgressiveMigrationEnum){
-		/*Migrate grounding line : */
-		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
-			element->AgressiveMigration();
-		}
-
-		/*Synchronise mask: */
-		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
-			element->ShelfSync();
-		}
-	}
-	else if(migration_style==SoftMigrationEnum){
-
+	if(migration_style==SoftMigrationEnum){
 		/*Create flag for nodes above the hydrostatic equilibrium: */
-		double* vertices_potentially_ungrounding=PotentialSheetUngrounding(elements,vertices,parameters);
+		vertices_potentially_ungrounding=PotentialSheetUngrounding(elements,vertices,parameters);
 
 		/*propagate ice shelf into connex areas of the ice sheet that potentially want to unground: */
-		double* sheet_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
+		sheet_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
+	}
 
-		/*Now, use the sheet_ungrounding flags to unground the ice sheet (at the same time, take care of grounding elements of the ice shelf 
-		 * that want to: */
-		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
-			element->SoftMigration(sheet_ungrounding);
-		}
+	/*Migrate grounding line : */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->Migration(sheet_ungrounding);
+	}
 
-		/*Synchronise mask*/
-		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
-			element->ShelfSync();
-		}
+	/*Synchronise mask: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->ShelfSync();
+	}
 
-		/*free ressouces: */
-		xfree((void**)&vertices_potentially_ungrounding);
-		xfree((void**)&sheet_ungrounding);
-	}
-	else if(migration_style==NoneEnum) _printf_(true,"%s\n","NoneEnum supplied for migration style, doing nothing!");
-	else _error_("%s not supported yet!",EnumToStringx(migration_style));
+	/*free ressouces: */
+	xfree((void**)&vertices_potentially_ungrounding);
+	xfree((void**)&sheet_ungrounding);
 }
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp	(revision 10354)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp	(revision 10355)
@@ -16,5 +16,5 @@
 	int      i,numberofvertices;
 	double*  vertices_potentially_ungrounding      = NULL;
-	Vec      vec_vertices_potentially_ungrounding = NULL;
+	Vec      vec_vertices_potentially_ungrounding  = NULL;
 	Element* element                               = NULL;
 
Index: /issm/trunk/src/c/objects/Elements/Element.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Element.h	(revision 10354)
+++ /issm/trunk/src/c/objects/Elements/Element.h	(revision 10355)
@@ -65,6 +65,5 @@
 		virtual int*   GetHorizontalNeighboorSids(void)=0;
 		virtual double TimeAdapt()=0;
-		virtual void   AgressiveMigration()=0;
-		virtual void   SoftMigration(double* sheet_ungrounding)=0;
+		virtual void   Migration(double* sheet_ungrounding)=0;
 		virtual void   ShelfSync()=0;
 		virtual void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding)=0;
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 10354)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 10355)
@@ -306,11 +306,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::AgressiveMigration{{{1*/
-void  Penta::AgressiveMigration(void){
-	_error_("not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::SoftMigration{{{1*/
-void  Penta::SoftMigration(double* sheet_ungrounding){
+/*FUNCTION Penta::Migration{{{1*/
+void  Penta::Migration(double* sheet_ungrounding){
 	_error_("not supported yet!");
 }
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 10354)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 10355)
@@ -103,6 +103,5 @@
 		
 		void   InputToResult(int enum_type,int step,double time);
-		void   AgressiveMigration();
-		void   SoftMigration(double* sheet_ungrounding);
+		void   Migration(double* sheet_ungrounding);
 		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
 		void   ShelfSync();
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10354)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10355)
@@ -278,46 +278,4 @@
 
 /*Other*/
-/*FUNCTION Tria::AgressiveMigration{{{1*/
-void  Tria::AgressiveMigration(void){
-
-	int     i;
-	bool    elementonshelf = false;
-	double  bed_hydro;
-	double  rho_water,rho_ice,density;
-	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
-
-	/*vertices and material parameters: */
-	GetInputListOnVertices(&h[0],ThicknessEnum);
-	GetInputListOnVertices(&s[0],SurfaceEnum);
-	GetInputListOnVertices(&b[0],BedEnum);
-	GetInputListOnVertices(&ba[0],BathymetryEnum);
-	rho_water=matpar->GetRhoWater();
-	rho_ice=matpar->GetRhoIce();
-	density=rho_ice/rho_water;
-
-	/*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 (nodes[i]->IsFloating()){
-			if(b[i]<=ba[i]){ 
-				b[i]=ba[i];
-				s[i]=b[i]+h[i];
-			}
-		}
-		/*Ice sheet: if hydrostatic bed above bathymetry, the ice sheet start to unground, elso do nothing */
-		else{
-			bed_hydro=-density*h[i];
-			if (bed_hydro>ba[i]){
-				s[i]=(1-density)*h[i];
-				b[i]=-density*h[i];
-			}
-		}
-	}
-
-	/*Update inputs*/
-	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
-	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
-	}
-/*}}}*/
 /*FUNCTION Tria::AverageOntoPartition {{{1*/
 void  Tria::AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part){
@@ -1964,4 +1922,55 @@
 
 }/*}}}*/
+/*FUNCTION Tria::Migration{{{1*/
+void  Tria::Migration(double* sheet_ungrounding){
+
+	int     i,migration_style,unground;
+	bool    elementonshelf = false;
+	double  bed_hydro;
+	double  rho_water,rho_ice,density;
+	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
+
+	/*Recover info at the vertices: */
+	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
+	GetInputListOnVertices(&h[0],ThicknessEnum);
+	GetInputListOnVertices(&s[0],SurfaceEnum);
+	GetInputListOnVertices(&b[0],BedEnum);
+	GetInputListOnVertices(&ba[0],BathymetryEnum);
+	rho_water=matpar->GetRhoWater();
+	rho_ice=matpar->GetRhoIce();
+	density=rho_ice/rho_water;
+	
+	/*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 (nodes[i]->IsFloating()){
+			if(b[i]<=ba[i]){ 
+				b[i]=ba[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 AgressiveMigration or if the ice sheet is in contact with the ocean*/
+		else{
+			bed_hydro=-density*h[i];
+			if (bed_hydro>ba[i]){
+				/*Unground only if the element is connected to the ice shelf*/
+				if(migration_style==AgressiveMigrationEnum){
+					s[i]=(1-density)*h[i];
+					b[i]=-density*h[i];
+				}
+				else if(migration_style==SoftMigrationEnum && sheet_ungrounding[nodes[i]->Sid()]){
+					s[i]=(1-density)*h[i];
+					b[i]=-density*h[i];
+				}
+			}
+		}
+	}
+
+	/*Update inputs*/    
+	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
+	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
+}
+/*}}}*/
 /*FUNCTION Tria::MigrateGroundingline{{{1*/
 void  Tria::MigrateGroundingline(void){
@@ -2085,21 +2094,9 @@
 void  Tria::PotentialSheetUngrounding(Vec potential_sheet_ungrounding){
 
-
-	double *values         = NULL;
-	double  h[3],s[3],b[3],ba[3];
+	int     i;
+	double  h[NUMVERTICES],ba[NUMVERTICES];
 	double  bed_hydro;
 	double  rho_water,rho_ice,density;
-	int     i;
 	bool    elementonshelf = false;
-
-	/*Recover info at the vertices: */
-	Input* surface_input =inputs->GetInput(SurfaceEnum); _assert_(surface_input);
-	Input* bed_input     =inputs->GetInput(BedEnum);     _assert_(bed_input);
-	if((surface_input->ObjectEnum()!=TriaVertexInputEnum) | (bed_input->ObjectEnum()!=TriaVertexInputEnum))_error_(" not supported yet for bed and surface interpolations not P1!");
-
-	GetInputListOnVertices(&h[0],ThicknessEnum);
-	GetInputListOnVertices(&s[0],SurfaceEnum);
-	GetInputListOnVertices(&b[0],BedEnum);
-	GetInputListOnVertices(&ba[0],BathymetryEnum);
 
 	/*material parameters: */
@@ -2107,14 +2104,14 @@
 	rho_ice=matpar->GetRhoIce();
 	density=rho_ice/rho_water;
+	GetInputListOnVertices(&h[0],ThicknessEnum);
+	GetInputListOnVertices(&ba[0],BathymetryEnum);
 
 	/*go through vertices, and figure out which ones are on the ice sheet, and want to unground: */
-	for(i=0;i<3;i++){
+	for(i=0;i<NUMVERTICES;i++){
+		/*Find if grounded vertices want to start floating*/
 		if (!nodes[i]->IsFloating()){
-			
-			/*This node is on the sheet, near the grounding line. See if wants to unground. To 
-			 * do so, we compute the hydrostatic bed, and if it is > bathymetry, then we unground: */
 			bed_hydro=-density*h[i];
 			if (bed_hydro>ba[i]){
-				/*ok, this node wants to unground. flag it: */
+				/*Vertex that could potentially unground, flag it*/
 				VecSetValue(potential_sheet_ungrounding,nodes[i]->Sid(),1,INSERT_VALUES);
 			}
@@ -2225,49 +2222,4 @@
 	/*Update inputs*/
    this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf));
-}
-/*}}}*/
-/*FUNCTION Tria::SoftMigration{{{1*/
-void  Tria::SoftMigration(double* sheet_ungrounding){
-
-	int     i;
-	bool    elementonshelf = false;
-	double  bed_hydro;
-	double  rho_water,rho_ice,density;
-	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
-
-	/*Recover info at the vertices: */
-	GetInputListOnVertices(&h[0],ThicknessEnum);
-	GetInputListOnVertices(&s[0],SurfaceEnum);
-	GetInputListOnVertices(&b[0],BedEnum);
-	GetInputListOnVertices(&ba[0],BathymetryEnum);
-	rho_water=matpar->GetRhoWater();
-	rho_ice=matpar->GetRhoIce();
-	density=rho_ice/rho_water;
-	
-	/*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 (nodes[i]->IsFloating()){
-			if(b[i]<=ba[i]){ 
-				b[i]=ba[i];
-				s[i]=b[i]+h[i];
-			}
-		}
-		/*Ice sheet: if hydrostatic bed above bathymetry, the ice sheet starts to unground if it is connected to the ice shelf, elso do nothing */
-		else{
-			bed_hydro=-density*h[i];
-			if (bed_hydro>ba[i]){
-				/*Unground only if the element is connected to the ice shelf*/
-				if(sheet_ungrounding[nodes[i]->Sid()]){
-					s[i]=(1-density)*h[i];
-					b[i]=-density*h[i];
-				}
-			}
-		}
-	}
-
-	/*Update inputs*/    
-	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
-	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 10354)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 10355)
@@ -104,6 +104,5 @@
 		void   MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
 		
-		void   AgressiveMigration();
-		void   SoftMigration(double* sheet_ungrounding);
+		void   Migration(double* sheet_ungrounding);
 		void   ShelfSync();
 		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
