Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 14893)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 14894)
@@ -184,6 +184,4 @@
 					./shared/shared.h\
 					./shared/Alloc/alloc.h\
-					./shared/Alloc/alloc.cpp\
-					./shared/Alloc/xNewDelete.h\
 					./shared/MemOps/xMemCpy.h\
 					./shared/Matrix/matrix.h\
Index: /issm/trunk-jpl/src/c/classes/objects/Contour.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Contour.h	(revision 14893)
+++ /issm/trunk-jpl/src/c/classes/objects/Contour.h	(revision 14894)
@@ -10,5 +10,5 @@
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
-#include "../../shared/Alloc/xNewDelete.h"
+#include "../../shared/Alloc/alloc.h"
 #include "../../shared/MemOps/xMemCpy.h"
 #include "../../io/io.h"
Index: sm/trunk-jpl/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/alloc.cpp	(revision 14893)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/* \file alloc.h
- * \brief: wrappers to "C" or "Matlab" memory allocators.
- * These wrappers try to insulate ISSM from any library dependency.
- * Ie: if we are running in matlab, matlab has to handle all memory allocations, 
- * otherwise, we get big segfaults. If running in stand alone mode (pure C or C++ 
- * application), we rely on the "C" library implementation of dynamic memory allocation.
- * Why don't we use the "new" and "delete" c++ implementations? Because so far there 
- * are no matlab wrappers to these, which implies having tons of segfaults when 
- * running a mex module.
- * Still, we try to throw memory allocation exceptions a la "C++" style when 
- * the allocation routines described here do not work.
- */
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile without HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include  "./alloc.h"
-#include "../Exceptions/exceptions.h"
-#include "../../include/include.h"
-#include "../../classes/objects/objects.h"
-
-void xdelete(Matrix<IssmDouble>** pv){
-
-	if (pv && *pv){
-		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
-		 * don't actually free memory in Matlab, we let the memory manager do that. We only
-		 * free in parallel: */
-		delete *pv;
-		*pv=NULL;
-	}
-}
-
-void xdelete(Vector<IssmDouble>** pv){
-
-	if (pv && *pv){
-		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
-		 * don't actually free memory in Matlab, we let the memory manager do that. We only
-		 * free in parallel: */
-		delete *pv;
-		*pv=NULL;
-	}
-}
Index: /issm/trunk-jpl/src/c/shared/Alloc/alloc.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/alloc.h	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/Alloc/alloc.h	(revision 14894)
@@ -1,4 +1,4 @@
 /* \file alloc.h
- * \brief: header file for memory allocations.
+ * \brief: header file for memory allocations as well as templated new/delete checking for non-null pointers
  */
 
@@ -6,11 +6,133 @@
 #define _ALLOC_H_
 
-#include "../../include/include.h"
-#include "./xNewDelete.h"
+#include <cassert>
 
-template <class doubletype> class Matrix;
-template <class doubletype> class Vector;
-void xdelete(Matrix<IssmDouble>** pvptr);
-void xdelete(Vector<IssmDouble>** pvptr);
+/* memory management of types T with non-trivial constructors require C++ style memory management*/
+#define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+/* but for speed one may alternatively use C memory management but can do so safely only for T that are at most 
+ * plain old data structures (POD)*/
+#ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+#include <cstdlib>
+#endif 
+
+template <class T> T* xNew(unsigned int size) { /*{{{*/
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T* aT_p=new T[size];
+  assert(aT_p);
+  return aT_p;
+#else
+  T* aT_p=(T*)malloc(size*sizeof(T));
+  assert(aT_p);
+  return aT_p;
+#endif  
+}/*}}}*/
+template <class T> T** xNew(unsigned int dim1, unsigned int dim2) { /*{{{*/
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T* buf=new T[dim1*dim2];
+  assert(buf );
+  T** aT_pp =new T*[dim1];
+  assert(aT_pp );
+  for (unsigned int i=0;i<dim1;++i) {
+    aT_pp [i]=buf;
+    buf+=dim2;
+  }
+  return aT_pp ;
+#else
+  T* buf=(T*)malloc(dim1*dim2*sizeof(T));
+  assert(buf );
+  T** aT_pp =(T**)malloc(dim1*sizeof(T*));
+  assert(aT_pp );
+  for (unsigned int i=0;i<dim1;++i) {
+    aT_pp [i]=buf;
+    buf+=dim2;
+  }
+  return aT_pp ;
+#endif
+}/*}}}*/
+template <class T> T* xNewZeroInit(unsigned int size) {/*{{{*/
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T* aT_p=xNew<T>(size);
+  for (unsigned int i=0; i<size;++i) 
+    aT_p[i]=(T)0;
+  return aT_p;
+#else
+  T* aT_p=(T*)calloc(size,sizeof(T));
+  assert(aT_p);
+  return aT_p;
+#endif
+}/*}}}*/
+template <class T> T** xNewZeroInit(unsigned int dim1, unsigned int dim2) {/*{{{*/
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T** aT_pp=xNew<T>(dim1,dim2);
+  for (unsigned int i=0; i<dim1*dim2;++i)
+    (*aT_pp)[i]=(T)0;
+  return aT_pp;
+#else
+  T* buf=(T*)calloc(dim1*dim2*sizeof(T));
+  assert(buf );
+  T** aT_pp =(T**)malloc(dim1*sizeof(T*));
+  assert(aT_pp );
+  for (unsigned int i=0;i<dim1;++i) {
+    aT_pp [i]=buf;
+    buf+=dim2;
+  }
+  return aT_pp ;
+#endif
+}/*}}}*/
+template <class T> void xDelete(T**& aT_pp) {/*{{{*/
+  if (aT_pp) {
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+    delete [](*aT_pp);
+    delete [](aT_pp);
+#else
+    free((void*)*aT_pp)
+    free((void**)aT_pp);
+#endif
+  }
+  aT_pp=0;
+}/*}}}*/
+template <class T> void xDelete(T*& aT_p) {/*{{{*/
+  if (aT_p) 
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+    delete []aT_p;
+#else
+    free((void*)aT_p);
+#endif
+  aT_p=0;
+}/*}}}*/
+template <class T> T* xReNew(T* old, unsigned int old_size, unsigned int size) {/*{{{*/
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+	T* aT_p=0;
+	if (!old) { // no old memory
+		if (size)  
+		 aT_p=xNew<T>(size); // according to realloc behavior in manual page 
+	}
+	else { // have old memory
+		if (!size)  // but 0 size
+		 xDelete<T>(old); // according to realloc behavior in manual page
+		else { // non-zero size
+			assert(old_size); // have old memory - need to have old_size set or this call is bad
+			// allocate new, delete old; ; even for the case when size is 
+			// less than old_size we can't just keep the memory unchanged 
+			// because otherwise classes that have ctors/dtors with side-effects 
+			// may misbehave, for example classes with static instance/operations counters. 
+			aT_p=xNew<T>(size);
+			unsigned int iMax=(old_size<size)?old_size:size;
+			for (unsigned int i=0; i<iMax;++i) { 
+				// we need to copy the items by explicit assignments
+				aT_p[i]=old[i];
+			}
+			xDelete<T>(old);
+		}
+	}
+	return aT_p;
+#else
+	T* aT_p=0;
+	aT_p=(T*)realloc((void*)old,size*sizeof(T));
+	if (size) 
+	 assert(aT_p); // according to realloc behavior in manual page
+	return aT_p;
+#endif 
+}/*}}}*/
 
 #endif
Index: sm/trunk-jpl/src/c/shared/Alloc/xNewDelete.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/xNewDelete.h	(revision 14893)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/* \file xNewDelete.h
- * \brief: header file for templated new/delete checking for non-null pointers
- */
-
-#ifndef _XNEWDELETE_H_
-#define _XNEWDELETE_H_
-
-#include <cassert>
-
-/* memory management of types T with non-trivial constructors require C++ style memory management*/
-#define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-/* but for speed one may alternatively use C memory management but can do so safely only for T that are at most 
- * plain old data structures (POD)*/
-#ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-#include <cstdlib>
-#endif 
-
-template <class T> T* xNew(unsigned int size) { /*{{{*/
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-  T* aT_p=new T[size];
-  assert(aT_p);
-  return aT_p;
-#else
-  T* aT_p=(T*)malloc(size*sizeof(T));
-  assert(aT_p);
-  return aT_p;
-#endif  
-}/*}}}*/
-template <class T> T** xNew(unsigned int dim1, unsigned int dim2) { /*{{{*/
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-  T* buf=new T[dim1*dim2];
-  assert(buf );
-  T** aT_pp =new T*[dim1];
-  assert(aT_pp );
-  for (unsigned int i=0;i<dim1;++i) {
-    aT_pp [i]=buf;
-    buf+=dim2;
-  }
-  return aT_pp ;
-#else
-  T* buf=(T*)malloc(dim1*dim2*sizeof(T));
-  assert(buf );
-  T** aT_pp =(T**)malloc(dim1*sizeof(T*));
-  assert(aT_pp );
-  for (unsigned int i=0;i<dim1;++i) {
-    aT_pp [i]=buf;
-    buf+=dim2;
-  }
-  return aT_pp ;
-#endif
-}/*}}}*/
-template <class T> T* xNewZeroInit(unsigned int size) {/*{{{*/
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-  T* aT_p=xNew<T>(size);
-  for (unsigned int i=0; i<size;++i) 
-    aT_p[i]=(T)0;
-  return aT_p;
-#else
-  T* aT_p=(T*)calloc(size,sizeof(T));
-  assert(aT_p);
-  return aT_p;
-#endif
-}/*}}}*/
-template <class T> T** xNewZeroInit(unsigned int dim1, unsigned int dim2) {/*{{{*/
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-  T** aT_pp=xNew<T>(dim1,dim2);
-  for (unsigned int i=0; i<dim1*dim2;++i)
-    (*aT_pp)[i]=(T)0;
-  return aT_pp;
-#else
-  T* buf=(T*)calloc(dim1*dim2*sizeof(T));
-  assert(buf );
-  T** aT_pp =(T**)malloc(dim1*sizeof(T*));
-  assert(aT_pp );
-  for (unsigned int i=0;i<dim1;++i) {
-    aT_pp [i]=buf;
-    buf+=dim2;
-  }
-  return aT_pp ;
-#endif
-}/*}}}*/
-template <class T> void xDelete(T**& aT_pp) {/*{{{*/
-  if (aT_pp) {
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-    delete [](*aT_pp);
-    delete [](aT_pp);
-#else
-    free((void*)*aT_pp)
-    free((void**)aT_pp);
-#endif
-  }
-  aT_pp=0;
-}/*}}}*/
-template <class T> void xDelete(T*& aT_p) {/*{{{*/
-  if (aT_p) 
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-    delete []aT_p;
-#else
-    free((void*)aT_p);
-#endif
-  aT_p=0;
-}/*}}}*/
-template <class T> T* xReNew(T* old, unsigned int old_size, unsigned int size) {/*{{{*/
-#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-	T* aT_p=0;
-	if (!old) { // no old memory
-		if (size)  
-		 aT_p=xNew<T>(size); // according to realloc behavior in manual page 
-	}
-	else { // have old memory
-		if (!size)  // but 0 size
-		 xDelete<T>(old); // according to realloc behavior in manual page
-		else { // non-zero size
-			assert(old_size); // have old memory - need to have old_size set or this call is bad
-			// allocate new, delete old; ; even for the case when size is 
-			// less than old_size we can't just keep the memory unchanged 
-			// because otherwise classes that have ctors/dtors with side-effects 
-			// may misbehave, for example classes with static instance/operations counters. 
-			aT_p=xNew<T>(size);
-			unsigned int iMax=(old_size<size)?old_size:size;
-			for (unsigned int i=0; i<iMax;++i) { 
-				// we need to copy the items by explicit assignments
-				aT_p[i]=old[i];
-			}
-			xDelete<T>(old);
-		}
-	}
-	return aT_p;
-#else
-	T* aT_p=0;
-	aT_p=(T*)realloc((void*)old,size*sizeof(T));
-	if (size) 
-	 assert(aT_p); // according to realloc behavior in manual page
-	return aT_p;
-#endif 
-}/*}}}*/
-
-#endif
Index: /issm/trunk-jpl/src/c/shared/Exceptions/exprintf.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exceptions/exprintf.cpp	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/Exceptions/exprintf.cpp	(revision 14894)
@@ -8,5 +8,4 @@
 #include <stdarg.h>
 #include <stdio.h>
-#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 
Index: /issm/trunk-jpl/src/c/shared/Threads/LaunchThread.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Threads/LaunchThread.cpp	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/Threads/LaunchThread.cpp	(revision 14894)
@@ -20,5 +20,5 @@
 
 #include "./issm_threads.h"
-#include "../Alloc/xNewDelete.h"
+#include "../Alloc/alloc.h"
 #include "../Exceptions/exceptions.h"
 #include "../../include/include.h"
Index: /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 14894)
@@ -3,5 +3,4 @@
  */
 #include "./trimesh.h"
-#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 
Index: /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 14894)
@@ -7,5 +7,4 @@
 #include "./trimesh.h"
 #include "../Exceptions/exceptions.h"
-#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 #include "../../include/include.h"
Index: /issm/trunk-jpl/src/c/shared/shared.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/shared.h	(revision 14893)
+++ /issm/trunk-jpl/src/c/shared/shared.h	(revision 14894)
@@ -7,5 +7,4 @@
 
 #include "./Alloc/alloc.h"
-#include "./Alloc/xNewDelete.h"
 #include "./Bamg/shared.h"
 #include "./Elements/elements.h"
Index: /issm/trunk-jpl/src/c/toolkits/mpi/patches/GetOwnershipBoundariesFromRange.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/GetOwnershipBoundariesFromRange.cpp	(revision 14893)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/patches/GetOwnershipBoundariesFromRange.cpp	(revision 14894)
@@ -12,4 +12,5 @@
 #include <stdio.h>
 #include "../../../shared/Alloc/alloc.h"
+#include "../../../classes/IssmComm.h"
 
 void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range,COMM comm){
