Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4851)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4852)
@@ -135,4 +135,5 @@
 	BoolParamEnum,
 	DoubleMatParamEnum,
+	DoubleMatArrayParamEnum,
 	DoubleParamEnum,
 	DoubleVecParamEnum,
Index: /issm/trunk/src/c/io/FetchParams.cpp
===================================================================
--- /issm/trunk/src/c/io/FetchParams.cpp	(revision 4851)
+++ /issm/trunk/src/c/io/FetchParams.cpp	(revision 4852)
@@ -32,4 +32,7 @@
 	double* matrix=NULL;
 	char**  stringarray=NULL;
+	double** array=NULL;
+	int*     mdims_array=NULL;
+	int*     ndims_array=NULL;
 	int nfields;
 	char* name=NULL;
@@ -113,25 +116,62 @@
 		}
 		else if (mxIsCell(pfield)){
-			/*string array: */
-			M=mxGetM(pfield);
-			stringarray=(char**)xmalloc(M*sizeof(char*));
 
-			for(i=0;i<M;i++){
-				char* descriptor=NULL;
-				pfield2=mxGetCell(pfield,i);
-				FetchData(&descriptor,pfield2);
-				stringarray[i]=descriptor;
+			/*This can be a string array, or a matrix array. Check the first 
+			 *element type to decide: */
+			pfield2=mxGetCell(pfield,0);
+			if (mxIsChar(pfield2)){
+				
+				/*string array: */
+				M=mxGetM(pfield);
+				stringarray=(char**)xmalloc(M*sizeof(char*));
+
+				for(i=0;i<M;i++){
+					char* descriptor=NULL;
+					pfield2=mxGetCell(pfield,i);
+					FetchData(&descriptor,pfield2);
+					stringarray[i]=descriptor;
+				}
+
+				param= new StringArrayParam(enum_type,stringarray,M);
+				parameters->AddObject(param);
+
+				/*Free ressources:*/
+				for(i=0;i<M;i++){
+					char* descriptor=stringarray[i];
+					xfree((void**)&descriptor);
+				}
+				xfree((void**)&stringarray);
+
 			}
-		
-			param= new StringArrayParam(enum_type,stringarray,M);
-			parameters->AddObject(param);
+			else{
+				
+				/*matrix array: */
+				M=mxGetM(pfield);
+				array=(double**)xmalloc(M*sizeof(double*));
+				mdims_array=(int*)xmalloc(M*sizeof(int));
+				ndims_array=(int*)xmalloc(M*sizeof(int));
 
-			/*Free ressources:*/
-			for(i=0;i<M;i++){
-				char* descriptor=stringarray[i];
-				xfree((void**)&descriptor);
+				for(i=0;i<M;i++){
+					double* matrix=NULL;
+					int     m,n;
+					pfield2=mxGetCell(pfield,i);
+					FetchData(&matrix,&m,&n,pfield2);
+					array[i]=matrix;
+					mdims_array[i]=m;
+					ndims_array[i]=n;
+				}
+
+				param= new DoubleMatArrayParam(enum_type,array,M,mdims_array,ndims_array);
+				parameters->AddObject(param);
+
+				/*Free ressources:*/
+				for(i=0;i<M;i++){
+					double* matrix=array[i];
+					xfree((void**)&matrix);
+				}
+				xfree((void**)&array);
+				xfree((void**)&mdims_array);
+				xfree((void**)&ndims_array);
 			}
-			xfree((void**)&stringarray);
-
 		}
 		else ISSMERROR("%s%i","unknow type in parameters structure field ",i);
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	(revision 4851)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	(revision 4852)
@@ -24,5 +24,5 @@
 	/*edge 1: */
 	xel[0]=xgrids[0];  yel[0]=ygrids[0]; xel[1]=xgrids[1];  yel[1]=ygrids[1];
-	edge1=SegmentIntersect(&alpha1,&alpha2, xel,yel,xsegment,ysegment);
+	edge1=SegmentIntersect(&alpha1,&alpha2, xel,yel,xsegment,ysegment); //alpha1: segment coordinate of intersection. alpha2: same thing for second interesection if it exists (colinear edges)
 
 	/*edge 2: */
@@ -33,4 +33,6 @@
 	xel[0]=xgrids[2];  yel[0]=ygrids[2]; xel[1]=xgrids[0];  yel[1]=ygrids[0];
 	edge3=SegmentIntersect(&gamma1,&gamma2, xel,yel,xsegment,ysegment);
+
+	/*edge can be either IntersectEnum (one iand only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */
 
 	if(    (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum)   ){
@@ -54,4 +56,7 @@
 
 			segments_dataset->AddObject(new  Segment(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));
+		}
+		else{
+			/*the segment intersected at the vertex, do not bother with this "0" length segment!:*/
 		}
 	}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4851)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 4852)
@@ -14,5 +14,6 @@
 
 void CreateParametersQmu(Parameters** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle,int analysis_type){
-	
+
+	/*variable declarations: {{{1*/
 	int i,j,k;
 	
@@ -37,4 +38,5 @@
 	
 	/*parameters for mass flux: */
+	bool     qmu_mass_flux_present=false;
 	double* qmu_mass_flux_segments=NULL;
 	double* my_qmu_mass_flux_segments=NULL;
@@ -50,4 +52,5 @@
 		mxArray* pfield2=NULL;
 	#endif
+	/*}}}*/
 	
 	/*recover parameters : */
@@ -57,5 +60,5 @@
 	if(iomodel->qmu_analysis){
 
-		//name of qmu input, error and output files
+		/*name of qmu input, error and output files:{{{1*/
 		qmuinname=(char*)xmalloc((strlen(iomodel->name)+strlen(".qmu.in")+1)*sizeof(char));
 		sprintf(qmuinname,"%s%s",iomodel->name,".qmu.in");
@@ -69,8 +72,7 @@
 		sprintf(qmuerrname,"%s%s",iomodel->name,".qmu.err");
 		parameters->AddObject(new   StringParam(QmuErrNameEnum,qmuerrname));
-		
-		parameters->AddObject(new    IntParam(QmuNPartEnum,iomodel->qmu_npart));
-
-		/*Deal with variables for qmu iomodeling: */
+		/*}}}*/
+		
+		/*Deal with variable descriptors: {{{1*/
 		variabledescriptors=(char**)xmalloc(iomodel->numberofvariables*sizeof(char*));
 
@@ -99,5 +101,7 @@
 		parameters->AddObject(new StringArrayParam(VariableDescriptorsEnum,variabledescriptors,iomodel->numberofvariables));
 
-		/*Deal with responses and partition for qmu iomodeling: */
+		/*}}}*/
+
+		/*Deal with responses: {{{1*/
 		responsedescriptors=(char**)xmalloc(iomodel->numberofresponses*sizeof(char*));
 
@@ -123,6 +127,10 @@
 		/*Ok, we have all the response descriptors. Build a parameter with it: */
 		parameters->AddObject(new StringArrayParam(ResponseDescriptorsEnum,responsedescriptors,iomodel->numberofresponses));
-
+		/*}}}}*/
+
+		/*Deal with partitioning: {{{1*/
 		/*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */
+		parameters->AddObject(new    IntParam(QmuNPartEnum,iomodel->qmu_npart));
+		
 		IoModelFetchData(&dpart,NULL,NULL,iomodel_handle,"part");
 
@@ -136,6 +144,7 @@
 		}
 		parameters->AddObject(new DoubleVecParam(QmuPartEnum,dpart,iomodel->numberofvertices));
-
-		/*Ok, now if any of the variables input from Dakota are distributed, we are going to need the parameters: */
+		/*}}}*/
+
+		/*Deal with data needed because of qmu variable inputs: {{{1*/
 		for(i=0;i<iomodel->numberofvariables;i++){
 
@@ -151,54 +160,14 @@
 			}
 		}
-
-		/*Deal with data needed for some responses: */
+		/*}}}*/
+
+		/*Deal with data needed to compute qmu responses: {{{1*/
 		for(i=0;i<iomodel->numberofresponses;i++){
 			char* descriptor=responsedescriptors[i];
-			if (strcmp(descriptor,"mass_flux")==0){
-
-				/*We need the qmu_mass_flux_segments to be able to compute the mass flux: */
-				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");
-
-				#ifdef _PARALLEL_
-
-					/*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++;
-						}
-
-					
-						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++;
-								}
-							}
-						}
-
-						parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,my_qmu_mass_flux_segments,my_tot_qmu_mass_flux_segments,5));
-
-					}
-					
-				#else
-
-					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));
-
-				#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);
-			}
+			
+			if(strncmp(response_descriptor,"MassFlux",8)==0){
+				qmu_mass_flux_present=true;
+			}
+
 			if (strcmp(descriptor,"misfit")==0){
 
@@ -210,6 +179,59 @@
 			}
 		}
-
-		/*Free data: */
+		
+		
+		if(qmu_mass_flux_present){
+			
+			/*We need the segments to be able to compute the mass flux. We have as many groups of segments as we have MassFlux 
+			 *responses. Let's build a DoubleMatArrayParam object with the array of segments: */
+			
+			#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++;
+				}
+
+
+				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++;
+						}
+					}
+				}
+
+				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));
+
+			#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);
+		}
+		/*}}}*/
+
+		/*Free data: {{{1*/
 		xfree((void**)&tag);
 		for(i=0;i<iomodel->numberofresponses;i++){
@@ -232,5 +254,6 @@
 		xfree((void**)&qmuerrname);
 		xfree((void**)&qmuoutname);
-	}
+		/*}}}*/
+	} //if(iomodel->qmu_analysis)
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/objects/Params/BoolParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 4852)
@@ -60,4 +60,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("Bool param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -72,4 +73,6 @@
 		void  SetValue(Vec vec){ISSMERROR("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Bool param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
+
 		
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 4852)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 4852)
@@ -0,0 +1,348 @@
+/*!\file DoubleMatArrayParam.c
+ * \brief: implementation of the DoubleMatArrayParam object
+ */
+
+/*header files: */
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+/*}}}*/
+
+/*DoubleMatArrayParam constructors and destructor*/
+/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(){{{1*/
+DoubleMatArrayParam::DoubleMatArrayParam(){
+	return;
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array){{{1*/
+DoubleMatArrayParam::DoubleMatArrayParam(int in_enum_type,double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
+
+	int i;
+	double* matrix=NULL;
+	int     m,n;
+
+	enum_type=in_enum_type;
+	M=in_M;
+	array=(double**)xmalloc(M*sizeof(double*));
+	mdim_array=(int*)xmalloc(M*sizeof(int));
+	ndim_array=(int*)xmalloc(M*sizeof(int));
+
+	for(i=0;i<M;i++){
+		m=in_mdim_array[i]; 
+		n=in_mdim_array[i];
+
+		mdim_array[i]=m;
+		ndim_array[i]=n;
+
+		matrix=(double*)xmalloc(m*n*sizeof(double));
+		memcpy(matrix,in_array[i],m*n*sizeof(double));
+
+		array[i]=matrix;
+	}
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::~DoubleMatArrayParam(){{{1*/
+DoubleMatArrayParam::~DoubleMatArrayParam(){
+
+	int i;
+	double* matrix=NULL;
+
+	xfree((void**)&mdim_array);
+	xfree((void**)&ndim_array);
+
+	for(i=0;i<M;i++){
+		matrix=array[i];
+		xfree((void**)&matrix);
+	}
+	
+	xfree((void**)&array);
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION DoubleMatArrayParam::Echo {{{1*/
+void DoubleMatArrayParam::Echo(void){
+
+	printf("DoubleMatArrayParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   array size: %i\n",this->M);
+	printf("   array pointer: %p\n",this->array);
+
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::DeepEcho{{{1*/
+void DoubleMatArrayParam::DeepEcho(void){
+
+	int i,j,k;
+	int m,n;
+	double* matrix=NULL;
+	
+	printf("DoubleMatArrayParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   array size: %i\n",this->M);
+	for(i=0;i<M;i++){
+		printf("   array %i (%ix%i):\n",i,mdim_array[i],ndim_array[i]);
+		matrix=array[i];
+		m=mdim_array[i];
+		n=ndim_array[i];
+
+		for(j=0;j<m;j++){
+			printf("   ");
+			for(k=0;k<n;k++)printf("%g ",*(matrix+n*j+k));
+			printf("\n");
+		}
+	}
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::Id{{{1*/
+int    DoubleMatArrayParam::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::MyRank{{{1*/
+int    DoubleMatArrayParam::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::Marshall{{{1*/
+void  DoubleMatArrayParam::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of DoubleMatArrayParam: */
+	enum_value=DoubleMatArrayParamEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall DoubleMatArrayParam data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
+	memcpy(marshalled_dataset,mdim_array,M*sizeof(double));marshalled_dataset+=M*sizeof(int);
+	memcpy(marshalled_dataset,ndim_array,M*sizeof(double));marshalled_dataset+=M*sizeof(int);
+	for(i=0;i<M;i++){
+		double* matrix=this->array[i];
+		int     m=this->mdim_array[i];
+		int     n=this->ndim_array[i];
+		memcpy(marshalled_dataset,&m,sizeof(m));marshalled_dataset+=sizeof(m);
+		memcpy(marshalled_dataset,&n,sizeof(n));marshalled_dataset+=sizeof(n);
+		memcpy(marshalled_dataset,matrix,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
+	}
+	
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::MarshallSize{{{1*/
+int   DoubleMatArrayParam::MarshallSize(){
+
+	int size=0;
+	int i;
+
+	size+=sizeof(enum_type)+
+		sizeof(M)+
+		M*sizeof(int)+
+		M*sizeof(int);
+
+	for(i=0;i<M;i++){
+		int     m=this->mdim_array[i];
+		int     n=this->ndim_array[i];
+		size+=sizeof(m)+sizeof(n)+m*n*sizeof(double);
+	}
+	size+=sizeof(int); //sizeof(int) for enum value
+
+	return  size;
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::Demarshall{{{1*/
+void  DoubleMatArrayParam::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+	double* matrix=NULL;
+	int     m,n;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum value, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	
+	/*data: */
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
+	this->mdim_array=(int*)xmalloc(M*sizeof(int));
+	this->ndim_array=(int*)xmalloc(M*sizeof(int));
+	memcpy(this->mdim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
+	memcpy(this->ndim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
+
+	this->array=(double**)xmalloc(M*sizeof(double*));
+	for(i=0;i<M;i++){
+		memcpy(&m,marshalled_dataset,sizeof(m));marshalled_dataset+=sizeof(m);
+		memcpy(&n,marshalled_dataset,sizeof(n));marshalled_dataset+=sizeof(n);
+		matrix=(double*)xmalloc(m*n*sizeof(double));
+		memcpy(matrix,marshalled_dataset,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
+		this->array[i]=matrix;
+	}
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::Enum{{{1*/
+int DoubleMatArrayParam::Enum(void){
+
+	return DoubleMatArrayParamEnum;
+
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::copy{{{1*/
+Object* DoubleMatArrayParam::copy() {
+	
+	return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
+
+}
+/*}}}*/
+
+/*DoubleMatArrayParam virtual functions definitions: */
+/*FUNCTION DoubleMatArrayParam::GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){{{1*/
+void  DoubleMatArrayParam::GetParameterValue(double*** pout_array, int* pout_M,int** pout_mdim_array, int** pout_ndim_array){
+
+	int i,m,n;
+	double* matrix=NULL;
+	double* out_matrix=NULL;
+
+	/*output: */
+	double** out_array=NULL;
+	int      out_M;
+	int*     out_mdim_array=NULL;
+	int*     out_ndim_array=NULL;
+
+
+	out_M=this->M;
+	out_array=(double**)xmalloc(M*sizeof(double*));
+	out_mdim_array=(int*)xmalloc(M*sizeof(int));
+	out_ndim_array=(int*)xmalloc(M*sizeof(int));
+
+	memcpy(out_mdim_array,this->mdim_array,M*sizeof(int));
+	memcpy(out_ndim_array,this->ndim_array,M*sizeof(int));
+
+	for(i=0;i<this->M;i++){
+		matrix=this->array[i];
+		m=this->mdim_array[i];
+		n=this->ndim_array[i];
+		
+		out_matrix=(double*)xmalloc(m*n*sizeof(double));
+		memcpy(out_matrix,matrix,m*n*sizeof(double));
+
+		out_array[i]=out_matrix;
+	}
+
+
+	/*Assign output pointers:*/
+	if(pout_M) *pout_M=out_M;
+	if(pout_mdim_array) *pout_mdim_array=out_mdim_array;
+	if(pout_ndim_array) *pout_ndim_array=out_ndim_array;
+	*pout_array=out_array;
+
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::GetParameterName{{{1*/
+char* DoubleMatArrayParam::GetParameterName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION StringArrayParam::SetMatlabField{{{1*/
+#ifdef _SERIAL_
+void  DoubleMatArrayParam::SetMatlabField(mxArray* dataref){
+	
+	int      i,m,n;
+	double*  matrix=NULL;
+	double*  outmatrix=NULL;
+	char*    name=NULL;
+	mwSize   dims[2]={0};
+	mxArray* pfield=NULL;
+	mxArray* pfield2=NULL;
+	mxArray* pfield3=NULL;
+	
+	name=this->GetParameterName();
+	dims[0]=this->M;
+	dims[1]=1;
+	pfield=mxCreateCellArray(2,dims);
+
+	for(i=0;i<this->M;i++){
+		matrix=this->array[i];
+		m=this->mdim_array[i];
+		n=this->ndim_array[i];
+		outmatrix=(double*)xmalloc(m*n*sizeof(double));
+		memcpy(outmatrix,matrix,m*n*sizeof(double));
+	
+		pfield2=mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(pfield2,m);
+		mxSetN(pfield2,n);
+		mxSetPr(pfield2,outmatrix);
+
+		//transpose the outmatrix, written directly to matlab! from C to matlab.
+		mexCallMATLAB(1,&pfield3, 1, &pfield2, "transpose");
+	
+		mxSetCell(pfield,i,pfield3);
+	}
+	
+	mxSetField( dataref, 0, name,pfield);
+}
+#endif
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::SetValue(double** array, int M, int* mdim_array, int* ndim_array){{{1*/
+void  DoubleMatArrayParam::SetValue(double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
+
+	int i;
+	double* in_matrix=NULL;
+	double* matrix=NULL;
+
+	/*avoid leak: */
+	xfree((void**)&mdim_array);
+	xfree((void**)&ndim_array);
+	for(i=0;i<M;i++){
+		matrix=array[i];
+		xfree((void**)&matrix);
+	}
+	xfree((void**)&array);
+
+	/*copy data: */
+	this->M=in_M;
+	this->array=(double**)xmalloc(M*sizeof(double*));
+	this->mdim_array=(int*)xmalloc(M*sizeof(int));
+	this->ndim_array=(int*)xmalloc(M*sizeof(int));
+	
+	memcpy(this->mdim_array,in_mdim_array,M*sizeof(double));
+	memcpy(this->ndim_array,in_ndim_array,M*sizeof(double));
+
+	for(i=0;i<M;i++){
+		in_matrix=in_array[i];
+		m=in_mdim_array[i];
+		n=in_ndim_array[i];
+
+		matrix=(double*)xmalloc(m*n*sizeof(double));
+		memcpy(this->matrix,in_matrix,m*n*sizeof(double));
+
+		this->array[i]=matrix;
+	}
+
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 4852)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 4852)
@@ -0,0 +1,87 @@
+/*! \file DoubleMatArrayParam.h 
+ *  \brief: header file for object holding an array of serial matrices
+ */
+
+
+#ifndef _DOUBLEMATARRAYPARAM_H_
+#define _DOUBLEMATARRAYPARAM_H_
+
+/*Headers:*/
+/*{{{1*/
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _SERIAL_
+#include <mex.h>
+#endif
+
+
+#include "./Param.h"
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class DoubleMatArrayParam: public Param{
+
+	private: 
+		int      enum_type;
+		double** array; //array of matrices
+		int      M; //size of array
+		int*     mdim_array; //m-dimensions of matrices in the array
+		int*     ndim_array; //n-dimensions -f matrices in the array
+
+	public:
+		/*DoubleMatArrayParam constructors, destructors: {{{1*/
+		DoubleMatArrayParam();
+		DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array);
+		~DoubleMatArrayParam();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		int   Enum();
+		Object* copy();
+		/*}}}*/
+		/*Param vritual function definitions: {{{1*/
+		int   EnumType(){return enum_type;}
+		void  GetParameterValue(bool* pbool){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a bool",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(int* pinteger){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return an integer",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double* pdouble){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a double",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(char** pstring){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a string",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a string arrayl",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims);
+		void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
+
+		void  SetValue(bool boolean){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
+		void  SetValue(int integer){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold an integer",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double scalar){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a scalar",enum_type,EnumAsString(enum_type));}
+		void  SetValue(char* string){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a string",enum_type,EnumAsString(enum_type));}
+		void  SetValue(char** stringarray,int M){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a string array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double* doublearray,int M){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a double vec array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double* doublearray,int M,int N)ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a double mat array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(Vec vec){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
+		void  SetValue(Mat mat){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array);
+
+		char* GetParameterName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
+
+		/*}}}*/
+};
+#endif  /* _DOUBLEMATARRAYPARAM_H */
Index: /issm/trunk/src/c/objects/Params/DoubleMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 4852)
@@ -31,7 +31,6 @@
 
 	private: 
-		/*just hold 3 values for 3 vertices: */
 		int enum_type;
-		IssmDouble* value;
+		double* value;
 		int M;
 		int N;
@@ -63,4 +62,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM,int* pN);
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -75,4 +75,5 @@
 		void  SetValue(Vec vec){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/DoubleParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 4852)
@@ -61,4 +61,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("Double param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("Double param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("Double param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -73,4 +74,5 @@
 		void  SetValue(Vec vec){ISSMERROR("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Double param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/DoubleVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 4852)
@@ -61,4 +61,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM);
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -73,4 +74,5 @@
 		void  SetValue(Vec vec){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 		
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/IntParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/IntParam.h	(revision 4852)
@@ -60,4 +60,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("Int param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("Int param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("Int param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -72,4 +73,5 @@
 		void  SetValue(Vec vec){ISSMERROR("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Int param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/Param.h
===================================================================
--- /issm/trunk/src/c/objects/Params/Param.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/Param.h	(revision 4852)
@@ -39,4 +39,5 @@
 		virtual void  GetParameterValue(double** pdoublearray,int* pM)=0;
 		virtual void  GetParameterValue(double** pdoublearray,int* pM,int* pN)=0;
+		virtual void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims)=0;
 		virtual void  GetParameterValue(Vec* pvec)=0;
 		virtual void  GetParameterValue(Mat* pmat)=0;
@@ -51,4 +52,5 @@
 		virtual void  SetValue(Vec vec)=0;
 		virtual void  SetValue(Mat mat)=0;
+		virtual void  SetValue(double** array, int M, int* mdim_array, int* ndim_array)=0;
 
 		virtual char* GetParameterName(void)=0;
Index: /issm/trunk/src/c/objects/Params/PetscMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/PetscMatParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/PetscMatParam.h	(revision 4852)
@@ -61,4 +61,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("PetscMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("PetscMat param of enum %i (%s) cannot return a vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* poutput);
@@ -73,4 +74,5 @@
 		void  SetValue(Vec vec){ISSMERROR("PetscMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat);
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("PetscMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/PetscVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/PetscVecParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/PetscVecParam.h	(revision 4852)
@@ -61,16 +61,18 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("PetscVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("PetscVec param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* poutput);
 
-		void  SetValue(bool boolean){ISSMERROR("Bool param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
-		void  SetValue(int integer){ISSMERROR("Bool param of enum %i (%s) cannot hold an integer",enum_type,EnumAsString(enum_type));}
-		void  SetValue(double scalar){ISSMERROR("Bool param of enum %i (%s) cannot hold a scalar",enum_type,EnumAsString(enum_type));}
-		void  SetValue(char* string){ISSMERROR("Bool param of enum %i (%s) cannot hold a string",enum_type,EnumAsString(enum_type));}
-		void  SetValue(char** stringarray,int M){ISSMERROR("Bool param of enum %i (%s) cannot hold a string array",enum_type,EnumAsString(enum_type));}
-		void  SetValue(double* doublearray,int M){ISSMERROR("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){ISSMERROR("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(bool boolean){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
+		void  SetValue(int integer){ISSMERROR("PetscVec param of enum %i (%s) cannot hold an integer",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double scalar){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumAsString(enum_type));}
+		void  SetValue(char* string){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a string",enum_type,EnumAsString(enum_type));}
+		void  SetValue(char** stringarray,int M){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a string array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double* doublearray,int M){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double* pdoublearray,int M,int N){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Vec vec);
-		void  SetValue(Mat mat){ISSMERROR("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(Mat mat){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("PetscVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/StringArrayParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/StringArrayParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/StringArrayParam.h	(revision 4852)
@@ -63,4 +63,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("Vec param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -75,4 +76,5 @@
 		void  SetValue(Vec vec){ISSMERROR("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("StringArray param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/c/objects/Params/StringParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/StringParam.h	(revision 4851)
+++ /issm/trunk/src/c/objects/Params/StringParam.h	(revision 4852)
@@ -61,4 +61,5 @@
 		void  GetParameterValue(double** pdoublearray,int* pM){ISSMERROR("String param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){ISSMERROR("String param of enum %i (%s) cannot return a double array",enum_type,EnumAsString(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("String param of enum %i (%s) cannot return a matrix array",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Vec* pvec){ISSMERROR("String param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
 		void  GetParameterValue(Mat* pmat){ISSMERROR("String param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
@@ -73,4 +74,5 @@
 		void  SetValue(Vec vec){ISSMERROR("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
 		void  SetValue(Mat mat){ISSMERROR("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("String param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
 
 		char* GetParameterName(void);
Index: /issm/trunk/src/m/qmu/process_qmu_response_data.m
===================================================================
--- /issm/trunk/src/m/qmu/process_qmu_response_data.m	(revision 4851)
+++ /issm/trunk/src/m/qmu/process_qmu_response_data.m	(revision 4852)
@@ -10,4 +10,5 @@
 process_mass_flux_profiles=0;
 
+num_mass_flux=0;
 
 %loop through response descriptors, and act accordingly
@@ -16,4 +17,5 @@
 	%Do we have to process  mass flux profiles?
 	if strncmpi(md.responsedescriptors{i},'MassFlux',8),
+		num_mass_flux=num_mass_flux+1;
 		process_mass_flux_profiles=1;
 	end
@@ -37,9 +39,16 @@
 	end
 
+	if num_mass_flux~=numel(md.qmu_mass_flux_profiles),
+		error('process_qmu_response_data error message: qmu_mass_flux_profiles should be of the same size as the number of MassFlux responses asked for in the Qmu analysis');
+	end
+
 	%ok, process the domains named in qmu_mass_flux_profiles,  to build a list of segments
-	md.qmu_mass_flux_segments=cell(numel(md.qmu_mass_flux_profiles),1);
+	md.qmu_mass_flux_segments=cell(num_mass_flux,1);
 
-	for i=1:numel(md.qmu_mass_flux_profiles),
-		md.qmu_mass_flux_segments{i}=MassFluxProcessProfile(md,md.qmu_mass_flux_profile_directory,md.qmu_mass_flux_profiles{i});
+	for i=1:num_mass_flux,
+		md.qmu_mass_flux_segments{i}=MeshProfileIntersection(md.elements,md.x,md.y,[md.qmu_mass_flux_profile_directory/md.qmu_mass_flux_profiles{i}]);
 	end
+
+	%finally, set qmu_mass_flux_num_profiles, for future marshalling
+	md.qmu_mass_flux_num_profiles=num_mass_flux;
 end
Index: /issm/trunk/src/m/qmu/qmumarshall.m
===================================================================
--- /issm/trunk/src/m/qmu/qmumarshall.m	(revision 4851)
+++ /issm/trunk/src/m/qmu/qmumarshall.m	(revision 4852)
@@ -70,4 +70,5 @@
 
 %write response specific data
+qmu_segments=0;
 count=0;
 for i=1:length(response_fieldnames),
@@ -76,7 +77,14 @@
 	for j=1:length(fieldresponses),
 		descriptor=fieldresponses(j).descriptor;
-		if strcmpi(descriptor,'mass_flux'),
-			WriteData(fid,md.qmu_mass_flux_segments,'Mat','qmu_mass_flux_segments');
+		if strncmpi(descriptor,'MassFlux',8),
+			qmu_segments=1;
 		end
+	end
+end
+			
+if qmu_segments,
+	WriteData(fid,md.qmu_mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles');
+	for i=1:md.qmu_mass_flux_num_profiles,
+		WriteData(fid,md.qmu_mass_flux_segments{i},'Mat',['qmu_mass_flux_segments' num2str(i)]);
 	end
 end
