Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 4863)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 4864)
@@ -35,19 +35,30 @@
 	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;
+	if(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;
+
+			if(m*n){
+				matrix=(double*)xmalloc(m*n*sizeof(double));
+				memcpy(matrix,in_array[i],m*n*sizeof(double));
+			}
+			else{
+				matrix=NULL;
+			}
+			array[i]=matrix;
+		}
+	}
+	else{
+		array=NULL;
+		mdim_array=NULL;
+		ndim_array=NULL;
 	}
 }
@@ -135,13 +146,15 @@
 	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);
+	if(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);
+			if(m*n)memcpy(marshalled_dataset,matrix,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
+		}
 	}
 	
@@ -188,16 +201,28 @@
 	
 	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;
+	if(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);
+			if(m*n){
+				matrix=(double*)xmalloc(m*n*sizeof(double));
+				memcpy(matrix,marshalled_dataset,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
+			}
+			else{
+				matrix=NULL;
+			}
+			this->array[i]=matrix;
+		}
+	}
+	else{
+		this->array=NULL;
+		this->mdim_array=NULL;
+		this->ndim_array=NULL;
 	}
 
@@ -238,20 +263,31 @@
 
 	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;
+	if(out_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];
+
+			if(m*n){
+				out_matrix=(double*)xmalloc(m*n*sizeof(double));
+				memcpy(out_matrix,matrix,m*n*sizeof(double));
+			}
+			else{
+				out_matrix=NULL;
+			}
+			out_array[i]=out_matrix;
+		}
+	}
+	else{
+		out_array=NULL;
+		out_matrix=NULL;
+		out_ndim_array=NULL;
 	}
 
