Index: /issm/trunk/externalpackages/chaco/chaco.patch
===================================================================
--- /issm/trunk/externalpackages/chaco/chaco.patch	(revision 4626)
+++ /issm/trunk/externalpackages/chaco/chaco.patch	(revision 4627)
@@ -1,7 +1,5 @@
-Only in /home/jschierm/Libs/Chaco-2.2: chaco_jes_notes.txt
-Only in /home/jschierm/Libs/Chaco-2.2: chaco_README.txt
-diff -rc src/code/assign/assign_out.c /home/jschierm/Libs/Chaco-2.2/code/assign/assign_out.c
+diff -rc src/code/assign/assign_out.c new/code/assign/assign_out.c
 *** src/code/assign/assign_out.c	1995-08-08 14:32:10.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/assign/assign_out.c	2009-07-30 09:37:34.781348564 -0700
+--- new/code/assign/assign_out.c	2010-04-06 15:51:09.378194563 -0700
 ***************
 *** 3,8 ****
@@ -14,7 +12,7 @@
   static void assign_out_normal(), assign_out_inv();
   
-diff -rc src/code/eigen/get_extval.c /home/jschierm/Libs/Chaco-2.2/code/eigen/get_extval.c
+diff -rc src/code/eigen/get_extval.c new/code/eigen/get_extval.c
 *** src/code/eigen/get_extval.c	1995-08-08 14:32:20.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/eigen/get_extval.c	2009-07-30 09:43:00.511686903 -0700
+--- new/code/eigen/get_extval.c	2010-04-06 15:51:09.399194588 -0700
 ***************
 *** 4,9 ****
@@ -27,7 +25,7 @@
   /* Finds first extended eigenpair of system corresponding to
      tridiagonal T using using Rafael's bisection technique. */
-diff -rc src/code/klvspiff/matching.c /home/jschierm/Libs/Chaco-2.2/code/klvspiff/matching.c
+diff -rc src/code/klvspiff/matching.c new/code/klvspiff/matching.c
 *** src/code/klvspiff/matching.c	1996-03-11 10:24:25.000000000 -0800
---- /home/jschierm/Libs/Chaco-2.2/code/klvspiff/matching.c	2009-07-30 09:43:11.604702814 -0700
+--- new/code/klvspiff/matching.c	2010-04-06 15:51:09.424194619 -0700
 ***************
 *** 6,11 ****
@@ -40,10 +38,10 @@
   #define  TRUE  1
   #define  FALSE 0
-diff -rc src/code/main/defs.h /home/jschierm/Libs/Chaco-2.2/code/main/defs.h
+diff -rc src/code/main/defs.h new/code/main/defs.h
 *** src/code/main/defs.h	1995-08-08 14:32:41.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/main/defs.h	2009-08-25 10:02:57.088970763 -0700
+--- new/code/main/defs.h	2010-06-15 10:43:54.039227352 -0700
 ***************
 *** 9,11 ****
---- 9,27 ----
+--- 9,28 ----
   #define	PI	3.141592653589793
   #define	TWOPI	6.283185307179586
@@ -61,14 +59,14 @@
 +     #define realloc mxRealloc
 +     #define free mxFree
++ 	#define exit(status) mexErrMsgTxt("exit=" #status)
 + 
-+     #define check_graph chaco_check_graph
 + #endif
++ #define check_graph chaco_check_graph
 + 
-Only in /home/jschierm/Libs/Chaco-2.2/code/main: defs_old.h
-diff -rc src/code/Makefile /home/jschierm/Libs/Chaco-2.2/code/Makefile
+diff -rc src/code/Makefile new/code/Makefile
 *** src/code/Makefile	1997-10-02 10:23:22.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/Makefile	2010-02-10 14:05:56.986149785 -0800
-***************
-*** 2,8 ****
+--- new/code/Makefile	2010-06-15 10:35:41.507925761 -0700
+***************
+*** 2,9 ****
   DEST=		${DEST_DIR}/chaco
   CC = 		gcc
@@ -78,5 +76,6 @@
   
   FILES.c=	main/user_params.c main/interface.c main/main.c \
---- 2,13 ----
+  		submain/balance.c submain/divide.c submain/submain.c \
+--- 2,18 ----
   DEST=		${DEST_DIR}/chaco
   CC = 		gcc
@@ -89,10 +88,53 @@
 ! #CFLAGS =	-fPIC -fno-omit-frame-pointer -pthread -fexceptions -DMATLAB
   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
   
   FILES.c=	main/user_params.c main/interface.c main/main.c \
-Only in /home/jschierm/Libs/Chaco-2.2/code: Makefile_old
-diff -rc src/code/misc/timing.c /home/jschierm/Libs/Chaco-2.2/code/misc/timing.c
+  		submain/balance.c submain/divide.c submain/submain.c \
+***************
+*** 90,97 ****
+  FILES.o=	$(FILES.c:.c=.o) 
+  
+  
+! ${DEST}:	${FILES.o} Makefile
+! 		${CC} ${OFLAGS} ${FILES.o} -lm -o ${DEST}
+  
+  lint:
+  		lint ${IFLAG} ${FILES.c} -lm
+--- 99,109 ----
+  FILES.o=	$(FILES.c:.c=.o) 
+  
+  
+! ${DEST}:	${FILES.c} chaco.a Makefile
+! 		${CC} ${OFLAGS} chaco.a -lm -o ${DEST}
+! 
+! chaco.a:	${FILES.o}
+! 		${AR} chaco.a ${FILES.o} ; ${RANLIB} chaco.a
+  
+  lint:
+  		lint ${IFLAG} ${FILES.c} -lm
+***************
+*** 100,106 ****
+  		alint ${IFLAG} ${FILES.c} -lm
+  
+  clean:
+! 		rm -f */*.o ${DEST_DIR}/core
+  
+  .c.o:
+  		${CC} -c ${IFLAG} ${CFLAGS} -o $*.o $*.c
+--- 112,118 ----
+  		alint ${IFLAG} ${FILES.c} -lm
+  
+  clean:
+! 		rm -f */*.o ${DEST_DIR}/core
+  
+  .c.o:
+  		${CC} -c ${IFLAG} ${CFLAGS} -o $*.o $*.c
+diff -rc src/code/misc/timing.c new/code/misc/timing.c
 *** src/code/misc/timing.c	1997-01-03 09:10:52.000000000 -0800
---- /home/jschierm/Libs/Chaco-2.2/code/misc/timing.c	2009-07-30 09:43:19.954714766 -0700
+--- new/code/misc/timing.c	2010-04-06 15:51:09.480194687 -0700
 ***************
 *** 3,8 ****
@@ -105,7 +147,7 @@
   /* Timing parameters. */
   
-diff -rc src/code/util/bail.c /home/jschierm/Libs/Chaco-2.2/code/util/bail.c
+diff -rc src/code/util/bail.c new/code/util/bail.c
 *** src/code/util/bail.c	1995-08-08 14:33:01.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/util/bail.c	2009-07-30 09:43:24.495721262 -0700
+--- new/code/util/bail.c	2010-05-27 10:29:34.698534832 -0700
 ***************
 *** 4,9 ****
@@ -118,7 +160,18 @@
   /* Wrapper for exit() - print message and exit with status code. Exit code
      of 0 indicates normal termination. Exit code of 1 indicates early 
-diff -rc src/code/util/checkpnt.c /home/jschierm/Libs/Chaco-2.2/code/util/checkpnt.c
+***************
+*** 14,20 ****
+  int       status;
+  {
+      extern FILE *Output_File;		/* Output file or NULL */
+-     void      exit();
+  
+      if (msg != NULL && (int) strlen(msg) > 0) {
+          printf("%s\n", msg);
+--- 15,20 ----
+Only in new/code/util: bail_old.c
+diff -rc src/code/util/checkpnt.c new/code/util/checkpnt.c
 *** src/code/util/checkpnt.c	1995-08-08 14:33:01.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/util/checkpnt.c	2009-07-30 09:43:28.190726549 -0700
+--- new/code/util/checkpnt.c	2010-04-06 15:51:09.513194728 -0700
 ***************
 *** 4,9 ****
@@ -131,7 +184,7 @@
   /* Debug break point. */
   void      checkpnt(tag)
-diff -rc src/code/util/doubleout.c /home/jschierm/Libs/Chaco-2.2/code/util/doubleout.c
+diff -rc src/code/util/doubleout.c new/code/util/doubleout.c
 *** src/code/util/doubleout.c	1995-08-08 14:33:02.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/util/doubleout.c	2009-07-30 09:43:34.192735135 -0700
+--- new/code/util/doubleout.c	2010-04-06 15:51:09.527194745 -0700
 ***************
 *** 3,8 ****
@@ -144,7 +197,7 @@
   /* Print a double precision number with filtering format to screen. */
   void      doubleout(number, mode)
-diff -rc src/code/util/smalloc.c /home/jschierm/Libs/Chaco-2.2/code/util/smalloc.c
+diff -rc src/code/util/smalloc.c new/code/util/smalloc.c
 *** src/code/util/smalloc.c	1996-03-11 10:44:07.000000000 -0800
---- /home/jschierm/Libs/Chaco-2.2/code/util/smalloc.c	2009-07-30 09:43:39.722743047 -0700
+--- new/code/util/smalloc.c	2010-04-06 15:51:09.542194763 -0700
 ***************
 *** 4,9 ****
@@ -157,7 +210,7 @@
   static int nmalloc = 0;		/* number of calls to malloc */
   static int nfree = 0;		/* number of calls to free */
-diff -rc src/code/util/strout.c /home/jschierm/Libs/Chaco-2.2/code/util/strout.c
+diff -rc src/code/util/strout.c new/code/util/strout.c
 *** src/code/util/strout.c	1995-08-08 14:33:05.000000000 -0700
---- /home/jschierm/Libs/Chaco-2.2/code/util/strout.c	2009-07-30 09:43:47.607754325 -0700
+--- new/code/util/strout.c	2010-04-06 15:51:09.549194772 -0700
 ***************
 *** 4,9 ****
@@ -170,2 +223,3 @@
   /* Wrapper for a printf statement with a string as only arg.
      Prints to screen and to output file if there is one. */
+Only in new/exec: chaco
Index: /issm/trunk/externalpackages/chaco/chaco_jes_notes.txt
===================================================================
--- /issm/trunk/externalpackages/chaco/chaco_jes_notes.txt	(revision 4626)
+++ /issm/trunk/externalpackages/chaco/chaco_jes_notes.txt	(revision 4627)
@@ -80,2 +80,7 @@
 > 
 
+6/15/10:
+
+- moved check_graph rename outside of MATLAB compiler directive.
+- created library chaco.a (without MATLAB compiler directive) for Chaco x-layer to link and implemented it in chaco stand-alone link.
+
Index: /issm/trunk/externalpackages/chaco/install.sh
===================================================================
--- /issm/trunk/externalpackages/chaco/install.sh	(revision 4626)
+++ /issm/trunk/externalpackages/chaco/install.sh	(revision 4627)
@@ -23,5 +23,5 @@
 cd src/code
 make
-# Clean up, so that meshpart creates its own objects for mlchaco
+# Clean up objects (but not library or executable)
 make clean
 cd ../..
Index: /issm/trunk/externalpackages/chaco/mex/Chaco.c
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/Chaco.c	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/Chaco.c	(revision 4627)
@@ -0,0 +1,244 @@
+
+#include <stdio.h>
+#include <string.h>    /*  strcasecmp  */
+#include <time.h>      /*  clock,time,difftime  */
+#include "mex.h"
+
+
+#define THISFUNCTION "Chaco"
+
+/* Input Arguments */
+
+#define    A_IN         prhs[0]
+#define    VWGTS_IN     prhs[1]
+#define    EWGTS_IN     prhs[2]
+#define    XYZ_IN       prhs[3]
+#define    OPTNS_IN     prhs[4]
+#define    NPARTS_IN    prhs[5]
+#define    GOAL_IN      prhs[6]
+
+/* Output Arguments */
+
+#define    ASSGN_OUT    plhs[0]
+
+
+void ChacoUsage( void );
+
+int Chacox(
+    int       nvtxs,		/* number of vertices in graph */
+    int      *start,		/* start of edge list for each vertex */
+    int      *adjacency,	/* edge list data */
+    int      *vwgts,		/* weights for all vertices */
+    float    *ewgts,		/* weights for all edges */
+    float    *x,
+    float    *y,
+    float    *z,			/* coordinates for inertial method */
+    short    *assignment,	/* set number of each vtx (length nvtxs+1) */
+    double   options[10],	/* architecture and partitioning options */
+    int      *nparts,		/* number of parts options */
+    double   *goal			/* desired set sizes */
+);
+
+
+void mexFunction(
+	int           nlhs,           /* number of outputs */
+	mxArray       *plhs[],        /* array of pointers to output arguments */
+	int           nrhs,           /* number of inputs */
+	const mxArray *prhs[]         /* array of pointers to input arguments */
+)
+{
+    int       nvtxs;		/* number of vertices in graph */
+    int      *start;		/* start of edge list for each vertex */
+    int      *adjacency;	/* edge list data */
+    int      *vwgts=NULL;	/* weights for all vertices */
+    float    *ewgts=NULL;	/* weights for all edges */
+    float    *x=NULL;
+    float    *y=NULL;
+    float    *z=NULL;		/* coordinates for inertial method */
+    short    *assignment=NULL;	/* set number of each vtx (length nvtxs+1) */
+    double   options[10]={1,1,0,0,1,1,50,0,.001,7654321};
+							/* architecture and partitioning options */
+    int      *nparts=NULL;	/* number of parts options */
+    double   *goal=NULL;	/* desired set sizes */
+
+	int    i, nedges, nterms, ncols, ierr=0;
+	double *p;
+	mwIndex *mwstart, *mwadjacency;
+
+	clock_t clock0,clock1;
+	time_t  time0, time1;
+
+	/* Check for proper number of arguments */
+
+	if      (nrhs == 0 && nlhs == 0) {
+		ChacoUsage();
+		return;
+	}
+	else if (nrhs <  1 || nlhs >  1) {
+		ChacoUsage();
+		mexErrMsgTxt(" ");
+	}
+
+	clock0=clock();
+	time0 =time(NULL);
+	mexPrintf("\nChaco Module -- %s",ctime(&time0));
+
+	/* Assign pointers to the various parameters */
+	/* and convert to the appropriate format for Chaco */
+
+	if (!mxIsEmpty(A_IN) && mxIsNumeric(A_IN) && mxIsSparse(A_IN)) {
+		nvtxs = mxGetN(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];
+		nedges = start[nvtxs];
+		mwadjacency = mxGetIr(A_IN);
+		adjacency = mxMalloc(mxGetNzmax(A_IN)*sizeof(int));
+		for (i=0; i<mxGetNzmax(A_IN); i++)
+			adjacency[i]= (int)mwadjacency[i];
+	}
+	else {
+		mexPrintf("%s -- Adjacency matrix must be numeric and sparse.\n",
+				  THISFUNCTION);
+		mexErrMsgTxt(" ");
+	}
+
+	if (nrhs >= 2 && !mxIsEmpty(VWGTS_IN)) {
+		if (mxIsNumeric(VWGTS_IN) && !mxIsSparse(VWGTS_IN) &&
+			(nterms=mxGetM(VWGTS_IN)*mxGetN(VWGTS_IN)) == nvtxs) {
+			vwgts = (int *) mxCalloc(nvtxs, sizeof(int));
+			p = mxGetPr(VWGTS_IN);
+			for (i = 0; i < nvtxs; vwgts[i++] = (int) *p++);
+		}
+		else {
+			mexPrintf("%s -- Vertex weight vector must be numeric, full, and length=%d.\n",
+					  THISFUNCTION,nvtxs);
+			mexErrMsgTxt(" ");
+		}
+	}
+
+	if (nrhs >= 3 && !mxIsEmpty(EWGTS_IN)) {
+		if (mxIsNumeric(EWGTS_IN) && mxIsSparse(EWGTS_IN) &&
+			(nterms=mxGetNzmax(EWGTS_IN)) == nedges) {
+			ewgts = (float *) mxCalloc(nedges, sizeof(float));
+			p = mxGetPr(A_IN);
+			for (i = 0; i < nedges; ewgts[i++] = (float) *p++);
+		}
+		else {
+			mexPrintf("%s -- Edge weight matrix must be numeric, sparse, and nonzeroes=%d.\n",
+					  THISFUNCTION,nedges);
+			mexErrMsgTxt(" ");
+		}
+	}
+
+	if (nrhs >= 4 && (ncols = mxGetN(XYZ_IN)) >= 1) {
+		if (mxIsNumeric(XYZ_IN) && !mxIsSparse(XYZ_IN) &&
+			mxGetM(XYZ_IN) == nvtxs) {
+			x = (float *) mxCalloc(nvtxs, sizeof(float));
+			p = mxGetPr(XYZ_IN);
+			for (i = 0; i < nvtxs; x[i++] = (float) *p++);
+		}
+		else {
+			mexPrintf("%s -- XYZ coordinate matrix must be numeric, full, and length=%d.\n",
+					  THISFUNCTION,nvtxs);
+			mexErrMsgTxt(" ");
+		}
+		if ((ncols                 ) >= 2) {
+			y = (float *) mxCalloc(nvtxs, sizeof(float));
+			for (i = 0; i < nvtxs; y[i++] = (float) *p++);
+			if ((ncols                 ) >= 3) {
+				z = (float *) mxCalloc(nvtxs, sizeof(float));
+				for (i = 0; i < nvtxs; z[i++] = (float) *p++);
+			}
+		}
+	}
+
+	if (nrhs >= 5 && !mxIsEmpty(OPTNS_IN)) {
+		if (mxIsNumeric(OPTNS_IN) && !mxIsSparse(OPTNS_IN) &&
+			(nterms=mxGetM(OPTNS_IN)*mxGetN(OPTNS_IN))) {
+			p = mxGetPr(OPTNS_IN);
+			for (i = 0; i < (nterms<10 ? nterms : 10); options[i++] = *p++);
+		}
+		else {
+			mexPrintf("%s -- Options vector must be numeric and full.\n",
+					  THISFUNCTION);
+			mexErrMsgTxt(" ");
+		}
+	}
+
+	if (nrhs >= 6 && !mxIsEmpty(NPARTS_IN)) {
+		if (mxIsNumeric(NPARTS_IN) && !mxIsSparse(NPARTS_IN) &&
+			(nterms=mxGetM(NPARTS_IN)*mxGetN(NPARTS_IN))) {
+			nparts = (int *) mxCalloc(nterms, sizeof(int));
+			p = mxGetPr(NPARTS_IN);
+			for (i = 0; i < nterms; nparts[i++] = (int) *p++);
+		}
+		else {
+			mexPrintf("%s -- Parts vector must be numeric and full.\n",
+					  THISFUNCTION);
+			mexErrMsgTxt(" ");
+		}
+	}
+
+	if (nrhs >= 7 && !mxIsEmpty(GOAL_IN)) {
+		if (mxIsNumeric(GOAL_IN) && !mxIsSparse(GOAL_IN) &&
+			(nterms=mxGetM(GOAL_IN)*mxGetN(GOAL_IN))) {
+			goal = (double *) mxCalloc(nterms, sizeof(double));
+			p = mxGetPr(GOAL_IN);
+			for (i = 0; i < nterms; goal[i++] = *p++);
+		}
+		else {
+			mexPrintf("%s -- Goal vector must be numeric and full.\n",
+					  THISFUNCTION);
+			mexErrMsgTxt(" ");
+		}
+	}
+
+	assignment = (short *) mxCalloc(nvtxs, sizeof(short));
+
+    /* Do the actual computations in a subroutine */
+
+	ierr = Chacox(nvtxs, start, adjacency, vwgts, ewgts, x, y, z,
+		assignment, options, nparts, goal);
+
+    /* Create matrices for the return arguments */
+
+	if (!ierr) {
+		ASSGN_OUT = mxCreateDoubleMatrix(1,nvtxs,mxREAL);
+		p = mxGetPr(ASSGN_OUT);
+		for (i = 0; i < nvtxs; *p++ = (double) assignment[i++]);
+	}
+	else
+		ASSGN_OUT = mxCreateDoubleMatrix(0,0,mxREAL);
+
+	/* Free what we allocated */
+   
+	if (!assignment) mxFree((void *) assignment);
+	if (!goal)       mxFree((void *) goal);
+	if (!nparts)     mxFree((void *) nparts);
+	if (!z)          mxFree((void *) z);
+	if (!y)          mxFree((void *) y);
+	if (!x)          mxFree((void *) x);
+	if (!ewgts)      mxFree((void *) ewgts);
+	if (!vwgts)      mxFree((void *) vwgts);
+	if (!adjacency)  mxFree((void *) adjacency);
+	if (!start)      mxFree((void *) start);
+
+    clock1=clock();
+    time1 =time(NULL);
+    mexPrintf("Chaco Module -- %f CPU seconds; %f elapsed seconds.\n\n",
+              ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
+
+	return;
+}
+
+void ChacoUsage( void )
+{
+	mexPrintf("\n");
+	mexPrintf("Usage: [assgn] = Chaco(A,vwgts,ewgts,xyz,options,nparts,goal);\n");
+	mexPrintf("\n");
+
+	return;
+}
+
Index: /issm/trunk/externalpackages/chaco/mex/Chaco_m.m
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/Chaco_m.m	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/Chaco_m.m	(revision 4627)
@@ -0,0 +1,217 @@
+function  [part1,part2,chaco_time] = chaco(A,xy,method,nparts,goal)
+% CHACO : Hendrickson/Leland's graph partitioner.
+% 
+%  [part1,part2,chaco_time] = chaco(A) returns a 50/50 vertex partition of the mesh
+%  whose symmetric adjacency matrix is A.  
+%
+%  Optional arguments:
+%  map = chaco(A, xy, method, nparts, goal);
+%  map = chaco(A, xy, method, inmap, goal);
+%
+%  A:          Depending on "method", A may contain vertex and edge weights.
+%
+%  xy:         Each row of xy is the coordinates of a vertex.
+%              If xy is non-null and there is no output, draw a picture.
+%
+%  method:     Scalar or vector describing the desired method.  
+%              Default is multilevel Kernighan-Lin; other possibilities below.
+%
+%  nparts      Number of parts to divide into.  Default is 2.  If nparts is 
+%    or        present, the output is a "map vector", see below.  (If method(5) 
+%  inmap:      is specified, nparts is interpreted differently; see below.  In
+%              any case, the default is to divide into two parts.)
+%              If method(1) = 7 (see below), this argument is a map vector
+%              specifying an initial 2-way partition, and Chaco refines it.
+%
+%  goal:       Optionally, a vector of desired sizes (or total vertex weights)
+%              for each of the nparts parts.  Default is all sizes equal.
+%
+%  map:        If nparts and inmap are not present, the output is a vector of 
+%              the n/2 vertex numbers in one part of the 2-way partition, for
+%              compatibility with geopart and specpart.
+%              If nparts or imap is present, the output is a vector of the
+%              n part numbers, from 0 to nparts-1, assigned to the vertices.
+%
+% This is a Matlab interface to the graph partitioning software described
+% in B. Hendrickson and R. Leland, "The Chaco User's Guide (Version 2.0)",
+% Sandia National Laboratories report SAND94-2692, October 1994.
+% This interface was written by John Gilbert, Xerox PARC, and is
+% Copyright (c) 1994-1996 by Xerox Corporation.  All rights reserved.
+% HELP COPYRIGHT for complete copyright and licensing notice.
+%
+% Modified by Tim Davis, for Matlab 5.1.  July 6, 1998.
+%   05/28/10    jes    Reorganization into Matlab-layer and x-layer.
+%
+% See also GEOPART, SPECPART.
+%
+% "method" is a vector of flags as follows.  Not all combinations are supported.
+% See Section 6.10 of the Chaco manual for more details on all the arguments.
+% If "method" is shorter than 10, we use the defaults for unspecified entries.
+%
+% method(1):  Global partitioning method  ("global_method" in the Chaco manual).
+%             1 Multilevel Kernighan-Lin (default)
+%             2 Spectral
+%             3 Inertial
+%             4 Linear
+%             5 Random
+%             6 Scattered
+%             7 Use "inmap" as the global (2-way) partition
+%
+% method(2):  Local refinement method  ("local_method" in the Chaco manual).
+%             1 Kernighan-Lin (default)
+%             2 None
+%
+% method(3):  Vertex weighting.
+%             0 No weights (default)
+%             1 Use diag(A) as (positive integer) vertex weights
+%
+% method(4):  Edge weighting.
+%             0 No weights (default)
+%             1 Use off-diagonals of A as (positive integer) edge weights
+%
+% method(5):  Target architecture  ("architecture" in the Chaco manual).
+%             If method(5) = 0, the target is a hypercube, "nparts" is the 
+%             number of dimensions, and the partition is into 2^nparts parts.  
+%             If method(5) = 1, 2, or 3, the target is a 1-, 2-, or 3-D grid,
+%             "nparts" is a vector of the sizes of the grid in each dimension,
+%             and the partition is into prod(nparts) parts.
+%             Default is method(5) = 1, so nparts is the number of parts.
+%
+% method(6):  Partitioning dimension  ("ndims" in the Chaco manual).
+%             1 Bisection (default)
+%             2 Quadrisection
+%             3 Octasection
+%
+% method(7):  Number of vertices to coarsen to  ("vmax" in the Chaco manual).
+%             Default is 50.
+%
+% method(8):  Eigensolver  ("rqi_flag" in the Chaco manual).
+%             0 RQI/Symmlq (default)
+%             1 Lanczos 
+%
+% method(9):  Eigensolver convergence tolerance  ("eigtol" in the Chaco manual).
+%             Default is .001
+%
+% method(10): Seed for random number generator  ("seed" in the Chaco manual).
+%             Default is 7654321.
+%
+% Many esoteric details of Chaco's behavior can be changed by placing a file
+% called "User_Params" in the same directory as the executable mlchaco.mex.
+% As always, see the manual for details.
+
+DefaultMethod = [1 1 0 0 1 1 50 0 .001 7654321];
+
+% Fill in default arguments.
+if nargin < 2, xy = []; end;
+if nargin < 3, method = DefaultMethod; end;
+if nargin < 4, nparts = []; end;
+if nargin < 5, goal = []; end;
+if length(method) < length(DefaultMethod)
+    method = [method DefaultMethod(length(method)+1 : length(DefaultMethod))];
+end;
+
+% Decide on output and graphics.
+if (isempty (nparts))
+    mapvector = 0;
+else
+    mapvector = 1;
+end;
+picture = (nargout == 0) & (size(xy,2) >= 2);
+
+% Chaco numbers vertices from 1 and the Matlab sparse data structure 
+% numbers rows from 0, so we add an empty first row to make things line up.
+% This code also makes sure the arg to Chaco will be sparse.
+[n,n] = size(A);
+Adiag = diag(diag(A));
+%Aout = [sparse(1,n) ; A-Adiag];
+Aout = sparse(A-Adiag);
+
+% Make sure all args except the adj matrix are full;
+if issparse(xy)
+    xy = full(xy);
+end;
+if issparse(method)
+    method = full(method);
+end;
+if issparse(nparts)
+    nparts = full(nparts);
+end;
+if issparse(goal)
+    goal = full(goal);
+end;
+
+% Decode "method" to get the actual args to Chaco.
+% Note that "nparts" may correspond to any of several Chaco
+% parameters, depending on the method.
+
+if method(3)
+    vwgts = full(diag(A));
+    totalvwgt = sum(vwgts);
+else
+    vwgts = [];
+    totalvwgt = size(A,2);
+end;
+if method(4)
+    ewgts = Aout;
+else
+    ewgts = [];
+end;
+if method(1) == 7
+    % Refine an input partition: "nparts" is the input partition.
+    % This seems to work only for hypercube architecture,
+    % so we force a 1-D hypercube with 2-way partitioning.
+    nsets = 2;
+elseif method(5) == 0
+    % Partition for hypercube: "nparts" is # of dimensions (default 1).
+    if (isempty (nparts))
+    	nsets = 2^1;
+    else
+    	nsets = 2^nparts;
+    end;
+else
+    % Partition for mesh: "nparts" is vector of mesh sizes in each
+    % dimension, default [2 1 ... 1] with "architecture" dimensions.
+    if (isempty (nparts))
+    	nsets = prod(2);
+    else
+    	nsets = prod(nparts);
+    end;
+end;
+if length(goal) ~= nsets
+    goal = totalvwgt/nsets * ones(1,nsets);
+end;
+
+[map,chaco_time]=Chaco(Aout, vwgts, ewgts, xy, method, nparts, goal);
+
+% Draw the picture.
+if picture
+    if size(xy,2) >= 3 && unique(xy(:,3)) == 0
+        xy=xy(:,1:2);
+    end
+    if length(unique(map)) == 2
+        gplotpart(A,xy,find(map==0));
+    else
+        gplotmap(A,xy,map);
+    end;
+    if     method(1)==1, heading = 'Multilevel Kernighan-Lin';
+    elseif method(1)==2, heading = 'Spectral';
+    elseif method(1)==3, heading = 'Inertial';
+    elseif method(1)==4, heading = 'Linear';
+    elseif method(1)==5, heading = 'Random';
+    elseif method(1)==6, heading = 'Scattered';
+    elseif method(1)==7, heading = 'Input'; 
+    end;
+    heading = [heading ' Partition'];
+    if method(2)==1 & method(1) ~= 1 
+        heading =[heading ' Refined by KL'];
+    end;
+    title(heading);
+end;
+
+% Put output in the right form.
+if mapvector
+    part1 = map;
+else
+    part1 = find(map==0);
+    part2 = find(map==1);
+end;
Index: /issm/trunk/externalpackages/chaco/mex/Chacox.c
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/Chacox.c	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/Chacox.c	(revision 4627)
@@ -0,0 +1,471 @@
+/* This software was developed by Bruce Hendrickson and Robert Leland   *
+ * at Sandia National Laboratories under US Department of Energy        *
+ * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
+
+#include <stdio.h>
+#include <string.h>
+#include "defs.h"
+#include "params.h"
+
+#define THISFUNCTION "Chacox"
+
+#define    OPT_GLOBAL    0
+#define    OPT_LOCAL     1
+#define    OPT_VWGTS     2
+#define    OPT_EWGTS     3
+#define    OPT_ARCH      4
+#define    OPT_NDIMS     5
+#define    OPT_VMAX      6
+#define    OPT_RQI       7
+#define    OPT_EIGTOL    8
+#define    OPT_SEED      9
+
+int      input_parse(
+	char     *outassignname,	/* name of assignment output file */
+	char     *outfilename,		/* name of file for outputing run results */
+	int      *architecture,		/* 0=> hypercube, d=> d-dimensional mesh */
+	int      *ndims_tot,		/* target number of hypercube dimensions */
+	int       mesh_dims[3],		/* mesh dimensions */
+	int      *global_method,	/* what global partitioning strategy to use? */
+	int      *local_method,		/* what local refinement strategy to use? */
+	int      *rqi_flag,		/* should I use multilevel eigensolver? */
+	int      *vmax,			/* if so, how far should I coarsen? */
+	int      *ndims,		/* number of divisions at each stage */
+	int      *nprocs,		/* number of processors being divided into */
+	double   options[10],	/* architecture and partitioning options */
+	int      *nparts		/* number of parts options */
+);
+
+
+int Chacox(
+	int       nvtxs,		/* number of vertices in graph */
+	int      *start,		/* start of edge list for each vertex */
+	int      *adjacency,	/* edge list data */
+	int      *vwgts,		/* weights for all vertices */
+	float    *ewgts,		/* weights for all edges */
+	float    *x,
+	float    *y,
+	float    *z,			/* coordinates for inertial method */
+	short    *assignment,	/* set number of each vtx (length nvtxs+1) */
+	double   options[10],	/* architecture and partitioning options */
+	int      *nparts,		/* number of parts options */
+	double   *goal			/* desired set sizes */
+)
+{
+	extern int Using_Main;	/* is main routine being called? */
+	extern char *PARAMS_FILENAME;	/* name of file with parameter updates */
+	extern double EIGEN_TOLERANCE;	/* tolerance for eigen calculations */
+	extern int OUTPUT_ASSIGN;	/* whether to write assignment to file */
+	extern int DEBUG_MEMORY;	/* debug memory allocation and freeing? */
+	extern int DEBUG_TRACE;	/* trace main execution path */
+	extern int DEBUG_PARAMS;	/* debug flag for reading parameters */
+	extern long RANDOM_SEED;	/* seed for random number generators */
+	extern int ECHO;		/* controls amount of output */
+	extern int PROMPT;		/* prompt for input or not? */
+	extern int PRINT_HEADERS;	/* print lines for output sections? */
+	extern int MATCH_TYPE;      /* matching routine to call */
+	extern double input_time;	/* times data file input */
+	extern double start_time;	/* time partitioning starts */
+	FILE     *params_file;	/* file with parameter value updates */
+	int       global_method;	/* global partitioning method */
+	int       local_method;	/* local partitioning method */
+	double    eigtol;		/* tolerance in eigenvector calculation */
+	int       ndims;		/* dimension of recursive partitioning */
+	int       architecture;	/* 0 => hypercube, d => d-dimensional mesh */
+	int       ndims_tot;	/* total number of cube dimensions to divide */
+	int       mesh_dims[3];	/* dimensions of mesh of processors */
+	long      seed;		/* for random graph mutations */
+	int       rqi_flag;		/* use RQI/Symmlq eigensolver? */
+	int       vmax;		/* if so, how many vertices to coarsen down to? */
+	char      outassignname[NAME_LENGTH];	/* assignment output file name */
+	char      outfilename[NAME_LENGTH];	/* name of output file */
+	char     *outassignptr;	/* name or null pointer for output assignment */
+	char     *outfileptr;	/* name or null pointer for output file */
+	int       nprocs;		/* number of processors being divided into */
+	double    time;		/* timing marker */
+	int       flag;		/* return code from input routines */
+	double   *smalloc();	/* safe version of malloc */
+	double    seconds();	/* returns elapsed time in seconds */
+	int       sfree(), interface(), affirm();
+	void      input_queries(), smalloc_stats(), read_params(), clear_timing();
+
+	int i,tvwgt;
+	double tgoal;
+
+	if (DEBUG_TRACE > 0) {
+		printf("<Entering main>\n");
+	}
+
+	if (PRINT_HEADERS) {
+		printf("\n                    Chaco 2.0\n");
+		printf("          Sandia National Laboratories\n\n");
+	}
+
+	Using_Main = TRUE;
+	params_file = fopen(PARAMS_FILENAME, "r");
+	if (params_file == NULL && DEBUG_PARAMS > 1) {
+		printf("Parameter file `%s' not found; using default parameters.\n",
+			   PARAMS_FILENAME);
+	}
+
+	start_time = time = seconds();
+
+	read_params(params_file);
+
+	flag = input_parse(outassignname, outfilename,
+			  &architecture, &ndims_tot, mesh_dims,
+			  &global_method, &local_method, &rqi_flag, &vmax, &ndims, &nprocs,
+			  options, nparts);
+	if (flag)
+		return(flag);
+
+	if (OUTPUT_ASSIGN > 0)
+		outassignptr = outassignname;
+	else
+		outassignptr = NULL;
+
+	if (ECHO < 0)
+		outfileptr = outfilename;
+	else
+		outfileptr = NULL;
+
+	if ((int)options[OPT_VWGTS] && vwgts) {
+		printf("%s -- Applying weights for %d vertices.\n",
+			   THISFUNCTION,nvtxs);
+		tvwgt = 0.;
+		for (i=0; i<nvtxs; i++)
+			tvwgt += vwgts[i];
+	}
+	else {
+		tvwgt = nvtxs;
+		if      ( (int)options[OPT_VWGTS] && !vwgts)
+			printf("%s -- Vertex weight flag=%d, but no vertex weights specified.\n",
+				   THISFUNCTION,options[OPT_VWGTS]);
+		else if (!(int)options[OPT_VWGTS] &&  vwgts)
+			printf("%s -- Vertex weight flag=%d, so specified vertex weights ignored.\n",
+				   THISFUNCTION,options[OPT_VWGTS]);
+	}
+
+	if ((int)options[OPT_EWGTS] && ewgts) {
+		printf("%s -- Applying weights for %d edges.\n",
+			   THISFUNCTION,start[nvtxs]/2);
+	}
+	else {
+		if      ( (int)options[OPT_EWGTS] && !ewgts)
+			printf("%s -- Edge weight flag=%d, but no edge weights specified.\n",
+				   THISFUNCTION,options[OPT_EWGTS]);
+		else if (!(int)options[OPT_EWGTS] &&  ewgts)
+			printf("%s -- Edge weight flag=%d, so specified edge weights ignored.\n",
+				   THISFUNCTION,options[OPT_EWGTS]);
+	}
+
+    if (goal) {
+        printf("%s -- Applying goals for %d sets.\n",
+               THISFUNCTION,nprocs);
+        tgoal = 0.;
+        for (i=0; i<nprocs; i++)
+            tgoal += goal[i];
+        for (i=0; i<nprocs; i++)
+            goal[i] *= (double)tvwgt/tgoal;
+    }
+
+	input_time += seconds() - time;
+
+	if (options[OPT_EIGTOL] > 0)
+		eigtol = options[OPT_EIGTOL];
+	else
+		eigtol = EIGEN_TOLERANCE;
+	if ((int)options[OPT_SEED] > 0)
+		seed = (int)options[OPT_SEED];
+	else
+		seed = RANDOM_SEED;
+
+/*  Chaco numbers vertices from 1 and the Matlab sparse data structure
+	numbers rows from 0, so increment the row indices for each column. */
+
+	for (i=0; i<start[nvtxs]; adjacency[i++]++);
+
+	printf("\n%s -- Calling Chaco interface:\n\n",
+		   THISFUNCTION);
+	flag = interface(nvtxs, start, adjacency,
+		  ((int)options[OPT_VWGTS] && vwgts ? vwgts : NULL),
+		  ((int)options[OPT_EWGTS] && ewgts ? ewgts : NULL),
+		  x, y, z,
+		  outassignptr, outfileptr,
+		  assignment,
+		  architecture, ndims_tot, mesh_dims, goal,
+		  global_method, local_method, rqi_flag, vmax, ndims,
+		  eigtol, seed);
+	printf("\n%s -- Chaco interface returning flag=%d.\n",
+		   THISFUNCTION,flag);
+
+/*  Reset adjacency matrix in case calling function needs it.  */
+
+	for (i=0; i<start[nvtxs]; adjacency[i++]--);
+
+	if (DEBUG_MEMORY > 0) {
+		printf("\n");
+		smalloc_stats();
+	}
+
+	if (params_file != NULL)
+		fclose(params_file);
+
+	if (DEBUG_TRACE > 1) {
+		printf("<Leaving main>\n");
+	}
+	
+	return(0);
+}
+
+
+int      input_parse(
+	char     *outassignname,	/* name of assignment output file */
+	char     *outfilename,		/* name of file for outputing run results */
+	int      *architecture,		/* 0=> hypercube, d=> d-dimensional mesh */
+	int      *ndims_tot,		/* target number of hypercube dimensions */
+	int       mesh_dims[3],		/* mesh dimensions */
+	int      *global_method,	/* what global partitioning strategy to use? */
+	int      *local_method,		/* what local refinement strategy to use? */
+	int      *rqi_flag,		/* should I use multilevel eigensolver? */
+	int      *vmax,			/* if so, how far should I coarsen? */
+	int      *ndims,		/* number of divisions at each stage */
+	int      *nprocs,		/* number of processors being divided into */
+	double   options[10],	/* architecture and partitioning options */
+	int      *nparts		/* number of parts options */
+)
+{
+	extern int SEQUENCE;	/* sequence instead of partition graph? */
+	extern int ARCHITECTURE;	/* 0=> hypercube, d=> d-dimensional mesh */
+	extern int OUTPUT_ASSIGN;	/* write assignments to file? */
+	extern int ECHO;		/* copy input to screen? results to file? */
+	extern int DEBUG_TRACE;	/* trace main execution path */
+	extern int PROMPT;		/* prompt for input? */
+	extern int MATCH_TYPE;      /* max-matching routine to call */
+	int       eigensolver;	/* which kind of eigensolver to use */
+
+	if (DEBUG_TRACE > 0) {
+		printf("<Entering input_parse>\n");
+	}
+
+	if (PROMPT) {
+		printf("Parallel machine architecture:\n");
+		printf("  (0) Hypercube\n");
+		printf("  (1) One-dimensional mesh\n");
+		printf("  (2) Two-dimensional mesh\n");
+		printf("  (3) Three-dimensional mesh\n");
+	}
+	*architecture = (int)options[OPT_ARCH];
+	if (*architecture < 0 || *architecture > 3) {
+		printf("%s -- Architecture %d must be between 0 and 3.\n",
+			   THISFUNCTION,options[OPT_ARCH]);
+		return(-1);
+	}
+
+	/* Name output assignment file. */
+	if (PROMPT)
+		printf("Assignment output file: ");
+	outassignname = NULL;
+
+	/* Name output results file. */
+	if (PROMPT)
+		printf("File name for saving run results: ");
+	outfilename = NULL;
+
+	/* Initialize the method flags */
+	*rqi_flag = 0;
+	*global_method = 0;
+
+	/* Get global method, if any. */
+	if (SEQUENCE) {
+		*global_method = 2;
+	}
+	else {
+		if (PROMPT) {
+			printf("Global partitioning method:\n");
+			printf("  (1) Multilevel-KL\n");
+			printf("  (2) Spectral\n");
+			printf("  (3) Inertial\n");
+			printf("  (4) Linear\n");
+			printf("  (5) Random\n");
+			printf("  (6) Scattered\n");
+			printf("  (7) Read-from-file\n");
+		}
+		*global_method = (int)options[OPT_GLOBAL];
+		if (*global_method < 1 || *global_method > 7) {
+			printf("%s -- Global method %d must be between 1 and 7.\n",
+				   THISFUNCTION,options[OPT_GLOBAL]);
+			return(-1);
+		}
+	}
+
+	if (*global_method == 7) {	/* Name and open input assignment file. */
+		if (PROMPT)
+			printf("Assignment input file: ");
+	}
+
+	else if (*global_method == 3) {
+		if (PROMPT)
+			printf("Geometry input file name: ");
+	}
+
+	else if (*global_method == 2) {
+		if (PROMPT) {
+			printf("Eigensolver:\n");
+			printf("  (1) Multilevel RQI/Symmlq\n");
+			printf("  (2) Lanczos\n"); 
+		}
+		eigensolver = (int)options[OPT_RQI];
+		if (eigensolver < 0 || eigensolver > 2) {
+			printf("%s -- RQI/Symmlq flag %d must be between 0 and 2.\n",
+				   THISFUNCTION,options[OPT_RQI]);
+			return(-1);
+		}
+		if (eigensolver == 1) {
+			if (MATCH_TYPE == 5) {	/* geometric matching */
+				if (PROMPT)
+					printf("Geometry input file name: ");
+			}
+			*rqi_flag = 1;
+			if (PROMPT)
+				printf("Number of vertices to coarsen down to: ");
+			*vmax = (int)options[OPT_VMAX];
+			if (*vmax <= 0) {
+				printf("%s -- Vmax %d must be greater then 0.\n",
+					   THISFUNCTION,options[OPT_VMAX]);
+				return(-1);
+			}
+		}
+		else if (eigensolver == 0 || eigensolver == 2) {
+			*rqi_flag = 0;
+		}
+	}
+
+	else if (*global_method == 1) {
+		if (MATCH_TYPE == 5) {		/* geometric matching */
+			if (PROMPT)
+				printf("Geometry input file name: ");
+		}
+		if (PROMPT)
+			printf("Number of vertices to coarsen down to: ");
+		*vmax = (int)options[OPT_VMAX];
+		if (*vmax <= 0) {
+			printf("%s -- Vmax %d must be greater then 0.\n",
+				   THISFUNCTION,options[OPT_VMAX]);
+			return(-1);
+		}
+	}
+
+	if (SEQUENCE) {
+		*local_method = 2;
+		if (*architecture == 0) {
+			*ndims_tot = 1;
+		}
+		else if (*architecture > 0) {
+			mesh_dims[0] = 2;
+			mesh_dims[1] = mesh_dims[2] = 1;
+		}
+		*ndims = 1;
+		goto End_Label;
+	}
+
+	/* Get local method, if any */
+	*local_method = 0;
+	if (*global_method == 1)
+		*local_method = 1;
+	else {
+		if (PROMPT) {
+			printf("Local refinement method:\n");
+			printf("  (1) Kernighan-Lin\n");
+			printf("  (2) None\n");
+		}
+		*local_method = (int)options[OPT_LOCAL];
+		if (*local_method < 1 || *local_method > 2) {
+			printf("%s -- Local method %d must be 1 and 2.\n",
+				   THISFUNCTION,options[OPT_LOCAL]);
+			return(-1);
+		}
+	}
+
+	/* Now learn about the parallel architecture. */
+	if (*architecture == 0) {
+	/* Get total number of hypercube dimensions in which to partition. */
+		*ndims_tot = 0;
+		if (PROMPT)
+			printf("Total number of target hypercube dimensions: ");
+		*ndims_tot = nparts[0];
+		if (*ndims_tot < 1) {
+			printf(" Number of divisions must be at least 1\n");
+			printf("%s -- Number of divisions %d must be at least 1.\n",
+				   THISFUNCTION,nparts[0]);
+			return(-1);
+		}
+		*nprocs = 1 << (*ndims_tot);
+	}
+
+	else {			/* Get dimensions of mesh. */
+		mesh_dims[1] = mesh_dims[2] = 1;
+		if (*architecture == 2) {
+			if (PROMPT)
+				printf("X and Y extent of of 2-D mesh: ");
+			mesh_dims[0] = nparts[0];
+			mesh_dims[1] = nparts[1];
+		}
+		else if (*architecture == 3) {
+			if (PROMPT)
+				printf("X, Y and Z extent of 3-D mesh: ");
+			mesh_dims[0] = nparts[0];
+			mesh_dims[1] = nparts[1];
+			mesh_dims[2] = nparts[2];
+		}
+		else {			/* Anything else => 1-D mesh */
+			if (PROMPT)
+				printf("Size of 1-D mesh: ");
+			mesh_dims[0] = nparts[0];
+			*architecture = 1;
+		}
+		*nprocs = mesh_dims[0] * mesh_dims[1] * mesh_dims[2];
+	}
+
+	/* Get number of dimensions in which to partition at each level. */
+	*ndims = 0;
+	if (*nprocs <= 3) {
+		*ndims = 1;
+	}
+	else if (*nprocs <= 7) {
+		if (PROMPT) {
+			printf("Partitioning dimension: \n");
+			printf("  (1) Bisection\n");
+			printf("  (2) Quadrisection\n");
+		}
+		*ndims = (int)options[OPT_NDIMS];
+		if (*ndims < 1 || *ndims > 2) {
+			printf("%s -- Ndims %d must be 1 or 2 for %d processors.\n",
+				   THISFUNCTION,options[OPT_NDIMS],*nprocs);
+			return(-1);
+		}
+	}
+	else {
+		if (PROMPT) {
+			printf("Partitioning dimension: \n");
+			printf("  (1) Bisection\n");
+			printf("  (2) Quadrisection\n");
+			printf("  (3) Octasection\n");
+		}
+		*ndims = (int)options[OPT_NDIMS];
+		if (*ndims < 1 || *ndims > 3) {
+			printf("%s -- Ndims %d must be between 1 and 3 for %d processors.\n",
+				   THISFUNCTION,options[OPT_NDIMS],*nprocs);
+			return(-1);
+		}
+	}
+End_Label: 
+
+	if (*global_method == 1 || *rqi_flag) {
+		if (*vmax < 2 * (1 << *ndims)) {
+			*vmax = 2 * (1 << *ndims);
+		}
+	}
+
+	return(0);
+}
Index: /issm/trunk/externalpackages/chaco/mex/Makefile
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/Makefile	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/Makefile	(revision 4627)
@@ -0,0 +1,293 @@
+# This is the Makefile for the mex-file version of Chaco, to be dynamically 
+# linked with Matlab using the interface in the "meshpart" toolbox.  
+# See file "README" for more information.
+#
+# You may need to change the following variables:
+# 
+# MATLAB      Matlab's top-level directory, often "/usr/matlab" or similar.
+# CHACO       Chaco's source directory, normally the "code" subdirectory
+#             of the Chaco distribution.
+# MLCHACO     Directory with Chaco files modified for Matlab, normally
+#             the directory containing this Makefile.
+# DEST_DIR    Directory for the executable mlchaco.mex, normally the 
+#             "meshpart" directory, which is normally the parent of the 
+#             directory containing this Makefile.
+# CC          Choice of C compiler.  gcc seems to work best for Matlab for me.
+# IFLAGS, CFLAGS, OFLAGS  Flags to go with the compiler and linker.
+#
+# This Makefile works under Solaris 2.  To use it with a different Unix, 
+# you may need to change the references to "ar" and/or "ranlib" and
+# possibly other things.
+#
+# John Gilbert, 1996.
+# Copyright (c) 1990-1996 by Xerox Corporation.  All rights reserved.
+# See file ../copyright.m for complete copyright and licensing notice.
+
+#MATLAB =        /import/matlab
+#MATLAB =        /usr/local/libexec/matlab
+#MATLAB =        /usr/local/pkgs/matlab-7.6
+MATLAB =        ${MATLAB_DIR}
+
+#CHACO =         /project/sparse/chaco/version2/code
+#CHACO =         ../../Chaco-2.0/code
+#CHACO =         ../../Chaco-2.2/code
+#CHACO =         ../../../chaco/src/code
+CHACO =         ${CHACO_DIR}/../src/code
+
+MLCHACO =       .
+DEST_DIR =      ..
+CC =            gcc 
+#CC =            cc 
+IFLAGS =	-I${MATLAB}/extern/include -I${CHACO}/main
+#CFLAGS =        -Xa -G -xO4 -xcg92
+#CFLAGS =        -fPIC -fno-omit-frame-pointer -pthread -fexceptions -DMATLAB
+CFLAGS =        -fPIC -fno-omit-frame-pointer -pthread -fexceptions
+#OFLAGS =        -xO4 -xcg92
+OFLAGS =        -O2
+#AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+AR =             /usr/bin/ar rcv   # for solaris 2
+#RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+RANLIB =         /usr/bin/ranlib   # for solaris 2
+
+
+MLFILES.c=	${MLCHACO}/Chacox.c \
+                ${MLCHACO}/user_params.c
+#		${MLCHACO}/bail.c \  # redefined original with -DMATLAB
+#		${MLCHACO}/chaco_check_graph.c \  # redefined original with -DMATLAB
+#		${MLCHACO}/check_input.c \  # redefined original with -DMATLAB
+#                ${MLCHACO}/smalloc.c \  # redefined original with -DMATLAB
+
+CHFILES.c=	${CHACO}/main/interface.c \
+		${CHACO}/main/main.c \
+		${CHACO}/submain/balance.c \
+		${CHACO}/submain/divide.c \
+		${CHACO}/submain/submain.c \
+		${CHACO}/input/input_assign.c \
+		${CHACO}/input/check_input.c \
+		${CHACO}/input/input.c \
+		${CHACO}/input/input_geom.c \
+		${CHACO}/input/input_graph.c \
+		${CHACO}/input/read_params.c \
+		${CHACO}/input/reflect_input.c \
+		${CHACO}/input/read_val.c \
+		${CHACO}/graph/check_graph.c \
+		${CHACO}/graph/free_graph.c \
+		${CHACO}/graph/reformat.c \
+		${CHACO}/graph/subgraph.c \
+		${CHACO}/graph/graph_out.c \
+		${CHACO}/inertial/eigenvec2.c \
+		${CHACO}/inertial/eigenvec3.c \
+		${CHACO}/inertial/inertial.c \
+		${CHACO}/inertial/inertial1d.c \
+		${CHACO}/inertial/inertial2d.c \
+		${CHACO}/inertial/inertial3d.c \
+		${CHACO}/inertial/make_subgeom.c \
+		${CHACO}/klspiff/buckets.c \
+		${CHACO}/klspiff/buckets_bi.c \
+		${CHACO}/klspiff/buckets1.c \
+		${CHACO}/klspiff/bilistops.c \
+		${CHACO}/klspiff/coarsen_kl.c \
+		${CHACO}/klspiff/count_weights.c \
+		${CHACO}/klspiff/compress_ewgts.c \
+		${CHACO}/klspiff/kl_init.c \
+		${CHACO}/klspiff/kl_output.c \
+		${CHACO}/klspiff/klspiff.c \
+		${CHACO}/klspiff/make_bndy_list.c \
+		${CHACO}/klspiff/make_kl_list.c \
+		${CHACO}/klspiff/nway_kl.c \
+		${CHACO}/klvspiff/bpm_improve.c \
+		${CHACO}/klvspiff/bucketsv.c \
+		${CHACO}/klvspiff/clear_dvals.c \
+		${CHACO}/klvspiff/coarsen_klv.c \
+		${CHACO}/klvspiff/countup_vtx_sep.c \
+		${CHACO}/klvspiff/find_bndy.c \
+		${CHACO}/klvspiff/flow.c \
+		${CHACO}/klvspiff/klv_init.c \
+		${CHACO}/klvspiff/klvspiff.c \
+		${CHACO}/klvspiff/make_bpgraph.c \
+		${CHACO}/klvspiff/make_sep_list.c \
+		${CHACO}/klvspiff/matching.c \
+		${CHACO}/klvspiff/nway_klv.c \
+		${CHACO}/klvspiff/flatten.c \
+		${CHACO}/coarsen/coarsen.c \
+		${CHACO}/coarsen/interpolate.c \
+		${CHACO}/coarsen/makefgraph.c \
+		${CHACO}/coarsen/makeccoords.c \
+		${CHACO}/coarsen/coarsen1.c \
+		${CHACO}/coarsen/makev2cv.c \
+		${CHACO}/coarsen/maxmatch.c \
+		${CHACO}/coarsen/maxmatch1.c \
+		${CHACO}/coarsen/maxmatch2.c  \
+		${CHACO}/coarsen/maxmatch3.c \
+		${CHACO}/coarsen/maxmatch4.c \
+		${CHACO}/coarsen/maxmatch5.c \
+		${CHACO}/connect/add_edges.c \
+		${CHACO}/connect/connected.c \
+		${CHACO}/connect/find_edges.c \
+		${CHACO}/eigen/bidir.c \
+		${CHACO}/eigen/bisect.c \
+		${CHACO}/eigen/checkeig.c \
+		${CHACO}/eigen/checkeig_ext.c \
+		${CHACO}/eigen/checkorth.c \
+		${CHACO}/eigen/cksturmcnt.c \
+		${CHACO}/eigen/mkeigvecs.c\
+		${CHACO}/eigen/eigensolve.c \
+		${CHACO}/eigen/get_extval.c \
+		${CHACO}/eigen/get_ritzvals.c \
+		${CHACO}/eigen/lanczos_FO.c \
+		${CHACO}/eigen/lanczos_SO.c \
+		${CHACO}/eigen/lanczos_SO_float.c \
+		${CHACO}/eigen/lanczos_ext.c \
+		${CHACO}/eigen/lanczos_ext_float.c \
+		${CHACO}/eigen/lanc_seconds.c\
+		${CHACO}/eigen/lanpause.c \
+		${CHACO}/eigen/makeorthlnk.c \
+		${CHACO}/eigen/mkscanlist.c \
+		${CHACO}/eigen/orthog1.c \
+		${CHACO}/eigen/orthogonalize.c \
+		${CHACO}/eigen/orthogvec.c \
+		${CHACO}/eigen/ql.c \
+		${CHACO}/eigen/rqi.c \
+		${CHACO}/eigen/rqi_ext.c \
+		${CHACO}/eigen/scale_diag.c \
+		${CHACO}/eigen/scanmax.c \
+		${CHACO}/eigen/scanmin.c \
+		${CHACO}/eigen/solistout.c \
+		${CHACO}/eigen/sorthog.c \
+		${CHACO}/eigen/splarax.c \
+		${CHACO}/eigen/sturmcnt.c \
+		${CHACO}/eigen/Tevec.c \
+		${CHACO}/eigen/tri_solve.c \
+		${CHACO}/eigen/warnings.c \
+		${CHACO}/symmlq/aprod.c \
+		${CHACO}/symmlq/msolve.c \
+		${CHACO}/symmlq/pow_dd.c \
+		${CHACO}/symmlq/symmlq.c \
+		${CHACO}/symmlq/symmlqblas.c \
+		${CHACO}/tinvit/tinvit.c \
+		${CHACO}/tinvit/pythag.c \
+		${CHACO}/tinvit/epslon.c \
+		${CHACO}/optimize/determinant.c \
+		${CHACO}/optimize/func2d.c \
+		${CHACO}/optimize/func3d.c \
+		${CHACO}/optimize/opt2d.c \
+		${CHACO}/optimize/opt3d.c \
+		${CHACO}/assign/assign.c \
+		${CHACO}/assign/assign_out.c \
+		${CHACO}/assign/mapper.c \
+		${CHACO}/assign/median.c \
+		${CHACO}/assign/merge_assign.c \
+		${CHACO}/assign/rec_median.c \
+		${CHACO}/assign/rotate.c \
+		${CHACO}/assign/y2x.c \
+		${CHACO}/bpmatch/checkbp.c \
+		${CHACO}/bpmatch/inits2d.c \
+		${CHACO}/bpmatch/inits3d.c \
+		${CHACO}/bpmatch/genvals2d.c \
+		${CHACO}/bpmatch/genvals3d.c \
+		${CHACO}/bpmatch/map2d.c \
+		${CHACO}/bpmatch/map3d.c \
+		${CHACO}/bpmatch/movevtxs.c \
+		${CHACO}/bpmatch/sorts2d.c \
+		${CHACO}/bpmatch/sorts3d.c \
+		${CHACO}/refine_map/compute_cube_edata.c \
+		${CHACO}/refine_map/compute_cube_vdata.c \
+		${CHACO}/refine_map/refine_cube.c \
+		${CHACO}/refine_map/update_cube_edata.c \
+		${CHACO}/refine_map/update_cube_vdata.c \
+		${CHACO}/refine_map/find_edge_cube.c \
+		${CHACO}/refine_map/init_cube_edata.c \
+		${CHACO}/refine_map/compute_mesh_edata.c \
+		${CHACO}/refine_map/compute_mesh_vdata.c \
+		${CHACO}/refine_map/find_edge_mesh.c \
+		${CHACO}/refine_map/init_mesh_edata.c \
+		${CHACO}/refine_map/refine_mesh.c \
+		${CHACO}/refine_map/update_mesh_edata.c \
+		${CHACO}/refine_map/update_mesh_vdata.c \
+		${CHACO}/refine_map/refine_map.c \
+		${CHACO}/refine_map/make_comm_graph.c \
+		${CHACO}/refine_part/refine_part.c \
+		${CHACO}/refine_part/kl_refine.c \
+		${CHACO}/refine_part/make_maps_ref.c \
+		${CHACO}/refine_part/make_terms_ref.c \
+		${CHACO}/internal/force_internal.c \
+		${CHACO}/internal/improve_internal.c \
+		${CHACO}/internal/check_internal.c \
+		${CHACO}/misc/define_subcubes.c \
+		${CHACO}/misc/define_submeshes.c \
+		${CHACO}/misc/divide_procs.c \
+		${CHACO}/misc/merge_goals.c \
+		${CHACO}/misc/make_term_props.c \
+		${CHACO}/misc/count.c \
+		${CHACO}/misc/countup.c \
+		${CHACO}/misc/countup_cube.c \
+		${CHACO}/misc/countup_mesh.c \
+		${CHACO}/misc/make_subgoal.c \
+		${CHACO}/misc/find_maxdeg.c \
+		${CHACO}/misc/make_maps.c \
+		${CHACO}/misc/make_setlists.c \
+		${CHACO}/misc/sequence.c \
+		${CHACO}/misc/perturb.c \
+		${CHACO}/misc/simple_part.c \
+		${CHACO}/misc/time_kernels.c \
+		${CHACO}/misc/timing.c \
+		${CHACO}/util/affirm.c \
+		${CHACO}/util/array_alloc_2D.c \
+		${CHACO}/util/bit_reverse.c \
+		${CHACO}/util/checkpnt.c \
+		${CHACO}/util/cpvec.c \
+		${CHACO}/util/dot.c \
+		${CHACO}/util/doubleout.c \
+		${CHACO}/util/input_int.c \
+		${CHACO}/util/gray.c \
+		${CHACO}/util/machine_params.c \
+		${CHACO}/util/makevwsqrt.c \
+		${CHACO}/util/mkvec.c \
+		${CHACO}/util/norm.c \
+		${CHACO}/util/normalize.c \
+		${CHACO}/util/mergesort.c \
+		${CHACO}/util/randomize.c \
+		${CHACO}/util/smalloc.c \
+		${CHACO}/util/bail.c \
+		${CHACO}/util/scadd.c \
+		${CHACO}/util/seconds.c \
+		${CHACO}/util/setvec.c \
+		${CHACO}/util/shell_sort.c \
+		${CHACO}/util/strout.c \
+		${CHACO}/util/tri_prod.c \
+		${CHACO}/util/true_or_false.c \
+		${CHACO}/util/update.c  \
+		${CHACO}/util/vecout.c \
+		${CHACO}/util/vecran.c \
+		${CHACO}/util/vecscale.c 
+#		${CHACO}/main/user_params.c \
+
+MLFILES.o=      $(MLFILES.c:.c=.o)
+
+CHFILES.o=      $(CHFILES.c:.c=.o)
+
+#mlchaco:        ${MLFILES.o} chaco.a Makefile
+#		${MATLAB}/bin/cmex CC='gcc -G' -lm ${OFLAGS} ${MLFILES.o} chaco.a; \
+#                 mv mlchaco.mex* ${DEST_DIR}
+
+#mlchaco:	${MLFILES.c} chaco.a Makefile
+#		mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+#		mv mlchaco.mex* ${DEST_DIR}
+
+#mlchaco:	${MLFILES.c} ${CHFILES.c} ${CHACO}/chaco.a Makefile
+#		${MATLAB}/bin/mex mlchaco.c -largeArrayDims -DMATLAB ${MLFILES.c} ${CHACO}/chaco.a -I${CHACO}/main
+#		mv mlchaco.mex* ${DEST_DIR}
+
+Chaco:	${MLFILES.c} ${CHFILES.c} ${CHACO}/chaco.a Makefile
+		${MATLAB}/bin/mex Chaco.c -largeArrayDims ${MLFILES.c} ${CHACO}/chaco.a -I${CHACO}/main
+#		mv Chaco.mex* ${DEST_DIR}
+
+chaco.a:        ${CHFILES.o}
+		${AR} ${CHACO}/chaco.a ${CHFILES.o} ; ${RANLIB} ${CHACO}/chaco.a
+
+clean:
+		rm -f ${CHACO}/*/*.o chaco.a ${MLCHACO}/*.o ${DEST_DIR}/core
+
+.c.o:
+		${CC} -c ${IFLAGS} ${CFLAGS} -o $*.o $*.c
+
Index: /issm/trunk/externalpackages/chaco/mex/User_Params.debug
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/User_Params.debug	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/User_Params.debug	(revision 4627)
@@ -0,0 +1,27 @@
+% This file, User_Params, is read at runtime to modify Chaco's defaults.
+% The purpose of this version is to turn on some debugging stuff that
+% the Matlab version will normally have off.
+
+ECHO = 2
+OUTPUT_METRICS = 2
+OUTPUT_TIME = 2
+PRINT_HEADERS = 1
+
+DEBUG_EVECS = 1
+DEBUG_KL = 1
+DEBUG_INERTIAL = 1
+DEBUG_CONNECTED = 1
+DEBUG_PERTURB = 1
+DEBUG_ASSIGN = 1
+DEBUG_OPTIMIZE = 1
+DEBUG_BPMATCH = 1
+DEBUG_COARSEN = 1
+DEBUG_MEMORY = 1
+DEBUG_INPUT = 0
+DEBUG_PARAMS = 1
+DEBUG_INTERNAL = 1
+DEBUG_REFINE_PART = 1
+DEBUG_REFINE_MAP = 1
+DEBUG_SIMULATOR = 1
+DEBUG_TRACE = 1
+DEBUG_MACH_PARAMS = 1
Index: /issm/trunk/externalpackages/chaco/mex/User_Params.verbose
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/User_Params.verbose	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/User_Params.verbose	(revision 4627)
@@ -0,0 +1,8 @@
+% This file, User_Params, is read at runtime to modify Chaco's defaults.
+% The purpose of this version is to turn on some verbose output that
+% the Matlab version will normally have off.
+
+ECHO = 1
+OUTPUT_METRICS = 1
+OUTPUT_TIME = 1
+PRINT_HEADERS = 1
Index: /issm/trunk/externalpackages/chaco/mex/mlchaco_README.txt
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/mlchaco_README.txt	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/mlchaco_README.txt	(revision 4627)
@@ -0,0 +1,136 @@
+mlchaco (from meshpartdist.tar, 2/08/02)
+http://www.cerfacs.fr/algor/Softs/MESHPART/
+
+
+[jschierm@astrid chaco]$ diff mlchaco_old.c mlchaco.c
+34a35  [CLK_TCK undefined, so use CLOCKS_PER_SEC]
+> #include <time.h>      /*  CLOCKS_PER_SEC  */
+56,61c57,62  [update for current Matlab]
+< 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  [update for current Matlab]
+>     mwIndex *mwstart,*mwadjacency;
+104c106,110  [update for current Matlab]
+<     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  [update for current Matlab]
+<     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  [provide default filenames, since no way to input]
+<     outassignname = NULL;
+<     outfilename = NULL;
+---
+> /*    outassignname = NULL;
+>     outfilename = NULL;*/
+>     outassignname = "chaco_assign.txt";
+>     outfilename = "chaco_out.txt";
+169c181  [update for current Matlab]
+<       plhs [1] = mxCreateFull (1, 1, REAL) ;
+---
+>       plhs [1] = mxCreateDoubleMatrix (1, 1, mxREAL) ;
+173c185  [CLK_TCK undefined, so use CLOCKS_PER_SEC]
+<       ((double) CLK_TCK) ;
+---
+>       ((double) CLOCKS_PER_SEC) ;
+179c191  [update for current Matlab]
+<         map_out = mxCreateFull(1,nvtxs,REAL);
+---
+>         map_out = mxCreateDoubleMatrix(1,nvtxs,mxREAL);
+185a198,199  [update for current Matlab]
+>     if (start != NULL) mxFree((char *) start);
+>     if (adjacency != NULL) mxFree((char *) adjacency);
+
+
+[jschierm@astrid chaco]$ diff Makefile_old Makefile
+27c27,28  [current Matlab location]
+< MATLAB =        /usr/local/libexec/matlab
+---
+> #MATLAB =        /usr/local/libexec/matlab
+> MATLAB =        /usr/local/pkgs/matlab-7.6
+30c31,32  [current Chaco 2.2 location]
+< CHACO =         ../../Chaco-2.0/code
+---
+> #CHACO =         ../../Chaco-2.0/code
+> CHACO =         ../../Chaco-2.2/code
+34,35c36,37  [use gcc instead of cc]
+< #CC =            gcc 
+< CC =            cc 
+---
+> CC =            gcc 
+> #CC =            cc 
+37c39,40  [add MATLAB flag to compile for mex-function]
+< CFLAGS =        -Xa -G -xO4 -xcg92
+---
+> #CFLAGS =        -Xa -G -xO4 -xcg92
+> CFLAGS =        -Xa -G -xO4 -xcg92 -DMATLAB
+39,40c42,45  [current function locations]
+< AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+< RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+---
+> #AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+> AR =             /usr/bin/ar rcv   # for solaris 2
+> #RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+> RANLIB =         /usr/bin/ranlib   # for solaris 2
+45,47d49  [use Chaco versions with MATLAB switch rather than local versions]
+<               ${MLCHACO}/chaco_check_graph.c \
+<               ${MLCHACO}/check_input.c \
+<                 ${MLCHACO}/smalloc.c \
+48a51,53
+> #             ${MLCHACO}/chaco_check_graph.c \
+> #             ${MLCHACO}/check_input.c \
+> #                ${MLCHACO}/smalloc.c \
+55a61  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/input/check_input.c \
+61a68  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/graph/check_graph.c \
+91a99  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/klvspiff/flow.c \
+97a106  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/klvspiff/flatten.c \
+100c109,110  [update CHLIST to match Chaco 2.2]
+<               ${CHACO}/coarsen/makecgraph.c \
+---
+>               ${CHACO}/coarsen/makefgraph.c \
+>               ${CHACO}/coarsen/makeccoords.c \
+102d111  [update CHLIST to match Chaco 2.2]
+<               ${CHACO}/coarsen/countcedges.c \
+108a118  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/coarsen/maxmatch5.c \
+234a245  [update CHLIST to match Chaco 2.2]
+>               ${CHACO}/util/smalloc.c \
+245a257,258  [use local versions rather than Chaco versions (added for clarity)]
+> #             ${CHACO}/main/user_params.c \
+> #             ${CHACO}/util/bail.c \
+254a268,271  [update for current mex]
+> #mlchaco:     ${MLFILES.c} chaco.a Makefile
+> #             mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+> #             mv mlchaco.mex* ${DEST_DIR}
+> 
+256c273  [update for current mex]
+<               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/chaco/mex/mlchaco_jes_notes.txt
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/mlchaco_jes_notes.txt	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/mlchaco_jes_notes.txt	(revision 4627)
@@ -0,0 +1,182 @@
+7/15/09:
+
+[jschierm@astrid chaco]$ diff Makefile_old Makefile
+27c27,28
+< MATLAB =        /usr/local/libexec/matlab
+---
+> #MATLAB =        /usr/local/libexec/matlab
+> MATLAB =        /usr/local/matlab780
+30c31,32
+< CHACO =         ../../Chaco-2.0/code
+---
+> #CHACO =         ../../Chaco-2.0/code
+> CHACO =         ../../Chaco-2.2/code
+34,35c36,37
+< #CC =            gcc 
+< CC =            cc 
+---
+> CC =            gcc 
+> #CC =            cc 
+39,40c41,44
+< AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+< RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+---
+> #AR =             /usr/ccs/bin/ar rcv   # for solaris 2
+> AR =             /usr/bin/ar rcv   # for solaris 2
+> #RANLIB =         /usr/ccs/bin/ranlib   # for solaris 2
+> RANLIB =         /usr/bin/ranlib   # for solaris 2
+91a96,97  [missing symbols]
+>               ${CHACO}/klvspiff/flatten.c \
+>               ${CHACO}/klvspiff/flow.c \
+99a106  [missing symbols]
+>               ${CHACO}/coarsen/makeccoords.c \
+102a110  [missing symbols]
+>               ${CHACO}/coarsen/makefgraph.c \
+108a117  [missing symbols]
+>               ${CHACO}/coarsen/maxmatch5.c \
+254a264,267
+> #mlchaco:     ${MLFILES.c} chaco.a Makefile
+> #             mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+> #             mv mlchaco.mex* ${DEST_DIR}
+> 
+256c269
+<               mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+---
+>               mex -output mlchaco -largeArrayDims ${MLFILES.c} chaco.a -I${CHACO}/main
+
+[jschierm@astrid chaco]$ diff mlchaco_old.c mlchaco.c
+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];
+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);
+
+
+7/29/09:
+
+[jschierm@astrid chaco]$ diff mlchaco_old.c mlchaco.c
+131,132c141,144
+<     outassignname = NULL;
+<     outfilename = NULL;
+---
+> /*    outassignname = NULL;
+>     outfilename = NULL;*/
+>     outassignname = "chaco_assign.txt";
+>     outfilename = "chaco_out.txt";
+
+7/30/09:
+
+[jschierm@astrid chaco]$ diff Makefile_old Makefile
+27c27,28
+< MATLAB =        /usr/local/libexec/matlab
+---
+> #MATLAB =        /usr/local/libexec/matlab
+> MATLAB =        /usr/local/pkgs/matlab-7.6
+37c39,40
+< CFLAGS =        -Xa -G -xO4 -xcg92
+---
+> #CFLAGS =        -Xa -G -xO4 -xcg92
+> CFLAGS =        -Xa -G -xO4 -xcg92 -DMATLAB
+45,47d49  [using Chaco versions with MATLAB switch]
+<               ${MLCHACO}/chaco_check_graph.c \
+<               ${MLCHACO}/check_input.c \
+<                 ${MLCHACO}/smalloc.c \
+48a51,53
+> #             ${MLCHACO}/chaco_check_graph.c \
+> #             ${MLCHACO}/check_input.c \
+> #                ${MLCHACO}/smalloc.c \
+55a61
+>               ${CHACO}/input/check_input.c \
+61a68
+>               ${CHACO}/graph/check_graph.c \
+91a99  [compared CHFILES with Chaco Makefile CHFILES]
+>               ${CHACO}/klvspiff/flow.c \
+97a106  [compared CHFILES with Chaco Makefile CHFILES]
+>               ${CHACO}/klvspiff/flatten.c \
+100c109,110  [compared CHFILES with Chaco Makefile CHFILES]
+<               ${CHACO}/coarsen/makecgraph.c \
+---
+>               ${CHACO}/coarsen/makefgraph.c \
+>               ${CHACO}/coarsen/makeccoords.c \
+102d111  [compared CHFILES with Chaco Makefile CHFILES]
+<               ${CHACO}/coarsen/countcedges.c \
+108a118  [compared CHFILES with Chaco Makefile CHFILES]
+>               ${CHACO}/coarsen/maxmatch5.c \
+234a245
+>               ${CHACO}/util/smalloc.c \
+245a257,258
+> #             ${CHACO}/main/user_params.c \
+> #             ${CHACO}/util/bail.c \
+254a268,271
+> #mlchaco:     ${MLFILES.c} chaco.a Makefile
+> #             mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+> #             mv mlchaco.mex* ${DEST_DIR}
+> 
+256c273
+<               mex -V4 -output mlchaco ${MLFILES.c} chaco.a -I${CHACO}/main
+---
+>               mex -output mlchaco -largeArrayDims -DMATLAB ${MLFILES.c}
+>               chaco.a -I${CHACO}/main
+
+5/25/10:
+
+- reorganized chaco.m and mlchaco.c drivers into Chaco.c matlab-layer (independent of chaco) and Chacox.c x-layer (independent of matlab).
+
+5/26/10:
+
+- added mexchaco target to Makefile (and related changes).
+
+5/27/10
+
+- added define for exit(status) to ${CHACO}/main/defs.h so that local bail.c is
+  unnecessary.
+
+6/15/10:
+
+- separated chaco x-layer from meshpart build.
+
Index: /issm/trunk/externalpackages/chaco/mex/user_params.c
===================================================================
--- /issm/trunk/externalpackages/chaco/mex/user_params.c	(revision 4627)
+++ /issm/trunk/externalpackages/chaco/mex/user_params.c	(revision 4627)
@@ -0,0 +1,142 @@
+/* This software was developed by Bruce Hendrickson and Robert Leland   *
+ * at Sandia National Laboratories under US Department of Energy        *
+ * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
+
+/* Modified by John Gilbert 25 Aug 1995 for Matlab mex-file interface   */
+/* Modified by Tim Davis, July 6, 1998, for Matlab 5.1 interface, and */
+/* a more picky compiler (cc) that complains about duplicate global */
+/* declarations. */
+
+#include "params.h"
+
+#define  TRUE  1
+#define  FALSE 0
+
+
+/* Input and ouput control parameters */
+
+int       CHECK_INPUT = TRUE;	 /* Check input for consistency? (TRUE/FALSE) */
+int       ECHO = 0;		 /* Print input/param options? to file? (-2..2) */
+int       OUTPUT_METRICS = 0;	 /* Controls displaying of results (-2..2) */
+int       OUTPUT_TIME = 0;	 /* At what level to display timings (0..2) */
+int       OUTPUT_ASSIGN = FALSE; /* Write assignments to file? (TRUE/FALSE) */
+int       OUT_ASSIGN_INV = FALSE;/* If so, use inverse form? (TRUE/FALSE) */
+int       IN_ASSIGN_INV = FALSE; /* Input file in inverse form? (TRUE/FALSE) */
+int       PROMPT = FALSE;	 /* Prompt for input? (TRUE/FALSE) */
+int       PRINT_HEADERS = FALSE; /* Print pretty output headers (TRUE/FALSE) */
+
+
+/* Eigenvector calculation parameters */
+
+int       LANCZOS_TYPE = 3;	/* type of Lanczos to use */
+				/* 1 => full orthog, 2 => full inverse operator */
+				/* 3 =>  selective orthogonalization */
+double    EIGEN_TOLERANCE = 1e-3;	/* Numerical eigen-tolerance */
+double    SRESTOL = -1.;		/* Rel resid tol on T evec; autoset if <= 0 */
+int       LANCZOS_SO_INTERVAL = 10;	/* Itns. between SO orthog checks; set >= 2 */
+int       LANCZOS_MAXITNS = -1;		/* Max Lanczos its; autoset if <= 0 */
+double    BISECTION_SAFETY = 10;	/* Divides Lanczos bisection tol */
+int       LANCZOS_CONVERGENCE_MODE = 0;	/* Lanczos convergence test type: */
+					/* 0=> residual,  1=> partition */
+int       RQI_CONVERGENCE_MODE = 1;	/* RQI convergence test type: */
+					/* 0=> residual,  1=> partition */
+int       LANCZOS_SO_PRECISION = 2;	/* 2 => double Lanczos, 1 => float */
+int       WARNING_EVECS = 2;	/* Warnings in eigenvector generation (0..3) */
+double    WARNING_ORTHTOL = 2;	/* Warning if Ares and bjitol have this ratio */
+double    WARNING_MISTOL = 100;	/* Warning if Ares and bjitol have this ratio */
+int       LANCZOS_TIME = FALSE;	/* Detailed Lanczos times? (TRUE/FALSE) */
+int       TIME_KERNELS = FALSE;	/* Time numerical kernels? (TRUE/FALSE) */
+
+
+/* Other parameters for spectral methods */
+
+int       MAKE_CONNECTED = TRUE;/* Connect graph if using spectral method? */
+int       PERTURB = TRUE;	/* Randomly perturb matrix in spectral method? */
+int       NPERTURB = 2;		/* If so, how many edges to modify? */
+double    PERTURB_MAX = 3.0e-3;	/* Largest value for perturbation */
+int       MAPPING_TYPE = 1;	/* How to map from eigenvectors to partition */
+				/* 0 => cut at origin, 1 => min-cost assign */
+int       COARSE_NLEVEL_RQI = 2;/* # levels between RQI calls in uncoarsening */
+int       OPT3D_NTRIES = 5;	/* # local opts to look for global min in opt3d */
+
+
+/* Kernighan--Lin/Fiduccia--Mattheyses parameters */
+
+int       KL_METRIC = 2;	/* KL interset cost: 1=>cuts, 2=>hops */
+int       KL_RANDOM = TRUE;	/* Use randomness in Kernighan-Lin? (TRUE/FALSE)*/
+int       KL_BAD_MOVES = 20;	/* Number of unhelpful moves in a row allowed */
+int       KL_NTRIES_BAD = 1;	/* # unhelpful passes before quitting KL */
+int       KL_UNDO_LIST = TRUE;	/* Only resort changed vtxs? (TRUE/FALSE) */
+double    KL_IMBALANCE = 0.0;	/* Fractional imbalance allowed by KL */
+
+
+/* Coarsening parameters */
+
+double    COARSEN_RATIO_MIN = .7;  /* Min vtx reduction each coarsen stage */
+int       COARSE_NLEVEL_KL = 2;	   /* # levels between KL calls in uncoarsening */
+int       MATCH_TYPE = 1;	   /* Type of contraction matching (1..4) */
+int       HEAVY_MATCH = FALSE;	   /* Encourage heavy match edges? (TRUE/FALSE) */
+int       COARSE_KL_BOTTOM = TRUE; /* Force KL at lowest level (TRUE/FALSE) */
+int       COARSEN_VWGTS = TRUE;	   /* Sum vtx weights in coarsening? (TRUE/FALSE) */
+int       COARSEN_EWGTS = TRUE;	   /* Sum edge weights in coarsening? (TRUE/FALSE) */
+int       KL_ONLY_BNDY = TRUE;	   /* Start moving vtxs on boundary? (TRUE/FALSE) */
+
+
+/* Parameters for post-processing options */
+
+int       REFINE_PARTITION = FALSE;	/* Postprocess to improve cuts? */
+int       INTERNAL_VERTICES = FALSE;	/* ... to up internal vtxs? (TRUE/FALSE) */
+int       REFINE_MAP = FALSE;		/* ... to reduce hops? (TRUE/FALSE) */
+
+
+/* Architecture and simulator parameters */
+
+int       ARCHITECTURE = 0;	/* 0=> hypercube, d=> d-dimensional mesh (0..3)*/
+
+/* Modified by Tim Davis:  remove duplicate definitions */
+#ifdef DUPLICATE_DEFINITIONS_REMOVED
+int       SIMULATOR = 0;	/* Run simulator? In what mode? */
+int       SIMULATION_ITNS = 1;	/* # iterations simulator is to imitate. */
+int       PERCENTAGE_OUTPUT = FALSE;	/* Output in percent? (TRUE/FALSE) */
+double    CUT_COST = 0.0;	/* Communication cost of a cut-edge. */
+double    HOP_COST = 0.0;	/* Communication cost of a hop. */
+double    BDY_COST = 0.0;	/* Cost associated with boundary vertices.  */
+double    BDY_HOP_COST = 0.0;	/* Cost associated with boundary hops. */
+double    STARTUP_COST = 0.0;	/* Communication cost of a message startup. */
+	/* Note: nCUBE2 startup: 112e-6, per byte: 4.6e-6, buffering 5.6e-6 */
+	/* Intel Paragon startup: 70e-6, per byte: 5.3e-8 */
+#endif
+
+/* Miscellaneous parameters */
+
+int       TERM_PROP = FALSE;	/* Invoke terminal propagation? (TRUE/FALSE) */
+double    CUT_TO_HOP_COST = 1;	/* ..if so, relative importance of cuts/hops */
+int       SEQUENCE = FALSE;	/* Only do spectral ordering? (TRUE/FALSE) */
+char      SEQ_FILENAME[NAME_LENGTH] = "Sequence.out";	/* If so, file name */
+long      RANDOM_SEED = 7654321L;	/* Seed for random number generator */
+int       NSQRTS = 1000;	/* # square roots to precompute if coarsening */
+int       MAKE_VWGTS = FALSE;	/* Make vtx weights degrees+1? (TRUE/FALSE) */
+int       FREE_GRAPH = FALSE;	/* Free input graph data? (TRUE/FALSE) */
+char     *PARAMS_FILENAME = "User_Params";	/* File of parameter changes */
+
+
+/* Parameters that control debugging output */
+
+int       DEBUG_EVECS = 0;	/* Debug flag for eigenvector generation (0..5) */
+int       DEBUG_KL = 0;		/* Debug flag for Kernighan-Lin (0..3) */
+int       DEBUG_INERTIAL = 0;	/* Debug flag for inertial method (0..1) */
+int       DEBUG_CONNECTED = 0;	/* Debug flag for connected components (0..1) */
+int       DEBUG_PERTURB = 0;	/* Debug flag for matrix perturbation (0..1) */
+int       DEBUG_ASSIGN = 0;	/* Debug flag for assignment to sets (0..1) */
+int       DEBUG_OPTIMIZE = 0;	/* Debug flag for optimization/rotation (0..2) */
+int       DEBUG_BPMATCH = 0;	/* Debug flag for bipartite matching code (0..2) */
+int       DEBUG_COARSEN = 0;	/* Debug flag for coarsening/uncoarsening (0..1) */
+int       DEBUG_MEMORY = 0;	/* Debug flag for smalloc/sfree (0..3) */
+int       DEBUG_INPUT = 0;	/* Debug flag for having read input files (0..1) */
+int       DEBUG_PARAMS = 1;	/* Debug flag for reading parameter file (0..2) */
+int       DEBUG_INTERNAL = 0;	/* Debug flag for internal vertices (0..2) */
+int       DEBUG_REFINE_PART = 0;/* Debug flag for refine partition (0..1) */
+int       DEBUG_REFINE_MAP = 0;	/* Debug flag for refining mapping (0..1) */
+int       DEBUG_SIMULATOR = 0;	/* Debug flag for comm simulator (0..2) */
+int       DEBUG_TRACE = 0;	/* Trace main execution path (0..2) */
+int       DEBUG_MACH_PARAMS = 0;/* Print computed machine params? (0..1) */
