Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 22115)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 22116)
@@ -4601,7 +4601,5 @@
 	/*Intermediaries*/
 	int numberofelements				= this->elements->NumberOfElements();
-	int numberofvertices				= this->vertices->NumberOfVertices();
 	IssmDouble* error_elements		= NULL;
-	IssmDouble* error_vertices		= NULL;
 	IssmDouble *x						= NULL;
 	IssmDouble *y						= NULL;
@@ -4609,4 +4607,5 @@
 	int *index							= NULL;
 	IssmDouble maxerror,threshold,resolution;
+	int vid;
 	
 	switch(errorestimator_type){
@@ -4629,13 +4628,4 @@
 	this->GetMesh(this->vertices,this->elements,&x,&y,&z,&index);
 
-	/*Sum the estimators over the vertices*/
-	error_vertices=xNewZeroInit<IssmDouble>(numberofvertices);
-	for(int i=0;i<numberofelements;i++){
-		for(int j=0;j<this->GetElementsWidth();j++){
-			int vid=index[i*this->GetElementsWidth()+j]-1;//Matlab to C indexing
-			error_vertices[vid]+=error_elements[i];
-		}
-	}
-
 	/*Find the max of the estimators (use error_elements)*/
 	maxerror=error_elements[0];
@@ -4643,8 +4633,12 @@
 	
 	/*Fill hmaxvertices*/
-	for(int i=0;i<numberofvertices;i++){
-		if(error_vertices[i]>threshold*maxerror){
-			if(xIsNan<IssmDouble>(hmaxvertices[i])) hmaxvertices[i]=resolution;
-			else  hmaxvertices[i]=min(resolution,hmaxvertices[i]);
+	for(int i=0;i<numberofelements;i++){
+		if(error_elements[i]>threshold*maxerror){
+			/*ok, fill the hmaxvertices using the element vertices*/
+			for(int j=0;j<this->GetElementsWidth();j++){
+				vid=index[i*this->GetElementsWidth()+j]-1;//Matlab to C indexing
+				if(xIsNan<IssmDouble>(hmaxvertices[vid])) hmaxvertices[vid]=resolution;
+				else hmaxvertices[vid]=min(resolution,hmaxvertices[vid]);
+			}
 		}
 	}
@@ -4656,5 +4650,4 @@
 	xDelete<int>(index);
    xDelete<IssmDouble>(error_elements);
-   xDelete<IssmDouble>(error_vertices);
 }
 /*}}}*/
