Index: /issm/trunk/src/Makefile.am
===================================================================
--- /issm/trunk/src/Makefile.am	(revision 12330)
+++ /issm/trunk/src/Makefile.am	(revision 12331)
@@ -1,2 +1,2 @@
-EXTRA_DIST =  perl  pro
-SUBDIRS = c mex m
+EXTRA_DIST =  perl  pro 
+SUBDIRS = c modules m  py
Index: /issm/trunk/src/ad/todo
===================================================================
--- /issm/trunk/src/ad/todo	(revision 12330)
+++ /issm/trunk/src/ad/todo	(revision 12331)
@@ -29,2 +29,14 @@
 amatrix will be used in adolc. pmatrix will be used in Petsc routines. Matrix will 
 have routines to map one into the other.
+
+
+Ad: 
+Eric: 
+Create ISSM namespace.
+Make Matrix Assembly one homogeneous block.
+Make Validation suite for Jean for his prognostic capabilities.
+Jean: 
+typedef all double to ISSM_DOUBLE 
+
+Create an alloc layer with template functions for new and delete.
+Check that the new code  is modular --without-kml, options are up to date.
Index: /issm/trunk/src/android/test102/test102.petsc
===================================================================
--- /issm/trunk/src/android/test102/test102.petsc	(revision 12331)
+++ /issm/trunk/src/android/test102/test102.petsc	(revision 12331)
@@ -0,0 +1,19 @@
+%Petsc options file: test102.petsc written from Matlab solver array
+
++NoneAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
+
++DiagnosticVertAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
Index: /issm/trunk/src/android/test102/test102.sh
===================================================================
--- /issm/trunk/src/android/test102/test102.sh	(revision 12331)
+++ /issm/trunk/src/android/test102/test102.sh	(revision 12331)
@@ -0,0 +1,2 @@
+#!/bin/sh
+/Users/larour/issm-uci/trunk-jpl/bin/issm.exe DiagnosticSolution /Users/larour/issm-uci/trunk-jpl/src/android/test102 test102 
Index: /issm/trunk/src/dox/issm.dox
===================================================================
--- /issm/trunk/src/dox/issm.dox	(revision 12330)
+++ /issm/trunk/src/dox/issm.dox	(revision 12331)
@@ -46,20 +46,20 @@
 </th>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">533</td><td  bgcolor=#FFFFFF style="text-align:right;">15491</td><td  bgcolor=#FFFFFF style="text-align:right;">17275</td><td  bgcolor=#FFFFFF style="text-align:right;">58005</td><td  bgcolor=#FFFFFF style="text-align:right;">90771</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">499</td><td  bgcolor=#FFFFFF style="text-align:right;">14338</td><td  bgcolor=#FFFFFF style="text-align:right;">16340</td><td  bgcolor=#FFFFFF style="text-align:right;">54651</td><td  bgcolor=#FFFFFF style="text-align:right;">85329</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">977</td><td  bgcolor=#C6E2FF style="text-align:right;">7199</td><td  bgcolor=#C6E2FF style="text-align:right;">13702</td><td  bgcolor=#C6E2FF style="text-align:right;">31690</td><td  bgcolor=#C6E2FF style="text-align:right;">52591</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">919</td><td  bgcolor=#C6E2FF style="text-align:right;">6875</td><td  bgcolor=#C6E2FF style="text-align:right;">13184</td><td  bgcolor=#C6E2FF style="text-align:right;">30350</td><td  bgcolor=#C6E2FF style="text-align:right;">50409</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">399</td><td  bgcolor=#FFFFFF style="text-align:right;">3069</td><td  bgcolor=#FFFFFF style="text-align:right;">2727</td><td  bgcolor=#FFFFFF style="text-align:right;">10358</td><td  bgcolor=#FFFFFF style="text-align:right;">16154</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">366</td><td  bgcolor=#FFFFFF style="text-align:right;">2665</td><td  bgcolor=#FFFFFF style="text-align:right;">2529</td><td  bgcolor=#FFFFFF style="text-align:right;">9400</td><td  bgcolor=#FFFFFF style="text-align:right;">14594</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">1061</td><td  bgcolor=#C6E2FF style="text-align:right;">242</td><td  bgcolor=#C6E2FF style="text-align:right;">8941</td><td  bgcolor=#C6E2FF style="text-align:right;">10244</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">993</td><td  bgcolor=#C6E2FF style="text-align:right;">80</td><td  bgcolor=#C6E2FF style="text-align:right;">8237</td><td  bgcolor=#C6E2FF style="text-align:right;">9310</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Objective  C </th><td  bgcolor=#FFFFFF style="text-align:right;">9</td><td  bgcolor=#FFFFFF style="text-align:right;">98</td><td  bgcolor=#FFFFFF style="text-align:right;">0</td><td  bgcolor=#FFFFFF style="text-align:right;">370</td><td  bgcolor=#FFFFFF style="text-align:right;">468</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">47</td><td  bgcolor=#FFFFFF style="text-align:right;">183</td><td  bgcolor=#FFFFFF style="text-align:right;">518</td><td  bgcolor=#FFFFFF style="text-align:right;">1099</td><td  bgcolor=#FFFFFF style="text-align:right;">1800</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">61</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">271</td><td  bgcolor=#C6E2FF style="text-align:right;">430</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Objective  C </th><td  bgcolor=#C6E2FF style="text-align:right;">9</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">0</td><td  bgcolor=#C6E2FF style="text-align:right;">370</td><td  bgcolor=#C6E2FF style="text-align:right;">468</td>
 </tr>
 <tr>
@@ -67,14 +67,14 @@
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> IDL </th><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">18</td><td  bgcolor=#C6E2FF style="text-align:right;">4</td><td  bgcolor=#C6E2FF style="text-align:right;">124</td><td  bgcolor=#C6E2FF style="text-align:right;">146</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">5</td><td  bgcolor=#C6E2FF style="text-align:right;">46</td><td  bgcolor=#C6E2FF style="text-align:right;">71</td><td  bgcolor=#C6E2FF style="text-align:right;">226</td><td  bgcolor=#C6E2FF style="text-align:right;">343</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C </th><td  bgcolor=#FFFFFF style="text-align:right;">2</td><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">24</td><td  bgcolor=#FFFFFF style="text-align:right;">30</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> IDL </th><td  bgcolor=#FFFFFF style="text-align:right;">1</td><td  bgcolor=#FFFFFF style="text-align:right;">18</td><td  bgcolor=#FFFFFF style="text-align:right;">4</td><td  bgcolor=#FFFFFF style="text-align:right;">124</td><td  bgcolor=#FFFFFF style="text-align:right;">146</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Python </th><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">4</td><td  bgcolor=#C6E2FF style="text-align:right;">13</td><td  bgcolor=#C6E2FF style="text-align:right;">18</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> C </th><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">24</td><td  bgcolor=#C6E2FF style="text-align:right;">30</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1941</td><td  bgcolor=#FFFFFF style="text-align:right;">27022</td><td  bgcolor=#FFFFFF style="text-align:right;">34078</td><td  bgcolor=#FFFFFF style="text-align:right;">110036</td><td  bgcolor=#FFFFFF style="text-align:right;">171136</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1858</td><td  bgcolor=#FFFFFF style="text-align:right;">25240</td><td  bgcolor=#FFFFFF style="text-align:right;">32752</td><td  bgcolor=#FFFFFF style="text-align:right;">104721</td><td  bgcolor=#FFFFFF style="text-align:right;">162713</td>
 </tr>
 </table>
Index: /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp
===================================================================
--- /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp	(revision 12331)
+++ /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp	(revision 12331)
@@ -0,0 +1,62 @@
+/*!\file:  AverageFilter.cpp
+ * \brief fill holes in matlab velocity array
+	this matlab module is an adaptation of a routine written by Robber 
+	Crippen.  The original routine was designed for the SRTM mission at JPL, 
+	and can be found in the current directory, under the name 
+	AverageFilterCrippen.  It fills void holes in an image, using an interpolation 
+	algorithm, and optionnally a smoothing algorithm. 
+	This matlab module extends the Crippen routine to be used in Matlab, 
+	using double arrays found in the workspace, and loaded directly into memory.
+*/
+
+
+#include "./AverageFilter.h"
+
+void mexFunction( int nlhs, mxArray* plhs[],
+				  int nrhs, const mxArray* prhs[])
+{
+
+	int i,j;
+
+	/* required input: */
+	double* imagein=NULL;
+	int     imagein_rows,imagein_cols;
+	int     smooth;
+
+
+	/* output: */
+	mxArray* pfield=NULL;
+	double* imageout=NULL;
+	int     imageout_rows,imageout_cols;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&AverageFilterUsage);
+
+	/*Fetch data: */
+	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchData(&smooth,SMOOTH);
+	
+	/*Run core hole filler routine: */
+	AverageFilterx( &imageout,imagein,imagein_rows,imagein_cols,smooth);
+
+	/* output: */
+	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+
+void AverageFilterUsage(void)
+{
+	printf("   AverageFilter usage:\n");
+	printf("   [image_out]=AverageFilter(image_in,pixels);\n\n");
+	printf("   where:\n");
+	printf("      image_in in double format\n");
+	printf("      pixels: characteristic size of smoothing\n");
+	printf("      image_out in double format\n");
+	printf("\n");
+}
Index: /issm/trunk/src/modules/AverageFilter/AverageFilter.h
===================================================================
--- /issm/trunk/src/modules/AverageFilter/AverageFilter.h	(revision 12331)
+++ /issm/trunk/src/modules/AverageFilter/AverageFilter.h	(revision 12331)
@@ -0,0 +1,36 @@
+
+/*
+	AverageFilter.h
+*/
+
+
+#ifndef _AVERAGEFILTER_H
+#define _AVERAGEFILTER_H
+
+/* local prototypes: */
+void AverageFilterUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "AverageFilter"
+
+
+/* serial input macros: */
+#define IMAGEIN prhs[0]
+#define SMOOTH prhs[1]
+
+/* serial output macros: */
+#define IMAGEOUT &plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif  /* _AVERAGEFILTER_H */
Index: /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp
===================================================================
--- /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12331)
+++ /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12331)
@@ -0,0 +1,86 @@
+/*\file BamgConvertMesh.c
+ *\brief: bamg module.
+ */
+#include "./BamgConvertMesh.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input: */
+	double* index=NULL;
+	int     index_rows;
+	double* x=NULL;
+	int     x_cols;
+	double* y=NULL;
+	int     y_rows;
+	int     y_cols;
+
+	/*Output*/
+	BamgMesh* bamgmesh=NULL;
+	BamgGeom* bamggeom=NULL;
+	mxArray* bamgmesh_mat=NULL;
+	mxArray* bamggeom_mat=NULL;
+
+	/*Intermediary*/
+	int nods;
+	int nels;
+	int verbose=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgConvertMeshUsage);
+
+	/*Initialize Bamg outputs*/
+	bamggeom=new BamgGeom();
+	bamgmesh=new BamgMesh();
+
+	/*Input datasets: */
+	if (verbose) printf("Fetching inputs\n");
+	FetchData(&index,&nels,&index_rows,INDEXHANDLE);
+	FetchData(&x,&nods,&x_cols,XHANDLE);
+	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+
+	/*Check inputs*/
+	if (nels<0){
+		_error_("Number of elements must be positive, check index number of lines");
+	}
+	if (nods<0){
+		_error_("Number of nods must be positive, check x and y sizes");
+	}
+	if (index_rows!=3){
+		_error_("index should have 3 columns");
+	}
+	if (y_rows!=nods){
+		_error_("x and y do not have the same length");
+	}
+	if (x_cols>1 || y_cols>1){
+		_error_("x and y should have only one column");
+	}
+
+	/* Run core computations: */
+	if (verbose) printf("Call core\n");
+	BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels);
+
+	/*Generate output Matlab Structures*/
+	WriteData(BAMGGEOMOUT,bamggeom);
+	WriteData(BAMGMESHOUT,bamgmesh);
+
+	/*Clean up*/
+	delete bamggeom;
+	delete bamgmesh;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgConvertMeshUsage(void)
+{
+	_printf_(true,"BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);\n");
+	_printf_(true,"      index: index of the mesh\n");
+	_printf_(true,"      x,y: coordinates of the nodes\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.h
===================================================================
--- /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.h	(revision 12331)
+++ /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*!\file BamgConvertMesh.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _BAMGCONVERTMESH_H
+#define _BAMGCONVERTMESH_H
+
+/* local prototypes: */
+void BamgConvertMeshUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgConvertMesh"
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+
+/* serial output macros: */
+#define BAMGMESHOUT    (mxArray**)&plhs[0]
+#define BAMGGEOMOUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  3
+
+#endif
Index: /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp
===================================================================
--- /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp	(revision 12331)
+++ /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp	(revision 12331)
@@ -0,0 +1,56 @@
+/*\file BamgMesher.c
+ *\brief: mesher that uses the bamg library
+ */
+#include "./BamgMesher.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*Outputs*/
+	mxArray* bamgmesh_mat=NULL;
+	mxArray* bamggeom_mat=NULL;
+
+	/*diverse: */
+	BamgOpts *bamgopts=NULL;
+	BamgMesh *bamgmesh_in=NULL;
+	BamgGeom *bamggeom_in=NULL;
+	BamgMesh *bamgmesh_out=NULL;
+	BamgGeom *bamggeom_out=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgMesherUsage);
+
+	/*Initialize outputs*/
+	bamggeom_out=new BamgGeom();
+	bamgmesh_out=new BamgMesh();
+
+	/*Fetch inputs: */
+	FetchData(&bamgopts,BAMGOPTIONS);
+	FetchData(&bamggeom_in,BAMGGEOMIN);
+	FetchData(&bamgmesh_in,BAMGMESHIN);
+
+	/*Call x layer*/
+	Bamgx(bamgmesh_out,bamggeom_out,bamgmesh_in,bamggeom_in,bamgopts);
+
+	/*Generate output Matlab Structures*/
+	WriteData(BAMGGEOMOUT,bamggeom_out);
+	WriteData(BAMGMESHOUT,bamgmesh_out);
+
+	/*Free ressources: */
+	delete bamgopts;
+	delete bamggeom_in;
+	delete bamggeom_out;
+	delete bamgmesh_in;
+	delete bamgmesh_out;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgMesherUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"   usage: [bamgmesh,bamggeom]=%s(bamgmesh,bamggeom,bamgoptions);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/BamgMesher/BamgMesher.h
===================================================================
--- /issm/trunk/src/modules/BamgMesher/BamgMesher.h	(revision 12331)
+++ /issm/trunk/src/modules/BamgMesher/BamgMesher.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*
+	BamgMesherUsage.h
+*/
+
+#ifndef _BAMG_MESHER_H_
+#define _BAMG_MESHER_H_
+
+/* local prototypes: */
+void BamgMesherUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgMesher"
+    
+/* serial input macros: */
+#define BAMGMESHIN  (mxArray*)prhs[0]
+#define BAMGGEOMIN  (mxArray*)prhs[1]
+#define BAMGOPTIONS (mxArray*)prhs[2]
+
+/* serial output macros: */
+#define BAMGMESHOUT    (mxArray**)&plhs[0]
+#define BAMGGEOMOUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  3
+
+#endif  /* _BAMG_MESHER_H_ */
+
Index: /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp
===================================================================
--- /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12331)
+++ /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12331)
@@ -0,0 +1,58 @@
+/*\file BamgTriangulate.c
+ *\brief: bamg module.
+ */
+#include "./BamgTriangulate.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     x_cols;
+	int     y_rows,y_cols;
+	int nods;
+
+	/*Output*/
+	int* index=NULL;
+	int  nels;
+
+	/*Intermediary*/
+	int verbose=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgTriangulateUsage);
+
+	/*Input datasets: */
+	if (verbose) printf("Fetching inputs\n");
+	FetchData(&x,&nods,&x_cols,XHANDLE);
+	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+
+	/*Check inputs*/
+	if(y_rows!=nods)         _error_("x and y do not have the same length");
+	if(x_cols>1 || y_cols>1) _error_("x and y should have only one column");
+	if(nods<3)               _error_("At least 3 points are required");
+
+	/* Run core computations: */
+	if (verbose) printf("Call core\n");
+	BamgTriangulatex(&index,&nels,x,y,nods);
+
+	/*Write output*/
+	WriteData(INDEX,index,nels,3);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgTriangulateUsage(void)
+{
+	_printf_(true,"BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      index=BamgTriangulate(x,y);\n");
+	_printf_(true,"      index: index of the triangulation\n");
+	_printf_(true,"      x,y: coordinates of the nodes\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.h
===================================================================
--- /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.h	(revision 12331)
+++ /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.h	(revision 12331)
@@ -0,0 +1,34 @@
+/*!\file BamgTriangulate.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _BAMGTRIANGULATE_H
+#define _BAMGTRIANGULATE_H
+
+/* local prototypes: */
+void BamgTriangulateUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgTriangulate"
+
+
+/* serial input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+
+/* serial output macros: */
+#define INDEX (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif
Index: /issm/trunk/src/modules/Chaco/Chaco.cpp
===================================================================
--- /issm/trunk/src/modules/Chaco/Chaco.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Chaco/Chaco.cpp	(revision 12331)
@@ -0,0 +1,137 @@
+/*\file Chaco.c
+ *\brief:  Chaco partitioner mex module
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include "./Chaco.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+   
+	int i;
+	int nterms;
+
+	/*Inputs: */
+	int     nvtxs;               /* number of vertices in graph           */
+	int    *start;               /* start of edge list for each vertex    */
+	int    *adjacency;           /* edge list data                        */
+	int    *vwgts       = NULL;  /* weights for all vertices              */
+	int     nedges;
+	float  *ewgts       = NULL;  /* weights for all edges                 */
+	float  *x           = NULL;
+	float  *y           = NULL;
+	float  *z           = NULL;  /* coordinates for inertial method       */
+	double  options[10] = {1,1,0,0,1,1,50,0,.001,7654321}; /* architecture and partitioning options */
+	double *in_options  = NULL;
+	int    *nparts      = NULL;   /* number of parts options               */
+	int     npart;
+	double *goal        = NULL;   /* desired set sizes                     */
+
+	/*intermediary pointers: */
+	mwIndex *mwstart, *mwadjacency;
+	double  *doublepointer;
+
+	/*output: */
+   short  *assignment       = NULL; /* set number of each vtx (length nvtxs+1)                */
+   double *doubleassignment = NULL; /*holds assignment, in double format, to return to matlab */
+
+	#ifndef _HAVE_CHACO_ //only works if dakota library has been compiled in.
+	_error_(" Chaco not available! Cannot carry out Chaco partitioning!");
+	#endif
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ChacoUsage);
+
+	/*Fetch adjacency matrix: */
+	nvtxs = mxGetN(A_IN);
+	mwstart = mxGetJc(A_IN);
+	start=(int*)xmalloc((nvtxs+1)*sizeof(int));
+	for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i];
+
+	mwadjacency = mxGetIr(A_IN);
+	adjacency = (int*)xmalloc(mxGetNzmax(A_IN)*sizeof(int));
+	for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i];
+
+	nedges = start[nvtxs];
+	if(!mxIsEmpty(EWGTS_IN)){
+		ewgts = (float*)xcalloc(nedges, sizeof(float));
+		doublepointer=mxGetPr(A_IN);
+		for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i];
+	}
+	else ewgts=NULL;
+
+	/*Fetch rest of data: */
+	FetchData(&vwgts,&nterms,VWGTS_IN); 
+	FetchData(&x,&nterms,X_IN); 
+	FetchData(&y,&nterms,Y_IN); 
+	FetchData(&z,&nterms,Z_IN); 
+	FetchData(&in_options,&nterms,OPTNS_IN); 
+	for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options
+	FetchData(&npart,NPARTS_IN); 
+	nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
+	FetchData(&goal,&nterms,GOAL_IN); 
+	
+	/*Some debugging print: {{{*/
+	#ifdef _DEBUG_
+	printf("nvtxs: %i\n",nvtxs);
+	printf("options: [");
+	for(i=0;i<10;i++)printf("%g|",options[i]);
+	printf("]\n");
+	printf("start: \n");
+	for (i=0; i<nvtxs+1;i++)printf("%i ",start[i]);
+	printf("\n");
+	printf("adjacency: \n");
+	for (i=0; i<mxGetNzmax(A_IN);i++)printf("%i ",adjacency[i]);
+	printf("\n");
+	printf("nedges: %i %p\n",nedges,ewgts);
+	if(ewgts) for (i = 0; i < nedges; i++)printf("%g ",ewgts[i]);
+	printf("\n");
+	printf("vwgts:\n");
+	for (i = 0; i < nvtxs; i++)printf("%g ",vwgts[i]);
+	printf("\n");
+	printf("nparts: %i\n",nparts[0]);
+	printf("goal: %p\n",goal);
+	#endif
+	/*}}}*/
+	
+	/*Allocate output: */
+	assignment = (short*)xcalloc(nvtxs, sizeof(short));
+	
+    /*Call core: */
+	Chacox(nvtxs, start, adjacency, vwgts, ewgts, x, y, z, assignment, options, nparts, goal);
+
+    /*Output data: */
+	doubleassignment=(double*)xmalloc(nvtxs*sizeof(double));
+	for(i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i];
+	WriteData(ASSGN_OUT,doubleassignment,nvtxs);
+
+	/*Free ressources:*/
+	xfree((void**)&assignment); 
+	xfree((void**)&goal);
+	xfree((void**)&nparts);
+	xfree((void**)&z);
+	xfree((void**)&y);
+	xfree((void**)&x);
+	xfree((void**)&ewgts);
+	xfree((void**)&vwgts);
+	xfree((void**)&adjacency);
+	xfree((void**)&start);
+	xfree((void**)&doubleassignment);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void ChacoUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/Chaco/Chaco.h
===================================================================
--- /issm/trunk/src/modules/Chaco/Chaco.h	(revision 12331)
+++ /issm/trunk/src/modules/Chaco/Chaco.h	(revision 12331)
@@ -0,0 +1,44 @@
+/*!\file:  Chaco.h
+ * \brief header file for Chaco module.
+ */ 
+
+#ifndef _CHACO_H
+#define _CHACO_H
+
+/* local prototypes: */
+void ChacoUsage(void);
+
+#include <stdio.h>
+#include <string.h>    /*  strcasecmp  */
+#include <time.h>      /*  clock,time,difftime  */
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define A_IN (mxArray*)prhs[0]
+#define VWGTS_IN (mxArray*)prhs[1]
+#define EWGTS_IN (mxArray*)prhs[2]
+#define X_IN (mxArray*)prhs[3]
+#define Y_IN (mxArray*)prhs[4]
+#define Z_IN (mxArray*)prhs[5]
+#define OPTNS_IN (mxArray*)prhs[6]
+#define NPARTS_IN (mxArray*)prhs[7]
+#define GOAL_IN (mxArray*)prhs[8]
+
+/* serial output macros: */
+#define ASSGN_OUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  9
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Chaco"
+
+#endif  /* _CHACO_H */
Index: /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12331)
+++ /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12331)
@@ -0,0 +1,113 @@
+/*! \file  ContourtoMesh
+    \brief: takes an  contour file, and figures out which nodes or elements from the mesh  
+    are inside this contour. 
+	usage:
+	[in_nod,in_elem]=ContourToMesh(index,x,y,contours,interptype,edgevalue);
+	
+	input:
+
+		index,x,y: delaunay triangulation.
+		contours: structure holding sets of vertices making open contours. 
+		interptype: string definining type of interpolation ('element', or 'node', or 'element and node');
+		edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons
+
+	output:
+		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.
+*/
+	
+#include "./ContourToMesh.h"
+
+WRAPPER(ContourToMesh){
+
+	int i,j;
+
+	/* required input: */
+	int     edgevalue;
+	double *index      = NULL;
+	int     nel;
+	double *x          = NULL;
+	int     nods;
+	double *y          = NULL;
+	char   *interptype = NULL;
+	char* contourname  = NULL;
+	DataSet* contours  = NULL;
+
+	/* output: */
+	Vector *in_nod  = NULL;
+	Vector *in_elem = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on output arguments on the matlab side: */
+	#ifdef _HAVE_MATLAB_MODULES_
+	if(nlhs!=1 && nlhs!=2){
+		ContourToMeshUsage();
+		_error_(" usage. See above");
+	}
+	#endif
+	/*check on input arguments: */
+	if(nrhs!=NRHS){
+		ContourToMeshUsage();
+		_error_(" usage. See above");
+	}
+
+
+	/*Fetch inputs: */
+	FetchData(&index,&nel,NULL,INDEX);
+	FetchData(&x,&nods,NULL,X);
+	FetchData(&y,NULL,NULL,Y);
+	FetchData(&edgevalue,EDGEVALUE);
+	FetchData(&contourname,CONTOURNAME);
+	contours=DomainOutlineRead(contourname);
+
+	/*Fetch  interptype: */
+	FetchData(&interptype,INTERPTYPE);
+
+	/*Run interpolation routine: */
+	ContourToMeshx( &in_nod,&in_elem,index,x,y,contours,interptype,nel,nods,edgevalue);
+
+	/* output: */
+	if (strcmp(interptype,"node")==0){
+		WriteData(PLHS0,in_nod);
+	}
+	else if (strcmp(interptype,"element")==0){
+		WriteData(PLHS0,in_elem);
+	}
+	else if (strcmp(interptype,"element and node")==0){
+		WriteData(PLHS0,in_nod);
+		WriteData(PLHS1,in_elem);
+	}
+	else _error_(" wrong interpolation type");
+
+	/*end module: */
+	MODULEEND();
+	
+}
+
+void ContourToMeshUsage(void)//{{{1
+{
+	printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
+	printf("\n");
+	printf("      Usage: \n");
+	printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
+	printf("\n");
+	printf("         index,x,y: mesh triangulation.\n");
+	printf("         contourname: name of .exp file containing the contours.\n");
+	printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
+	printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
+	printf("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', \n");
+	printf("            or of size 0 otherwise.\n");
+	printf("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', \n");
+	printf("            or of size 0 otherwise.\n");
+	printf("\n");
+	printf("      Example: \n");
+	printf("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)\n");
+	printf("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)\n");
+	printf("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)\n");
+	printf("\n");
+}
+//}}}
Index: /issm/trunk/src/modules/ContourToMesh/ContourToMesh.h
===================================================================
--- /issm/trunk/src/modules/ContourToMesh/ContourToMesh.h	(revision 12331)
+++ /issm/trunk/src/modules/ContourToMesh/ContourToMesh.h	(revision 12331)
@@ -0,0 +1,72 @@
+
+/*
+	ContourToMesh.h
+*/
+
+
+#ifndef _CONTOURTOMESH_H
+#define _CONTOURTOMESH_H
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define INDEX (mxArray *)prhs[0]
+#define X (mxArray *)prhs[1]
+#define Y (mxArray *)prhs[2]
+#define CONTOURNAME (mxArray *)prhs[3]
+#define INTERPTYPE (mxArray *)prhs[4]
+#define EDGEVALUE (mxArray *)prhs[5]
+/* serial output macros: */
+#define PLHS0 (mxArray**)&plhs[0]
+#define PLHS1 (mxArray**)&plhs[1]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define INDEX PyTuple_GetItem(args,0)
+#define X PyTuple_GetItem(args,1)
+#define Y PyTuple_GetItem(args,2)
+#define CONTOURNAME PyTuple_GetItem(args,3)
+#define INTERPTYPE PyTuple_GetItem(args,4)
+#define EDGEVALUE PyTuple_GetItem(args,5)
+/* serial output macros: */
+#define PLHS0 output,0
+#define PLHS1 output,1
+#endif
+
+#undef __FUNCT__
+#define __FUNCT__ "ContourToMesh"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS 6
+
+/* local prototypes: */
+void ContourToMeshUsage(void);
+
+#endif  /* _CONTOURTOMESH_H */
+
Index: /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12331)
+++ /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12331)
@@ -0,0 +1,114 @@
+/*! \file  ContourtoNodes
+    \brief: takes a  contour file, and figures out which nodes  (x,y list)
+    are inside this contour. 
+
+	usage:
+	[flags]=ContourToNodes(x,y,contours,interptype,edgevalue);
+	
+	where:
+
+	input:
+
+		x,y: node cooredinates
+		
+		contours: structure holding sets of vertices making open contours. 
+		
+		interptype: string definining type of interpolation ('element', or 'node', or 'element and node');
+
+		edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons
+
+	output:
+		flags: vector of flags (0 or 1), of size nods 
+*/
+	
+#include "./ContourToNodes.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     edgevalue;
+	char*   interptype=NULL;
+
+	/* output: */
+	Vector*  flags=NULL;
+	int  nods;
+
+	//contours
+	mxArray*  matlabstructure=NULL;
+	int numcontours;
+	Contour** contours=NULL;
+	Contour*  contouri=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToNodesUsage);
+
+	
+	/*Fetch inputs: */
+	FetchData(&x,&nods,NULL,XHANDLE);
+	FetchData(&y,NULL,NULL,YHANDLE);
+	FetchData(&edgevalue,EDGEVALUEHANDLE);
+
+	//Fetch contours
+
+	if(mxIsChar(FILENAME)){
+		/*Call expread on filename to build a contour array in the matlab workspace: */
+		mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+	}
+	else{
+		/*FILENAME is actually a structure, coming directly from expread: */
+		matlabstructure=(mxArray*)FILENAME;
+	}
+
+	numcontours=mxGetNumberOfElements(matlabstructure);
+	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	for(i=0;i<numcontours;i++){
+		//allocate
+		contouri=(Contour*)xmalloc(sizeof(Contour));
+		//retrieve dimension of this contour.
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+		//set pointers.
+		contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+		contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+		*(contours+i)=contouri;
+	}
+
+	/* Debugging of contours :{{{1*/
+	/*for(i=0;i<numcontours;i++){
+		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		contouri=*(contours+i);
+		printf("   Number of nodes %i\n",contouri->nods);
+		for (j=0;j<contouri->nods;j++){
+			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		}
+	}*/
+	/*}}}*/
+
+	/*Run interpolation routine: */
+	ContourToNodesx(&flags,x,y,nods,contours,numcontours,edgevalue);
+
+	/* output: */
+	WriteData(FLAGS,flags);
+
+	/*end module: */
+	MODULEEND();
+
+}
+
+void ContourToNodesUsage(void){
+	printf("   usage:\n");
+	printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
+	printf("   where:\n");
+	printf("      x,y: list of nodes.\n");
+	printf("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.\n");
+	printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
+	printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
+	printf("      flags: vector of flags (0 or 1), of size nods.\n");
+	printf("\n");
+}
Index: /issm/trunk/src/modules/ContourToNodes/ContourToNodes.h
===================================================================
--- /issm/trunk/src/modules/ContourToNodes/ContourToNodes.h	(revision 12331)
+++ /issm/trunk/src/modules/ContourToNodes/ContourToNodes.h	(revision 12331)
@@ -0,0 +1,44 @@
+
+/*
+	ContourToNodes.h
+*/
+
+
+#ifndef _CONTOURTONODES_H
+#define _CONTOURTONODES_H
+
+/* local prototypes: */
+void ContourToNodesUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "ContourToNodes"
+
+
+#ifndef ALL
+#define ALL 0
+#endif
+
+/* input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define FILENAME prhs[2]
+#define EDGEVALUEHANDLE prhs[3]
+
+/* serial output macros: */
+#define FLAGS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+
+#endif  /* _CONTOURTONODES_H */
+
Index: /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12331)
+++ /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12331)
@@ -0,0 +1,42 @@
+/*\file ElementConnectivity.c
+ *\brief: build element connectivity using node connectivity and elements. 
+ */
+
+#include "./ElementConnectivity.h"
+
+WRAPPER(ElementConnectivity){
+
+	/*inputs: */
+	double* elements=NULL;
+	double* nodeconnectivity=NULL;
+	int     nel,nods;
+	int     width;
+
+	/*outputs: */
+	double* elementconnectivity=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&ElementConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&elements,&nel,NULL,ELEMENTS);
+	FetchData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY);
+
+	/*!Generate internal degree of freedom numbers: */
+	ElementConnectivityx(&elementconnectivity, elements,nel, nodeconnectivity, nods, width);
+
+	/*write output datasets: */
+	WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nel,3);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void ElementConnectivityUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: elementconnectivity = %s(elements, nodeconnectivity);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.h
===================================================================
--- /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.h	(revision 12331)
+++ /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.h	(revision 12331)
@@ -0,0 +1,60 @@
+/*
+	ElementConnectivity.h
+*/
+
+#ifndef _ELEMENTCONNECTIVITY_H
+#define _ELEMENTCONNECTIVITY_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+/* serial input macros: */
+#define ELEMENTS (mxArray*)prhs[0]
+#define NODECONNECTIVITY (mxArray*)prhs[1]
+/* serial output macros: */
+#define ELEMENTCONNECTIVITY (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+/* serial input macros: */
+#define ELEMENTS PyTuple_GetItem(args,0)
+#define NODECONNECTIVITY PyTuple_GetItem(args,1)
+/* serial output macros: */
+#define ELEMENTCONNECTIVITY output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "ElementConnectivity"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+/* local prototypes: */
+void ElementConnectivityUsage(void);
+
+#endif  /* _ELEMENTCONNECTIVITY_H */
Index: /issm/trunk/src/modules/EnumToString/EnumToString.cpp
===================================================================
--- /issm/trunk/src/modules/EnumToString/EnumToString.cpp	(revision 12331)
+++ /issm/trunk/src/modules/EnumToString/EnumToString.cpp	(revision 12331)
@@ -0,0 +1,32 @@
+/*\file EnumToString.c
+ *\brief:convert enum (int) to string
+ */
+
+#include "./EnumToString.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	char    *name    = NULL;
+	int      enum_in;
+
+	/*checks on arguments on the matlab side: */
+	if(nrhs!=NRHS){
+		EnumToStringUsage(); _error_(" usage. See above");
+	}
+
+	/*Fetch inputs: */
+	FetchData(&enum_in,ENUMIN);
+
+	/*Run core function: */
+	EnumToStringx(&name,enum_in);
+
+	/* output: */
+	WriteData(NAME,name);
+}
+
+void EnumToStringUsage(void)
+{
+	_printf_(true,"\n");
+	_printf_(true,"   usage: %sstring = EnumToString(enum);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/EnumToString/EnumToString.h
===================================================================
--- /issm/trunk/src/modules/EnumToString/EnumToString.h	(revision 12331)
+++ /issm/trunk/src/modules/EnumToString/EnumToString.h	(revision 12331)
@@ -0,0 +1,32 @@
+/*!\file:  EnumToString.h
+ * \brief header file for EnumToString module.
+ */ 
+
+#ifndef _ENUMTOSTRING_H
+#define _ENUMTOSTRING_H
+
+/* local prototypes: */
+void EnumToStringUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define ENUMIN (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define NAME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#undef __FUNCT__ 
+#define __FUNCT__  "EnumToString"
+
+#endif  /* _TEST_H */
Index: /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp
===================================================================
--- /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12331)
@@ -0,0 +1,98 @@
+/*\file Exp2Kml.c
+ *\brief: exp to kml file conversion mex module.
+ */
+#include "./Exp2Kml.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filexp=NULL,*filkml=NULL;
+	int     sgn;
+
+	Options* options=NULL;
+	char     *choles=NULL;
+	bool     holes=false;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+	}
+	if (nrhs < NRHS) {
+		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filexp,EXP_IN);
+	FetchData(&filkml,KML_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&choles,"holes","no");
+	if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2)) holes=true;
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes);
+	else
+		iret=Exp2Kmlx(filexp,filkml,sgn,holes);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	xfree((void**)&choles);
+	delete options;
+	xfree((void**)&filkml);
+	xfree((void**)&filexp);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Exp2KmlUsage(void){
+	_printf_(true,"Exp2Kml - exp to kml file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from exp to kml format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filexp      file name of exp file to be read (char)\n");
+	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1);\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/modules/Exp2Kml/Exp2Kml.h
===================================================================
--- /issm/trunk/src/modules/Exp2Kml/Exp2Kml.h	(revision 12331)
+++ /issm/trunk/src/modules/Exp2Kml/Exp2Kml.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*!\file Exp2Kml.h
+ * \brief: prototype for exp to kml file conversion mex module.
+ */
+
+#ifndef _EXP2KML_H
+#define _EXP2KML_H
+
+/* local prototypes: */
+void Exp2KmlUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Exp2Kml"
+
+
+/* serial input macros: */
+#define EXP_IN    prhs[0]
+#define KML_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp
===================================================================
--- /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp	(revision 12331)
+++ /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp	(revision 12331)
@@ -0,0 +1,69 @@
+/*!\file:  HoleFiller.cpp
+ * \brief fill holes in matlab velocity array
+	this matlab module is an adaptation of a routine written by Robber 
+	Crippen.  The original routine was designed for the SRTM mission at JPL, 
+	and can be found in the current directory, under the name 
+	HoleFillerCrippen.  It fills void holes in an image, using an interpolation 
+	algorithm, and optionnally a smoothing algorithm. 
+	This matlab module extends the Crippen routine to be used in Matlab, 
+	using double arrays found in the workspace, and loaded directly into memory.
+*/
+
+
+#include "./HoleFiller.h"
+
+void mexFunction( int nlhs, mxArray* plhs[],
+				  int nrhs, const mxArray* prhs[])
+{
+
+	int i,j;
+
+	/* required input: */
+	double* imagein=NULL;
+	int     imagein_rows,imagein_cols;
+	int     smooth_flag;
+	int     smooth;
+
+
+	/* output: */
+	mxArray* pfield=NULL;
+	double* imageout=NULL;
+	int     imageout_rows,imageout_cols;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&HoleFillerUsage);
+
+	/*Fetch data: */
+	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchData(&smooth_flag,SMOOTH);
+	
+	/*Get smooth flag setup: */
+	if (smooth_flag==0)
+		smooth=1;
+	else
+		smooth=0;
+
+	/*Run core hole filler routine: */
+	HoleFillerx( &imageout,imagein,imagein_rows,imagein_cols,smooth);
+
+	/* output: */
+	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+
+void HoleFillerUsage(void)
+{
+	printf("   HoleFiller usage:\n");
+	printf("   [image_out]=HoleFiller(image_in,smooth);\n\n");
+	printf("   where:\n");
+	printf("      image_in in double format\n");
+	printf("      smooth: 1 to smooth with a box filer, 0 to leave data raw\n");
+	printf("      image_out in double format\n");
+	printf("\n");
+}
Index: /issm/trunk/src/modules/HoleFiller/HoleFiller.h
===================================================================
--- /issm/trunk/src/modules/HoleFiller/HoleFiller.h	(revision 12331)
+++ /issm/trunk/src/modules/HoleFiller/HoleFiller.h	(revision 12331)
@@ -0,0 +1,36 @@
+
+/*
+	HoleFiller.h
+*/
+
+
+#ifndef _HOLEFILLER_H
+#define _HOLEFILLER_H
+
+/* local prototypes: */
+void HoleFillerUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "HoleFiller"
+
+
+/* serial input macros: */
+#define IMAGEIN prhs[0]
+#define SMOOTH prhs[1]
+
+/* serial output macros: */
+#define IMAGEOUT &plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif  /* _HOLEFILLER_H */
Index: /issm/trunk/src/modules/InternalFront/InternalFront.cpp
===================================================================
--- /issm/trunk/src/modules/InternalFront/InternalFront.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InternalFront/InternalFront.cpp	(revision 12331)
@@ -0,0 +1,99 @@
+/*\file InternalFront.c
+ *\brief: build pressureload
+ */
+
+#include "./InternalFront.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	bool*   elementonwater=NULL;
+	int*    elements=NULL;
+	int*    connectivity=NULL;
+	int*    elementconnectivity=NULL;
+	int*    front=NULL;
+	double* front2=NULL;
+	bool    found;
+	int     numberofelements,numberofsegments;
+	int     N,M;
+	int     i,j,ii,jj,id;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InternalFrontUsage);
+
+	/*Fetch required fields*/
+	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	if(numberofelements<=0) _error_("No elements found in the model");
+	FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
+	if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
+	FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
+	if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
+	FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
+	if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
+
+	/*Allocate and initialize all variables*/
+	numberofsegments=0;
+	front=(int*)xmalloc(3*numberofelements*4*sizeof(int));
+
+	/*Loop over all elements on water*/
+	for(i=0;i<numberofelements;i++){
+
+		/*Skip if on water*/
+		if(!elementonwater[i]) continue;
+
+		/*Loop over all three adjacent elements*/
+		for(j=0;j<3;j++){
+
+			/*Skip if adjacent element does not exist or is on water*/
+			id=elementconnectivity[i*3+j];
+			if(id==0) continue;
+			if(elementonwater[id-1]) continue;
+
+			/*We have an ice front to add here, let's go!*/
+			for(ii=0;ii<3;ii++){
+
+				found=false;
+				for(jj=0;jj<3;jj++){
+					if(elements[(id-1)*3+ii]==elements[i*3+jj]){
+						found=true;
+						break;
+					}
+				}
+
+				/*OK, we just found the node of id, which is not in i. We have the segment*/
+				if(!found){
+					front[numberofsegments*4+0]=elements[(id-1)*3+(ii+1)%3];
+					front[numberofsegments*4+1]=elements[(id-1)*3+(ii+2)%3];
+					front[numberofsegments*4+2]=id;
+					front[numberofsegments*4+3]=IceEnum;
+					numberofsegments+=1;
+					break;
+				}
+			}
+
+			/*In debugging mode, check that the segment has been found*/
+			_assert_(!found);
+		}
+	}
+
+	/*Now that we know how many segments there is we can allocate the final matrix*/
+	if(numberofsegments){
+		front2=(double*)xmalloc(4*numberofsegments*sizeof(double));
+		for(i=0;i<4*numberofsegments;i++) front2[i]=(double)front[i];
+	}
+	xfree((void**)&front);
+
+	/*write output datasets: */
+	WriteData(FRONT,front2,numberofsegments,4);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InternalFrontUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: icefront = %s(md);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/InternalFront/InternalFront.h
===================================================================
--- /issm/trunk/src/modules/InternalFront/InternalFront.h	(revision 12331)
+++ /issm/trunk/src/modules/InternalFront/InternalFront.h	(revision 12331)
@@ -0,0 +1,33 @@
+
+/*
+	InternalFront.h
+*/
+
+
+#ifndef _INTERNALFRONT_H
+#define _INTERNALFRONT_H
+
+/* local prototypes: */
+void InternalFrontUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InternalFront"
+
+/* serial input macros: */
+#define MODEL (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define FRONT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#endif
Index: /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12331)
@@ -0,0 +1,95 @@
+/*!\file InterpFromGridToMesh.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromGridToMesh.c
+
+	usage:
+	data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh);
+	
+	where:
+
+		input:
+		x,y: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+*/
+	
+#include "./InterpFromGridToMesh.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/*input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     x_rows,y_rows;
+	double* data=NULL; 
+	int     data_rows,data_cols;
+	double* x_mesh=NULL;
+	double* y_mesh=NULL;
+	int     x_mesh_rows,y_mesh_rows;
+	double  default_value;
+	int     interpolationenum;
+
+	/* output: */
+	Vector*  data_mesh=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	//CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromGridToMeshUsage);
+	if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
+		InterpFromGridToMeshUsage();
+		_error_(" usage. See above");
+	}
+
+	/*Input datasets: */
+	FetchData(&x,&x_rows,NULL,XHANDLE);
+	FetchData(&y,&y_rows,NULL,YHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
+	FetchData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
+	FetchData(&default_value,DEFAULTHANDLE);
+
+	/* Run core computations: */
+	if(nrhs==7){
+		FetchData(&interpolationenum,INTERPENUM);
+		InterpFromGridToMeshx(&data_mesh, x, x_rows,  y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationenum);
+	}
+	else{
+		InterpFromGridToMeshx(&data_mesh, x, x_rows,  y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value);
+	}
+
+	/*Write data: */
+	WriteData(DATAMESH,data_mesh);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromGridToMeshUsage(void)
+{
+	_printf_(true,"INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a grid onto a list of points\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
+	_printf_(true,"      x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
+	_printf_(true,"      x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      default_value: default value if no data is found (holes).\n");
+	_printf_(true,"      data_mesh: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('velocities.mat');\n");
+	_printf_(true,"      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h
===================================================================
--- /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h	(revision 12331)
@@ -0,0 +1,42 @@
+/*!\file InterpFromGridToMesh.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _InterpFromGridToMesh_H
+#define _InterpFromGridToMesh_H
+
+/* local prototypes: */
+void InterpFromGridToMeshUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromGridToMesh"
+
+#undef CLEANUP
+#define CLEANUP InterpFromGridToMeshLocalCleanup();
+
+
+/* serial input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define DATAHANDLE prhs[2]
+#define XMESHHANDLE prhs[3]
+#define YMESHHANDLE prhs[4]
+#define DEFAULTHANDLE prhs[5]
+#define INTERPENUM prhs[6]
+
+/* serial output macros: */
+#define DATAMESH (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  6
+
+#endif  /* _INTERPFROMGRIDTOMESH_H */
Index: /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12331)
@@ -0,0 +1,169 @@
+/*!\file InterpFromMesh2d.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromMesh2d.c
+
+	usage:
+	data_mesh=InterpFromMesh2d(index,x,y,data,x_mesh,y_mesh);
+	
+	where:
+
+		input:
+		x,y: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+
+*/
+	
+#include "./InterpFromMesh2d.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	/*input: */
+	double* index_data=NULL;
+	int     index_data_rows;
+	int     dummy;
+
+	double* x_data=NULL;
+	int     x_data_rows;
+	
+	double* y_data=NULL;
+	int     y_data_rows;
+
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+
+	double* x_prime=NULL;
+	double* y_prime=NULL;
+	
+	int     x_prime_rows;
+	int     y_prime_rows;
+
+
+	double* default_values=NULL;
+	int     num_default_values=0;
+
+	//contours
+	mxArray*  matlabstructure=NULL;
+	Contour** contours=NULL;
+	int       numcontours;
+	Contour*  contouri=NULL;
+	int       i;
+
+	/*Intermediary*/
+	int nods_data;
+	int nels_data;
+	int nods_prime;
+
+	/* output: */
+	Vector*  data_prime=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if(nlhs!=NLHS){
+		InterpFromMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+	if((nrhs!=6) && (nrhs!=7) && (nrhs!=8)){
+		InterpFromMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&index_data,&index_data_rows,&dummy,INDEXHANDLE);
+	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+
+	if(nrhs>=7){
+		/*default values: */
+		FetchData(&default_values,&num_default_values,DEFAULTHANDLE);
+	}
+	else{
+		default_values=NULL;
+		num_default_values=0;
+	}
+
+	if(nrhs>=8){
+		
+		/*Call expread on filename to build a contour array in the matlab workspace: */
+		mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
+		/*contours: */
+		numcontours=mxGetNumberOfElements(matlabstructure);
+		contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+		for(i=0;i<numcontours;i++){
+			//allocate
+			contouri=(Contour*)xmalloc(sizeof(Contour));
+			//retrieve dimension of this contour.
+			contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+			//set pointers.
+			contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+			contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+			*(contours+i)=contouri;
+		}
+
+		/* Debugging of contours :{{{1*/
+		/*for(i=0;i<numcontours;i++){
+		  printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		  contouri=*(contours+i);
+		  printf("   Number of vertices %i\n",contouri->nods);
+		  for (j=0;j<contouri->nods;j++){
+		  printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		  }
+		  }*/
+		/*}}}*/
+	}
+	else{
+		numcontours=0;
+		contours=NULL;
+	}
+
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows){
+		_error_("vectors x and y should have the same length!");
+	}
+	if (x_prime_rows!=y_prime_rows){
+		_error_("vectors x_prime and y_prime should have the same length!");
+	}
+	
+	/*get number of elements and number of nodes in the data*/
+	nels_data=index_data_rows;
+	nods_data=x_data_rows;
+	nods_prime=x_prime_rows;
+
+	/* Run core computations: */
+	InterpFromMesh2dx(&data_prime,index_data,x_data,y_data,nods_data,nels_data,data,data_rows,x_prime,y_prime,nods_prime,default_values,num_default_values,contours,numcontours);
+
+	/*Write data: */
+	WriteData(DATAPRIME,data_prime);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMesh2dUsage(void)
+{
+	_printf_(true,"   usage:\n");
+	_printf_(true,"         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n\n");
+	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n\n");
+	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n\n");
+	_printf_(true,"   where:\n");
+	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      data - vector holding the data to be interpolated onto the points.\n");
+	_printf_(true,"      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.\n");
+	_printf_(true,"      default_value: a scalar or vector of size length(x_prime).\n");
+	_printf_(true,"      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
+	_printf_(true,"      data_prime:  vector of prime interpolated data.\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.h
===================================================================
--- /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.h	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.h	(revision 12331)
@@ -0,0 +1,40 @@
+/*!\file InterpFromMesh2d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESH2D_H
+#define _INTERPFROMMESH2D_H
+
+/* local prototypes: */
+void InterpFromMesh2dUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMesh2d"
+
+#undef CLEANUP
+#define CLEANUP InterpFromMesh2dLocalCleanup();
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define DATAHANDLE prhs[3]
+#define XPRIMEHANDLE prhs[4]
+#define YPRIMEHANDLE prhs[5]
+#define DEFAULTHANDLE prhs[6]
+#define FILENAME prhs[7]
+
+/* serial output macros: */
+#define DATAPRIME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+
+#endif  /* _INTERPFROMMESH2D_H */
Index: /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12331)
@@ -0,0 +1,79 @@
+/*\file InterpFromMeshToGrid.c
+ *\brief: compute diff between observed and modeled velocity
+ */
+
+#include "./InterpFromMeshToGrid.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input datasets: */
+	double* index=NULL;
+	int     nel;
+	double* x=NULL;
+	int     nods;
+	double* y=NULL;
+	double* meshdata=NULL;
+	int     meshdata_length;
+	double  xmin;
+	double  ymax;
+	double  xposting;
+	double  yposting;
+	int     nlines,ncols;
+	double  default_value;
+
+	/* output datasets: */
+	double* griddata=NULL;
+	double* x_m=NULL;
+	double* y_m=NULL;
+
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromMeshToGridUsage);
+
+	/*Input datasets: */
+	FetchData(&index,&nel,NULL,INDEX);
+	FetchData(&x,&nods,NULL,X);
+	FetchData(&y,NULL,NULL,Y);
+	FetchData(&meshdata,&meshdata_length,NULL,MESHDATA);
+	FetchData(&xmin,XMIN);
+	FetchData(&ymax,YMAX);
+	FetchData(&xposting,XPOSTING);
+	FetchData(&yposting,YPOSTING);
+	FetchData(&nlines,NLINES);
+	FetchData(&ncols,NCOLS);
+	FetchData(&default_value,DEFAULTVALUE);
+
+	/*Call core of computation: */
+	InterpFromMeshToGridx(&x_m,&y_m,&griddata,index,x,y,nods,nel,meshdata,meshdata_length,xmin,ymax,xposting,yposting,nlines,ncols,default_value);
+
+	/*Write results: */
+	WriteData(XM,x_m,ncols);
+	WriteData(YM,y_m,nlines);
+	WriteData(GRIDDATA,griddata,nlines,ncols);
+
+	/*Free ressources: */
+	//let matlab do this.
+	
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToGridUsage(void)
+{
+	_printf_(true,"INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a regular grid\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index,x,y: delaunay triangulation defining the mesh.\n");
+	_printf_(true,"      meshdata: vertex values of data to be interpolated.\n");
+	_printf_(true,"      xmin,ymax,posting,nlines,ncols: parameters that define the grid\n");
+	_printf_(true,"      default_value: value of points located out of the mesh.\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h	(revision 12331)
@@ -0,0 +1,46 @@
+
+/*
+	InterpFromMeshToGrid.h
+*/
+
+
+#ifndef _INTERPFROMMESHTOGRID_H
+#define _INTERPFROMMESHTOGRID_H
+
+/* local prototypes: */
+void InterpFromMeshToGridUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToGrid"
+
+/* serial input macros: */
+#define INDEX (mxArray*)prhs[0]
+#define X (mxArray*)prhs[1]
+#define Y (mxArray*)prhs[2]
+#define MESHDATA (mxArray*)prhs[3]
+#define XMIN (mxArray*)prhs[4]
+#define YMAX (mxArray*)prhs[5]
+#define XPOSTING (mxArray*)prhs[6]
+#define YPOSTING (mxArray*)prhs[7]
+#define NLINES (mxArray*)prhs[8]
+#define NCOLS (mxArray*)prhs[9]
+#define DEFAULTVALUE (mxArray*)prhs[10]
+
+/* serial output macros: */
+#define XM (mxArray**)&plhs[0]
+#define YM (mxArray**)&plhs[1]
+#define GRIDDATA (mxArray**)&plhs[2]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  3
+#undef NRHS
+#define NRHS  11
+
+#endif  /* _INTERPFROMMESHTOGRID_H*/
Index: /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12331)
@@ -0,0 +1,119 @@
+/*\file InterpFromMeshToMesh2d.c
+ *\brief: bamg module.
+ */
+#include "./InterpFromMeshToMesh2d.h"
+
+
+WRAPPER(InterpFromMeshToMesh2d){
+
+	/*input: */
+	double* index=NULL;
+	int     index_cols;
+	double* x_data=NULL;
+	int     x_data_rows;
+	double* y_data=NULL;
+	int     y_data_rows;
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+	double* x_interp=NULL;
+	int     x_interp_rows;
+	double* y_interp=NULL;
+	int     y_interp_rows;
+	char*   contourname=NULL;
+	double* default_values=NULL;
+	int     num_default_values=0;
+	DataSet *contours = NULL;
+
+	/*Intermediary*/
+	int nels_data;
+
+	/* output: */
+	double* data_interp=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on output arguments on the matlab side: */
+	#ifdef _HAVE_MATLAB_MODULES_
+	if(nlhs!=NLHS){
+		InterpFromMeshToMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+	#endif
+	/*check on input arguments: */
+	if((nrhs!=6) & (nrhs!=8)){
+		InterpFromMeshToMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&index,&nels_data,&index_cols,INDEX);
+	FetchData(&x_data,&x_data_rows,NULL,X);
+	FetchData(&y_data,&y_data_rows,NULL,Y);
+	FetchData(&data,&data_rows,&data_cols,DATA);
+	FetchData(&x_interp,&x_interp_rows,XINTERP);
+	FetchData(&y_interp,&y_interp_rows,YINTERP);
+
+	/*Figure out contours and default values: */
+	if(nrhs==8){
+		FetchData(&default_values,&num_default_values,DEFAULT);
+		FetchData(&contourname,CONTOURNAME);
+		contours=DomainOutlineRead(contourname);
+	}
+	else{
+		num_default_values=0;
+		default_values=NULL;
+		contours=new DataSet();
+	}
+
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows){
+		_error_("vectors x and y should have the same length!");
+	}
+	if (x_interp_rows!=y_interp_rows){
+		_error_("vectors x_interp and y_interp should have the same length!");
+	}
+	if (index_cols!=3){
+		_error_("index should have 3 columns (input provided has %i columns)",index_cols);
+	}
+
+	/* Run core computations: */
+	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours);
+
+	/*Write data: */
+	WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToMesh2dUsage(void)//{{{1
+
+{
+	_printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);\n");
+	_printf_(true,"      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,default_value,contourname);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh. (one column per field)\n");
+	_printf_(true,"      x_interp,y_interp: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      if default_value and contourname not specified: linear interpolation will happen on all x_interp,y_interp.\n");
+	_printf_(true,"      if (default_value,contourname) specified: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
+	_printf_(true,"      note that default_value is either a scalar, or a vector of size  length(x_interp)\n");
+	_printf_(true,"      data_interp: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('temperature.mat');\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,253,'Contour.exp');\n");
+	_printf_(true,"\n");
+}
+//}}}
Index: /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12331)
@@ -0,0 +1,71 @@
+/*!\file InterpFromMeshToMesh2d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESHTOMESH2d_H
+#define _INTERPFROMMESHTOMESH2d_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define INDEX prhs[0]
+#define X prhs[1]
+#define Y prhs[2]
+#define DATA prhs[3]
+#define XINTERP prhs[4]
+#define YINTERP prhs[5]
+#define DEFAULT prhs[6]
+#define CONTOURNAME prhs[7]
+
+/* serial output macros: */
+#define DATAINTERP (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define INDEX PyTuple_GetItem(args,0)
+#define X PyTuple_GetItem(args,1)
+#define Y PyTuple_GetItem(args,2)
+#define DATA PyTuple_GetItem(args,3)
+#define XINTERP PyTuple_GetItem(args,4)
+#define YINTERP PyTuple_GetItem(args,5)
+#define DEFAULT PyTuple_GetItem(args,6)
+#define CONTOURNAME PyTuple_GetItem(args,7)
+/* serial output macros: */
+#define DATAINTERP output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToMesh2d"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  6 //can be 8 though
+
+/* local prototypes: */
+void InterpFromMeshToMesh2dUsage(void);
+
+#endif
Index: /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12331)
@@ -0,0 +1,119 @@
+/*!\file InterpFromMeshToMesh3d.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromMeshToMesh3d.c
+
+	usage:
+	data_mesh=InterpFromMeshToMesh3d(index,x,y,z,data,x_mesh,y_mesh,z_mesh);
+	
+	where:
+
+		input:
+		x,y,z: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh,z_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+
+*/
+	
+#include "./InterpFromMeshToMesh3d.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	/*input: */
+	double* index_data=NULL;
+	int     index_data_rows;
+
+	double* x_data=NULL;
+	double* y_data=NULL;
+	double* z_data=NULL;
+
+	int     x_data_rows;
+	int     y_data_rows;
+	int     z_data_rows;
+
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+
+	double* x_prime=NULL;
+	double* y_prime=NULL;
+	double* z_prime=NULL;
+	
+	int     x_prime_rows;
+	int     y_prime_rows;
+	int     z_prime_rows;
+
+	double  default_value;
+
+	/*Intermediary*/
+	int nods_data;
+	int nels_data;
+	int nods_prime;
+
+	/* output: */
+	Vector*  data_prime=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromMeshToMesh3dUsage);
+
+	/*Input datasets: */
+	FetchData(&index_data,&index_data_rows,NULL,INDEXHANDLE);
+	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchData(&z_data,&z_data_rows,NULL,ZHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+	FetchData(&z_prime,&z_prime_rows,NULL,ZPRIMEHANDLE);
+	FetchData(&default_value,DEFAULTHANDLE);
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows || x_data_rows!=z_data_rows){
+		_error_("vectors x, y and z should have the same length!");
+	}
+	if (x_prime_rows!=y_prime_rows || x_prime_rows!=z_prime_rows){
+		_error_("vectors x_prime, y_prime and z_prime should have the same length!");
+	}
+	/*get number of elements and number of nodes in the data*/
+	nels_data=index_data_rows;
+	nods_data=x_data_rows;
+	nods_prime=x_prime_rows;
+
+	/* Run core computations: */
+	InterpFromMeshToMesh3dx(&data_prime,index_data,x_data,y_data,z_data,nods_data,nels_data,data,data_rows,x_prime,y_prime,z_prime,nods_prime,default_value);
+
+	/*Write data: */
+	WriteData(DATAPRIME,data_prime);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToMesh3dUsage(void)
+{
+	_printf_(true,"INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      x,y,z: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
+	_printf_(true,"      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      default_value: default value if no data is found (holes).\n");
+	_printf_(true,"      data_prime: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('temperature.mat');\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h	(revision 12331)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h	(revision 12331)
@@ -0,0 +1,44 @@
+/*!\file InterpFromMeshToMesh3d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESH3D_H
+#define _INTERPFROMMESH3D_H
+
+/* local prototypes: */
+void InterpFromMeshToMesh3dUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToMesh3d"
+
+#undef CLEANUP
+#define CLEANUP InterpFromMeshToMesh3dLocalCleanup();
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define ZHANDLE prhs[3]
+#define DATAHANDLE prhs[4]
+#define XPRIMEHANDLE prhs[5]
+#define YPRIMEHANDLE prhs[6]
+#define ZPRIMEHANDLE prhs[7]
+#define DEFAULTHANDLE prhs[8]
+
+/* serial output macros: */
+#define DATAPRIME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  9
+
+#endif  /* _INTERPFROMMESHTOMESH3D_H */
Index: /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp
===================================================================
--- /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12331)
+++ /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12331)
@@ -0,0 +1,129 @@
+/*\file KMLFileRead.c
+ *\brief: KML file reader module.
+ */
+#include "./KMLFileRead.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,j,nnodes=0,verbose=1;
+	KML_Object* kobj;
+
+	/*input: */
+	char*   name=NULL;
+	char*   notes=NULL;
+	const mxArray* notesi;
+	mwIndex        nindex;
+	int*    elem=NULL;
+	int     melem=0,nelem=0;
+	int*    nodecon=NULL;
+	int     mncon=0,nncon=0;
+	double* lat=NULL;
+	int     mlat=0,nlat=0,llat=0;
+	double* lng=NULL;
+	int     mlng=0,nlng=0,llng=0;
+	int     nparts=0;
+	int*    part=NULL;
+	int     mprt=0,nprt=0,lprt=0;
+	double* data=NULL;
+	int     mdata=0,ndata=0;
+	double* cmap=NULL;
+	int     mcmap=0,ncmap=0;
+	char*   filnam=NULL;
+	FILE*   fidi=NULL;
+	FILE*   fido=NULL;
+	Options* options=NULL;
+	char*    echo    =NULL;
+	char*    deepecho=NULL;
+	char*    write   =NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+	}
+	if (nrhs < NRHS) {
+		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filnam,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&echo    ,"echo"    ,"off");
+	options->Get(&deepecho,"deepecho","off");
+	options->Get(&write   ,"write"   ,"off");
+
+	/*some checks*/
+	if (!strlen(filnam)) strcpy(filnam,"stdout");
+
+	if (verbose) printf("Opening file \"%s\".\n",filnam);
+	fidi=fopen(filnam,"r");
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	kobj=KMLFileReadx(fidi);
+
+	if (verbose) printf("Closing file \"%s\".\n",filnam);
+	fclose(fidi);
+
+	if (kobj){
+		if (!strncmp(echo    ,"on",2) || !strncmp(echo    ,"y",1))
+			kobj->Echo();
+		if (!strncmp(deepecho,"on",2) || !strncmp(deepecho,"y",1))
+			kobj->DeepEcho();
+		if (strncmp(write,"off",3) && strncmp(write,"no",2)) {
+			if (!strncmp(write,"on",2) || !strncmp(write,"yes",3) || !strncmp(write,"stdout",6)) {
+				kobj->Write(stdout,"");
+			}
+			else {
+				if (verbose) printf("Opening file \"%s\".\n",write);
+				fido=fopen(write,"w");
+				kobj->Write(fido,"");
+				if (verbose) printf("Closing file \"%s\".\n",write);
+				ierror=fclose(fido);
+			}
+		}
+		delete kobj;
+	}
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	xfree((void**)&write);
+	xfree((void**)&deepecho);
+	xfree((void**)&echo);
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLFileReadUsage(void){
+	_printf_(true,"KMLFileRead - KML file reader module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module reads a KML file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror       return code (non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
+	_printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/modules/KMLFileRead/KMLFileRead.h
===================================================================
--- /issm/trunk/src/modules/KMLFileRead/KMLFileRead.h	(revision 12331)
+++ /issm/trunk/src/modules/KMLFileRead/KMLFileRead.h	(revision 12331)
@@ -0,0 +1,33 @@
+/*!\file KMLFileRead.h
+ * \brief: prototype for KML file reader mex module.
+ */
+
+#ifndef _KMLFILEREAD_H
+#define _KMLFILEREAD_H
+
+/* local prototypes: */
+void KMLFileReadUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLFileRead"
+
+
+/* serial input macros: */
+#define FILENAME      prhs[0]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  1
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12331)
+++ /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12331)
@@ -0,0 +1,143 @@
+/*\file KMLMeshWrite.c
+ *\brief: KML mesh writer module.
+ */
+#include "./KMLMeshWrite.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,j,nnodes=0,verbose=1;
+
+	/*input: */
+	char*   name=NULL;
+	char*   notes=NULL;
+	const mxArray* notesi;
+	mwIndex        nindex;
+	int*    elem=NULL;
+	int     melem=0,nelem=0;
+	int*    nodecon=NULL;
+	int     mncon=0,nncon=0;
+	double* lat=NULL;
+	int     mlat=0,nlat=0,llat=0;
+	double* lng=NULL;
+	int     mlng=0,nlng=0,llng=0;
+	int     nparts=0;
+	int*    part=NULL;
+	int     mprt=0,nprt=0,lprt=0;
+	double* data=NULL;
+	int     mdata=0,ndata=0;
+	double* cmap=NULL;
+	int     mcmap=0,ncmap=0;
+	char*   filnam=NULL;
+	FILE*   fid=NULL;
+	Options* options=NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+	}
+	if (nrhs < NRHS) {
+		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&name,NAME);
+
+/*  notes is typically a cell array of character strings  */
+	if (mxIsCell(NOTES)) {
+		for (nindex=0; nindex<mxGetNumberOfElements(NOTES); nindex++) {
+			notesi=mxGetCell(NOTES,nindex);
+			if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) {
+				if (!notes) {
+					notes=(char *) xmalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					mxGetString(notesi,notes,mxGetNumberOfElements(notesi)+1);
+				}
+				else {
+/*  note that strlen does not include trailing null  */
+					notes=(char*)xrealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					strcat(notes,"\n");
+					mxGetString(notesi,&notes[strlen(notes)],mxGetNumberOfElements(notesi)+1);
+				}
+			}
+		}
+	}
+	else
+		FetchData(&notes,NOTES);
+	FetchData(&elem,&melem,&nelem,ELEMHANDLE);
+	FetchData(&nodecon,&mncon,&nncon,NODECONHANDLE);
+	FetchData(&lat,&mlat,&nlat,LATHANDLE);
+	llat=mlat*nlat;
+	FetchData(&lng,&mlng,&nlng,LNGHANDLE);
+	llng=mlng*nlng;
+	FetchData(&part,&mprt,&nprt,PARTHANDLE);
+	lprt=mprt*nprt;
+	FetchData(&data,&mdata,&ndata,DATAHANDLE);
+	FetchData(&cmap,&mcmap,&ncmap,CMAPHANDLE);
+	FetchData(&filnam,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*some checks*/
+	for (i=0; i<melem*nelem; i++) if(elem[i]>nnodes) nnodes=elem[i];
+	if(part) for (i=0; i<lprt; i++) if (part[i]+1 > nparts) nparts=part[i]+1;
+
+	if (nodecon && (mncon != nnodes))
+		_error_("Nodal connectivity table, if supplied, must be supplied for all nodes.");
+	else if (!nodecon)
+		mncon=nnodes;
+	if ((llat != nnodes) || (llng != nnodes) || (llat != llng))
+		_error_("Latitude and longitude vectors must be supplied for all nodes.");
+	if (part && (lprt != nnodes))
+		_error_("Partitioning vector, if supplied, must be supplied for all nodes.");
+	if (data && !((mdata == nnodes) || (mdata == melem)))
+		_error_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
+	if (cmap && (ncmap != 3))
+		_error_("Colormap matrix, if supplied, must have three columns for rgb.");
+	if (!strlen(filnam))
+		strcpy(filnam,"stdout");
+
+	/* Run core computations: */
+	fid=fopen(filnam,"w");
+	KMLMeshWritex(&ierror,name,notes,elem,melem,nelem,nodecon,mncon,nncon,lat,lng,part,data,mdata,ndata,cmap,mcmap,ncmap,fid);
+	fclose(fid);
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	delete options;
+	if (mxIsCell(NOTES) && notes) xfree((void**)&notes);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLMeshWriteUsage(void){
+	_printf_(true,"KMLMeshWrite - KML mesh writer module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module writes the mesh of a model as KML polygons into the specified KML file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      name       model name (string, may be empty)\n");
+	_printf_(true,"      notes      model notes (string or cell array of strings, may be empty)\n");
+	_printf_(true,"      elem       elements (double array)\n");
+	_printf_(true,"      nodecon    nodal connectivity array (double array, may be empty)\n");
+	_printf_(true,"      lat        nodal latititudes (double vector)\n");
+	_printf_(true,"      long       nodal longitudes (double vector)\n");
+	_printf_(true,"      part       nodal partitions (double vector, may be empty)\n");
+	_printf_(true,"      data       nodal or element data (double vector, may be empty)\n");
+	_printf_(true,"      cmap       color map (double nx3 array, may be empty)\n");
+	_printf_(true,"      kmlfile    KML file name (string)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.h
===================================================================
--- /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.h	(revision 12331)
+++ /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.h	(revision 12331)
@@ -0,0 +1,42 @@
+/*!\file KMLMeshWrite.h
+ * \brief: prototype for KML mesh writer mex module.
+ */
+
+#ifndef _KMLMESHWRITE_H
+#define _KMLMESHWRITE_H
+
+/* local prototypes: */
+void KMLMeshWriteUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLMeshWrite"
+
+
+/* serial input macros: */
+#define NAME          prhs[0]
+#define NOTES         prhs[1]
+#define ELEMHANDLE    prhs[2]
+#define NODECONHANDLE prhs[3]
+#define LATHANDLE     prhs[4]
+#define LNGHANDLE     prhs[5]
+#define PARTHANDLE    prhs[6]
+#define DATAHANDLE    prhs[7]
+#define CMAPHANDLE    prhs[8]
+#define FILENAME      prhs[9]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS 10
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp
===================================================================
--- /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12331)
+++ /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12331)
@@ -0,0 +1,134 @@
+/*\file KMLOverlay.c
+ *\brief: KML file overlay mex module.
+ */
+#include "./KMLOverlay.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char*   filkml=NULL;
+	char*   filkmz=NULL;
+
+	FILE*   fid=NULL;
+
+	Options* options=NULL;
+	int      nlat=0,nlong=0;
+	double*  lataxis =NULL;
+	double*  longaxis=NULL;
+	int      nimages=0;
+	char**   pimages=NULL;
+	double   dzip=0;
+	char*    czip=NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if(nlhs>NLHS){
+		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+	}
+	if(nrhs<NRHS){
+		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filkml,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&lataxis ,&nlat ,"lataxis" );
+	if (verbose && lataxis) for (i=0; i<nlat; i++) printf("  lataxis [%d]=%g\n",i,lataxis[i]);
+	options->Get(&longaxis,&nlong,"longaxis");
+	if (verbose && longaxis) for (i=0; i<nlong; i++) printf("  longaxis[%d]=%g\n",i,longaxis[i]);
+	options->Get(&pimages,&nimages,"images");
+	if (verbose && pimages) for (i=0; i<nimages; i++) printf("  pimages[%d]=\"%s\"\n",i,pimages[i]);
+	options->Get(&dzip,"zip",0.);
+	if (verbose) printf("  dzip=%g\n",dzip);
+
+	/*some checks*/
+	if (nlat !=2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
+	if (nlong!=2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
+	if (!nimages) _error_("No image files provided.");
+
+	if ((int)dzip){
+		filkmz=filkml;
+		filkml=(char*)mxMalloc(8*sizeof(char));
+		strcpy(filkml,"doc.kml");
+	}
+
+	if(!strlen(filkml)) strcpy(filkml,"stdout");
+
+	if(verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
+	fid=fopen(filkml,"w");
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	KMLOverlayx(&ierror,lataxis,longaxis,nimages,pimages,fid);
+
+	if (verbose) printf("Closing file \"%s\".\n",filkml);
+	fclose(fid);
+
+	/* Create kmz file, if specified: */
+	if ((int)dzip) {
+		czip=(char*)mxMalloc((5+strlen(filkmz)+1+strlen(filkml)+1)*sizeof(char));
+		czip[0]='\0';
+		strcat(czip,"!zip ");
+		strcat(czip,filkmz);
+		strcat(czip," ");
+		strcat(czip,filkml);
+		for (i=0; i<nimages; i++)
+			if (strlen(pimages[i]) && strncmp(pimages[i],"http",4)) {
+				czip=(char*)mxRealloc(czip,(strlen(czip)+1+strlen(pimages[i])+1)*sizeof(char));
+				strcat(czip," ");
+				strcat(czip,pimages[i]);
+			}
+		if (verbose) printf("Zipping file \"%s\".\n",filkmz);
+		if (verbose) printf("%s\n",czip);
+
+		if (mexEvalString(czip)) _error_("Error zipping file \"%s\".",filkmz);
+		xfree((void**)&czip);
+		xfree((void**)&filkmz);
+	}
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	if (pimages) {
+		for (i=nimages; i>0; i--) xfree((void**)&(pimages[i-1]));
+		xfree((void**)&pimages);
+	}
+	xfree((void**)&longaxis);
+	xfree((void**)&lataxis);
+	delete options;
+	xfree((void**)&filkml);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLOverlayUsage(void){
+	_printf_(true,"KMLOverlay - KML file overlay module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module reads a list of image files and writes a KML or KMZ overlay file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      ierror=KMLOverlay(kmlfile,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      kmlfile     KML or KMZ file name (string)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lataxis     latitude axis (double vector [south north], required)\n");
+	_printf_(true,"      longaxis    longitude axis (double vector [west east], required)\n");
+	_printf_(true,"      images      relative or http image file names (string or array of strings or cell array of strings, required)\n");
+	_printf_(true,"      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/KMLOverlay/KMLOverlay.h
===================================================================
--- /issm/trunk/src/modules/KMLOverlay/KMLOverlay.h	(revision 12331)
+++ /issm/trunk/src/modules/KMLOverlay/KMLOverlay.h	(revision 12331)
@@ -0,0 +1,33 @@
+/*!\file KMLOverlay.h
+ * \brief: prototype for KML file overlay mex module.
+ */
+
+#ifndef _KMLOVERLAY_H
+#define _KMLOVERLAY_H
+
+/* local prototypes: */
+void KMLOverlayUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLOverlay"
+
+
+/* serial input macros: */
+#define FILENAME      prhs[0]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  1
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp
===================================================================
--- /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12331)
@@ -0,0 +1,90 @@
+/*\file Kml2Exp.c
+ *\brief: kml to exp file conversion mex module.
+ */
+#include "./Kml2Exp.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filkml=NULL,*filexp=NULL;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+	}
+	if (nrhs < NRHS) {
+		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filkml,KML_IN);
+	FetchData(&filexp,EXP_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn !=+1 && sgn!= -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Kml2Expx(filkml,filexp,sgn,cm,sp);
+	else
+		iret=Kml2Expx(filkml,filexp,sgn);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	delete options;
+	xfree((void**)&filexp);
+	xfree((void**)&filkml);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Kml2ExpUsage(void){
+	_printf_(true,"Kml2Exp - kml to exp file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from kml to exp format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filkml      file name of kml file to be read (char)\n");
+	_printf_(true,"      filexp      file name of exp file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1);\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/modules/Kml2Exp/Kml2Exp.h
===================================================================
--- /issm/trunk/src/modules/Kml2Exp/Kml2Exp.h	(revision 12331)
+++ /issm/trunk/src/modules/Kml2Exp/Kml2Exp.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*!\file Kml2Exp.h
+ * \brief: prototype for kml to exp file conversion mex module.
+ */
+
+#ifndef _KML2EXP_H
+#define _KML2EXP_H
+
+/* local prototypes: */
+void Kml2ExpUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Kml2Exp"
+
+
+/* serial input macros: */
+#define KML_IN    prhs[0]
+#define EXP_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/trunk/src/modules/Kriging/Kriging.cpp
===================================================================
--- /issm/trunk/src/modules/Kriging/Kriging.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Kriging/Kriging.cpp	(revision 12331)
@@ -0,0 +1,73 @@
+/*\file Kriging.c
+ *\brief: best linear predictor
+ */
+#include "./Kriging.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*Outputs*/
+	double  *x            = NULL;
+	double  *y            = NULL;
+	double  *observations = NULL;
+	double  *x_interp     = NULL;
+	double  *y_interp     = NULL;
+	double  *predictions  = NULL;
+	double  *error        = NULL;
+	Options *options      = NULL;
+	int      N_interp,M_interp,M,N,n_obs;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nrhs<NRHS || nlhs>NLHS){
+		KrigingUsage(); _error_("Kriging usage error");
+	}
+
+	/*Fetch inputs: */
+	FetchData(&x,&n_obs,X);
+	FetchData(&y,&N,Y);                       if(n_obs!=N) _error_("x and y should have the same size");
+	FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
+	FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
+	FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*Call x layer*/
+	Krigingx(&predictions,&error,x,y,observations,n_obs,x_interp,y_interp,M_interp*N_interp,options);
+
+	/*Generate output Matlab Structures*/
+	if(nlhs>=1) WriteData(PREDICTIONS,predictions,M_interp,N_interp);
+	if(nlhs==2) WriteData(ERROR,error,M_interp,N_interp);
+
+	/*Free ressources: */
+	xfree((void**)&x);
+	xfree((void**)&y);
+	xfree((void**)&observations);
+	xfree((void**)&x_interp);
+	xfree((void**)&y_interp);
+	xfree((void**)&predictions);
+	xfree((void**)&error);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KrigingUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"   usage: predictions=%s(x,y,observations,x_interp,y_interp,'options');\n",__FUNCT__);
+	_printf_(true,"   available options:\n");
+	_printf_(true,"      -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'\n");
+	_printf_(true,"         -'nugget': nugget effect (default 0.2)\n");
+	_printf_(true,"         -'range':  for gaussian, spherical and exponential models (default sqrt(3))\n");
+	_printf_(true,"         -'sill':   for gaussian, spherical and exponential models (default 1)\n");
+	_printf_(true,"         -'slope':  for power model (default 1)\n");
+	_printf_(true,"         -'power':  for power model (default 1)\n");
+	_printf_(true,"      -'searchradius': search radius for each prediction (default is observations span)\n");
+	_printf_(true,"      -'boxlength':    minimum length of quadtree boxes (useful to decrease the number of observations)\n");
+	_printf_(true,"      -'maxdata':      minimum number of observations for a prediction (default is 50)\n");
+	_printf_(true,"      -'mindata':      maximum number of observations for a prediction (default is 1)\n");
+	_printf_(true,"      -'maxtrimming':  maximum trimming value (default is -1.e+21)\n");
+	_printf_(true,"      -'mintrimming':  minimum trimming value (default is +1.e+21)\n");
+	_printf_(true,"      -'minspacing':   minimum distance between observation (default is 0.01)\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/Kriging/Kriging.h
===================================================================
--- /issm/trunk/src/modules/Kriging/Kriging.h	(revision 12331)
+++ /issm/trunk/src/modules/Kriging/Kriging.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*
+	KrigingUsage.h
+*/
+
+#ifndef _KRIGING_H_
+#define _KRIGING_H_
+
+/* local prototypes: */
+void KrigingUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Kriging"
+    
+/* serial input macros: */
+#define X            (mxArray *)prhs[0]
+#define Y            (mxArray *)prhs[1]
+#define OBSERVATIONS (mxArray *)prhs[2]
+#define XINTERP      (mxArray *)prhs[3]
+#define YINTERP      (mxArray *)prhs[4]
+
+/* serial output macros: */
+#define PREDICTIONS (mxArray**)&plhs[0]
+#define ERROR       (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  5
+
+#endif  /* _KRIGING_H_ */
Index: /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp
===================================================================
--- /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp	(revision 12331)
@@ -0,0 +1,98 @@
+/*\file Ll2xy.c
+ *\brief: lat/long to x/y coordinate mex module.
+ */
+#include "./Ll2xy.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	double  *lat=NULL,*lon=NULL;
+	int     nlat,nlon,ncoord;
+	int     sgn;
+
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	double  *x=NULL,*y=NULL;
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Ll2xyUsage(); _error_("Ll2xy usage error");
+	}
+	if (nrhs < NRHS) {
+		Ll2xyUsage(); _error_("Ll2xy usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&lat,&nlat,LAT_IN);
+	FetchData(&lon,&nlon,LON_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
+	if(options->GetOption("central_meridian") || options->GetOption("standard_parallel")){
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (verbose) printf("Checking inputs:\n");
+	if (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
+	else                ncoord=nlat;
+	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	x=(double*)mxMalloc(ncoord*sizeof(double));
+	y=(double*)mxMalloc(ncoord*sizeof(double));
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	else
+		iret=Ll2xyx(x,y,lat,lon,ncoord,sgn);
+
+	/*Write data: */
+	WriteData(X_OUT,x,ncoord);
+	WriteData(Y_OUT,y,ncoord);
+
+	/*Clean-up*/
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Ll2xyUsage(void){
+	_printf_(true,"Ll2xy - lat/long to x/y coordinate transformation module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module transforms lat/long to x/y coordinates.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lat         latitude coordinates (double vector)\n");
+	_printf_(true,"      lon         longitude coordinates (double vector)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      x           x coordinates (double vector)\n");
+	_printf_(true,"      y           y coordinates (double vector)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1);\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/Ll2xy/Ll2xy.h
===================================================================
--- /issm/trunk/src/modules/Ll2xy/Ll2xy.h	(revision 12331)
+++ /issm/trunk/src/modules/Ll2xy/Ll2xy.h	(revision 12331)
@@ -0,0 +1,37 @@
+/*!\file Ll2xy.h
+ * \brief: prototype for lat/long to x/y coordinate mex module.
+ */
+
+#ifndef _LL2XY_H
+#define _LL2XY_H
+
+/* local prototypes: */
+void Ll2xyUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Ll2xy"
+
+
+/* serial input macros: */
+#define LAT_IN    prhs[0]
+#define LON_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define X_OUT    (mxArray**)&plhs[0]
+#define Y_OUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  2
+
+#endif
+
Index: /issm/trunk/src/modules/Makefile.am
===================================================================
--- /issm/trunk/src/modules/Makefile.am	(revision 12331)
+++ /issm/trunk/src/modules/Makefile.am	(revision 12331)
@@ -0,0 +1,8 @@
+SUBDIRS = 
+if MATLAB
+SUBDIRS += matlab
+endif
+
+if PYTHON
+SUBDIRS += python
+endif
Index: /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp
===================================================================
--- /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp	(revision 12331)
+++ /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp	(revision 12331)
@@ -0,0 +1,104 @@
+/*!\file:  MeshPartition.cpp
+ * \brief: partition mesh according to number of areas, using Metis library.
+
+	usage:
+	[element_partitioning,node_partitioning]=MeshPartition(model,numareas)
+	
+	%Info needed from model are the following: 
+	%mesh info: 
+	numberofelements,numberofvertices,elements,elements_width
+	%Non-extruded 2d mesh info
+	nel2d,nods2d,elements2d,
+	%Extruded 2d mesh info
+	nel2d_ext,nods2d_ext,elements2d_ext,
+	%Diverse
+	numberoflayers,dim)
+
+	output:
+	vector of partitioning area numbers, for every element.
+	vector of partitioning area numbers, for every node.
+*/
+	
+#include "./MeshPartition.h"
+
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+
+	/*Indexing: */
+	int i,j;
+
+	/* required input: */
+	int     dim;
+	int     numberofelements;
+	int     numberofvertices;
+	double *elements         = NULL;
+	int     elements_width;
+
+	int numberofelements2d;
+	int numberofvertices2d;
+	double* elements2d=NULL;
+
+	int numberoflayers;
+	int numareas=1;
+
+	/* output: */
+	int    *int_element_partitioning = NULL;
+	int    *int_node_partitioning    = NULL;
+	double *element_partitioning     = NULL;
+	double *node_partitioning        = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&MeshPartitionUsage);
+
+	/*Fetch data: */
+	FetchData(&dim,mxGetAssignedField(MODEL,0,"dimension"));
+	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	FetchData(&numberofvertices,mxGetAssignedField(MODEL,0,"numberofvertices"));
+	FetchData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements"));
+
+	if (dim==3){
+		FetchData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d"));
+		FetchData(&numberofvertices2d,mxGetAssignedField(MODEL,0,"numberofvertices2d"));
+		FetchData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d"));
+	}
+	FetchData(&numberoflayers,mxGetAssignedField(MODEL,0,"numberoflayers"));
+	FetchData(&numareas,NUMAREAS);
+
+	/*Run partitioning algorithm based on a "clever" use of the Metis partitioner: */
+	MeshPartitionx(&int_element_partitioning,&int_node_partitioning,numberofelements,numberofvertices,elements,
+		numberofelements2d,numberofvertices2d,elements2d,numberoflayers,elements_width,dim,numareas);
+
+	/*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */
+	element_partitioning=(double*)xmalloc(numberofelements*sizeof(double));
+	for (i=0;i<numberofelements;i++){
+		element_partitioning[i]=(double)int_element_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
+	}
+	
+	node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double));
+	for (i=0;i<numberofvertices;i++){
+		node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
+	}
+
+	/*Write data:*/
+	WriteData(ELEMENTPARTITIONING,element_partitioning,numberofelements);
+	WriteData(NODEPARTITIONING,node_partitioning,numberofvertices);
+	
+	/*Free ressources:*/
+	//don't! let matlab do it.
+
+	/*end module: */
+	MODULEEND();
+}
+
+void MeshPartitionUsage(void){
+	printf("   usage:\n");
+	printf("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
+	printf("   where:\n");
+	printf("      element_partitioning is a vector of partitioning area numbers, for every element.\n");
+	printf("      node_partitioning is a vector of partitioning area numbers, for every node.\n");
+	printf("\n");
+}
Index: /issm/trunk/src/modules/MeshPartition/MeshPartition.h
===================================================================
--- /issm/trunk/src/modules/MeshPartition/MeshPartition.h	(revision 12331)
+++ /issm/trunk/src/modules/MeshPartition/MeshPartition.h	(revision 12331)
@@ -0,0 +1,41 @@
+
+/*
+	MeshPartition.h
+*/
+
+
+#ifndef _MESHPARTITION_H
+#define _MESHPARTITION_H
+
+/* local prototypes: */
+void MeshPartitionUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef CLEANUP
+#define CLEANUP MeshPartitionLocalCleanup();
+
+#undef __FUNCT__ 
+#define __FUNCT__  "MeshPartition"
+
+/* serial input macros: */
+#define MODEL (mxArray*)prhs[0]
+#define NUMAREAS (mxArray*)prhs[1]
+
+/* serial output macros: */
+#define ELEMENTPARTITIONING (mxArray**)&plhs[0]
+#define NODEPARTITIONING (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  2
+
+
+#endif  /* _MESHPARTITION_H */
+
Index: /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12331)
+++ /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12331)
@@ -0,0 +1,114 @@
+/*! \file  MeshProfileIntersection.cpp
+    \brief: takes a  .exp file (made of several profiles), and figures out its intersection 
+	with a mesh.
+
+	usage:
+	[segments]=MeshProfileIntersection(index,x,y,filename);
+
+	where:
+	input:
+		index,x,y is a triangulation
+		filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)
+	output:
+		segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment 
+		belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the 
+		mesh.
+*/
+	
+#include "./MeshProfileIntersection.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	//mesh
+	double* double_index=NULL;
+	int*    index=NULL;
+	int     nel;
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+	int     dummy;
+	
+	//contours
+	mxArray*  matlabstructure=NULL;
+	Contour** contours=NULL;
+	int       numcontours;
+	Contour*  contouri=NULL;
+
+	/* output: */
+	double* segments=NULL;
+	int     numsegs;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&MeshProfileIntersectionUsage);
+
+	/*First, call expread on filename to build a contour array in the matlab workspace: */
+	mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
+	/*Fetch inputs: */
+	//index
+	FetchData(&double_index,&nel,&dummy,INDEX);
+	if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
+	index=(int*)xmalloc(nel*3*sizeof(int));
+	for(i=0;i<nel;i++){
+		for(j=0;j<3;j++){
+			*(index+3*i+j)=(int)*(double_index+dummy*i+j)-1; //"C" style indexing
+		}
+	}
+	//x and y
+	FetchData(&x,&nods,X);
+	FetchData(&y,&dummy,Y);
+
+	//contours
+	numcontours=mxGetNumberOfElements(matlabstructure);
+	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	for(i=0;i<numcontours;i++){
+		//allocate
+		contouri=(Contour*)xmalloc(sizeof(Contour));
+		//retrieve dimension of this contour.
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+		//set pointers.
+		contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+		contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+		*(contours+i)=contouri;
+	}
+
+	/* Debugging of contours :{{{1*/
+	/*for(i=0;i<numcontours;i++){
+		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		contouri=*(contours+i);
+		printf("   Number of vertices %i\n",contouri->nods);
+		for (j=0;j<contouri->nods;j++){
+			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		}
+	}*/
+	/*}}}*/
+
+	/*Run interpolation routine: */
+	MeshProfileIntersectionx(&segments,&numsegs,index,x,y,nel,nods,contours,numcontours);
+
+	/* output: */
+	WriteData(SEGMENTS,segments,numsegs,5);
+
+	/*end module: */
+	MODULEEND();
+
+}
+
+void MeshProfileIntersectionUsage(void){
+	printf("   usage:\n");
+	printf("   [segments]=MeshProfileIntersection(index,x,y,filename);\n");
+	printf("   where:\n");
+	printf("   input:\n");
+	printf("        index,x,y is a triangulation\n");
+	printf("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)\n");
+	printf("   output:\n");
+	printf("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment \n");
+	printf("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the \n");
+	printf("        mesh.\n");
+}
Index: /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.h
===================================================================
--- /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.h	(revision 12331)
+++ /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.h	(revision 12331)
@@ -0,0 +1,38 @@
+
+/*
+	MeshProfileIntersection.h
+*/
+
+
+#ifndef _MESHPROFILEINTERSECTION_H
+#define _MESHPROFILEINTERSECTION_H
+
+/* local prototypes: */
+void MeshProfileIntersectionUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "MeshProfileIntersection"
+
+/* input macros: */
+#define INDEX prhs[0]
+#define X prhs[1]
+#define Y prhs[2]
+#define FILENAME prhs[3]
+
+/* serial output macros: */
+#define SEGMENTS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+#endif  /* _MESHPROFILEINTERSECTION_H */
+
Index: /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12331)
+++ /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12331)
@@ -0,0 +1,42 @@
+/*\file NodeConnectivity.c
+ *\brief: build node connectivity from elements. 
+ */
+
+#include "./NodeConnectivity.h"
+
+WRAPPER(NodeConnectivity){
+
+	/*inputs: */
+	double* elements=NULL;
+	int     nel;
+	int     nods;
+
+	/*outputs: */
+	double* connectivity=NULL;
+	int     width;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&NodeConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&elements,&nel,NULL,ELEMENTS);
+	FetchData(&nods,NUMNODES);
+
+	/*!Generate internal degree of freedom numbers: */
+	NodeConnectivityx(&connectivity, &width,elements,nel, nods);
+
+	/*write output datasets: */
+	WriteData(CONNECTIVITY,connectivity,nods,width);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void NodeConnectivityUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: connectivity = %s(elements, numnodes);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.h
===================================================================
--- /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.h	(revision 12331)
+++ /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.h	(revision 12331)
@@ -0,0 +1,58 @@
+/*
+	NodeConnectivity.h
+*/
+
+#ifndef _NODECONNECTIVITY_H
+#define _NODECONNECTIVITY_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define ELEMENTS (mxArray*)prhs[0]
+#define NUMNODES (mxArray*)prhs[1]
+/* serial output macros: */
+#define CONNECTIVITY (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define ELEMENTS PyTuple_GetItem(args,0)
+#define NUMNODES PyTuple_GetItem(args,1)
+/* serial output macros: */
+#define CONNECTIVITY output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "NodeConnectivity"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+/* local prototypes: */
+void NodeConnectivityUsage(void);
+
+#endif  /* _NODECONNECTIVITY_H */
Index: /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12331)
+++ /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12331)
@@ -0,0 +1,52 @@
+/*! \file  PointCloudFindNeighbors
+    \brief: flag points that are too near one another, within an array of point coordinates
+*/
+	
+#include "./PointCloudFindNeighbors.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+	double  mindistance;
+	double  multithread;
+
+	/* output: */
+	Vector*  flags=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&PointCloudFindNeighborsUsage);
+
+	/*Fetch inputs: */
+	FetchData(&x,&nods,NULL,XHANDLE);  
+	FetchData(&y,NULL,NULL,YHANDLE);
+	FetchData(&mindistance,MINDISTANCE);
+	FetchData(&multithread,MULTITHREAD);
+
+	/*Run core routine: */
+	PointCloudFindNeighborsx(&flags,x,y,nods,mindistance,multithread);
+
+	/* output: */
+	WriteData(FLAGS,flags);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void PointCloudFindNeighborsUsage(void){
+	printf("   usage:\n");
+	printf("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n\n");
+	printf("   where:\n");
+	printf("      x,y: list of points.\n");
+	printf("      mindistance: minimum distance that should exist between points in the cloud.\n");
+	printf("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.\n");
+	printf("      flags: array of flags (flag==1 means point is within mindistance of another point)\n");
+	printf("\n");
+}
Index: /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h
===================================================================
--- /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h	(revision 12331)
+++ /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h	(revision 12331)
@@ -0,0 +1,44 @@
+
+/*
+	PointCloudFindNeighbors.h
+*/
+
+
+#ifndef _POINTCLOUDFINDNEIGHBORS_H
+#define _POINTCLOUDFINDNEIGHBORS_H
+
+/* local prototypes: */
+void PointCloudFindNeighborsUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "PointCloudFindNeighbors"
+
+
+#ifndef ALL
+#define ALL 0
+#endif
+
+/* input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define MINDISTANCE prhs[2]
+#define MULTITHREAD prhs[3]
+
+/* serial output macros: */
+#define FLAGS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+
+#endif  /* _POINTCLOUDFINDNEIGHBORS_H */
+
Index: /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12331)
+++ /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12331)
@@ -0,0 +1,47 @@
+/*\file PropagateFlagsFromConnectivity.c
+ *\brief: propagate flags onto mesh, element by element, using connectivity.
+ */
+
+#include "./PropagateFlagsFromConnectivity.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input/output datasets: */
+	double* connectivity=NULL;
+	int     nel;
+	double* pool=NULL;
+	double* flags=NULL;
+	int     index;
+	int     dummy;
+	
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&PropagateFlagsFromConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&connectivity,&nel,&dummy,CONNECTIVITY);
+	FetchData(&pool,&dummy,POOL);
+	FetchData(&index,INDEX);
+	FetchData(&flags,&dummy,FLAGS);
+
+	/*!Generate internal degree of freedom numbers: */
+	PropagateFlagsFromConnectivityx(pool,connectivity,index,flags);
+
+	/*write output datasets: */
+	WriteData(POOLOUT,pool,nel);
+
+	/*Free ressources: */
+	xfree((void**)&connectivity);
+	xfree((void**)&flags);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void PropagateFlagsFromConnectivityUsage(void) {
+	printf("\n");
+	printf("   usage: [pool] = %s(connectivity,pool,index,flags);\n",__FUNCT__);
+	printf("\n");
+}
Index: /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
===================================================================
--- /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h	(revision 12331)
+++ /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h	(revision 12331)
@@ -0,0 +1,40 @@
+
+/*
+	PropagateFlagsFromConnectivity.h
+*/
+
+
+#ifndef _PROPAGATEFLAGSFROMCONNECTIVITY_H
+#define _PROPAGATEFLAGSFROMCONNECTIVITY_H
+
+/* local prototypes: */
+void PropagateFlagsFromConnectivityUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "PropagateFlagsFromConnectivity"
+
+/* serial input macros: */
+#define CONNECTIVITY (mxArray*)prhs[0]
+#define POOL (mxArray*)prhs[1]
+#define INDEX (mxArray*)prhs[2]
+#define FLAGS (mxArray*)prhs[3]
+
+/* serial output macros: */
+#define POOLOUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  4
+
+
+#endif  /* _PROPAGATEFLAGSFROMCONNECTIVITY_H */
+
+
Index: /issm/trunk/src/modules/Scotch/Scotch.cpp
===================================================================
--- /issm/trunk/src/modules/Scotch/Scotch.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Scotch/Scotch.cpp	(revision 12331)
@@ -0,0 +1,267 @@
+/*\file Scotch.c
+ *\brief:  Scotch partitioner mex module
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include "./Scotch.h"
+
+/******************************/
+/*                            */
+/* This is the main function. */
+/*                            */
+/******************************/
+
+void mexFunction( int nlhs,
+				  mxArray *plhs[],
+				  int nrhs,
+				  const mxArray *prhs[] )
+{
+
+#ifndef _HAVE_SCOTCH_ //only works if scotch library has been compiled in.
+	_error_(" Scotch not available! Cannot carry out Scotch partitioning!");
+	#else
+
+	int     argcm;
+	char    **argvm=NULL;
+	int     nvert =0,nedge2=0,napar =0;
+	mwIndex *ir=NULL,*jc=NULL;
+	int     *adjir=NULL,*adjjc=NULL;
+	double  *vld=NULL,*vwd=NULL,*ewd=NULL,*apd=NULL;
+	int     *vli=NULL,*vwi=NULL,*ewi=NULL,*api=NULL;
+	char    *archtyp=NULL;
+	int     (*maptabi)[2]=NULL;
+	double* maptabd=NULL;
+	int     i,j,k,imi=0,imo=0,isi=0,ierr;
+
+	/* Check for proper number of arguments */
+   
+	if      (nrhs == 0 && nlhs == 0) {
+		GmapUsage();
+		return;
+	}
+	else if (nrhs <  6 || nlhs >  1) {
+		GmapUsage();
+		mexErrMsgTxt(" ");
+	}
+
+/*  load matlab argument list and convert to integer (note that converting here
+	and in the x-layer is inefficient, but it makes the x-layer more general)  */
+
+	argvm = (char **) calloc(nrhs,sizeof(char *));
+
+	if (!(mxIsNumeric(prhs[imi]) &&
+		  (mxGetM(prhs[imi]) == 1 && mxGetN(prhs[imi]) == 1))) {
+		argvm[isi] = (char *) calloc(4+1,sizeof(char));
+		strcpy(argvm[isi],"gmap");
+		mexPrintf("%s -- Using \"%s\" entry point.\n",
+				  __FUNCT__,argvm[isi]);
+		isi++;
+	}
+	else {
+		argvm[isi] = (char *) calloc(5+1,sizeof(char));
+		strcpy(argvm[isi],"gpart");
+		mexPrintf("%s -- Using \"%s\" entry point.\n",
+				  __FUNCT__,argvm[isi]);
+		isi++;
+
+		argvm[isi] = (char *) calloc(17,sizeof(char));
+		sprintf(argvm[isi],"%d",(int)mxGetScalar(prhs[imi]));
+		mexPrintf("%s -- Number of parts is %s.\n",
+				  __FUNCT__,argvm[isi]);
+		isi++;
+		imi++;
+	}
+
+	if (!mxIsNumeric(prhs[imi]) || (!mxIsEmpty(prhs[imi]) && !mxIsSparse(prhs[imi]))) {
+		mexPrintf("%s -- Adjacency matrix must be numeric and sparse.\n",__FUNCT__);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		nvert =mxGetM(prhs[imi]);
+		nedge2=mxGetNzmax(prhs[imi]);
+		if (mxGetNzmax(prhs[imi])) {
+			ir    =mxGetIr(prhs[imi]);
+			adjir = (int *) malloc(mxGetNzmax(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetNzmax(prhs[imi]); i++)
+				adjir[i]=(int)ir[i];
+		}
+		if (mxGetN(prhs[imi])) {
+			jc    =mxGetJc(prhs[imi]);
+			adjjc = (int *) malloc((mxGetN(prhs[imi])+1)*sizeof(int));
+			for (i=0; i<(mxGetN(prhs[imi])+1); i++)
+				adjjc[i]=(int)jc[i];
+		}
+		mexPrintf("%s -- Adjacency matrix is of size %d by %d with %d non-zeroes.\n",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]),mxGetNzmax(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex label vector must be numeric.\n",__FUNCT__);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+			vld=mxGetPr(prhs[imi]);
+			vli = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+				vli[i]=(int)vld[i];
+		}
+		mexPrintf("%s -- Vertex label vector is of size %d by %d.\n",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex weight vector must be numeric.\n",__FUNCT__);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+			vwd=mxGetPr(prhs[imi]);
+			vwi = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+				vwi[i]=(int)vwd[i];
+		}
+		mexPrintf("%s -- Vertex weight vector is of size %d by %d.\n",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi]) || (!mxIsEmpty(prhs[imi]) && !mxIsSparse(prhs[imi]))) {
+		mexPrintf("%s -- Edge weight matrix must be numeric and sparse.\n",__FUNCT__);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])) {
+			ewd=mxGetPr(prhs[imi]);
+			ewi = (int *) malloc(mxGetM(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetNzmax(prhs[imi]); i++)
+				ewi[i]=(int)ewd[i];
+		}
+		mexPrintf("%s -- Edge weight matrix is of size %d by %d with %d non-zeroes.\n",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]),mxGetNzmax(prhs[imi]));
+	}
+	imi++;
+
+	if (!((strlen (argvm[0]) >= 5) &&
+		  (strncmp (argvm[0] + strlen (argvm[0]) - 5, "gpart", 5) == 0))) {
+		if (!mxIsChar(prhs[imi])) {
+			mexPrintf("%s -- Architecture type must be character.\n",__FUNCT__);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+				archtyp = (char *) calloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])+1,sizeof(char));
+				mxGetString(prhs[imi],archtyp,mxGetM(prhs[imi])*mxGetN(prhs[imi])+1);
+			}
+			mexPrintf("%s -- Architecture type is \"%s\".\n",
+					  __FUNCT__,archtyp);
+		}
+		imi++;
+
+		if (!mxIsNumeric(prhs[imi])) {
+			mexPrintf("%s -- Architecture parameter vector must be numeric.\n",__FUNCT__);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			napar =mxGetM(prhs[imi])*mxGetN(prhs[imi]);
+			if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+				apd=mxGetPr(prhs[imi]);
+				api = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+				for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+					api[i]=(int)apd[i];
+			}
+			mexPrintf("%s -- Architecture parameter vector is of size %d by %d.\n",
+					  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+		}
+		imi++;
+	}
+
+	while (imi < nrhs) {
+		if (!mxIsChar(prhs[imi])) {
+			mexPrintf("%s -- prhs[%d] must be character.\n",__FUNCT__,imi);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			argvm[isi] = (char *) calloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])+1,sizeof(char));
+			mxGetString(prhs[imi],argvm[isi],mxGetM(prhs[imi])*mxGetN(prhs[imi])+1);
+		}
+		isi++;
+		imi++;
+	}
+	argcm=isi;
+	mexPrintf("argcm=%d\n",argcm);
+	for (i=0; i<argcm; i++)
+		mexPrintf("argvm[%d]=\"%s\"\n",i,argvm[i]);
+
+	/* Do the actual computations in a subroutine */
+
+	mexPrintf("Gmapx:\n");
+	ierr=gmapx(&maptabi,
+			   argcm,
+			   argvm,
+			   nvert,
+			   nedge2,
+			   adjir,
+			   adjjc,
+			   vli,
+			   vwi,
+			   ewi,
+			   archtyp,
+			   napar,
+			   api);
+	mexPrintf("%s -- Error %d from Gmapx.\n",__FUNCT__,ierr);
+
+/*  for (i=0; i<nvert; i++)
+		mexPrintf("maptabi[%d][0]=%d, maptabi[%d][1]=%d\n",
+			 	  i,maptabi[i][0],i,maptabi[i][1]); */
+
+	/* Create matrices for the return arguments */
+
+	if (maptabi) {
+		plhs[imo]=mxCreateDoubleMatrix(nvert, 2, mxREAL);
+		maptabd = mxGetPr(plhs[imo]);
+		k=0;
+		for (j=0; j<2; j++)
+			for (i=0; i<nvert; i++)
+				maptabd[k++]=(double)maptabi[i][j];
+		//free(maptabi);
+	}
+	else {
+		plhs[imo]=mxCreateDoubleMatrix(0, 2, mxREAL);
+	}
+	imo++;
+
+	/*if (argvm)
+		for (i=argcm-1; i>=0; i--)
+			free(argvm[i]);
+	if (api)     free(api);
+	if (archtyp) free(archtyp);
+	if (ewi)     free(ewi);
+	if (vwi)     free(vwi);
+	if (vli)     free(vli);
+	if (adjjc)   free(adjjc);
+	if (adjir)   free(adjir);*/
+
+	return;
+#endif //#ifndef _HAVE_SCOTCH_
+}
+
+void GmapUsage( void )
+{
+
+    mexPrintf("\n");
+    mexPrintf("Usage: [maptab]=Scotch(adjmat,vertlb,vertwt,edgewt,archtyp,archpar,\n");
+    mexPrintf("                         Scotch-specific parameters);\n");
+    mexPrintf("\n");
+
+    return;
+}
+
Index: /issm/trunk/src/modules/Scotch/Scotch.h
===================================================================
--- /issm/trunk/src/modules/Scotch/Scotch.h	(revision 12331)
+++ /issm/trunk/src/modules/Scotch/Scotch.h	(revision 12331)
@@ -0,0 +1,40 @@
+/*!\file:  Scotch.h
+ * \brief header file for Scotch module.
+ */ 
+
+#ifndef _SCOTCH_H
+#define _SCOTCH_H
+
+/* local prototypes: */
+void GmapUsage(void);
+
+#include <stdio.h>
+#include <string.h>    /*  strcasecmp  */
+#include <time.h>      /*  clock,time,difftime  */
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+#undef __FUNCT__ 
+#define __FUNCT__  "Scotch"
+
+/*  Scotch structures and prototypes  */
+#ifdef MATLAB
+		#include "mat.h"
+		#include "mex.h"
+		#include "matrix.h"
+
+		#define printf mexPrintf
+		#define fprintf(file,...) (file == stdout || file == stderr ? mexPrintf(__VA_ARGS__) : fprintf(file,__VA_ARGS__))
+		#define malloc mxMalloc
+		#define calloc mxCalloc
+		#define realloc mxRealloc
+		#define free mxFree
+		#define exit(status) mexErrMsgTxt("exit=" #status)
+#endif
+
+
+#endif  /* _SCOTCH_H */
Index: /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp
===================================================================
--- /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12331)
@@ -0,0 +1,100 @@
+/*\file Shp2Kml.c
+ *\brief: shp to kml file conversion mex module.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "./Shp2Kml.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filshp=NULL,*filkml=NULL;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	#ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in.
+	_error_(" Shapelib not available! Cannot carry out shp file translation!");
+	#endif
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+	}
+	if (nrhs < NRHS) {
+		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filshp,SHP_IN);
+	FetchData(&filkml,KML_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=%d must be +1 (north), -1 (south), or 0 (no translation).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Shp2Kmlx(filshp,filkml,sgn,cm,sp);
+	else
+		iret=Shp2Kmlx(filshp,filkml,sgn);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	delete options;
+	xfree((void**)&filkml);
+	xfree((void**)&filshp);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Shp2KmlUsage(void){
+	_printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from shp to kml format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filshp      file name of shp file to be read (char, extension optional)\n");
+	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 0);\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/Shp2Kml/Shp2Kml.h
===================================================================
--- /issm/trunk/src/modules/Shp2Kml/Shp2Kml.h	(revision 12331)
+++ /issm/trunk/src/modules/Shp2Kml/Shp2Kml.h	(revision 12331)
@@ -0,0 +1,36 @@
+/*!\file Shp2Kml.h
+ * \brief: prototype for shp to kml file conversion mex module.
+ */
+
+#ifndef _SHP2KML_H
+#define _SHP2KML_H
+
+/* local prototypes: */
+void Shp2KmlUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Shp2Kml"
+
+
+/* serial input macros: */
+#define SHP_IN    prhs[0]
+#define KML_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp
===================================================================
--- /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp	(revision 12331)
+++ /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp	(revision 12331)
@@ -0,0 +1,32 @@
+/*\file StringToEnum.c
+ *\brief:convert enum (int) to string
+ */
+
+#include "./StringToEnum.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	char    *name    = NULL;
+	int      enum_out;
+
+	/*checks on arguments on the matlab side: */
+	if(nrhs!=NRHS){
+		StringToEnumUsage(); _error_(" usage. See above");
+	}
+
+	/*Fetch inputs: */
+	FetchData(&name,NAME);
+
+	/*Run core function: */
+	enum_out=StringToEnumx(name);
+
+	/* output: */
+	WriteData(ENUMOUT,enum_out);
+}
+
+void StringToEnumUsage(void)
+{
+	_printf_(true,"\n");
+	_printf_(true,"   usage: %senum = StringToEnum(string);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/StringToEnum/StringToEnum.h
===================================================================
--- /issm/trunk/src/modules/StringToEnum/StringToEnum.h	(revision 12331)
+++ /issm/trunk/src/modules/StringToEnum/StringToEnum.h	(revision 12331)
@@ -0,0 +1,32 @@
+/*!\file:  StringToEnum.h
+ * \brief header file for StringToEnum module.
+ */ 
+
+#ifndef _STRINGTOENUM_H
+#define _STRINGTOENUM_H
+
+/* local prototypes: */
+void StringToEnumUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define NAME (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define ENUMOUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#undef __FUNCT__ 
+#define __FUNCT__  "StringToEnum"
+
+#endif  /* _TEST_H */
Index: /issm/trunk/src/modules/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk/src/modules/TriMesh/TriMesh.cpp	(revision 12331)
+++ /issm/trunk/src/modules/TriMesh/TriMesh.cpp	(revision 12331)
@@ -0,0 +1,73 @@
+/*
+ * TriMesh: mesh a domain using an .exp file
+ */
+
+#include "./TriMesh.h"
+
+WRAPPER(TriMesh){
+	
+	/* input: */
+	char   *domainname = NULL;
+	char   *riftsname  = NULL;
+	double  area;
+
+	/*intermediary: */
+	DataSet *domain = NULL;
+	DataSet *rifts  = NULL;
+
+	/* output: */
+	Matrix *index             = NULL;
+	Vector *x                 = NULL;
+	Vector *y                 = NULL;
+	Matrix *segments          = NULL;
+	Vector *segmentmarkerlist = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&TriMeshUsage);
+	
+	/*Fetch data needed for meshing: */
+	FetchData(&domainname,DOMAINOUTLINE);
+	FetchData(&riftsname,RIFTSOUTLINE);
+	FetchData(&area,AREA);
+
+	/*Read domain outline: */
+	domain = DomainOutlineRead(domainname);
+	rifts  = DomainOutlineRead(riftsname);
+
+	/*call x core: */
+	TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist,domain,rifts,area);
+
+	/*write outputs: */
+	WriteData(INDEX,index);
+	WriteData(X,x);
+	WriteData(Y,y);
+	WriteData(SEGMENTS,segments);
+	WriteData(SEGMENTMARKERLIST,segmentmarkerlist);
+
+	/*free ressources: */
+	delete domain;
+	delete rifts;
+	xdelete_module(&index);
+	xdelete_module(&x);
+	xdelete_module(&y);
+	xdelete_module(&segments);
+	xdelete_module(&segmentmarkerlist);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void TriMeshUsage(void) //{{{1
+{
+	printf("\n");
+	printf("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) \n");
+	printf("      where: index,x,y defines a triangulation, segments is an array made \n");
+	printf("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, \n");
+	printf("      outlinefilename an Argus domain outline file, \n");
+	printf("      area is the maximum area desired for any element of the resulting mesh, \n");
+	printf("\n");
+}
+//}}}
Index: /issm/trunk/src/modules/TriMesh/TriMesh.h
===================================================================
--- /issm/trunk/src/modules/TriMesh/TriMesh.h	(revision 12331)
+++ /issm/trunk/src/modules/TriMesh/TriMesh.h	(revision 12331)
@@ -0,0 +1,68 @@
+/*
+	TriMesh.h
+*/
+
+#ifndef _TRIMESH_H
+#define _TRIMESH_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define DOMAINOUTLINE  (mxArray *)prhs[0]
+#define RIFTSOUTLINE   (mxArray *)prhs[1]
+#define AREA           (mxArray *)prhs[2]
+/* serial output macros: */
+#define INDEX             (mxArray**)&plhs[0]
+#define X                 (mxArray**)&plhs[1]
+#define Y                 (mxArray**)&plhs[2]
+#define SEGMENTS          (mxArray**)&plhs[3]
+#define SEGMENTMARKERLIST (mxArray**)&plhs[4]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define DOMAINOUTLINE PyTuple_GetItem(args,0)
+#define RIFTSOUTLINE  PyTuple_GetItem(args,1)
+#define AREA          PyTuple_GetItem(args,2)
+/* serial output macros: */
+#define INDEX             output,0
+#define X                 output,1
+#define Y                 output,2
+#define SEGMENTS          output,3
+#define SEGMENTMARKERLIST output,4
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "TriMesh"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  5
+#undef NRHS
+#define NRHS  3
+
+/* local prototypes: */
+void TriMeshUsage(void);
+
+#endif  /* _TRIMESH_H */
Index: /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12331)
+++ /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12331)
@@ -0,0 +1,331 @@
+/*!\file:  TriMeshProcessRifts.cpp
+ * \brief split a mesh where a rift (or fault) is present
+ */ 
+
+#include "./TriMeshProcessRifts.h"
+
+void mexFunction(	int nlhs, mxArray* plhs[],
+					int nrhs, const mxArray* prhs[] ) {
+
+
+	/*Matlab arrays: */
+	mxArray* pmxa_array=NULL;
+	mxArray* pmxa_array2=NULL;
+	mxArray* pmxa_array3=NULL;
+	int i,j,k,counter;
+	
+	/* returned quantities: */
+	int      out_numrifts;
+	int*     out_riftsnumsegments=NULL;
+	double** out_riftssegments=NULL; 
+	int*     out_riftsnumpairs=NULL;
+	double** out_riftspairs=NULL;
+	double*  out_riftstips=NULL;
+	double** out_riftspenaltypairs=NULL;
+	int*     out_riftsnumpenaltypairs=NULL;
+
+	/*empty rifts structure: */
+	double* pNaN=NULL;
+	const	char*	fnames[10];
+	mwSize     ndim=2;
+	mwSize		dimensions[2] = {1,1};
+	double* pair=NULL;
+
+	
+	/* input: */
+	double* tindex_in=NULL;
+	double* index_in=NULL;
+	int     nel;
+	double* x_inm=NULL; //matlab vector
+	double* x_in=NULL; //copy of matlab vector
+	int     nods;
+	double* y_inm=NULL;//matlab vector
+	double* y_in=NULL;//copy of matlab vector
+	double* tsegments_in=NULL;
+	double* segments_in=NULL;
+	double* tsegmentmarkers_in=NULL;
+	double* segmentmarkers_in=NULL;
+
+	/* state: */
+	double* state=NULL;
+
+	int     num_seg;
+
+	/*rifts: */
+	int     riftflag;
+	int     numrifts;
+
+	/* verify correct usage: */
+	if (nlhs==0 && nrhs==0) {
+		/* special case: */
+		TriMeshProcessRiftsUsage();
+		return;
+	}
+	
+	if (!(  (nlhs==6) || (nrhs==5))){
+		mexPrintf("   %s format error.\n", __FUNCT__);
+		TriMeshProcessRiftsUsage();
+		printf("   ");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch index_in: */
+	if(mxIsDouble(prhs[0])){
+		nel=mxGetM(prhs[0]);
+		tindex_in=mxGetPr(prhs[0]);
+		index_in=(double*)xmalloc(nel*3*sizeof(double));
+		for (i=0;i<nel;i++){
+			for (j=0;j<3;j++){
+				*(index_in+3*i+j)=*(tindex_in+nel*j+i);
+			}
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: first argument should be the element list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch x_in: */
+	if(mxIsDouble(prhs[1])){
+		nods=mxGetM(prhs[1]);
+		x_inm=mxGetPr(prhs[1]);
+		x_in=(double*)xmalloc(nods*sizeof(double));
+		for (i=0;i<nods;i++){
+			x_in[i]=x_inm[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: second argument should be the x corrdinate list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch y_in: */
+	if(mxIsDouble(prhs[2])){
+		y_inm=mxGetPr(prhs[2]);
+		y_in=(double*)xmalloc(nods*sizeof(double));
+		for (i=0;i<nods;i++){
+			y_in[i]=y_inm[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: third argument should be the y corrdinate list!");
+		mexErrMsgTxt(" ");
+	}	
+
+	/*Fetch segments_in: */
+	if(mxIsDouble(prhs[3])){
+		num_seg=mxGetM(prhs[3]);
+		tsegments_in=mxGetPr(prhs[3]);
+		segments_in=(double*)xmalloc(num_seg*3*sizeof(double));
+		for (i=0;i<num_seg;i++){
+			for (j=0;j<3;j++){
+				*(segments_in+3*i+j)=*(tsegments_in+num_seg*j+i);
+			}
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segments list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch segment markers: */
+	if(mxIsDouble(prhs[4])){
+		tsegmentmarkers_in=mxGetPr(prhs[4]);
+		segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double));
+		for (i=0;i<num_seg;i++){
+			segmentmarkers_in[i]=tsegmentmarkers_in[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segmentmarkers list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*
+	printf("Index: \n");
+	for (i=0;i<nel;i++){
+		for(j=0;j<3;j++){
+			printf("%lf ",*(index_in+3*i+j));
+		}
+		printf("\n");
+	}
+	printf("x,y: \n");
+	for (i=0;i<nods;i++){
+		printf("%16.16lf %16.16lf\n",x_in[i],y_in[i]);
+	}
+	printf("segments:\n");
+	for (i=0;i<num_seg;i++){
+		for(j=0;j<3;j++){
+			printf("%lf ",*(segments_in+3*i+j));
+		}
+		printf("%lf ",segmentmarkers_in[i]);
+		printf("\n");
+	}
+	*/
+
+	/*First, do some fixing on the existing mesh: we do not want any element belonging entirely to the segment list (ie: 
+	 *all the nodes of this element belong to the segments (tends to happen when there are corners: */
+	RemoveCornersFromRifts(&index_in,&nel,&x_in,&y_in,&nods,segments_in,segmentmarkers_in,num_seg);
+
+	/*Figure out if we have rifts, and how many: */
+	IsRiftPresent(&riftflag,&numrifts,segmentmarkers_in,num_seg);
+	
+	if(riftflag){	
+		SplitMeshForRifts(&nel,&index_in,&nods,&x_in,&y_in,&num_seg,&segments_in,&segmentmarkers_in);
+	}
+
+	/*Order segments so that their normals point outside the domain: */
+	OrderSegments(&segments_in,num_seg, index_in,nel);
+	
+	if(riftflag){
+		
+		/*We do not want to output segments mixed with rift segments: wring out the rifts from the segments, using the 
+		 *segmentmarkerlist:*/
+		SplitRiftSegments(&segments_in,&segmentmarkers_in,&num_seg,&out_numrifts,&out_riftsnumsegments,&out_riftssegments,numrifts,nods,nel);
+
+		/*Using rift segments, associate rift faces in pairs, each pair face representing opposite flanks of the rifts facing one another directly: */
+		PairRiftElements(&out_riftsnumpairs,&out_riftspairs,out_numrifts,out_riftsnumsegments,out_riftssegments,x_in,y_in);
+		
+		/*Order rifts so that they start from one tip, go to the other tip, and back: */
+		OrderRifts(&out_riftstips, out_riftssegments,out_riftspairs,numrifts,out_riftsnumsegments,x_in,y_in,nods,nel);
+
+		/*Create penalty pairs, used by Imp: */
+		PenaltyPairs(&out_riftspenaltypairs,&out_riftsnumpenaltypairs,numrifts,out_riftssegments,out_riftsnumsegments,out_riftspairs,out_riftstips,x_in,y_in);
+	}
+
+
+	/*Output : */
+	WriteData(&plhs[0],index_in,nel,3);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,3);
+	//mxSetN(pmxa_array,nel);
+	//mxSetPr(pmxa_array,index_in);
+	//mexCallMATLAB( 1, &plhs[0], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[1],x_in,nods,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,nods);
+	//mxSetPr(pmxa_array,x_in);
+	//mexCallMATLAB( 1, &plhs[1], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[2],y_in,nods,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,nods);
+	//mxSetPr(pmxa_array,y_in);
+	//mexCallMATLAB( 1, &plhs[2], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[3],segments_in,num_seg,3);
+//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+//mxSetM(pmxa_array,3);
+//mxSetN(pmxa_array,num_seg);
+//mxSetPr(pmxa_array,segments_in);
+//mexCallMATLAB( 1, &plhs[3], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[4],segmentmarkers_in,num_seg,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,num_seg);
+	//mxSetPr(pmxa_array,segmentmarkers_in);
+	//mexCallMATLAB( 1, &plhs[4], 1, &pmxa_array, "transpose");
+
+	if(riftflag){
+		/*Create a structure rifts where if i is a rift number, we have the following fields rifts(i).segments and rifts(i).numsegs: */
+
+		fnames[0] = "numsegs";
+		fnames[1] = "segments";
+		fnames[2] = "pairs";
+		fnames[3] = "tips";
+		fnames[4] = "penaltypairs";
+		fnames[5] = "fill";
+		fnames[6] = "friction";
+		fnames[7] = "fraction";
+		fnames[8] = "fractionincrement";
+		fnames[9] = "state";
+
+		dimensions[0]=out_numrifts;
+
+		pmxa_array=mxCreateStructArray( ndim,dimensions,10,fnames);
+		
+		for (i=0;i<out_numrifts;i++){
+
+			/*Segments: */
+			WriteData(&pmxa_array3,out_riftssegments[i],out_riftsnumsegments[i],3);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,3);
+			//mxSetN(pmxa_array2,out_riftsnumsegments[i]);
+			//mxSetPr(pmxa_array2,out_riftssegments[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"segments",pmxa_array3);
+			mxSetField(pmxa_array,i,"numsegs",mxCreateDoubleScalar((double)out_riftsnumsegments[i]));
+
+			/*Element pairs: */
+			WriteData(&pmxa_array3,out_riftspairs[i],out_riftsnumpairs[i],2);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,2);
+			//mxSetN(pmxa_array2,out_riftsnumpairs[i]);
+			//mxSetPr(pmxa_array2,out_riftspairs[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"pairs",pmxa_array3);
+
+			/*Tips: */
+			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			mxSetM(pmxa_array2,1);
+			pair=(double*)mxMalloc(2*sizeof(double));
+			pair[0]=*(out_riftstips+2*i+0);
+			pair[1]=*(out_riftstips+2*i+1);
+			mxSetN(pmxa_array2,2);
+			mxSetPr(pmxa_array2,pair);
+			mxSetField(pmxa_array,i,"tips",pmxa_array2);
+
+			/*Penalty pairs: */
+			WriteData(&pmxa_array3,out_riftspenaltypairs[i],out_riftsnumpenaltypairs[i],7);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,7);
+			//mxSetN(pmxa_array2,out_riftsnumpenaltypairs[i]);
+			//mxSetPr(pmxa_array2,out_riftspenaltypairs[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"penaltypairs",pmxa_array3);
+
+			/*Friction fraction, fractionincrement  and fill: */
+			mxSetField(pmxa_array,i,"friction",mxCreateDoubleScalar(0));
+			mxSetField(pmxa_array,i,"fill",mxCreateDoubleScalar(IceEnum)); //default is ice
+			mxSetField(pmxa_array,i,"fraction",mxCreateDoubleScalar(0)); //default is ice
+			mxSetField(pmxa_array,i,"fractionincrement",mxCreateDoubleScalar(0.1)); 
+
+			/*State: */
+			state=(double*)mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
+			for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum;
+			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			mxSetM(pmxa_array2,1);
+			mxSetN(pmxa_array2,out_riftsnumpenaltypairs[i]);
+			mxSetPr(pmxa_array2,state);
+			mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			
+			mxSetField(pmxa_array,i,"state",pmxa_array3);
+		}
+	}
+	else{
+		/*output NaN :*/
+		pNaN=(double*)mxMalloc(sizeof(double));
+		*pNaN=NAN;
+		pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(pmxa_array,1);
+		mxSetN(pmxa_array,1);
+		mxSetPr(pmxa_array,pNaN);
+		
+	}
+	plhs[5]=pmxa_array;
+
+	return;
+}
+
+
+void TriMeshProcessRiftsUsage(void)
+{
+	printf("\n");
+	printf("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) \n");
+	printf("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.\n");
+	printf("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.\n");
+}
Index: /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h
===================================================================
--- /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h	(revision 12331)
+++ /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h	(revision 12331)
@@ -0,0 +1,23 @@
+/*!\file:  TriMeshProcessRifts.h
+ * \brief header prototype
+ */ 
+
+#ifndef _TRIMESH_PROCESSRIFTS_H_
+#define _TRIMESH_PROCESSRIFTS_H_
+
+#include "mex.h"
+#include "triangle.h"
+#include "string.h"
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+void TriMeshProcessRiftsUsage(void);
+#undef __FUNCT__ 
+#define __FUNCT__ "TriMeshProcessRifts"
+
+#endif
Index: /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp
===================================================================
--- /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp	(revision 12331)
+++ /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp	(revision 12331)
@@ -0,0 +1,66 @@
+/*\file TriaSearch.c
+ *\brief: TriaSearch module. See TriaSearchx for more details.
+ */
+#include "./TriaSearch.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i;
+
+	/*input: */
+	double* index=NULL;
+	int     nel;
+	int     dummy;
+
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+
+	double* x0=NULL;
+	double* y0=NULL;
+	int     numberofnodes;
+
+	/* output: */
+	double*  tria=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&TriaSearchUsage);
+
+	/*Input datasets: */
+	FetchData(&index,&nel,&dummy,INDEXHANDLE);
+	FetchData(&x,&nods,XHANDLE);
+	FetchData(&y,&nods,YHANDLE);
+	FetchData(&x0,&numberofnodes,X0HANDLE);
+	FetchData(&y0,&numberofnodes,Y0HANDLE);
+
+	/* Echo: {{{1*/
+	//printf("(x0,y0)=(%g,%g)\n",x0,y0);
+	/*}}}*/
+
+	/* Run core computations: */
+	TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes);
+
+	/* c to matlab: */
+	for(i=0;i<numberofnodes;i++)tria[i]++;
+
+	/*Write data: */
+	WriteData(TRIA,tria,numberofnodes);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void TriaSearchUsage(void)
+{
+	_printf_(true,"TriaSearch- find triangle holding a point (x0,y0) in a mesh\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"         tria=TriaSearch(index,x,y,x0,y0);\n");
+	_printf_(true,"      index,x,y: mesh triangulatrion\n");
+	_printf_(true,"      x0,y0: coordinates of the point for which we are trying to find a triangle\n");
+	_printf_(true,"      x0,y0 can be an array of points\n");
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/modules/TriaSearch/TriaSearch.h
===================================================================
--- /issm/trunk/src/modules/TriaSearch/TriaSearch.h	(revision 12331)
+++ /issm/trunk/src/modules/TriaSearch/TriaSearch.h	(revision 12331)
@@ -0,0 +1,37 @@
+/*!\file TriaSearch.h
+ */
+
+#ifndef _TRIASEARCH_H
+#define _TRIASEARCH_H
+
+/* local prototypes: */
+void TriaSearchUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "TriaSearch"
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define X0HANDLE prhs[3]
+#define Y0HANDLE prhs[4]
+
+/* serial output macros: */
+#define TRIA (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+
+#undef NRHS
+#define NRHS  5
+
+#endif
Index: /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp
===================================================================
--- /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp	(revision 12331)
+++ /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp	(revision 12331)
@@ -0,0 +1,98 @@
+/*\file Xy2ll.c
+ *\brief: x/y to lat/long coordinate mex module.
+ */
+#include "./Xy2ll.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	double  *x=NULL,*y=NULL;
+	int     nx,ny,ncoord;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	double  *lat=NULL,*lon=NULL;
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Xy2llUsage(); _error_("Xy2ll usage error");
+	}
+	if (nrhs < NRHS) {
+		Xy2llUsage(); _error_("Xy2ll usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&x,&nx,X_IN);
+	FetchData(&y,&ny,Y_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
+	else            ncoord=nx;
+	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	lat=(double*)mxMalloc(ncoord*sizeof(double));
+	lon=(double*)mxMalloc(ncoord*sizeof(double));
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
+	else
+		iret=Xy2llx(lat,lon,x,y,ncoord,sgn);
+
+	/*Write data: */
+	WriteData(LAT_OUT,lat,ncoord);
+	WriteData(LON_OUT,lon,ncoord);
+
+	/*Clean-up*/
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Xy2llUsage(void){
+	_printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module transforms x/y to lat/long coordinates.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      x           x coordinates (double vector)\n");
+	_printf_(true,"      y           y coordinates (double vector)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lat         latitude coordinates (double vector)\n");
+	_printf_(true,"      lon         longitude coordinates (double vector)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1);\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/modules/Xy2ll/Xy2ll.h
===================================================================
--- /issm/trunk/src/modules/Xy2ll/Xy2ll.h	(revision 12331)
+++ /issm/trunk/src/modules/Xy2ll/Xy2ll.h	(revision 12331)
@@ -0,0 +1,37 @@
+/*!\file Xy2ll.h
+ * \brief: prototype for x/y to lat/long coordinate mex module.
+ */
+
+#ifndef _XY2LL_H
+#define _XY2LL_H
+
+/* local prototypes: */
+void Xy2llUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Xy2ll"
+
+
+/* serial input macros: */
+#define X_IN      prhs[0]
+#define Y_IN      prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define LAT_OUT    (mxArray**)&plhs[0]
+#define LON_OUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  2
+
+#endif
+
Index: /issm/trunk/src/modules/matlab/Makefile.am
===================================================================
--- /issm/trunk/src/modules/matlab/Makefile.am	(revision 12331)
+++ /issm/trunk/src/modules/matlab/Makefile.am	(revision 12331)
@@ -0,0 +1,163 @@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+EXEEXT=$(MATLABWRAPPEREXT)
+#Bin programs {{{1
+if MODULES
+bin_PROGRAMS =  AverageFilter\
+				BamgMesher\
+				BamgConvertMesh\
+				BamgTriangulate\
+				Chaco\
+				ContourToMesh \
+				ContourToNodes \
+				ElementConnectivity\
+				EnumToString\
+				Exp2Kml \
+				HoleFiller \
+				InternalFront\
+				InterpFromGridToMesh \
+				InterpFromMeshToMesh2d \
+				InterpFromMeshToMesh3d \
+				InterpFromMeshToGrid \
+				InterpFromMesh2d \
+				KMLFileRead \
+				KMLMeshWrite \
+				KMLOverlay \
+				Kml2Exp \
+				Kriging \
+				Ll2xy \
+				NodeConnectivity \
+				MeshPartition\
+				MeshProfileIntersection\
+				PointCloudFindNeighbors\
+				PropagateFlagsFromConnectivity\
+				Scotch\
+				Shp2Kml\
+				StringToEnum\
+				TriaSearch\
+				TriMesh\
+				TriMeshProcessRifts\
+				Xy2ll
+endif 
+#}}}
+#Flags and libraries {{{1
+LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+
+#Triangle library
+AM_CXXFLAGS =  -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER
+
+#Matlab part
+AM_LDFLAGS   = $(MEXLINK)
+AM_CXXFLAGS +=  -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread 
+LDADD       += $(MEXLIB) ../../c/libISSMMatlab.a 
+
+LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a 
+
+#Optimization flags:
+AM_CXXFLAGS += $(CXXOPTFLAGS) 
+#}}}
+#Bin sources {{{1
+AverageFilter_SOURCES = ../AverageFilter/AverageFilter.cpp\
+			  ../AverageFilter/AverageFilter.h
+
+BamgMesher_SOURCES = ../BamgMesher/BamgMesher.cpp\
+					../BamgMesher/BamgMesher.h
+
+BamgConvertMesh_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\
+					../BamgConvertMesh/BamgConvertMesh.h
+
+BamgTriangulate_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp\
+								  ../BamgTriangulate/BamgTriangulate.h
+
+Chaco_SOURCES = ../Chaco/Chaco.cpp\
+					../Chaco/Chaco.h
+
+ContourToMesh_SOURCES = ../ContourToMesh/ContourToMesh.cpp\
+			  ../ContourToMesh/ContourToMesh.h
+
+ContourToNodes_SOURCES = ../ContourToNodes/ContourToNodes.cpp\
+			  ../ContourToNodes/ContourToNodes.h
+
+ElementConnectivity_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
+			  ../ElementConnectivity/ElementConnectivity.h
+
+EnumToString_SOURCES = ../EnumToString/EnumToString.cpp\
+			  ../EnumToString/EnumToString.h
+
+StringToEnum_SOURCES = ../StringToEnum/StringToEnum.cpp\
+			  ../StringToEnum/StringToEnum.h
+
+HoleFiller_SOURCES = ../HoleFiller/HoleFiller.cpp\
+			  ../HoleFiller/HoleFiller.h
+
+InternalFront_SOURCES = ../InternalFront/InternalFront.cpp\
+										 ../InternalFront/InternalFront.h
+
+InterpFromGridToMesh_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\
+			  ../InterpFromGridToMesh/InterpFromGridToMesh.h
+
+InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
+
+InterpFromMeshToMesh3d_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\
+									../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
+
+InterpFromMeshToGrid_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\
+									../InterpFromMeshToGrid/InterpFromMeshToGrid.h
+
+InterpFromMesh2d_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp\
+									../InterpFromMesh2d/InterpFromMesh2d.h
+
+KMLFileRead_SOURCES = ../KMLFileRead/KMLFileRead.cpp\
+			  ../KMLFileRead/KMLFileRead.h
+
+KMLMeshWrite_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp\
+			  ../KMLMeshWrite/KMLMeshWrite.h
+
+KMLOverlay_SOURCES = ../KMLOverlay/KMLOverlay.cpp\
+			  ../KMLOverlay/KMLOverlay.h
+
+Xy2ll_SOURCES = ../Xy2ll/Xy2ll.cpp\
+			  ../Xy2ll/Xy2ll.h
+
+Ll2xy_SOURCES = ../Ll2xy/Ll2xy.cpp\
+			  ../Ll2xy/Ll2xy.h
+
+Exp2Kml_SOURCES = ../Exp2Kml/Exp2Kml.cpp\
+			  ../Exp2Kml/Exp2Kml.h
+
+Kml2Exp_SOURCES = ../Kml2Exp/Kml2Exp.cpp\
+			  ../Kml2Exp/Kml2Exp.h
+
+Kriging_SOURCES = ../Kriging/Kriging.cpp\
+						../Kriging/Kriging.h
+
+MeshPartition_SOURCES = ../MeshPartition/MeshPartition.cpp\
+			  ../MeshPartition/MeshPartition.h
+
+MeshProfileIntersection_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\
+			  ../MeshProfileIntersection/MeshProfileIntersection.h
+
+NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
+										../NodeConnectivity/NodeConnectivity.h
+
+PointCloudFindNeighbors_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp\
+			  ../PointCloudFindNeighbors/PointCloudFindNeighbors.h
+
+PropagateFlagsFromConnectivity_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\
+			  ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
+
+Scotch_SOURCES = ../Scotch/Scotch.cpp\
+			  ../Scotch/Scotch.h
+
+Shp2Kml_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
+			  ../Shp2Kml/Shp2Kml.h
+
+TriaSearch_SOURCES = ../TriaSearch/TriaSearch.cpp\
+			  ../TriaSearch/TriaSearch.h
+
+TriMesh_SOURCES = ../TriMesh/TriMesh.cpp\
+			  ../TriMesh/TriMesh.h
+
+TriMeshProcessRifts_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\
+			  ../TriMeshProcessRifts/TriMeshProcessRifts.h
+#}}}
Index: /issm/trunk/src/modules/python/Makefile.am
===================================================================
--- /issm/trunk/src/modules/python/Makefile.am	(revision 12331)
+++ /issm/trunk/src/modules/python/Makefile.am	(revision 12331)
@@ -0,0 +1,42 @@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+EXEEXT=$(PYTHONWRAPPEREXT)
+#Bin programs {{{1
+if MODULES
+bin_PROGRAMS = ElementConnectivity\
+			   InterpFromMeshToMesh2d \
+			   NodeConnectivity\
+			   TriMesh 
+endif 
+#}}}
+#Flags and libraries {{{1
+LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+
+#Triangle library
+AM_CXXFLAGS =  -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER
+
+#Python part
+AM_LDFLAGS   = $(PYTHONLINK)
+AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_ 
+if PYTHON3
+AM_CXXFLAGS +=  -DNPY_NO_DEPRECATED_API 
+endif
+LDADD       += $(BOOSTLIB) $(PYTHONLIB) ../../c/libISSMPython.a
+
+LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a 
+
+#Optimization flags:
+AM_CXXFLAGS += $(CXXOPTFLAGS) 
+#}}}
+#Bin sources {{{1
+ElementConnectivity_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
+			  ../ElementConnectivity/ElementConnectivity.h
+
+InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
+
+NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
+										../NodeConnectivity/NodeConnectivity.h
+
+TriMesh_SOURCES = ../TriMesh/TriMesh.cpp\
+			  ../TriMesh/TriMesh.h
+#}}}
Index: /issm/trunk/src/py/Makefile.am
===================================================================
--- /issm/trunk/src/py/Makefile.am	(revision 12331)
+++ /issm/trunk/src/py/Makefile.am	(revision 12331)
@@ -0,0 +1,1 @@
+SUBDIRS = model
Index: /issm/trunk/src/py/model/Makefile.am
===================================================================
--- /issm/trunk/src/py/model/Makefile.am	(revision 12331)
+++ /issm/trunk/src/py/model/Makefile.am	(revision 12331)
@@ -0,0 +1,11 @@
+bin_SCRIPTS = petscversion.py
+CLEANFILES = $(bin_SCRIPTS)
+
+if PYTHON3
+%.py : %.2.py
+	cp -f $< $@
+	2to3 -n -w  $@
+else
+%.py : %.2.py
+	ln -s -f $< $@
+endif
Index: sm/trunk/src/py/model/display/fielddisplay.rest
===================================================================
--- /issm/trunk/src/py/model/display/fielddisplay.rest	(revision 12330)
+++ 	(revision )
@@ -1,154 +1,0 @@
-def fielddisplay(md,name,comment):
-#FIELDDISPLAY - display model field
-#
-#   Usage:
-#      fielddisplay(md,offset,name,comment)
-
-	#get field
-	field=getattr(md,name)
-
-	#disp corresponding line as a function of field type (offset set as 9 spaces)
-	#parsedisplay('         ',name,field,comment);
-
-	return 
-
-function parsedisplay(offset,name,field,comment); %{{{
-
-	%string
-	if ischar(field),
-
-		if length(field)>30;
-			displayunit(offset,name,'not displayed',comment),
-		else
-			displayunit(offset,name,['''' field ''''],comment),
-		end
-
-	%numeric
-	elseif isnumeric(field)
-
-		%get size
-		fieldsize=size(field);
-
-		%double
-		if max(fieldsize)==1,
-			displayunit(offset,name,num2str(field),comment),
-		%matrix
-		else
-			displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
-		end
-
-	%logical
-	elseif islogical(field)
-
-		%get size
-		fieldsize=size(field);
-
-		%single value
-		if max(fieldsize)==1,
-			if (field)
-				displayunit(offset,name,'true',comment),
-			else
-				displayunit(offset,name,'false',comment),
-			end
-		%matrix
-		else
-			displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
-		end
-
-		%structure
-	elseif isstruct(field),
-		if ~isempty(fields(field))
-			displayunit(offset,name,'(structure)',comment),
-			struct_display(field,[offset '   ']),
-		else
-			displayunit(offset,name,'N/A',comment),
-		end
-
-	%cell
-	elseif iscell(field),
-		cell_display(offset,name,field,comment),
-
-	else
-		displayunit(offset,name,'not displayed',comment),
-
-	end
-end%}}}
-
-function struct_display(structure,offset) % {{{
-
-	structure_fields=fields(structure);
-
-	for i=1:length(structure_fields),
-
-		%get current field
-		field=structure.(structure_fields{i});
-
-		%recursive call if necessary
-		if isstruct(field),
-			displayunit(offset,structure_fields{i},'(structure)',''),
-			struct_display(field,[offset '   ']);
-
-		%display value
-		else
-			parsedisplay(offset,structure_fields{i},field,'');
-		end
-	end
-end% }}}
-function cell_display(offset,name,field,comment) % {{{
-
-	%initialization
-	string='{';
-
-	%go through the cell and fill string
-	if length(field)<5;
-		for i=1:length(field),
-			if ischar(field{i}),
-				string=[string ''''  field{i} ''','];
-			elseif (isnumeric(field{i}) & length(field{i})==1)
-				string=[string num2str(field{i}) ',' ];
-			else
-				string='{';
-				break
-			end
-		end
-	end
-	if strcmp(string,'{'),
-		string=['(' num2str(size(field,1)) 'x' num2str(size(field,2)) ')'];
-	else
-		string=[string(1:end-1) '}'];
-	end
-
-	%call displayunit
-	displayunit(offset,name,string,comment);
-end% }}}
-function displayunit(offset,name,characterization,comment),% {{{
-
-	%take care of name
-	if length(name)>23,
-		name=[name(1:20) '...'];
-	end
-
-	%take care of characterization
-	if (strcmp(characterization,['''' '''']) | strcmp(characterization,'NaN')),
-		characterization='N/A';
-	end
-	if length(characterization)>15,
-		characterization=[characterization(1:12) '...'];
-	end
-
-	%print
-	if isempty(comment)
-		disp(sprintf('%s%-23s: %-15s',offset,name,characterization));
-	else
-		if ischar(comment),
-			disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment));
-		elseif iscell(comment),
-			disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment{1}));
-			for i=2:length(comment),
-				disp(sprintf('%s%-23s  %-15s    %s',offset,'','',comment{i}));
-			end
-		else
-			error('fielddisplay error message: format for comment not supportet yet');
-		end
-	end
-end% }}}
Index: /issm/trunk/src/py/model/petscversion.2.py
===================================================================
--- /issm/trunk/src/py/model/petscversion.2.py	(revision 12331)
+++ /issm/trunk/src/py/model/petscversion.2.py	(revision 12331)
@@ -0,0 +1,39 @@
+#PETSCVERSION - recover petsc version number, inside config.h file
+#
+#   Usage:
+#       PETSC_VERSION=petscversion();
+
+#Module imports {{{
+import os
+import sys
+from issmtier import *
+#}}}
+
+def petscversion():
+
+	#default
+	PETSC_VERSION=3;
+	
+	configfile=issmtier() + "/bin/config.h" #should find it in the install target
+	
+	if not os.path.isfile(configfile):
+		raise RuntimeError("%s%s%s"%("File ",configfile," not found. ISSM has not been configured yet!"))
+
+	#go through the file, and recover the line we want
+	fid=open(configfile,'r');
+
+	tline=fid.readline()
+	while tline:
+
+		if tline=='': 
+			break
+		
+		if tline[0:21]=="#define _PETSC_MAJOR_":
+			PETSC_VERSION=int(tline[22])
+			break
+		
+		tline=fid.readline()
+	
+	fid.close();
+
+	return PETSC_VERSION
Index: sm/trunk/src/py/model/petscversion.py
===================================================================
--- /issm/trunk/src/py/model/petscversion.py	(revision 12330)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#PETSCVERSION - recover petsc version number, inside config.h file
-#
-#   Usage:
-#       PETSC_VERSION=petscversion();
-
-#Module imports {{{
-import os
-import sys
-from issmtier import *
-#}}}
-
-def petscversion():
-
-	#default
-	PETSC_VERSION=3;
-	
-	configfile=issmtier() + "/bin/config.h" #should find it in the install target
-	
-	if not os.path.isfile(configfile):
-		raise RuntimeError("%s%s%s"%("File ",configfile," not found. ISSM has not been configured yet!"))
-
-	#go through the file, and recover the line we want
-	fid=open(configfile,'r');
-
-	tline=fid.readline()
-	while tline:
-
-		if tline=='': 
-			break
-		
-		if tline[0:21]=="#define _PETSC_MAJOR_":
-			PETSC_VERSION=int(tline[22])
-			break
-		
-		tline=fid.readline()
-	
-	fid.close();
-
-	return PETSC_VERSION
