Index: ../trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
===================================================================
--- ../trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp	(revision 18704)
+++ ../trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp	(revision 18705)
@@ -688,6 +688,7 @@
 				}
 			}
 		}
+		
 	}
 	if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
 	xDelete<IssmDouble>(epl_thickness);
@@ -730,7 +731,7 @@
 		}
 	}
 	else{
-		/*Do not do anything: at least one node is active for this element but this element is not solved for*/
+		/*Do not do anything: at least one node was active for this element but this element is not solved for*/
 	}
 	if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
 	xDelete<IssmDouble>(active);
Index: ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.h
===================================================================
--- ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.h	(revision 18704)
+++ ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.h	(revision 18705)
@@ -40,5 +40,6 @@
 		IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input);
 		IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input);
 		void ElementizeEplMask(FemModel* femmodel);
+		void ResetCounter(FemModel* femmodel);
 };
 #endif
Index: ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
===================================================================
--- ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18704)
+++ ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18705)
@@ -16,6 +16,7 @@
 	int         transfer_flag;
 	int         penalty_lock;
 	int         hydro_maxiter;
+	int         *elementactive_counter =NULL;
 	bool        isefficientlayer;
 	IssmDouble  sedimentlimit;
 	IssmDouble  penalty_factor;
@@ -55,12 +56,18 @@
 	parameters->AddObject(new IntParam(HydrologydcPenaltyLockEnum,penalty_lock));
 	parameters->AddObject(new IntParam(HydrologydcMaxIterEnum,hydro_maxiter));
 
+	if(isefficientlayer==1){
+		elementactive_counter=xNewZeroInit<int>(iomodel->numberofelements);
+		parameters->AddObject(new IntVecParam(ElementActiveCounterEnum,elementactive_counter,iomodel->numberofelements));
+	}
+	
 }/*}}}*/
 void HydrologyDCInefficientAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
 
 	bool   isefficientlayer;
+	bool   element_active;
 	int    hydrology_model;
-
+	
 	/*Fetch data needed: */
 	iomodel->Constant(&hydrology_model,HydrologyModelEnum);
 
@@ -92,7 +99,22 @@
 		iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum);
 	}
 
-	if(isefficientlayer)iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum);
+	if(isefficientlayer){
+		iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum);
+
+		for(int i=0;i<iomodel->numberofelements;i++){
+			Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
+			Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum); _assert_(node_mask_input);
+			
+			if(node_mask_input->Max()>0.) {
+				element_active = true;
+			}
+			else{
+				element_active = false;
+			}
+			element->AddInput(new BoolInput(HydrologydcMaskEplactiveEltEnum,element_active));
+		}
+	}
 }/*}}}*/
 void HydrologyDCInefficientAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
 
@@ -660,20 +682,46 @@
 void HydrologyDCInefficientAnalysis::ElementizeEplMask(FemModel* femmodel){/*{{{*/
 
 	bool     element_active;
+	bool     old_active;
+	int      penalty_lock;
+	int*     elementactive_counter = NULL;
 	Element* element=NULL;
 
 	for(int i=0;i<femmodel->elements->Size();i++){
 		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
-
-		int numvertices = element->GetNumberOfVertices();
-		Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum);
+		element->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
+		element->parameters->FindParam(&penalty_lock,HydrologydcPenaltyLockEnum);
+		
+		Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum); _assert_(node_mask_input);
+		Input* old_active_input = element->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(old_active_input);
+		old_active_input->GetInputValue(&old_active);
+		
 		if(node_mask_input->Max()>0.) {
 			element_active = true;
 		}
 		else{
 			element_active = false;
 		}
+		if(old_active!=element_active){
+			elementactive_counter[i]=elementactive_counter[i]+1;
+		}
+		if(elementactive_counter[i]>penalty_lock){
+			element_active = true;
+		}
+		//		femmodel->parameters->SetParam(elementactive_counter,ElementActiveCounterEnum);
 		element->AddInput(new BoolInput(HydrologydcMaskEplactiveEltEnum,element_active));
 	}
 }/*}}}*/
 
+void HydrologyDCInefficientAnalysis::ResetCounter(FemModel* femmodel){/*{{{*/
+
+	int*     elementactive_counter = NULL;
+	Element* element=NULL;
+	
+	for(int i=0;i<femmodel->elements->Size();i++){
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
+
+		elementactive_counter=0;
+	}
+}/*}}}*/
Index: ../trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- ../trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 18704)
+++ ../trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 18705)
@@ -108,6 +108,7 @@
 	EplHeadOldEnum,
 	EplHeadSlopeXEnum,
 	EplHeadSlopeYEnum,
+	ElementActiveCounterEnum,
 	HydrologydcMaxIterEnum,
 	HydrologydcRelTolEnum,
 	HydrologydcSpcsedimentHeadEnum,
Index: ../trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
===================================================================
--- ../trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 18704)
+++ ../trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 18705)
@@ -116,6 +116,7 @@
 		case EplHeadOldEnum : return "EplHeadOld";
 		case EplHeadSlopeXEnum : return "EplHeadSlopeX";
 		case EplHeadSlopeYEnum : return "EplHeadSlopeY";
+		case ElementActiveCounterEnum : return "ElementActiveCounter";
 		case HydrologydcMaxIterEnum : return "HydrologydcMaxIter";
 		case HydrologydcRelTolEnum : return "HydrologydcRelTol";
 		case HydrologydcSpcsedimentHeadEnum : return "HydrologydcSpcsedimentHead";
Index: ../trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
===================================================================
--- ../trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 18704)
+++ ../trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 18705)
@@ -116,6 +116,7 @@
 	      else if (strcmp(name,"EplHeadOld")==0) return EplHeadOldEnum;
 	      else if (strcmp(name,"EplHeadSlopeX")==0) return EplHeadSlopeXEnum;
 	      else if (strcmp(name,"EplHeadSlopeY")==0) return EplHeadSlopeYEnum;
+	      else if (strcmp(name,"ElementActiveCounter")==0) return ElementActiveCounterEnum;
 	      else if (strcmp(name,"HydrologydcMaxIter")==0) return HydrologydcMaxIterEnum;
 	      else if (strcmp(name,"HydrologydcRelTol")==0) return HydrologydcRelTolEnum;
 	      else if (strcmp(name,"HydrologydcSpcsedimentHead")==0) return HydrologydcSpcsedimentHeadEnum;
@@ -135,11 +136,11 @@
 	      else if (strcmp(name,"HydrologydcEplThickness")==0) return HydrologydcEplThicknessEnum;
 	      else if (strcmp(name,"HydrologydcEplThicknessOld")==0) return HydrologydcEplThicknessOldEnum;
 	      else if (strcmp(name,"HydrologydcEplConductivity")==0) return HydrologydcEplConductivityEnum;
-	      else if (strcmp(name,"HydrologydcIsefficientlayer")==0) return HydrologydcIsefficientlayerEnum;
          else stage=2;
    }
    if(stage==2){
-	      if (strcmp(name,"HydrologydcSedimentlimitFlag")==0) return HydrologydcSedimentlimitFlagEnum;
+	      if (strcmp(name,"HydrologydcIsefficientlayer")==0) return HydrologydcIsefficientlayerEnum;
+	      else if (strcmp(name,"HydrologydcSedimentlimitFlag")==0) return HydrologydcSedimentlimitFlagEnum;
 	      else if (strcmp(name,"HydrologydcSedimentlimit")==0) return HydrologydcSedimentlimitEnum;
 	      else if (strcmp(name,"HydrologydcTransferFlag")==0) return HydrologydcTransferFlagEnum;
 	      else if (strcmp(name,"HydrologydcLeakageFactor")==0) return HydrologydcLeakageFactorEnum;
@@ -258,11 +259,11 @@
 	      else if (strcmp(name,"MasstransportPenaltyFactor")==0) return MasstransportPenaltyFactorEnum;
 	      else if (strcmp(name,"MasstransportSpcthickness")==0) return MasstransportSpcthicknessEnum;
 	      else if (strcmp(name,"MasstransportCalvingrate")==0) return MasstransportCalvingrateEnum;
-	      else if (strcmp(name,"MasstransportStabilization")==0) return MasstransportStabilizationEnum;
          else stage=3;
    }
    if(stage==3){
-	      if (strcmp(name,"MasstransportVertexPairing")==0) return MasstransportVertexPairingEnum;
+	      if (strcmp(name,"MasstransportStabilization")==0) return MasstransportStabilizationEnum;
+	      else if (strcmp(name,"MasstransportVertexPairing")==0) return MasstransportVertexPairingEnum;
 	      else if (strcmp(name,"MasstransportNumRequestedOutputs")==0) return MasstransportNumRequestedOutputsEnum;
 	      else if (strcmp(name,"MasstransportRequestedOutputs")==0) return MasstransportRequestedOutputsEnum;
 	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
@@ -381,11 +382,11 @@
 	      else if (strcmp(name,"StressbalanceAnalysis")==0) return StressbalanceAnalysisEnum;
 	      else if (strcmp(name,"StressbalanceSIAAnalysis")==0) return StressbalanceSIAAnalysisEnum;
 	      else if (strcmp(name,"StressbalanceSolution")==0) return StressbalanceSolutionEnum;
-	      else if (strcmp(name,"StressbalanceVerticalAnalysis")==0) return StressbalanceVerticalAnalysisEnum;
          else stage=4;
    }
    if(stage==4){
-	      if (strcmp(name,"EnthalpyAnalysis")==0) return EnthalpyAnalysisEnum;
+	      if (strcmp(name,"StressbalanceVerticalAnalysis")==0) return StressbalanceVerticalAnalysisEnum;
+	      else if (strcmp(name,"EnthalpyAnalysis")==0) return EnthalpyAnalysisEnum;
 	      else if (strcmp(name,"FlaimAnalysis")==0) return FlaimAnalysisEnum;
 	      else if (strcmp(name,"FlaimSolution")==0) return FlaimSolutionEnum;
 	      else if (strcmp(name,"HydrologyShreveAnalysis")==0) return HydrologyShreveAnalysisEnum;
@@ -504,11 +505,11 @@
 	      else if (strcmp(name,"Closed")==0) return ClosedEnum;
 	      else if (strcmp(name,"Free")==0) return FreeEnum;
 	      else if (strcmp(name,"Open")==0) return OpenEnum;
-	      else if (strcmp(name,"Adjointp")==0) return AdjointpEnum;
          else stage=5;
    }
    if(stage==5){
-	      if (strcmp(name,"Adjointx")==0) return AdjointxEnum;
+	      if (strcmp(name,"Adjointp")==0) return AdjointpEnum;
+	      else if (strcmp(name,"Adjointx")==0) return AdjointxEnum;
 	      else if (strcmp(name,"Adjointy")==0) return AdjointyEnum;
 	      else if (strcmp(name,"Adjointz")==0) return AdjointzEnum;
 	      else if (strcmp(name,"BalancethicknessMisfit")==0) return BalancethicknessMisfitEnum;
@@ -627,11 +628,11 @@
 	      else if (strcmp(name,"BoolExternalResult")==0) return BoolExternalResultEnum;
 	      else if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum;
 	      else if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum;
-	      else if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum;
          else stage=6;
    }
    if(stage==6){
-	      if (strcmp(name,"J")==0) return JEnum;
+	      if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum;
+	      else if (strcmp(name,"J")==0) return JEnum;
 	      else if (strcmp(name,"StringExternalResult")==0) return StringExternalResultEnum;
 	      else if (strcmp(name,"Step")==0) return StepEnum;
 	      else if (strcmp(name,"Time")==0) return TimeEnum;
@@ -750,11 +751,11 @@
 	      else if (strcmp(name,"BasalforcingsRhoOcean")==0) return BasalforcingsRhoOceanEnum;
 	      else if (strcmp(name,"BasalforcingsOceanCoef")==0) return BasalforcingsOceanCoefEnum;
 	      else if (strcmp(name,"BasalforcingsOceanLinDragCoef")==0) return BasalforcingsOceanLinDragCoefEnum;
-	      else if (strcmp(name,"BasalforcingsOceanQuadDragCoef")==0) return BasalforcingsOceanQuadDragCoefEnum;
          else stage=7;
    }
    if(stage==7){
-	      if (strcmp(name,"BasalforcingsOceanTurningAngle")==0) return BasalforcingsOceanTurningAngleEnum;
+	      if (strcmp(name,"BasalforcingsOceanQuadDragCoef")==0) return BasalforcingsOceanQuadDragCoefEnum;
+	      else if (strcmp(name,"BasalforcingsOceanTurningAngle")==0) return BasalforcingsOceanTurningAngleEnum;
 	      else if (strcmp(name,"BasalforcingsOceanSsh")==0) return BasalforcingsOceanSshEnum;
 	      else if (strcmp(name,"BasalforcingsOceanVx")==0) return BasalforcingsOceanVxEnum;
 	      else if (strcmp(name,"BasalforcingsOceanVy")==0) return BasalforcingsOceanVyEnum;
Index: ../trunk-jpl/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp
===================================================================
--- ../trunk-jpl/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp	(revision 18704)
+++ ../trunk-jpl/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp	(revision 18705)
@@ -221,6 +221,7 @@
 					if(VerboseSolution()) _printf0_("eplconverged...\n");
 					InputUpdateFromConstantx(femmodel,eplconverged,ConvergedEnum);
 					InputUpdateFromSolutionx(femmodel,ug_epl);
+					inefanalysis->ResetCounter(femmodel);
 					break;
 				}
 			}
