Index: /issm/trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp	(revision 13352)
+++ /issm/trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp	(revision 13353)
@@ -609,5 +609,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{*/
+/*FUNCTION FetchData(Options** poptions,const mxArray** pdataref){{{*/
 void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
 
@@ -634,2 +634,49 @@
 }
 /*}}}*/
+/*FUNCTION FetchData(DataSet** pcontours,const mxArray* dataref){{{*/
+void FetchData(DataSet** pcontours,const mxArray* dataref){
+
+	int              numcontours,index,test1,test2;
+	char            *contourname = NULL;
+	DataSet         *contours    = NULL;
+	Contour<double> *contouri    = NULL;
+
+	if (mxIsClass(dataref,"char")){
+		FetchData(&contourname,dataref);
+		contours=DomainOutlineRead<double>(contourname);
+	}
+	else if(mxIsClass(dataref,"struct")){
+
+		contours=new DataSet(0);
+		numcontours=mxGetNumberOfElements(dataref);
+
+		for(int i=0;i<numcontours;i++){
+
+			contouri=xNew<Contour<double> >(1);
+
+			index = mxGetFieldNumber(dataref,"nods");
+			if(index==-1) _error_("input structure does not have a 'nods' field");
+			FetchData(&contouri->nods,mxGetFieldByNumber(dataref,i,index));
+
+			index = mxGetFieldNumber(dataref,"x");
+			if(index==-1) _error_("input structure does not have a 'x' field");
+			FetchData(&contouri->x,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
+			if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
+
+			index = mxGetFieldNumber(dataref,"y");
+			if(index==-1) _error_("input structure does not have a 'y' field");
+			FetchData(&contouri->y,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
+			if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
+
+			contours->AddObject(contouri);
+		}
+	}
+	else{
+		_error_("Contour is neither a string nor a structure and cannot be loaded ("<<mxGetClassName(dataref)<<" not supported)");
+	}
+
+	/*clean-up and assign output pointer*/
+	xDelete<char>(contourname);
+	*pcontours=contours;
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/matlab/io/matlabio.h
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/matlabio.h	(revision 13352)
+++ /issm/trunk-jpl/src/c/matlab/io/matlabio.h	(revision 13353)
@@ -49,4 +49,5 @@
 void FetchData(BamgOpts** bamgopts,const mxArray* dataref);
 void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref);
+void FetchData(DataSet** pcontours,const mxArray* dataref);
 
 Option* OptionParse(char* name, const mxArray* prhs[]);
Index: /issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp
===================================================================
--- /issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp	(revision 13352)
+++ /issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp	(revision 13353)
@@ -235,4 +235,10 @@
 }
 /*}}}*/
+/*FUNCTION FetchData(DataSet** pcontours,PyObject* py_dict){{{*/
+void FetchData(DataSet** pcontours,PyObject* py_dict){
+
+	_error_("not supported yet");
+}
+/*}}}*/
 
 /*Python version dependent: */
Index: /issm/trunk-jpl/src/c/python/io/pythonio.h
===================================================================
--- /issm/trunk-jpl/src/c/python/io/pythonio.h	(revision 13352)
+++ /issm/trunk-jpl/src/c/python/io/pythonio.h	(revision 13353)
@@ -35,4 +35,5 @@
 void FetchData(BamgOpts** bamgopts,PyObject* py_dict);
 void FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments);
+void FetchData(DataSet** pcontours,PyObject* py_dict);
 
 int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
Index: /issm/trunk-jpl/src/c/shared/Exp/DomainOutlineWrite.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 13352)
+++ /issm/trunk-jpl/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 13353)
@@ -12,5 +12,4 @@
 
 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
-
 	
 	/*Error management: */
@@ -56,3 +55,2 @@
 	return noerr;
 }
-
Index: /issm/trunk-jpl/src/c/shared/Exp/exp.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 13352)
+++ /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 13353)
@@ -175,12 +175,12 @@
 
 	/*intermediary: */
-	int       nprof;
-	int      *profnvertices = NULL;
-	doubletype  **pprofx        = NULL;
-	doubletype  **pprofy        = NULL;
-	Contour<doubletype>* contour       = NULL;
+	int                  nprof;
+	int                 *profnvertices = NULL;
+	doubletype         **pprofx        = NULL;
+	doubletype         **pprofy        = NULL;
+	Contour<doubletype> *contour       = NULL;
 
 	/*output: */
-	DataSet* domain=NULL;
+	DataSet *domain = NULL;
 
 	/*If domainname is an empty string, return empty dataset*/
Index: /issm/trunk-jpl/src/m/mesh/bamg.m
===================================================================
--- /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 13352)
+++ /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 13353)
@@ -66,7 +66,4 @@
 	domain=expread(domainfile);
 
-	%Write temporary file, with only the domain outline (exclude holes)
-	expwrite(domain(1),[domainfile '_TEMPouterboundary.exp']);
-
 	%Build geometry 
 	count=0;
@@ -80,5 +77,5 @@
 		%Checks that all holes are INSIDE the principle domain outline
 		if i>1,
-			flags=ContourToNodes(domain(i).x,domain(i).y,[domainfile '_TEMPouterboundary.exp'],0);
+			flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0);
 			if any(~flags),
 				error('bamg error message: All holes should be stricly inside the principal domain');
@@ -109,5 +106,5 @@
 
 			%detect wether all points of the rift are inside the domain
-			flags=ContourToNodes(rift(i).x,rift(i).y,[domainfile '_TEMPouterboundary.exp'],0);
+			flags=ContourToNodes(rift(i).x,rift(i).y,domain(1),0);
 			if ~flags,
 				error('one Rift has all his points outside of the domain outline'),
@@ -241,5 +238,5 @@
 	
 		%only keep those inside
-		flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),[domainfile '_TEMPouterboundary.exp'],0);
+		flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),domain(1),0);
 		requiredvertices=requiredvertices(find(flags),:);
 
@@ -255,5 +252,4 @@
 	%process geom
 	%bamg_geometry=processgeometry(bamg_geometry,getfieldvalue(options,'tol',NaN),domain(1));
-	delete([domainfile '_TEMPouterboundary.exp']);
 
 elseif isstruct(md.private.bamg) & isfield(md.private.bamg,'geometry'),
Index: /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 13352)
+++ /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 13353)
@@ -36,7 +36,6 @@
 	FetchData(&x,&nods,NULL,XHANDLE);
 	FetchData(&y,NULL,NULL,YHANDLE);
-	FetchData(&edgevalue,EDGEVALUEHANDLE);
-	FetchData(&contourname,CONTOURNAME);
-	contours=DomainOutlineRead<double>(contourname);
+	FetchData(&edgevalue,EDGEVALUE);
+	FetchData(&contours,CONTOUR);
 
 	/*Run x layer */
Index: /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.h
===================================================================
--- /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.h	(revision 13352)
+++ /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.h	(revision 13353)
@@ -28,8 +28,8 @@
 #ifdef _HAVE_MATLAB_MODULES_
 /* input macros: */
-#define XHANDLE         prhs[0]
-#define YHANDLE         prhs[1]
-#define CONTOURNAME     prhs[2]
-#define EDGEVALUEHANDLE prhs[3]
+#define XHANDLE   prhs[0]
+#define YHANDLE   prhs[1]
+#define CONTOUR   prhs[2]
+#define EDGEVALUE prhs[3]
 
 /* serial output macros: */
@@ -39,8 +39,8 @@
 #ifdef _HAVE_PYTHON_MODULES_
 /* input macros: */
-#define XHANDLE         PyTuple_GetItem(args,0)
-#define YHANDLE         PyTuple_GetItem(args,1)
-#define CONTOURNAME     PyTuple_GetItem(args,2)
-#define EDGEVALUEHANDLE PyTuple_GetItem(args,3)
+#define XHANDLE   PyTuple_GetItem(args,0)
+#define YHANDLE   PyTuple_GetItem(args,1)
+#define CONTOUR   PyTuple_GetItem(args,2)
+#define EDGEVALUE PyTuple_GetItem(args,3)
 
 /* serial output macros: */
