Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 10238)
+++ /issm/trunk/src/c/Makefile.am	(revision 10239)
@@ -534,8 +534,10 @@
 					./modules/Ll2xyx/Ll2xyx.h\
 					./modules/Ll2xyx/Ll2xyx.cpp\
+					./modules/Exp2Kmlx/Exp2Kmlx.h\
 					./modules/Exp2Kmlx/Exp2Kmlx.cpp\
-					./modules/Exp2Kmlx/Exp2Kmlx.cpp\
+					./modules/Kml2Expx/Kml2Expx.h\
 					./modules/Kml2Expx/Kml2Expx.cpp\
-					./modules/Kml2Expx/Kml2Expx.cpp\
+					./modules/Shp2Kmlx/Shp2Kmlx.h\
+					./modules/Shp2Kmlx/Shp2Kmlx.cpp\
 					./modules/InputDuplicatex/InputDuplicatex.h\
 					./modules/InputDuplicatex/InputDuplicatex.cpp\
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 10238)
+++ /issm/trunk/src/c/modules/modules.h	(revision 10239)
@@ -59,4 +59,5 @@
 #include "./Exp2Kmlx/Exp2Kmlx.h"
 #include "./Kml2Expx/Kml2Expx.h"
+#include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./MassFluxx/MassFluxx.h"
 #include "./MaxAbsVxx/MaxAbsVxx.h"
Index: /issm/trunk/src/mex/Shp2Kml/Shp2Kml.cpp
===================================================================
--- /issm/trunk/src/mex/Shp2Kml/Shp2Kml.cpp	(revision 10238)
+++ /issm/trunk/src/mex/Shp2Kml/Shp2Kml.cpp	(revision 10239)
@@ -1,16 +1,33 @@
 /*\file Shp2Kml.c
- *\brief: build degrees of freedom for every node.
+ *\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[]){
 
-	/*input datasets: */
-	Nodes* nodes=NULL;
-	Parameters* parameters=NULL;
-	Constraints* constraints=NULL;
-	int      analysis_type;
+	int i,verbose=1;
+
+	/*input: */
+	char    *filshp=NULL,*filkml=NULL;
+	int     sgn;
+
+	Options* options=NULL;
+	char     *choles=NULL;
+	bool     holes=false;
+	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: */
@@ -18,22 +35,63 @@
 
 	/*checks on arguments on the matlab side: */
-	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&Shp2KmlUsage);
+	if (nlhs > NLHS) {
+		Shp2KmlUsage();
+		_error_("Shp2Kml usage error");
+	}
+	if (nrhs < NRHS) {
+		Shp2KmlUsage();
+		_error_("Shp2Kml usage error");
+	}
 
 	/*Input datasets: */
-	FetchMatlabData((DataSet**)&nodes,NODESIN);
-	FetchMatlabData((DataSet**)&constraints,CONSTRAINTS);
-	FetchMatlabData(&parameters,PARAMETERS);
-	FetchMatlabData(&analysis_type,ANALYSISTYPE);
-	
-	/*!Generate internal degree of freedom numbers: */
-	SpcNodesx(nodes,constraints,parameters,analysis_type); 
+	if (verbose) printf("Fetching inputs:\n");
+	FetchMatlabData(&filshp,SHP_IN);
+	if (verbose) printf("  filshp=\"%s\"\n",filshp);
+	FetchMatlabData(&filkml,KML_IN);
+	if (verbose) printf("  filkml=\"%s\"\n",filkml);
+	FetchMatlabData(&sgn,SGN_IN);
+	if (verbose) printf("  sgn=%d\n",sgn);
 
-	/*write output datasets: */
-	WriteMatlabData(NODES,nodes);
+	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);
+	}
 
-	/*Free ressources: */
-	delete nodes;
-	delete constraints;
-	delete parameters;
+	/*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=Shp2Kmlx(filshp,filkml,
+					  sgn,cm,sp,
+					  holes);
+	else
+		iret=Shp2Kmlx(filshp,filkml,
+					  sgn,
+					  holes);
+	if (verbose) printf("  iret=%d\n",iret);
+
+	/*Write data: */
+	WriteMatlabData(RET_OUT,iret);
+
+	/*Clean-up*/
+	xfree((void**)&choles);
+	delete options;
+	xfree((void**)&filkml);
+	xfree((void**)&filshp);
 
 	/*end module: */
@@ -43,6 +101,26 @@
 void Shp2KmlUsage(void)
 {
+	_printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
 	_printf_(true,"\n");
-	_printf_(true,"   usage: [m.node]=%s(m.nodes,m.constraints,m.parameters);\n",__FUNCT__);
+	_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)\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]=Shp2Kml('file.shp','file.kml', 1);\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
 	_printf_(true,"\n");
 }
+
Index: /issm/trunk/src/mex/Shp2Kml/Shp2Kml.h
===================================================================
--- /issm/trunk/src/mex/Shp2Kml/Shp2Kml.h	(revision 10238)
+++ /issm/trunk/src/mex/Shp2Kml/Shp2Kml.h	(revision 10239)
@@ -1,7 +1,5 @@
-
-/*
-	Shp2Kml.h
-*/
-
+/*!\file Shp2Kml.h
+ * \brief: prototype for shp to kml file conversion mex module.
+ */
 
 #ifndef _SHP2KML_H
@@ -18,20 +16,19 @@
 #define __FUNCT__  "Shp2Kml"
 
+
 /* serial input macros: */
-#define NODESIN (mxArray*)prhs[0]
-#define CONSTRAINTS (mxArray*)prhs[1]
-#define PARAMETERS (mxArray*)prhs[2]
-#define ANALYSISTYPE (mxArray*)prhs[3]
+#define SHP_IN    prhs[0]
+#define KML_IN    prhs[1]
+#define SGN_IN    prhs[2]
 
 /* serial output macros: */
-#define NODES (mxArray**)&plhs[0]
+#define RET_OUT    (mxArray**)&plhs[0]
 
 /* serial arg counts: */
+#undef NRHS
+#define NRHS  3
 #undef NLHS
 #define NLHS  1
-#undef NRHS
-#define NRHS  4
 
+#endif
 
-#endif  /* _SHP2KML_H */
-
