Index: /issm/trunk/src/c/Container/Parameters.cpp
===================================================================
--- /issm/trunk/src/c/Container/Parameters.cpp	(revision 4854)
+++ /issm/trunk/src/c/Container/Parameters.cpp	(revision 4855)
@@ -229,4 +229,30 @@
 }
 /*}}}*/
+/*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/
+int   Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){
+	
+	/*Go through a dataset, and find a Param* object 
+	 *which parameter name is "name" : */
+	
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	int found=0;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		/*Ok, this object is a parameter, recover it and ask which name it has: */
+		param=(Param*)(*object);
+
+		if(param->EnumType()==enum_type){
+			/*Ok, this is the one! Recover the value of this parameter: */
+			param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
+			found=1;
+			break;
+		}
+	}
+	return found;
+}
+/*}}}*/
 /*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/
 int   Parameters::FindParam(Vec* pvec,int enum_type){
Index: /issm/trunk/src/c/Container/Parameters.h
===================================================================
--- /issm/trunk/src/c/Container/Parameters.h	(revision 4854)
+++ /issm/trunk/src/c/Container/Parameters.h	(revision 4855)
@@ -33,4 +33,5 @@
 		int   FindParam(double** pdoublearray,int* pM,int enum_type);
 		int   FindParam(double** pdoublearray,int* pM,int* pN,int enum_type);
+		int   FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
 		int   FindParam(Vec* pvec,int enum_type);
 		int   FindParam(Mat* pmat,int enum_type);
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4854)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4855)
@@ -334,5 +334,4 @@
 	QmuErrNameEnum,
 	QmuInNameEnum,
-	QmuMassFluxNumSegmentsEnum,
 	QmuMassFluxSegmentsEnum,
 	QmuNPartEnum,
Index: /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 4854)
+++ /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 4855)
@@ -20,6 +20,7 @@
 void DakotaResponsesx(double* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char** responses_descriptors,int numresponses){
 
-	int        i;
+	int        i,j;
 	int        dummy;
+	int        counter;
 	extern int my_rank;
 
@@ -71,12 +72,24 @@
 		}
 		else if(strlen(response_descriptor)>=8){
-
 			if(strncmp(response_descriptor,"MassFlux",8)==0){
 
-				double*   segments=NULL;
-				int       num_segments;
+				/*Deal with several mass flux computations: {{{1*/
+				double** array=NULL;
+				int      M;
+				int*     mdims_array=NULL;
+				int*     ndims_array=NULL;
+
+				double*  segments=NULL;
+				int      num_segments;
 
 				/*retrieve qmu_mass_flux_segments: */
-				parameters->FindParam(&segments,&num_segments,&dummy,QmuMassFluxSegmentsEnum);
+				parameters->FindParam(&array,&M,&mdims_array,&ndims_array,QmuMassFluxSegmentsEnum);
+
+				/*figure out counter after MassFlux: */
+				sscanf(response_descriptor,"MassFlux%i",&counter);
+
+				/*retrieve segments from array: */
+				segments=array[counter-1]; //matlab to "C" indexing
+				num_segments=mdims_array[counter-1];
 
 				/*call mass flux module: */
@@ -84,7 +97,13 @@
 
 				/*Free ressources:*/
-				xfree((void**)&segments);
+				for(j=0;j<M;j++){
+					double* matrix=array[i];
+					xfree((void**)&matrix);
+				}
+				xfree((void**)&mdims_array);
+				xfree((void**)&ndims_array);
+				xfree((void**)&array);
+				/*}}}*/
 			}
-
 		}
 		else{
Index: /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4854)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4855)
@@ -44,7 +44,9 @@
 	double** array=NULL;
 	double*  matrix=NULL;
+	double*  temp_matrix=NULL;
 	int*     mdims_array=NULL;
 	int*     ndims_array=NULL;
 	int      M;
+	int      temp_m,temp_n;
 
 	#ifdef _SERIAL_
@@ -190,5 +192,5 @@
 			#ifdef _SERIAL_
 			pfield=mxGetField(iomodel_handle,0,"qmu_mass_flux_segments");
-			for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){
+			for(i=0;i<M;i++){
 				pfield2=mxGetCell(pfield,i);
 				FetchData(&matrix,mdims_array+i,ndims_array+i,pfield2);
@@ -196,55 +198,46 @@
 			}
 			#else
-			for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){
-				sprintf(massflux_tag,"%s%i","qmu_mass_flux_segmentsi",i);
-				IoModelFetchData(&tot_matrix,tot_mdims_array+i,NULL,iomodel_handle,"qmu_mass_flux_segments");
-				variabledescriptors[i]=descriptor;
-			}
-			#endif
-
-			#ifdef _PARALLEL_
-			IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments");
-			IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments");
-
-
-			/*Only if partitioning exist do we care about the segments: */
-			if(iomodel->my_elements){
-
-				/*Use the element partitioning vector from the iomodel to down select qmu_mass_flux_segments to only segments that are relevant 
-				 * to this cpu: */
-				my_tot_qmu_mass_flux_segments=0;
-				for(j=0;j<tot_qmu_mass_flux_segments;j++){
-					if (  iomodel->my_elements[(int)(*(qmu_mass_flux_segments+5*j+4))-1])my_tot_qmu_mass_flux_segments++;
+			for(i=0;i<M;i++){
+				sprintf(massflux_tag,"%s%i","qmu_mass_flux_segments",i);
+				IoModelFetchData(&temp_matrix,&temp_m,&temp_n,iomodel_handle,massflux_tag);
+
+				/*This temp_matrix represents all the segments, for all elements. On this cpu, we only have a subset of these 
+				 * elements. Extract matrix, out of temp_matrix, corresponding to only our elements: */
+				m=0;
+				for(j=0;j<temp_m;j++){
+					if (  iomodel->my_elements[(int)(*(temp_matrix+5*j+4))-1])m++;
 				}
-
-
-				if(my_tot_qmu_mass_flux_segments){
-					my_qmu_mass_flux_segments=(double*)xcalloc(5*my_tot_qmu_mass_flux_segments,sizeof(double));
-					second_count=0;
-					for(j=0;j<tot_qmu_mass_flux_segments;j++){
-						if (iomodel->my_elements[(int)*(qmu_mass_flux_segments+5*j+4)-1]){
-							for(k=0;k<5;k++)*(my_qmu_mass_flux_segments+5*second_count+k)=*(qmu_mass_flux_segments+5*j+k);
-							second_count++;
+				if(m){
+					matrix=(double*)xcalloc(5*m,sizeof(double));
+					count=0;
+					for(j=0;j<temp_m;j++){
+						if (iomodel->my_elements[(int)*(temp_matrix+5*j+4)-1]){
+							for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
+							count++;
 						}
 					}
 				}
 
-				parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,my_qmu_mass_flux_segments,my_tot_qmu_mass_flux_segments,5));
-
-			}
-					
-			#else
-			IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments");
-			IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments");
-
-			parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,qmu_mass_flux_segments,tot_qmu_mass_flux_segments,5));
-			parameters->AddObject(new DoubleVecParam(QmuMassFluxNumSegmentsEnum,qmu_mass_flux_num_segments,tot_qmu_mass_flux_num_segments));
-
+				/*Assign: */
+				array[i]=matrix;
+				mdims_array[i]=m;
+				ndims_array[i]=5;
+
+				/*Free data: */
+				xfree((void**)&temp_matrix);
+			}
 			#endif
 
-			xfree((void**)&qmu_mass_flux_segments);
-			xfree((void**)&my_qmu_mass_flux_segments);
-			xfree((void**)&qmu_mass_flux_num_segments);
-			xfree((void**)&my_qmu_mass_flux_num_segments);
+			/*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
+			parameters->AddObject(new DoubleMatArrayParam(QmuMassFluxSegmentsEnum,array,M,mdims_array,ndims_array));
+
+			/*Free data: */
+			for(i=0;i<M;i++){
+				double* matrix=array[i];
+				xfree((void**)&matrix);
+			}
+			xfree((void**)&mdims_array); 
+			xfree((void**)&ndims_array);
+			xfree((void**)&array);
 		}
 		/*}}}*/
