Index: /issm/trunk-jpl/configs/config-macosx64-larour-nopetsc.sh
===================================================================
--- /issm/trunk-jpl/configs/config-macosx64-larour-nopetsc.sh	(revision 12101)
+++ /issm/trunk-jpl/configs/config-macosx64-larour-nopetsc.sh	(revision 12102)
@@ -1,28 +1,15 @@
 #!/bin/sh
 
-#petsc 3.2
-#mpich 1.4
+pythonversion=2.7
 
 ./configure \
 	--prefix=$ISSM_TIER \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-matlab-dir=$MATLAB_DIR \
+	--with-python-dir=$ISSM_TIER/externalpackages/python/install\
+	--with-python-version=$pythonversion \
+	--with-python-numpy-dir=$ISSM_TIER/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
 	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
-	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib \
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
-	--with-numthreads=8 \
 	--with-gsl-dir=$ISSM_TIER/externalpackages/gsl/install
-#	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-#	--with-petsc-arch=$ISSM_ARCH \
-#	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-#	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-#	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ 
-#   --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
Index: /issm/trunk-jpl/externalpackages/nose/install-macosx64sh
===================================================================
--- /issm/trunk-jpl/externalpackages/nose/install-macosx64sh	(revision 12101)
+++ /issm/trunk-jpl/externalpackages/nose/install-macosx64sh	(revision 12102)
@@ -1,10 +1,27 @@
 #/bin/bash
-#Install Python3 nose module
+#Install Python nose module
 
-rm -rf py3k
+pythonversion=2
+	
+rm -rf src 
 
-svn checkout http://python-nose.googlecode.com/svn/branches/py3k
-cd py3k
+if [[ $pythonversion == "3" ]];then
 
-python3.2 ./setup.py build
-python3.2 ./setup.py install
+	svn checkout http://python-nose.googlecode.com/svn/branches/py3k
+	mv py3k src
+
+	cd src
+	python ./setup.py build
+	python ./setup.py install
+fi
+
+if [[ $pythonversion == "2" ]];then
+
+	tar -zxvf  nose-1.1.2.tar.gz
+	mv nose-1.1.2 src
+	rm -rf nose-1.1.2
+
+	cd src
+	python ./setup.py build
+	python ./setup.py install
+fi
Index: /issm/trunk-jpl/externalpackages/scipy/install-macosx64.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/scipy/install-macosx64.sh	(revision 12101)
+++ /issm/trunk-jpl/externalpackages/scipy/install-macosx64.sh	(revision 12102)
@@ -19,6 +19,6 @@
 	#install numpy
 	cd numpy
-	python3.2 setup.py build
-	python3.2 setup.py install
+	python setup.py build
+	python setup.py install
 
 	
@@ -30,6 +30,6 @@
 	#install scipy
 	cd scipy
-	python3.2 setup.py build
-	python3.2 setup.py install
+	python setup.py build
+	python setup.py install
 
 elif [[ $install == "3" ]];then 
Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 12101)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 12102)
@@ -572,10 +572,5 @@
 		HAVE_METIS=no
 	fi
-
-	if test $HAVE_METIS = no; then
-		AC_MSG_ERROR([--with-metis-dir  missing. Metis is needed to run ISSM]);
-	else
-		AC_MSG_RESULT($HAVE_METIS)
-	fi
+	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
 	dnl }}}
 	dnl mpi{{{
@@ -603,4 +598,5 @@
 		fi
 	fi
+	AM_CONDITIONAL([MPI], [test x$HAVE_MPI = xyes])
 	AC_MSG_RESULT($HAVE_MPI)
 	dnl }}}
@@ -1228,4 +1224,13 @@
 	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)
 	dnl }}}
Index: /issm/trunk-jpl/src/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/Makefile.am	(revision 12101)
+++ /issm/trunk-jpl/src/Makefile.am	(revision 12102)
@@ -1,2 +1,2 @@
-EXTRA_DIST =  perl  pro py
-SUBDIRS = c modules m 
+EXTRA_DIST =  perl  pro 
+SUBDIRS = c modules m  py
Index: /issm/trunk-jpl/src/c/Container/Constraints.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Constraints.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/Container/Constraints.cpp	(revision 12102)
@@ -48,6 +48,11 @@
 
 	/*figure out total number of constraints combining all the cpus (no clones here)*/
-	MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);
+	#ifdef _HAVE_MPI_
+		MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
+		MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+		numberofconstraints=localconstraints;
+	#endif
+	
 
 	return numberofconstraints;
Index: /issm/trunk-jpl/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 12102)
@@ -125,4 +125,5 @@
 
 	/*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&max_numvertices,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -132,4 +133,5 @@
 	MPI_Bcast(&max_numnodes,1,MPI_INT,0,MPI_COMM_WORLD);
 	numnodes=max_numnodes;
+	#endif
 
 	/*Ok, initialize Patch object: */
@@ -191,7 +193,11 @@
 
 		/*Get rank of first cpu that has results*/
+		#ifdef _HAVE_MPI_
 		if(this->Size()) rank=my_rank;
 		else rank=num_procs;
 		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+		#else
+		minrank=my_rank;
+		#endif
 
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
@@ -201,8 +207,11 @@
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
+		#endif
 
 		/*Get out if there is no results. Otherwise broadcast info*/
 		if(!numberofresults) return;
+		#ifdef _HAVE_MPI_
 		if(my_rank!=minrank){
 			resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
@@ -215,4 +224,5 @@
 		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
 		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
+		#endif
 
 		/*Loop over all results and get nodal vector*/
@@ -273,5 +283,9 @@
 
 	local_nelem=this->Size();
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	#else
+	numberofelements=local_nelem;
+	#endif
 
 	return numberofelements;
Index: /issm/trunk-jpl/src/c/Container/Loads.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Loads.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/Container/Loads.cpp	(revision 12102)
@@ -63,6 +63,11 @@
 
 	/*figure out total number of loads combining all the cpus (no clones here)*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&numberofloads,1,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	numberofloads=localloads;
+	#endif
+
 
 	return numberofloads;
Index: /issm/trunk-jpl/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 12102)
@@ -83,8 +83,12 @@
 	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
-	 * First: bet number of dofs for each cpu*/
+	 * First: get number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	alldofcount[0]=dofcount;
+	#endif
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
@@ -119,5 +123,9 @@
 		}
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	#else
+	alltruedofs[0]=truedofs[0];
+	#endif
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
@@ -162,5 +170,9 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numnodes;i++)minranks[i]=ranks[i];
+	#endif
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -205,6 +217,7 @@
 
 	/*Grab max of all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
-	max=allmax;
+	#endif
 
 	return max;
@@ -237,5 +250,9 @@
 
 	/*Gather from all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	#else
+	allnumdofs=numdofs;
+	#endif
 	return allnumdofs;
 }
@@ -260,5 +277,9 @@
 
 	/*Gather from all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	#else
+	allnumnodes=numnodes;
+	#endif
 
 	return allnumnodes;
@@ -286,7 +307,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
 	max_sid=node_max_sid;
+	#endif
 
 	if(max_sid==1){
Index: /issm/trunk-jpl/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 12102)
@@ -61,6 +61,10 @@
 	 * First: bet number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	alldofcount[0]=dofcount;
+	#endif
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
@@ -85,5 +89,9 @@
 		vertex->ShowTrueDofs(truedofs);
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numberofobjects*numberofdofsperobject;i++)alltruedofs[i]=truedofs[i];
+	#endif
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
@@ -121,5 +129,9 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i];
+	#endif
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -149,7 +161,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
 	max_sid=vertex_max_sid;
+	#endif
 
 	/*sid starts at 0*/
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 12101)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 12102)
@@ -206,10 +206,4 @@
 					./shared/Wrapper/ModuleBoot.cpp\
 					./shared/Wrapper/ModuleEnd.cpp\
-					./toolkits/mpi/mpiincludes.h\
-					./toolkits/mpi/patches/mpipatches.h\
-					./toolkits/mpi/patches/DetermineLocalSize.cpp\
-					./toolkits/mpi/patches/MPI_Upperrow.cpp\
-					./toolkits/mpi/patches/MPI_Lowerrow.cpp\
-					./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp\
 					./toolkits/metis/metisincludes.h\
 					./toolkits/issm/issmtoolkit.h\
@@ -218,6 +212,4 @@
 					./toolkits/issm/SeqMat.h\
 					./toolkits/issm/SeqMat.cpp\
-					./toolkits/metis/patches/metispatches.h\
-					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp\
 					./toolkits/triangle/triangleincludes.h\
 					./toolkitsenums.h\
@@ -700,4 +692,6 @@
 					./toolkits/petsc/patches/SerialToVec.cpp\
 					./toolkits/petsc/patches/VecFree.cpp\
+					./toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp\
+					./toolkits/petsc/patches/PetscVectorToDoubleVector.cpp\
 					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
 					./toolkits/petsc/patches/KSPFree.cpp\
@@ -722,4 +716,16 @@
 
 #}}}
+#Mpi sources  {{{1
+mpi_sources= ./toolkits/mpi/mpiincludes.h\
+				./toolkits/mpi/patches/mpipatches.h\
+				./toolkits/mpi/patches/DetermineLocalSize.cpp\
+				./toolkits/mpi/patches/MPI_Upperrow.cpp\
+				./toolkits/mpi/patches/MPI_Lowerrow.cpp\
+				./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
+#}}}
+#Metis sources  {{{1
+metis_sources= ./toolkits/metis/patches/metispatches.h\
+					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
+#}}}
 #Python sources  {{{1
 python_sources=     ./python/io/pythonio.h\
@@ -744,10 +750,11 @@
 					 ./matlab/io/MatlabVectorToDoubleVector.cpp\
 					 ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\
-					 ./matlab/io/MatlabMatrixToPetscMatrix.cpp\
-					 ./matlab/io/MatlabVectorToPetscVector.cpp\
-					 ./matlab/io/PetscMatrixToDoubleMatrix.cpp\
-					 ./matlab/io/PetscVectorToDoubleVector.cpp\
 					 ./matlab/io/MatlabMatrixToSeqMat.cpp\
 					 ./matlab/io/MatlabVectorToSeqVec.cpp
+#}}}
+#Matlab and Petsc sources  {{{1
+matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMatrix.cpp\
+					 ./matlab/io/MatlabVectorToPetscVector.cpp
+	
 #}}}
 #Modules sources{{{1
@@ -911,4 +918,20 @@
 issm_sources +=  $(threed_sources)
 endif
+
+if MPI
+issm_sources +=  $(mpi_sources)
+endif
+
+if METIS
+issm_sources +=  $(metis_sources)
+endif
+
+if PETSC
+if MATLAB
+issm_sources +=  $(matlabpetsc_sources)
+endif
+endif
+
+
 #}}}
 #Library flags and sources {{{1
Index: sm/trunk-jpl/src/c/matlab/io/PetscMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/PetscMatrixToDoubleMatrix.cpp	(revision 12101)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/* \file PetscMatrixToDoubleMatrix.cpp
- * \brief: convert a sparse or dense Petsc matrix into a matlab matrix
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Petsc includes: */
-#include "mex.h"
-
-#include "../../shared/shared.h"
-#include <string>
-
-
-void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat petsc_matrix){
-
-	int i,j,k;
-
-	/*output: */
-	double* matrix=NULL;
-	int     rows,cols;
-
-	/*intermediary: */
-	int*    idxm=NULL;
-	int*    idxn=NULL;
-
-	/*Some needed information: */
-	MatGetSize(petsc_matrix,&rows,&cols);
-
-	idxm=(int*)xmalloc(rows*sizeof(int));
-	idxn=(int*)xmalloc(cols*sizeof(int));
-
-	for(i=0;i<rows;i++)idxm[i]=i;
-	for(i=0;i<cols;i++)idxn[i]=i;
-
-	matrix=(double*)xmalloc(rows*cols*sizeof(double));
-	MatGetValues(petsc_matrix,rows,idxm,cols,idxn,matrix);
-
-	/*Assign output pointers: */
-	*pmatrix=matrix;
-	*prows=rows;
-	*pcols=cols;
-}
Index: sm/trunk-jpl/src/c/matlab/io/PetscVectorToDoubleVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/PetscVectorToDoubleVector.cpp	(revision 12101)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/* \file PetscVectorToDoubleVector.cpp
- */
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-#include "mex.h"
-#include "../../shared/shared.h"
-#include <string>
-
-void PetscVectorToDoubleVector(double** pvector, int* prows, Vec petsc_vector){
-
-	int     i;
-	int     rows;
-	int    *idxm   = NULL;
-	double *vector = NULL;
-
-	/*output: */
-	mxArray* dataref=NULL;
-
-	/*Get size of vector: */
-	if(petsc_vector){
-		VecGetSize(petsc_vector,&rows);
-		if(rows){
-			idxm=(int*)xmalloc(rows*sizeof(int));
-			vector=(double*)xmalloc(rows*sizeof(double));
-			for(i=0;i<rows;i++)idxm[i]=i;
-
-			VecGetValues(petsc_vector,rows,idxm,vector);
-		}
-	}
-	else{
-		rows=0;
-	}
-
-	/*Assign output pointers: */
-	*pvector=vector;
-	*prows=rows;
-}
Index: /issm/trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp	(revision 12102)
@@ -231,5 +231,5 @@
 		#else
 		matrix_ptr=matrix->matrix->ToSerial();
-		matrix->matrix->GetSize(&rows,cols);
+		matrix->matrix->GetSize(&rows,&cols);
 		#endif
 
Index: /issm/trunk-jpl/src/c/matlab/io/matlabio.h
===================================================================
--- /issm/trunk-jpl/src/c/matlab/io/matlabio.h	(revision 12101)
+++ /issm/trunk-jpl/src/c/matlab/io/matlabio.h	(revision 12102)
@@ -72,10 +72,4 @@
 int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
 int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
-int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
-
-/*Matlab to Petsc routines: */
-int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
-void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat matrix);
-void PetscVectorToDoubleVector(double** pvector, int* prows, Vec vector);
 
 /*Matlab to SeqMat routines: */
@@ -83,3 +77,10 @@
 SeqVec* MatlabVectorToSeqVec(const mxArray* dataref);
 
+/*Matlab to Petsc routines: */
+#ifdef _HAVE_PETSC_
+int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
+int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
+#endif
+
+
 #endif	/* _IO_H_ */
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
 	found=mpi_found;
+	#endif
 
 	return found;
@@ -93,7 +95,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
 	num_unstable_constraints=sum_num_unstable_constraints;
+	#endif
 	
 	/*Assign output pointers: */
@@ -131,7 +135,9 @@
 	
 	/*Is there just one found? that would mean we have frozen! : */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
 	found=mpi_found;
+	#endif
 
 	return found;
@@ -189,7 +195,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
 	found=mpi_found;
+	#endif
 
 	return found;
@@ -220,7 +228,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
 	found=mpi_found;
+	#endif
 
 	if (found){
@@ -279,7 +289,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
 	num_unstable_constraints=sum_num_unstable_constraints;
+	#endif
 	
 	/*Assign output pointers: */
@@ -317,7 +329,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,MPI_COMM_WORLD);                
 	max_penetration=mpi_max_penetration;
+	#endif
 
 	/*feed max_penetration to inputs: */
@@ -354,7 +368,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
 	num_unstable_constraints=sum_num_unstable_constraints;
+	#endif
 
 	return num_unstable_constraints;
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 12102)
@@ -36,7 +36,9 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
 	num_unstable_constraints=sum_num_unstable_constraints;
+	#endif
 
 	/*Have we converged? : */
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 12102)
@@ -28,7 +28,9 @@
 	}
 	
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
 	found=mpi_found;
+	#endif
 
 	return found;
Index: /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ElementResponsex/ElementResponsex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12102)
@@ -37,6 +37,8 @@
 
 	/*Broadcast whether we found the element: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse");
+	#endif
 
 	/*Ok, we found the element, compute responseocity: */
@@ -46,6 +48,8 @@
 
 	/*Broadcast and plug into response: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 	MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 
+	#endif
 
 	*presponse=response;
Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12102)
@@ -156,6 +156,10 @@
 		vec_nodes_on_floatingice->Assemble();
 		
+		#ifdef _HAVE_MPI_
 		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 		_printf_(VerboseConvergence(),"   Additional number of vertices allowed to unground: %i\n",nflipped);
+		#else
+		nflipped=local_nflipped;
+		#endif
 
 		/*Avoid leaks: */
Index: /issm/trunk-jpl/src/c/modules/IceVolumex/IceVolumex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/IceVolumex/IceVolumex.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/IceVolumex/IceVolumex.cpp	(revision 12102)
@@ -19,6 +19,10 @@
 		local_ice_volume+=element->IceVolume();
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	#else
+	total_ice_volume=local_ice_volume;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/InputConvergencex/InputConvergencex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12102)
@@ -30,6 +30,8 @@
 
 	/*In parallel, we need to gather the converged status: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	num_notconverged=total_notconverged;
+	#endif
 	_printf_(VerboseConvergence(),"      #elements above convergence criterion = %i\n",num_notconverged);
 
Index: /issm/trunk-jpl/src/c/modules/MassFluxx/MassFluxx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12102)
@@ -59,6 +59,8 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
 	mass_flux=all_mass_flux;
+	#endif
 
 	/*Free ressources:*/
Index: /issm/trunk-jpl/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxabsvx=node_maxabsvx;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp	(revision 12102)
@@ -33,7 +33,9 @@
 
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxabsvy=node_maxabsvy;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxabsvz=node_maxabsvz;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxVelx/MaxVelx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxVelx/MaxVelx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxVelx/MaxVelx.cpp	(revision 12102)
@@ -33,7 +33,9 @@
 
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxvel=node_maxvel;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxVxx/MaxVxx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxVxx/MaxVxx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxVxx/MaxVxx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxvx=node_maxvx;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxVyx/MaxVyx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxVyx/MaxVyx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxVyx/MaxVyx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxvy=node_maxvy;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MaxVzx/MaxVzx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MaxVzx/MaxVzx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MaxVzx/MaxVzx.cpp	(revision 12102)
@@ -33,7 +33,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	maxvz=node_maxvz;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12102)
@@ -42,5 +42,7 @@
 		/*Partition using Metis:*/
 		if (num_procs>1){
+			#ifdef _HAVE_METIS_
 			METIS_PartMeshNodalPatch(&numberofelements,&numberofnodes, index, &etype, &numflag, &num_procs, &edgecut, epart, npart);
+			#endif
 		}
 		else if (num_procs==1){
@@ -67,5 +69,7 @@
 		/*Partition using Metis:*/
 		if (num_procs>1){
+			#ifdef _HAVE_METIS_
 			METIS_PartMeshNodalPatch(&numberofelements2d,&numberofnodes2d, index2d, &etype2d, &numflag, &num_procs, &edgecut, epart2d, npart2d);
+			#endif
 		}
 		else if (num_procs==1){
Index: /issm/trunk-jpl/src/c/modules/MinVelx/MinVelx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MinVelx/MinVelx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MinVelx/MinVelx.cpp	(revision 12102)
@@ -33,7 +33,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	minvel=node_minvel;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MinVxx/MinVxx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MinVxx/MinVxx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MinVxx/MinVxx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	minvx=node_minvx;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MinVyx/MinVyx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MinVyx/MinVyx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MinVyx/MinVyx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	minvy=node_minvy;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/MinVzx/MinVzx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/MinVzx/MinVzx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/MinVzx/MinVzx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
 	minvz=node_minvz;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12102)
@@ -36,10 +36,16 @@
 
 	/*Broadcast whether we found the element: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	if(!sumfound)_error_("%s%i%s%s","could not find element with vertex with id",index," to compute nodal value ",EnumToStringx(natureofdataenum));
+	#endif
 
 	/*Broadcast and plug into response: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 	MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 
+	#else
+	value=cpu_found;
+	#endif
 
 	*pnodalvalue=value;
Index: /issm/trunk-jpl/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12102)
@@ -93,4 +93,5 @@
 
 	/*Ok, broadcast to other cpus: */
+ 	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD);
 	if(my_rank!=0){
@@ -99,4 +100,5 @@
 	}
 	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	#endif
 	for(i=0;i<numanalyses;i++){
 		char* string=strings[i];
@@ -105,8 +107,10 @@
 		}
 		if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD);
 		if(my_rank!=0)string=(char*)xmalloc(stringlength);
 		MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD);
 		if(my_rank!=0)strings[i]=string;
+		#endif
 	}
 
Index: /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12102)
@@ -28,7 +28,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
+	#ifdef _HAVE_MPI_
+ 	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 	S=S_sum;
+	#endif
 
 	/*add surface area to element inputs:*/
Index: /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 12102)
@@ -31,7 +31,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 12102)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/TimeAdaptx/TimeAdaptx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12102)
@@ -32,7 +32,9 @@
 
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	min_dt=node_min_dt;
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/objects/Bamg/Metric.h
===================================================================
--- /issm/trunk-jpl/src/c/objects/Bamg/Metric.h	(revision 12101)
+++ /issm/trunk-jpl/src/c/objects/Bamg/Metric.h	(revision 12102)
@@ -5,4 +5,5 @@
 #include "../../shared/Bamg/shared.h"
 #include "R2.h"
+#include <math.h>
 
 namespace bamg {
Index: /issm/trunk-jpl/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12102)
@@ -198,5 +198,7 @@
 				/*Ok, we have reached the end of the file. break: */
 				record_code=0; //0 means bailout
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell others cpus we are bailing: */
+				#endif
 				break;
 			}
@@ -207,4 +209,5 @@
 				fread(&record_code,sizeof(int),1,this->fid);
 					
+				#ifdef _HAVE_MPI_
 				/*Tell other cpus what we are doing: */
 				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell other cpus what we are going to do: */
@@ -213,11 +216,13 @@
 				MPI_Bcast(&record_enum,1,MPI_INT,0,MPI_COMM_WORLD);  
 				MPI_Bcast(&record_length,1,MPI_INT,0,MPI_COMM_WORLD);  
+				#endif
 				
-
 				switch(record_code){
 					case 1: 
 						/*Read the boolean and broadcast it to other cpus:*/
 						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_(" could not read boolean ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create BoolParam: */
@@ -228,5 +233,7 @@
 						/*Read the integer and broadcast it to other cpus:*/
 						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_(" could not read integer ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create IntParam: */
@@ -237,5 +244,7 @@
 						/*Read the scalar and broadcast it to other cpus:*/
 						if(fread(&scalar,sizeof(double),1,this->fid)!=1) _error_(" could not read scalar ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create DoubleParam: */
@@ -246,5 +255,7 @@
 						/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_(" could not read length of string ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						if(string_size){
@@ -254,5 +265,7 @@
 							/*Read string, then broadcast: */
 							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_("  could not read string ");
+							#ifdef _HAVE_MPI_
 							MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+							#endif
 						}
 						else{
@@ -308,4 +321,5 @@
 		}
 	} //}}}
+	#ifdef _HAVE_MPI_
 	else{ //cpu ~0 {{{2
 		for(;;){ //wait on cpu 0
@@ -377,4 +391,5 @@
 		}
 	} //}}}
+	#endif
 }
 /*}}}*/
@@ -399,5 +414,7 @@
 		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_(" could not read boolean ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*cast to bool: */
@@ -428,5 +445,7 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers: */
@@ -456,5 +475,7 @@
 		if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers: */
@@ -487,5 +508,7 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate string: */
@@ -498,5 +521,7 @@
 			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+		#endif
 	}
 	else{
@@ -538,10 +563,14 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#ifdef _HAVE_MPI_
+	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);
+	#endif
 
 	/*Now allocate matrix: */
@@ -554,5 +583,7 @@
 		}
 		
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		#endif
 	}
 
@@ -602,10 +633,14 @@
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate matrix: */
@@ -617,5 +652,7 @@
 			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		#endif
 	}
 
@@ -652,5 +689,7 @@
 		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_(" could not read length of string array");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numstrings,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate string array: */
@@ -665,5 +704,7 @@
 				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 			if(string_size){
 				string=(char*)xmalloc((string_size+1)*sizeof(char));
@@ -674,5 +715,7 @@
 					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
 				}
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+				#endif
 			}
 			else{
@@ -717,5 +760,7 @@
 		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numrecords,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(numrecords){
@@ -738,10 +783,14 @@
 				if(fread(&M,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of rows in ",i,"th matrix of matrix array");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 
 			if(my_rank==0){  
 				if(fread(&N,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of columns in ",i,"th matrix of matrix array");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 
 			/*Now allocate matrix: */
@@ -754,5 +803,7 @@
 				}
 
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+				#endif
 			}
 
@@ -1047,11 +1098,15 @@
 		}
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum));
+	#endif
 
 	/*Broadcast code and vector type: */
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 
 	MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/objects/Patch.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Patch.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/objects/Patch.cpp	(revision 12102)
@@ -120,9 +120,15 @@
 	int         node_numrows;
 	double     *total_values  = NULL;
+	#ifdef _HAVE_MPI_
 	MPI_Status  status;
+	#endif
 
 	/*First, figure out total number of rows combining all the cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&total_numrows,1,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	total_numrows=this->numrows;
+	#endif
 
 	/*return if patch empty*/
@@ -140,4 +146,5 @@
 
 	/*Now, ask other nodes to send their values: */
+	#ifdef _HAVE_MPI_
 	for (i=1;i<num_procs;i++){
 		if (my_rank==i){ 
@@ -151,4 +158,5 @@
 		}
 	}	
+	#endif
 
 	/*Now, node 0 has total_values, of size total_numrows*this->numcols. Update the fields in the patch, to reflect this new 
@@ -159,7 +167,9 @@
 		this->values=total_values;
 	}
+	#ifdef _HAVE_MPI_
 	else{
 		this->numrows=0;
 		xfree((void**)&this->values);
 	}
+	#endif
 }/*}}}*/
Index: /issm/trunk-jpl/src/c/solutions/issm.cpp
===================================================================
--- /issm/trunk-jpl/src/c/solutions/issm.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/solutions/issm.cpp	(revision 12102)
@@ -42,12 +42,20 @@
 	if(ierr) _error_("Could not initialize Petsc");
 	#else
+	#ifdef _HAVE_MPI_
 	MPI_Init(&argc,&argv);
 	#endif
+	#endif
 
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
+	#else
+	start=(double)clock();
+	#endif
 
 	/*Size and rank: */
+	#ifdef _HAVE_MPI_
 	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);  
 	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
+	#endif
 
 	/*First process inputs*/
@@ -62,5 +70,9 @@
 	
 	/*Create femmodel, using input file: */
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
+	#else
+	start_init=(double)clock();
+	#endif
 	femmodel=new FemModel(binfilename,outbinfilename,solution_type,analyses,numanalyses);
 	
@@ -82,8 +94,17 @@
 	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
 	femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
+	#else
+	finish_init=(double)clock();
+	#endif
 
 	_printf_(true,"call computational core:\n");
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
+	#else
+	start_core=(double)clock();
+	#endif
+	
 	if(dakota_analysis){
 		#ifdef _HAVE_DAKOTA_
@@ -106,6 +127,10 @@
 		solutioncore(femmodel);
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
-
+	#else
+	finish_core=(double)clock();
+	#endif
+	
 	_printf_(true,"write results to disk:\n");
 	OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
@@ -127,15 +152,26 @@
 
 	/*Get finish time and close*/
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
 	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",finish_init-start_init);
 	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",finish_core-start_core);
 	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
+	#else
+	finish=(double)clock();
+	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",(finish_init-start_init)/CLOCKS_PER_SEC);
+	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",(finish_core-start_core)/CLOCKS_PER_SEC);
+	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600/CLOCKS_PER_SEC),int(int((finish-start)/CLOCKS_PER_SEC)%3600/60),(int(finish-start)/CLOCKS_PER_SEC)%60);
+	#endif
 	
+		
 	
+	#ifdef _HAVE_PETSC_
 	_printf_(true,"closing MPI and Petsc\n");
-	#ifdef _HAVE_PETSC_
 	PetscFinalize(); 
 	#else
+	#ifdef _HAVE_MPI_
+	_printf_(true,"closing MPI and Petsc\n");
 	MPI_Finalize();
+	#endif
 	#endif
 	
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12102)
@@ -10,4 +10,5 @@
 #endif
 
+#include <string>
 
 /*Petsc includes: */
@@ -17,8 +18,5 @@
 
 /*Petsc includes: */
-#include "mex.h"
-
-#include "../../shared/shared.h"
-#include <string>
+#include "../../../shared/shared.h"
 
 
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12101)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12102)
@@ -8,4 +8,6 @@
 #endif
 
+#include <string>
+
 /*Petsc includes: */
 #include "petscmat.h"
@@ -13,7 +15,5 @@
 #include "petscksp.h"
 
-#include "mex.h"
-#include "../../shared/shared.h"
-#include <string>
+#include "../../../shared/shared.h"
 
 void PetscVectorToDoubleVector(double** pvector, int* prows, Vec petsc_vector){
@@ -23,7 +23,4 @@
 	int    *idxm   = NULL;
 	double *vector = NULL;
-
-	/*output: */
-	mxArray* dataref=NULL;
 
 	/*Get size of vector: */
Index: /issm/trunk-jpl/src/c/toolkits/toolkits.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/toolkits.h	(revision 12101)
+++ /issm/trunk-jpl/src/c/toolkits/toolkits.h	(revision 12102)
@@ -20,6 +20,12 @@
 #endif
 
+#ifdef _HAVE_MPI_
 #include "./mpi/mpiincludes.h"
+#endif
+
+#ifdef _HAVE_METIS_
 #include "./metis/metisincludes.h"
+#endif
+
 #include "./triangle/triangleincludes.h"
 #include "./toolkitsenums.h"
Index: /issm/trunk-jpl/src/m/model/mesh/triangle.py
===================================================================
--- /issm/trunk-jpl/src/m/model/mesh/triangle.py	(revision 12102)
+++ /issm/trunk-jpl/src/m/model/mesh/triangle.py	(revision 12102)
@@ -0,0 +1,55 @@
+from TriMesh import *
+from numpy import *
+
+def triangle(md, domainname, resolution,riftname=''):
+	#TRIANGLE - create model mesh using the triangle package
+	#
+	#   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
+	#   where md is a @model object, domainname is the name of an Argus domain outline file, 
+	#   and resolution is a characteristic length for the mesh (same unit as the domain outline
+	#   unit). Riftname is an optional argument (Argus domain outline) describing rifts.
+	#
+	#   Usage:
+	#      md=triangle(md,domainname,resolution)
+	#   or md=triangle(md,domainname, resolution, riftname)
+	#
+	#   Examples:
+	#      md=triangle(md,'DomainOutline.exp',1000);
+	#      md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp');
+
+
+	#Figure out a characteristic area. Resolution is a node oriented concept (ex a 1000m  resolution node would 
+	#be made of 1000*1000 area squares). 
+
+	#Check that mesh was not already run, and warn user: 
+	if md.mesh.numberofelements != 0.:
+		choice = input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
+		if choice != 'y':
+			print 'no meshing done ... exiting'
+			return []
+		
+	area = resolution**2.
+
+	#Mesh using TriMesh
+	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMesh(domainname,riftname,area)
+
+	#Fill in rest of fields:
+	md.mesh.numberofelements = size(md.mesh.elements)
+	md.mesh.numberofvertices = size(md.mesh.x)
+	md.mesh.z = zeros(md.mesh.numberofvertices)
+	md.mesh.vertexonboundary = zeros(md.mesh.numberofvertices)
+	md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)] = 1.
+	md.mesh.vertexonbed = ones(md.mesh.numberofvertices)
+	md.mesh.vertexonsurface = ones(md.mesh.numberofvertices)
+	md.mesh.elementonbed = ones(md.mesh.numberofelements)
+	md.mesh.elementonsurface = ones(md.mesh.numberofelements)
+
+	#Now, build the connectivity tables for this mesh.
+	print "Node: NodeConnectivity not implemented yet!"
+	#md.mesh.vertexconnectivity = NodeConnectivity((md.mesh.elements), (md.mesh.numberofvertices))
+	print "Node: ElementConnectivity not implemented yet!"
+	#md.mesh.elementconnectivity = ElementConnectivity((md.mesh.elements), (md.mesh.vertexconnectivity))
+
+	#type of model
+	md.mesh.dimension = 2.
+	return md
Index: /issm/trunk-jpl/startup.py
===================================================================
--- /issm/trunk-jpl/startup.py	(revision 12101)
+++ /issm/trunk-jpl/startup.py	(revision 12102)
@@ -82,4 +82,5 @@
 from miscellaneous import *
 from private import *
+from triangle import *
 
 #}}}
Index: /issm/trunk-jpl/test/NightlyRun/test101.py
===================================================================
--- /issm/trunk-jpl/test/NightlyRun/test101.py	(revision 12101)
+++ /issm/trunk-jpl/test/NightlyRun/test101.py	(revision 12102)
@@ -1,8 +1,9 @@
 from model import *
 from TriMesh import *
+from triangle import *
 
-#md=model()
-#md=triangle(md,'../Exp/Square.exp',150000);
+md=model()
+md=triangle(md,'../Exp/Square.exp',150000);
 
-[index,x,y,segments,segmentmarkers]=TriMesh('../Exp/Square.exp',15000.0**2.0,True)
-print(index,x,y,segments,segmentmarkers)
+#[index,x,y,segments,segmentmarkers]=TriMesh('../Exp/Square.exp',15000.0**2.0,True)
+#print(index,x,y,segments,segmentmarkers)
