Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 23485)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 23486)
@@ -99,5 +99,6 @@
 		/*Verifications. AMR supports SSA, P1 and horizontal 2D domain*/
 		bool isSSA;
-		int domaintype,element_type,analysis_counter=-1;
+		int domaintype,element_type;
+		this->analysis_counter=-1;
 		this->parameters->FindParam(&isSSA,FlowequationIsSSAEnum);
 		this->parameters->FindParam(&domaintype,DomainTypeEnum);
@@ -207,14 +208,17 @@
 int FemModel::AnalysisIndex(int analysis_enum){/*{{{*/
 
-	int found=-1;
+	/*Checks in debugging mode*/
 	_assert_(this->analysis_type_list); 
+
+	/*Find analysis in list*/
 	for(int i=0;i<this->nummodels;i++){
 		if(this->analysis_type_list[i]==analysis_enum){
-			found=i;
+			return i;
 			break;
 		}
 	}
-	if(found!=-1) return found;
-	else _error_("Could not find index of analysis " << EnumToStringx(analysis_enum) << " in list of FemModel analyses");
+
+	/*If you reach this point, analysis has not been found*/
+	_error_("Could not find index of analysis " << EnumToStringx(analysis_enum) << " in list of FemModel analyses");
 
 
@@ -409,5 +413,5 @@
 	/*Initialize internal data: */
 	this->solution_type    = in_solution_type;
-	this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
+	this->analysis_counter = -1;
 	this->results          = new Results(); //not initialized by CreateDataSets
 
@@ -582,13 +586,9 @@
 	 * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
 	 * Slope configuration.*/
-	int found=-1;
-	for(int i=0;i<nummodels;i++){
-		if (analysis_type_list[i]==configuration_type){
-			found=i;
-			break;
-		}
-	}
-	if(found!=-1) this->analysis_counter=found;
-	else _error_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
+	int index = AnalysisIndex(configuration_type);
+
+	/*If we already have the right analysis, return*/
+	if(this->analysis_counter==index) return;
+	this->analysis_counter=index;
 
 	/*Now, plug analysis_counter and analysis_type inside the parameters: */
