Index: /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h	(revision 19837)
+++ /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h	(revision 19838)
@@ -55,4 +55,19 @@
 #endif
 
+#ifdef _HAVE_JAVASCRIPT_MODULES_
+/* serial input macros: */
+#define INDEX       indexin,nelin,3
+#define X           xin,nodsin,1
+#define Y           yin,nodsin,1
+#define CONTOUR     contourx,contoury,contour_nods
+#define INTERPTYPE  interptypein
+#define EDGEVALUE   valuein
+#define WRAPPER(modulename) extern "C" { int  ContourToMeshModule(double** pin_nod, double** pin_nel, double* indexin, double* xin, double* yin, double* contourx, double* contoury, char* interptypein, int nelin, int nodsin, int contour_nods, double valuein)
+/* serial output macros: */
+#define PLHS0 pin_nod,NULL
+#define PLHS1 pin_nel,NULL
+#define nrhs 6
+#endif
+
 /* serial arg counts: */
 #undef NLHS
Index: /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.js
===================================================================
--- /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.js	(revision 19838)
+++ /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.js	(revision 19838)
@@ -0,0 +1,95 @@
+function ContourToMesh(indexin,xin,yin,contour,interptype,edgevalue){
+/* CONTOURTOMESH - Flag the elements or nodes inside a contour;
+	
+	      Usage: ;
+	         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue);
+	
+	         index,x,y: mesh triangulation
+	         contourname: name of .exp file containing the contours
+	         interptype: string definining type of interpolation ('element', or 'node')
+	         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.
+	         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node',
+	            or of size 0 otherwise.
+	         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', 
+	            or of size 0 otherwise.
+	
+	      Example: 
+	         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)
+	         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)
+	         return_values=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0); in_nodes=return_values[0]; in_elements=return_values[1];
+*/
+
+	//Dynamic allocations: {{{
+	//Retrieve elements and allocate on Module heap: 
+	
+	//input
+	
+	var dindex=new Int32Array(MatrixToList(indexin)); var nindex=dindex.length * dindex.BYTES_PER_ELEMENT;
+	var dindexPtr= Module._malloc(nindex); var indexHeap = new Uint8Array(Module.HEAPU8.buffer,dindexPtr,nindex);
+	indexHeap.set(new Uint8Array(dindex.buffer)); var index=indexHeap.byteOffset;
+
+	var dx=new Float64Array(xin); var nx=dx.length * dx.BYTES_PER_ELEMENT;
+	var dxPtr= Module._malloc(nx); var dxHeap = new Uint8Array(Module.HEAPU8.buffer,dxPtr,nx);
+	dxHeap.set(new Uint8Array(dx.buffer)); var x=dxHeap.byteOffset;
+	
+	var dy=new Float64Array(yin); var ny=dy.length * dy.BYTES_PER_ELEMENT;
+	var dyPtr= Module._malloc(nx); var dyHeap = new Uint8Array(Module.HEAPU8.buffer,dyPtr,ny);
+	dyHeap.set(new Uint8Array(dy.buffer)); var y=dyHeap.byteOffset;
+	
+	var dcontourx=new Float64Array(contour['x']); var nx=dcontourx.length * dcontourx.BYTES_PER_ELEMENT;
+	var dcontourxPtr= Module._malloc(nx); var contourxHeap = new Uint8Array(Module.HEAPU8.buffer,dcontourxPtr,nx);
+	contourxHeap.set(new Uint8Array(dcontourx.buffer)); var contourx=contourxHeap.byteOffset;
+
+	var dcontoury=new Float64Array(contour['y']); var ny=dcontoury.length * dcontoury.BYTES_PER_ELEMENT;
+	var dcontouryPtr = Module._malloc(ny); var contouryHeap = new Uint8Array(Module.HEAPU8.buffer,dcontouryPtr,ny);
+	contouryHeap.set(new Uint8Array(dcontoury.buffer)); var contoury=contouryHeap.byteOffset;
+	
+	nel=indexin.length;
+	nods=xin.length;
+	contour_nods=dcontourx.length;
+
+	//output
+	var in_nod;
+	var pin_nod= Module._malloc(4); 
+	var in_nel;
+	var pin_nel= Module._malloc(4); 
+	//}}}
+
+	//Declare ContourToMesh module: 
+	ContourToMeshModule = Module.cwrap('ContourToMeshModule','number',['number','number','number','number','number','number','number','string','number','number','number']);
+	
+	//Call ContourToMesh module: 
+	ContourToMeshModule(pin_nod,pin_nel,index,x,y,contourx,contoury,interptype,nel, nods, contour_nods, edgevalue);
+
+	/*Dynamic copying from heap: {{{*/
+	if(interptype == 'node'){
+		var in_nodptr = Module.getValue(pin_nod,'i32');
+		in_nod = Module.HEAPF64.slice(in_nodptr /8, in_nodptr/8 + nods);
+	}
+	else if (interptype == 'element'){
+		var in_nelptr = Module.getValue(pin_nel,'i32');
+		in_nel = Module.HEAPF64.slice(in_nelptr /8, in_nelptr/8 + nel);
+	}
+	else if (interptype == 'element and node'){
+		var in_nodptr = Module.getValue(pin_nod,'i32');
+		in_nod = Module.HEAPF64.slice(in_nodptr /8, in_nodptr/8 + nods);
+		var in_nelptr = Module.getValue(pin_nel,'i32');
+		in_nel = Module.HEAPF64.slice(in_nelptr /8, in_nelptr/8 + nel);
+	}
+	else throw Error('ContourToMeshModule error message: wrong interpolation type!');
+	/*}}}*/
+
+	/*Free ressources: */
+	Module._free(pin_nod); 
+	Module._free(pin_nel); 
+	
+	if(interptype == 'node'){
+		return in_nod;
+	}
+	else if (interptype == 'element'){
+		return in_nel;
+	}
+	else if (interptype == 'element and node'){
+		return [in_nod,in_nel];
+	}
+}
Index: /issm/trunk-jpl/src/wrappers/javascript/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 19837)
+++ /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 19838)
@@ -10,4 +10,5 @@
 bin_SCRIPTS += ../TriMesh/TriMesh.js  \
 			   ../NodeConnectivity/NodeConnectivity.js\
+			   ../ContourToMesh/ContourToMesh.js\
 			   ../ElementConnectivity/ElementConnectivity.js\
 			   ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.js\
@@ -80,4 +81,5 @@
 IssmModule_SOURCES = ../TriMesh/TriMesh.cpp \
 					 ../NodeConnectivity/NodeConnectivity.cpp\
+					 ../ContourToMesh/ContourToMesh.cpp\
 					 ../ElementConnectivity/ElementConnectivity.cpp\
 					 ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
@@ -87,5 +89,5 @@
 					 ../Issm/issm.cpp
 
-IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_  --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule','_ElementConnectivityModule','_InterpFromMeshToMesh2dModule','_IssmConfigModule','_EnumToStringModule','_StringToEnumModule','_IssmModule']"  -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s INVOKE_RUN=0
+IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_  --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule','_ContourToMeshModule','_ElementConnectivityModule','_InterpFromMeshToMesh2dModule','_IssmConfigModule','_EnumToStringModule','_StringToEnumModule','_IssmModule']"  -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s INVOKE_RUN=0
 IssmModule_LDADD = ${deps} $(TRIANGLELIB)  $(GSLLIB)
 #}}}
Index: /issm/trunk-jpl/src/wrappers/javascript/io/WriteJavascriptData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/javascript/io/WriteJavascriptData.cpp	(revision 19837)
+++ /issm/trunk-jpl/src/wrappers/javascript/io/WriteJavascriptData.cpp	(revision 19838)
@@ -84,4 +84,9 @@
 }
 /*}}}*/
+/*FUNCTION WriteData(IssmPDouble** pdouble, void* nullptr){{{*/
+void WriteData(IssmPDouble** pdouble, void*){
+	//do nothing
+}
+/*}}}*/
 /*FUNCTION WriteData(char** pstring, char* string){{{*/
 void WriteData(char** pstring, char* stringin){
Index: /issm/trunk-jpl/src/wrappers/javascript/io/javascriptio.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/javascript/io/javascriptio.h	(revision 19837)
+++ /issm/trunk-jpl/src/wrappers/javascript/io/javascriptio.h	(revision 19838)
@@ -25,4 +25,5 @@
 void WriteData(char** pstring, char* stringin);
 void WriteData(IssmPDouble* pdouble, IssmPDouble doublein);
+void WriteData(IssmPDouble** pdouble, void*);
 
 void FetchData(char** pstring, char* stringin);
