Index: /issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp	(revision 18522)
+++ /issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp	(revision 18523)
@@ -1,3 +1,3 @@
-/*!\file PentaRef.c
+/*!\file PentaRef.cpp
  * \brief: implementation of the PentaRef object
  */
@@ -26,4 +26,5 @@
 #define NUMNODESP2b   19
 #define NUMNODESP2xP4 30
+#define NUMNODESMAX   30
 
 /*Object constructors and destructor*/
@@ -886,22 +887,23 @@
 /*}}}*/
 void PentaRef::GetInputValue(IssmDouble* pvalue,IssmDouble* plist,Gauss* gauss,int finiteelement){/*{{{*/
-
-	/*Output*/
-	IssmDouble value =0.;
+	/* WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.*/
+
+	/*Allocate basis functions*/
+	IssmDouble  basis[NUMNODESMAX];
 
 	/*Fetch number of nodes for this finite element*/
 	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions*/
-	IssmDouble* basis=xNew<IssmDouble>(numnodes);
-	GetNodalFunctions(basis, gauss,finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions at this point*/
+	GetNodalFunctions(&basis[0],gauss,finiteelement);
 
 	/*Calculate parameter for this Gauss point*/
+	IssmDouble value =0.;
 	for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];
 
 	/*Assign output pointer*/
-	xDelete<IssmDouble>(basis);
 	*pvalue = value;
-
 }
 /*}}}*/
@@ -915,19 +917,23 @@
 	 *
 	 *   p is a vector of size 3x1 already allocated.
+	 *
+	 * WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.
 	 */
 
-	/*Output*/
+	/*Allocate derivatives of basis functions*/
+	IssmDouble  dbasis[3*NUMNODESMAX];
+
+	/*Fetch number of nodes for this finite element*/
+	int numnodes = this->NumberofNodes(finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions derivatives at this point*/
+	GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement);
+
+	/*Calculate parameter for this Gauss point*/
 	IssmDouble dpx=0.;
 	IssmDouble dpy=0.;
 	IssmDouble dpz=0.;
-
-	/*Fetch number of nodes for this finite element*/
-	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions derivatives*/
-	IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes);
-	GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);
-
-	/*Calculate parameter for this Gauss point*/
 	for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];
 	for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i];
@@ -935,9 +941,7 @@
 
 	/*Assign values*/
-	xDelete<IssmDouble>(dbasis);
 	p[0]=dpx;
 	p[1]=dpy;
 	p[2]=dpz;
-
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp	(revision 18522)
+++ /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp	(revision 18523)
@@ -18,4 +18,5 @@
 #define NUMNODESP0  1
 #define NUMNODESP1  2
+#define NUMNODESMAX 2
 
 /*Object constructors and destructor*/
@@ -115,42 +116,46 @@
 	 *
 	 * p is a vector already allocated.
+	 *
+	 * WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.
 	 */
 
-	/*Output*/
-	IssmDouble dpx = 0.;
+	/*Allocate derivatives of basis functions*/
+	IssmDouble  dbasis[1*NUMNODESMAX];
 
 	/*Fetch number of nodes for this finite element*/
 	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions derivatives*/
-	IssmDouble* dbasis=xNew<IssmDouble>(1*numnodes);
-	GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions derivatives at this point*/
+	GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement);
 
 	/*Calculate parameter for this Gauss point*/
-	for(int i=0;i<numnodes;i++) dpx += dbasis[i]*plist[i];
+	IssmDouble dpx=0.;
+	for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];
 
 	/*Assign values*/
-	xDelete<IssmDouble>(dbasis);
-	*p=dpx;
-
+	p[0]=dpx;
 }
 /*}}}*/
 void SegRef::GetInputValue(IssmDouble* p, IssmDouble* plist, GaussSeg* gauss,int finiteelement){/*{{{*/
-
-	/*Output*/
-	IssmDouble value =0.;
+	/* WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.*/
+
+	/*Allocate basis functions*/
+	IssmDouble  basis[NUMNODESMAX];
 
 	/*Fetch number of nodes for this finite element*/
 	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions*/
-	IssmDouble* basis=xNew<IssmDouble>(numnodes);
-	GetNodalFunctions(basis, gauss,finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions at this point*/
+	GetNodalFunctions(&basis[0],gauss,finiteelement);
 
 	/*Calculate parameter for this Gauss point*/
+	IssmDouble value =0.;
 	for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];
 
 	/*Assign output pointer*/
-	xDelete<IssmDouble>(basis);
 	*p = value;
 }
Index: /issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp	(revision 18522)
+++ /issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp	(revision 18523)
@@ -20,4 +20,5 @@
 #define NUMNODESP1b 5
 #define NUMNODESP2  10
+#define NUMNODESMAX 10
 
 /*Object constructors and destructor*/
@@ -217,19 +218,23 @@
 	 *
 	 *   p is a vector of size 3x1 already allocated.
+	 *
+	 * WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.
 	 */
 
-	/*Output*/
+	/*Allocate derivatives of basis functions*/
+	IssmDouble  dbasis[3*NUMNODESMAX];
+
+	/*Fetch number of nodes for this finite element*/
+	int numnodes = this->NumberofNodes(finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions derivatives at this point*/
+	GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement);
+
+	/*Calculate parameter for this Gauss point*/
 	IssmDouble dpx=0.;
 	IssmDouble dpy=0.;
 	IssmDouble dpz=0.;
-
-	/*Fetch number of nodes for this finite element*/
-	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions derivatives*/
-	IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes);
-	GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);
-
-	/*Calculate parameter for this Gauss point*/
 	for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];
 	for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i];
@@ -237,5 +242,4 @@
 
 	/*Assign values*/
-	xDelete<IssmDouble>(dbasis);
 	p[0]=dpx;
 	p[1]=dpy;
@@ -244,20 +248,22 @@
 /*}}}*/
 void TetraRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/
-
-	/*Output*/
-	IssmDouble value =0.;
+	/* WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.*/
+
+	/*Allocate basis functions*/
+	IssmDouble  basis[NUMNODESMAX];
 
 	/*Fetch number of nodes for this finite element*/
 	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions*/
-	IssmDouble* basis=xNew<IssmDouble>(numnodes);
-	GetNodalFunctions(basis, gauss,finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions at this point*/
+	GetNodalFunctions(&basis[0],gauss,finiteelement);
 
 	/*Calculate parameter for this Gauss point*/
+	IssmDouble value =0.;
 	for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];
 
 	/*Assign output pointer*/
-	xDelete<IssmDouble>(basis);
 	*p = value;
 }
Index: /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 18522)
+++ /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 18523)
@@ -21,4 +21,5 @@
 #define NUMNODESP2  6
 #define NUMNODESP2b 7
+#define NUMNODESMAX 7
 
 /*Object constructors and destructor*/
@@ -354,5 +355,4 @@
 /*}}}*/
 void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/
-
 	/*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 
 	 * point specified by gauss_basis:
@@ -361,45 +361,50 @@
 	 *
 	 * p is a vector already allocated.
+	 *
+	 * WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.
 	 */
 
-	/*Output*/
+	/*Allocate derivatives of basis functions*/
+	IssmDouble  dbasis[2*NUMNODESMAX];
+
+	/*Fetch number of nodes for this finite element*/
+	int numnodes = this->NumberofNodes(finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions derivatives at this point*/
+	GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement);
+
+	/*Calculate parameter for this Gauss point*/
 	IssmDouble dpx=0.;
 	IssmDouble dpy=0.;
+	for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];
+	for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i];
+
+	/*Assign values*/
+	p[0]=dpx;
+	p[1]=dpy;
+
+}
+/*}}}*/
+void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/
+	/* WARNING: For a significant gain in performance, it is better to use
+	 * static memory allocation instead of dynamic.*/
+
+	/*Allocate basis functions*/
+	IssmDouble  basis[NUMNODESMAX];
 
 	/*Fetch number of nodes for this finite element*/
 	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions derivatives*/
-	IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes);
-	GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);
+	_assert_(numnodes<=NUMNODESMAX);
+
+	/*Get basis functions at this point*/
+	GetNodalFunctions(&basis[0],gauss,finiteelement);
 
 	/*Calculate parameter for this Gauss point*/
-	for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];
-	for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i];
-
-	/*Assign values*/
-	xDelete<IssmDouble>(dbasis);
-	p[0]=dpx;
-	p[1]=dpy;
-
-}
-/*}}}*/
-void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/
-
-	/*Output*/
 	IssmDouble value =0.;
-
-	/*Fetch number of nodes for this finite element*/
-	int numnodes = this->NumberofNodes(finiteelement);
-
-	/*Get nodal functions*/
-	IssmDouble* basis=xNew<IssmDouble>(numnodes);
-	GetNodalFunctions(basis, gauss,finiteelement);
-
-	/*Calculate parameter for this Gauss point*/
 	for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];
 
 	/*Assign output pointer*/
-	xDelete<IssmDouble>(basis);
 	*p = value;
 }
