Index: /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 22520)
+++ /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 22521)
@@ -31,22 +31,10 @@
 int  Inputs::AddInput(Input* in_input){/*{{{*/
 
-	/*First, go through dataset of inputs and check whether any input 
-	 * with the same name is already in. If so, erase the corresponding 
-	 * object before adding this new one: */
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	/*In debugging mode, check that the input is not a NULL pointer*/
-	_assert_(in_input);
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==in_input->InstanceEnum()){
-			this->DeleteObject(input);
-			break;
-		}
-	}
+	_assert_(in_input); 
+
+	/*Delete input if it already exists*/
+	this->DeleteInput(in_input->InstanceEnum());
+
+	/*Now add new input to the dataset*/
 	this->AddObject(in_input);
 
@@ -56,31 +44,11 @@
 void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
 
-	/*Go through dataset of inputs and look for input with 
-	 * same enum as input enum, once found, just change its name */
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	/*Delete existing input of newenumtype if it exists*/
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==newenumtype){
-			this->DeleteObject(input);
-			break;
-		}
-	}
-
-	/*Change enum_type of input of oldenumtype*/
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==oldenumtype){
-			input->ChangeEnum(newenumtype);
-			break;
-		}
-	}
-}
-/*}}}*/
+	/*Delete input if it already exists*/
+	this->DeleteInput(newenumtype);
+
+	/*Now get old input and change its enum (do not error out if not found)*/
+	Input* input=this->GetInput(oldenumtype);
+	if(input) input->ChangeEnum(newenumtype);
+}/*}}}*/
 void Inputs::Configure(Parameters* parameters){/*{{{*/
 
@@ -99,17 +67,6 @@
 int  Inputs::DeleteInput(int enum_type){/*{{{*/
 
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==enum_type){
-			this->DeleteObject(input);
-			break;
-		}
-	}
-
+	Input* input=this->GetInput(enum_type);
+	if(input) this->DeleteObject(input);
 	return 1;
 
@@ -119,5 +76,5 @@
 
 	/*Make a copy of the original input: */
-	Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
+	Input* original=this->GetInput(original_enum);
 	if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 
 	Input* copy=xDynamicCast<Input*>(original->copy());
@@ -136,11 +93,8 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
 		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==enum_name){
-			return input;
-		}
-	}
+		if (input->InstanceEnum()==enum_name) return input;
+	}
+
 	return NULL;
 }
@@ -148,23 +102,7 @@
 void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/
 
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-	bool   found=false;
-
-	/*Go through inputs and check whether any input with the same name is already in: */
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-		if (input->InstanceEnum()==enum_type){
-			found=true;
-			break;
-		}
-	}
-
-	if (!found){
-		/*we could not find an input with the correct enum type. No defaults values were provided, 
-		 * error out: */
-		_error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
-	}
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enum_type);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
@@ -175,23 +113,7 @@
 void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/
 
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-	bool   found=false;
-
-	/*Go through inputs and check whether any input with the same name is already in: */
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-		if (input->InstanceEnum()==enum_type){
-			found=true;
-			break;
-		}
-	}
-
-	if (!found){
-		/*we could not find an input with the correct enum type. No defaults values were provided, 
-		 * error out: */
-		_error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
-	}
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enum_type);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
@@ -202,136 +124,62 @@
 void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/
 
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-	bool   found=false;
-
-	/*Go through inputs and check whether any input with the same name is already in: */
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-		if (input->InstanceEnum()==enum_type){
-			found=true;
-			break;
-		}
-	}
-
-	if (!found){
-		/*we could not find an input with the correct enum type. No defaults values were provided, 
-		 * error out: */
-		_error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
-	}
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enum_type);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
 	input->GetInputValue(pvalue);
 
-}
-/*}}}*/
+}/*}}}*/
 void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/
 
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-	bool   found=false;
-
-	/*Go through inputs and check whether any input with the same name is already in: */
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object); 
-		if (input->InstanceEnum()==enum_type){
-			found=true;
-			break;
-		}
-	}
-
-	if (!found){
-		/*we could not find an input with the correct enum type. No defaults values were provided, 
-		 * error out: */
-		_error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
-	}
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enum_type);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
 	input->GetInputValue(pvalue);
 
-}
-/*}}}*/
+}/*}}}*/
 IssmDouble Inputs::Max(int enumtype){/*{{{*/
 
-	/*Output*/
-	IssmDouble max;
-
-	/*Get input*/
-	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
-
-	/*Apply ContrainMin: */
-	if (input){
-		max=input->Max();
-	}
-	else{
-		_error_("Input " << EnumToStringx(enumtype) << " not found");
-	}
-
-	/*Return output*/
-	return max;
-}
-/*}}}*/
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enumtype);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
+
+	/*Return output*/
+	return input->Max();
+
+}/*}}}*/
 IssmDouble Inputs::MaxAbs(int enumtype){/*{{{*/
 
-	/*Output*/
-	IssmDouble max;
-
-	/*Get input*/
-	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
-
-	/*Apply ContrainMin: */
-	if (input){
-		max=input->MaxAbs();
-	}
-	else{
-		_error_("Input " << EnumToStringx(enumtype) << " not found");
-	}
-
-	/*Return output*/
-	return max;
-}
-/*}}}*/
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enumtype);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
+
+	/*Return output*/
+	return input->MaxAbs();
+
+}/*}}}*/
 IssmDouble Inputs::Min(int enumtype){/*{{{*/
 
-	/*Output*/
-	IssmDouble min;
-
-	/*Get input*/
-	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
-
-	/*Apply ContrainMin: */
-	if (input){
-		min=input->Min();
-	}
-	else{
-		_error_("Input " << EnumToStringx(enumtype) << " not found");
-	}
-
-	/*Return output*/
-	return min;
-}
-/*}}}*/
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enumtype);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
+
+	/*Return output*/
+	return input->Min();
+
+}/*}}}*/
 IssmDouble Inputs::MinAbs(int enumtype){/*{{{*/
 
-	/*Output*/
-	IssmDouble min;
-
-	/*Get input*/
-	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
-
-	/*Apply ContrainMin: */
-	if (input){
-		min=input->MinAbs();
-	}
-	else{
-		_error_("Input " << EnumToStringx(enumtype) << " not found");
-	}
-
-	/*Return output*/
-	return min;
-}
-/*}}}*/
+	/*Find input in current dataset*/
+	Input* input=this->GetInput(enumtype);
+	if (!input) _error_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
+
+	/*Return output*/
+	return input->MinAbs();
+
+}/*}}}*/
 Inputs* Inputs::SpawnSegInputs(int index1,int index2){/*{{{*/
 
