Index: /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 5216)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 5217)
@@ -27,4 +27,5 @@
 	char**  variabledescriptors=NULL;
 	char*   descriptor=NULL;
+	char*   root=NULL;
 	double* dakota_parameter=NULL;
 
@@ -52,4 +53,9 @@
 	int      count;
 
+	/*fetching of parameters: */
+	int    found=0;
+	char** strings=NULL;
+	char*  string=NULL;
+
 	#ifdef _SERIAL_
 		mxArray* pfield=NULL;
@@ -77,5 +83,5 @@
 		parameters->AddObject(new   StringParam(QmuErrNameEnum,qmuerrname));
 		/*}}}*/
-		
+
 		/*Deal with variable descriptors: {{{1*/
 		variabledescriptors=(char**)xmalloc(iomodel->numberofvariables*sizeof(char*));
@@ -95,5 +101,5 @@
 		#else
 		for(i=0;i<iomodel->numberofvariables;i++){
-			sprintf(variabledescriptors_tag,"%s%i","variabledescriptor",i);
+			sprintf(variabledescriptors_tag,"%s%i","variabledescriptor",i+1);
 			IoModelFetchData(&descriptor,iomodel_handle,variabledescriptors_tag);
 			variabledescriptors[i]=descriptor;
@@ -119,5 +125,5 @@
 		#else
 		for(i=0;i<iomodel->numberofresponses;i++){
-			sprintf(responsedescriptors_tag,"%s%i","responsedescriptor",i);
+			sprintf(responsedescriptors_tag,"%s%i","responsedescriptor",i+1);
 			IoModelFetchData(&descriptor,iomodel_handle,responsedescriptors_tag);
 			responsedescriptors[i]=descriptor;
@@ -127,5 +133,5 @@
 		/*Ok, we have all the response descriptors. Build a parameter with it: */
 		parameters->AddObject(new StringArrayParam(ResponseDescriptorsEnum,responsedescriptors,iomodel->numberofresponses));
-		/*}}}}*/
+		/*}}}*/
 
 		/*Deal with partitioning: {{{1*/
@@ -147,18 +153,51 @@
 
 		/*Deal with data needed because of qmu variable inputs: {{{1*/
-		for(i=0;i<iomodel->numberofvariables;i++){
-
+		
+		/*First, build a list of strings, used to make sure we don't deal with the same descriptor twice: */
+		if(iomodel->numberofvariables){
+			strings=(char**)xmalloc(iomodel->numberofvariables*sizeof(char*));
+			for(i=0;i<iomodel->numberofvariables;i++)strings[i]=NULL;
+		}
+					
+		/*Now, go through all our needed variables, and fetch the corresponding data: */
+		for(i=0;i<iomodel->numberofvariables;i++){
+
+			/*recover root of descriptor. Descriptors can come in 2 forms: Letters+Number or just letters (ex: Thickness1, RhoIce, Surface3). Strip the number
+			 * from the descriptor (root), so that we key off of this: */
 			descriptor=variabledescriptors[i];
-
-			if ((strcmp(descriptor,"Thickness")==0) || (strcmp(descriptor,"DragCoefficient")     ==0) || (strcmp(descriptor,"Surface")     ==0) || (strcmp(descriptor,"Bed")     ==0)
-
-
-				){
-
-				IoModelFetchData(&dakota_parameter,NULL,NULL,iomodel_handle,EnumToModelField(StringToEnum(descriptor)));
-				parameters->AddObject(new DoubleVecParam(StringToEnum(descriptor),dakota_parameter,iomodel->numberofvertices));
-				xfree((void**)&dakota_parameter);
-			}
-		}
+			if(isdistributed(&root,descriptor)){
+
+				//now, check that this root was not already processed, ie we did not already fetch the corresponding data! 
+				found=0;
+				for(j=0;j<iomodel->numberofvariables;j++){
+					if (strings[j]) if (strcmp(strings[j],root)==0)found=1;
+				}
+
+				/*If we did not, fetch data and add it to the parameters: */
+				if(!found){
+
+					/*Recover: */
+					printf("ok1 %s %s %s\n",descriptor,root,EnumToModelField(StringToEnum(root)));
+
+					IoModelFetchData(&dakota_parameter,NULL,NULL,iomodel_handle,EnumToModelField(StringToEnum(root)));
+					
+					/*Add to parameters: */
+					parameters->AddObject(new DoubleVecParam(StringToEnum(root),dakota_parameter,iomodel->numberofvertices));
+				
+					/*Free ressources:*/
+					xfree((void**)&dakota_parameter);
+
+					/*Ensure we won't process this variable anymore: */
+					string=(char*)xmalloc((strlen(root)+1)*sizeof(char)); strcpy(string,root); strings[i]=string;
+				}
+			}
+			xfree((void**)&root);
+		}
+		/*Free strings: not needed anymore */
+		for(i=0;i<iomodel->numberofvariables;i++){
+			string=strings[i];
+			xfree((void**)&string);
+		}
+		xfree((void**)&strings);
 		/*}}}*/
 
