Index: /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 19466)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 19467)
@@ -134,9 +134,18 @@
 		}
 		else{
-			for (j=0;j<N_data;j++){
-				if (it<0 || it>=nels_data){
-					_error_("Triangle number " << it << " not in [0 " << nels_data << "], report bug to developers");
+			/*For the P0 implementation*/
+			/*If we fall outside of the convex or outside of the mesh, return NaN*/
+			if(tb.det<0 || reft[it]<0){
+				data_interp[i*N_data+j]=-9999;
+			}
+			else{
+				if(it<0 || it>=nels_data){
+					_error_("Triangle number " << it << " not in [0 " << nels_data
+								<< "], report bug to developers (interpolation point: " <<x_interp[i]<<" "<<y_interp[i]<<")");
 				}
-				data_interp[i*N_data+j]=data[N_data*it+j];
+				for (j=0;j<N_data;j++){
+
+					data_interp[i*N_data+j]=data[N_data*it+j];
+				}
 			}
 		}
