Index: /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14672)
+++ /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14673)
@@ -22,5 +22,5 @@
 /*}}}*/
 
-void TriMeshx(IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
+void TriMeshx(int** pindex,IssmPDouble** px,IssmPDouble** py,int** psegments,int** psegmentmarkerlist,int* pnels,int* pnods, int* pnsegs,DataSet* domain,DataSet* rifts,double area){
 
 #if !defined(_HAVE_TRIANGLE_)
@@ -31,11 +31,9 @@
 
 	/*output: */
-	int         *index             = NULL;
-	IssmDenseMat<int> *index_matrix      = NULL;
-	double      *x                 = NULL;
-	double      *y                 = NULL;
-	int         *segments          = NULL;
-	IssmDenseMat<int> *segments_matrix   = NULL;
-	int         *segmentmarkerlist = NULL;
+	int    *index             = NULL;
+	double *x                 = NULL;
+	double *y                 = NULL;
+	int    *segments          = NULL;
+	int    *segmentmarkerlist = NULL;
 
 	/*intermediary: */
@@ -197,13 +195,12 @@
 
 	/*Output : */
-	index_matrix=new IssmDenseMat<int>(index,out.numberoftriangles,3,1);
-	*pindex=index_matrix;
-
-	segments_matrix=new IssmDenseMat<int>(segments,out.numberofsegments,3,1);
-	*psegments=segments_matrix;
-
-	*px=new IssmSeqVec<IssmPDouble>(x,out.numberofpoints);
-	*py=new IssmSeqVec<IssmPDouble>(y,out.numberofpoints);
-	*psegmentmarkerlist=new IssmSeqVec<int>(segmentmarkerlist,out.numberofsegments);
+	*pindex=index;
+	*px=x;
+	*py=y;
+	*psegments=segments;
+	*psegmentmarkerlist=segmentmarkerlist;
+	*pnels=out.numberoftriangles;
+	*pnods=out.numberofpoints;
+	*pnsegs=out.numberofsegments;
 #endif
 }
Index: /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h	(revision 14672)
+++ /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h	(revision 14673)
@@ -11,5 +11,4 @@
 
 /* local prototypes: */
-void TriMeshx(IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
-
+void TriMeshx(int** pindex,IssmPDouble** px,IssmPDouble** py,int** psegments,int** psegmentmarkerlist,int* pnels,int* pnods, int* pnseg,DataSet* domain,DataSet* rifts,double area);
 #endif  /* _TRIMESHX_H */
Index: /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 14672)
+++ /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 14673)
@@ -17,14 +17,15 @@
 	
 	/*intermediary: */
-	double  area;
+	double   area;
 	DataSet *domain = NULL;
 	DataSet *rifts  = NULL;
 
 	/* output: */
-	IssmDenseMat<int>    *index             = NULL;
-	IssmSeqVec<double> *x                 = NULL;
-	IssmSeqVec<double> *y                 = NULL;
-	IssmDenseMat<int>    *segments          = NULL;
-	IssmSeqVec<int>    *segmentmarkerlist = NULL;
+	int    *index             = NULL;
+	double *x                 = NULL;
+	double *y                 = NULL;
+	int    *segments          = NULL;
+	int    *segmentmarkerlist = NULL;
+	int     nels,nods,nsegs;
 
 	/*Boot module: */
@@ -40,12 +41,12 @@
 
 	/*call x core: */
-	TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist,domain,rifts,area);
+	TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist,&nels,&nods,&nsegs,domain,rifts,area);
 
 	/*write outputs: */
-	WriteData(INDEX,index);
-	WriteData(X,x);
-	WriteData(Y,y);
-	WriteData(SEGMENTS,segments);
-	WriteData(SEGMENTMARKERLIST,segmentmarkerlist);
+	WriteData(INDEX,index,nels,3);
+	WriteData(X,x,nods);
+	WriteData(Y,y,nods);
+	WriteData(SEGMENTS,segments,nsegs,3);
+	WriteData(SEGMENTMARKERLIST,segmentmarkerlist,nsegs);
 
 	/*free ressources: */
Index: /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14672)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14673)
@@ -74,4 +74,27 @@
 		vector_matlab=(double*)mxMalloc(M*sizeof(double));
 		for(int i=0;i<M;i++) vector_matlab[i]=vector[i];
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,(mwSize)M);
+		mxSetN(dataref,(mwSize)1);
+		mxSetPr(dataref,vector_matlab);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,int* vector, int M){{{*/
+void WriteData(mxArray** pdataref,int* vector, int M){
+
+	mxArray* dataref       = NULL;
+	double*  vector_matlab = NULL;
+
+	if(vector){
+
+		/*create the matlab vector with Matlab's memory manager */
+		vector_matlab=(double*)mxMalloc(M*sizeof(double));
+		for(int i=0;i<M;i++) vector_matlab[i]=double(vector[i]);
 		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
 		mxSetM(dataref,(mwSize)M);
@@ -290,73 +313,4 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){{{*/
-void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){
-
-	int      i,j;
-	int      rows,cols;
-	mxArray *dataref     = NULL;
-	int     *matrix_ptr  = NULL;
-	double  *tmatrix_ptr = NULL;
-
-	if(matrix){
-
-		matrix_ptr=matrix->ToSerial();
-		matrix->GetSize(&rows,&cols);
-
-		/*Now transpose the matrix and allocate with Matlab's memory manager: */
-		tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));
-		for(i=0;i<rows;i++){
-			for(j=0;j<cols;j++){
-				tmatrix_ptr[j*rows+i]=(double)matrix_ptr[i*cols+j];
-			}
-		}
-
-		/*create matlab matrix: */
-		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(dataref,rows); 
-		mxSetN(dataref,cols);
-		mxSetPr(dataref,tmatrix_ptr);
-
-		/*Free ressources:*/
-		xDelete<int>(matrix_ptr);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){{{*/
-void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){
-
-	mxArray* dataref=NULL;
-	int*     vector_ptr=NULL;
-	double*  vector_matlab=NULL;
-	int      rows;
-
-	if(vector){
-		/*call toolkit routine: */
-		vector_ptr=vector->ToMPISerial();
-		vector->GetSize(&rows);
-
-		/*now create the matlab vector with Matlab's memory manager */
-		vector_matlab=(double*)mxMalloc(rows*sizeof(double));
-		for(int i=0;i<rows;i++) vector_matlab[i]=(double)vector_ptr[i];
-
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);                         
-		mxSetM(dataref,rows);
-		mxSetN(dataref,1);                                                                                          
-		mxSetPr(dataref,vector_matlab);           
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	/*Clean-up and return*/
-	xDelete<int>(vector_ptr);
-	*pdataref=dataref;
-}
-/*}}}*/
 /*FUNCTION WriteData(mxArray** pdataref,RiftStruct* riftstruct){{{*/
 void WriteData(mxArray** pdataref,RiftStruct* riftstruct){
Index: /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h	(revision 14672)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h	(revision 14673)
@@ -18,11 +18,10 @@
 #include "../../c/toolkits/toolkits.h"
 
-void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix);
 void WriteData(mxArray** pdataref,IssmDenseMat<double>* matrix);
 void WriteData(mxArray** pdataref,double* matrix, int M,int N);
 void WriteData(mxArray** pdataref,int*    matrix, int M,int N);
-void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector);
 void WriteData(mxArray** pdataref,IssmSeqVec<double>* vector);
 void WriteData(mxArray** pdataref,double* vector, int M);
+void WriteData(mxArray** pdataref,int* vector, int M);
 void WriteData(mxArray** pdataref,int integer);
 void WriteData(mxArray** pdataref,bool boolean);
Index: /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 14672)
+++ /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 14673)
@@ -74,4 +74,38 @@
 
 	PyTuple_SetItem(tuple, index, array);
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index, double* vector, int M){{{*/
+void WriteData(PyObject* py_tuple, int index, double* vector, int M){
+
+	double   *buffer = NULL;
+	npy_intp  dim   = 10;
+	PyObject *array = NULL;
+
+	/*Copy vector*/
+	buffer=xNew<double>(M);
+	for(int i=0;i<M;i++)buffer[i]=vector[i];
+
+	dim=(npy_intp)M;
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
+
+	PyTuple_SetItem(py_tuple, index, array);
+
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index, int* vector, int M){{{*/
+void WriteData(PyObject* py_tuple, int index, int* vector, int M){
+
+	long* lvector=NULL;
+	npy_intp dim=10;
+	PyObject* array=NULL;
+
+	/*transform into long matrix: */
+	lvector=xNew<long>(M);
+	for(int i=0;i<M;i++)lvector[i]=(long)vector[i];
+
+	dim=(npy_intp)M;
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_INT64,lvector);
+
+	PyTuple_SetItem(py_tuple, index, array);
+
 }/*}}}*/
 /*FUNCTION WriteData(PyObject* py_tuple,int index){{{*/
@@ -164,84 +198,4 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){{{*/
-void WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){
-
-	int M,N;
-	int* ibuffer=NULL;
-	npy_intp dims[2]={0,0};
-	PyObject* array=NULL;
-
-	matrix->GetSize(&M,&N);
-	ibuffer=matrix->ToSerial();
-
-	/*convert to long*/
-	long* lbuffer=xNew<long>(M*N);
-	for(int i=0;i<M*N;i++) lbuffer[i]=(long)ibuffer[i];
-	xDelete<int>(ibuffer);
-
-	dims[0]=(npy_intp)M;
-	dims[1]=(npy_intp)N;
-	array=PyArray_SimpleNewFromData(2,dims,NPY_INT64,lbuffer);
-
-	PyTuple_SetItem(py_tuple, index, array);
-
-}/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){{{*/
-void WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){
-
-	int M;
-	int* ibuffer=NULL;
-	npy_intp dim=10;
-	PyObject* array=NULL;
-
-	vector->GetSize(&M);
-	ibuffer=vector->ToMPISerial();
-
-	/*convert to long*/
-	long* lbuffer=xNew<long>(M);
-	for(int i=0;i<M;i++) lbuffer[i]=(long)ibuffer[i];
-	xDelete<int>(ibuffer);
-
-	dim=(npy_intp)M;
-	array=PyArray_SimpleNewFromData(1,&dim,NPY_INT64,lbuffer);
-
-	PyTuple_SetItem(py_tuple, index, array);
-}
-/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){{{*/
-void WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){
-
-	int M,N;
-	bool* buffer=NULL;
-	npy_intp dims[2]={0,0};
-	PyObject* array=NULL;
-
-	matrix->GetSize(&M,&N);
-	buffer=matrix->ToSerial();
-
-	dims[0]=(npy_intp)M;
-	dims[1]=(npy_intp)N;
-	array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,buffer);
-
-	PyTuple_SetItem(py_tuple, index, array);
-
-}/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){{{*/
-void WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){
-
-	int M;
-	bool* buffer=NULL;
-	npy_intp dim=10;
-	PyObject* array=NULL;
-
-	vector->GetSize(&M);
-	buffer=vector->ToMPISerial();
-
-	dim=(npy_intp)M;
-	array=PyArray_SimpleNewFromData(1,&dim,NPY_BOOL,buffer);
-
-	PyTuple_SetItem(py_tuple, index, array);
-}
-/*}}}*/
 /*FUNCTION WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){{{*/
 void WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){
Index: /issm/trunk-jpl/src/wrappers/python/io/pythonio.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/python/io/pythonio.h	(revision 14672)
+++ /issm/trunk-jpl/src/wrappers/python/io/pythonio.h	(revision 14673)
@@ -21,12 +21,10 @@
 void WriteData(PyObject* py_tuple,int index, bool* matrix, int M,int N);
 void WriteData(PyObject* py_tuple,int index, int integer);
+void WriteData(PyObject* py_tuple,int index, double* vector, int M);
+void WriteData(PyObject* py_tuple,int index, int* vector, int M);
 void WriteData(PyObject* py_tuple,int index, char* string);
 void WriteData(PyObject* py_tuple,int index);
 void WriteData(PyObject* py_tuple,int index, IssmDenseMat<double>* matrix);
 void WriteData(PyObject* py_tuple,int index, IssmSeqVec<double>* vector);
-void WriteData(PyObject* py_tuple,int index, IssmDenseMat<int>* matrix);
-void WriteData(PyObject* py_tuple,int index, IssmSeqVec<int>* vector);
-void WriteData(PyObject* py_tuple,int index, IssmDenseMat<bool>* matrix);
-void WriteData(PyObject* py_tuple,int index, IssmSeqVec<bool>* vector);
 void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom);
 void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
