Index: /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m
===================================================================
--- /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m	(revision 26219)
+++ /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m	(revision 26220)
@@ -178,8 +178,20 @@
 	%}}}
 
-	%figure out other fields in mesh3dsurface:
+	%a little technicality here. the mesh generate is not exactly on the 
+	%sphere. we create lat,long coordinates, and reproject on an exact sphere. 
 	mesh.r=sqrt(mesh.x.^2+mesh.y.^2+mesh.z.^2);
-	mesh.lat = asin(mesh.z./mesh.r)/pi*180;
-	mesh.long = atan2(mesh.y,mesh.x)/pi*180;
+
+	%make sure we don't have south and north pole: 
+	pos=find(mesh.x==0 & mesh.y==0);
+	mesh.lat = asind(mesh.z./mesh.r);
+	mesh.long = atan2d(mesh.y,mesh.x);
+	pos=find(mesh.lat==90); mesh.lat(pos)=90-.01;
+	pos=find(mesh.lat==-90); mesh.lat(pos)=-90+.01;
+
+	mesh.r=radius*ones(mesh.numberofvertices,1);
+	mesh.x=radius*cosd(mesh.lat).*cosd(mesh.long);
+	mesh.y=radius*cosd(mesh.lat).*sind(mesh.long);
+	mesh.z=radius*sind(mesh.lat);
+
 
 	%erase files:
