Index: /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	(revision 4453)
+++ /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	(revision 4454)
@@ -8,17 +8,104 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../modules.h"
 
-void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables){
+void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,Vec vec_partition,double* variables,char* *variables_descriptors,int numvariables){
 
+	int     i,j,k;
+	int     dummy;
+	
 	int     verbose;
+	int     numberofvertices;
 	int     qmu_npart;
-	double* qmu_part=NULL;
-	int     dummy;
+	double *qmu_part_serial = NULL;
+	double *qmu_part  = NULL;
+
+	double* distributed_values=NULL;
+	double* parameter=NULL;
+	double* parameter_serial=NULL;
+	char*   descriptor=NULL;
+	char*   root=NULL; //root name of distributed variable, ex: thickness, drag, etc ...
+	double* partition=NULL; //serial version of vec_partition
 
 	/*retrieve parameters: */
 	parameters->FindParam(&verbose,VerboseEnum);
 	parameters->FindParam(&qmu_npart,QmuNPartEnum);
-	parameters->FindParam(&qmu_part,&dummy,QmuPartEnum);
+	parameters->FindParam(&qmu_part_serial,&dummy,QmuPartEnum);
+	numberofvertices=vertices->NumberOfVertices();
 
-	ISSMERROR(" not supported yet!");
+	/*serialize partition vector: */
+	VecToMPISerial(&partition,vec_partition);
+
+	/*Use partition vector to repartition qmu_part, which is ordered in a serial way: */
+	qmu_part=(double*)xmalloc(numberofvertices*sizeof(double));
+	for(k=0;k<numberofvertices;k++) qmu_part[(int)(partition[k])]=qmu_part_serial[k];
+	
+	/*Go through all dakota descriptors, ex: "rho_ice","thermal_conductivity","thickness1","thickness2", etc ..., and 
+	 * for each descriptor, take the variable value and plug it into the inputs: */
+
+	for(i=0;i<numvariables;i++){
+	
+		descriptor=variables_descriptors[i];
+
+		/*From descriptor, figure out if the variable is distributed (distributed implies there is a numeric value at the 
+		 * end of the descriptor, for ex: thickness1, thickness10, etc .... If it is distributed, the next qmu_npart (number 
+		 * of partitions in the distributed variable) variable are the values for each partition of the distributed variable: */
+		if (!isdistributed(&root,descriptor)){
+			
+			/*Ok, variable is not distributed, just update inputs using the variable: */
+			InputUpdateFromConstantx( elements,nodes, vertices,loads, materials,  parameters, variables[i],StringAsEnum(descriptor));
+
+		}
+		else{
+			
+			/*Ok, variable is distributed. Root name of variable is also known. Now, allocate distributed_values and fill the 
+			 * distributed_values with the next qmu_npart variables: */
+
+			distributed_values=(double*)xmalloc(qmu_npart*sizeof(double));
+			for(j=0;j<qmu_npart;j++){
+				distributed_values[j]=variables[i+j];
+			}
+
+			/*Now, pick up the parameter corresponding to root: */
+			parameters->FindParam(&parameter_serial,NULL,NULL,StringAsEnum(root));
+
+			/*repartition parameter: */
+			parameter=(double*)xmalloc(numberofvertices*sizeof(double));
+			for(k=0;k<numberofvertices;k++) parameter[(int)(partition[k])]=parameter_serial[k];
+
+			/*We've got the parameter, we need to update it using qmu_part (a partitioning vector), and the distributed_values: */
+			for(k=0;k<numberofvertices;k++){
+				parameter[k]=parameter[k]*distributed_values[(int)qmu_part[k]];
+			}
+
+			#ifdef _ISSM_DEBUG_
+				PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter vetor:");
+				PetscSynchronizedFlush(MPI_COMM_WORLD);
+				for(k=0;k<numberofvertices;k++){
+					PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,parameter[k]);
+					PetscSynchronizedFlush(MPI_COMM_WORLD);
+				}
+			#endif
+			  
+
+			/*Update inputs using the parameter vector: */
+			InputUpdateFromVectorx( elements,nodes, vertices,loads, materials,  parameters, parameter, StringAsEnum(root), VertexEnum);
+
+			/*increment i to skip the distributed values just collected: */
+			i+=qmu_npart-1; //careful, the for loop will add 1.
+
+			/*Free allocations: */
+			xfree((void**)&parameter);
+			xfree((void**)&parameter_serial);
+			xfree((void**)&distributed_values);
+
+		}
+		xfree((void**)&root);
+	}
+
+	/*Free ressources:*/
+	xfree((void**)&partition);
+	xfree((void**)&qmu_part);
+	xfree((void**)&qmu_part_serial);
+
 }
Index: /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h	(revision 4453)
+++ /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h	(revision 4454)
@@ -9,5 +9,5 @@
 #include "../../Container/Container.h"
 
-void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables);
+void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,Vec partition,double* variables,char* *variables_descriptors,int numvariables);
 
 #endif  /* _INPUTUPDATEFROMDAKOTAXX_H */
Index: /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp
===================================================================
--- /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp	(revision 4453)
+++ /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp	(revision 4454)
@@ -61,5 +61,5 @@
 
 	/*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
-	InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,variables,variables_descriptors,numvariables);
+	InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,femmodel->partition,variables,variables_descriptors,numvariables);
 
 	/*Run the core solution sequence: */
Index: /issm/trunk/src/m/solutions/SpawnCore.m
===================================================================
--- /issm/trunk/src/m/solutions/SpawnCore.m	(revision 4453)
+++ /issm/trunk/src/m/solutions/SpawnCore.m	(revision 4454)
@@ -14,5 +14,5 @@
 
 %first update the inputs to the femmodel using the variables provided to us by dakota.
-[femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,variables,variabledescriptors);
+[femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,femmodel.partition,variables,variabledescriptors);
 
 %now run the core solution
Index: /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 4453)
+++ /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 4454)
@@ -22,4 +22,5 @@
 	int         numvariables;
 	mxArray*    pfield=NULL;
+	Vec         partition=NULL;
 
 	/*Boot module: */
@@ -36,4 +37,5 @@
 	FetchData((DataSet**)&materials,MATERIALSIN);
 	FetchParams(&parameters,PARAMETERSIN);
+	FetchData(&partition,PARTITION);
 	
 	/*dakota input: */
@@ -51,5 +53,5 @@
 	
 	/*!Generate internal degree of freedom numbers: */
-	InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters,variables,variables_descriptors,numvariables);
+	InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters,partition,variables,variables_descriptors,numvariables);
 
 	/*write output datasets: */
@@ -64,4 +66,5 @@
 	delete materials;
 	delete parameters;
+	VecFree(&partition);
 	
 	xfree((void**)&variables);
Index: /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h	(revision 4453)
+++ /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h	(revision 4454)
@@ -24,6 +24,7 @@
 #define MATERIALSIN (mxArray*)prhs[4]
 #define PARAMETERSIN (mxArray*)prhs[5]
-#define VARIABLES (mxArray*)prhs[6]
-#define VARIABLESDESCRIPTORS (mxArray*)prhs[7]
+#define PARTITION (mxArray*)prhs[6]
+#define VARIABLES (mxArray*)prhs[7]
+#define VARIABLESDESCRIPTORS (mxArray*)prhs[8]
 
 /* serial output macros: */
@@ -35,5 +36,5 @@
 #define NLHS  2
 #undef NRHS
-#define NRHS  8
+#define NRHS  9
 
 #endif  /* _UPDATEINPUTSFROMDAKOTA_H */
