Index: /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	(revision 8153)
+++ /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	(revision 8154)
@@ -130,4 +130,9 @@
 			j2= (int)ceil((x_tria_max-x_grid_min)/xposting);
 		}
+		/*Check indices*/
+		if(i1<0)      _error_("first index is 0!");
+		if(j1<0)      _error_("first index is 0!");
+		if(i2>=nlines)_error_("index exceeds matrix dimension! (%i >= nlines  %i)",i2,nlines);
+		if(j2>=ncols) _error_("index exceeds matrix dimension! (%i >= ncols   %i)",j2,ncols);
 
 		/*get area of the current element (Jacobian = 2 * area)*/
