Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 10355)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 10356)
@@ -16,5 +16,5 @@
 	int      i, migration_style;
 	double*  vertices_potentially_ungrounding = NULL;
-	double*  sheet_ungrounding                = NULL;
+	double*  vertices_ungrounding             = NULL;
 	Element* element                          = NULL;
 	
@@ -31,5 +31,5 @@
 
 		/*propagate ice shelf into connex areas of the ice sheet that potentially want to unground: */
-		sheet_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
+		vertices_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
 	}
 
@@ -37,5 +37,5 @@
 	for(i=0;i<elements->Size();i++){
 		element=(Element*)elements->GetObjectByOffset(i);
-		element->Migration(sheet_ungrounding);
+		element->Migration(vertices_ungrounding);
 	}
 
@@ -48,4 +48,4 @@
 	/*free ressouces: */
 	xfree((void**)&vertices_potentially_ungrounding);
-	xfree((void**)&sheet_ungrounding);
+	xfree((void**)&vertices_ungrounding);
 }
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxLocal.h
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxLocal.h	(revision 10355)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxLocal.h	(revision 10356)
@@ -17,5 +17,6 @@
 double*    CreateElementOnIceShelf(Elements* elements);
 double*    CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf);
+Vec        CreateNodesOnIceShelf(Nodes* nodes,int analysis_type);
+
 int        UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf);
-Vec        CreateNodesOnIceShelf(Nodes* nodes,int analysis_type);
 #endif  /* _GROUNDINGLINEMIGRATIONXLOCAL_H */
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp	(revision 10355)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp	(revision 10356)
@@ -11,105 +11,12 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-/*FUNCTION PotentialSheetUngrounding {{{1*/
-double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){ 
-
-	int      i,numberofvertices;
-	double*  vertices_potentially_ungrounding      = NULL;
-	Vec      vec_vertices_potentially_ungrounding  = NULL;
-	Element* element                               = NULL;
-
-	/*Initialize vector with number of vertices*/
-	numberofvertices=vertices->NumberOfVertices();
-	vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
-
-	/*Fill vector vertices_potentially_floating: */
-	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
-		element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
-	}
-
-	/*Assemble vector: */
-	VecAssemblyBegin(vec_vertices_potentially_ungrounding);
-	VecAssemblyEnd(vec_vertices_potentially_ungrounding);
-
-	/*Serialize vector: */
-	VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
-
-	/*free ressouces and return: */
-	VecFree(&vec_vertices_potentially_ungrounding);
-	return vertices_potentially_ungrounding;
-}
-/*}}}*/
-/*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/
-double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* potential_sheet_ungrounding){ 
-
-	int      i;
-	Element* element=NULL;
-	int      numnods;
-	int      analysis_type;
-	Vec      vec_nodes_on_iceshelf=NULL;
-	double*  nodes_on_iceshelf=NULL;
-	int      nflipped,local_nflipped;
-	double*  elements_touching_iceshelf=NULL;
-
-	/*recover parameters: */
-	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
-
-	/*recover vec_nodes_on_iceshelf: */
-	vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type);
-
-	nflipped=1; //bootstrap
-	while(nflipped){
-		
-		/*get a list of potential elements that have nodes on ice shelf: */
-		elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf);
-
-		/*now,  go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding, 
-		 * flag it: */
-		local_nflipped=0;
-
-		/*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if 
-		 * nodes have flipped from grounded to ungrounded: */
-		VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
-
-		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
-			if(elements_touching_iceshelf[element->Sid()]){
-				local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
-			}
-		}
-		
-		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-		_printf_(VerboseConvergence(),"   number of grounded vertices  connected to grounding line: %i\n",nflipped);
-
-		/*Avoid leaks: */
-		xfree((void**)&nodes_on_iceshelf);
-		xfree((void**)&elements_touching_iceshelf);
-
-		/*Assemble:*/
-		VecAssemblyBegin(vec_nodes_on_iceshelf);
-		VecAssemblyEnd(vec_nodes_on_iceshelf);
-	}
-
-	/*Serialize: */
-	VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
-
-	/*Free ressources:*/
-	VecFree(&vec_nodes_on_iceshelf);
-	xfree((void**)&elements_touching_iceshelf);
-
-	return nodes_on_iceshelf;
-}
-/*}}}*/
 /*FUNCTION CreateElementOnGroundingline {{{1*/
 bool*      CreateElementOnGroundingline(Elements* elements,double* element_on_iceshelf){ 
 
-	int      i,j;
-	Element *element       = NULL;
 	bool    *element_on_gl = NULL;
 	bool     ongl=false;
+	int      i,j,sid,shelf;
 	int     *neighboorsids = NULL;
-	int      sid;
-	int      shelf;
+	Element *element       = NULL;
 
 	/*Go through elements, and look for elements that can possibly have a grounding line migration. These 
@@ -140,8 +47,8 @@
 double*    CreateElementOnIceShelf(Elements* elements){ 
 
-	int i;
-	Element* element=NULL;
-	Vec vec_element_on_iceshelf=NULL;
-	double* element_on_iceshelf=NULL;
+	int      i;
+	double  *element_on_iceshelf     = NULL;
+	Element *element                 = NULL;
+	Vec      vec_element_on_iceshelf = NULL;
 
 	/*Create  vector holding  all the elements IsFloating flags: */
@@ -170,11 +77,9 @@
 double*    CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf){ 
 
-	int i;
-	Element* element=NULL;
-	Vec vec_element_touching_iceshelf=NULL;
-	double* nodes_on_iceshelf=NULL;
-	
-	/*output: */
-	double* element_touching_iceshelf=NULL;
+	int      i;
+	double  *nodes_on_iceshelf             = NULL;
+	double  *element_touching_iceshelf     = NULL;
+	Element *element                       = NULL;
+	Vec      vec_element_touching_iceshelf = NULL;
 
 	/*serialize: */
@@ -204,62 +109,10 @@
 }
 /*}}}*/
-/*FUNCTION UpdateShelfStatus {{{1*/
-int        UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){
-
-	int i;
-	Element* element=NULL;
-	int configuration_type;
-	int numnods;
-	Vec vec_new_shelf_nodes=NULL;
-	double* new_shelf_nodes=NULL;
-
-	/*output: */
-	int local_nflipped=0;
-	int nflipped=0;
-
-	/*recover parameters: */
-	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-
-	/*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */
-	numnods=nodes->NumberOfNodes(configuration_type);
-	vec_new_shelf_nodes=NewVec(numnods);
-
-	/*Ok, now go through  the elements that have gone through grounding line migration, 
-	 * and update their flags: */
-	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
-		if(element_touching_iceshelf[element->Sid()]){
-			local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes);
-		}
-	}
-	MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-
-	/*Serialize vec_new_shelf_nodes: */
-	VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes);
-
-	/*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */
-	/*Carry out grounding line migration for those elements: */
-	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
-		element->UpdateShelfFlags(new_shelf_nodes);
-	}
-
-	/*Free ressources: */
-	VecFree(&vec_new_shelf_nodes);
-	xfree((void**)&new_shelf_nodes);
-
-	return nflipped;
-}
-/*}}}*/
 /*FUNCTION CreateNodesOnIceShelf {{{1*/
 Vec CreateNodesOnIceShelf(Nodes* nodes,int configuration_type){ 
 
-	/*output: */
-	Vec     nodes_on_iceshelf=NULL;
-
-	/*intermediary: */
-	int     numnods;
-	int     i;
-	Node*   node=NULL;
+	int     i,numnods;
+	Vec     nodes_on_iceshelf = NULL;
+	Node*   node              = NULL;
 
 	/*First, initialize nodes_on_iceshelf, which will track which nodes have changed status: */
@@ -284,2 +137,136 @@
 }
 /*}}}*/
+/*FUNCTION PotentialSheetUngrounding {{{1*/
+double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){ 
+
+	int      i,numberofvertices;
+	double*  vertices_potentially_ungrounding      = NULL;
+	Vec      vec_vertices_potentially_ungrounding  = NULL;
+	Element* element                               = NULL;
+
+	/*Initialize vector with number of vertices*/
+	numberofvertices=vertices->NumberOfVertices();
+	vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
+
+	/*Fill vector vertices_potentially_floating: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
+	}
+
+	/*Assemble vector: */
+	VecAssemblyBegin(vec_vertices_potentially_ungrounding);
+	VecAssemblyEnd(vec_vertices_potentially_ungrounding);
+
+	/*Serialize vector: */
+	VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
+
+	/*free ressouces and return: */
+	VecFree(&vec_vertices_potentially_ungrounding);
+	return vertices_potentially_ungrounding;
+}
+/*}}}*/
+/*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/
+double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* vertices_potentially_ungrounding){ 
+
+	int      i,numnods,analysis_type;
+	int      nflipped,local_nflipped;
+	double*  nodes_on_iceshelf          = NULL;
+	double*  elements_touching_iceshelf = NULL;
+	Vec      vec_nodes_on_iceshelf      = NULL;
+	Element* element                    = NULL;
+
+	/*recover parameters: */
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+
+	/*recover vec_nodes_on_iceshelf: */
+	vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type);
+
+	nflipped=1; //bootstrap
+	while(nflipped){
+		
+		/*get a list of potential elements that have nodes on ice shelf: */
+		elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf);
+
+		/*now,  go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding, 
+		 * flag it: */
+		local_nflipped=0;
+
+		/*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if 
+		 * nodes have flipped from grounded to ungrounded: */
+		VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
+
+		for(i=0;i<elements->Size();i++){
+			element=(Element*)elements->GetObjectByOffset(i);
+			if(elements_touching_iceshelf[element->Sid()]){
+				local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
+			}
+		}
+		
+		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+		_printf_(VerboseConvergence(),"   number of grounded vertices  connected to grounding line: %i\n",nflipped);
+
+		/*Avoid leaks: */
+		xfree((void**)&nodes_on_iceshelf);
+		xfree((void**)&elements_touching_iceshelf);
+
+		/*Assemble:*/
+		VecAssemblyBegin(vec_nodes_on_iceshelf);
+		VecAssemblyEnd(vec_nodes_on_iceshelf);
+	}
+
+	/*Serialize: */
+	VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
+
+	/*Free ressources:*/
+	VecFree(&vec_nodes_on_iceshelf);
+	xfree((void**)&elements_touching_iceshelf);
+
+	return nodes_on_iceshelf;
+}
+/*}}}*/
+
+/*FUNCTION UpdateShelfStatus {{{1*/
+int UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){
+
+	int      i,numnods,configuration_type;
+	int      nflipped=0;
+	int      local_nflipped=0;
+	Vec      vec_new_shelf_nodes = NULL;
+	double*  new_shelf_nodes     = NULL;
+	Element* element             = NULL;
+
+	/*recover parameters: */
+	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+
+	/*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */
+	numnods=nodes->NumberOfNodes(configuration_type);
+	vec_new_shelf_nodes=NewVec(numnods);
+
+	/*Ok, now go through  the elements that have gone through grounding line migration, 
+	 * and update their flags: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		if(element_touching_iceshelf[element->Sid()]){
+			local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes);
+		}
+	}
+	MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+
+	/*Serialize vec_new_shelf_nodes: */
+	VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes);
+
+	/*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */
+	/*Carry out grounding line migration for those elements: */
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->UpdateShelfFlags(new_shelf_nodes);
+	}
+
+	/*Free ressources: */
+	VecFree(&vec_new_shelf_nodes);
+	xfree((void**)&new_shelf_nodes);
+
+	return nflipped;
+}
+/*}}}*/
