Index: /issm/trunk-jpl/src/m/mesh/bamg.m
===================================================================
--- /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 13328)
+++ /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 13329)
@@ -64,7 +64,10 @@
 	domainfile=getfieldvalue(options,'domain');
 	if ~exist(domainfile,'file') error(['bamg error message: file ' domainfile ' not found ']); end
+	domain=expread(domainfile);
+
+	%Write temporary file, with only the domain outline (exclude holes)
+	expwrite(domain(1),[domainfile '_TEMPouterboundary.exp']);
 
 	%Build geometry 
-	domain=expread(domainfile);
 	count=0;
 	for i=1:length(domain),
@@ -77,5 +80,5 @@
 		%Checks that all holes are INSIDE the principle domain outline
 		if i>1,
-			flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0);
+			flags=ContourToNodes(domain(i).x,domain(i).y,[domainfile '_TEMPouterboundary.exp'],0);
 			if any(~flags),
 				error('bamg error message: All holes should be stricly inside the principal domain');
@@ -106,5 +109,5 @@
 
 			%detect wether all points of the rift are inside the domain
-			flags=ContourToNodes(rift(i).x,rift(i).y,domain(1),0);
+			flags=ContourToNodes(rift(i).x,rift(i).y,[domainfile '_TEMPouterboundary.exp'],0);
 			if ~flags,
 				error('one Rift has all his points outside of the domain outline'),
@@ -238,5 +241,5 @@
 	
 		%only keep those inside
-		flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),domain(1),0);
+		flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),[domainfile '_TEMPouterboundary.exp'],0);
 		requiredvertices=requiredvertices(find(flags),:);
 
@@ -252,4 +255,5 @@
 	%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'),
