Index: /issm/trunk/src/m/utils/Exp/clicktoflowline.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/clicktoflowline.m	(revision 5392)
+++ /issm/trunk/src/m/utils/Exp/clicktoflowline.m	(revision 5392)
@@ -0,0 +1,16 @@
+function clicktoflowline(index,x,y,u,v,filename)
+%CLICKTOFLOWLINE create a flowline contour file (named 'filename') by clicking on a velocity field once.
+%
+% Usage: clicktoflowline(index,x,y,u,v,x0,y0,filename)
+%
+% Ex: clicktoflowline(md.elements,md.x,md.y,md.vx_obs,md.vy_obs,'flowline1.exp')
+
+
+[x0,y0]=ginput(1);
+
+line=flowlines(index,x,y,u,v,x0,y0,200);
+
+hold on
+plot(line.x,line.y,'r-');
+
+expwrite(line,filename);
Index: /issm/trunk/src/m/utils/Exp/flowlines.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/flowlines.m	(revision 5391)
+++ /issm/trunk/src/m/utils/Exp/flowlines.m	(revision 5392)
@@ -39,7 +39,7 @@
 %check seed points
 tria=TriaSearch(index,x,y,x0,y0);
-if isnan(tria),
-	error('flowlines error message: seed point is not inside mesh!');
-end
+pos=find(isnan(tria));
+x0(pos)=[];
+y0(pos)=[];
 
 %initialize other variables
@@ -69,5 +69,5 @@
 	%find current triangle
 	queue=find(~done);
-	tria=tsearch(x,y,index,X(queue),Y(queue));
+	tria=TriaSearch(index,x,y,X(queue),Y(queue));
 
 	%check that the point is actually inside a triangle of the mesh
@@ -81,4 +81,8 @@
 	tria(listnan)=[]; 
 	queue(listnan)=[];
+
+	if isempty(tria),
+		break;
+	end
 
 	%velocity of the current triangle and norm it
@@ -114,5 +118,5 @@
 	%find current triangle
 	queue=find(~done);
-	tria=tsearch(x,y,index,X(queue),Y(queue));
+	tria=TriaSearch(index,x,y,X(queue),Y(queue));
 
 	%check that the point is actually inside a triangle of the mesh
@@ -126,4 +130,8 @@
 	tria(listnan)=[]; 
 	queue(listnan)=[];
+
+	if isempty(tria),
+		break;
+	end
 
 	%velocity of the current triangle and norm it
