Index: issm/trunk/src/c/Container/Parameters.cpp
===================================================================
--- issm/trunk/src/c/Container/Parameters.cpp	(revision 13395)
+++ issm/trunk/src/c/Container/Parameters.cpp	(revision 13975)
@@ -45,5 +45,5 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type) return true;
 	}
@@ -53,11 +53,11 @@
 /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{*/
 void Parameters::FindParam(bool* pbool,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pbool);
@@ -70,11 +70,11 @@
 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{*/
 void Parameters::FindParam(int* pinteger,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pinteger);
@@ -87,11 +87,11 @@
 /*FUNCTION Parameters::FindParam(IssmDouble* pscalar, int enum_type){{{*/
 void Parameters::FindParam(IssmDouble* pscalar, int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar);
@@ -110,5 +110,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar,time);
@@ -121,11 +121,11 @@
 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{*/
 void Parameters::FindParam(char** pstring,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstring);
@@ -139,11 +139,11 @@
 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{*/
 void Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstringarray,pM);
@@ -163,5 +163,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM);
@@ -181,5 +181,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM,pN);
@@ -199,5 +199,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM);
@@ -217,5 +217,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM,pN);
@@ -229,11 +229,11 @@
 /*FUNCTION Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{*/
 void Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
@@ -246,11 +246,11 @@
 /*FUNCTION Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){{{*/
 void Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pvec);
@@ -264,11 +264,11 @@
 /*FUNCTION Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){{{*/
 void Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){ _assert_(this);
-	
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pmat);
@@ -288,7 +288,25 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pfid);
+			return;
+		}
+	}
+	_error_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(DataSet** pdataset,int enum_type){{{*/
+void Parameters::FindParam(DataSet** pdataset,int enum_type){ 
+	_assert_(this);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
+		if(param->InstanceEnum()==enum_type){
+			param->GetParameterValue(pdataset);
 			return;
 		}
@@ -302,7 +320,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(boolean); //already exists, just set it.
@@ -314,7 +332,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(integer); //already exists, just set it.
@@ -326,7 +344,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(scalar); //already exists, just set it.
@@ -338,7 +356,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(string); //already exists, just set it.
@@ -350,7 +368,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(stringarray,M); //already exists, just set it.
@@ -362,7 +380,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
@@ -374,7 +392,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it.
@@ -388,5 +406,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M); //already exists, just set it.
@@ -400,5 +418,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M,N); //already exists, just set it.
@@ -410,7 +428,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(vector); //already exists, just set it.
@@ -422,7 +440,7 @@
 
 	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+
+	/*first, figure out if the param has already been created: */
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(matrix); //already exists, just set it.
@@ -436,5 +454,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(fid); //already exists, just set it.
@@ -449,5 +467,5 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		param->UnitConversion(direction_enum);
 	}
@@ -464,5 +482,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			return (*object);
