Index: /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4853)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4854)
@@ -27,5 +27,4 @@
 	char**  variabledescriptors=NULL;
 	char*   descriptor=NULL;
-	char*   tag=NULL;
 	double* dakota_parameter=NULL;
 
@@ -35,16 +34,17 @@
 	char* qmuoutname=NULL;
 	extern int my_rank;
-				
+	
+	//tags
+	char variabledescriptors_tag[30]; //strlen("variabledescriptor"+number)+1
+	char responsedescriptors_tag[30]; //strlen("responsedescriptors"+number)+1
+	char massflux_tag[35];            //strlen("qmu_mass_flux_segments"+number)+1
 	
 	/*parameters for mass flux: */
 	bool     qmu_mass_flux_present=false;
-	double* qmu_mass_flux_segments=NULL;
-	double* my_qmu_mass_flux_segments=NULL;
-	double* qmu_mass_flux_num_segments=NULL;
-	double* my_qmu_mass_flux_num_segments=NULL;
-	int tot_qmu_mass_flux_segments=0;
-	int my_tot_qmu_mass_flux_segments=0;
-	int tot_qmu_mass_flux_num_segments=0;
-	int my_tot_qmu_mass_flux_num_segments=0;
+	double** array=NULL;
+	double*  matrix=NULL;
+	int*     mdims_array=NULL;
+	int*     ndims_array=NULL;
+	int      M;
 
 	#ifdef _SERIAL_
@@ -90,8 +90,7 @@
 		}
 		#else
-		tag=(char*)xmalloc((strlen("variabledescriptori")+1)*sizeof(char));
-		for(i=0;i<iomodel->numberofvariables;i++){
-			sprintf(tag,"%s%i","variabledescriptor",i);
-			IoModelFetchData(&descriptor,iomodel_handle,tag);
+		for(i=0;i<iomodel->numberofvariables;i++){
+			sprintf(variabledescriptors_tag,"%s%i","variabledescriptor",i);
+			IoModelFetchData(&descriptor,iomodel_handle,variabledescriptors_tag);
 			variabledescriptors[i]=descriptor;
 		}
@@ -115,10 +114,7 @@
 		}
 		#else
-		xfree((void**)&tag);
-		tag=(char*)xmalloc((strlen("responsedescriptori")+1)*sizeof(char));
-
-		for(i=0;i<iomodel->numberofresponses;i++){
-			sprintf(tag,"%s%i","responsedescriptor",i);
-			IoModelFetchData(&descriptor,iomodel_handle,tag);
+		for(i=0;i<iomodel->numberofresponses;i++){
+			sprintf(responsedescriptors_tag,"%s%i","responsedescriptor",i);
+			IoModelFetchData(&descriptor,iomodel_handle,responsedescriptors_tag);
 			responsedescriptors[i]=descriptor;
 		}
@@ -186,4 +182,25 @@
 			 *responses. Let's build a DoubleMatArrayParam object with the array of segments: */
 			
+			if(iomodel->qmu_mass_flux_num_profiles==0)ISSMERROR(" qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
+			array=(double**)xmalloc(iomodel->qmu_mass_flux_num_profiles*sizeof(double*));
+			mdims_array=(int*)xmalloc(iomodel->qmu_mass_flux_num_profiles*sizeof(int));
+			ndims_array=(int*)xmalloc(iomodel->qmu_mass_flux_num_profiles*sizeof(int));
+			M=iomodel->qmu_mass_flux_num_profiles;
+
+			#ifdef _SERIAL_
+			pfield=mxGetField(iomodel_handle,0,"qmu_mass_flux_segments");
+			for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){
+				pfield2=mxGetCell(pfield,i);
+				FetchData(&matrix,mdims_array+i,ndims_array+i,pfield2);
+				array[i]=matrix;
+			}
+			#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");
@@ -234,5 +251,4 @@
 
 		/*Free data: {{{1*/
-		xfree((void**)&tag);
 		for(i=0;i<iomodel->numberofresponses;i++){
 			char* descriptor=responsedescriptors[i];
Index: /issm/trunk/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk/src/c/objects/IoModel.cpp	(revision 4853)
+++ /issm/trunk/src/c/objects/IoModel.cpp	(revision 4854)
@@ -216,4 +216,5 @@
 		IoModelFetchData(&this->numberofresponses,iomodel_handle,"numberofresponses");
 		IoModelFetchData(&this->qmu_npart,iomodel_handle,"npart");
+		IoModelFetchData(&this->qmu_mass_flux_num_profiles,iomodel_handle,"qmu_mass_flux_num_profiles");
 	}
 	
Index: /issm/trunk/src/c/objects/IoModel.h
===================================================================
--- /issm/trunk/src/c/objects/IoModel.h	(revision 4853)
+++ /issm/trunk/src/c/objects/IoModel.h	(revision 4854)
@@ -179,4 +179,7 @@
 		int      numoutput;
 
+		/*qmu: */
+		int      qmu_mass_flux_num_profiles;
+
 		/*exterior partitioning data, to be carried around: */
 		bool*   my_elements;
Index: /issm/trunk/src/m/qmu/qmumarshall.m
===================================================================
--- /issm/trunk/src/m/qmu/qmumarshall.m	(revision 4853)
+++ /issm/trunk/src/m/qmu/qmumarshall.m	(revision 4854)
@@ -88,5 +88,9 @@
 		WriteData(fid,md.qmu_mass_flux_segments{i},'Mat',['qmu_mass_flux_segments' num2str(i)]);
 	end
+else
+	md.qmu_mass_flux_num_profiles=0;
+	WriteData(fid,md.qmu_mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles');
 end
+
 
 %write part and npart to disk
