Index: /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp
===================================================================
--- /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp	(revision 8714)
+++ /issm/trunk/src/mex/Exp2Kml/Exp2Kml.cpp	(revision 8714)
@@ -0,0 +1,115 @@
+/*\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: */
+	if (verbose) printf("Fetching inputs:\n");
+	FetchData(&filexp,EXP_IN);
+	if (verbose) printf("  filexp=\"%s\"\n",filexp);
+	FetchData(&filkml,KML_IN);
+	if (verbose) printf("  filkml=\"%s\"\n",filkml);
+	FetchData(&sgn,SGN_IN);
+	if (verbose) printf("  sgn=%d\n",sgn);
+
+	if (verbose) printf("Parsing options:\n");
+	options=new Options(NRHS,nrhs,prhs);
+	if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
+	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 (verbose) printf("Checking inputs:\n");
+
+	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 (verbose) printf("Calling core:\n");
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Exp2Kmlx(filexp,filkml,
+					  sgn,cm,sp,
+					  holes);
+	else
+		iret=Exp2Kmlx(filexp,filkml,
+					  sgn,
+					  holes);
+	if (verbose) printf("  iret=%d\n",iret);
+
+	/*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,"      [lat,lon]=Exp2Kml(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]=Exp2Kml(x,y, 1);\n");
+	_printf_(true,"      [lat,lon]=Exp2Kml(x,y, 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [lat,lon]=Exp2Kml(x,y,-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/mex/Exp2Kml/Exp2Kml.h
===================================================================
--- /issm/trunk/src/mex/Exp2Kml/Exp2Kml.h	(revision 8714)
+++ /issm/trunk/src/mex/Exp2Kml/Exp2Kml.h	(revision 8714)
@@ -0,0 +1,34 @@
+/*!\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/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.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/mex/Makefile.am
===================================================================
--- /issm/trunk/src/mex/Makefile.am	(revision 8713)
+++ /issm/trunk/src/mex/Makefile.am	(revision 8714)
@@ -46,4 +46,5 @@
 				Xy2ll \
 				Ll2xy \
+				Exp2Kml \
 				Mergesolutionfromftog\
 				MeshPartition\
@@ -236,4 +237,7 @@
 			  Ll2xy/Ll2xy.h
 
+Exp2Kml_SOURCES = Exp2Kml/Exp2Kml.cpp\
+			  Exp2Kml/Exp2Kml.h
+
 AverageFilter_SOURCES = AverageFilter/AverageFilter.cpp\
 			  AverageFilter/AverageFilter.h
