Index: /issm/trunk-jpl/src/c/modules/KillIcebergsx/KillIcebergsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/KillIcebergsx/KillIcebergsx.cpp	(revision 23996)
+++ /issm/trunk-jpl/src/c/modules/KillIcebergsx/KillIcebergsx.cpp	(revision 23997)
@@ -25,8 +25,9 @@
 	bool* element_flag = xNewZeroInit<bool>(femmodel->elements->Size());
 
-	/*Fill vector with 1 where it is grounded*/
+	/*Fill vector with 1 once for all*/
 	IssmDouble eflags[MAXVERTICES];
 	for(int i=0;i<MAXVERTICES;i++) eflags[i] = 1.;
 
+	/*Step 1, go through all elements and put 1 in vec_connected_to_land if the element is grounded*/
 	for(int i=0;i<femmodel->elements->Size();i++){
 		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
@@ -47,9 +48,11 @@
 	vec_connected_to_land->Assemble();
 
+	/*Now we have 2 loops, one across cpus, and one for each cpus: we are going to propagate the mask if an element
+	 * is connected to a positive mask already.
+	 * We then communicate to the other partitions. We stop when the mask stops changing*/
 	bool keepsyncing = true;
-
 	while(keepsyncing){
 
-		/*Need to place an outer loop here*/
+		/*Get local mask from parallel vector*/
 		if(local_mask) xDelete<IssmDouble>(local_mask);
 		femmodel->GetLocalVectorWithClonesVertices(&local_mask,vec_connected_to_land);
@@ -59,5 +62,5 @@
 		int  iter      = 1;
 		while(keepgoing){
-			_printf0_("Iteration "<<iter);
+			_printf0_("   -- Kill icebergs: iteration "<<iter);
 
 			keepgoing = 0;
@@ -116,6 +119,25 @@
 
 	/*OK, now deactivate iceberg and count the number of deactivated vertices*/
+	for(int i=0;i<femmodel->elements->Size();i++){
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
-	/*First, create a vector full of 0 and place 1 where the ice is grounded*/
-	_error_("Not implemented yet");
+		if(element->IsIceInElement()){
+			int  numvertices = element->GetNumberOfVertices();
+			element->GetVerticesLidList(&lidlist[0]);
+			bool deactivate = false;
+			for(int j=0;j<numvertices;j++){
+				if(local_mask[lidlist[j]]==0.){
+					deactivate = true;
+					break;
+				}
+			}
+
+			if(deactivate){
+				_error_("Don't know what to do....");
+			}
+		}
+	}
+
+	/*cleanup*/
+	xDelete<IssmDouble>(local_mask);
 }
