Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 13755)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 13756)
@@ -230,21 +230,25 @@
 	  AS_HELP_STRING([--with-python-dir=DIR], [python root directory.]),
 	  [PYTHON_ROOT=$withval],[PYTHON_ROOT=""]) 
+
 	AC_MSG_CHECKING(for python)
-	
 	if test -d "$PYTHON_ROOT"; then
-	 AC_MSG_RESULT($HAVE_PYTHON)
-		dnl defaults
-		HAVE_PYTHON3="no"
 		HAVE_PYTHON="yes"
-		AC_MSG_RESULT($HAVE_PYTHON)
-		
-		AC_ARG_WITH([python-version],
-		  AS_HELP_STRING([--with-python-version = PYTHONVERSION],[python version.]),
-		  [PYTHONVERSION=$withval],[PYTHONVERSION=""])
+		AC_DEFINE([_HAVE_PYTHON_],[1],[with Python in ISSM src])
+	else
+	 HAVE_PYTHON=no
+	fi
+	AC_MSG_RESULT($HAVE_PYTHON)
+
+	dnl get python version
+	if test "$HAVE_PYTHON" = "yes"; then
 		AC_MSG_CHECKING(for python version)
+		dnl Query Python for its version number.  Getting [:3] seems to be
+		dnl the best way to do this; it's what "site.py" does in the standard
+		dnl library.
+		PYTHON_VERSION=$($PYTHON_ROOT/bin/python -c "import sys; print sys.version[[:3]]")
+		AC_MSG_RESULT($PYTHON_VERSION)
 
 		dnl recover major: 
-		PYTHON_MAJOR=${PYTHONVERSION%.*}
-
+		PYTHON_MAJOR=${PYTHON_VERSION%.*}
 		if test x$PYTHON_MAJOR = x3; then
 			dnl are we running python 3?
@@ -252,5 +256,4 @@
 		fi
 		AC_DEFINE_UNQUOTED([_PYTHON_MAJOR_],$PYTHON_MAJOR,[python version major])
-		AC_MSG_RESULT($PYTHON_MAJOR)
 
 		PYTHONINCL=-I$PYTHON_ROOT/include
@@ -270,5 +273,4 @@
 		esac
 
-		AC_DEFINE([_HAVE_PYTHON_],[1],[with Python in ISSM src])
 		AC_SUBST([PYTHONINCL])
 		AC_SUBST([PYTHONLIB])
@@ -276,7 +278,4 @@
 		AC_SUBST([PYTHONWRAPPEREXT])
 		AC_SUBST([PYTHONLINK])
-	else
-		HAVE_PYTHON=no
-		AC_MSG_RESULT($HAVE_PYTHON)
 	fi
 	AM_CONDITIONAL([PYTHON], [test x$HAVE_PYTHON = xyes])
@@ -455,67 +454,4 @@
 	AM_CONDITIONAL([ROSE], [test x$HAVE_ROSE = xyes])
 	AC_MSG_RESULT($HAVE_ROSE)
-	dnl }}}
-	dnl metis{{{
-	AC_ARG_WITH([metis-dir],
-	  AS_HELP_STRING([--with-metis-dir=DIR],[metis root directory. necessary for serial build]),
-	  [METIS_ROOT=$withval],[METIS_ROOT=""])
-
-   AC_MSG_CHECKING(for metis headers and libraries in $METIS_ROOT)
-
-	if test -d "$METIS_ROOT"; then
-
-		dnl first figure out version of metis: does the VERSION file exist?
-		if test -e "$METIS_ROOT/VERSION"; then
-			METIS_VERSION=4
-		else
-			METIS_VERSION=5
-		fi
-
-		dnl defaults
-		HAVE_METIS=yes
-
-		if test "$METIS_VERSION" = "4" ; then
-   			
-			METISINCL=-I"$METIS_ROOT/Lib" 
-			case "${host_os}" in
-				*cygwin*)
-				METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
-				;;
-				*linux*)
-				METISLIB=-L"$METIS_ROOT/ -lmetis"
-				;;
-				*darwin*)
-				METISLIB=-L"$METIS_ROOT/ -lmetis"
-				;;
-			esac
-
-   			AC_DEFINE([_METIS_VERSION_],[4],[ Metis version number])
-		fi
-		if test "$METIS_VERSION" = "5" ; then
-	
-			case "${host_os}" in
-				*cygwin*)
-				METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
-				;;
-				*linux*)
-				METISLIB=-L"$METIS_ROOT/lib -lmetis"
-				;;
-				*darwin*)
-				METISLIB=-L"$METIS_ROOT/lib -lmetis"
-				;;
-			esac
-
-			METISINCL=-I"$METIS_ROOT/include" 
-			AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
-		fi
-
-		AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
-		AC_SUBST([METISINCL])
-		AC_SUBST([METISLIB])
-	else
-		HAVE_METIS=no
-	fi
-	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
-	AC_MSG_RESULT($HAVE_METIS)
 	dnl }}}
 	dnl mpi{{{
@@ -595,4 +531,5 @@
 			else
 				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib\" libpetsc.lib"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" libmetis.lib"; fi
 			fi
 			;;
@@ -602,4 +539,5 @@
 			else
 				PETSCLIB="-L$PETSC_ROOT/lib -lpetsc -ldl"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" -lmetis"; fi
 			fi
 			;;
@@ -609,4 +547,5 @@
 			else
 				PETSCLIB="-L$PETSC_ROOT/lib -lpetsc"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" -lmetis"; fi
 			fi
 			;;
@@ -622,4 +561,75 @@
 	AM_CONDITIONAL([PETSC], [test x$HAVE_PETSC = xyes])
 	AC_MSG_RESULT($HAVE_PETSC)
+	dnl }}}
+	dnl metis{{{
+	if test "$HAVE_PETSC" = "yes" && test "x$PETSC_MAJOR" = "x3" && test $PETSC_MINOR -ge 3; then
+
+		dnl in petsc >=3.3, metis is provided
+		HAVE_METIS="yes"
+		AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
+		AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
+	else
+		AC_ARG_WITH([metis-dir],
+		  AS_HELP_STRING([--with-metis-dir=DIR],[metis root directory. necessary for serial build]),
+		  [METIS_ROOT=$withval],[METIS_ROOT=""])
+
+		AC_MSG_CHECKING(for metis headers and libraries in $METIS_ROOT)
+
+		if test -d "$METIS_ROOT"; then
+
+			dnl first figure out version of metis: does the VERSION file exist?
+			if test -e "$METIS_ROOT/VERSION"; then
+				METIS_VERSION=4
+			else
+				METIS_VERSION=5
+			fi
+
+			dnl defaults
+			HAVE_METIS=yes
+
+			if test "$METIS_VERSION" = "4" ; then
+					
+				METISINCL=-I"$METIS_ROOT/Lib" 
+				case "${host_os}" in
+					*cygwin*)
+					METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
+					;;
+					*linux*)
+					METISLIB=-L"$METIS_ROOT/ -lmetis"
+					;;
+					*darwin*)
+					METISLIB=-L"$METIS_ROOT/ -lmetis"
+					;;
+				esac
+
+					AC_DEFINE([_METIS_VERSION_],[4],[ Metis version number])
+			fi
+			if test "$METIS_VERSION" = "5" ; then
+		
+				case "${host_os}" in
+					*cygwin*)
+					METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
+					;;
+					*linux*)
+					METISLIB=-L"$METIS_ROOT/lib -lmetis"
+					;;
+					*darwin*)
+					METISLIB=-L"$METIS_ROOT/lib -lmetis"
+					;;
+				esac
+
+				METISINCL=-I"$METIS_ROOT/include" 
+				AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
+			fi
+
+			AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
+			AC_SUBST([METISINCL])
+			AC_SUBST([METISLIB])
+		else
+			HAVE_METIS=no
+		fi
+		AC_MSG_RESULT($HAVE_METIS)
+	fi
+	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
 	dnl }}}
 	dnl tao{{{
@@ -1355,17 +1365,8 @@
 	fi
 
-	dnl check that we have python version if python compile is specified
-	if test "$HAVE_PYTHON" = "yes"  && test "$PYTHONVERSION" = "" ; then
-	AC_MSG_ERROR([need python-version if python compile is required!]);
-	fi
-
 	dnl check that if we have MPI, we have metis
 	if test "$HAVE_METIS" = "yes"  && test "$HAVE_MPI" = "no" ; then
 	AC_MSG_ERROR([need mpi if using the metis partitioner!]);
 	fi
-
-
-
-
 
 	AC_MSG_RESULT(done)
@@ -1425,12 +1426,3 @@
 	AC_MSG_RESULT($USE_64BIT_INDICES)
 	dnl }}}
-	dnl circular-dependency{{{
-	AC_ARG_WITH([circular-dependency],
-	  AS_HELP_STRING([--with-circular-dependency = bool],[do we look for circular dependencies, default "yes", ex: --with-circular-dependency="no"]),
-	  [CIRCULAR_DEPENDENCIES=$withval],[CIRCULAR_DEPENDENCIES=yes]) 
-	AC_MSG_CHECKING(for circular dependencies)
-	AM_CONDITIONAL([CIRCULAR_DEPENDENCIES], [test x$CIRCULAR_DEPENDENCIES = xyes])
-	AC_MSG_RESULT($CIRCULAR_DEPENDENCIES) 
-
-	dnl }}}
 ])
