Index: /issm/trunk/externalpackages/meshpart/Makefile.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/Makefile.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/Makefile.patch	(revision 2975)
@@ -0,0 +1,69 @@
+27c27,28
+< MATLAB =        /usr/local/libexec/matlab
+---
+> #MATLAB =        /usr/local/libexec/matlab
+> MATLAB =        /usr/local/pkgs/matlab-7.8
+30c31,32
+< CHACO =         ../../Chaco-2.0/code
+---
+> #CHACO =         ../../Chaco-2.0/code
+> CHACO =         ../../../chaco/src/code
+34,35c36,37
+< #CC =            gcc 
+< CC =            cc 
+---
+> CC =            gcc 
+> #CC =            cc 
+37,40c39,46
+< CFLAGS =        -Xa -G -xO4 -xcg92
+< OFLAGS =        -xO4 -xcg92
+< AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+< RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+---
+> #CFLAGS =        -Xa -G -xO4 -xcg92
+> CFLAGS =        -fPIC -fno-omit-frame-pointer -pthread -fexceptions -DMATLAB
+> #OFLAGS =        -xO4 -xcg92
+> OFLAGS =        -O2
+> #AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+> AR =             /usr/bin/ar rcv
+> #RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+> RANLIB =         /usr/bin/ranlib
+45,47d50
+< 		${MLCHACO}/chaco_check_graph.c \
+< 		${MLCHACO}/check_input.c \
+<                 ${MLCHACO}/smalloc.c \
+48a52,54
+> #		${MLCHACO}/chaco_check_graph.c \
+> #		${MLCHACO}/check_input.c \
+> #                ${MLCHACO}/smalloc.c \
+55a62
+> 		${CHACO}/input/check_input.c \
+61a69
+> 		${CHACO}/graph/check_graph.c \
+91a100
+> 		${CHACO}/klvspiff/flow.c \
+97a107
+> 		${CHACO}/klvspiff/flatten.c \
+100c110,111
+< 		${CHACO}/coarsen/makecgraph.c \
+---
+> 		${CHACO}/coarsen/makefgraph.c \
+> 		${CHACO}/coarsen/makeccoords.c \
+102d112
+< 		${CHACO}/coarsen/countcedges.c \
+108a119
+> 		${CHACO}/coarsen/maxmatch5.c \
+234a246
+> 		${CHACO}/util/smalloc.c \
+245a258,259
+> #		${CHACO}/main/user_params.c \
+> #		${CHACO}/util/bail.c \
+254a269,272
+> #mlchaco:	${MLFILES.c} chaco.a Makefile
+> #		mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+> #		mv mlchaco.mex* ${DEST_DIR}
+> 
+256c274
+< 		mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+---
+> 		mex -output mlchaco -largeArrayDims -DMATLAB ${MLFILES.c} chaco.a -I${CHACO}/main
Index: /issm/trunk/externalpackages/meshpart/chaco.m.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/chaco.m.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/chaco.m.patch	(revision 2975)
@@ -0,0 +1,5 @@
+145c145,146
+<     vwgts = full(Adiag);
+---
+> %     vwgts = full(Adiag);
+>     vwgts = full(diag(A));
Index: /issm/trunk/externalpackages/meshpart/fiedler.m.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/fiedler.m.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/fiedler.m.patch	(revision 2975)
@@ -0,0 +1,8 @@
+61c61,65
+<     p = symmmd(L);
+---
+>     if exist('symamd')
+>         p = symamd(L);
+>     else
+>         p = symmmd(L);
+>     end
Index: /issm/trunk/externalpackages/meshpart/install.sh
===================================================================
--- /issm/trunk/externalpackages/meshpart/install.sh	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/install.sh	(revision 2975)
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf meshpart
+rm -rf src 
+rm -rf install 
+
+#Create src and install directories
+mkdir src install 
+
+#Untar 
+tar -xvzf meshpart-020208.tar.gz
+mkdir meshpart/metis
+tar -xvzf metismex-4.0.tar.gz -C meshpart/metis
+
+#Move meshpart to src directory
+mv meshpart/* src
+rm -rf meshpart
+
+#Apply patches
+patch src/fiedler.m fiedler.m.patch
+patch src/chaco.m chaco.m.patch
+patch src/meshdemo.m meshdemo.m.patch
+patch src/metis/metismex.c metismex.c.patch
+patch src/chaco/mlchaco.c mlchaco.c.patch
+patch src/chaco/Makefile Makefile.patch
+
+#Nothing to build for meshpart itself
+
+#Build metismex
+cd src/metis
+#proto.h in metis library is not patched, at least for metismex, so create a local version
+#mex -I../../../metis/install/Lib -L../../../metis/install -lmetis -largeArrayDims metismex.c
+cp ../../../metis/install/Lib/proto.h .
+patch proto.h ../../proto.h.patch
+mex -I. -I../../../metis/install/Lib -L../../../metis/install -lmetis -largeArrayDims metismex.c
+cd ../..
+
+#Build mlchaco
+cd src/chaco
+make
+#Clean up, specifically the objects left in the chaco directories by mlchaco
+make clean
+cd ../..
+
Index: /issm/trunk/externalpackages/meshpart/meshdemo.m.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/meshdemo.m.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/meshdemo.m.patch	(revision 2975)
@@ -0,0 +1,4 @@
+100c100
+< usechaco = 0;
+---
+> usechaco = 1;
Index: /issm/trunk/externalpackages/meshpart/metismex.c.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/metismex.c.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/metismex.c.patch	(revision 2975)
@@ -0,0 +1,6 @@
+95c95,97
+<     int i, j, jbar, n, nnz, *jc, *ir;
+---
+> /*    int i, j, jbar, n, nnz, *jc, *ir;*/
+>     int i, j, jbar, n, nnz;
+>     mwIndex *jc, *ir;
Index: /issm/trunk/externalpackages/meshpart/mlchaco.c.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/mlchaco.c.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/mlchaco.c.patch	(revision 2975)
@@ -0,0 +1,57 @@
+34a35
+> #include <time.h>      /*  CLOCKS_PER_SEC  */
+56,61c57,62
+< void mexFunction(    
+<     int         nlhs,           /* number of expected outputs */
+<     Matrix      *plhs[],        /* matrix pointer array returning outputs */
+<     int         nrhs,           /* number of inputs */
+<     Matrix      *prhs[]         /* matrix pointer array for inputs */
+<     )
+---
+> void mexFunction(
+>     int           nlhs,           /* number of expected outputs */
+>     mxArray       *plhs[],        /* array of pointers to output arguments */
+>     int           nrhs,           /* number of inputs */
+>     const mxArray *prhs[]         /* array of pointers to input arguments */
+> )
+87a89
+>     mwIndex *mwstart,*mwadjacency;
+104c106,110
+<     start = mxGetJc(A_in);
+---
+> /*    start = mxGetJc(A_in);*/
+>     mwstart = mxGetJc(A_in);
+>     start = mxMalloc((mxGetN(A_in)+1)*sizeof(int));
+>     for (i=0; i<(mxGetN(A_in)+1); i++)
+>         start[i]= (int)mwstart[i];
+106c112,116
+<     adjacency = mxGetIr(A_in);
+---
+> /*    adjacency = mxGetIr(A_in);*/
+>     mwadjacency = mxGetIr(A_in);
+>     adjacency = mxMalloc(mxGetNzmax(A_in)*sizeof(int));
+>     for (i=0; i<mxGetNzmax(A_in); i++)
+>         adjacency[i]= (int)mwadjacency[i];
+131,132c141,144
+<     outassignname = NULL;
+<     outfilename = NULL;
+---
+> /*    outassignname = NULL;
+>     outfilename = NULL;*/
+>     outassignname = "chaco_assign.txt";
+>     outfilename = "chaco_out.txt";
+169c181
+< 	plhs [1] = mxCreateFull (1, 1, REAL) ;
+---
+> 	plhs [1] = mxCreateDoubleMatrix (1, 1, mxREAL) ;
+173c185
+< 	((double) CLK_TCK) ;
+---
+> 	((double) CLOCKS_PER_SEC) ;
+179c191
+<         map_out = mxCreateFull(1,nvtxs,REAL);
+---
+>         map_out = mxCreateDoubleMatrix(1,nvtxs,mxREAL);
+185a198,199
+>     if (start != NULL) mxFree((char *) start);
+>     if (adjacency != NULL) mxFree((char *) adjacency);
Index: /issm/trunk/externalpackages/meshpart/proto.h.patch
===================================================================
--- /issm/trunk/externalpackages/meshpart/proto.h.patch	(revision 2975)
+++ /issm/trunk/externalpackages/meshpart/proto.h.patch	(revision 2975)
@@ -0,0 +1,13 @@
+233,234c233,237
+< extern "C" void METIS_PartMeshNodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);
+< extern "C" void METIS_PartMeshDual(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);
+---
+> /*extern "C" void METIS_PartMeshNodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);*/
+> /*extern "C" void METIS_PartMeshDual(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);*/
+> 
+> void METIS_PartMeshNodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);
+> void METIS_PartMeshDual(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *);
+462c465
+< int log2(int);
+---
+> /*int log2(int);*/
