Index: sm/trunk-jpl/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp	(revision 12009)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/* \file MatlabMatrixToPetscMatrix.cpp
- * \brief: convert a sparse or dense matlab matrix to a serial Petsc matrix:
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabMatrixToPetscMatrix(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
-
-	int rows, cols;
-	double* mxmatrix_ptr=NULL;
-	double* tmatrix=NULL;
-	int ierr;
-	int i,j;
-
-	/*output: */
-	Mat matrix=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
-
-	/*petsc indices: */
-	int* idxm=NULL;
-	int* idxn=NULL;
-	
-	/*Ok, first check if we are dealing with a sparse or full matrix: */
-	if (mxIsSparse(mxmatrix)){
-
-		/*Dealing with sparse matrix: recover size first: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-		nnz=mxGetNzmax(mxmatrix);
-		if(rows){
-			nz=(int)((double)nnz/(double)rows);
-		}
-		else{
-			nz=0;
-		}
-
-		ierr=MatCreateSeqAIJ(PETSC_COMM_SELF,rows,cols,nz,PETSC_NULL,&matrix);CHKERRQ(ierr);
-
-		/*Now, get ir,jc and pr: */
-		pr=mxGetPr(mxmatrix);
-		ir=mxGetIr(mxmatrix);
-		jc=mxGetJc(mxmatrix);
-
-		/*Now, start inserting data into sparse matrix: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				MatSetValue(matrix,ir[count],i,pr[count],INSERT_VALUES);
-				count++;
-			}
-		}
-
-	}
-	else{
-
-		/*Dealing with dense matrix: recover pointer and size: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-
-		/*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
-		tmatrix=(double*)xmalloc(rows*cols*sizeof(double));
-		for(i=0;i<cols;i++){
-			for(j=0;j<rows;j++){
-				*(tmatrix+rows*i+j)=*(mxmatrix_ptr+cols*j+i);
-			}
-		}
-
-		/*Create serial matrix: */
-		ierr=MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&matrix);CHKERRQ(ierr);
-
-		/*Insert mxmatrix_ptr values into petsc matrix: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		idxn=(int*)xmalloc(cols*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-		for(i=0;i<cols;i++)idxn[i]=i;
-
-		ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
-
-		xfree((void**)&tmatrix);
-
-	}
-
-	/*Assemble matrix: */
-	MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY); 
-	MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
-
-
-	/*Assign output pointer: */
-	*pmatrix=matrix;
-	if(pmatrix_rows) *pmatrix_rows=rows;
-	if(pmatrix_cols) *pmatrix_cols=cols;
-
-	return 1;
-}
-#endif
Index: sm/trunk-jpl/src/c/toolkits/petsc/patches/MatlabVectorToPetscVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatlabVectorToPetscVector.cpp	(revision 12009)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/* \file MatlabVectorToPetscVector.cpp
- * \brief: convert a sparse or dense matlab vector to a serial Petsc vector:
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector){
-
-	int rows, cols;
-	double* mxvector_ptr=NULL;
-	int ierr;
-	int i,j;
-
-	/*output: */
-	Vec vector=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
-
-	/*petsc indices: */
-	int* idxm=NULL;
-	
-	/*Ok, first check if we are dealing with a sparse or full vector: */
-	if (mxIsSparse(mxvector)){
-
-		/*Dealing with sparse vector: recover size first: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-		nnz=mxGetNzmax(mxvector);
-		nz=(int)((double)nnz/(double)rows);
-
-		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
-
-		/*Now, get ir,jc and pr: */
-		pr=mxGetPr(mxvector);
-		ir=mxGetIr(mxvector);
-		jc=mxGetJc(mxvector);
-
-		/*Now, start inserting data into sparse vector: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				VecSetValue(vector,ir[count],pr[count],INSERT_VALUES);
-				count++;
-			}
-		}
-
-	}
-	else{
-
-		/*Dealing with dense vector: recover pointer and size: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-
-		/*Create serial vector: */
-		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
-
-		/*Insert mxvector_ptr values into petsc vector: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-
-		ierr=VecSetValues(vector,rows,idxm,mxvector_ptr,INSERT_VALUES);CHKERRQ(ierr);
-
-	}
-
-	/*Assemble vector: */
-	VecAssemblyBegin(vector);
-	VecAssemblyEnd(vector);
-
-	/*Assign output pointer: */
-	*pvector=vector;
-	*pvector_rows=rows;
-
-	return 1;
-}
-#endif
Index: sm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp	(revision 12009)
+++ 	(revision )
@@ -1,150 +1,0 @@
-/* \file PetscMatrixToMatlabMatrix.cpp
- * \brief: convert a sparse or dense Petsc matrix into a matlab matrix
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Petsc includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-#include <string>
-
-
-int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat tmatrix){
-
-	int i,j,k;
-
-	/*output: */
-	mxArray* dataref=NULL;
-	int    rows,cols;
-
-	int ncols;
-	int nnz=0;
-	int nzmax=0;
-	const int* columns=NULL;
-	const double* column_values=NULL;
-	double* matrix_ptr=NULL;
-
-	/*compress row format: */
-	double* val=NULL;
-	mwIndex*    col_ind=NULL;
-	mwIndex*    row_ptr=NULL;
-
-	/*petsc type: */
-	const char* type=NULL;
-	int*    idxm=NULL;
-	int*    idxn=NULL;
-	Mat     matrix=NULL;
-
-	
-	/*First off, we need to transpose the matrix using the Petsc API. We tried using the transpose operation from 
-	 * Matlab, but this ends up creating issues with lost pointers and references: */
-	MatTranspose(tmatrix,MAT_INITIAL_MATRIX,&matrix);
-
-	/*Some needed information: */
-	MatGetType(matrix,&type);
-	MatGetSize(matrix,&rows,&cols);
-
-	if (strcmp(type,MATSEQAIJ)==0){
-		
-		/*Dealing with a sparse sequential matrix: build ir, jc and val, as though it was a row comvalessed 
-		 *format, instead of a column comvalessed format. We'll transpose later.*/
-
-		/*First get nnz: */
-		nnz=0;
-		for(i=0;i<rows;i++){
-			MatGetRow(matrix,i,&ncols,&columns,&column_values);
-			nnz+=ncols;
-			MatRestoreRow(matrix,i,&ncols,&columns,&column_values);
-		}
-
-		if(nnz){
-			nzmax=nnz;
-		}
-		else{
-			nzmax=1; //so a null matrix can be returned.
-		}
-
-		val=(double*)xcalloc(nzmax,sizeof(double));
-		col_ind=(mwIndex*)xcalloc(nzmax,sizeof(mwIndex));
-		row_ptr=(mwIndex*)xcalloc((rows+1),sizeof(mwIndex));
-
-		j=0;
-
-		for(i=0;i<rows;i++){
-
-			/*Get row from petsc matrix: */
-			MatGetRow(matrix,i,&ncols,&columns,&column_values);
-
-			/*copy values: */
-			if(ncols)memcpy( val+j, column_values,ncols*sizeof(double));
-			  
-			for(k=0;k<ncols;k++) col_ind[j+k]=(mwIndex)columns[k];
-			row_ptr[i]=(mwIndex)j;
-			
-			j+=ncols;
-			
-			/*restore petsc row, otherwise we are leaking memory: */
-			MatRestoreRow(matrix,i,&ncols,&columns,&column_values);
-		}
-		row_ptr[rows]=(mwIndex)nnz;
-
-		/*Ok, allocate arrays: */
-		dataref = mxCreateSparse((mwSize)0,(mwSize)0,(mwSize)0,mxREAL);
-	
-		/* free first to avoid mem leaks...: */
-		mxFree(mxGetData(dataref));
-		mxFree(mxGetIr(dataref));
-		mxFree(mxGetJc(dataref));
-		
-		/* ...then set data: */
-		mxSetM(dataref,(mwSize)cols);
-		mxSetN(dataref,(mwSize)rows);
-		mxSetNzmax(dataref,(mwSize)nzmax);
-		mxSetData( dataref, val);
-		mxSetIr(dataref,col_ind);
-		mxSetJc(dataref,row_ptr);
-
-	}
-	else{
-		/*Dealing with a dense sequential matrix: recover pointer to the data in the Petsc matrix*/
-
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		idxn=(int*)xmalloc(cols*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-		for(i=0;i<cols;i++)idxn[i]=i;
-
-		matrix_ptr=(double*)xmalloc(rows*cols*sizeof(double));
-		MatGetValues(matrix,rows,idxm,cols,idxn,matrix_ptr);
-
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(dataref,cols);
-		mxSetN(dataref,rows);
-		mxSetPr(dataref,(double*)matrix_ptr);	
-	}
-
-	/*Free ressources:*/
-	MatFree(&matrix);
-
-	/*Assign output pointers: */
-	*pdataref=dataref;
-
-	return 1;
-}
-
-#endif  
Index: sm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp	(revision 12009)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/* \file PetscVectorToMatlabVector.cpp
- * \brief: convert a sparse or dense Petsc vector into a matlab vector
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Petsc includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-#include <string>
-
-
-int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector){
-
-	int     i;
-	int     rows;
-	int    *idxm   = NULL;
-	double *values = NULL;
-
-	/*output: */
-	mxArray* dataref=NULL;
-
-	/*Get size of vector: */
-	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;
-
-			VecGetValues(vector,rows,idxm,values);
-		}
-	}
-	else{
-		rows=0;
-	}
-
-	/*Using values, build a matlab vector: */
-	dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(dataref,rows);
-	mxSetN(dataref,1);
-	mxSetPr(dataref,(double*)values);	
-
-	/*Some logic here to make the vector sparse? Although this could slow down the code quite a bit: */
-
-	/*Assign output pointers: */
-	*pdataref=dataref;
-
-	return 1;
-}
-
-#endif  //#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/petscpatches.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/petscpatches.h	(revision 12009)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/petscpatches.h	(revision 12010)
@@ -15,12 +15,4 @@
 
 class Parameters;
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
-int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
-int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix);
-int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector);
-#endif
 
 Vec NewVec(int size,bool fromlocalsize=false);
