Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 8672)
+++ /issm/trunk/src/c/Makefile.am	(revision 8673)
@@ -534,4 +534,8 @@
 					./modules/KMLOverlayx/KMLOverlayx.h\
 					./modules/KMLOverlayx/KMLOverlayx.cpp\
+					./modules/Xy2llx/Xy2llx.h\
+					./modules/Xy2llx/Xy2llx.cpp\
+					./modules/Ll2xyx/Ll2xyx.h\
+					./modules/Ll2xyx/Ll2xyx.cpp\
 					./modules/InputDuplicatex/InputDuplicatex.h\
 					./modules/InputDuplicatex/InputDuplicatex.cpp\
@@ -1206,4 +1210,8 @@
 					./modules/KMLOverlayx/KMLOverlayx.h\
 					./modules/KMLOverlayx/KMLOverlayx.cpp\
+					./modules/Xy2llx/Xy2llx.h\
+					./modules/Xy2llx/Xy2llx.cpp\
+					./modules/Ll2xyx/Ll2xyx.h\
+					./modules/Ll2xyx/Ll2xyx.cpp\
 					./modules/InputDuplicatex/InputDuplicatex.h\
 					./modules/InputDuplicatex/InputDuplicatex.cpp\
Index: /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp	(revision 8673)
+++ /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp	(revision 8673)
@@ -0,0 +1,122 @@
+/*!\file Ll2xyx.cpp
+ */
+
+#include "./Ll2xyx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+int Ll2xyx(double* x, double* y,
+		   double* lat, double* lon, int ncoord,
+		   int sgn){
+
+/*  This is a cpp conversion of the following:
+%LL2XY - converts lat long to polar stereographic
+%
+%   Converts from geodetic latitude and longitude to Polar 
+%   Stereographic (X,Y) coordinates for the polar regions.
+%   Author: Michael P. Schodlok, December 2003 (map2ll)
+%
+%   Usage:
+%      [x,y] = ll2xy(lat,lon,sgn)
+%      [x,y] = ll2xy(lat,lon,sgn,central_meridian,standard_parallel)
+%
+%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
+%                               -1 : south latitude (default is mer=0  lat=71)
+*/
+
+	double  delta,slat;
+	bool    flag=false;
+
+	/*  Get central_meridian and standard_parallel depending on hemisphere  */
+	if      (sgn ==  1) {
+		delta = 45;
+		slat = 70;
+		_printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45)");
+	}
+	else if (sgn == -1) {
+		delta = 0;
+		slat = 71;
+		_printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0)");
+	}
+	else
+		_error_("Sign should be either +1 or -1");
+
+	return(Ll2xyx(lat,lon,
+				  x,y,ncoord,
+				  sgn,delta,slat));
+}
+
+int Ll2xyx(double* x, double* y,
+		   double* lat, double* lon, int ncoord,
+		   int sgn, double central_meridian, double standard_parallel){
+
+/*  This is a cpp conversion of the following:
+%LL2XY - converts lat long to polar stereographic
+%
+%   Converts from geodetic latitude and longitude to Polar 
+%   Stereographic (X,Y) coordinates for the polar regions.
+%   Author: Michael P. Schodlok, December 2003 (map2ll)
+%
+%   Usage:
+%      [x,y] = ll2xy(lat,lon,sgn)
+%      [x,y] = ll2xy(lat,lon,sgn,central_meridian,standard_parallel)
+%
+%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
+%                               -1 : south latitude (default is mer=0  lat=71)
+*/
+
+	int     i;
+	double  delta,slat;
+	double  cde,re,ex2,ex,pi;
+	double  latitude,longitude;
+	double  T,rho,sl,tc,mc;
+
+	if      ((sgn !=  1) && (sgn != -1))
+		_error_("Sign should be either +1 or -1");
+
+	delta = central_meridian;
+	slat  = standard_parallel;
+
+	/*  Conversion constant from degrees to radians  */
+	cde  = 57.29577951;
+	/*  Radius of the earth in meters  */
+	re   = 6378.273*pow(10.,3.);
+	/*  Eccentricity of the Hughes ellipsoid squared  */
+	ex2   = .006693883;
+	/*  Eccentricity of the Hughes ellipsoid  */
+	ex    =  sqrt(ex2);
+	/*  pi is not defined in cpp  */
+	pi   = 4.*atan(1.);
+
+	/*  loop over all the coordinate pairs  */
+
+	for (i=0; i<ncoord; i++) {
+		latitude  = fabs(lat[i]) * pi/180.;
+		longitude = (lon[i] + delta) * pi/180.;
+
+		/*  compute X and Y in grid coordinates.  */
+		T = tan(pi/4.-latitude/2.) / pow(((1.-ex*sin(latitude))/(1.+ex*sin(latitude))),(ex/2.));
+
+		if ((90. - slat) <  1.e-5)
+			rho = 2.*re*T/sqrt(pow((1.+ex),(1.+ex))*pow((1.-ex),(1.-ex)));
+		else {
+			sl  = slat*pi/180.;
+			tc  = tan(pi/4.-sl/2.)/pow(((1.-ex*sin(sl))/(1.+ex*sin(sl))),(ex/2.));
+			mc  = cos(sl)/sqrt(1.0-ex2*(pow(sin(sl),2.)));
+			rho = re*mc*T/tc;
+		}
+
+		y[i] = -rho * sgn * cos(sgn*longitude);
+		x[i] =  rho * sgn * sin(sgn*longitude);
+
+		if (latitude >= pi / 2.) {
+			x[i] = 0.0;
+			y[i] = 0.0;
+		}
+	}
+
+	return(0);
+}
+
Index: /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.h
===================================================================
--- /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.h	(revision 8673)
+++ /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.h	(revision 8673)
@@ -0,0 +1,18 @@
+/*!\file:  Ll2xyx.h
+ * \brief header file for lat/long to x/y coordinate functions.
+ */ 
+
+#ifndef _LL2XYX_H
+#define _LL2XYX_H
+
+/* local prototypes: */
+int Ll2xyx(double* x, double* y,
+		   double* lat, double* lon, int ncoord,
+		   int sgn);
+
+int Ll2xyx(double* x, double* y,
+		   double* lat, double* lon, int ncoord,
+		   int sgn, double central_meridian, double standard_parallel);
+
+#endif  /* _LL2XYX_H */
+
Index: /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp	(revision 8673)
+++ /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp	(revision 8673)
@@ -0,0 +1,128 @@
+/*!\file Xy2llx.cpp
+ */
+
+#include "./Xy2llx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+int Xy2llx(double* lat, double* lon,
+		   double* x, double* y, int ncoord,
+		   int sgn){
+
+/*  This is a cpp conversion of the following:
+%XY2LL - converts xy to lat long
+%
+%   Converts Polar  Stereographic (X,Y) coordinates for the polar regions to
+%   latitude and longitude Stereographic (X,Y) coordinates for the polar
+%   regions.
+%   Author: Michael P. Schodlok, December 2003 (map2xy.m)
+%
+%   Usage:
+%      [lat,lon] = xy2ll(x,y,sgn);
+%      [lat,lon] = xy2ll(x,y,sgn,central_meridian,standard_parallel);
+%
+%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
+%                               -1 : south latitude (default is mer=0  lat=71)
+*/
+
+	double  delta,slat;
+	bool    flag=false;
+
+	/*  Get central_meridian and standard_parallel depending on hemisphere  */
+	if      (sgn ==  1) {
+		delta = 45;
+		slat = 70;
+		_printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45)");
+	}
+	else if (sgn == -1) {
+		delta = 0;
+		slat = 71;
+		_printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0)");
+	}
+	else
+		_error_("Sign should be either +1 or -1");
+
+	return(Xy2llx(lat,lon,
+				  x,y,ncoord,
+				  sgn,delta,slat));
+}
+
+int Xy2llx(double* lat, double* lon,
+		   double* x, double* y, int ncoord,
+		   int sgn, double central_meridian, double standard_parallel){
+
+/*  This is a cpp conversion of the following:
+%XY2LL - converts xy to lat long
+%
+%   Converts Polar  Stereographic (X,Y) coordinates for the polar regions to
+%   latitude and longitude Stereographic (X,Y) coordinates for the polar
+%   regions.
+%   Author: Michael P. Schodlok, December 2003 (map2xy.m)
+%
+%   Usage:
+%      [lat,lon] = xy2ll(x,y,sgn);
+%      [lat,lon] = xy2ll(x,y,sgn,central_meridian,standard_parallel);
+%
+%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
+%                               -1 : south latitude (default is mer=0  lat=71)
+*/
+
+	int     i;
+	double  delta,slat;
+	double  cde,re,ex2,ex,pi;
+	double  sl,rho,cm,T,chi;
+
+	if      ((sgn !=  1) && (sgn != -1))
+		_error_("Sign should be either +1 or -1");
+
+	delta = central_meridian;
+	slat  = standard_parallel;
+
+	/*  Conversion constant from degrees to radians  */
+	cde  = 57.29577951;
+	/*  Radius of the earth in meters  */
+	re   = 6378.273*pow(10.,3.);
+	/*  Eccentricity of the Hughes ellipsoid squared  */
+	ex2   = .006693883;
+	/*  Eccentricity of the Hughes ellipsoid  */
+	ex    =  sqrt(ex2);
+	/*  pi is not defined in cpp  */
+	pi   = 4.*atan(1.);
+
+	/*  loop over all the coordinate pairs  */
+
+	for (i=0; i<ncoord; i++) {
+		sl  = slat*pi/180.;
+		cm = cos(sl) / sqrt(1.0 - ex2 * (pow(sin(sl),2.)));
+		rho = sqrt(pow(x[i],2.) + pow(y[i],2.));
+		T = tan((pi / 4.0) - (sl / 2.0)) / pow(((1.0 - ex * sin(sl)) / (1.0 + ex * sin(sl))),(ex / 2.0));
+
+		if  (fabs(slat-90.) < 1.e-5)
+			T = rho * sqrt(pow((1. + ex),(1. + ex)) * pow((1. - ex),(1. - ex))) / 2. / re;
+		else
+			T = rho * T / (re * cm);
+
+		chi = (pi / 2.0) - 2.0 * atan(T);
+		lat[i] = chi + ((ex2 / 2.0) + (5.0 * pow(ex2,2.0) / 24.0) + (pow(ex2,3.0) / 12.0)) *
+			   sin(2.0 * chi) + ((7.0 * pow(ex2,2.0) / 48.0) + (29.0 * pow(ex2,3.0) / 240.0)) *
+			   sin(4.0 * chi) + (7.0 * pow(ex2,3.0) / 120.0) * sin(6.0 * chi) ;
+
+		lat[i] = (double)sgn * lat[i];
+		lon[i] = atan2((double)sgn * x[i],-(double)sgn * y[i]);
+		lon[i] = (double)sgn * lon[i];
+
+		if (rho <= 0.1) {
+			lat[i] = 90. * (double)sgn;
+			lon[i] = 0.0;
+		}
+
+		lon[i] = lon[i] * 180. / pi;
+		lat[i] = lat[i] * 180. / pi;
+		lon[i] = lon[i] - delta; 
+	}
+
+	return(0);
+}
+
Index: /issm/trunk/src/c/modules/Xy2llx/Xy2llx.h
===================================================================
--- /issm/trunk/src/c/modules/Xy2llx/Xy2llx.h	(revision 8673)
+++ /issm/trunk/src/c/modules/Xy2llx/Xy2llx.h	(revision 8673)
@@ -0,0 +1,18 @@
+/*!\file:  Xy2llx.h
+ * \brief header file for x/y to lat/long coordinate functions.
+ */ 
+
+#ifndef _XY2LLX_H
+#define _XY2LLX_H
+
+/* local prototypes: */
+int Xy2llx(double* lat, double* lon,
+		   double* x, double* y, int ncoord,
+		   int sgn);
+
+int Xy2llx(double* lat, double* lon,
+		   double* x, double* y, int ncoord,
+		   int sgn, double central_meridian, double standard_parallel);
+
+#endif  /* _XY2LLX_H */
+
