Index: /issm/trunk-jpl/src/c/io/Matlab/FetchMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11715)
+++ /issm/trunk-jpl/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11716)
@@ -286,5 +286,5 @@
 		/*Check dataref is not pointing to NaN: */
 		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix=NULL;
+			outmatrix=new Matrix(0,0);
 		}
 		else{
@@ -434,5 +434,5 @@
 	if(mxIsEmpty(dataref)){
 		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		vector=NULL;
+		vector=new Vector(0);
 	}
 	else if (mxIsClass(dataref,"double") ){
Index: /issm/trunk-jpl/src/c/io/Matlab/WriteMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11715)
+++ /issm/trunk-jpl/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11716)
@@ -114,5 +114,4 @@
 	
 	if(vector){
-		
 		/*call toolkit routine: */
 		dataref=vector->ToMatlabVector();
Index: /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp	(revision 11715)
+++ /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp	(revision 11716)
@@ -16,16 +16,19 @@
 void	Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters){
 
-	/*output: */
-	Vector* uf=NULL;
-	uf=new Vector();
-
 	/*Intermediary: */
 	int analysis_type;
+
+	/*output: */
+	Vector *uf=new Vector();
+
+	/*In debugging mode, check that stiffness matrix and load vectors are not NULL (they can be empty)*/
+	_assert_(Kff);
+	_assert_(pf);
 
 	#ifdef _HAVE_PETSC_
 	Vec uf0_vector = NULL;
 	Vec df_vector  = NULL;
-	if(uf0) uf0_vector=uf0->vector;
-	if(df)  df_vector = df->vector;
+	if(uf0) uf0_vector = uf0->vector;
+	if(df)  df_vector  = df->vector;
 
 	/*In serial mode, the Petsc Options database has not been initialized properly: */
@@ -37,5 +40,5 @@
 	SolverxPetsc(&uf->vector,Kff->matrix,pf->vector,uf0_vector,df_vector,parameters);
 	if(uf->vector == NULL){
-		uf->M;
+		uf->M = 0;
 	}
 	else{
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp	(revision 11715)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp	(revision 11716)
@@ -27,9 +27,8 @@
 int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector){
 
-
-	int i;
-	int rows;
-	int* idxm=NULL;
-	double* values=NULL;
+	int     i;
+	int     rows;
+	int    *idxm   = NULL;
+	double *values = NULL;
 
 	/*output: */
@@ -37,12 +36,16 @@
 
 	/*Get size of vector: */
-	VecGetSize(vector,&rows);
+	if(vector){
+		VecGetSize(vector,&rows);
+		if(rows){
+			idxm=(int*)xmalloc(rows*sizeof(int));
+			values=(double*)xmalloc(rows*sizeof(double));
+			for(i=0;i<rows;i++)idxm[i]=i;
 
-	if(rows){
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		values=(double*)xmalloc(rows*sizeof(double));
-		for(i=0;i<rows;i++)idxm[i]=i;
-		 
-		VecGetValues(vector,rows,idxm,values);
+			VecGetValues(vector,rows,idxm,values);
+		}
+	}
+	else{
+		rows=0;
 	}
 
@@ -61,5 +64,3 @@
 }
 
-
 #endif  //#ifdef _SERIAL_
-
