Index: /issm/trunk/configs/linux64/linux64.sh.petsc2
===================================================================
--- /issm/trunk/configs/linux64/linux64.sh.petsc2	(revision 4655)
+++ /issm/trunk/configs/linux64/linux64.sh.petsc2	(revision 4656)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2" --with-numthreads=32 --with-petsc-version=2
+./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2" --with-numthreads=32 --with-petsc-version=2 --with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install 
Index: /issm/trunk/m4/issm_options.m4
===================================================================
--- /issm/trunk/m4/issm_options.m4	(revision 4655)
+++ /issm/trunk/m4/issm_options.m4	(revision 4656)
@@ -212,5 +212,33 @@
 	fi
 	AC_MSG_RESULT($HAVE_CHACO)
-	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%chaco-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%chaco-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+	
+	
+	
+	
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%scotch-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	AC_ARG_WITH([scotch-dir],
+			  AS_HELP_STRING([--with-scotch-dir = DIR], [scotch root directory.]),
+			 [SCOTCH_ROOT=$withval],[SCOTCH_ROOT=""]) 
+	AC_MSG_CHECKING(for Scotch )
+	
+	if test -d "$SCOTCH_ROOT"; then
+
+		dnl defaults
+		HAVE_SCOTCH=yes
+		SCOTCHINCL="-I$SCOTCH_ROOT/include -DSCOTCH_VERSION=\\\"UNKNOWN\\\""
+		SCOTCHLIB="-L$SCOTCH_ROOT/lib -lscotch -lscotcherr -lscotcherrexit -lscotchmetis"
+
+
+		AC_DEFINE([_HAVE_SCOTCH_],[1],[with Scotch in ISSM src])
+		AC_SUBST([SCOTCHINCL])
+		AC_SUBST([SCOTCHLIB])
+
+	else
+		HAVE_SCOTCH=no
+	fi
+	AC_MSG_RESULT($HAVE_SCOTCH)
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%scotch-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 
 
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 4655)
+++ /issm/trunk/src/c/Makefile.am	(revision 4656)
@@ -1,3 +1,3 @@
-INCLUDES = @DAKOTAINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ 
+INCLUDES = @DAKOTAINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ 
 
 #Compile serial library, and then try and compile parallel library
@@ -539,4 +539,6 @@
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp\
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.h\
+					./modules/Scotchx/Scotchx.cpp\
+					./modules/Scotchx/Scotchx.h\
 					./modules/Solverx/Solverx.cpp\
 					./modules/Solverx/Solverx.h\
@@ -1091,4 +1093,6 @@
 					./modules/Solverx/Solverx.cpp\
 					./modules/Solverx/Solverx.h\
+					./modules/Scotchx/Scotchx.cpp\
+					./modules/Scotchx/Scotchx.h\
 					./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp\
 					./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h\
@@ -1156,5 +1160,5 @@
 endif
 
-LDADD =    ./libpISSM.a $(PETSCLIB)    $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) libOverload.a $(MULTITHREADINGLIB)
+LDADD =    ./libpISSM.a $(PETSCLIB)    $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) libOverload.a $(MULTITHREADINGLIB)
 
 issm_exe_SOURCES = solutions/issm.cpp
Index: /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp	(revision 4656)
+++ /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp	(revision 4656)
@@ -0,0 +1,342 @@
+/* Copyright 2004,2007,2008 ENSEIRB, INRIA & CNRS
+**
+** This file is part of the Scotch software package for static mapping,
+** graph partitioning and sparse matrix ordering.
+**
+** This software is governed by the CeCILL-C license under French law
+** and abiding by the rules of distribution of free software. You can
+** use, modify and/or redistribute the software under the terms of the
+** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
+** URL: "http://www.cecill.info".
+** 
+** As a counterpart to the access to the source code and rights to copy,
+** modify and redistribute granted by the license, users are provided
+** only with a limited warranty and the software's author, the holder of
+** the economic rights, and the successive licensors have only limited
+** liability.
+** 
+** In this respect, the user's attention is drawn to the risks associated
+** with loading, using, modifying and/or developing or reproducing the
+** software by the user in light of its specific status of free software,
+** that may mean that it is complicated to manipulate, and that also
+** therefore means that it is reserved for developers and experienced
+** professionals having in-depth computer knowledge. Users are therefore
+** encouraged to load and test the software's suitability as regards
+** their requirements in conditions enabling the security of their
+** systems and/or data to be ensured and, more generally, to use and
+** operate it in the same conditions as regards security.
+** 
+** The fact that you are presently reading this means that you have had
+** knowledge of the CeCILL-C license and that you accept its terms.
+*/
+/************************************************************/
+/**                                                        **/
+/**   NAME       : gmap.c                                  **/
+/**                                                        **/
+/**   AUTHOR     : Francois PELLEGRINI                     **/
+/**                                                        **/
+/**   FUNCTION   : Part of a graph mapping software.       **/
+/**                This module contains the main function. **/
+/**                                                        **/
+/**   DATES      : # Version 0.0  : from : 05 jan 1993     **/
+/**                                 to     12 may 1993     **/
+/**                # Version 1.1  : from : 15 oct 1993     **/
+/**                                 to     15 oct 1993     **/
+/**                # Version 1.3  : from : 06 apr 1994     **/
+/**                                 to     18 may 1994     **/
+/**                # Version 2.0  : from : 06 jun 1994     **/
+/**                                 to     17 nov 1994     **/
+/**                # Version 2.1  : from : 07 apr 1995     **/
+/**                                 to     18 jun 1995     **/
+/**                # Version 3.0  : from : 01 jul 1995     **/
+/**                                 to     02 oct 1995     **/
+/**                # Version 3.1  : from : 07 nov 1995     **/
+/**                                 to     25 apr 1996     **/
+/**                # Version 3.2  : from : 24 sep 1996     **/
+/**                                 to     26 may 1998     **/
+/**                # Version 3.3  : from : 19 oct 1998     **/
+/**                                 to   : 30 mar 1999     **/
+/**                # Version 3.4  : from : 03 feb 2000     **/
+/**                                 to   : 03 feb 2000     **/
+/**                # Version 4.0  : from : 16 jan 2004     **/
+/**                                 to   : 27 dec 2004     **/
+/**                # Version 5.0  : from : 23 dec 2007     **/
+/**                                 to   : 18 jun 2008     **/
+/**                                                        **/
+/************************************************************/
+
+#include "./Scotchx.h"
+
+int
+gmapx (
+  int                 (**pmaptabi)[2],
+  int                 argcm,
+  char                *argvm[],
+  int                 nvi,
+  int                 ne2i,
+  int                 *ir,
+  int                 *jc,
+  int                 *vli,
+  int                 *vwi,
+  int                 *ewi,
+  char                archtyp[],
+  int                 nai,
+  int                 *api)
+{ 
+#ifdef _HAVE_SCOTCH_ //only works if Scotch library has been compiled in.
+
+  SCOTCH_Graph        grafdat;                    /* Source graph            */
+  SCOTCH_Num          grafflag;                   /* Source graph properties */
+  SCOTCH_Arch         archdat;                    /* Target architecture     */
+  SCOTCH_Strat        stradat;                    /* Mapping strategy        */
+  SCOTCH_Mapping      mapdat;                     /* Mapping data            */
+  Clock               runtime[2];                 /* Timing variables        */
+  SCOTCH_Num          nvert =0;
+  SCOTCH_Num          nedge2=0;
+  SCOTCH_Num*         adjir  =NULL;
+  SCOTCH_Num*         adjjc  =NULL;
+  SCOTCH_Num*         vertlab=NULL;
+  SCOTCH_Num*         vertwgt=NULL;
+  SCOTCH_Num*         edgewgt=NULL;
+  SCOTCH_Num          napar =0;
+  SCOTCH_Num*         archpar=NULL;
+  SCOTCH_Num          (*maptab)[2]=NULL;
+  int                 (*maptabi)[2]=NULL;
+  int                 flagval;
+  int                 i,j,k;
+
+/*  reset static variables from previous runs (jes, 4/27/10)  */
+
+  C_partNbr = 2;        /* Default number of parts     */
+  C_paraNum = 0;        /* Number of parameters        */
+  C_paraNbr = 0;        /* No parameters for mapping   */
+  C_fileNum = 0;        /* Number of file in arg list  */
+  C_fileNbr = 4;        /* Number of files for mapping */
+  for (i=0; i<C_FILENBR; i++) {
+    C_fileTab[i].name = "-";
+    C_fileTab[i].pntr = NULL;
+    if (i < 2)
+      C_fileTab[i].mode = "r";
+    else
+      C_fileTab[i].mode = "w";
+  }
+
+/*  convert input arguments to scotch data types  */
+
+  nvert =(SCOTCH_Num)nvi;
+  nedge2=(SCOTCH_Num)ne2i;
+
+  if (ir && jc) {
+    adjir = (SCOTCH_Num *) malloc(nedge2*sizeof(SCOTCH_Num));
+    for (i=0; i<nedge2; i++)
+      adjir[i]=(SCOTCH_Num)ir[i];
+    adjjc = (SCOTCH_Num *) malloc((nvert+1)*sizeof(SCOTCH_Num));
+    for (i=0; i<(nvert+1); i++)
+      adjjc[i]=(SCOTCH_Num)jc[i];
+  }
+
+  if (vli) {
+    vertlab = (SCOTCH_Num *) malloc(nvert*sizeof(SCOTCH_Num));
+    for (i=0; i<nvert; i++)
+      vertlab[i]=(SCOTCH_Num)vli[i];
+  }
+
+  if (vwi) {
+    vertwgt = (SCOTCH_Num *) malloc(nvert*sizeof(SCOTCH_Num));
+    for (i=0; i<nvert; i++)
+      vertwgt[i]=(SCOTCH_Num)vwi[i];
+  }
+
+  if (ewi) {
+    edgewgt = (SCOTCH_Num *) malloc(nedge2*sizeof(SCOTCH_Num));
+    for (i=0; i<nedge2; i++)
+      edgewgt[i]=(SCOTCH_Num)ewi[i];
+  }
+
+  napar =(SCOTCH_Num)nai;
+
+  if (api) {
+    archpar = (SCOTCH_Num *) malloc(nai*sizeof(SCOTCH_Num));
+    for (i=0; i<nai; i++)
+      archpar[i]=(SCOTCH_Num)api[i];
+  }
+
+/*  start scotch processing  */
+
+  flagval = C_FLAGNONE;                           /* Default behavior */
+  i = strlen (argvm[0]);
+  if ((i >= 5) && (strncmp (argvm[0] + i - 5, "gpart", 5) == 0)) {
+    flagval |= C_FLAGPART;
+    C_paraNbr = 1;                                /* One more parameter       */
+    C_fileNbr = 3;                                /* One less file to provide */
+    errorProg ("gpart");
+  }
+  else
+    errorProg ("gmap");
+
+  intRandResetStatic ();
+  intRandInit ();
+
+  if ((argcm >= 2) && (argvm[1][0] == '?')) {       /* If need for help */
+    usagePrint (stdout, C_usageList);
+    return     (0);
+  }
+
+  grafflag = 0;                                   /* Use vertex and edge weights  */
+  SCOTCH_stratInit (&stradat);                    /* Set default mapping strategy */
+
+  for (i = 0; i < C_FILENBR; i ++)                /* Set default stream pointers */
+    C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout;
+  for (i = 1; i < argcm; i ++) {                   /* Loop for all option codes                        */
+    if ((argvm[i][0] != '-') || (argvm[i][1] == '\0') || (argvm[i][1] == '.')) { /* If found a file name */
+      if (C_paraNum < C_paraNbr) {                /* If number of parameters not reached              */
+        if ((C_partNbr = atoi (argvm[i])) < 1)     /* Get the number of parts                          */
+          errorPrint ("main: invalid number of parts (\"%s\")", argvm[i]);
+        C_paraNum ++;
+        continue;                                 /* Process the other parameters */
+      }
+      if (C_fileNum < C_fileNbr)                  /* A file name has been given */
+        C_fileTab[C_fileNum ++].name = argvm[i];
+      else
+        errorPrint ("main: too many file names given");
+    }
+    else {                                        /* If found an option name */
+      switch (argvm[i][1]) {
+        case 'H' :                                /* Give the usage message */
+        case 'h' :
+          usagePrint (stdout, C_usageList);
+          return     (0);
+        case 'M' :
+        case 'm' :
+          SCOTCH_stratExit (&stradat);
+          SCOTCH_stratInit (&stradat);
+          SCOTCH_stratGraphMap (&stradat, &argvm[i][2]);
+          break;
+        case 'S' :
+        case 's' :                                /* Source graph parameters */
+          for (j = 2; argvm[i][j] != '\0'; j ++) {
+            switch (argvm[i][j]) {
+              case 'E' :
+              case 'e' :
+                grafflag |= 2;                    /* Do not load edge weights */
+                break;
+              case 'V' :
+              case 'v' :
+                grafflag |= 1;                    /* Do not load vertex weights */
+                break;
+              default :
+                errorPrint ("main: invalid source graph option (\"%c\")", argvm[i][j]);
+            }
+          }
+          break;
+        case 'V' :
+          fprintf (stderr, "gmap/gpart, version %s - F. Pellegrini\n", SCOTCH_VERSION);
+          fprintf (stderr, "Copyright 2004,2007,2008 ENSEIRB, INRIA & CNRS, France\n");
+          fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n");
+          return  (0);
+        case 'v' :                                /* Output control info */
+          for (j = 2; argvm[i][j] != '\0'; j ++) {
+            switch (argvm[i][j]) {
+              case 'M' :
+              case 'm' :
+                flagval |= C_FLAGVERBMAP;
+                break;
+              case 'S' :
+              case 's' :
+                flagval |= C_FLAGVERBSTR;
+                break;
+              case 'T' :
+              case 't' :
+                flagval |= C_FLAGVERBTIM;
+                break;
+              default :
+                errorPrint ("main: unprocessed parameter \"%c\" in \"%s\"", argvm[i][j], argvm[i]);
+            }
+          }
+          break;
+        default :
+          errorPrint ("main: unprocessed option (\"%s\")", argvm[i]);
+      }
+    }
+  }
+  if ((flagval & C_FLAGPART) != 0) {              /* If program run as the partitioner            */
+    C_fileTab[3].name = C_fileTab[2].name;        /* Put provided file names at their right place */
+    C_fileTab[2].name = C_fileTab[1].name;
+    C_fileTab[1].name = "-";
+  }
+
+  fileBlockOpen (C_fileTab, C_FILENBR);           /* Open all files */
+
+  clockInit  (&runtime[0]);
+  clockStart (&runtime[0]);
+
+  SCOTCH_graphInit (&grafdat);                    /* Create graph structure         */
+  SCOTCH_graphLoad (&grafdat, C_filepntrsrcinp, -1, grafflag, nvert, nedge2, adjir, adjjc, vertlab, vertwgt, edgewgt); /* Read source graph */
+
+  SCOTCH_archInit (&archdat);                     /* Create architecture structure          */
+  if ((flagval & C_FLAGPART) != 0)                /* If program run as the partitioner      */
+    SCOTCH_archCmplt (&archdat, C_partNbr);       /* Create a complete graph of proper size */
+  else
+    SCOTCH_archLoad (&archdat, C_filepntrtgtinp, archtyp, napar, archpar); /* Read target architecture */
+
+  clockStop  (&runtime[0]);                       /* Get input time */
+  clockInit  (&runtime[1]);
+  clockStart (&runtime[1]);
+
+  SCOTCH_graphMapInit    (&grafdat, &mapdat, &archdat, NULL);
+  SCOTCH_graphMapCompute (&grafdat, &mapdat, &stradat); /* Perform mapping */
+
+  clockStop  (&runtime[1]);                       /* Get computation time */
+  clockStart (&runtime[0]);
+
+  SCOTCH_graphMapSave (&nvert, &maptab, &grafdat, &mapdat, C_filepntrmapout); /* Write mapping */
+
+/*  convert output arguments from scotch data types  */
+
+  if (maptab) {
+    *pmaptabi = (int (*)[2]) malloc(nvert*2*sizeof(int));
+    maptabi  = *pmaptabi;
+    for (j=0; j<2; j++)
+      for (i=0; i<nvert; i++)
+          maptabi[i][j]=(int)maptab[i][j];
+    free(maptab);
+  }
+
+  clockStop (&runtime[0]);                        /* Get output time */
+
+  if (flagval & C_FLAGVERBSTR) {
+    fprintf (C_filepntrlogout, "S\tStrat=");
+    SCOTCH_stratSave (&stradat, C_filepntrlogout);
+    putc ('\n', C_filepntrlogout);
+  }
+  if (flagval & C_FLAGVERBTIM) {
+    fprintf (C_filepntrlogout, "T\tMapping\t\t%g\nT\tI/O\t\t%g\nT\tTotal\t\t%g\n",
+             (double) clockVal (&runtime[1]),
+             (double) clockVal (&runtime[0]),
+             (double) clockVal (&runtime[0]) +
+             (double) clockVal (&runtime[1]));
+  }
+  if (flagval & C_FLAGVERBMAP)
+    SCOTCH_graphMapView (&grafdat, &mapdat, C_filepntrlogout);
+
+  fileBlockClose (C_fileTab, C_FILENBR);          /* Always close explicitely to end eventual (un)compression tasks */
+
+  SCOTCH_graphMapExit (&grafdat, &mapdat);
+  SCOTCH_graphExit    (&grafdat);
+  SCOTCH_stratExit    (&stradat);
+  SCOTCH_archExit     (&archdat);
+
+  if (archpar) free(archpar);
+  if (edgewgt) free(edgewgt);
+  if (vertwgt) free(vertwgt);
+  if (vertlab) free(vertlab);
+  if (adjjc) free(adjjc);
+  if (adjir) free(adjir);
+
+#ifdef COMMON_PTHREAD
+  pthread_exit ((void *) 0);                      /* Allow potential (un)compression tasks to complete */
+#endif /* COMMON_PTHREAD */
+  return (0);
+
+#endif //#ifdef _HAVE_SCOTCH_ 
+}
Index: /issm/trunk/src/c/modules/Scotchx/Scotchx.h
===================================================================
--- /issm/trunk/src/c/modules/Scotchx/Scotchx.h	(revision 4656)
+++ /issm/trunk/src/c/modules/Scotchx/Scotchx.h	(revision 4656)
@@ -0,0 +1,71 @@
+/*!\file:  Scotchxx.h
+ * \brief header file for Scotch partitioner
+ */ 
+
+#ifndef _SCOTCHX_H
+#define _SCOTCHX_H
+
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Scotchx"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+#ifdef _HAVE_SCOTCH_ //only works if scotch library has been compiled in.
+
+	#define GMAP
+
+	#include "scotch_module.h"
+	#include "scotch_common.h"
+	#include "scotch.h"
+	#include "scotch_gmap.h"
+
+	/*
+	**  The static variables.
+	*/
+
+	static int                  C_partNbr = 2;        /* Default number of parts     */
+	static int                  C_paraNum = 0;        /* Number of parameters        */
+	static int                  C_paraNbr = 0;        /* No parameters for mapping   */
+	static int                  C_fileNum = 0;        /* Number of file in arg list  */
+	static int                  C_fileNbr = 4;        /* Number of files for mapping */
+	static File                 C_fileTab[C_FILENBR] = { /* File array               */
+								  { "-", NULL, "r" },
+								  { "-", NULL, "r" },
+								  { "-", NULL, "w" },
+								  { "-", NULL, "w" } };
+
+	static const char *         C_usageList[] = {     /* Usage */
+	  "gmap [<input source file> [<input target file> [<output mapping file> [<output log file>]]]] <options>",
+	  "gpart [<nparts>] [<input source file> [<output mapping file> [<output log file>]]] <options>",
+	  "  -h         : Display this help",
+	  "  -m<strat>  : Set mapping strategy (see user's manual)",
+	  "  -s<obj>    : Force unity weights on <obj>:",
+	  "                 e  : edges",
+	  "                 v  : vertices",
+	  "  -V         : Print program version and copyright",
+	  "  -v<verb>   : Set verbose mode to <verb>:",
+	  "                 m  : mapping information",
+	  "                 s  : strategy information",
+	  "                 t  : timing information",
+	  "",
+	  "See default strategy with option '-vs'",
+	  NULL };
+	extern "C"  void intRandResetStatic(void);
+
+#endif
+
+/* local prototypes: */
+int gmapx ( int (**pmaptabi)[2], int argcm, char *argvm[], int nvi, int ne2i, int *ir, int *jc, int *vli, int *vwi, int *ewi, char archtyp[], int nai, int *api);
+
+#endif  /* _SCOTCHX_H */
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 4655)
+++ /issm/trunk/src/c/modules/modules.h	(revision 4656)
@@ -8,81 +8,82 @@
 /*Modules: */
 #include "./AddExternalResultx/AddExternalResultx.h"
+#include "./AverageFilterx/AverageFilterx.h"
+#include "./Bamgx/Bamgx.h"
+#include "./BamgConvertMeshx/BamgConvertMeshx.h"
+#include "./BuildNodeSetsx/BuildNodeSetsx.h"
 #include "./Chacox/Chacox.h"
-#include "./ModelProcessorx/ModelProcessorx.h"
-#include "./VerticesDofx/VerticesDofx.h"
-#include "./NodesDofx/NodesDofx.h"
-#include "./Dux/Dux.h"
-#include "./SpcNodesx/SpcNodesx.h"
-#include "./MpcNodesx/MpcNodesx.h"
+#include "./ComputeBasalStressx/ComputeBasalStressx.h"
+#include "./ComputePressurex/ComputePressurex.h"
+#include "./ComputeStrainRatex/ComputeStrainRatex.h"
+#include "./ConfigureObjectsx/ConfigureObjectsx.h"
 #include "./ContourToMeshx/ContourToMeshx.h"
 #include "./ContourToNodesx/ContourToNodesx.h"
+#include "./CostFunctionx/CostFunctionx.h"
+#include "./DakotaResponsesx/DakotaResponsesx.h"
+#include "./Dux/Dux.h"
+#include "./ElementConnectivityx/ElementConnectivityx.h"
+#include "./FieldAverageOntoVerticesx/FieldAverageOntoVerticesx.h"
+#include "./FieldDepthAveragex/FieldDepthAveragex.h"
+#include "./GetSolutionFromInputsx/GetSolutionFromInputsx.h"
+#include "./GetVectorFromInputsx/GetVectorFromInputsx.h"
+#include "./Gradjx/Gradjx.h"
+#include "./HoleFillerx/HoleFillerx.h"
+#include "./InputAXPYx/InputAXPYx.h"
+#include "./InputControlConstrainx/InputControlConstrainx.h"
+#include "./InputConvergencex/InputConvergencex.h"
+#include "./InputDepthAveragex/InputDepthAveragex.h"
+#include "./InputDuplicatex/InputDuplicatex.h"
+#include "./InputScalex/InputScalex.h"
 #include "./InterpFromGridToMeshx/InterpFromGridToMeshx.h"
 #include "./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h"
 #include "./InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h"
 #include "./InterpFromMeshToGridx/InterpFromMeshToGridx.h"
-#include "./HoleFillerx/HoleFillerx.h"
-#include "./AverageFilterx/AverageFilterx.h"
-#include "./MeshPartitionx/MeshPartitionx.h"
-#include "./BuildNodeSetsx/BuildNodeSetsx.h"
-#include "./Reducevectorgtosx/Reducevectorgtosx.h"
-#include "./Reducevectorgtofx/Reducevectorgtofx.h"
-#include "./NormalizeConstraintsx/NormalizeConstraintsx.h"
-#include "./ConfigureObjectsx/ConfigureObjectsx.h"
-#include "./SystemMatricesx/SystemMatricesx.h"
+#include "./InputExtrudex/InputExtrudex.h"
+#include "./InputToResultx/InputToResultx.h"
 #include "./InputUpdateFromConstantx/InputUpdateFromConstantx.h"
 #include "./InputUpdateFromSolutionx/InputUpdateFromSolutionx.h"
 #include "./InputUpdateFromDakotax/InputUpdateFromDakotax.h"
 #include "./InputUpdateFromVectorx/InputUpdateFromVectorx.h"
+#include "./MassFluxx/MassFluxx.h"
+#include "./MaxAbsVxx/MaxAbsVxx.h"
+#include "./MaxAbsVyx/MaxAbsVyx.h"
+#include "./MaxAbsVzx/MaxAbsVzx.h"
+#include "./MaxVelx/MaxVelx.h"
+#include "./MaxVxx/MaxVxx.h"
+#include "./MaxVyx/MaxVyx.h"
+#include "./MaxVzx/MaxVzx.h"
+#include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
+#include "./MeshPartitionx/MeshPartitionx.h"
+#include "./MinVelx/MinVelx.h"
+#include "./MinVxx/MinVxx.h"
+#include "./MinVyx/MinVyx.h"
+#include "./MinVzx/MinVzx.h"
+#include "./Misfitx/Misfitx.h"
+#include "./ModelProcessorx/ModelProcessorx.h"
+#include "./MpcNodesx/MpcNodesx.h"
+#include "./NodeConnectivityx/NodeConnectivityx.h"
+#include "./NodesDofx/NodesDofx.h"
+#include "./NormalizeConstraintsx/NormalizeConstraintsx.h"
+#include "./Orthx/Orthx.h"
+#include "./OutputResultsx/OutputResultsx.h"
+#include "./OutputRiftsx/OutputRiftsx.h"
+#include "./PenaltyConstraintsx/PenaltyConstraintsx.h"
+#include "./PenaltySystemMatricesx/PenaltySystemMatricesx.h"
+#include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h"
+#include "./Qmux/Qmux.h"
+#include "./Reduceloadfromgtofx/Reduceloadfromgtofx.h"
+#include "./Reducematrixfromgtofx/Reducematrixfromgtofx.h"
+#include "./Reducevectorgtosx/Reducevectorgtosx.h"
+#include "./Reducevectorgtofx/Reducevectorgtofx.h"
+#include "./Scotchx/Scotchx.h"
+#include "./Solverx/Solverx.h"
+#include "./SpcNodesx/SpcNodesx.h"
+#include "./SplitSolutionVectorx/SplitSolutionVectorx.h"
+#include "./SurfaceAreax/SurfaceAreax.h"
+#include "./SystemMatricesx/SystemMatricesx.h"
 #include "./UpdateGeometryx/UpdateGeometryx.h"
 #include "./UpdateVertexPositionsx/UpdateVertexPositionsx.h"
-#include "./PenaltySystemMatricesx/PenaltySystemMatricesx.h"
-#include "./Reducematrixfromgtofx/Reducematrixfromgtofx.h"
-#include "./Reduceloadfromgtofx/Reduceloadfromgtofx.h"
-#include "./Solverx/Solverx.h"
-#include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
-#include "./PenaltyConstraintsx/PenaltyConstraintsx.h"
-#include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h"
-#include "./Gradjx/Gradjx.h"
-#include "./Orthx/Orthx.h"
-#include "./Misfitx/Misfitx.h"
-#include "./SurfaceAreax/SurfaceAreax.h"
-#include "./CostFunctionx/CostFunctionx.h"
-#include "./InputControlConstrainx/InputControlConstrainx.h"
-#include "./FieldAverageOntoVerticesx/FieldAverageOntoVerticesx.h"
-#include "./FieldDepthAveragex/FieldDepthAveragex.h"
-#include "./ComputeBasalStressx/ComputeBasalStressx.h"
-#include "./ComputePressurex/ComputePressurex.h"
-#include "./ComputeStrainRatex/ComputeStrainRatex.h"
 #include "./VecExtrudex/VecExtrudex.h"
-#include "./Qmux/Qmux.h"
-#include "./NodeConnectivityx/NodeConnectivityx.h"
-#include "./ElementConnectivityx/ElementConnectivityx.h"
-#include "./OutputRiftsx/OutputRiftsx.h"
-#include "./MassFluxx/MassFluxx.h"
-#include "./Bamgx/Bamgx.h"
-#include "./BamgConvertMeshx/BamgConvertMeshx.h"
-#include "./SplitSolutionVectorx/SplitSolutionVectorx.h"
-#include "./InputDepthAveragex/InputDepthAveragex.h"
-#include "./InputExtrudex/InputExtrudex.h"
-#include "./InputToResultx/InputToResultx.h"
-#include "./GetSolutionFromInputsx/GetSolutionFromInputsx.h"
-#include "./OutputResultsx/OutputResultsx.h"
-#include "./MinVelx/MinVelx.h"
-#include "./MaxVelx/MaxVelx.h"
-#include "./MinVxx/MinVxx.h"
-#include "./MaxVxx/MaxVxx.h"
-#include "./MaxAbsVxx/MaxAbsVxx.h"
-#include "./MinVyx/MinVyx.h"
-#include "./MaxVyx/MaxVyx.h"
-#include "./MaxAbsVyx/MaxAbsVyx.h"
-#include "./MinVzx/MinVzx.h"
-#include "./MaxVzx/MaxVzx.h"
-#include "./MaxAbsVzx/MaxAbsVzx.h"
-#include "./InputDuplicatex/InputDuplicatex.h"
-#include "./InputScalex/InputScalex.h"
-#include "./InputAXPYx/InputAXPYx.h"
-#include "./GetVectorFromInputsx/GetVectorFromInputsx.h"
-#include "./InputConvergencex/InputConvergencex.h"
-#include "./DakotaResponsesx/DakotaResponsesx.h"
+#include "./VerticesDofx/VerticesDofx.h"
 
 #endif
Index: /issm/trunk/src/mex/Makefile.am
===================================================================
--- /issm/trunk/src/mex/Makefile.am	(revision 4655)
+++ /issm/trunk/src/mex/Makefile.am	(revision 4656)
@@ -1,3 +1,3 @@
-INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@
 EXEEXT=$(MEXEXT)
 
@@ -61,4 +61,5 @@
 				Reducevectorgtos\
 				Reducevectorgtof\
+				Scotch\
 				SetStructureField\
 				Solver\
@@ -82,5 +83,5 @@
 
 
-LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB)   $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB)
+LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB)   $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB)
 
 AM_LDFLAGS = $(MEXLINK)
@@ -273,4 +274,7 @@
 									Reducevectorgtof/Reducevectorgtof.h
 
+Scotch_SOURCES = Scotch/Scotch.cpp\
+			  Scotch/Scotch.h
+
 SetStructureField_SOURCES = SetStructureField/SetStructureField.cpp\
 			  SetStructureField/SetStructureField.h
Index: /issm/trunk/src/mex/Scotch/Scotch.cpp
===================================================================
--- /issm/trunk/src/mex/Scotch/Scotch.cpp	(revision 4656)
+++ /issm/trunk/src/mex/Scotch/Scotch.cpp	(revision 4656)
@@ -0,0 +1,267 @@
+/*\file Scotch.c
+ *\brief:  Scotch partitioner mex module
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include "./Scotch.h"
+
+/******************************/
+/*                            */
+/* This is the main function. */
+/*                            */
+/******************************/
+
+void mexFunction( int nlhs,
+				  mxArray *plhs[],
+				  int nrhs,
+				  const mxArray *prhs[] )
+{
+
+#ifndef _HAVE_SCOTCH_ //only works if scotch library has been compiled in.
+	ISSMERROR(" Scotch not available! Cannot carry out Scotch partitioning!");
+	#else
+
+	int     argcm;
+	char    **argvm=NULL;
+	int     nvert =0,nedge2=0,napar =0;
+	mwIndex *ir=NULL,*jc=NULL;
+	int     *adjir=NULL,*adjjc=NULL;
+	double  *vld=NULL,*vwd=NULL,*ewd=NULL,*apd=NULL;
+	int     *vli=NULL,*vwi=NULL,*ewi=NULL,*api=NULL;
+	char    *archtyp=NULL;
+	int     (*maptabi)[2]=NULL;
+	double* maptabd=NULL;
+	int     i,j,k,imi=0,imo=0,isi=0,ierr;
+
+	/* Check for proper number of arguments */
+   
+	if      (nrhs == 0 && nlhs == 0) {
+		GmapUsage();
+		return;
+	}
+	else if (nrhs <  6 || nlhs >  1) {
+		GmapUsage();
+		mexErrMsgTxt(" ");
+	}
+
+/*  load matlab argument list and convert to integer (note that converting here
+	and in the x-layer is inefficient, but it makes the x-layer more general)  */
+
+	argvm = (char **) calloc(nrhs,sizeof(char *));
+
+	if (!(mxIsNumeric(prhs[imi]) &&
+		  (mxGetM(prhs[imi]) == 1 && mxGetN(prhs[imi]) == 1))) {
+		argvm[isi] = (char *) calloc(4+1,sizeof(char));
+		strcpy(argvm[isi],"gmap");
+		mexPrintf("%s -- Using \"%s\" entry point.\n",
+				  THISFUNCTION,argvm[isi]);
+		isi++;
+	}
+	else {
+		argvm[isi] = (char *) calloc(5+1,sizeof(char));
+		strcpy(argvm[isi],"gpart");
+		mexPrintf("%s -- Using \"%s\" entry point.\n",
+				  THISFUNCTION,argvm[isi]);
+		isi++;
+
+		argvm[isi] = (char *) calloc(17,sizeof(char));
+		sprintf(argvm[isi],"%d",(int)mxGetScalar(prhs[imi]));
+		mexPrintf("%s -- Number of parts is %s.\n",
+				  THISFUNCTION,argvm[isi]);
+		isi++;
+		imi++;
+	}
+
+	if (!mxIsNumeric(prhs[imi]) || (!mxIsEmpty(prhs[imi]) && !mxIsSparse(prhs[imi]))) {
+		mexPrintf("%s -- Adjacency matrix must be numeric and sparse.\n",THISFUNCTION);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		nvert =mxGetM(prhs[imi]);
+		nedge2=mxGetNzmax(prhs[imi]);
+		if (mxGetNzmax(prhs[imi])) {
+			ir    =mxGetIr(prhs[imi]);
+			adjir = (int *) malloc(mxGetNzmax(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetNzmax(prhs[imi]); i++)
+				adjir[i]=(int)ir[i];
+		}
+		if (mxGetN(prhs[imi])) {
+			jc    =mxGetJc(prhs[imi]);
+			adjjc = (int *) malloc((mxGetN(prhs[imi])+1)*sizeof(int));
+			for (i=0; i<(mxGetN(prhs[imi])+1); i++)
+				adjjc[i]=(int)jc[i];
+		}
+		mexPrintf("%s -- Adjacency matrix is of size %d by %d with %d non-zeroes.\n",
+				  THISFUNCTION,mxGetM(prhs[imi]),mxGetN(prhs[imi]),mxGetNzmax(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex label vector must be numeric.\n",THISFUNCTION);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+			vld=mxGetPr(prhs[imi]);
+			vli = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+				vli[i]=(int)vld[i];
+		}
+		mexPrintf("%s -- Vertex label vector is of size %d by %d.\n",
+				  THISFUNCTION,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex weight vector must be numeric.\n",THISFUNCTION);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+			vwd=mxGetPr(prhs[imi]);
+			vwi = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+				vwi[i]=(int)vwd[i];
+		}
+		mexPrintf("%s -- Vertex weight vector is of size %d by %d.\n",
+				  THISFUNCTION,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi]) || (!mxIsEmpty(prhs[imi]) && !mxIsSparse(prhs[imi]))) {
+		mexPrintf("%s -- Edge weight matrix must be numeric and sparse.\n",THISFUNCTION);
+		mexErrMsgTxt(" ");
+	}
+	else {
+		if (mxGetM(prhs[imi])) {
+			ewd=mxGetPr(prhs[imi]);
+			ewi = (int *) malloc(mxGetM(prhs[imi])*sizeof(int));
+			for (i=0; i<mxGetNzmax(prhs[imi]); i++)
+				ewi[i]=(int)ewd[i];
+		}
+		mexPrintf("%s -- Edge weight matrix is of size %d by %d with %d non-zeroes.\n",
+				  THISFUNCTION,mxGetM(prhs[imi]),mxGetN(prhs[imi]),mxGetNzmax(prhs[imi]));
+	}
+	imi++;
+
+	if (!((strlen (argvm[0]) >= 5) &&
+		  (strncmp (argvm[0] + strlen (argvm[0]) - 5, "gpart", 5) == 0))) {
+		if (!mxIsChar(prhs[imi])) {
+			mexPrintf("%s -- Architecture type must be character.\n",THISFUNCTION);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+				archtyp = (char *) calloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])+1,sizeof(char));
+				mxGetString(prhs[imi],archtyp,mxGetM(prhs[imi])*mxGetN(prhs[imi])+1);
+			}
+			mexPrintf("%s -- Architecture type is \"%s\".\n",
+					  THISFUNCTION,archtyp);
+		}
+		imi++;
+
+		if (!mxIsNumeric(prhs[imi])) {
+			mexPrintf("%s -- Architecture parameter vector must be numeric.\n",THISFUNCTION);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			napar =mxGetM(prhs[imi])*mxGetN(prhs[imi]);
+			if (mxGetM(prhs[imi])*mxGetN(prhs[imi])) {
+				apd=mxGetPr(prhs[imi]);
+				api = (int *) malloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])*sizeof(int));
+				for (i=0; i<mxGetM(prhs[imi])*mxGetN(prhs[imi]); i++)
+					api[i]=(int)apd[i];
+			}
+			mexPrintf("%s -- Architecture parameter vector is of size %d by %d.\n",
+					  THISFUNCTION,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+		}
+		imi++;
+	}
+
+	while (imi < nrhs) {
+		if (!mxIsChar(prhs[imi])) {
+			mexPrintf("%s -- prhs[%d] must be character.\n",THISFUNCTION,imi);
+			mexErrMsgTxt(" ");
+		}
+		else {
+			argvm[isi] = (char *) calloc(mxGetM(prhs[imi])*mxGetN(prhs[imi])+1,sizeof(char));
+			mxGetString(prhs[imi],argvm[isi],mxGetM(prhs[imi])*mxGetN(prhs[imi])+1);
+		}
+		isi++;
+		imi++;
+	}
+	argcm=isi;
+	mexPrintf("argcm=%d\n",argcm);
+	for (i=0; i<argcm; i++)
+		mexPrintf("argvm[%d]=\"%s\"\n",i,argvm[i]);
+
+	/* Do the actual computations in a subroutine */
+
+	mexPrintf("Gmapx:\n");
+	ierr=gmapx(&maptabi,
+			   argcm,
+			   argvm,
+			   nvert,
+			   nedge2,
+			   adjir,
+			   adjjc,
+			   vli,
+			   vwi,
+			   ewi,
+			   archtyp,
+			   napar,
+			   api);
+	mexPrintf("%s -- Error %d from Gmapx.\n",THISFUNCTION,ierr);
+
+/*  for (i=0; i<nvert; i++)
+		mexPrintf("maptabi[%d][0]=%d, maptabi[%d][1]=%d\n",
+			 	  i,maptabi[i][0],i,maptabi[i][1]); */
+
+	/* Create matrices for the return arguments */
+
+	if (maptabi) {
+		plhs[imo]=mxCreateDoubleMatrix(nvert, 2, mxREAL);
+		maptabd = mxGetPr(plhs[imo]);
+		k=0;
+		for (j=0; j<2; j++)
+			for (i=0; i<nvert; i++)
+				maptabd[k++]=(double)maptabi[i][j];
+		free(maptabi);
+	}
+	else {
+		plhs[imo]=mxCreateDoubleMatrix(0, 2, mxREAL);
+	}
+	imo++;
+
+	if (argvm)
+		for (i=argcm-1; i>=0; i--)
+			free(argvm[i]);
+	if (api)     free(api);
+	if (archtyp) free(archtyp);
+	if (ewi)     free(ewi);
+	if (vwi)     free(vwi);
+	if (vli)     free(vli);
+	if (adjjc)   free(adjjc);
+	if (adjir)   free(adjir);
+
+	return;
+#endif //#ifndef _HAVE_SCOTCH_
+}
+
+void GmapUsage( void )
+{
+
+    mexPrintf("\n");
+    mexPrintf("Usage: [maptab]=Scotch(adjmat,vertlb,vertwt,edgewt,archtyp,archpar,\n");
+    mexPrintf("                         Scotch-specific parameters);\n");
+    mexPrintf("\n");
+
+    return;
+}
+
Index: /issm/trunk/src/mex/Scotch/Scotch.h
===================================================================
--- /issm/trunk/src/mex/Scotch/Scotch.h	(revision 4656)
+++ /issm/trunk/src/mex/Scotch/Scotch.h	(revision 4656)
@@ -0,0 +1,38 @@
+/*!\file:  Scotch.h
+ * \brief header file for Scotch module.
+ */ 
+
+#ifndef _SCOTCH_H
+#define _SCOTCH_H
+
+/* local prototypes: */
+void GmapUsage(void);
+
+#include <stdio.h>
+#include <string.h>    /*  strcasecmp  */
+#include <time.h>      /*  clock,time,difftime  */
+
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+    
+#undef __FUNCT__ 
+#define __FUNCT__  "Scotch"
+
+/*  Scotch structures and prototypes  */
+#ifdef MATLAB
+		#include "mat.h"
+		#include "mex.h"
+		#include "matrix.h"
+
+		#define printf mexPrintf
+		#define fprintf(file,...) (file == stdout || file == stderr ? mexPrintf(__VA_ARGS__) : fprintf(file,__VA_ARGS__))
+		#define malloc mxMalloc
+		#define calloc mxCalloc
+		#define realloc mxRealloc
+		#define free mxFree
+		#define exit(status) mexErrMsgTxt("exit=" #status)
+#endif
+
+
+#endif  /* _SCOTCH_H */
Index: /issm/trunk/test/Verification/test01_IceShelfIceFrontM2d/configuration.m
===================================================================
--- /issm/trunk/test/Verification/test01_IceShelfIceFrontM2d/configuration.m	(revision 4655)
+++ /issm/trunk/test/Verification/test01_IceShelfIceFrontM2d/configuration.m	(revision 4656)
@@ -3,5 +3,5 @@
 
 %meshing
-resolution=50000;
+resolution=5000;
 domainname='DomainOutline.exp';
 riftname='';
