Index: /issm/trunk/src/m/utils/Mesh/ProfileProjectOntoMesh.m
===================================================================
--- /issm/trunk/src/m/utils/Mesh/ProfileProjectOntoMesh.m	(revision 4039)
+++ /issm/trunk/src/m/utils/Mesh/ProfileProjectOntoMesh.m	(revision 4040)
@@ -25,5 +25,5 @@
 processed_y=[];
 for i=1:numel(indices),
-	if(((indices(i)-floor(indices(i)))~=0) & ((ceil(indices(i))-indices(i))~=0))
+	if(((indices(i)-floor(indices(i)))~=0) && ((ceil(indices(i))-indices(i))~=0))
 		processed_indices=[processed_indices;floor(indices(i))];
 		processed_x=[processed_x;x0(i)];
@@ -32,5 +32,5 @@
 end
 
-%now merge profile.x,profile.y with processed_x,processed_y, at locatoins processed_indices:
+%now merge profile.x,profile.y with processed_x,processed_y, at locations processed_indices:
 newx=profile.x;
 newy=profile.y;
@@ -49,4 +49,12 @@
 node_in_element=NodeInElement(newx,newy,md.elements,md.x,md.y,md.nodeconnectivity);
 
+% eliminate nodes that don't fall in any element
+% (profile may start and/or end externally and/or cross holes in the model)
+
+ind=find(node_in_element(:,9)>0);
+newx=newx(ind,:);
+newy=newy(ind,:);
+node_in_element=node_in_element(ind,:);
+
 mesh_profile=[newx(1:end-1) newy(1:end-1) newx(2:end) newy(2:end) zeros(length(newy(2:end)),1)];
 
