Index: /issm/trunk/src/c/Container/Options.cpp
===================================================================
--- /issm/trunk/src/c/Container/Options.cpp	(revision 8909)
+++ /issm/trunk/src/c/Container/Options.cpp	(revision 8910)
@@ -42,5 +42,5 @@
 		if (!mxIsClass(prhs[i],"char")) _error_("Argument %d must be name of option.",i+1);
 
-		FetchData(&name,prhs[i]);
+		FetchMatlabData(&name,prhs[i]);
 		if (i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);
 
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 8909)
+++ /issm/trunk/src/c/Makefile.am	(revision 8910)
@@ -402,12 +402,13 @@
 					./toolkits.h\
 					./io/io.h\
-					./io/FetchData.cpp\
-					./io/WriteData.cpp\
-					./io/IoModelFetchData.cpp\
-					./io/WriteParams.cpp\
-					./io/FetchParams.cpp\
-					./io/OptionParse.cpp\
-					./io/pfopen.cpp\
-					./io/pfclose.cpp\
+					./io/Disk/diskio.h\
+					./io/Disk/IoModelFetchData.cpp\
+					./io/Disk/pfopen.cpp\
+					./io/Disk/pfclose.cpp\
+					./io/Disk/FetchData.cpp\
+					./io/Matlab/matlabio.h\
+					./io/Matlab/WriteMatlabData.cpp\
+					./io/Matlab/FetchMatlabData.cpp\
+					./io/Matlab/OptionParse.cpp\
 					./EnumDefinitions/EnumDefinitions.h\
 					./EnumDefinitions/EnumToModelField.cpp\
@@ -1075,10 +1076,13 @@
 					./toolkits.h\
 					./io/io.h\
-					./io/FetchData.cpp\
-					./io/WriteData.cpp\
-					./io/IoModelFetchData.cpp\
-					./io/WriteParams.cpp\
-					./io/pfopen.cpp\
-					./io/pfclose.cpp\
+					./io/Disk/diskio.h\
+					./io/Disk/IoModelFetchData.cpp\
+					./io/Disk/pfopen.cpp\
+					./io/Disk/pfclose.cpp\
+					./io/Disk/FetchData.cpp\
+					./io/Matlab/matlabio.h\
+					./io/Matlab/WriteMatlabData.cpp\
+					./io/Matlab/FetchMatlabData.cpp\
+					./io/Matlab/OptionParse.cpp\
 					./EnumDefinitions/EnumDefinitions.h\
 					./EnumDefinitions/EnumToModelField.cpp\
Index: /issm/trunk/src/c/io/Disk/FetchData.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/FetchData.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Disk/FetchData.cpp	(revision 8910)
@@ -0,0 +1,137 @@
+/*\file FetchData.cpp:
+ * \brief: general I/O interface to fetch data.
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+#if defined(_HAVE_PETSC_)
+/*FUNCTION FetchData(double** pmatrix, int* pM,int* pN,FILE* fid){{{1*/
+void FetchData(double** pmatrix, int* pM,int* pN,FILE* fid){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	int M,N;
+	double* matrix=NULL;
+	
+	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
+	/*numberofelements: */
+	if(my_rank==0){  
+		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
+	}
+
+	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+
+	if(my_rank==0){  
+		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
+	}
+	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+
+	/*Now allocate matrix: */
+	if(M*N){
+		matrix=(double*)xmalloc(M*N*sizeof(double));
+
+		/*Read matrix on node 0, then broadcast: */
+		if(my_rank==0){  
+			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
+		}
+		
+		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+	}
+
+
+	/*Assign output pointers: */
+	*pmatrix=matrix;
+	if (pM)*pM=M;
+	if (pN)*pN=N;
+
+}
+/*}}}*/
+/*FUNCTION FetchData(char** pstring,FILE* fid){{{1*/
+void FetchData(char** pstring,FILE* fid){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	char* string=NULL;
+	int   string_size;
+
+	/*We have to read a string from disk. First read the dimensions of the string, then the string: */
+	if(my_rank==0){  
+		if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
+	}
+
+	MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+
+	/*Now allocate string: */
+	if(string_size){
+		string=(char*)xmalloc((string_size+1)*sizeof(char));
+		string[string_size]='\0';
+
+		/*Read string on node 0, then broadcast: */
+		if(my_rank==0){  
+			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
+		}
+		MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+	}
+	else{
+		string=(char*)xmalloc(sizeof(char));
+		string[0]='\0';
+	}
+
+
+	/*Assign output pointers: */
+	*pstring=string;
+}
+/*}}}*/
+/*FUNCTION FetchData(double* pscalar,FILE* fid){{{1*/
+void FetchData(double* pscalar,FILE* fid){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	double   scalar;
+
+	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
+	if(my_rank==0){
+		if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
+	}
+	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+
+	/*Assign output pointers: */
+	*pscalar=scalar;
+		 
+}
+/*}}}*/
+/*FUNCTION FetchData(int* pinteger,FILE* fid){{{1*/
+void FetchData(int* pinteger,FILE* fid){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	int   integer;
+
+	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
+	if(my_rank==0){  
+		if(fread(&integer,sizeof(int),1,fid)!=1) _error_(" could not read integer ");
+	}
+
+	MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+
+	/*Assign output pointers: */
+	*pinteger=integer;
+
+}
+/*}}}*/
+#endif
Index: /issm/trunk/src/c/io/Disk/IoModelFetchData.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/IoModelFetchData.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Disk/IoModelFetchData.cpp	(revision 8910)
@@ -0,0 +1,127 @@
+/*! \file IoModelFetchData.c
+ *  \brief: wrapper to the I/O routines, for special processing of the IoModel structure.
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "./diskio.h"
+
+/*FUNCTION IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){{{1*/
+void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){
+	
+	FILE* fid=NULL;
+	
+	/*Set file pointer to beginning of the data: */
+	fid=SetFilePointerToData(model_handle,data_name);
+	
+	/*Now fetch: */
+	FetchData(pmatrix,pM,pN,fid);
+
+}
+/*}}}*/
+/*FUNCTION IoModelFetchData(char** pstring,FILE* model_handle,char* data_name){{{1*/
+void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name){
+
+	FILE* fid=NULL;
+	
+	/*Set file pointer to beginning of the data: */
+	fid=SetFilePointerToData(model_handle,data_name);
+	
+	/*Now fetch: */
+	FetchData(pstring,fid);
+}
+/*}}}*/
+/*FUNCTION IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name){{{1*/
+void  IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name){
+
+	FILE* fid=NULL;
+	
+	/*Set file pointer to beginning of the data: */
+	fid=SetFilePointerToData(model_handle,data_name);
+	
+	/*Now fetch: */
+	FetchData(pscalar,fid);
+}
+/*}}}*/
+/*FUNCTION IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name){{{1*/
+void  IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name){
+
+	FILE* fid=NULL;
+	
+	/*Set file pointer to beginning of the data: */
+	fid=SetFilePointerToData(model_handle,data_name);
+	
+	/*Now fetch: */
+	FetchData(pinteger,fid);
+}
+/*}}}*/
+/*FUNCTION SetFilePointerToData(FILE* model_handle,char* data_name){{{1*/
+FILE* SetFilePointerToData(FILE* model_handle,char* data_name){
+
+	extern int my_rank;
+	extern int num_procs;
+	
+	int string_size;
+	int record_length;
+	char* string=NULL;
+	char* repository=NULL;
+	FILE* fid=NULL;
+	int found=0;
+
+	/*Go find in the binary file, the position of the data we want to fetch: */
+	if(my_rank==0){
+	
+		/*First set FILE* position to the beginning of the file: */
+		fid=(FILE*)model_handle;
+		fseek(fid,0,SEEK_SET);
+
+		/*Now march through file looking for the correct name: */
+		for(;;){
+			/*Read size of first string name: */
+			if(fread(&string_size,sizeof(int),1,fid)==0){
+				/*Ok, we have reached the end of the file. break: */
+				found=0;
+				break;
+			}
+			/*Allocate string of correct size: */
+			string=(char*)xmalloc((string_size+1)*sizeof(char));
+			string[string_size]='\0';
+
+			/*Read string: */
+			if(fread(string,string_size*sizeof(char),1,fid)==0){
+				/*Ok, we have reached the end of the file. break: */
+				found=0;
+				break;
+			}
+			/*Is this the correct string? : */
+			if (strcmp(string,data_name)==0){
+				/*Ok, we have found the correct string. Pass the record length, and break: */
+				fseek(fid,sizeof(int),SEEK_CUR);
+				found=1;
+				break;
+			}
+			else{
+				/*This is not the correct string, read the record length, and skip it: */
+				fread(&record_length,sizeof(int),1,fid);
+				/*skip: */
+				fseek(fid,record_length,SEEK_CUR);
+			}
+			/*Erase string: */
+			xfree((void**)&string);
+		}
+		/*erase string, if we broke from the for() loop:*/
+		xfree((void**)&string);
+	}
+	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
+
+	if(!found)_error_("%s %s ","could not find data with name",data_name);
+
+	return fid;
+}
+/*}}}*/
Index: /issm/trunk/src/c/io/Disk/diskio.h
===================================================================
--- /issm/trunk/src/c/io/Disk/diskio.h	(revision 8910)
+++ /issm/trunk/src/c/io/Disk/diskio.h	(revision 8910)
@@ -0,0 +1,29 @@
+/*\file diskio.h
+ *\brief: I/O for ISSM from disk
+ */
+
+#ifndef _DISK_IO_H_
+#define _DISK_IO_H_
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+class DataSet;
+class Parameters;
+
+FILE* pfopen(char* filename,char* format);
+void  pfclose(FILE* fid,char* filename);
+
+void  FetchData(double** pmatrix, int* pM,int* pN,FILE* fid);
+void  FetchData(char** pstring,FILE* fid);
+void  FetchData(double* pscalar,FILE* fid);
+void  FetchData(int* pinteger,FILE* fid);
+
+void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name);
+void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name);
+void  IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name);
+void  IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name);
+FILE* SetFilePointerToData(FILE* model_handle,char* data_name);
+
+#endif	/* _IO_H_ */
Index: /issm/trunk/src/c/io/Disk/pfclose.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/pfclose.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Disk/pfclose.cpp	(revision 8910)
@@ -0,0 +1,21 @@
+/*!\file:  pfclose.cpp
+ * \brief fclose wrapper for parallel solution
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+void pfclose(FILE* fid,char* filename){
+
+	/*Close file handle: */
+	extern int my_rank;
+	_assert_(fid);
+	if(fclose(fid)!=0)_error_("%s%s","could not close file ",filename);
+}
Index: /issm/trunk/src/c/io/Disk/pfopen.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/pfopen.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Disk/pfopen.cpp	(revision 8910)
@@ -0,0 +1,26 @@
+/*!\file:  pfopen.cpp
+ * \brief fopen wrapper for parallel solution
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+FILE* pfopen(char* filename,char* format){
+
+	FILE* fid=NULL;
+	extern int my_rank;
+	
+	/*Open handle to data on disk: */
+	fid=fopen(filename,format);
+	if(fid==NULL) _error_("%s%s%s","could not open file ",filename," for binary reading or writing"); 
+
+	return fid;
+}
+
Index: sm/trunk/src/c/io/FetchData.cpp
===================================================================
--- /issm/trunk/src/c/io/FetchData.cpp	(revision 8909)
+++ 	(revision )
@@ -1,696 +1,0 @@
-/*\file FetchData.cpp:
- * \brief: general I/O interface to fetch data.
- */
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "./io.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-
-#ifdef _SERIAL_
-#include <mex.h>
-/*FUNCTION FetchData(DataSet** pdataset,const mxArray* dataref){{{1*/
-void FetchData(DataSet** pdataset,const mxArray* dataref){
-
-	/*output*/
-	DataSet* outdataset=NULL;
-	char*    outdataset_buffer=NULL;
-	int      outdataset_size;
-
-	/*First, check that our reference is a double, otherwise, error out: */
-	if (mxIsClass(dataref,"double")){
-			
-		/*We need to copy the data pointed by dataref, so that our dataset is not actually a pointer!:*/
-		if (!mxIsEmpty(dataref)){
-			outdataset_buffer=(char*)mxGetPr(dataref);
-			outdataset_size=mxGetM(dataref)*mxGetN(dataref);
-			if(outdataset_size)outdataset=DataSetDemarshall(outdataset_buffer);
-		}
-	}
-	else{
-		if (mxIsEmpty(dataref)){
-			/*Nothing to pick up. Just initialize pointer to NULL, and warn the server we are not uploading anything: */
-			outdataset_size=0;
-			outdataset=NULL;
-		}
-		else{
-			/*This is an error: we don't have the correct input!: */
-			_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-		}
-	}
-
-	/*Assign output pointers:*/
-	*pdataset=outdataset;
-}
-/*}}}*/
-/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
-void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
-
-	double*  outmatrix=NULL;
-	int      outmatrix_rows,outmatrix_cols;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_rows=0;
-		outmatrix_cols=0;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix_rows=0;
-			outmatrix_cols=0;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab matrix to double* matrix: */
-			MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-			
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pM)*pM=outmatrix_rows;
-	if (pN)*pN=outmatrix_cols;
-
-}
-/*}}}*/
-/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
-void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
-
-	double*  outmatrix=NULL;
-	int      outmatrix_numel,outmatrix_ndims;
-	int*     outmatrix_size=NULL;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_numel=0;
-		outmatrix_ndims=0;
-		outmatrix_size =NULL;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
-			outmatrix_numel=0;
-			outmatrix_ndims=0;
-			outmatrix_size =NULL;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab n-dim array to double* matrix: */
-			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-			
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pnumel)*pnumel=outmatrix_numel;
-	if (pndims)*pndims=outmatrix_ndims;
-	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
-void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
-
-	int     i,outmatrix_rows,outmatrix_cols;
-	double *doublematrix=NULL;
-	int    *outmatrix=NULL;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_rows=0;
-		outmatrix_cols=0;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix_rows=0;
-			outmatrix_cols=0;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab matrix to double* matrix: */
-			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
-
-			/*Convert double matrix into integer matrix: */
-			outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int));
-			for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pM)*pM=outmatrix_rows;
-	if (pN)*pN=outmatrix_cols;
-}
-/*}}}*/
-/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
-void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
-
-	int     i,outmatrix_rows,outmatrix_cols;
-	double *doublematrix=NULL;
-	bool   *outmatrix=NULL;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_rows=0;
-		outmatrix_cols=0;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix_rows=0;
-			outmatrix_cols=0;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab matrix to double* matrix: */
-			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
-
-			/*Convert double matrix into integer matrix: */
-			outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool));
-			for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pM)*pM=outmatrix_rows;
-	if (pN)*pN=outmatrix_cols;
-}
-/*}}}*/
-/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
-void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
-
-	int      i;
-	int      outmatrix_numel,outmatrix_ndims;
-	int*     outmatrix_size=NULL;
-	double*  doublematrix=NULL;
-	bool*    outmatrix=NULL;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_numel=0;
-		outmatrix_ndims=0;
-		outmatrix_size =NULL;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"logical") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*((bool*)mxGetData(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
-			outmatrix_numel=0;
-			outmatrix_ndims=0;
-			outmatrix_size =NULL;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab n-dim array to bool* matrix: */
-			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
-		}
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
-			outmatrix_numel=0;
-			outmatrix_ndims=0;
-			outmatrix_size =NULL;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab n-dim array to double* matrix: */
-			MatlabNArrayToNArray(&doublematrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
-
-			/*Convert double matrix into bool matrix: */
-			outmatrix=(bool*)xmalloc(outmatrix_numel*sizeof(bool));
-			for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
-			xfree((void**)&doublematrix);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-			
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pnumel)*pnumel=outmatrix_numel;
-	if (pndims)*pndims=outmatrix_ndims;
-	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(Mat* pmatrix,const mxArray* dataref){{{1*/
-void FetchData(Mat* pmatrix,const mxArray* dataref){
-	
-	Mat outmatrix=NULL;
-	int dummy=0;
-
-	if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab matrix to petsc matrix: */
-			MatlabMatrixToPetscMatrix(&outmatrix,&dummy,&dummy,dataref);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-}
-/*}}}*/
-/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{1*/
-void FetchData(double** pvector,int* pM,const mxArray* dataref){
-
-	double* outvector=NULL;
-	int outvector_rows;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outvector_rows=0;
-		outvector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to double*  vector: */
-		MatlabVectorToDoubleVector(&outvector,&outvector_rows,dataref);
-
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=outvector;
-	if (pM)*pM=outvector_rows;
-}
-/*}}}*/
-/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{1*/
-void FetchData(int** pvector,int* pM,const mxArray* dataref){
-
-	int    i;
-	double *doublevector   = NULL;
-	int    *outvector      = NULL;
-	int     outvector_rows;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outvector_rows=0;
-		outvector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to double*  vector: */
-		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
-
-		/*Convert double vector into integer vector: */
-		outvector=(int*)xmalloc(outvector_rows*sizeof(int));
-		for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=outvector;
-	if (pM)*pM=outvector_rows;
-}
-/*}}}*/
-/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{1*/
-void FetchData(bool** pvector,int* pM,const mxArray* dataref){
-
-	int    i;
-	double *doublevector   = NULL;
-	bool   *outvector      = NULL;
-	int     outvector_rows;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outvector_rows=0;
-		outvector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to double*  vector: */
-		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
-
-		/*Convert double vector into integer vector: */
-		outvector=(bool*)xmalloc(outvector_rows*sizeof(bool));
-		for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=outvector;
-	if (pM)*pM=outvector_rows;
-}
-/*}}}*/
-/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{1*/
-void FetchData(float** pvector,int* pM,const mxArray* dataref){
-
-	int    i;
-	double *doublevector   = NULL;
-	float  *outvector      = NULL;
-	int     outvector_rows;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outvector_rows=0;
-		outvector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to double*  vector: */
-		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
-
-		/*Convert double vector into float vector: */
-		outvector=(float*)xmalloc(outvector_rows*sizeof(float));
-		for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=outvector;
-	if (pM)*pM=outvector_rows;
-}
-/*}}}*/
-/*FUNCTION FetchData(Vec* pvector,const mxArray* dataref){{{1*/
-void FetchData(Vec* pvector,const mxArray* dataref){
-
-	Vec vector=NULL;
-	int dummy;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		vector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to petsc vector: */
-		MatlabVectorToPetscVector(&vector,&dummy,dataref);
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=vector;
-}
-/*}}}*/
-/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{1*/
-void FetchData(char** pstring,const mxArray* dataref){
-
-	char* outstring=NULL;
-
-
-	/*Ok, the string should be coming directly from the matlab workspace: */
-	if (!mxIsClass(dataref,"char")){
-		_error_("input data_type is not a string!");
-	}
-	else{
-		/*Recover the string:*/
-		int stringlen;
-		
-		stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
-		outstring = (char*)xmalloc(sizeof(mxChar)*stringlen);
-		mxGetString(dataref,outstring,stringlen);
-	}
-
-	/*Assign output pointers:*/
-	*pstring=outstring;
-}
-/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
-void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
-
-	int      outmatrix_numel,outmatrix_ndims;
-	int*     outmatrix_size=NULL;
-	char*    outmatrix=NULL;
-
-	if(mxIsEmpty(dataref) ){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		outmatrix_numel=0;
-		outmatrix_ndims=0;
-		outmatrix_size =NULL;
-		outmatrix=NULL;
-	}
-	else if (mxIsClass(dataref,"char") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
-			outmatrix_numel=0;
-			outmatrix_ndims=0;
-			outmatrix_size =NULL;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab n-dim array to char* matrix: */
-			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-			
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-	if (pnumel)*pnumel=outmatrix_numel;
-	if (pndims)*pndims=outmatrix_ndims;
-	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{1*/
-void FetchData(double* pscalar,const mxArray* dataref){
-
-	double scalar;
-
-	if (!mxIsClass(dataref,"double")){
-		_error_("input data_type is not a double!");
-	}
-	else{
-		/*Recover the double: */
-		scalar=mxGetScalar(dataref);
-	}
-
-	/*Assign output pointers:*/
-	*pscalar=scalar;
-}
-/*}}}*/
-/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{1*/
-void FetchData(int* pinteger,const mxArray* dataref){
-
-	int integer;
-
-	if (!mxIsClass(dataref,"double")){
-		_error_("input data_type is not a scalar!");
-	}
-	else{
-		/*Recover the double: */
-		integer=(int)mxGetScalar(dataref);
-	}
-
-	/*Assign output pointers:*/
-	*pinteger=integer;
-}
-/*}}}*/
-/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{1*/
-void FetchData(bool* pboolean,const mxArray* dataref){
-
-	bool* mxbool_ptr=NULL;
-
-	if (mxIsClass(dataref,"logical")){
-		if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
-		if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
-		mxbool_ptr=mxGetLogicals(dataref);
-	}
-	else{
-		_error_("input data_type is not a bool!");
-	}
-
-	*pboolean=*mxbool_ptr;
-}
-/*}}}*/
-#endif
-
-#if defined(_HAVE_PETSC_)
-/*FUNCTION FetchData(double** pmatrix, int* pM,int* pN,FILE* fid){{{1*/
-void FetchData(double** pmatrix, int* pM,int* pN,FILE* fid){
-
-	extern int my_rank;
-	extern int num_procs;
-
-	/*output: */
-	int M,N;
-	double* matrix=NULL;
-	
-	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
-	/*numberofelements: */
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-
-	/*Now allocate matrix: */
-	if(M*N){
-		matrix=(double*)xmalloc(M*N*sizeof(double));
-
-		/*Read matrix on node 0, then broadcast: */
-		if(my_rank==0){  
-			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
-		}
-		
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-	}
-
-
-	/*Assign output pointers: */
-	*pmatrix=matrix;
-	if (pM)*pM=M;
-	if (pN)*pN=N;
-
-}
-/*}}}*/
-/*FUNCTION FetchData(char** pstring,FILE* fid){{{1*/
-void FetchData(char** pstring,FILE* fid){
-
-	extern int my_rank;
-	extern int num_procs;
-
-	/*output: */
-	char* string=NULL;
-	int   string_size;
-
-	/*We have to read a string from disk. First read the dimensions of the string, then the string: */
-	if(my_rank==0){  
-		if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
-	}
-
-	MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
-
-	/*Now allocate string: */
-	if(string_size){
-		string=(char*)xmalloc((string_size+1)*sizeof(char));
-		string[string_size]='\0';
-
-		/*Read string on node 0, then broadcast: */
-		if(my_rank==0){  
-			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
-		}
-		MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
-	}
-	else{
-		string=(char*)xmalloc(sizeof(char));
-		string[0]='\0';
-	}
-
-
-	/*Assign output pointers: */
-	*pstring=string;
-}
-/*}}}*/
-/*FUNCTION FetchData(double* pscalar,FILE* fid){{{1*/
-void FetchData(double* pscalar,FILE* fid){
-
-	extern int my_rank;
-	extern int num_procs;
-
-	/*output: */
-	double   scalar;
-
-	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
-	if(my_rank==0){
-		if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
-	}
-	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-
-	/*Assign output pointers: */
-	*pscalar=scalar;
-		 
-}
-/*}}}*/
-/*FUNCTION FetchData(int* pinteger,FILE* fid){{{1*/
-void FetchData(int* pinteger,FILE* fid){
-
-	extern int my_rank;
-	extern int num_procs;
-
-	/*output: */
-	int   integer;
-
-	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
-	if(my_rank==0){  
-		if(fread(&integer,sizeof(int),1,fid)!=1) _error_(" could not read integer ");
-	}
-
-	MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
-
-	/*Assign output pointers: */
-	*pinteger=integer;
-
-}
-/*}}}*/
-#endif
Index: sm/trunk/src/c/io/FetchNodeSets.cpp
===================================================================
--- /issm/trunk/src/c/io/FetchNodeSets.cpp	(revision 8909)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/* \file FetchNodeSets.c:
- * \brief: interface for reading nodesets from matlab workspace
- */
-
-#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>
-
-#include "../objects/NodeSets.h"
-#include "./io.h"
-
-void  FetchNodeSets(NodeSets** pnodesets,ConstDataHandle dataref){
-
-	/*output: */
-	NodeSets* nodesets=NULL;
-	double* pv_f=NULL;
-	double* pv_s=NULL;
-	int gsize;
-	int fsize;
-	int ssize;
-
-	if(mxIsEmpty(dataref)){
-		nodesets=NULL;
-	}
-	else{
-
-		FetchData(&pv_f,NULL,mxGetField(dataref,0,"pv_f"));
-		FetchData(&pv_s,NULL,mxGetField(dataref,0,"pv_s"));
-		
-		gsize=(int)mxGetScalar(mxGetField(dataref,0,"gsize"));
-		fsize=(int)mxGetScalar(mxGetField(dataref,0,"fsize"));
-		ssize=(int)mxGetScalar(mxGetField(dataref,0,"ssize"));
-
-		nodesets=new NodeSets( pv_f,pv_s,gsize,fsize,ssize);
-	}
-
-	/*Assign output pointers:*/
-	*pnodesets=nodesets;
-
-}
-#endif
Index: sm/trunk/src/c/io/FetchParams.cpp
===================================================================
--- /issm/trunk/src/c/io/FetchParams.cpp	(revision 8909)
+++ 	(revision )
@@ -1,184 +1,0 @@
-/* \file FetchParams.c:
- * \brief: interface for fetching  matlab parameters into a "C" dataset 
- */
-
-#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>
-#include "./io.h"
-#include "../objects/objects.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-#include "../EnumDefinitions/EnumDefinitions.h"
-
-void FetchParams(Parameters** pparameters, DataHandle dataref){
-
-	int i,j;
-	int count;
-
-	/*output: */
-	Param* param=NULL;
-	Parameters* parameters=NULL;
-
-	/*intermediary: */
-	int M,N;
-	double* tmatrix=NULL;
-	double* matrix=NULL;
-	char**  stringarray=NULL;
-	double** array=NULL;
-	int*     mdims_array=NULL;
-	int*     ndims_array=NULL;
-	int nfields;
-	char* name=NULL;
-	mxArray* pfield=NULL;
-	mxArray* pfield2=NULL;
-	int enum_type;
-
-
-	/*First, create parameters : */
-	parameters=new Parameters();
-
-	/*go through matlab params structure, and create Param object for each field: */
-
-	nfields=mxGetNumberOfFields(dataref);
-
-	for(count=0;count<nfields;count++){
-
-		/*Get i'th field: */
-		name=(char*)mxGetFieldNameByNumber(dataref,count);
-		enum_type=StringToEnumx(name);
-		pfield=mxGetFieldByNumber(dataref,0,count);
-		_assert_(pfield);
-		
-		/*Check type of field: */
-		if (mxIsClass(pfield,"double")){
-			
-			/*could be  DOUBLE, DOUBLEVEC or DOUBLEMAT, depends on dimensions: */
-			M=mxGetM(pfield);
-			N=mxGetN(pfield);
-
-			if (M==0 | N==0){
-				_error_("%s%i (%s) %s%i%s%i%s","array in parameters structure field ",count,name," is of size (",M,",",N,")");
-			}
-			if (M==1 && N==1){
-				/*we have a simple scalar: */
-				param= new DoubleParam(enum_type,*mxGetPr(pfield));
-				parameters->AddObject(param);
-
-			}
-			else{
-				if (N==1){
-					
-					/*vector: */
-					param= new DoubleVecParam(enum_type,mxGetPr(pfield),M);
-					parameters->AddObject(param);
-
-				}
-				else{
-					/*matrix: first, transpose, then plug into Param */
-					matrix=mxGetPr(pfield);
-					tmatrix=(double*)xmalloc(M*N*sizeof(double));
-					for (i=0;i<M;i++){
-						for(j=0;j<N;j++){
-							*(tmatrix+N*i+j)=*(matrix+M*j+i);
-						}
-					}
-
-					param= new DoubleMatParam(enum_type,tmatrix,M,N);
-					parameters->AddObject(param);
-	
-					/*Free ressources:*/
-					xfree((void**)&tmatrix);
-				}
-			}
-
-		}
-		else if (mxIsClass(pfield,"char")){
-			/* we have a string parameter:*/
-			
-			int stringlen;
-			char* string=NULL;
-			
-			stringlen = mxGetM(pfield)*mxGetN(pfield)+1;
-			string = (char*)xmalloc(sizeof(mxChar)*stringlen);
-			mxGetString(pfield,string,stringlen);
-
-			param= new StringParam(enum_type,string);
-			parameters->AddObject(param);
-
-			xfree((void**)&string);
-		}
-		else if (mxIsClass(pfield,"cell")){
-
-			/*This can be a string array, or a matrix array. Check the first 
-			 *element type to decide: */
-			pfield2=mxGetCell(pfield,0);
-			if (mxIsClass(pfield2,"char")){
-				
-				/*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);
-
-			}
-			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));
-
-				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);
-			}
-		}
-		else _error_("%s%i","unknow type in parameters structure field ",i);
-	}
-
-	/*Assign output pointers:*/
-	*pparameters=parameters;
-
-}
-#endif
Index: sm/trunk/src/c/io/IoModelFetchData.cpp
===================================================================
--- /issm/trunk/src/c/io/IoModelFetchData.cpp	(revision 8909)
+++ 	(revision )
@@ -1,125 +1,0 @@
-/*! \file IoModelFetchData.c
- *  \brief: wrapper to the I/O routines, for special processing of the IoModel structure.
- */
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "./io.h"
-
-/*FUNCTION IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){{{1*/
-void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){
-	
-	FILE* fid=NULL;
-	
-	/*Set file pointer to beginning of the data: */
-	fid=SetFilePointerToData(model_handle,data_name);
-	
-	/*Now fetch: */
-	FetchData(pmatrix,pM,pN,fid);
-
-}
-/*}}}*/
-/*FUNCTION IoModelFetchData(char** pstring,FILE* model_handle,char* data_name){{{1*/
-void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name){
-
-	FILE* fid=NULL;
-	
-	/*Set file pointer to beginning of the data: */
-	fid=SetFilePointerToData(model_handle,data_name);
-	
-	/*Now fetch: */
-	FetchData(pstring,fid);
-}
-/*}}}*/
-/*FUNCTION IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name){{{1*/
-void  IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name){
-
-	FILE* fid=NULL;
-	
-	/*Set file pointer to beginning of the data: */
-	fid=SetFilePointerToData(model_handle,data_name);
-	
-	/*Now fetch: */
-	FetchData(pscalar,fid);
-}
-/*}}}*/
-/*FUNCTION IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name){{{1*/
-void  IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name){
-
-	FILE* fid=NULL;
-	
-	/*Set file pointer to beginning of the data: */
-	fid=SetFilePointerToData(model_handle,data_name);
-	
-	/*Now fetch: */
-	FetchData(pinteger,fid);
-}
-/*}}}*/
-/*FUNCTION SetFilePointerToData(FILE* model_handle,char* data_name){{{1*/
-FILE* SetFilePointerToData(FILE* model_handle,char* data_name){
-
-	extern int my_rank;
-	extern int num_procs;
-	
-	int string_size;
-	int record_length;
-	char* string=NULL;
-	char* repository=NULL;
-	FILE* fid=NULL;
-	int found=0;
-
-	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){
-	
-		/*First set FILE* position to the beginning of the file: */
-		fid=(FILE*)model_handle;
-		fseek(fid,0,SEEK_SET);
-
-		/*Now march through file looking for the correct name: */
-		for(;;){
-			/*Read size of first string name: */
-			if(fread(&string_size,sizeof(int),1,fid)==0){
-				/*Ok, we have reached the end of the file. break: */
-				found=0;
-				break;
-			}
-			/*Allocate string of correct size: */
-			string=(char*)xmalloc((string_size+1)*sizeof(char));
-			string[string_size]='\0';
-
-			/*Read string: */
-			if(fread(string,string_size*sizeof(char),1,fid)==0){
-				/*Ok, we have reached the end of the file. break: */
-				found=0;
-				break;
-			}
-			/*Is this the correct string? : */
-			if (strcmp(string,data_name)==0){
-				/*Ok, we have found the correct string. Pass the record length, and break: */
-				fseek(fid,sizeof(int),SEEK_CUR);
-				found=1;
-				break;
-			}
-			else{
-				/*This is not the correct string, read the record length, and skip it: */
-				fread(&record_length,sizeof(int),1,fid);
-				/*skip: */
-				fseek(fid,record_length,SEEK_CUR);
-			}
-			/*Erase string: */
-			xfree((void**)&string);
-		}
-		/*erase string, if we broke from the for() loop:*/
-		xfree((void**)&string);
-	}
-	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
-
-	if(!found)_error_("%s %s ","could not find data with name",data_name);
-
-	return fid;
-}
-/*}}}*/
Index: /issm/trunk/src/c/io/Matlab/FetchMatlabData.cpp
===================================================================
--- /issm/trunk/src/c/io/Matlab/FetchMatlabData.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Matlab/FetchMatlabData.cpp	(revision 8910)
@@ -0,0 +1,736 @@
+/*\file FetchMatlabData.cpp:
+ * \brief: general I/O interface to fetch data in matlab
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+#ifdef _SERIAL_
+#include <mex.h>
+/*FUNCTION FetchMatlabData(DataSet** pdataset,const mxArray* dataref){{{1*/
+void FetchMatlabData(DataSet** pdataset,const mxArray* dataref){
+
+	/*output*/
+	DataSet* outdataset=NULL;
+	char*    outdataset_buffer=NULL;
+	int      outdataset_size;
+
+	/*First, check that our reference is a double, otherwise, error out: */
+	if (mxIsClass(dataref,"double")){
+			
+		/*We need to copy the data pointed by dataref, so that our dataset is not actually a pointer!:*/
+		if (!mxIsEmpty(dataref)){
+			outdataset_buffer=(char*)mxGetPr(dataref);
+			outdataset_size=mxGetM(dataref)*mxGetN(dataref);
+			if(outdataset_size)outdataset=DataSetDemarshall(outdataset_buffer);
+		}
+	}
+	else{
+		if (mxIsEmpty(dataref)){
+			/*Nothing to pick up. Just initialize pointer to NULL, and warn the server we are not uploading anything: */
+			outdataset_size=0;
+			outdataset=NULL;
+		}
+		else{
+			/*This is an error: we don't have the correct input!: */
+			_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		}
+	}
+
+	/*Assign output pointers:*/
+	*pdataset=outdataset;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchMatlabData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	double*  outmatrix=NULL;
+	int      outmatrix_rows,outmatrix_cols;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchMatlabData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	double*  outmatrix=NULL;
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to double* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchMatlabData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	int     i,outmatrix_rows,outmatrix_cols;
+	double *doublematrix=NULL;
+	int    *outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
+
+			/*Convert double matrix into integer matrix: */
+			outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int));
+			for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchMatlabData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	int     i,outmatrix_rows,outmatrix_cols;
+	double *doublematrix=NULL;
+	bool   *outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
+
+			/*Convert double matrix into integer matrix: */
+			outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool));
+			for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	int      i;
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+	double*  doublematrix=NULL;
+	bool*    outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"logical") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*((bool*)mxGetData(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to bool* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to double* matrix: */
+			MatlabNArrayToNArray(&doublematrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+
+			/*Convert double matrix into bool matrix: */
+			outmatrix=(bool*)xmalloc(outmatrix_numel*sizeof(bool));
+			for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
+			xfree((void**)&doublematrix);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(Mat* pmatrix,const mxArray* dataref){{{1*/
+void FetchMatlabData(Mat* pmatrix,const mxArray* dataref){
+	
+	Mat outmatrix=NULL;
+	int dummy=0;
+
+	if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to petsc matrix: */
+			MatlabMatrixToPetscMatrix(&outmatrix,&dummy,&dummy,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){
+
+	double* outvector=NULL;
+	int outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&outvector,&outvector_rows,dataref);
+
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(int** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchMatlabData(int** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	int    *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into integer vector: */
+		outvector=(int*)xmalloc(outvector_rows*sizeof(int));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	bool   *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into integer vector: */
+		outvector=(bool*)xmalloc(outvector_rows*sizeof(bool));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(float** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchMatlabData(float** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	float  *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into float vector: */
+		outvector=(float*)xmalloc(outvector_rows*sizeof(float));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(Vec* pvector,const mxArray* dataref){{{1*/
+void FetchMatlabData(Vec* pvector,const mxArray* dataref){
+
+	Vec vector=NULL;
+	int dummy;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		vector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to petsc vector: */
+		MatlabVectorToPetscVector(&vector,&dummy,dataref);
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=vector;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(char** pstring,const mxArray* dataref){{{1*/
+void FetchMatlabData(char** pstring,const mxArray* dataref){
+
+	char* outstring=NULL;
+
+
+	/*Ok, the string should be coming directly from the matlab workspace: */
+	if (!mxIsClass(dataref,"char")){
+		_error_("input data_type is not a string!");
+	}
+	else{
+		/*Recover the string:*/
+		int stringlen;
+		
+		stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
+		outstring = (char*)xmalloc(sizeof(mxChar)*stringlen);
+		mxGetString(dataref,outstring,stringlen);
+	}
+
+	/*Assign output pointers:*/
+	*pstring=outstring;
+}
+/*FUNCTION FetchMatlabData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchMatlabData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+	char*    outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"char") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to char* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(double* pscalar,const mxArray* dataref){{{1*/
+void FetchMatlabData(double* pscalar,const mxArray* dataref){
+
+	double scalar;
+
+	if (!mxIsClass(dataref,"double")){
+		_error_("input data_type is not a double!");
+	}
+	else{
+		/*Recover the double: */
+		scalar=mxGetScalar(dataref);
+	}
+
+	/*Assign output pointers:*/
+	*pscalar=scalar;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(int* pinteger,const mxArray* dataref){{{1*/
+void FetchMatlabData(int* pinteger,const mxArray* dataref){
+
+	int integer;
+
+	if (!mxIsClass(dataref,"double")){
+		_error_("input data_type is not a scalar!");
+	}
+	else{
+		/*Recover the double: */
+		integer=(int)mxGetScalar(dataref);
+	}
+
+	/*Assign output pointers:*/
+	*pinteger=integer;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(bool* pboolean,const mxArray* dataref){{{1*/
+void FetchMatlabData(bool* pboolean,const mxArray* dataref){
+
+	bool* mxbool_ptr=NULL;
+
+	if (mxIsClass(dataref,"logical")){
+		if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
+		if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
+		mxbool_ptr=mxGetLogicals(dataref);
+	}
+	else{
+		_error_("input data_type is not a bool!");
+	}
+
+	*pboolean=*mxbool_ptr;
+}
+/*}}}*/
+/*FUNCTION FetchMatlabData(Parameters** pparameters, DataHandle dataref){{{1*/
+void FetchMatlabData(Parameters** pparameters, DataHandle dataref){
+
+	int i,j;
+	int count;
+
+	/*output: */
+	Param* param=NULL;
+	Parameters* parameters=NULL;
+
+	/*intermediary: */
+	int M,N;
+	double* tmatrix=NULL;
+	double* matrix=NULL;
+	char**  stringarray=NULL;
+	double** array=NULL;
+	int*     mdims_array=NULL;
+	int*     ndims_array=NULL;
+	int nfields;
+	char* name=NULL;
+	mxArray* pfield=NULL;
+	mxArray* pfield2=NULL;
+	int enum_type;
+
+
+	/*First, create parameters : */
+	parameters=new Parameters();
+
+	/*go through matlab params structure, and create Param object for each field: */
+
+	nfields=mxGetNumberOfFields(dataref);
+
+	for(count=0;count<nfields;count++){
+
+		/*Get i'th field: */
+		name=(char*)mxGetFieldNameByNumber(dataref,count);
+		enum_type=StringToEnumx(name);
+		pfield=mxGetFieldByNumber(dataref,0,count);
+		_assert_(pfield);
+		
+		/*Check type of field: */
+		if (mxIsClass(pfield,"double")){
+			
+			/*could be  DOUBLE, DOUBLEVEC or DOUBLEMAT, depends on dimensions: */
+			M=mxGetM(pfield);
+			N=mxGetN(pfield);
+
+			if (M==0 | N==0){
+				_error_("%s%i (%s) %s%i%s%i%s","array in parameters structure field ",count,name," is of size (",M,",",N,")");
+			}
+			if (M==1 && N==1){
+				/*we have a simple scalar: */
+				param= new DoubleParam(enum_type,*mxGetPr(pfield));
+				parameters->AddObject(param);
+
+			}
+			else{
+				if (N==1){
+					
+					/*vector: */
+					param= new DoubleVecParam(enum_type,mxGetPr(pfield),M);
+					parameters->AddObject(param);
+
+				}
+				else{
+					/*matrix: first, transpose, then plug into Param */
+					matrix=mxGetPr(pfield);
+					tmatrix=(double*)xmalloc(M*N*sizeof(double));
+					for (i=0;i<M;i++){
+						for(j=0;j<N;j++){
+							*(tmatrix+N*i+j)=*(matrix+M*j+i);
+						}
+					}
+
+					param= new DoubleMatParam(enum_type,tmatrix,M,N);
+					parameters->AddObject(param);
+	
+					/*Free ressources:*/
+					xfree((void**)&tmatrix);
+				}
+			}
+
+		}
+		else if (mxIsClass(pfield,"char")){
+			/* we have a string parameter:*/
+			
+			int stringlen;
+			char* string=NULL;
+			
+			stringlen = mxGetM(pfield)*mxGetN(pfield)+1;
+			string = (char*)xmalloc(sizeof(mxChar)*stringlen);
+			mxGetString(pfield,string,stringlen);
+
+			param= new StringParam(enum_type,string);
+			parameters->AddObject(param);
+
+			xfree((void**)&string);
+		}
+		else if (mxIsClass(pfield,"cell")){
+
+			/*This can be a string array, or a matrix array. Check the first 
+			 *element type to decide: */
+			pfield2=mxGetCell(pfield,0);
+			if (mxIsClass(pfield2,"char")){
+				
+				/*string array: */
+				M=mxGetM(pfield);
+				stringarray=(char**)xmalloc(M*sizeof(char*));
+
+				for(i=0;i<M;i++){
+					char* descriptor=NULL;
+					pfield2=mxGetCell(pfield,i);
+					FetchMatlabData(&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);
+
+			}
+			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));
+
+				for(i=0;i<M;i++){
+					double* matrix=NULL;
+					int     m,n;
+					pfield2=mxGetCell(pfield,i);
+					FetchMatlabData(&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);
+			}
+		}
+		else _error_("%s%i","unknow type in parameters structure field ",i);
+	}
+
+	/*Assign output pointers:*/
+	*pparameters=parameters;
+
+}
+/*}}}*/
+#endif
Index: /issm/trunk/src/c/io/Matlab/OptionParse.cpp
===================================================================
--- /issm/trunk/src/c/io/Matlab/OptionParse.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Matlab/OptionParse.cpp	(revision 8910)
@@ -0,0 +1,189 @@
+/*\file OptionParse.c
+ *\brief: functions to parse the mex options.
+ */
+#ifdef HAVE_CONFIG_H
+    #include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "./matlabio.h"
+
+#ifdef _SERIAL_
+#include <mex.h>
+
+/*FUNCTION OptionDoubleParse {{{1*/
+OptionDouble* OptionDoubleParse( char* name, const mxArray* prhs[]){
+
+	OptionDouble *odouble = NULL;
+
+	/*check and parse the name  */
+	odouble=new OptionDouble;
+	odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	strcpy(odouble->name,name);
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"double")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchMatlabData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
+
+	return(odouble);
+}/*}}}*/
+/*FUNCTION OptionLogicalParse {{{1*/
+OptionLogical* OptionLogicalParse( char* name, const mxArray* prhs[]){
+
+	OptionLogical *ological = NULL;
+
+	/*check and parse the name  */
+	ological=new OptionLogical;
+	ological->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	strcpy(ological->name,name);
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"logical")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchMatlabData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
+
+	return(ological);
+}/*}}}*/
+/*FUNCTION OptionCharParse {{{1*/
+OptionChar* OptionCharParse( char* name, const mxArray* prhs[]){
+
+	OptionChar  *ochar = NULL;
+
+	/*check and parse the name  */
+	ochar=new OptionChar;
+	ochar->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	strcpy(ochar->name,name);
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"char")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchMatlabData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
+
+	return(ochar);
+}/*}}}*/
+/*FUNCTION OptionStructParse {{{1*/
+OptionStruct* OptionStructParse( char* name, const mxArray* prhs[]){
+
+	int            i;
+	char           namei[161];
+	OptionStruct  *ostruct    = NULL;
+	Option        *option     = NULL;
+	const mwSize  *ipt        = NULL;
+	const mxArray *structi;
+	mwIndex        sindex;
+
+	/*check and parse the name  */
+	ostruct=new OptionStruct;
+	ostruct->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
+	strcpy(ostruct->name,name);
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"struct")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0]));
+	}
+
+	ostruct->numel=mxGetNumberOfElements(prhs[0]);
+	ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
+	ipt           =mxGetDimensions(prhs[0]);
+	ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int));
+	for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
+	if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *));
+
+	/*loop through and process each element of the struct array  */
+	for (sindex=0; sindex<ostruct->numel; sindex++) {
+		ostruct->values[sindex]=new Options;
+
+		/*loop through and process each field for the element  */
+		for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {
+			sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));
+			structi=mxGetFieldByNumber(prhs[0],sindex,i);
+
+			option=(Option*)OptionParse(namei,&structi);
+			ostruct->values[sindex]->AddObject((Object*)option);
+			option=NULL;
+		}
+	}
+
+	return(ostruct);
+}/*}}}*/
+/*FUNCTION OptionCellParse {{{1*/
+OptionCell* OptionCellParse( char* name, const mxArray* prhs[]){
+
+	int            i;
+	int           *dims;
+	char           namei[161];
+	char           cstr[81];
+	OptionCell    *ocell      = NULL;
+	Option        *option     = NULL;
+	const mwSize  *ipt        = NULL;
+	const mxArray *celli;
+	mwIndex        cindex;
+
+	/*check and parse the name  */
+	ocell=new OptionCell;
+	ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	strcpy(ocell->name,name);
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"cell")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0]));
+	}
+
+	ocell->numel=mxGetNumberOfElements(prhs[0]);
+	ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
+	ipt         =mxGetDimensions(prhs[0]);
+	ocell->size =(int *) xmalloc(ocell->ndims*sizeof(int));
+	for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
+	ocell->values=new Options;
+
+	/*loop through and process each element of the cell array  */
+	dims=(int *) xmalloc(ocell->ndims*sizeof(int));
+	for (cindex=0; cindex<ocell->numel; cindex++) {
+		ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
+		StringFromDims(cstr,dims,ocell->ndims);
+		sprintf(namei,"%s%s",name,cstr);
+		celli=mxGetCell(prhs[0],cindex);
+
+		option=(Option*)OptionParse(namei,&celli);
+		ocell->values->AddObject((Object*)option);
+		option=NULL;
+	}
+	xfree((void**)&dims);
+
+	return(ocell);
+}/*}}}*/
+/*FUNCTION OptionParse{{{1*/
+Option* OptionParse(char* name, const mxArray* prhs[]){
+
+	Option *option = NULL;
+	mxArray       *lhs[1];
+
+	/*parse the value according to the matlab data type  */
+	if     (mxIsClass(prhs[0],"double"))  option=(Option*)OptionDoubleParse(name,prhs);
+	else if(mxIsClass(prhs[0],"logical")) option=(Option*)OptionLogicalParse(name,prhs);
+	else if(mxIsClass(prhs[0],"char"))    option=(Option*)OptionCharParse(name,prhs);
+	else if(mxIsClass(prhs[0],"struct"))  option=(Option*)OptionStructParse(name,prhs);
+	else if(mxIsClass(prhs[0],"cell"))    option=(Option*)OptionCellParse(name,prhs);
+	else {
+		_printf_(true,"  Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct");
+		if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
+			option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
+			mxDestroyArray(lhs[0]);
+		}
+		else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0]));
+	}
+
+	return(option);
+}/*}}}*/
+
+#endif
Index: /issm/trunk/src/c/io/Matlab/WriteMatlabData.cpp
===================================================================
--- /issm/trunk/src/c/io/Matlab/WriteMatlabData.cpp	(revision 8910)
+++ /issm/trunk/src/c/io/Matlab/WriteMatlabData.cpp	(revision 8910)
@@ -0,0 +1,185 @@
+/* \file WriteMatlabData.c:
+ * \brief: general interface for writing data
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+
+#ifdef _SERIAL_
+#include <mex.h>
+
+/*FUNCTION WriteMatlabData(mxArray** pdataref,DataSet* dataset){{{1*/
+void WriteMatlabData(mxArray** pdataref,DataSet* dataset){
+
+	mxArray* dataref=NULL;
+	char* marshalled_dataset=NULL;
+	int   marshalled_dataset_size;
+
+	/*Write a dataset: */
+	if(dataset){
+			/* marshall the dataset: */
+			marshalled_dataset=dataset->Marshall();
+			marshalled_dataset_size=dataset->MarshallSize();
+			
+			dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+			mxSetM(dataref,(mwSize)(marshalled_dataset_size/sizeof(double)));
+			mxSetN(dataref,(mwSize)1);
+			mxSetPr(dataref,(double*)marshalled_dataset);	
+	}
+	else{
+		/* return empty matrix: */
+		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+	
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,Mat matrix){{{1*/
+void WriteMatlabData(mxArray** pdataref,Mat matrix){
+		
+	mxArray* dataref=NULL;
+	
+	if(matrix){
+		
+		/*call toolkit routine: */
+		PetscMatrixToMatlabMatrix(&dataref,matrix);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
+void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){
+	
+	mxArray* dataref=NULL;
+	mxArray* tdataref=NULL;
+		
+	if(matrix){
+		
+		/*data is a double* pointer. Copy into a matrix: */
+		tdataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(tdataref,(mwSize)N);
+		mxSetN(tdataref,(mwSize)M);
+		mxSetPr(tdataref,(double*)matrix);
+
+		//transpose
+		mexCallMATLAB(1,&dataref,1,&tdataref, "transpose");
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,Vec vector){{{1*/
+void WriteMatlabData(mxArray** pdataref,Vec vector){
+	
+	mxArray* dataref=NULL;
+	
+	if(vector){
+		
+		/*call toolkit routine: */
+		PetscVectorToMatlabVector(&dataref,vector);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,double* vector, int M){{{1*/
+void WriteMatlabData(mxArray** pdataref,double* vector, int M){
+	
+	mxArray* dataref=NULL;
+
+	if(vector){
+
+		/*data is a double* pointer. Copy into a vector: */
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,(mwSize)M);
+		mxSetN(dataref,(mwSize)1);
+		mxSetPr(dataref,vector);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,double scalar){{{1*/
+void WriteMatlabData(mxArray** pdataref,double scalar){
+
+	*pdataref=mxCreateDoubleScalar(scalar);
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,int integer){{{1*/
+void WriteMatlabData(mxArray** pdataref,int integer){
+
+		*pdataref=mxCreateDoubleScalar((double)integer);
+
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,int boolean){{{1*/
+void WriteMatlabData(mxArray** pdataref,bool boolean){
+
+	*pdataref=mxCreateDoubleScalar((double)boolean);
+
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,char* string){{{1*/
+void WriteMatlabData(mxArray** pdataref,char* string){
+
+		*pdataref=mxCreateString(string);
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,Parameters* parameters){{{1*/
+void WriteMatlabData(mxArray** pdataref,Parameters* parameters){
+
+	int i;
+
+	/*output: */
+	mxArray* dataref=NULL;
+	mwSize nfields;
+	const	char**	fnames=NULL;
+	mwSize		onebyone[2] = {1,1};
+	mwSize		ndim=2;
+
+	/*intermediary: */
+	Param*      param=NULL;
+
+	/*Recover data from the parameters dataset: */
+	nfields=(mwSize)parameters->Size();
+	fnames=(const char**)xmalloc(nfields*sizeof(char*));
+	
+	/*Build structure in matlab workspace with all the parameter fields: */
+	for(i=0;i<nfields;i++){
+		param=(Param*)parameters->GetObjectByOffset(i);
+		fnames[i]=param->GetParameterName();
+	}
+	/*Initialize structure: */
+	dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
+
+	/*Fill each field: */
+	for(i=0;i<nfields;i++){
+
+		param=(Param*)parameters->GetObjectByOffset(i);
+		param->SetMatlabField(dataref);
+	}
+		
+	/*Assign output pointers:*/
+	*pdataref=dataref;
+
+}
+/*}}}*/
+#endif
Index: /issm/trunk/src/c/io/Matlab/matlabio.h
===================================================================
--- /issm/trunk/src/c/io/Matlab/matlabio.h	(revision 8910)
+++ /issm/trunk/src/c/io/Matlab/matlabio.h	(revision 8910)
@@ -0,0 +1,54 @@
+/*\file matlabio.h
+ *\brief: I/O for ISSM in matlab mode
+ */
+
+#ifndef _MATLAB_IO_H_
+#define _MATLAB_IO_H_
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+class DataSet;
+class Parameters;
+
+#ifdef _SERIAL_
+#include <mex.h>
+void WriteMatlabData(mxArray** pdataref,DataSet* dataset);
+void WriteMatlabData(mxArray** pdataref,Mat matrix);
+void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N);
+void WriteMatlabData(mxArray** pdataref,Vec vector);
+void WriteMatlabData(mxArray** pdataref,double* vector, int M);
+void WriteMatlabData(mxArray** pdataref,int integer);
+void WriteMatlabData(mxArray** pdataref,bool boolean);
+void WriteMatlabData(mxArray** pdataref,double scalar);
+void WriteMatlabData(mxArray** pdataref,char* string);
+void WriteMatlabData(DataHandle* pdataref,Parameters* parameters);
+
+void FetchMatlabData(DataSet** pdataset,const mxArray* dataref);
+void FetchMatlabData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchMatlabData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchMatlabData(int** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchMatlabData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchMatlabData(Mat* pmatrix,const mxArray* dataref);
+void FetchMatlabData(int** pvector,int* pM,const mxArray* dataref);
+void FetchMatlabData(float** pvector,int* pM,const mxArray* dataref);
+void FetchMatlabData(double** pvector,int* pM,const mxArray* dataref);
+void FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref);
+void FetchMatlabData(Vec* pvector,const mxArray* dataref);
+void FetchMatlabData(char** pstring,const mxArray* dataref);
+void FetchMatlabData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchMatlabData(double* pscalar,const mxArray* dataref);
+void FetchMatlabData(int* pinteger,const mxArray* dataref);
+void FetchMatlabData(bool* pbool,const mxArray* dataref);
+void FetchMatlabData(Parameters** pparameters, DataHandle dataref);
+
+Option* OptionParse(char* name, const mxArray* prhs[]);
+OptionDouble*   OptionDoubleParse( char* name, const mxArray* prhs[]);
+OptionLogical*  OptionLogicalParse( char* name, const mxArray* prhs[]);
+OptionChar*     OptionCharParse( char* name, const mxArray* prhs[]);
+OptionStruct*   OptionStructParse( char* name, const mxArray* prhs[]);
+OptionCell*     OptionCellParse( char* name, const mxArray* prhs[]);
+#endif
+#endif	/* _IO_H_ */
Index: sm/trunk/src/c/io/OptionParse.cpp
===================================================================
--- /issm/trunk/src/c/io/OptionParse.cpp	(revision 8909)
+++ 	(revision )
@@ -1,189 +1,0 @@
-/*\file OptionParse.c
- *\brief: functions to parse the mex options.
- */
-#ifdef HAVE_CONFIG_H
-    #include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "./io.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-
-#ifdef _SERIAL_
-#include <mex.h>
-
-/*FUNCTION OptionParse{{{1*/
-Option* OptionParse(char* name, const mxArray* prhs[]){
-
-	Option *option = NULL;
-	mxArray       *lhs[1];
-
-	/*parse the value according to the matlab data type  */
-	if     (mxIsClass(prhs[0],"double"))  option=(Option*)OptionDoubleParse(name,prhs);
-	else if(mxIsClass(prhs[0],"logical")) option=(Option*)OptionLogicalParse(name,prhs);
-	else if(mxIsClass(prhs[0],"char"))    option=(Option*)OptionCharParse(name,prhs);
-	else if(mxIsClass(prhs[0],"struct"))  option=(Option*)OptionStructParse(name,prhs);
-	else if(mxIsClass(prhs[0],"cell"))    option=(Option*)OptionCellParse(name,prhs);
-	else {
-		_printf_(true,"  Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct");
-		if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
-			option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
-			mxDestroyArray(lhs[0]);
-		}
-		else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0]));
-	}
-
-	return(option);
-}/*}}}*/
-/*FUNCTION OptionDoubleParse {{{1*/
-OptionDouble* OptionDoubleParse( char* name, const mxArray* prhs[]){
-
-	OptionDouble *odouble = NULL;
-
-	/*check and parse the name  */
-	odouble=new OptionDouble;
-	odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
-	strcpy(odouble->name,name);
-
-	/*check and parse the value  */
-	if (!mxIsClass(prhs[0],"double")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0]));
-	}
-
-	FetchData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
-
-	return(odouble);
-}/*}}}*/
-/*FUNCTION OptionLogicalParse {{{1*/
-OptionLogical* OptionLogicalParse( char* name, const mxArray* prhs[]){
-
-	OptionLogical *ological = NULL;
-
-	/*check and parse the name  */
-	ological=new OptionLogical;
-	ological->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
-	strcpy(ological->name,name);
-
-	/*check and parse the value  */
-	if (!mxIsClass(prhs[0],"logical")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0]));
-	}
-
-	FetchData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
-
-	return(ological);
-}/*}}}*/
-/*FUNCTION OptionCharParse {{{1*/
-OptionChar* OptionCharParse( char* name, const mxArray* prhs[]){
-
-	OptionChar  *ochar = NULL;
-
-	/*check and parse the name  */
-	ochar=new OptionChar;
-	ochar->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
-	strcpy(ochar->name,name);
-
-	/*check and parse the value  */
-	if (!mxIsClass(prhs[0],"char")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0]));
-	}
-
-	FetchData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
-
-	return(ochar);
-}/*}}}*/
-/*FUNCTION OptionStructParse {{{1*/
-OptionStruct* OptionStructParse( char* name, const mxArray* prhs[]){
-
-	int            i;
-	char           namei[161];
-	OptionStruct  *ostruct    = NULL;
-	Option        *option     = NULL;
-	const mwSize  *ipt        = NULL;
-	const mxArray *structi;
-	mwIndex        sindex;
-
-	/*check and parse the name  */
-	ostruct=new OptionStruct;
-	ostruct->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
-	strcpy(ostruct->name,name);
-
-	/*check and parse the value  */
-	if (!mxIsClass(prhs[0],"struct")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0]));
-	}
-
-	ostruct->numel=mxGetNumberOfElements(prhs[0]);
-	ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
-	ipt           =mxGetDimensions(prhs[0]);
-	ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int));
-	for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
-	if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *));
-
-	/*loop through and process each element of the struct array  */
-	for (sindex=0; sindex<ostruct->numel; sindex++) {
-		ostruct->values[sindex]=new Options;
-
-		/*loop through and process each field for the element  */
-		for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {
-			sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));
-			structi=mxGetFieldByNumber(prhs[0],sindex,i);
-
-			option=(Option*)OptionParse(namei,&structi);
-			ostruct->values[sindex]->AddObject((Object*)option);
-			option=NULL;
-		}
-	}
-
-	return(ostruct);
-}/*}}}*/
-/*FUNCTION OptionCellParse {{{1*/
-OptionCell* OptionCellParse( char* name, const mxArray* prhs[]){
-
-	int            i;
-	int           *dims;
-	char           namei[161];
-	char           cstr[81];
-	OptionCell    *ocell      = NULL;
-	Option        *option     = NULL;
-	const mwSize  *ipt        = NULL;
-	const mxArray *celli;
-	mwIndex        cindex;
-
-	/*check and parse the name  */
-	ocell=new OptionCell;
-	ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
-	strcpy(ocell->name,name);
-
-	/*check and parse the value  */
-	if (!mxIsClass(prhs[0],"cell")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0]));
-	}
-
-	ocell->numel=mxGetNumberOfElements(prhs[0]);
-	ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
-	ipt         =mxGetDimensions(prhs[0]);
-	ocell->size =(int *) xmalloc(ocell->ndims*sizeof(int));
-	for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
-	ocell->values=new Options;
-
-	/*loop through and process each element of the cell array  */
-	dims=(int *) xmalloc(ocell->ndims*sizeof(int));
-	for (cindex=0; cindex<ocell->numel; cindex++) {
-		ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
-		StringFromDims(cstr,dims,ocell->ndims);
-		sprintf(namei,"%s%s",name,cstr);
-		celli=mxGetCell(prhs[0],cindex);
-
-		option=(Option*)OptionParse(namei,&celli);
-		ocell->values->AddObject((Object*)option);
-		option=NULL;
-	}
-	xfree((void**)&dims);
-
-	return(ocell);
-}/*}}}*/
-
-#endif
Index: sm/trunk/src/c/io/WriteData.cpp
===================================================================
--- /issm/trunk/src/c/io/WriteData.cpp	(revision 8909)
+++ 	(revision )
@@ -1,155 +1,0 @@
-/* \file WriteData.c:
- * \brief: general interface for writing data
- */
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "../include/include.h"
-#include "./shared/shared.h"
-#include "./io.h"
-
-#ifdef _SERIAL_
-#include <mex.h>
-/*Several prototypes for WriteData, according to type: */
-/*FUNCTION WriteData(mxArray** pdataref,DataSet* dataset){{{1*/
-void WriteData(mxArray** pdataref,DataSet* dataset){
-
-	mxArray* dataref=NULL;
-	char* marshalled_dataset=NULL;
-	int   marshalled_dataset_size;
-
-	/*Write a dataset: */
-	if(dataset){
-			/* marshall the dataset: */
-			marshalled_dataset=dataset->Marshall();
-			marshalled_dataset_size=dataset->MarshallSize();
-			
-			dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-			mxSetM(dataref,(mwSize)(marshalled_dataset_size/sizeof(double)));
-			mxSetN(dataref,(mwSize)1);
-			mxSetPr(dataref,(double*)marshalled_dataset);	
-	}
-	else{
-		/* return empty matrix: */
-		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-	*pdataref=dataref;
-	
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,Mat matrix){{{1*/
-void WriteData(mxArray** pdataref,Mat matrix){
-		
-	mxArray* dataref=NULL;
-	
-	if(matrix){
-		
-		/*call toolkit routine: */
-		PetscMatrixToMatlabMatrix(&dataref,matrix);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
-void WriteData(mxArray** pdataref,double* matrix, int M,int N){
-	
-	mxArray* dataref=NULL;
-	mxArray* tdataref=NULL;
-		
-	if(matrix){
-		
-		/*data is a double* pointer. Copy into a matrix: */
-		tdataref = mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(tdataref,(mwSize)N);
-		mxSetN(tdataref,(mwSize)M);
-		mxSetPr(tdataref,(double*)matrix);
-
-		//transpose
-		mexCallMATLAB(1,&dataref,1,&tdataref, "transpose");
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,Vec vector){{{1*/
-void WriteData(mxArray** pdataref,Vec vector){
-	
-	mxArray* dataref=NULL;
-	
-	if(vector){
-		
-		/*call toolkit routine: */
-		PetscVectorToMatlabVector(&dataref,vector);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-	*pdataref=dataref;
-
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{1*/
-void WriteData(mxArray** pdataref,double* vector, int M){
-	
-	mxArray* dataref=NULL;
-
-	if(vector){
-
-		/*data is a double* pointer. Copy into a vector: */
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(dataref,(mwSize)M);
-		mxSetN(dataref,(mwSize)1);
-		mxSetPr(dataref,vector);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{1*/
-void WriteData(mxArray** pdataref,double scalar){
-
-	*pdataref=mxCreateDoubleScalar(scalar);
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,int integer){{{1*/
-void WriteData(mxArray** pdataref,int integer){
-
-		*pdataref=mxCreateDoubleScalar((double)integer);
-
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{1*/
-void WriteData(mxArray** pdataref,bool boolean){
-
-	*pdataref=mxCreateDoubleScalar((double)boolean);
-
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,char* string){{{1*/
-void WriteData(mxArray** pdataref,char* string){
-
-		*pdataref=mxCreateString(string);
-}
-/*}}}*/
-
-#else
-/*FUNCTION WriteData(int* pdummy,void* data,char* data_type){{{1*/
-void WriteData(int* pdummy,void* data,char* data_type){
-	
-	/*In parallel mode, WriteData is not used, instead we access the data directly through pointers in the solution sequences. */
-}
-/*}}}*/
-#endif
Index: sm/trunk/src/c/io/WriteNodeSets.cpp
===================================================================
--- /issm/trunk/src/c/io/WriteNodeSets.cpp	(revision 8909)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/* \file WriteNodeSets.c:
- * \brief: interface for writing nodesets to matlab workspace
- */
-
-#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>
-
-#include "../objects/NodeSets.h"
-#include "./io.h"
-#include "../shared/shared.h"
-
-void WriteNodeSets(DataHandle* pdataref,NodeSets* nodesets){
-
-	/*output: */
-	mxArray* dataref=NULL;
-	int gsize=0;
-	int fsize=0;
-	int ssize=0;
-	const mwSize nfields=5;
-	const	char*	fnames[nfields];
-	mwSize		onebyone[2] = {1,1};
-	mwSize		ndim=2;
-
-	
-	/*intermediary: */
-	double* pv_f=NULL;
-	double* pv_s=NULL;
-	mxArray*    field=NULL;
-
-	if(nodesets){
-		/*Recover data from the nodesets class: */
-		gsize=nodesets->GetGSize();
-		fsize=nodesets->GetFSize();
-		ssize=nodesets->GetSSize();
-
-		if(fsize){
-			pv_f=(double*)xmalloc(fsize*sizeof(double));
-			memcpy(pv_f,nodesets->GetPV_F(),fsize*sizeof(double));
-		}
-		if(ssize){
-			pv_s=(double*)xmalloc(ssize*sizeof(double));
-			memcpy(pv_s,nodesets->GetPV_S(),ssize*sizeof(double));
-		}
-
-		/*Build structure in matlab workspace with all these fields: */
-		fnames[0] = "gsize";
-		fnames[1] = "fsize";
-		fnames[2] = "ssize";
-		fnames[3] = "pv_f";
-		fnames[4] = "pv_s";
-
-		dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
-		
-		mxSetField( dataref, 0, "gsize",mxCreateDoubleScalar((double)gsize));
-		mxSetField( dataref, 0, "fsize",mxCreateDoubleScalar((double)fsize));
-		mxSetField( dataref, 0, "ssize",mxCreateDoubleScalar((double)ssize));
-
-		if(fsize){
-			field = mxCreateDoubleMatrix(0,0,mxREAL);
-			mxSetM(field,fsize); mxSetN(field,1); mxSetPr(field,pv_f);
-		}
-		else{
-			field = mxCreateDoubleMatrix(0,0,mxREAL);
-		}
-		mxSetField( dataref, 0, "pv_f",field);
-		
-		if(ssize){
-			field = mxCreateDoubleMatrix(0,0,mxREAL);
-			mxSetM(field,ssize); mxSetN(field,1); mxSetPr(field,pv_s);
-		}
-		else{
-			field = mxCreateDoubleMatrix(0,0,mxREAL);
-		}
-		mxSetField( dataref, 0, "pv_s",field);
-	}
-	else{
-		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	/*Assign output pointers:*/
-	*pdataref=dataref;
-
-}
-#endif
Index: sm/trunk/src/c/io/WriteParams.cpp
===================================================================
--- /issm/trunk/src/c/io/WriteParams.cpp	(revision 8909)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/* \file WriteParams.c:
- * \brief: interface for writing parameters dataset into a matlab structure
- */
-
-#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>
-
-#include "./io.h"
-#include "../objects/objects.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-
-void WriteParams(DataHandle* pdataref,Parameters* parameters){
-
-	int i;
-
-	/*output: */
-	mxArray* dataref=NULL;
-	mwSize nfields;
-	const	char**	fnames=NULL;
-	mwSize		onebyone[2] = {1,1};
-	mwSize		ndim=2;
-
-	/*intermediary: */
-	Param*      param=NULL;
-
-	/*Recover data from the parameters dataset: */
-	nfields=(mwSize)parameters->Size();
-	fnames=(const char**)xmalloc(nfields*sizeof(char*));
-	
-	/*Build structure in matlab workspace with all the parameter fields: */
-	for(i=0;i<nfields;i++){
-		param=(Param*)parameters->GetObjectByOffset(i);
-		fnames[i]=param->GetParameterName();
-	}
-	/*Initialize structure: */
-	dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
-
-	/*Fill each field: */
-	for(i=0;i<nfields;i++){
-
-		param=(Param*)parameters->GetObjectByOffset(i);
-		param->SetMatlabField(dataref);
-	}
-		
-	/*Assign output pointers:*/
-	*pdataref=dataref;
-
-}
-#endif
Index: /issm/trunk/src/c/io/io.h
===================================================================
--- /issm/trunk/src/c/io/io.h	(revision 8909)
+++ /issm/trunk/src/c/io/io.h	(revision 8910)
@@ -6,64 +6,6 @@
 #define _IO_H_
 
-#include "../objects/objects.h"
-#include "../Container/Container.h"
-#include "../include/include.h"
+#include "./Disk/diskio.h"
+#include "./Matlab/matlabio.h"
 
-class DataSet;
-class Parameters;
-
-FILE* pfopen(char* filename,char* format);
-void  pfclose(FILE* fid,char* filename);
-
-void  FetchData(double** pmatrix, int* pM,int* pN,FILE* fid);
-void  FetchData(char** pstring,FILE* fid);
-void  FetchData(double* pscalar,FILE* fid);
-void  FetchData(int* pinteger,FILE* fid);
-
-void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name);
-void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name);
-void  IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name);
-void  IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name);
-FILE* SetFilePointerToData(FILE* model_handle,char* data_name);
-
-#ifdef _SERIAL_
-void WriteData(mxArray** pdataref,DataSet* dataset);
-void WriteData(mxArray** pdataref,Mat matrix);
-void WriteData(mxArray** pdataref,double* matrix, int M,int N);
-void WriteData(mxArray** pdataref,Vec vector);
-void WriteData(mxArray** pdataref,double* vector, int M);
-void WriteData(mxArray** pdataref,int integer);
-void WriteData(mxArray** pdataref,bool boolean);
-void WriteData(mxArray** pdataref,double scalar);
-void WriteData(mxArray** pdataref,char* string);
-void WriteNodeSets(DataHandle* pdataref,NodeSets* nodesets);
-void WriteParams(DataHandle* pdataref,Parameters* parameters);
-
-void FetchData(DataSet** pdataset,const mxArray* dataref);
-void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
-void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
-void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref);
-void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
-void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
-void FetchData(Mat* pmatrix,const mxArray* dataref);
-void FetchData(int** pvector,int* pM,const mxArray* dataref);
-void FetchData(float** pvector,int* pM,const mxArray* dataref);
-void FetchData(double** pvector,int* pM,const mxArray* dataref);
-void FetchData(bool** pvector,int* pM,const mxArray* dataref);
-void FetchData(Vec* pvector,const mxArray* dataref);
-void FetchData(char** pstring,const mxArray* dataref);
-void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
-void FetchData(double* pscalar,const mxArray* dataref);
-void FetchData(int* pinteger,const mxArray* dataref);
-void FetchData(bool* pbool,const mxArray* dataref);
-void FetchNodeSets(NodeSets** pnodesets,ConstDataHandle dataref);
-void FetchParams(Parameters** pparameters, DataHandle dataref);
-
-Option* OptionParse(char* name, const mxArray* prhs[]);
-OptionDouble*   OptionDoubleParse( char* name, const mxArray* prhs[]);
-OptionLogical*  OptionLogicalParse( char* name, const mxArray* prhs[]);
-OptionChar*     OptionCharParse( char* name, const mxArray* prhs[]);
-OptionStruct*   OptionStructParse( char* name, const mxArray* prhs[]);
-OptionCell*     OptionCellParse( char* name, const mxArray* prhs[]);
-#endif
 #endif	/* _IO_H_ */
Index: sm/trunk/src/c/io/pfclose.cpp
===================================================================
--- /issm/trunk/src/c/io/pfclose.cpp	(revision 8909)
+++ 	(revision )
@@ -1,21 +1,0 @@
-/*!\file:  pfclose.cpp
- * \brief fclose wrapper for parallel solution
- */ 
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "stdio.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-
-void pfclose(FILE* fid,char* filename){
-
-	/*Close file handle: */
-	extern int my_rank;
-	_assert_(fid);
-	if(fclose(fid)!=0)_error_("%s%s","could not close file ",filename);
-}
Index: sm/trunk/src/c/io/pfopen.cpp
===================================================================
--- /issm/trunk/src/c/io/pfopen.cpp	(revision 8909)
+++ 	(revision )
@@ -1,26 +1,0 @@
-/*!\file:  pfopen.cpp
- * \brief fopen wrapper for parallel solution
- */ 
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "stdio.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-
-FILE* pfopen(char* filename,char* format){
-
-	FILE* fid=NULL;
-	extern int my_rank;
-	
-	/*Open handle to data on disk: */
-	fid=fopen(filename,format);
-	if(fid==NULL) _error_("%s%s%s","could not open file ",filename," for binary reading or writing"); 
-
-	return fid;
-}
-
Index: /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp	(revision 8909)
+++ /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp	(revision 8910)
@@ -22,12 +22,12 @@
 BamgGeom::BamgGeom(mxArray* matlab_struct){
 
-	FetchData(&this->Vertices,        &this->VerticesSize[0],        &this->VerticesSize[1],        mxGetAssignedField(matlab_struct,0,"Vertices"));
-	FetchData(&this->Edges,           &this->EdgesSize[0],           &this->EdgesSize[1],           mxGetAssignedField(matlab_struct,0,"Edges"));
+	FetchMatlabData(&this->Vertices,        &this->VerticesSize[0],        &this->VerticesSize[1],        mxGetAssignedField(matlab_struct,0,"Vertices"));
+	FetchMatlabData(&this->Edges,           &this->EdgesSize[0],           &this->EdgesSize[1],           mxGetAssignedField(matlab_struct,0,"Edges"));
 	this->TangentAtEdgesSize[0]=0,    this->TangentAtEdgesSize[1]=0;    this->TangentAtEdges=NULL;
-	FetchData(&this->Corners,         &this->CornersSize[0],         &this->CornersSize[1],         mxGetAssignedField(matlab_struct,0,"Corners"));
-	FetchData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetAssignedField(matlab_struct,0,"RequiredVertices"));
-	FetchData(&this->RequiredEdges,   &this->RequiredEdgesSize[0],   &this->RequiredEdgesSize[1],   mxGetAssignedField(matlab_struct,0,"RequiredEdges"));
-	FetchData(&this->CrackedEdges,    &this->CrackedEdgesSize[0],    &this->CrackedEdgesSize[1],    mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
-	FetchData(&this->SubDomains,      &this->SubDomainsSize[0],      &this->SubDomainsSize[1],      mxGetAssignedField(matlab_struct,0,"SubDomains"));
+	FetchMatlabData(&this->Corners,         &this->CornersSize[0],         &this->CornersSize[1],         mxGetAssignedField(matlab_struct,0,"Corners"));
+	FetchMatlabData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetAssignedField(matlab_struct,0,"RequiredVertices"));
+	FetchMatlabData(&this->RequiredEdges,   &this->RequiredEdgesSize[0],   &this->RequiredEdgesSize[1],   mxGetAssignedField(matlab_struct,0,"RequiredEdges"));
+	FetchMatlabData(&this->CrackedEdges,    &this->CrackedEdgesSize[0],    &this->CrackedEdgesSize[1],    mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
+	FetchMatlabData(&this->SubDomains,      &this->SubDomainsSize[0],      &this->SubDomainsSize[1],      mxGetAssignedField(matlab_struct,0,"SubDomains"));
 
 }
Index: /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp	(revision 8909)
+++ /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp	(revision 8910)
@@ -37,7 +37,7 @@
 	int lines,cols;
 
-	FetchData(&this->Vertices,            &this->VerticesSize[0],            &this->VerticesSize[1],            mxGetAssignedField(matlab_struct,0,"Vertices"));
-	FetchData(&this->Edges,               &this->EdgesSize[0],               &this->EdgesSize[1],               mxGetAssignedField(matlab_struct,0,"Edges"));
-	FetchData(&this->Triangles,           &this->TrianglesSize[0],           &this->TrianglesSize[1],           mxGetAssignedField(matlab_struct,0,"Triangles"));
+	FetchMatlabData(&this->Vertices,            &this->VerticesSize[0],            &this->VerticesSize[1],            mxGetAssignedField(matlab_struct,0,"Vertices"));
+	FetchMatlabData(&this->Edges,               &this->EdgesSize[0],               &this->EdgesSize[1],               mxGetAssignedField(matlab_struct,0,"Edges"));
+	FetchMatlabData(&this->Triangles,           &this->TrianglesSize[0],           &this->TrianglesSize[1],           mxGetAssignedField(matlab_struct,0,"Triangles"));
 	this->QuadrilateralsSize[0]=0,        this->QuadrilateralsSize[1]=0;     this->Quadrilaterals=NULL;
 
@@ -45,12 +45,12 @@
 	this->SubDomainsFromGeomSize[0]=0,    this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL;
 	this->CrackedVerticesSize[0]=0,       this->CrackedVerticesSize[1]=0;    this->CrackedVertices=NULL;
-	FetchData(&this->CrackedEdges,        &this->CrackedEdgesSize[0],        &this->CrackedEdgesSize[1],        mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
+	FetchMatlabData(&this->CrackedEdges,        &this->CrackedEdgesSize[0],        &this->CrackedEdgesSize[1],        mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
 
-	FetchData(&this->VerticesOnGeomEdge,  &this->VerticesOnGeomEdgeSize[0],  &this->VerticesOnGeomEdgeSize[1],  mxGetAssignedField(matlab_struct,0,"VerticesOnGeomEdge"));
-	FetchData(&this->VerticesOnGeomVertex,&this->VerticesOnGeomVertexSize[0],&this->VerticesOnGeomVertexSize[1],mxGetAssignedField(matlab_struct,0,"VerticesOnGeomVertex"));
-	FetchData(&this->EdgesOnGeomEdge,     &this->EdgesOnGeomEdgeSize[0],     &this->EdgesOnGeomEdgeSize[1],     mxGetAssignedField(matlab_struct,0,"EdgesOnGeomEdge"));
+	FetchMatlabData(&this->VerticesOnGeomEdge,  &this->VerticesOnGeomEdgeSize[0],  &this->VerticesOnGeomEdgeSize[1],  mxGetAssignedField(matlab_struct,0,"VerticesOnGeomEdge"));
+	FetchMatlabData(&this->VerticesOnGeomVertex,&this->VerticesOnGeomVertexSize[0],&this->VerticesOnGeomVertexSize[1],mxGetAssignedField(matlab_struct,0,"VerticesOnGeomVertex"));
+	FetchMatlabData(&this->EdgesOnGeomEdge,     &this->EdgesOnGeomEdgeSize[0],     &this->EdgesOnGeomEdgeSize[1],     mxGetAssignedField(matlab_struct,0,"EdgesOnGeomEdge"));
 
 	this->IssmEdgesSize[0]=0,             this->IssmEdgesSize[1]=0;          this->IssmEdges=NULL;
-	FetchData(&this->IssmSegments,        &this->IssmSegmentsSize[0],        &this->IssmSegmentsSize[1],        mxGetAssignedField(matlab_struct,0,"IssmSegments"));
+	FetchMatlabData(&this->IssmSegments,        &this->IssmSegmentsSize[0],        &this->IssmSegmentsSize[1],        mxGetAssignedField(matlab_struct,0,"IssmSegments"));
 
 	this->ElementConnectivitySize[0]=0,      this->ElementConnectivitySize[1]=0;      this->ElementConnectivity=NULL;
Index: /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp	(revision 8909)
+++ /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp	(revision 8910)
@@ -45,33 +45,33 @@
 BamgOpts::BamgOpts(mxArray* matlab_struct){
 
-	FetchData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax"));
-	FetchData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff"));
-	FetchData(&this->coeff,mxGetField(matlab_struct,0,"coeff"));
-	FetchData(&this->errg,mxGetField(matlab_struct,0,"errg"));
-	FetchData(&this->gradation,mxGetField(matlab_struct,0,"gradation"));
-	FetchData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype"));
-	FetchData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle"));
-	FetchData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv"));
-	FetchData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv"));
-	FetchData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype"));
-	FetchData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi"));
-	FetchData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth"));
-	FetchData(&this->omega,mxGetField(matlab_struct,0,"omega"));
-	FetchData(&this->power,mxGetField(matlab_struct,0,"power"));
-	FetchData(&this->verbose,mxGetField(matlab_struct,0,"verbose"));
+	FetchMatlabData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax"));
+	FetchMatlabData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff"));
+	FetchMatlabData(&this->coeff,mxGetField(matlab_struct,0,"coeff"));
+	FetchMatlabData(&this->errg,mxGetField(matlab_struct,0,"errg"));
+	FetchMatlabData(&this->gradation,mxGetField(matlab_struct,0,"gradation"));
+	FetchMatlabData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype"));
+	FetchMatlabData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle"));
+	FetchMatlabData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv"));
+	FetchMatlabData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv"));
+	FetchMatlabData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype"));
+	FetchMatlabData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi"));
+	FetchMatlabData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth"));
+	FetchMatlabData(&this->omega,mxGetField(matlab_struct,0,"omega"));
+	FetchMatlabData(&this->power,mxGetField(matlab_struct,0,"power"));
+	FetchMatlabData(&this->verbose,mxGetField(matlab_struct,0,"verbose"));
 
-	FetchData(&this->Crack,mxGetField(matlab_struct,0,"Crack"));
-	FetchData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric"));
-	FetchData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices"));
-	FetchData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners"));
+	FetchMatlabData(&this->Crack,mxGetField(matlab_struct,0,"Crack"));
+	FetchMatlabData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric"));
+	FetchMatlabData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices"));
+	FetchMatlabData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners"));
 
-	FetchData(&this->hmin,mxGetField(matlab_struct,0,"hmin"));
-	FetchData(&this->hmax,mxGetField(matlab_struct,0,"hmax"));
-	FetchData(&this->hminVertices,&this->hminVerticesSize[0],&this->hminVerticesSize[1],mxGetField(matlab_struct,0,"hminVertices"));
-	FetchData(&this->hmaxVertices,&this->hmaxVerticesSize[0],&this->hmaxVerticesSize[1],mxGetField(matlab_struct,0,"hmaxVertices"));
-	FetchData(&this->hVertices,&this->hVerticesSize[0],&this->hVerticesSize[1],mxGetField(matlab_struct,0,"hVertices"));
-	FetchData(&this->metric,&this->metricSize[0],&this->metricSize[1],mxGetField(matlab_struct,0,"metric"));
-	FetchData(&this->field,&this->fieldSize[0],&this->fieldSize[1],mxGetField(matlab_struct,0,"field"));
-	FetchData(&this->err,&this->errSize[0],&this->errSize[1],mxGetField(matlab_struct,0,"err"));
+	FetchMatlabData(&this->hmin,mxGetField(matlab_struct,0,"hmin"));
+	FetchMatlabData(&this->hmax,mxGetField(matlab_struct,0,"hmax"));
+	FetchMatlabData(&this->hminVertices,&this->hminVerticesSize[0],&this->hminVerticesSize[1],mxGetField(matlab_struct,0,"hminVertices"));
+	FetchMatlabData(&this->hmaxVertices,&this->hmaxVerticesSize[0],&this->hmaxVerticesSize[1],mxGetField(matlab_struct,0,"hmaxVertices"));
+	FetchMatlabData(&this->hVertices,&this->hVerticesSize[0],&this->hVerticesSize[1],mxGetField(matlab_struct,0,"hVertices"));
+	FetchMatlabData(&this->metric,&this->metricSize[0],&this->metricSize[1],mxGetField(matlab_struct,0,"metric"));
+	FetchMatlabData(&this->field,&this->fieldSize[0],&this->fieldSize[1],mxGetField(matlab_struct,0,"field"));
+	FetchMatlabData(&this->err,&this->errSize[0],&this->errSize[1],mxGetField(matlab_struct,0,"err"));
 
 	/*Additional checks*/
Index: /issm/trunk/src/mex/AddExternalResult/AddExternalResult.cpp
===================================================================
--- /issm/trunk/src/mex/AddExternalResult/AddExternalResult.cpp	(revision 8909)
+++ /issm/trunk/src/mex/AddExternalResult/AddExternalResult.cpp	(revision 8910)
@@ -19,7 +19,7 @@
 
 	/*Input datasets: */
-	FetchData(&results,RESULTS);
-	FetchData(&type,TYPE);
-	FetchData(&value,&nraws,&ncols,VALUE);
+	FetchMatlabData(&results,RESULTS);
+	FetchMatlabData(&type,TYPE);
+	FetchMatlabData(&value,&nraws,&ncols,VALUE);
 
 	/*results might be NILL, allocate: */
@@ -38,5 +38,5 @@
 
 	/*write output datasets: */
-	WriteData(RESULTSOUT,results);
+	WriteMatlabData(RESULTSOUT,results);
 	
 	/*Free ressources: */
Index: /issm/trunk/src/mex/AverageFilter/AverageFilter.cpp
===================================================================
--- /issm/trunk/src/mex/AverageFilter/AverageFilter.cpp	(revision 8909)
+++ /issm/trunk/src/mex/AverageFilter/AverageFilter.cpp	(revision 8910)
@@ -37,6 +37,6 @@
 
 	/*Fetch data: */
-	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
-	FetchData(&smooth,SMOOTH);
+	FetchMatlabData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchMatlabData(&smooth,SMOOTH);
 	
 	/*Run core hole filler routine: */
@@ -44,5 +44,5 @@
 
 	/* output: */
-	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+	WriteMatlabData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
 
 	/*end module: */
Index: /issm/trunk/src/mex/BamgConvertMesh/BamgConvertMesh.cpp
===================================================================
--- /issm/trunk/src/mex/BamgConvertMesh/BamgConvertMesh.cpp	(revision 8909)
+++ /issm/trunk/src/mex/BamgConvertMesh/BamgConvertMesh.cpp	(revision 8910)
@@ -38,7 +38,7 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs\n");
-	FetchData(&index,&nels,&index_rows,INDEXHANDLE);
-	FetchData(&x,&nods,&x_cols,XHANDLE);
-	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+	FetchMatlabData(&index,&nels,&index_rows,INDEXHANDLE);
+	FetchMatlabData(&x,&nods,&x_cols,XHANDLE);
+	FetchMatlabData(&y,&y_rows,&y_cols,YHANDLE);
 
 	/*Check inputs*/
Index: /issm/trunk/src/mex/Chaco/Chaco.cpp
===================================================================
--- /issm/trunk/src/mex/Chaco/Chaco.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Chaco/Chaco.cpp	(revision 8910)
@@ -74,17 +74,17 @@
 
 	/*Fetch rest of data: */
-	FetchData(&vwgts,&nterms,VWGTS_IN); 
+	FetchMatlabData(&vwgts,&nterms,VWGTS_IN); 
 
-	FetchData(&x,&nterms,X_IN); 
-	FetchData(&y,&nterms,Y_IN); 
-	FetchData(&z,&nterms,Z_IN); 
+	FetchMatlabData(&x,&nterms,X_IN); 
+	FetchMatlabData(&y,&nterms,Y_IN); 
+	FetchMatlabData(&z,&nterms,Z_IN); 
 	
-	FetchData(&in_options,&nterms,OPTNS_IN); 
+	FetchMatlabData(&in_options,&nterms,OPTNS_IN); 
 	for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options
 	
-	FetchData(&npart,NPARTS_IN); 
+	FetchMatlabData(&npart,NPARTS_IN); 
 	nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
 
-	FetchData(&goal,&nterms,GOAL_IN); 
+	FetchMatlabData(&goal,&nterms,GOAL_IN); 
 	
 	/*Some debugging print: {{{*/
@@ -120,5 +120,5 @@
 	doubleassignment=(double*)xmalloc(nvtxs*sizeof(double));
 	for (i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i];
-	WriteData(ASSGN_OUT,doubleassignment,nvtxs);
+	WriteMatlabData(ASSGN_OUT,doubleassignment,nvtxs);
 
 	/*Free ressources:*/
Index: /issm/trunk/src/mex/ComputeBasalStress/ComputeBasalStress.cpp
===================================================================
--- /issm/trunk/src/mex/ComputeBasalStress/ComputeBasalStress.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ComputeBasalStress/ComputeBasalStress.cpp	(revision 8910)
@@ -26,10 +26,10 @@
         
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -42,5 +42,5 @@
 
 	/*write output datasets: */
-	WriteData(SIGMA,sigma_g);
+	WriteMatlabData(SIGMA,sigma_g);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ConfigureObjects/ConfigureObjects.cpp
===================================================================
--- /issm/trunk/src/mex/ConfigureObjects/ConfigureObjects.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ConfigureObjects/ConfigureObjects.cpp	(revision 8910)
@@ -24,10 +24,10 @@
 	
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Configure objects:*/
@@ -35,8 +35,8 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(LOADS,loads);
-	WriteData(NODESOUT,nodes);
-	WriteParams(PARAMETERSOUT,parameters);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(NODESOUT,nodes);
+	WriteMatlabData(PARAMETERSOUT,parameters);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ConstraintsState/ConstraintsState.cpp
===================================================================
--- /issm/trunk/src/mex/ConstraintsState/ConstraintsState.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ConstraintsState/ConstraintsState.cpp	(revision 8910)
@@ -26,10 +26,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -42,7 +42,7 @@
 
 	/*write output datasets: */
-	WriteData(LOADS,loads);
-	WriteData(CONVERGED,converged);
-	WriteData(NUMUNSTABLECONSTRAINTS,num_unstable_constraints);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(CONVERGED,converged);
+	WriteMatlabData(NUMUNSTABLECONSTRAINTS,num_unstable_constraints);
 	
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 8910)
@@ -58,8 +58,8 @@
 
 	/*Fetch inputs: */
-	FetchData(&index,&nel,NULL,INDEXHANDLE);
-	FetchData(&x,&nods,NULL,XHANDLE);
-	FetchData(&y,NULL,NULL,YHANDLE);
-	FetchData(&edgevalue,EDGEVALUEHANDLE);
+	FetchMatlabData(&index,&nel,NULL,INDEXHANDLE);
+	FetchMatlabData(&x,&nods,NULL,XHANDLE);
+	FetchMatlabData(&y,NULL,NULL,YHANDLE);
+	FetchMatlabData(&edgevalue,EDGEVALUEHANDLE);
 
 	//Fetch contours
@@ -78,5 +78,5 @@
 
 	/*Fetch  interptype: */
-	FetchData(&interptype,INTERPTYPEHANDLE);
+	FetchMatlabData(&interptype,INTERPTYPEHANDLE);
 
 	/* Debugging of contours :{{{1*/
@@ -96,12 +96,12 @@
 	/* output: */
 	if (strcmp(interptype,"node")==0){
-		WriteData(PLHS0,in_nod);
+		WriteMatlabData(PLHS0,in_nod);
 	}
 	else if (strcmp(interptype,"element")==0){
-		WriteData(PLHS0,in_elem);
+		WriteMatlabData(PLHS0,in_elem);
 	}
 	else if (strcmp(interptype,"element and node")==0){
-		WriteData(PLHS0,in_nod);
-		WriteData(PLHS1,in_elem);
+		WriteMatlabData(PLHS0,in_nod);
+		WriteMatlabData(PLHS1,in_elem);
 	}
 	else _error_(" wrong interpolation type");
Index: /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 8910)
@@ -52,7 +52,7 @@
 	
 	/*Fetch inputs: */
-	FetchData(&x,&nods,NULL,XHANDLE);
-	FetchData(&y,NULL,NULL,YHANDLE);
-	FetchData(&edgevalue,EDGEVALUEHANDLE);
+	FetchMatlabData(&x,&nods,NULL,XHANDLE);
+	FetchMatlabData(&y,NULL,NULL,YHANDLE);
+	FetchMatlabData(&edgevalue,EDGEVALUEHANDLE);
 
 	//Fetch contours
@@ -95,5 +95,5 @@
 
 	/* output: */
-	WriteData(FLAGS,flags);
+	WriteMatlabData(FLAGS,flags);
 
 	/*end module: */
Index: /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 8910)
@@ -26,11 +26,11 @@
 	
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
-	FetchData(&control_type,CONTROLTYPE);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&control_type,CONTROLTYPE);
 
 	/*configure: */
@@ -44,5 +44,5 @@
 
 	/*write output datasets: */
-	WriteData(GRADIENT,gradient);
+	WriteMatlabData(GRADIENT,gradient);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp	(revision 8910)
@@ -24,12 +24,12 @@
 
 /*Input datasets: */
-FetchData((DataSet**)&elements,ELEMENTSIN);
-FetchData((DataSet**)&nodes,NODESIN);
-FetchData((DataSet**)&vertices,VERTICESIN);
-FetchData((DataSet**)&loads,LOADSIN);
-FetchData((DataSet**)&materials,MATERIALSIN);
-FetchParams(&parameters,PARAMETERSIN);
-FetchData(&control_type,CONTROLTYPE);
-FetchData(&scaling_factor,SCALE);
+FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+FetchMatlabData((DataSet**)&nodes,NODESIN);
+FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+FetchMatlabData((DataSet**)&loads,LOADSIN);
+FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+FetchMatlabData(&parameters,PARAMETERSIN);
+FetchMatlabData(&control_type,CONTROLTYPE);
+FetchMatlabData(&scaling_factor,SCALE);
 
 /*configure: */
@@ -42,10 +42,10 @@
 
 /*write output datasets: */
-WriteData(ELEMENTS,elements);
-WriteData(NODES,nodes);
-WriteData(VERTICES,vertices);
-WriteData(LOADS,loads);
-WriteData(MATERIALS,materials);
-WriteParams(PARAMETERS,parameters);
+WriteMatlabData(ELEMENTS,elements);
+WriteMatlabData(NODES,nodes);
+WriteMatlabData(VERTICES,vertices);
+WriteMatlabData(LOADS,loads);
+WriteMatlabData(MATERIALS,materials);
+WriteMatlabData(PARAMETERS,parameters);
 
 /*Free ressources: */
Index: /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp	(revision 8910)
@@ -24,12 +24,12 @@
 
 /*Input datasets: */
-FetchData((DataSet**)&elements,ELEMENTSIN);
-FetchData((DataSet**)&nodes,NODESIN);
-FetchData((DataSet**)&vertices,VERTICESIN);
-FetchData((DataSet**)&loads,LOADSIN);
-FetchData((DataSet**)&materials,MATERIALSIN);
-FetchParams(&parameters,PARAMETERSIN);
-FetchData(&control_type,CONTROLTYPE);
-FetchData(&gradient,NULL,GRADIENT);
+FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+FetchMatlabData((DataSet**)&nodes,NODESIN);
+FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+FetchMatlabData((DataSet**)&loads,LOADSIN);
+FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+FetchMatlabData(&parameters,PARAMETERSIN);
+FetchMatlabData(&control_type,CONTROLTYPE);
+FetchMatlabData(&gradient,NULL,GRADIENT);
 
 /*configure: */
@@ -42,10 +42,10 @@
 
 /*write output datasets: */
-WriteData(ELEMENTS,elements);
-WriteData(NODES,nodes);
-WriteData(VERTICES,vertices);
-WriteData(LOADS,loads);
-WriteData(MATERIALS,materials);
-WriteParams(PARAMETERS,parameters);
+WriteMatlabData(ELEMENTS,elements);
+WriteMatlabData(NODES,nodes);
+WriteMatlabData(VERTICES,vertices);
+WriteMatlabData(LOADS,loads);
+WriteMatlabData(MATERIALS,materials);
+WriteMatlabData(PARAMETERS,parameters);
 
 /*Free ressources: */
Index: /issm/trunk/src/mex/ControlOptimization/ControlOptimization.cpp
===================================================================
--- /issm/trunk/src/mex/ControlOptimization/ControlOptimization.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ControlOptimization/ControlOptimization.cpp	(revision 8910)
@@ -30,13 +30,13 @@
 
 	/*Input datasets: */
-	FetchData(&function_name,FUNCTIONNAME);
-	FetchData(&xmin,XMIN);
-	FetchData(&xmax,XMAX);
-	FetchData(&tolerance,mxGetField(OPTIONS,0,"TolX"));
-	FetchData(&maxiter,NULL,NULL,mxGetField(OPTIONS,0,"MaxIter"));
+	FetchMatlabData(&function_name,FUNCTIONNAME);
+	FetchMatlabData(&xmin,XMIN);
+	FetchMatlabData(&xmax,XMAX);
+	FetchMatlabData(&tolerance,mxGetField(OPTIONS,0,"TolX"));
+	FetchMatlabData(&maxiter,NULL,NULL,mxGetField(OPTIONS,0,"MaxIter"));
 
 	/*Parameters: */
-	FetchData(&cm_jump,NULL,NULL,mxGetField(PARAMETERS,0,"CmJump"));
-	FetchData(&n_value,STEP);
+	FetchMatlabData(&cm_jump,NULL,NULL,mxGetField(PARAMETERS,0,"CmJump"));
+	FetchMatlabData(&n_value,STEP);
 
 	optargs.function_name=function_name;
@@ -52,6 +52,6 @@
 
 	/*write output : */
-	WriteData(SEARCHSCALAR,search_scalar);
-	WriteData(MISFIT,J);
+	WriteMatlabData(SEARCHSCALAR,search_scalar);
+	WriteMatlabData(MISFIT,J);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/CostFunction/CostFunction.cpp
===================================================================
--- /issm/trunk/src/mex/CostFunction/CostFunction.cpp	(revision 8909)
+++ /issm/trunk/src/mex/CostFunction/CostFunction.cpp	(revision 8910)
@@ -25,10 +25,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -41,5 +41,5 @@
 
 	/*write output : */
-	WriteData(COST,J);
+	WriteMatlabData(COST,J);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp
===================================================================
--- /issm/trunk/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 8909)
+++ /issm/trunk/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 8910)
@@ -21,6 +21,6 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData(&analysis_type,ANALYSISTYPE);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData(&analysis_type,ANALYSISTYPE);
 
 	/*!Reduce vector: */
@@ -28,5 +28,5 @@
 
 	/*write output datasets: */
-	WriteData(YS,ys);
+	WriteMatlabData(YS,ys);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp
===================================================================
--- /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp	(revision 8909)
+++ /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp	(revision 8910)
@@ -31,10 +31,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
 
 	/*number of responses: */
@@ -64,5 +64,5 @@
 
 	/*write output datasets: */
-	WriteData(RESPONSES,responses,numresponses);
+	WriteMatlabData(RESPONSES,responses,numresponses);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Echo/Echo.cpp
===================================================================
--- /issm/trunk/src/mex/Echo/Echo.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Echo/Echo.cpp	(revision 8910)
@@ -17,5 +17,5 @@
 
 	/*Input datasets: */
-	FetchData(&dataset,DATASET);
+	FetchMatlabData(&dataset,DATASET);
 
 	/*Echo dataset: */
Index: /issm/trunk/src/mex/ElementConnectivity/ElementConnectivity.cpp
===================================================================
--- /issm/trunk/src/mex/ElementConnectivity/ElementConnectivity.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ElementConnectivity/ElementConnectivity.cpp	(revision 8910)
@@ -23,6 +23,6 @@
         
 	/*Input datasets: */
-	FetchData(&elements,&nel,NULL,ELEMENTS);
-	FetchData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY);
+	FetchMatlabData(&elements,&nel,NULL,ELEMENTS);
+	FetchMatlabData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY);
 
 	/*!Generate internal degree of freedom numbers: */
@@ -30,5 +30,5 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nel,3);
+	WriteMatlabData(ELEMENTCONNECTIVITY,elementconnectivity,nel,3);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/EnumToString/EnumToString.cpp
===================================================================
--- /issm/trunk/src/mex/EnumToString/EnumToString.cpp	(revision 8909)
+++ /issm/trunk/src/mex/EnumToString/EnumToString.cpp	(revision 8910)
@@ -16,5 +16,5 @@
 
 	/*Fetch inputs: */
-	FetchData(&enum_in,ENUMIN);
+	FetchMatlabData(&enum_in,ENUMIN);
 
 	/*Run core function: */
@@ -22,5 +22,5 @@
 
 	/* output: */
-	WriteData(NAME,name);
+	WriteMatlabData(NAME,name);
 }
 
Index: /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp
===================================================================
--- /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp	(revision 8910)
@@ -35,9 +35,9 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&filexp,EXP_IN);
+	FetchMatlabData(&filexp,EXP_IN);
 	if (verbose) printf("  filexp=\"%s\"\n",filexp);
-	FetchData(&filkml,KML_IN);
+	FetchMatlabData(&filkml,KML_IN);
 	if (verbose) printf("  filkml=\"%s\"\n",filkml);
-	FetchData(&sgn,SGN_IN);
+	FetchMatlabData(&sgn,SGN_IN);
 	if (verbose) printf("  sgn=%d\n",sgn);
 
@@ -76,5 +76,5 @@
 
 	/*Write data: */
-	WriteData(RET_OUT,iret);
+	WriteMatlabData(RET_OUT,iret);
 
 	/*Clean-up*/
Index: /issm/trunk/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp
===================================================================
--- /issm/trunk/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp	(revision 8909)
+++ /issm/trunk/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp	(revision 8910)
@@ -25,10 +25,10 @@
 	
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -41,5 +41,5 @@
 
 	/*write output datasets: */
-	WriteData(UG,ug);
+	WriteMatlabData(UG,ug);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp
===================================================================
--- /issm/trunk/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp	(revision 8909)
+++ /issm/trunk/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp	(revision 8910)
@@ -27,12 +27,12 @@
 	
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
-	FetchData(&name_enum,NAMEENUM);
-	FetchData(&type_enum,TYPEENUM);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&name_enum,NAMEENUM);
+	FetchMatlabData(&type_enum,TYPEENUM);
 
 	/*configure: */
@@ -45,5 +45,5 @@
 
 	/*write output datasets: */
-	WriteData(UG,ug);
+	WriteMatlabData(UG,ug);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Gradj/Gradj.cpp
===================================================================
--- /issm/trunk/src/mex/Gradj/Gradj.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Gradj/Gradj.cpp	(revision 8910)
@@ -26,11 +26,11 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
-	FetchData(&control_type,CONTROLTYPE);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&control_type,CONTROLTYPE);
 
 	/*configure: */
@@ -43,5 +43,5 @@
 
 	/*write output : */
-	WriteData(GRADG,gradient);
+	WriteMatlabData(GRADG,gradient);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/HoleFiller/HoleFiller.cpp
===================================================================
--- /issm/trunk/src/mex/HoleFiller/HoleFiller.cpp	(revision 8909)
+++ /issm/trunk/src/mex/HoleFiller/HoleFiller.cpp	(revision 8910)
@@ -38,6 +38,6 @@
 
 	/*Fetch data: */
-	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
-	FetchData(&smooth_flag,SMOOTH);
+	FetchMatlabData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchMatlabData(&smooth_flag,SMOOTH);
 	
 	/*Get smooth flag setup: */
@@ -51,5 +51,5 @@
 
 	/* output: */
-	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+	WriteMatlabData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
 
 	/*end module: */
Index: /issm/trunk/src/mex/InputControlUpdate/InputControlUpdate.cpp
===================================================================
--- /issm/trunk/src/mex/InputControlUpdate/InputControlUpdate.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputControlUpdate/InputControlUpdate.cpp	(revision 8910)
@@ -24,12 +24,12 @@
 
 /*Input datasets: */
-FetchData((DataSet**)&elements,ELEMENTSIN);
-FetchData((DataSet**)&nodes,NODESIN);
-FetchData((DataSet**)&vertices,VERTICESIN);
-FetchData((DataSet**)&loads,LOADSIN);
-FetchData((DataSet**)&materials,MATERIALSIN);
-FetchParams(&parameters,PARAMETERSIN);
-FetchData(&scalar,SCALAR);
-FetchData(&update,UPDATE);
+FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+FetchMatlabData((DataSet**)&nodes,NODESIN);
+FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+FetchMatlabData((DataSet**)&loads,LOADSIN);
+FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+FetchMatlabData(&parameters,PARAMETERSIN);
+FetchMatlabData(&scalar,SCALAR);
+FetchMatlabData(&update,UPDATE);
 
 /*configure: */
@@ -42,10 +42,10 @@
 
 /*write output datasets: */
-WriteData(ELEMENTS,elements);
-WriteData(NODES,nodes);
-WriteData(VERTICES,vertices);
-WriteData(LOADS,loads);
-WriteData(MATERIALS,materials);
-WriteParams(PARAMETERS,parameters);
+WriteMatlabData(ELEMENTS,elements);
+WriteMatlabData(NODES,nodes);
+WriteMatlabData(VERTICES,vertices);
+WriteMatlabData(LOADS,loads);
+WriteMatlabData(MATERIALS,materials);
+WriteMatlabData(PARAMETERS,parameters);
 
 /*Free ressources: */
Index: /issm/trunk/src/mex/InputConvergence/InputConvergence.cpp
===================================================================
--- /issm/trunk/src/mex/InputConvergence/InputConvergence.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputConvergence/InputConvergence.cpp	(revision 8910)
@@ -35,17 +35,17 @@
 	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InputConvergenceUsage);
 
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
-	FetchData(&double_fields,&numfields,FIELDENUMS);
+	FetchMatlabData(&double_fields,&numfields,FIELDENUMS);
 	field_enums=(int*)xmalloc(numfields*sizeof(int));
 	for(i=0;i<numfields;i++)field_enums[i]=(int)double_fields[i];
 
-	FetchData(&double_criterion,&numcriterions,CRITERIONENUMS);
-	FetchData(&criterion_values,&numcriterions,CRITERIONVALUES);
+	FetchMatlabData(&double_criterion,&numcriterions,CRITERIONENUMS);
+	FetchMatlabData(&criterion_values,&numcriterions,CRITERIONVALUES);
 	criterion_enums=(int*)xmalloc(numcriterions*sizeof(int));
 	for(i=0;i<numcriterions;i++)criterion_enums[i]=(int)double_criterion[i];
@@ -60,5 +60,5 @@
 
 	/*Write output data: */
-	WriteData(CONVERGED,converged);
+	WriteMatlabData(CONVERGED,converged);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputDuplicate/InputDuplicate.cpp
===================================================================
--- /issm/trunk/src/mex/InputDuplicate/InputDuplicate.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputDuplicate/InputDuplicate.cpp	(revision 8910)
@@ -23,13 +23,13 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 	
-	FetchData(&original_enum,ORIGINALENUM);
-	FetchData(&new_enum,NEWENUM);
+	FetchMatlabData(&original_enum,ORIGINALENUM);
+	FetchMatlabData(&new_enum,NEWENUM);
 
 	/*!Call core code: */
@@ -37,5 +37,5 @@
 
 	/*write output : */
-	WriteData(ELEMENTSOUT,elements);
+	WriteMatlabData(ELEMENTSOUT,elements);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputScale/InputScale.cpp
===================================================================
--- /issm/trunk/src/mex/InputScale/InputScale.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputScale/InputScale.cpp	(revision 8910)
@@ -24,13 +24,13 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 	
-	FetchData(&enum_type,ENUMTYPE);
-	FetchData(&scale_factor,SCALEFACTOR);
+	FetchMatlabData(&enum_type,ENUMTYPE);
+	FetchMatlabData(&scale_factor,SCALEFACTOR);
 
 	/*configure: */
@@ -43,5 +43,5 @@
 
 	/*write output : */
-	WriteData(ELEMENTSOUT,elements);
+	WriteMatlabData(ELEMENTSOUT,elements);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputToResult/InputToResult.cpp
===================================================================
--- /issm/trunk/src/mex/InputToResult/InputToResult.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputToResult/InputToResult.cpp	(revision 8910)
@@ -28,12 +28,12 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 	
-	FetchData(&enum_type,ENUMTYPE);
+	FetchMatlabData(&enum_type,ENUMTYPE);
 
 	/*configure: */
@@ -43,6 +43,6 @@
 
 	if(nrhs==9){
-		FetchData(&step,STEP);
-		FetchData(&time,TIME);
+		FetchMatlabData(&step,STEP);
+		FetchMatlabData(&time,TIME);
 
 		/*!Call core code: */
@@ -56,5 +56,5 @@
 
 	/*write output : */
-	WriteData(ELEMENTSOUT,elements);
+	WriteMatlabData(ELEMENTSOUT,elements);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputUpdateFromConstant/InputUpdateFromConstant.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromConstant/InputUpdateFromConstant.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputUpdateFromConstant/InputUpdateFromConstant.cpp	(revision 8910)
@@ -24,12 +24,12 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
-	FetchData(&constant,CONSTANT);
-	FetchData(&name,NAME);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
+	FetchMatlabData(&constant,CONSTANT);
+	FetchMatlabData(&name,NAME);
 
 	/*configure: */
@@ -42,6 +42,6 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(LOADS,loads);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(LOADS,loads);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 8910)
@@ -30,12 +30,12 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
 	/*dakota input: */
-	FetchData(&variables,&numvariables,VARIABLES);
+	FetchMatlabData(&variables,&numvariables,VARIABLES);
 
 	variables_descriptors=(char**)xmalloc(numvariables*sizeof(char*));
@@ -60,7 +60,7 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(LOADS,loads);
-	WriteData(MATERIALS,materials);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(MATERIALS,materials);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 8910)
@@ -23,11 +23,11 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
-	FetchData(&solution,SOLUTION);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
+	FetchMatlabData(&solution,SOLUTION);
 
 	/*configure: */
@@ -40,6 +40,6 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(MATERIALS,materials);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(MATERIALS,materials);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputUpdateFromVector/InputUpdateFromVector.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromVector/InputUpdateFromVector.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InputUpdateFromVector/InputUpdateFromVector.cpp	(revision 8910)
@@ -26,13 +26,13 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
-	FetchData(&vector,&dummy,VECTOR);
-	FetchData(&name,NAME);
-	FetchData(&type,TYPE);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
+	FetchMatlabData(&vector,&dummy,VECTOR);
+	FetchMatlabData(&name,NAME);
+	FetchMatlabData(&type,TYPE);
 
 	/*Check that type is one of Constant, Vertex or Element: */
@@ -50,10 +50,10 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(NODES,nodes);
-	WriteData(VERTICES,vertices);
-	WriteData(LOADS,loads);
-	WriteData(MATERIALS,materials);
-	WriteParams(PARAMETERS,parameters);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(NODES,nodes);
+	WriteMatlabData(VERTICES,vertices);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(MATERIALS,materials);
+	WriteMatlabData(PARAMETERS,parameters);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InternalFront/InternalFront.cpp
===================================================================
--- /issm/trunk/src/mex/InternalFront/InternalFront.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InternalFront/InternalFront.cpp	(revision 8910)
@@ -25,11 +25,11 @@
 
 	/*Fetch required fields*/
-	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	FetchMatlabData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
 	if(numberofelements<=0) _error_("No elements found in the model");
-	FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
+	FetchMatlabData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
 	if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
-	FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
+	FetchMatlabData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
 	if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
-	FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
+	FetchMatlabData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
 	if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
 
@@ -87,5 +87,5 @@
 
 	/*write output datasets: */
-	WriteData(FRONT,front2,numberofsegments,4);
+	WriteMatlabData(FRONT,front2,numberofsegments,4);
 
 	/*end module: */
Index: /issm/trunk/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/trunk/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 8910)
@@ -50,14 +50,14 @@
 
 	/*Input datasets: */
-	FetchData(&x,&x_rows,NULL,XHANDLE);
-	FetchData(&y,&y_rows,NULL,YHANDLE);
-	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
-	FetchData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
-	FetchData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
-	FetchData(&default_value,DEFAULTHANDLE);
+	FetchMatlabData(&x,&x_rows,NULL,XHANDLE);
+	FetchMatlabData(&y,&y_rows,NULL,YHANDLE);
+	FetchMatlabData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchMatlabData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
+	FetchMatlabData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
+	FetchMatlabData(&default_value,DEFAULTHANDLE);
 
 	/* Run core computations: */
 	if(nrhs==7){
-		FetchData(&interpolationenum,INTERPENUM);
+		FetchMatlabData(&interpolationenum,INTERPENUM);
 		InterpFromGridToMeshx(&data_mesh, x, x_rows,  y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationenum);
 	}
@@ -67,5 +67,5 @@
 
 	/*Write data: */
-	WriteData(DATAMESH,data_mesh);
+	WriteMatlabData(DATAMESH,data_mesh);
 
 	/*end module: */
Index: /issm/trunk/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/trunk/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 8910)
@@ -77,14 +77,14 @@
 
 	/*Input datasets: */
-	FetchData(&index_data,&index_data_rows,&dummy,INDEXHANDLE);
-	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
-	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
-	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
-	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
-	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+	FetchMatlabData(&index_data,&index_data_rows,&dummy,INDEXHANDLE);
+	FetchMatlabData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchMatlabData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchMatlabData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchMatlabData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchMatlabData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
 
 	if(nrhs>=7){
 		/*default values: */
-		FetchData(&default_values,&num_default_values,DEFAULTHANDLE);
+		FetchMatlabData(&default_values,&num_default_values,DEFAULTHANDLE);
 	}
 	else{
@@ -146,5 +146,5 @@
 
 	/*Write data: */
-	WriteData(DATAPRIME,data_prime);
+	WriteMatlabData(DATAPRIME,data_prime);
 
 	/*end module: */
Index: /issm/trunk/src/mex/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp
===================================================================
--- /issm/trunk/src/mex/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 8910)
@@ -35,15 +35,15 @@
 
 	/*Input datasets: */
-	FetchData(&index,&nel,NULL,INDEX);
-	FetchData(&x,&nods,NULL,X);
-	FetchData(&y,NULL,NULL,Y);
-	FetchData(&meshdata,&meshdata_length,NULL,MESHDATA);
-	FetchData(&cornereast,CORNEREAST);
-	FetchData(&cornernorth,CORNERNORTH);
-	FetchData(&xposting,XPOSTING);
-	FetchData(&yposting,YPOSTING);
-	FetchData(&nlines,NLINES);
-	FetchData(&ncols,NCOLS);
-	FetchData(&default_value,DEFAULTVALUE);
+	FetchMatlabData(&index,&nel,NULL,INDEX);
+	FetchMatlabData(&x,&nods,NULL,X);
+	FetchMatlabData(&y,NULL,NULL,Y);
+	FetchMatlabData(&meshdata,&meshdata_length,NULL,MESHDATA);
+	FetchMatlabData(&cornereast,CORNEREAST);
+	FetchMatlabData(&cornernorth,CORNERNORTH);
+	FetchMatlabData(&xposting,XPOSTING);
+	FetchMatlabData(&yposting,YPOSTING);
+	FetchMatlabData(&nlines,NLINES);
+	FetchMatlabData(&ncols,NCOLS);
+	FetchMatlabData(&default_value,DEFAULTVALUE);
 
 	/*Call core of computation: */
@@ -51,7 +51,7 @@
 
 	/*Write results: */
-	WriteData(XM,x_m,ncols+1);
-	WriteData(YM,y_m,nlines+1);
-	WriteData(GRIDDATA,griddata,nlines,ncols);
+	WriteMatlabData(XM,x_m,ncols+1);
+	WriteMatlabData(YM,y_m,nlines+1);
+	WriteMatlabData(GRIDDATA,griddata,nlines,ncols);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/trunk/src/mex/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 8910)
@@ -61,10 +61,10 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs\n");
-	FetchData(&index,&nels_data,&index_cols,INDEXHANDLE);
-	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
-	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
-	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
-	FetchData(&x_interp,&x_interp_rows,NULL,XINTERPHANDLE);
-	FetchData(&y_interp,&y_interp_rows,NULL,YINTERPHANDLE);
+	FetchMatlabData(&index,&nels_data,&index_cols,INDEXHANDLE);
+	FetchMatlabData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchMatlabData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchMatlabData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchMatlabData(&x_interp,&x_interp_rows,NULL,XINTERPHANDLE);
+	FetchMatlabData(&y_interp,&y_interp_rows,NULL,YINTERPHANDLE);
 
 	if(nrhs==8){
@@ -74,5 +74,5 @@
 
 		/*default values: */
-		FetchData(&default_values,&num_default_values,DEFAULTHANDLE);
+		FetchMatlabData(&default_values,&num_default_values,DEFAULTHANDLE);
 
 		/*contours: */
@@ -129,5 +129,5 @@
 
 	/*Write data: */
-	WriteData(DATAINTERP,data_interp,nods_interp,data_cols);
+	WriteMatlabData(DATAINTERP,data_interp,nods_interp,data_cols);
 
 	/*end module: */
Index: /issm/trunk/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/trunk/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 8909)
+++ /issm/trunk/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 8910)
@@ -64,13 +64,13 @@
 
 	/*Input datasets: */
-	FetchData(&index_data,&index_data_rows,NULL,INDEXHANDLE);
-	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
-	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
-	FetchData(&z_data,&z_data_rows,NULL,ZHANDLE);
-	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
-	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
-	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
-	FetchData(&z_prime,&z_prime_rows,NULL,ZPRIMEHANDLE);
-	FetchData(&default_value,DEFAULTHANDLE);
+	FetchMatlabData(&index_data,&index_data_rows,NULL,INDEXHANDLE);
+	FetchMatlabData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchMatlabData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchMatlabData(&z_data,&z_data_rows,NULL,ZHANDLE);
+	FetchMatlabData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchMatlabData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchMatlabData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+	FetchMatlabData(&z_prime,&z_prime_rows,NULL,ZPRIMEHANDLE);
+	FetchMatlabData(&default_value,DEFAULTHANDLE);
 
 	/*some checks*/
@@ -90,5 +90,5 @@
 
 	/*Write data: */
-	WriteData(DATAPRIME,data_prime);
+	WriteMatlabData(DATAPRIME,data_prime);
 
 	/*end module: */
Index: /issm/trunk/src/mex/KMLMeshWrite/KMLFileRead.cpp
===================================================================
--- /issm/trunk/src/mex/KMLMeshWrite/KMLFileRead.cpp	(revision 8909)
+++ /issm/trunk/src/mex/KMLMeshWrite/KMLFileRead.cpp	(revision 8910)
@@ -67,5 +67,5 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&filnam,FILENAME);
+	FetchMatlabData(&filnam,FILENAME);
 	if (verbose) printf("  filnam =\"%s\"\n",filnam);
 
@@ -112,5 +112,5 @@
 
 	/*Write data: */
-	WriteData(ERRORFLAG,ierror);
+	WriteMatlabData(ERRORFLAG,ierror);
 
 	/*Clean-up*/
Index: /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp	(revision 8909)
+++ /issm/trunk/src/mex/KMLMeshWrite/KMLMeshWrite.cpp	(revision 8910)
@@ -62,5 +62,5 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&name,NAME);
+	FetchMatlabData(&name,NAME);
 	if (verbose) printf("  name   =\"%s\"\n",name);
 
@@ -84,25 +84,25 @@
 	}
 	else
-		FetchData(&notes,NOTES);
+		FetchMatlabData(&notes,NOTES);
 	if (verbose) printf("  notes  =\"%s\"\n",notes);
 
-	FetchData(&elem,&melem,&nelem,ELEMHANDLE);
+	FetchMatlabData(&elem,&melem,&nelem,ELEMHANDLE);
 	if (verbose) printf("  elem   =size [%d x %d]\n",melem,nelem);
-	FetchData(&nodecon,&mncon,&nncon,NODECONHANDLE);
+	FetchMatlabData(&nodecon,&mncon,&nncon,NODECONHANDLE);
 	if (verbose) printf("  nodecon=size [%d x %d]\n",mncon,nncon);
-	FetchData(&lat,&mlat,&nlat,LATHANDLE);
+	FetchMatlabData(&lat,&mlat,&nlat,LATHANDLE);
 	llat=mlat*nlat;
 	if (verbose) printf("  lat    =length [%d]\n",llat);
-	FetchData(&lng,&mlng,&nlng,LNGHANDLE);
+	FetchMatlabData(&lng,&mlng,&nlng,LNGHANDLE);
 	llng=mlng*nlng;
 	if (verbose) printf("  lng    =length [%d]\n",llng);
-	FetchData(&part,&mprt,&nprt,PARTHANDLE);
+	FetchMatlabData(&part,&mprt,&nprt,PARTHANDLE);
 	lprt=mprt*nprt;
 	if (verbose) printf("  part   =length [%d]\n",lprt);
-	FetchData(&data,&mdata,&ndata,DATAHANDLE);
+	FetchMatlabData(&data,&mdata,&ndata,DATAHANDLE);
 	if (verbose) printf("  data   =size [%d x %d]\n",mdata,ndata);
-	FetchData(&cmap,&mcmap,&ncmap,CMAPHANDLE);
+	FetchMatlabData(&cmap,&mcmap,&ncmap,CMAPHANDLE);
 	if (verbose) printf("  cmap   =size [%d x %d]\n",mcmap,ncmap);
-	FetchData(&filnam,FILENAME);
+	FetchMatlabData(&filnam,FILENAME);
 	if (verbose) printf("  filnam =\"%s\"\n",filnam);
 
@@ -160,5 +160,5 @@
 
 	/*Write data: */
-	WriteData(ERRORFLAG,ierror);
+	WriteMatlabData(ERRORFLAG,ierror);
 
 	/*Clean-up*/
Index: /issm/trunk/src/mex/KMLOverlay/KMLOverlay.cpp
===================================================================
--- /issm/trunk/src/mex/KMLOverlay/KMLOverlay.cpp	(revision 8909)
+++ /issm/trunk/src/mex/KMLOverlay/KMLOverlay.cpp	(revision 8910)
@@ -41,5 +41,5 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&filkml,FILENAME);
+	FetchMatlabData(&filkml,FILENAME);
 	if (verbose) printf("  filkml=\"%s\"\n",filkml);
 
@@ -109,5 +109,5 @@
 
 	/*Write data: */
-	WriteData(ERRORFLAG,ierror);
+	WriteMatlabData(ERRORFLAG,ierror);
 
 	/*Clean-up*/
Index: /issm/trunk/src/mex/Ll2xy/Ll2xy.cpp
===================================================================
--- /issm/trunk/src/mex/Ll2xy/Ll2xy.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Ll2xy/Ll2xy.cpp	(revision 8910)
@@ -35,15 +35,15 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&lat,&nlat,LAT_IN);
+	FetchMatlabData(&lat,&nlat,LAT_IN);
 	if (verbose)
 		if   (nlat == 1) printf("  lat=%g\n",lat[0]);
 		else             printf("  lat=[%d values]\n",nlat);
 //	for (i=0; i<nlat; i++) printf("  lat[%d]=%g\n",i,lat[i]);
-	FetchData(&lon,&nlon,LON_IN);
+	FetchMatlabData(&lon,&nlon,LON_IN);
 	if (verbose)
 		if   (nlon == 1) printf("  lon=%g\n",lon[0]);
 		else             printf("  lon=[%d values]\n",nlon);
 //	for (i=0; i<nlon; i++) printf("  lon[%d]=%g\n",i,lon[i]);
-	FetchData(&sgn,SGN_IN);
+	FetchMatlabData(&sgn,SGN_IN);
 	if (verbose) printf("  sgn=%d\n",sgn);
 
@@ -84,6 +84,6 @@
 
 	/*Write data: */
-	WriteData(X_OUT,x,ncoord);
-	WriteData(Y_OUT,y,ncoord);
+	WriteMatlabData(X_OUT,x,ncoord);
+	WriteMatlabData(Y_OUT,y,ncoord);
 
 	/*Clean-up*/
Index: /issm/trunk/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp
===================================================================
--- /issm/trunk/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 8910)
@@ -27,8 +27,8 @@
 
 	/*Input datasets: */
-	FetchData(&uf,UF);
-	FetchData(&ys,YS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData(&uf,UF);
+	FetchMatlabData(&ys,YS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Reduce vector: */
@@ -37,10 +37,10 @@
 	}
 	else{
-		FetchData(&flag_ys0,YSFLAG);
+		FetchMatlabData(&flag_ys0,YSFLAG);
 		Mergesolutionfromftogx(&ug, uf,ys,nodes,parameters,flag_ys0);
 	}
 
 	/*write output datasets: */
-	WriteData(UG,ug);
+	WriteMatlabData(UG,ug);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/MeshPartition/MeshPartition.cpp
===================================================================
--- /issm/trunk/src/mex/MeshPartition/MeshPartition.cpp	(revision 8909)
+++ /issm/trunk/src/mex/MeshPartition/MeshPartition.cpp	(revision 8910)
@@ -57,18 +57,18 @@
 
 	/*Fetch data: */
-	FetchData(&dim,mxGetAssignedField(MODEL,0,"dim"));
-	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
-	FetchData(&numberofnodes,mxGetAssignedField(MODEL,0,"numberofnodes"));
-	FetchData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements"));
+	FetchMatlabData(&dim,mxGetAssignedField(MODEL,0,"dim"));
+	FetchMatlabData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	FetchMatlabData(&numberofnodes,mxGetAssignedField(MODEL,0,"numberofnodes"));
+	FetchMatlabData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements"));
 
 	if (dim==3){
 	
-		FetchData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d"));
-		FetchData(&numberofnodes2d,mxGetAssignedField(MODEL,0,"numberofnodes2d"));
-		FetchData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d"));
+		FetchMatlabData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d"));
+		FetchMatlabData(&numberofnodes2d,mxGetAssignedField(MODEL,0,"numberofnodes2d"));
+		FetchMatlabData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d"));
 
 	}
-	FetchData(&numlayers,mxGetAssignedField(MODEL,0,"numlayers"));
-	FetchData(&numareas,NUMAREAS);
+	FetchMatlabData(&numlayers,mxGetAssignedField(MODEL,0,"numlayers"));
+	FetchMatlabData(&numareas,NUMAREAS);
 
 	/*Run partitioning algorithm based on a "clever" use of the Metis partitioner: */
@@ -89,6 +89,6 @@
 
 	/*Write data:*/
-	WriteData(ELEMENTPARTITIONING,element_partitioning,numberofelements);
-	WriteData(NODEPARTITIONING,node_partitioning,numberofnodes);
+	WriteMatlabData(ELEMENTPARTITIONING,element_partitioning,numberofelements);
+	WriteMatlabData(NODEPARTITIONING,node_partitioning,numberofnodes);
 	
 	/*Free ressources:*/
Index: /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 8909)
+++ /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 8910)
@@ -53,5 +53,5 @@
 	/*Fetch inputs: */
 	//index
-	FetchData(&double_index,&nel,&dummy,INDEX);
+	FetchMatlabData(&double_index,&nel,&dummy,INDEX);
 	if(dummy!=3)_error_(" element triangulation should be of 3 column width!");
 	index=(int*)xmalloc(nel*3*sizeof(int));
@@ -62,6 +62,6 @@
 	}
 	//x and y
-	FetchData(&x,&nods,X);
-	FetchData(&y,&dummy,Y);
+	FetchMatlabData(&x,&nods,X);
+	FetchMatlabData(&y,&dummy,Y);
 
 	//contours
@@ -94,5 +94,5 @@
 
 	/* output: */
-	WriteData(SEGMENTS,segments,numsegs,5);
+	WriteMatlabData(SEGMENTS,segments,numsegs,5);
 
 	/*end module: */
Index: /issm/trunk/src/mex/ModelProcessor/ModelProcessor.cpp
===================================================================
--- /issm/trunk/src/mex/ModelProcessor/ModelProcessor.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ModelProcessor/ModelProcessor.cpp	(revision 8910)
@@ -34,10 +34,10 @@
 	
 	/*open file input for reading: */
-	FetchData(&inputfilename,INPUTFILE);
+	FetchMatlabData(&inputfilename,INPUTFILE);
 	IOMODEL= pfopen(inputfilename ,"rb");
 
 	/*retrieve solution type and analyses: */
-	FetchData(&solution_type,SOLUTIONTYPE);
-	FetchData(&double_analyses,&numanalyses,ANALYSES);
+	FetchMatlabData(&solution_type,SOLUTIONTYPE);
+	FetchMatlabData(&double_analyses,&numanalyses,ANALYSES);
 	analyses=(int*)xmalloc(numanalyses*sizeof(int));
 	for(i=0;i<numanalyses;i++)analyses[i]=(int)double_analyses[i];
@@ -47,11 +47,11 @@
 
 	/*Write output data: */
-	WriteData(ELEMENTS,elements);
-	WriteData(NODES,nodes);
-	WriteData(VERTICES,vertices);
-	WriteData(CONSTRAINTS,constraints);
-	WriteData(LOADS,loads);
-	WriteData(MATERIALS,materials);
-	WriteParams(PARAMETERS,parameters);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(NODES,nodes);
+	WriteMatlabData(VERTICES,vertices);
+	WriteMatlabData(CONSTRAINTS,constraints);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(MATERIALS,materials);
+	WriteMatlabData(PARAMETERS,parameters);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/NodeConnectivity/NodeConnectivity.cpp
===================================================================
--- /issm/trunk/src/mex/NodeConnectivity/NodeConnectivity.cpp	(revision 8909)
+++ /issm/trunk/src/mex/NodeConnectivity/NodeConnectivity.cpp	(revision 8910)
@@ -22,6 +22,6 @@
         
 	/*Input datasets: */
-	FetchData(&elements,&nel,NULL,ELEMENTS);
-	FetchData(&nods,NUMNODES);
+	FetchMatlabData(&elements,&nel,NULL,ELEMENTS);
+	FetchMatlabData(&nods,NUMNODES);
 
 	/*!Generate internal degree of freedom numbers: */
@@ -29,5 +29,5 @@
 
 	/*write output datasets: */
-	WriteData(CONNECTIVITY,connectivity,nods,width);
+	WriteMatlabData(CONNECTIVITY,connectivity,nods,width);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/NodesDof/NodesDof.cpp
===================================================================
--- /issm/trunk/src/mex/NodesDof/NodesDof.cpp	(revision 8909)
+++ /issm/trunk/src/mex/NodesDof/NodesDof.cpp	(revision 8910)
@@ -19,6 +19,6 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*find analysis_type: */
@@ -29,5 +29,5 @@
 
 	/*write output datasets: */
-	WriteData(NODES,nodes);
+	WriteMatlabData(NODES,nodes);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Orth/Orth.cpp
===================================================================
--- /issm/trunk/src/mex/Orth/Orth.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Orth/Orth.cpp	(revision 8910)
@@ -21,6 +21,6 @@
 
 	/*Input datasets: */
-	FetchData(&gradj,GRADJ);
-	FetchData(&oldgradj,OLDGRADJ);
+	FetchMatlabData(&gradj,GRADJ);
+	FetchMatlabData(&oldgradj,OLDGRADJ);
 
 	/*!Reduce load from g to f size: */
@@ -28,5 +28,5 @@
 
 	/*write output datasets: */
-	WriteData(NEWGRADJ,newgradj);
+	WriteMatlabData(NEWGRADJ,newgradj);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/OutputResults/OutputResults.cpp
===================================================================
--- /issm/trunk/src/mex/OutputResults/OutputResults.cpp	(revision 8909)
+++ /issm/trunk/src/mex/OutputResults/OutputResults.cpp	(revision 8910)
@@ -26,11 +26,11 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
-	FetchData((DataSet**)&results,RESULTS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&results,RESULTS);
 
 	/*results might be NILL, allocate: */
Index: /issm/trunk/src/mex/OutputRifts/OutputRifts.cpp
===================================================================
--- /issm/trunk/src/mex/OutputRifts/OutputRifts.cpp	(revision 8909)
+++ /issm/trunk/src/mex/OutputRifts/OutputRifts.cpp	(revision 8910)
@@ -24,6 +24,6 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData(&numrifts,mxGetField(PARAMETERS,0,"numrifts"));
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData(&numrifts,mxGetField(PARAMETERS,0,"numrifts"));
 
 	/*!Call core code: */
@@ -31,5 +31,5 @@
 
 	/*write output : */
-	WriteData(RIFTPROPERTIES,riftproperties);
+	WriteMatlabData(RIFTPROPERTIES,riftproperties);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ParameterOutput/ParameterOutput.cpp
===================================================================
--- /issm/trunk/src/mex/ParameterOutput/ParameterOutput.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ParameterOutput/ParameterOutput.cpp	(revision 8910)
@@ -27,13 +27,13 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchData(&results,RESULTS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&results,RESULTS);
 	
 	/*parameters: */
-	FetchData(&analysis_type,ANALYSIS);
-	FetchData(&sub_analysis_type,SUBANALYSIS);
+	FetchMatlabData(&analysis_type,ANALYSIS);
+	FetchMatlabData(&sub_analysis_type,SUBANALYSIS);
 
 	/*!Generate internal degree of freedom numbers: */
@@ -41,5 +41,5 @@
 
 	/*write output datasets: */
-	WriteData(RESULTS,results,0,0,"DataSet",NULL); 
+	WriteMatlabData(RESULTS,results,0,0,"DataSet",NULL); 
 	
 	/*Free ressources: */
Index: /issm/trunk/src/mex/ParsePetscOptions/ParsePetscOptions.cpp
===================================================================
--- /issm/trunk/src/mex/ParsePetscOptions/ParsePetscOptions.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ParsePetscOptions/ParsePetscOptions.cpp	(revision 8910)
@@ -19,6 +19,6 @@
 
 	/*Input datasets: */
-	FetchParams(&parameters,PARAMETERS);
-	FetchData(&petscoptionsfilename,PETSCOPTIONSFILENAME); 
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&petscoptionsfilename,PETSCOPTIONSFILENAME); 
 
 	petscoptionsfid=fopen(petscoptionsfilename,"r");
@@ -28,5 +28,5 @@
 
 	/*write output datasets: */
-	WriteParams(PARAMETERSOUT,parameters);
+	WriteMatlabData(PARAMETERSOUT,parameters);
 	
 	/*Free ressources: */
Index: /issm/trunk/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/trunk/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 8909)
+++ /issm/trunk/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 8910)
@@ -26,8 +26,8 @@
 
 	/*Fetch inputs: */
-	FetchData(&x,&nods,NULL,XHANDLE);  
-	FetchData(&y,NULL,NULL,YHANDLE);
-	FetchData(&mindistance,MINDISTANCE);
-	FetchData(&multithread,MULTITHREAD);
+	FetchMatlabData(&x,&nods,NULL,XHANDLE);  
+	FetchMatlabData(&y,NULL,NULL,YHANDLE);
+	FetchMatlabData(&mindistance,MINDISTANCE);
+	FetchMatlabData(&multithread,MULTITHREAD);
 
 	/*Run core routine: */
@@ -35,5 +35,5 @@
 
 	/* output: */
-	WriteData(FLAGS,flags);
+	WriteMatlabData(FLAGS,flags);
 
 	/*end module: */
Index: /issm/trunk/src/mex/ProcessParams/ProcessParams.cpp
===================================================================
--- /issm/trunk/src/mex/ProcessParams/ProcessParams.cpp	(revision 8909)
+++ /issm/trunk/src/mex/ProcessParams/ProcessParams.cpp	(revision 8910)
@@ -17,8 +17,8 @@
 	
 	/*Input datasets: */
-	FetchData((DataSet**)&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&parameters,PARAMETERS);
 
 	/*write output datasets: */
-	WriteParams(PARAMETERSOUT,parameters);
+	WriteMatlabData(PARAMETERSOUT,parameters);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp
===================================================================
--- /issm/trunk/src/mex/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 8909)
+++ /issm/trunk/src/mex/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 8910)
@@ -22,8 +22,8 @@
         
 	/*Input datasets: */
-	FetchData(&connectivity,&nel,&dummy,CONNECTIVITY);
-	FetchData(&pool,&dummy,POOL);
-	FetchData(&index,INDEX);
-	FetchData(&flags,&dummy,FLAGS);
+	FetchMatlabData(&connectivity,&nel,&dummy,CONNECTIVITY);
+	FetchMatlabData(&pool,&dummy,POOL);
+	FetchMatlabData(&index,INDEX);
+	FetchMatlabData(&flags,&dummy,FLAGS);
 
 	/*!Generate internal degree of freedom numbers: */
@@ -31,5 +31,5 @@
 
 	/*write output datasets: */
-	WriteData(POOLOUT,pool,nel);
+	WriteMatlabData(POOLOUT,pool,nel);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Qmu/Qmu.cpp
===================================================================
--- /issm/trunk/src/mex/Qmu/Qmu.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Qmu/Qmu.cpp	(revision 8910)
@@ -33,5 +33,5 @@
 
 	/*Fetch parameters from femmodel structure: */
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Generate internal degree of freedom numbers: */
Index: /issm/trunk/src/mex/Reduceload/Reduceload.cpp
===================================================================
--- /issm/trunk/src/mex/Reduceload/Reduceload.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Reduceload/Reduceload.cpp	(revision 8910)
@@ -23,11 +23,11 @@
 
 	/*Input datasets: */
-	FetchData(&pf,PF);
-	FetchData(&Kfs,KFS);
-	FetchData(&ys,YS);
+	FetchMatlabData(&pf,PF);
+	FetchMatlabData(&Kfs,KFS);
+	FetchMatlabData(&ys,YS);
 
 	/*!Reduce load from g to f size: */
 	if(nrhs==4){
-		FetchData(&flag_ys0,YSFLAG);
+		FetchMatlabData(&flag_ys0,YSFLAG);
 		Reduceloadx(pf, Kfs, ys,flag_ys0);
 	}
@@ -37,5 +37,5 @@
 
 	/*write output datasets: */
-	WriteData(PFOUT,pf);
+	WriteMatlabData(PFOUT,pf);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Reducevectorgtof/Reducevectorgtof.cpp
===================================================================
--- /issm/trunk/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 8910)
@@ -22,7 +22,7 @@
 
 	/*Input datasets: */
-	FetchData(&ug,UG);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData(&ug,UG);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Reduce vector: */
@@ -30,5 +30,5 @@
 
 	/*write output datasets: */
-	WriteData(UF,uf);
+	WriteMatlabData(UF,uf);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Reducevectorgtos/Reducevectorgtos.cpp
===================================================================
--- /issm/trunk/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 8910)
@@ -22,7 +22,7 @@
 
 	/*Input datasets: */
-	FetchData(&yg,YG);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData(&yg,YG);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Reduce vector: */
@@ -30,5 +30,5 @@
 
 	/*write output datasets: */
-	WriteData(YS,ys);
+	WriteMatlabData(YS,ys);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Response/Response.cpp
===================================================================
--- /issm/trunk/src/mex/Response/Response.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Response/Response.cpp	(revision 8910)
@@ -28,13 +28,13 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
-	FetchData(&response,RESPONSE);
-	FetchData(&process_units,PROCESSUNITS);
-	FetchData(&weight_index,WEIGHTINDEX);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&response,RESPONSE);
+	FetchMatlabData(&process_units,PROCESSUNITS);
+	FetchMatlabData(&weight_index,WEIGHTINDEX);
 
 	/*configure: */
@@ -47,5 +47,5 @@
 
 	/*write output : */
-	WriteData(OUTPUT,resp);
+	WriteMatlabData(OUTPUT,resp);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Solver/Solver.cpp
===================================================================
--- /issm/trunk/src/mex/Solver/Solver.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Solver/Solver.cpp	(revision 8910)
@@ -28,5 +28,5 @@
 	
 	/*parameters: */
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*In serial mode, we have no set any petsc options, do it now: */
@@ -43,8 +43,8 @@
 	
 		/*Input datasets: */
-		FetchData(&Kff,KFF);
-		FetchData(&pf,PF);
-		FetchData(&uf0,UF0);
-		FetchData(&df,DF);
+		FetchMatlabData(&Kff,KFF);
+		FetchMatlabData(&pf,PF);
+		FetchMatlabData(&uf0,UF0);
+		FetchMatlabData(&df,DF);
 
 		/*Core module: */
@@ -52,5 +52,5 @@
 
 		/*Write output*/
-		WriteData(UF,uf);
+		WriteMatlabData(UF,uf);
 	}
 	else{
Index: /issm/trunk/src/mex/SpcNodes/SpcNodes.cpp
===================================================================
--- /issm/trunk/src/mex/SpcNodes/SpcNodes.cpp	(revision 8909)
+++ /issm/trunk/src/mex/SpcNodes/SpcNodes.cpp	(revision 8910)
@@ -20,7 +20,7 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&constraints,CONSTRAINTS);
-	FetchData(&analysis_type,ANALYSISTYPE);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&constraints,CONSTRAINTS);
+	FetchMatlabData(&analysis_type,ANALYSISTYPE);
 	
 	/*!Generate internal degree of freedom numbers: */
@@ -28,5 +28,5 @@
 
 	/*write output datasets: */
-	WriteData(NODES,nodes);
+	WriteMatlabData(NODES,nodes);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/StringToEnum/StringToEnum.cpp
===================================================================
--- /issm/trunk/src/mex/StringToEnum/StringToEnum.cpp	(revision 8909)
+++ /issm/trunk/src/mex/StringToEnum/StringToEnum.cpp	(revision 8910)
@@ -16,5 +16,5 @@
 
 	/*Fetch inputs: */
-	FetchData(&name,NAME);
+	FetchMatlabData(&name,NAME);
 
 	/*Run core function: */
@@ -22,5 +22,5 @@
 
 	/* output: */
-	WriteData(ENUMOUT,enum_out);
+	WriteMatlabData(ENUMOUT,enum_out);
 }
 
Index: /issm/trunk/src/mex/SurfaceArea/SurfaceArea.cpp
===================================================================
--- /issm/trunk/src/mex/SurfaceArea/SurfaceArea.cpp	(revision 8909)
+++ /issm/trunk/src/mex/SurfaceArea/SurfaceArea.cpp	(revision 8910)
@@ -22,10 +22,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -38,5 +38,5 @@
 
 	/*write output : */
-	WriteData(ELEMENTSOUT,elements);
+	WriteMatlabData(ELEMENTSOUT,elements);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/SystemMatrices/SystemMatrices.cpp
===================================================================
--- /issm/trunk/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 8909)
+++ /issm/trunk/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 8910)
@@ -34,10 +34,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTS);
-	FetchData((DataSet**)&nodes,NODES);
-	FetchData((DataSet**)&vertices,VERTICES);
-	FetchData((DataSet**)&loads,LOADS);
-	FetchData((DataSet**)&materials,MATERIALS);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*configure: */
@@ -49,8 +49,8 @@
 	/*!Generate internal degree of freedom numbers: */
 	if(nrhs==10){
-		FetchData(&kflag,KFLAG);
-		FetchData(&pflag,PFLAG);
-		FetchData(&penalty_kflag,PENALTYKFLAG);
-		FetchData(&penalty_pflag,PENALTYPFLAG);
+		FetchMatlabData(&kflag,KFLAG);
+		FetchMatlabData(&pflag,PFLAG);
+		FetchMatlabData(&penalty_kflag,PENALTYKFLAG);
+		FetchMatlabData(&penalty_pflag,PENALTYPFLAG);
 		SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);
 	}
@@ -59,9 +59,9 @@
 
 	/*write output datasets: */
-	WriteData(KFF,Kff);
-	WriteData(KFS,Kfs);
-	WriteData(PF,pf);
-	WriteData(DF,df);
-	WriteData(KMAX,kmax);
+	WriteMatlabData(KFF,Kff);
+	WriteMatlabData(KFS,Kfs);
+	WriteMatlabData(PF,pf);
+	WriteMatlabData(DF,df);
+	WriteMatlabData(KMAX,kmax);
 	
 	/*Free ressources: */
Index: /issm/trunk/src/mex/TimeAdapt/TimeAdapt.cpp
===================================================================
--- /issm/trunk/src/mex/TimeAdapt/TimeAdapt.cpp	(revision 8909)
+++ /issm/trunk/src/mex/TimeAdapt/TimeAdapt.cpp	(revision 8910)
@@ -25,10 +25,10 @@
 
 /*Input datasets: */
-FetchData((DataSet**)&elements,ELEMENTSIN);
-FetchData((DataSet**)&nodes,NODESIN);
-FetchData((DataSet**)&vertices,VERTICESIN);
-FetchData((DataSet**)&loads,LOADSIN);
-FetchData((DataSet**)&materials,MATERIALSIN);
-FetchParams(&parameters,PARAMETERSIN);
+FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+FetchMatlabData((DataSet**)&nodes,NODESIN);
+FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+FetchMatlabData((DataSet**)&loads,LOADSIN);
+FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+FetchMatlabData(&parameters,PARAMETERSIN);
 
 /*configure: */
@@ -41,5 +41,5 @@
 
 /*write output datasets: */
-WriteData(DT,dt);
+WriteMatlabData(DT,dt);
 
 /*Free ressources: */
Index: /issm/trunk/src/mex/TriaSearch/TriaSearch.cpp
===================================================================
--- /issm/trunk/src/mex/TriaSearch/TriaSearch.cpp	(revision 8909)
+++ /issm/trunk/src/mex/TriaSearch/TriaSearch.cpp	(revision 8910)
@@ -31,9 +31,9 @@
 
 	/*Input datasets: */
-	FetchData(&index,&nel,&dummy,INDEXHANDLE);
-	FetchData(&x,&nods,XHANDLE);
-	FetchData(&y,&nods,YHANDLE);
-	FetchData(&x0,&numberofnodes,X0HANDLE);
-	FetchData(&y0,&numberofnodes,Y0HANDLE);
+	FetchMatlabData(&index,&nel,&dummy,INDEXHANDLE);
+	FetchMatlabData(&x,&nods,XHANDLE);
+	FetchMatlabData(&y,&nods,YHANDLE);
+	FetchMatlabData(&x0,&numberofnodes,X0HANDLE);
+	FetchMatlabData(&y0,&numberofnodes,Y0HANDLE);
 
 	/* Echo: {{{1*/
@@ -48,5 +48,5 @@
 
 	/*Write data: */
-	WriteData(TRIA,tria,numberofnodes);
+	WriteMatlabData(TRIA,tria,numberofnodes);
 
 	/*end module: */
Index: /issm/trunk/src/mex/UpdateSpcs/UpdateSpcs.cpp
===================================================================
--- /issm/trunk/src/mex/UpdateSpcs/UpdateSpcs.cpp	(revision 8909)
+++ /issm/trunk/src/mex/UpdateSpcs/UpdateSpcs.cpp	(revision 8910)
@@ -20,7 +20,7 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchParams((Parameters**)&parameters,PARAMETERS);
-	FetchData(&ys,YS);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((Parameters**)&parameters,PARAMETERS);
+	FetchMatlabData(&ys,YS);
 	
 	/*!Generate internal degree of freedom numbers: */
@@ -28,5 +28,5 @@
 
 	/*write output datasets: */
-	WriteData(NODESOUT,nodes);
+	WriteMatlabData(NODESOUT,nodes);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/UpdateVertexPositions/UpdateVertexPositions.cpp
===================================================================
--- /issm/trunk/src/mex/UpdateVertexPositions/UpdateVertexPositions.cpp	(revision 8909)
+++ /issm/trunk/src/mex/UpdateVertexPositions/UpdateVertexPositions.cpp	(revision 8910)
@@ -22,10 +22,10 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&elements,ELEMENTSIN);
-	FetchData((DataSet**)&nodes,NODESIN);
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchData((DataSet**)&loads,LOADSIN);
-	FetchData((DataSet**)&materials,MATERIALSIN);
-	FetchParams(&parameters,PARAMETERSIN);
+	FetchMatlabData((DataSet**)&elements,ELEMENTSIN);
+	FetchMatlabData((DataSet**)&nodes,NODESIN);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData((DataSet**)&loads,LOADSIN);
+	FetchMatlabData((DataSet**)&materials,MATERIALSIN);
+	FetchMatlabData(&parameters,PARAMETERSIN);
 
 	/*configure: */
@@ -38,10 +38,10 @@
 
 	/*write output datasets: */
-	WriteData(ELEMENTS,elements);
-	WriteData(NODES,nodes);
-	WriteData(VERTICES,vertices);
-	WriteData(LOADS,loads);
-	WriteData(MATERIALS,materials);
-	WriteParams(PARAMETERS,parameters);
+	WriteMatlabData(ELEMENTS,elements);
+	WriteMatlabData(NODES,nodes);
+	WriteMatlabData(VERTICES,vertices);
+	WriteMatlabData(LOADS,loads);
+	WriteMatlabData(MATERIALS,materials);
+	WriteMatlabData(PARAMETERS,parameters);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/VerticesDof/VerticesDof.cpp
===================================================================
--- /issm/trunk/src/mex/VerticesDof/VerticesDof.cpp	(revision 8909)
+++ /issm/trunk/src/mex/VerticesDof/VerticesDof.cpp	(revision 8910)
@@ -18,6 +18,6 @@
 
 	/*Input datasets: */
-	FetchData((DataSet**)&vertices,VERTICESIN);
-	FetchParams(&parameters,PARAMETERS);
+	FetchMatlabData((DataSet**)&vertices,VERTICESIN);
+	FetchMatlabData(&parameters,PARAMETERS);
 
 	/*!Generate internal degree of freedom numbers: */
@@ -25,5 +25,5 @@
 
 	/*write output datasets: */
-	WriteData(VERTICES,vertices);
+	WriteMatlabData(VERTICES,vertices);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/Xy2ll/Xy2ll.cpp
===================================================================
--- /issm/trunk/src/mex/Xy2ll/Xy2ll.cpp	(revision 8909)
+++ /issm/trunk/src/mex/Xy2ll/Xy2ll.cpp	(revision 8910)
@@ -35,15 +35,15 @@
 	/*Input datasets: */
 	if (verbose) printf("Fetching inputs:\n");
-	FetchData(&x,&nx,X_IN);
+	FetchMatlabData(&x,&nx,X_IN);
 	if (verbose)
 		if   (nx == 1) printf("  x=%g\n",x[0]);
 		else           printf("  x=[%d values]\n",nx);
 //	for (i=0; i<nx; i++) printf("  x[%d]=%g\n",i,x[i]);
-	FetchData(&y,&ny,Y_IN);
+	FetchMatlabData(&y,&ny,Y_IN);
 	if (verbose)
 		if   (ny == 1) printf("  y=%g\n",y[0]);
 		else           printf("  y=[%d values]\n",ny);
 //	for (i=0; i<ny; i++) printf("  y[%d]=%g\n",i,y[i]);
-	FetchData(&sgn,SGN_IN);
+	FetchMatlabData(&sgn,SGN_IN);
 	if (verbose) printf("  sgn=%d\n",sgn);
 
@@ -84,6 +84,6 @@
 
 	/*Write data: */
-	WriteData(LAT_OUT,lat,ncoord);
-	WriteData(LON_OUT,lon,ncoord);
+	WriteMatlabData(LAT_OUT,lat,ncoord);
+	WriteMatlabData(LON_OUT,lon,ncoord);
 
 	/*Clean-up*/
