Index: /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp	(revision 2590)
+++ /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp	(revision 2591)
@@ -1,4 +1,11 @@
 /*! \file  ContourToMeshx.c
  */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
 
 #include "./ContourToMeshx.h"
@@ -14,10 +21,14 @@
 
 	/*Contour:*/
-	Contour* contouri=NULL;
-	int      numgrids;
-	double*  xc=NULL;
-	double*  yc=NULL;
 	double*  in_nod_serial;
 	double   value;
+
+	/*threading: */
+	ContourToMeshxThreadStruct gate;
+	int num=1;
+	#ifdef _MULTITHREADING_
+	num=_NUMTHREADS_;
+	#endif
+
 
 	/*output: */
@@ -28,15 +39,19 @@
 	in_elem=NewVec(nel);
 
-	/*Loop through all contours: */
-	for (i=0;i<numcontours;i++){
-		#ifdef _ISSM_DEBUG_
-			printf("\nHandling contour %i/%i\n",i,numcontours);
-		#endif
-		contouri=*(contours+i);
-		numgrids=contouri->nods;
-		xc=contouri->x;
-		yc=contouri->y;
-		IsInPoly(in_nod,xc,yc,numgrids,x,y,nods,edgevalue);
-	}
+	/*initialize thread parameters: */
+	gate.numcontours=numcontours;
+	gate.contours=contours;
+	gate.nods=nods;
+	gate.edgevalue=edgevalue;
+	gate.in_nod=in_nod;
+	gate.x=x;
+	gate.y=y;
+
+	/*launch the thread manager with ContourToMeshxt as a core: */
+	LaunchThread(ContourToMeshxt,(void*)&gate,num);
+
+	/*Assemble in_nod: */
+	VecAssemblyBegin(in_nod);
+	VecAssemblyEnd(in_nod);
 
 	/*Get in_nod serialised for next operation: */
@@ -53,6 +68,4 @@
 
 	/*Assemble vectors: */
-	VecAssemblyBegin(in_nod);
-	VecAssemblyEnd(in_nod);
 	VecAssemblyBegin(in_elem);
 	VecAssemblyEnd(in_elem);
Index: /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.h
===================================================================
--- /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.h	(revision 2590)
+++ /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.h	(revision 2591)
@@ -10,7 +10,24 @@
 #include "../objects/objects.h"
 
+/*threading: */
+typedef struct{
+
+	int numcontours;
+	Contour** contours;
+	int nods;
+	int edgevalue;
+	Vec in_nod;
+	double* x;
+	double* y;
+
+} ContourToMeshxThreadStruct;
+
+
 /* local prototypes: */
 int ContourToMeshx( Vec* pin_nods,Vec* pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);
 
+void* ContourToMeshxt(void* vContourToMeshxThreadStruct);
+
+
 #endif /* _CONTOURTOMESHX_H */
 
Index: /issm/trunk/src/c/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- /issm/trunk/src/c/ContourToMeshx/ContourToMeshxt.cpp	(revision 2591)
+++ /issm/trunk/src/c/ContourToMeshx/ContourToMeshxt.cpp	(revision 2591)
@@ -0,0 +1,77 @@
+/*!\file:  ContourToMeshxt.cpp
+ * \brief  "thread" core code for interpolating values from a structured grid.
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "./ContourToMeshx.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "ContourToMeshxt"
+
+void* ContourToMeshxt(void* vpthread_handle){
+	
+	int noerr=1;
+
+	/*gate variables :*/
+	ContourToMeshxThreadStruct* gate=NULL;
+	pthread_handle* handle=NULL;
+	int     my_thread;
+	int     num_threads;
+	int     i0;
+	int     i1;
+
+	int i;
+
+	/*Contour:*/
+	Contour* contouri=NULL;
+	int      numgrids;
+	double*  xc=NULL;
+	double*  yc=NULL;
+
+
+	/*parameters: */
+	int numcontours;
+	Contour** contours=NULL;
+	int nods;
+	int edgevalue;
+	double* x=NULL;
+	double* y=NULL;
+	Vec in_nod=NULL;
+
+
+	/*recover handle and gate: */
+	handle=(pthread_handle*)vpthread_handle;
+	gate=(ContourToMeshxThreadStruct*)handle->gate;
+	my_thread=handle->id;
+	num_threads=handle->num;
+
+	/*recover parameters :*/
+	numcontours=gate->numcontours;
+	contours=gate->contours;
+	nods=gate->nods;
+	edgevalue=gate->edgevalue;
+	in_nod=gate->in_nod;
+	x=gate->x;
+	y=gate->y;
+
+	/*distribute indices across threads :*/
+	PartitionRange(&i0,&i1,nods,num_threads,my_thread);
+
+	/*Loop through all contours: */
+	for (i=0;i<numcontours;i++){
+		#ifdef _ISSM_DEBUG_
+			printf("\nHandling contour %i/%i\n",i,numcontours);
+		#endif
+		contouri=*(contours+i);
+		numgrids=contouri->nods;
+		xc=contouri->x;
+		yc=contouri->y;
+		IsInPoly(in_nod,xc,yc,numgrids,x,y,i0,i1,edgevalue);
+	}
+
+}
Index: /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp	(revision 2590)
+++ /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp	(revision 2591)
@@ -33,5 +33,5 @@
 		xc=contouri->x;
 		yc=contouri->y;
-		IsInPoly(flags,xc,yc,numgrids,x,y,nods,edgevalue);
+		IsInPoly(flags,xc,yc,numgrids,x,y,0,nods,edgevalue);
 	}
 
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 2590)
+++ /issm/trunk/src/c/Makefile.am	(revision 2591)
@@ -263,4 +263,5 @@
 					./MeshPartitionx/MeshPartitionx.h\
 					./ContourToMeshx/ContourToMeshx.cpp\
+					./ContourToMeshx/ContourToMeshxt.cpp\
 					./ContourToMeshx/ContourToMeshx.h\
 					./ContourToNodesx/ContourToNodesx.cpp\
@@ -561,4 +562,5 @@
 					./MeshPartitionx/MeshPartitionx.h\
 					./ContourToMeshx/ContourToMeshx.cpp\
+					./ContourToMeshx/ContourToMeshxt.cpp\
 					./ContourToMeshx/ContourToMeshx.h\
 					./Reducevectorgtosx/Reducevectorgtosx.cpp\
