Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 14278)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 14279)
@@ -627,4 +627,6 @@
 			     ./modules/Kml2Expx/Kml2Expx.h\
 			     ./modules/Kml2Expx/Kml2Expx.cpp\
+			     ./modules/Shp2Expx/Shp2Expx.h\
+			     ./modules/Shp2Expx/Shp2Expx.cpp\
 			     ./modules/Shp2Kmlx/Shp2Kmlx.h\
 			     ./modules/Shp2Kmlx/Shp2Kmlx.cpp\
Index: /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp	(revision 14279)
+++ /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp	(revision 14279)
@@ -0,0 +1,553 @@
+/*!\file Shp2Expx
+ * \brief shp to exp conversion routines.
+ */
+
+#include "./Shp2Expx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../modules.h"
+
+int Shp2Expx(char* filshp,char* filexp,
+			 int sgn){
+
+	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+	double  cm,sp;
+
+	if (sgn)
+		Xy2lldef(&cm,&sp,sgn);
+
+	return(Shp2Expx(filshp,filexp,
+					sgn,cm,sp));
+
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
+}
+
+int Shp2Expx(char* filshp,char* filexp,
+			 int sgn,double cm,double sp){
+
+	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+	int     i,j,k,iret=0;
+	int     lwidth=1;
+	double  popac=0.50;
+	int     nshape,ncoord;
+	double  cpsum;
+	int     *pstype = NULL, *pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
+	double **pshapx = NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
+	double  *lat    = NULL, *lon=NULL;
+
+	SHPHandle   hSHP;
+	int     nShapeType, nEntities, iPart, bValidate = 0,nInvalidCount=0;
+	const char  *pszPlus;
+	double  adfMinBound[4], adfMaxBound[4];
+
+	char    indent[81]="";
+	KML_Folder        *kfold  = NULL;
+	KML_Placemark     *kplace = NULL;
+	KML_MultiGeometry *kmulti = NULL;
+	KML_Polygon       *kpoly  = NULL;
+	KML_LinearRing    *kring  = NULL;
+	KML_LineString    *kline  = NULL;
+	KML_Point         *kpoint = NULL;
+	FILE              *fid    = NULL;
+
+	clock_t clock0,clock1;
+	time_t  time0, time1;
+
+	clock0=clock();
+	time0 =time(NULL);
+	_pprintString_("\nShp2Expx Module -- " << ctime(&time0));
+
+/*  note that much of the following code is taken from shpdump.c in shapelib.  */
+
+/*  open shp/shx files  */
+
+	hSHP = SHPOpen( filshp, "rb" );
+	if (!hSHP) _error_("Error opening shp/shx files.");
+
+/*  read header and print out file bounds  */
+
+	SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
+
+	printf( "Shapefile Type: %s   # of Shapes: %d\n\n",
+			SHPTypeName( nShapeType ), nEntities );
+
+	printf( "File Bounds: (%12.3f,%12.3f,%g,%g)\n"
+			"         to  (%12.3f,%12.3f,%g,%g)\n",
+			adfMinBound[0],
+			adfMinBound[1],
+			adfMinBound[2],
+			adfMinBound[3],
+			adfMaxBound[0],
+			adfMaxBound[1],
+			adfMaxBound[2],
+			adfMaxBound[3] );
+
+	nshape=nEntities;
+	pstype=xNew<int>(nshape);
+	pnpart=xNew<int>(nshape);
+	ppstrt=xNew<int*>(nshape);
+	pptype=xNew<int*>(nshape);
+	pnvert=xNew<int>(nshape);
+	pshapx=xNew<double*>(nshape);
+	pshapy=xNew<double*>(nshape);
+	pshapz=xNew<double*>(nshape);
+	pshapm=xNew<double*>(nshape);
+
+/*  loop over the list of shapes  */
+
+	for( i = 0; i < nEntities; i++ )
+	{
+//	int     j;
+		SHPObject   *psShape;
+
+	psShape = SHPReadObject( hSHP, i );
+
+	printf( "\nShape:%d (%s)  nVertices=%d, nParts=%d\n"
+				"  Bounds:(%12.3f,%12.3f, %g, %g)\n"
+				"      to (%12.3f,%12.3f, %g, %g)\n",
+			i, SHPTypeName(psShape->nSHPType),
+				psShape->nVertices, psShape->nParts,
+				psShape->dfXMin, psShape->dfYMin,
+				psShape->dfZMin, psShape->dfMMin,
+				psShape->dfXMax, psShape->dfYMax,
+				psShape->dfZMax, psShape->dfMMax );
+
+	pstype[i]=psShape->nSHPType;
+	pnpart[i]=psShape->nParts;
+	if (pnpart[i]) {
+		ppstrt[i]=xNew<int>(pnpart[i]);
+		pptype[i]=xNew<int>(pnpart[i]);
+	}
+	else {
+		ppstrt[i]=NULL;
+		pptype[i]=NULL;
+	}
+	pnvert[i]=psShape->nVertices;
+	if (pnvert[i]) {
+		pshapx[i]=xNew<double>(pnvert[i]);
+		pshapy[i]=xNew<double>(pnvert[i]);
+		pshapz[i]=xNew<double>(pnvert[i]);
+		pshapm[i]=xNew<double>(pnvert[i]);
+	}
+	else {
+		pshapx[i]=NULL;
+		pshapy[i]=NULL;
+		pshapz[i]=NULL;
+		pshapm[i]=NULL;
+	}
+
+	for( j = 0, iPart = 1; j < psShape->nVertices; j++ )
+	{
+			const char  *pszPartType = "";
+
+			if( j == 0 && psShape->nParts > 0 )
+			{
+				pszPartType = SHPPartTypeName( psShape->panPartType[0] );
+				ppstrt[i][0]=psShape->panPartStart[0];
+				pptype[i][0]=psShape->panPartType[0];
+			}
+
+		if( iPart < psShape->nParts
+				&& psShape->panPartStart[iPart] == j )
+		{
+				pszPartType = SHPPartTypeName( psShape->panPartType[iPart] );
+				ppstrt[i][iPart]=psShape->panPartStart[iPart];
+				pptype[i][iPart]=psShape->panPartType[iPart];
+		iPart++;
+		pszPlus = "+";
+		}
+		else
+			pszPlus = " ";
+
+//		printf("   %s (%12.3f,%12.3f, %g, %g) %s \n",
+//				   pszPlus,
+//				   psShape->padfX[j],
+//				   psShape->padfY[j],
+//				   psShape->padfZ[j],
+//				   psShape->padfM[j],
+//				   pszPartType );
+
+		pshapx[i][j]=psShape->padfX[j];
+		pshapy[i][j]=psShape->padfY[j];
+		pshapz[i][j]=psShape->padfZ[j];
+		pshapm[i][j]=psShape->padfM[j];
+	}
+
+		if( bValidate )
+		{
+			int nAltered = SHPRewindObject( hSHP, psShape );
+
+			if( nAltered > 0 )
+			{
+				printf( "  %d rings wound in the wrong direction.\n",
+						nAltered );
+				nInvalidCount++;
+			}
+		}
+
+		SHPDestroyObject( psShape );
+	}
+
+/*  close shp/shx files  */
+
+	SHPClose( hSHP );
+
+/*  construct kml folder for shapes  */
+
+	kfold =new KML_Folder();
+	sprintf(kfold->name      ,"Shapefile: %s  Type: %s  nShapes: %d",
+			filshp, SHPTypeName( nShapeType ), nEntities );
+	kfold->open      =1;
+
+/*  loop over the list of shapes  */
+
+	for (i=0; i<nshape; i++) {
+
+/*  null type  */
+
+		if      (pstype[i] == SHPT_NULL) {
+			;
+		}
+
+/*  point types  */
+
+		else if (pstype[i] == SHPT_POINT ||
+			  	 pstype[i] == SHPT_POINTZ ||
+			 	 pstype[i] == SHPT_POINTM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+			if (pnpart[i] > 0)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 0 parts.\n",
+						 i,SHPTypeName( pstype[i] ),pnpart[i]);
+			if (pnvert[i] > 1)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 1 vertices.\n",
+						 i,SHPTypeName( pstype[i] ),pnvert[i]);
+
+			kpoint=new KML_Point();
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+			kpoint->coords[0]=lon      [0];
+			kpoint->coords[1]=lat      [0];
+			kpoint->coords[2]=pshapz[i][0];
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kpoint);
+			kpoint=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  polyline types  */
+
+		else if (pstype[i] == SHPT_ARC ||
+				 pstype[i] == SHPT_ARCZ ||
+				 pstype[i] == SHPT_ARCM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+/*  create a multigeometry to hold all the lines  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the lines  */
+
+			for (j=0; j<pnpart[i]; j++) {
+				kline =new KML_LineString();
+
+				kline->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+				kline->coords    =xNew<double>(kline->ncoord*3);
+				for (k=0; k<kline->ncoord; k++) {
+					kline->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+					kline->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+					kline->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+				}
+				(kmulti->geometry  )->AddObject((Object*)kline);
+				kline = NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry)->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  polygon types  */
+
+		else if (pstype[i] == SHPT_POLYGON ||
+				 pstype[i] == SHPT_POLYGONZ ||
+				 pstype[i] == SHPT_POLYGONM) {
+
+/*  the shp format specifies that outer rings are cw, while inner rings are ccw.  there
+	may be multiple outer rings and inner rings in any order.  the kml format specifies
+	all rings are ccw (right-hand rule).  there may be only one outer ring with multiple
+	inner rings, and rings are differentiated by keyword.
+
+	at least for now, assume that each cw ring forms a new kml polygon, and each ccw
+	ring forms an inner ring for the most recent outer ring.  a more elaborate solution
+	would be for each inner ring to search in which outer ring it occurs.  */
+
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#BlackLineRandomPoly");
+
+/*  create a multigeometry to hold all the polygons  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the polygons  */
+
+			for (j=0; j<pnpart[i]; j++) {
+
+/*  check if polygon is ccw or cw by computing sum of cross products (twice the area)  */
+
+				ncoord=(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+				cpsum =0.;
+
+				for (k=ppstrt[i][j]; k<ppstrt[i][j]+ncoord-1; k++)
+					cpsum +=pshapx[i][k]*pshapy[i][k+1         ]-pshapy[i][k]*pshapx[i][k+1         ];
+				cpsum +=pshapx[i][k]*pshapy[i][ppstrt[i][j]]-pshapy[i][k]*pshapx[i][ppstrt[i][j]];
+
+/*  outer ring (cw) (allow exception for single-part shapes)  */
+
+				if (cpsum < 0 || pnpart[i] == 1) {
+					if (kpoly) {
+						(kmulti->geometry  )->AddObject((Object*)kpoly);
+						kpoly =NULL;
+					}
+
+/*  create a new polygon from the outer ring (reversing cw to ccw)  */
+
+					kpoly =new KML_Polygon();
+					kring =new KML_LinearRing();
+
+					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+					kring->coords    =xNew<double>(kring->ncoord*3);
+					if (cpsum < 0)
+						for (k=0; k<kring->ncoord; k++) {
+							kring->coords[3*(kring->ncoord-1-k)+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+2]=pshapz[i][ppstrt[i][j]+k];
+						}
+					else
+						for (k=0; k<kring->ncoord; k++) {
+							kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+						}
+
+					(kpoly ->outer     )->AddObject((Object*)kring);
+					kring =NULL;
+				}
+
+/*  inner ring (ccw)  */
+
+				else {
+					if (!kpoly) {
+						_printf_(true,"Warning -- Shape %d of type \"%s\", part %d, expected to be outer loop (cw).\n",
+								 i,SHPTypeName( pstype[i] ),j);
+						continue;
+					}
+
+/*  add the inner ring to the current polygon  */
+
+					kring =new KML_LinearRing();
+
+					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+					kring->coords    =xNew<double>(kring->ncoord*3);
+					for (k=0; k<kring->ncoord; k++) {
+						kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+						kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+						kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+					}
+
+					(kpoly ->inner     )->AddObject((Object*)kring);
+					kring =NULL;
+				}
+			}
+
+			if (kpoly) {
+				(kmulti->geometry  )->AddObject((Object*)kpoly);
+				kpoly =NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  multipoint types  */
+
+		else if (pstype[i] == SHPT_MULTIPOINT ||
+				 pstype[i] == SHPT_MULTIPOINTZ ||
+				 pstype[i] == SHPT_MULTIPOINTM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+			if (pnpart[i] > 0)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 0 parts.\n",
+						 i,SHPTypeName( pstype[i] ),pnpart[i]);
+
+/*  create a multigeometry to hold all the points  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the points  */
+
+			for (j=0; j<pnvert[i]; j++) {
+				kpoint=new KML_Point();
+
+				kpoint->coords[0]=lon      [j];
+				kpoint->coords[1]=lat      [j];
+				kpoint->coords[2]=pshapz[i][j];
+
+				(kmulti->geometry  )->AddObject((Object*)kpoint);
+				kpoint=NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  multipatch types  */
+
+		else if (pstype[i] == SHPT_MULTIPATCH) {
+			_printf_(true,"Warning -- Shape %d of type \"%s\" will be ignored.\n",
+					 i,SHPTypeName( pstype[i] ));
+			continue;
+		}
+
+/*  unknown type  */
+
+		else {
+			_printf_(true,"Warning -- Shape %d of type \"%s\" will be ignored.\n",
+					 i,SHPTypeName( pstype[i] ));
+		}
+	}
+
+/*  open exp file  */
+
+    _pprintLine_("Writing exp profiles to file.");
+    fid=fopen(filexp,"w");
+
+/*  write the polygons and linestrings  */
+
+    kfold->WriteExp(fid,"",sgn,cm,sp);
+
+/*  close exp file  */
+
+    fclose(fid);
+
+	delete kfold;
+	for (i=nshape-1; i>=0; i--) {
+		xDelete<double>((pshapm[i]));
+		xDelete<double>((pshapz[i]));
+		xDelete<double>((pshapy[i]));
+		xDelete<double>((pshapx[i]));
+	}
+	xDelete<double*>(pshapm);
+	xDelete<double*>(pshapz);
+	xDelete<double*>(pshapy);
+	xDelete<double*>(pshapx);
+	xDelete<int>(pnvert);
+	for (i=nshape-1; i>=0; i--) {
+		xDelete<int>((pptype[i]));
+		xDelete<int>((ppstrt[i]));
+	}
+	xDelete<int*>(pptype);
+	xDelete<int*>(ppstrt);
+	xDelete<int>(pnpart);
+	xDelete<int>(pstype);
+
+	clock1=clock();
+	time1 =time(NULL);
+	_printf_(true,"Shp2Expx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
+			 ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
+
+	return(iret);
+
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
+}
Index: /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.h	(revision 14279)
+++ /issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.h	(revision 14279)
@@ -0,0 +1,27 @@
+/*!\file:  Shp2Expx.h
+ * \brief header file for shp to exp conversion routines.
+ */ 
+
+#ifndef _SHP2EXPX_H
+#define _SHP2EXPX_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+#include "shapefil.h"
+
+#endif
+
+#include "../../Container/Container.h"
+#include "../../classes/objects/objects.h"
+
+/* local prototypes: */
+int Shp2Expx(char* filshp,char* filexp, int sgn);
+int Shp2Expx(char* filshp,char* filexp, int sgn,double cm,double sp);
+
+#endif  /* _SHP2EXPX_H */
Index: /issm/trunk-jpl/src/c/modules/modules.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/modules.h	(revision 14278)
+++ /issm/trunk-jpl/src/c/modules/modules.h	(revision 14279)
@@ -60,5 +60,4 @@
 #include "./Kml2Expx/Kml2Expx.h"
 #include "./Krigingx/Krigingx.h"
-#include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
 #include "./MeshPartitionx/MeshPartitionx.h"
@@ -87,4 +86,6 @@
 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
 #include "./Scotchx/Scotchx.h"
+#include "./Shp2Expx/Shp2Expx.h"
+#include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./SmbGradientsx/SmbGradientsx.h"
 #include "./Solverx/Solverx.h"
Index: /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.cpp	(revision 14279)
+++ /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.cpp	(revision 14279)
@@ -0,0 +1,99 @@
+/*\file Shp2Exp.c
+ *\brief: shp to exp 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 "./Shp2Exp.h"
+
+void Shp2ExpUsage(void){/*{{{*/
+	_pprintLine_("Shp2Exp - shp to exp file conversion module:");
+	_pprintLine_("");
+	_pprintLine_("   This module converts a file from shp to exp format.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ret]=Shp2Exp(filshp,filexp,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      filshp      file name of shp file to be read (char, extension optional)");
+	_pprintLine_("      filexp      file name of exp file to be written (char)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("");
+	_pprintLine_("      ret         return code (non-zero for warning)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ret]=Shp2Exp('file.shp','file.exp', 0);");
+	_pprintLine_("      [ret]=Shp2Exp('file.shp','file.exp', 1,'central_meridian',45,'standard_parallel',70);");
+	_pprintLine_("      [ret]=Shp2Exp('file.shp','file.exp',-1,'central_meridian', 0,'standard_parallel',71);");
+	_pprintLine_("");
+}/*}}}*/
+WRAPPER(Shp2Exp){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filshp=NULL,*filexp=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) {
+		Shp2ExpUsage(); _error_("Shp2Exp usage error");
+	}
+	if (nrhs < NRHS) {
+		Shp2ExpUsage(); _error_("Shp2Exp usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filshp,SHP_IN);
+	FetchData(&filexp,EXP_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) _printLine_("  cm=" << cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) _printLine_("  sp=" << sp);
+	}
+
+	/*some checks*/
+	if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=" << sgn << " must be +1 (north), -1 (south), or 0 (no translation).");
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Shp2Expx(filshp,filexp,sgn,cm,sp);
+	else
+		iret=Shp2Expx(filshp,filexp,sgn);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	delete options;
+	xDelete<char>(filexp);
+	xDelete<char>(filshp);
+
+	/*end module: */
+	MODULEEND();
+}
Index: /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.h	(revision 14279)
+++ /issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.h	(revision 14279)
@@ -0,0 +1,53 @@
+/*!\file Shp2Exp.h
+ * \brief: prototype for shp to exp file conversion mex module.
+ */
+
+#ifndef _SHP2EXP_H
+#define _SHP2EXP_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+	#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*For python modules: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../bindings.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Shp2Exp"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define SHP_IN  prhs[0]
+#define EXP_IN  prhs[1]
+#define SGN_IN  prhs[2]
+/* serial output macros: */
+#define RET_OUT (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define SHP_IN PyTuple_GetItem(args,0)
+#define EXP_IN PyTuple_GetItem(args,1)
+#define SGN_IN PyTuple_GetItem(args,2)
+/* serial output macros: */
+#define RET_OUT output,0
+#endif
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/trunk-jpl/src/wrappers/matlab/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 14278)
+++ /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 14279)
@@ -76,7 +76,8 @@
 				   KMLMeshWrite.la\
 				   KMLOverlay.la\
-				   Shp2Kml.la\
 				   Exp2Kml.la\
-				   Kml2Exp.la
+				   Kml2Exp.la\
+				   Shp2Exp.la\
+				   Shp2Kml.la
 endif
 endif 
@@ -246,4 +247,8 @@
 Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB)
 
+Shp2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\
+							../Shp2Exp/Shp2Exp.h
+Shp2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB)
+
 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
 							../Shp2Kml/Shp2Kml.h
